mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
feat(providers): expose agent cwd to provider processes
This commit is contained in:
@@ -35,6 +35,7 @@ import type {
|
||||
AgentStreamEvent,
|
||||
AgentTimelineItem,
|
||||
ImportProviderSessionInput,
|
||||
ImportProviderSessionContext,
|
||||
ResolveAgentDefaultModeInput,
|
||||
} from "./agent-sdk-types.js";
|
||||
import type { PaseoToolCatalog } from "./tools/types.js";
|
||||
@@ -1706,6 +1707,7 @@ test("createAgent passes daemon launch env through the provider launch context",
|
||||
agentId: snapshot.id,
|
||||
env: {
|
||||
PASEO_AGENT_ID: snapshot.id,
|
||||
PASEO_AGENT_CWD: workdir,
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -2511,6 +2513,7 @@ test("resumeAgentFromPersistence keeps metadata config, applies overrides, and p
|
||||
agentId: resumed.id,
|
||||
env: {
|
||||
PASEO_AGENT_ID: resumed.id,
|
||||
PASEO_AGENT_CWD: workdir,
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -2525,14 +2528,16 @@ test("importProviderSession imports the selected session without listing and pub
|
||||
class ImportClient extends TestAgentClient {
|
||||
listCalls = 0;
|
||||
importInput: unknown = null;
|
||||
importLaunchContext: AgentLaunchContext | undefined;
|
||||
|
||||
async listImportableSessions() {
|
||||
this.listCalls += 1;
|
||||
return [];
|
||||
}
|
||||
|
||||
async importSession(input: ImportProviderSessionInput) {
|
||||
async importSession(input: ImportProviderSessionInput, context: ImportProviderSessionContext) {
|
||||
this.importInput = input;
|
||||
this.importLaunchContext = context.launchContext;
|
||||
return {
|
||||
session,
|
||||
config: { provider: "codex" as const, cwd: workdir },
|
||||
@@ -2612,6 +2617,13 @@ test("importProviderSession imports the selected session without listing and pub
|
||||
|
||||
expect(client.listCalls).toBe(0);
|
||||
expect(client.importInput).toEqual({ providerHandleId: "thread-selected", cwd: workdir });
|
||||
expect(client.importLaunchContext).toEqual({
|
||||
agentId: imported.id,
|
||||
env: {
|
||||
PASEO_AGENT_ID: imported.id,
|
||||
PASEO_AGENT_CWD: workdir,
|
||||
},
|
||||
});
|
||||
expect(imported.lifecycle).toBe("idle");
|
||||
expect(imported.historyPrimed).toBe(true);
|
||||
expect(manager.getTimeline(imported.id)).toEqual([
|
||||
@@ -2712,6 +2724,7 @@ test("reloadAgentSession passes daemon launch env through the provider launch co
|
||||
agentId: snapshot.id,
|
||||
env: {
|
||||
PASEO_AGENT_ID: snapshot.id,
|
||||
PASEO_AGENT_CWD: workdir,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2723,6 +2736,7 @@ test("reloadAgentSession passes daemon launch env through the provider launch co
|
||||
agentId: snapshot.id,
|
||||
env: {
|
||||
PASEO_AGENT_ID: snapshot.id,
|
||||
PASEO_AGENT_CWD: workdir,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1047,7 +1047,12 @@ export class AgentManager {
|
||||
const client = await this.requireAvailableClient({
|
||||
provider: storedConfig.provider,
|
||||
});
|
||||
const launchContext = await this.buildLaunchContext(resolvedAgentId, client, options?.env);
|
||||
const launchContext = await this.buildLaunchContext(
|
||||
resolvedAgentId,
|
||||
client,
|
||||
storedConfig.cwd,
|
||||
options?.env,
|
||||
);
|
||||
const providerLaunchConfig = this.resolveProviderLaunchConfig(launchConfig, launchContext);
|
||||
const createOptions = this.buildCreateSessionOptions(options);
|
||||
const session = await client.createSession(providerLaunchConfig, launchContext, createOptions);
|
||||
@@ -1125,7 +1130,7 @@ export class AgentManager {
|
||||
`Provider '${handle.provider}' is not available. Please ensure the CLI is installed.`,
|
||||
);
|
||||
}
|
||||
const launchContext = await this.buildLaunchContext(resolvedAgentId, client);
|
||||
const launchContext = await this.buildLaunchContext(resolvedAgentId, client, storedConfig.cwd);
|
||||
const providerLaunchConfig = this.resolveProviderLaunchConfig(launchConfig, launchContext);
|
||||
const session = await client.resumeSession(
|
||||
handle,
|
||||
@@ -1172,7 +1177,7 @@ export class AgentManager {
|
||||
},
|
||||
resolvedAgentId,
|
||||
);
|
||||
const launchContext = await this.buildLaunchContext(resolvedAgentId, client);
|
||||
const launchContext = await this.buildLaunchContext(resolvedAgentId, client, storedConfig.cwd);
|
||||
const providerLaunchConfig = this.resolveProviderLaunchConfig(launchConfig, launchContext);
|
||||
const imported = await client.importSession(
|
||||
{
|
||||
@@ -1253,7 +1258,7 @@ export class AgentManager {
|
||||
provider,
|
||||
} as AgentSessionConfig;
|
||||
const { storedConfig, launchConfig } = await this.prepareSessionConfig(refreshConfig, agentId);
|
||||
const launchContext = await this.buildLaunchContext(agentId, client);
|
||||
const launchContext = await this.buildLaunchContext(agentId, client, storedConfig.cwd);
|
||||
const providerLaunchConfig = this.resolveProviderLaunchConfig(launchConfig, launchContext);
|
||||
|
||||
const session = handle
|
||||
@@ -4253,6 +4258,7 @@ export class AgentManager {
|
||||
private async buildLaunchContext(
|
||||
agentId: string,
|
||||
client: AgentClient,
|
||||
cwd: string,
|
||||
env?: Record<string, string>,
|
||||
): Promise<AgentLaunchContext> {
|
||||
const context: AgentLaunchContext = {
|
||||
@@ -4260,6 +4266,7 @@ export class AgentManager {
|
||||
env: {
|
||||
...env,
|
||||
PASEO_AGENT_ID: agentId,
|
||||
PASEO_AGENT_CWD: cwd,
|
||||
},
|
||||
};
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user