Inject agent-control MCP URL for codex session configs
This commit is contained in:
@@ -1256,10 +1256,8 @@ export class Session {
|
|||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const sessionConfig = await this.buildAgentSessionConfig(
|
const sessionConfig = this.withCodexAgentControl(
|
||||||
config,
|
await this.buildAgentSessionConfig(config, git, worktreeName)
|
||||||
git,
|
|
||||||
worktreeName
|
|
||||||
);
|
);
|
||||||
const snapshot = await this.agentManager.createAgent(sessionConfig);
|
const snapshot = await this.agentManager.createAgent(sessionConfig);
|
||||||
this.setCachedTitle(snapshot.id, null);
|
this.setCachedTitle(snapshot.id, null);
|
||||||
@@ -1354,7 +1352,14 @@ export class Session {
|
|||||||
`[Session ${this.clientId}] Resuming agent ${handle.sessionId} (${handle.provider})`
|
`[Session ${this.clientId}] Resuming agent ${handle.sessionId} (${handle.provider})`
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
const snapshot = await this.agentManager.resumeAgent(handle, overrides);
|
const normalizedOverrides = this.withCodexAgentControl(
|
||||||
|
overrides ?? {},
|
||||||
|
handle.provider
|
||||||
|
);
|
||||||
|
const snapshot = await this.agentManager.resumeAgent(
|
||||||
|
handle,
|
||||||
|
normalizedOverrides
|
||||||
|
);
|
||||||
this.setCachedTitle(snapshot.id, null);
|
this.setCachedTitle(snapshot.id, null);
|
||||||
await this.agentManager.primeAgentHistory(snapshot.id);
|
await this.agentManager.primeAgentHistory(snapshot.id);
|
||||||
await this.forwardAgentState(snapshot);
|
await this.forwardAgentState(snapshot);
|
||||||
@@ -1414,11 +1419,11 @@ export class Session {
|
|||||||
`Agent ${agentId} cannot be refreshed because it lacks persistence`
|
`Agent ${agentId} cannot be refreshed because it lacks persistence`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
snapshot = await this.agentManager.resumeAgent(
|
const overrides = this.withCodexAgentControl(
|
||||||
handle,
|
|
||||||
buildConfigOverrides(record),
|
buildConfigOverrides(record),
|
||||||
agentId
|
record.provider
|
||||||
);
|
);
|
||||||
|
snapshot = await this.agentManager.resumeAgent(handle, overrides, agentId);
|
||||||
this.setCachedTitle(agentId, null);
|
this.setCachedTitle(agentId, null);
|
||||||
}
|
}
|
||||||
await this.agentManager.primeAgentHistory(agentId);
|
await this.agentManager.primeAgentHistory(agentId);
|
||||||
@@ -1529,6 +1534,37 @@ export class Session {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private withCodexAgentControl<T extends Partial<AgentSessionConfig>>(
|
||||||
|
config: T,
|
||||||
|
providerOverride?: AgentProvider
|
||||||
|
): T {
|
||||||
|
const provider =
|
||||||
|
providerOverride ?? (config as AgentSessionConfig).provider;
|
||||||
|
if (provider !== "codex") {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
const agentControlMcpUrl = this.agentMcpConfig?.agentMcpUrl;
|
||||||
|
if (!agentControlMcpUrl) {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
const extra = (config.extra ?? {}) as AgentSessionConfig["extra"];
|
||||||
|
const codexExtra =
|
||||||
|
extra?.codex && typeof extra.codex === "object"
|
||||||
|
? { ...extra.codex }
|
||||||
|
: {};
|
||||||
|
if (typeof (codexExtra as Record<string, unknown>).agentControlMcpUrl !== "string") {
|
||||||
|
(codexExtra as Record<string, unknown>).agentControlMcpUrl =
|
||||||
|
agentControlMcpUrl;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...config,
|
||||||
|
extra: {
|
||||||
|
...extra,
|
||||||
|
codex: codexExtra,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private async handleGitRepoInfoRequest(
|
private async handleGitRepoInfoRequest(
|
||||||
msg: Extract<SessionInboundMessage, { type: "git_repo_info_request" }>
|
msg: Extract<SessionInboundMessage, { type: "git_repo_info_request" }>
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user