feat(codex): use hook to obtain the session id and transcript path

This commit is contained in:
weishu
2026-04-24 10:52:38 +08:00
parent 82703b85fb
commit 8e54bbeb53
8 changed files with 610 additions and 762 deletions
+13 -1
View File
@@ -1,6 +1,10 @@
import { logger } from '@/ui/logger';
import { spawnWithTerminalGuard } from '@/utils/spawnWithTerminalGuard';
import { buildMcpServerConfigArgs, buildDeveloperInstructionsArg } from './utils/codexMcpConfig';
import {
buildMcpServerConfigArgs,
buildDeveloperInstructionsArg,
buildSessionStartHookConfigArgs
} from './utils/codexMcpConfig';
import { codexSystemPrompt } from './utils/systemPrompt';
import type { ReasoningEffort } from './appServerTypes';
@@ -33,6 +37,10 @@ export async function codexLocal(opts: {
onSessionFound: (id: string) => void;
codexArgs?: string[];
mcpServers?: Record<string, { command: string; args: string[] }>;
sessionHook?: {
port: number;
token: string;
};
}): Promise<void> {
const args: string[] = [];
@@ -58,6 +66,10 @@ export async function codexLocal(opts: {
args.push(...buildMcpServerConfigArgs(opts.mcpServers));
}
if (opts.sessionHook) {
args.push(...buildSessionStartHookConfigArgs(opts.sessionHook.port, opts.sessionHook.token));
}
// Add developer instructions (system prompt)
args.push(...buildDeveloperInstructionsArg(codexSystemPrompt));