(opts: {
abort: AbortSignal;
sessionId: string | null;
path: string;
model?: string;
modelReasoningEffort?: ReasoningEffort;
sandbox?: 'read-only' | 'workspace-write' | 'danger-full-access';
onSessionFound: (id: string) => void;
codexArgs?: string[];
mcpServers?: McpServersConfig;
sessionHook?: {
port: number;
token: string;
};
})
| 31 | } |
| 32 | |
| 33 | export async function codexLocal(opts: { |
| 34 | abort: AbortSignal; |
| 35 | sessionId: string | null; |
| 36 | path: string; |
| 37 | model?: string; |
| 38 | modelReasoningEffort?: ReasoningEffort; |
| 39 | sandbox?: 'read-only' | 'workspace-write' | 'danger-full-access'; |
| 40 | onSessionFound: (id: string) => void; |
| 41 | codexArgs?: string[]; |
| 42 | mcpServers?: McpServersConfig; |
| 43 | sessionHook?: { |
| 44 | port: number; |
| 45 | token: string; |
| 46 | }; |
| 47 | }): Promise<void> { |
| 48 | const args: string[] = []; |
| 49 | |
| 50 | if (opts.sessionId) { |
| 51 | args.push('resume', opts.sessionId); |
| 52 | opts.onSessionFound(opts.sessionId); |
| 53 | } |
| 54 | |
| 55 | if (opts.model) { |
| 56 | args.push('--model', opts.model); |
| 57 | } |
| 58 | |
| 59 | if (opts.modelReasoningEffort) { |
| 60 | args.push(...buildModelReasoningEffortConfigArgs(opts.modelReasoningEffort)); |
| 61 | } |
| 62 | |
| 63 | if (opts.sandbox) { |
| 64 | args.push('--sandbox', opts.sandbox); |
| 65 | } |
| 66 | |
| 67 | // Add MCP server configuration |
| 68 | if (opts.mcpServers && Object.keys(opts.mcpServers).length > 0) { |
| 69 | args.push(...buildMcpServerConfigArgs(opts.mcpServers)); |
| 70 | } |
| 71 | |
| 72 | if (opts.sessionHook) { |
| 73 | args.push(...buildSessionStartHookConfigArgs(opts.sessionHook.port, opts.sessionHook.token)); |
| 74 | } |
| 75 | |
| 76 | // Add developer instructions (system prompt) |
| 77 | args.push(...buildDeveloperInstructionsArg(codexSystemPrompt)); |
| 78 | |
| 79 | if (opts.codexArgs) { |
| 80 | const safeArgs = filterResumeSubcommand(opts.codexArgs); |
| 81 | args.push(...safeArgs); |
| 82 | } |
| 83 | |
| 84 | logger.debug(`[CodexLocal] Spawning codex with args: ${JSON.stringify(args)}`); |
| 85 | |
| 86 | if (opts.abort.aborted) { |
| 87 | logger.debug('[CodexLocal] Abort already signaled before spawn; skipping launch'); |
| 88 | return; |
| 89 | } |
| 90 |
no test coverage detected