( projectId: string, projectPath: string, instruction: string, model: string, requestId?: string, isInitialPrompt: boolean = false, )
| 480 | } |
| 481 | |
| 482 | async function executeCodex( |
| 483 | projectId: string, |
| 484 | projectPath: string, |
| 485 | instruction: string, |
| 486 | model: string, |
| 487 | requestId?: string, |
| 488 | isInitialPrompt: boolean = false, |
| 489 | ): Promise<void> { |
| 490 | const normalizedModel = normalizeCodexModelId(model); |
| 491 | const modelDisplayName = getCodexModelDisplayName(normalizedModel); |
| 492 | publishStatus(projectId, 'starting', requestId); |
| 493 | |
| 494 | if (requestId) { |
| 495 | await markUserRequestAsRunning(requestId); |
| 496 | } |
| 497 | |
| 498 | const absoluteProjectPath = await ensureProjectPath(projectId, projectPath); |
| 499 | const repoPath = await (async () => { |
| 500 | const candidate = path.join(absoluteProjectPath, 'repo'); |
| 501 | try { |
| 502 | const stats = await fs.stat(candidate); |
| 503 | if (stats.isDirectory()) { |
| 504 | return candidate; |
| 505 | } |
| 506 | } catch { |
| 507 | // ignore |
| 508 | } |
| 509 | return absoluteProjectPath; |
| 510 | })(); |
| 511 | |
| 512 | publishStatus(projectId, 'ready', requestId, `Codex CLI detected (${modelDisplayName}). Starting execution...`); |
| 513 | |
| 514 | const promptBase = instruction.trim(); |
| 515 | const promptWithContext = await appendProjectContext(promptBase, repoPath); |
| 516 | |
| 517 | const codexConfigArgs = [ |
| 518 | '-c', |
| 519 | 'include_apply_patch_tool=true', |
| 520 | '-c', |
| 521 | 'include_plan_tool=true', |
| 522 | '-c', |
| 523 | 'tools.web_search_request=true', |
| 524 | '-c', |
| 525 | 'use_experimental_streamable_shell_tool=true', |
| 526 | '-c', |
| 527 | 'sandbox_mode=danger-full-access', |
| 528 | '-c', |
| 529 | 'max_turns=20', |
| 530 | '-c', |
| 531 | 'max_thinking_tokens=4096', |
| 532 | '-c', |
| 533 | `instructions=${JSON.stringify(AUTO_INSTRUCTIONS)}`, |
| 534 | ]; |
| 535 | |
| 536 | const codexArgs = [ |
| 537 | 'exec', |
| 538 | '--json', |
| 539 | '--skip-git-repo-check', |
no test coverage detected