feat(codex): implement CLI argument passthrough for codex

Collect unknown CLI arguments from index.ts and pass them through the execution chain (runCodex → loop → CodexSession → codexLocalLauncher → codexLocal), similar to how claude already works. This enables users to pass CLI arguments like --model and --sandbox to the underlying codex process.

Filter out the 'resume' subcommand which is managed internally by hapi, while allowing other CLI arguments to pass through. Add warning log in remote mode when CLI args are ignored since remote mode uses message-based configuration instead. Include unit tests for the resume filtering logic.
This commit is contained in:
weishu
2025-12-23 09:06:08 +08:00
parent 0128792495
commit f132a7dc79
8 changed files with 92 additions and 8 deletions
+2
View File
@@ -22,6 +22,7 @@ export { emitReadyIfIdle } from './utils/emitReadyIfIdle';
export async function runCodex(opts: {
startedBy?: 'daemon' | 'terminal';
codexArgs?: string[];
}): Promise<void> {
const workingDirectory = process.cwd();
const sessionTag = randomUUID();
@@ -188,6 +189,7 @@ export async function runCodex(opts: {
messageQueue,
api,
session,
codexArgs: opts.codexArgs,
onModeChange: (newMode) => {
session.sendSessionEvent({ type: 'switch', mode: newMode });
session.updateAgentState((currentState) => ({