MCPcopy
hub / github.com/opactorai/Claudable / executeCodex

Function executeCodex

lib/services/cli/codex.ts:482–1009  ·  view source on GitHub ↗
(
  projectId: string,
  projectPath: string,
  instruction: string,
  model: string,
  requestId?: string,
  isInitialPrompt: boolean = false,
)

Source from the content-addressed store, hash-verified

480}
481
482async 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',

Callers 2

initializeNextJsProjectFunction · 0.85
applyChangesFunction · 0.85

Calls 14

normalizeCodexModelIdFunction · 0.90
getCodexModelDisplayNameFunction · 0.90
markUserRequestAsRunningFunction · 0.90
markUserRequestAsFailedFunction · 0.90
CODEX_ENVFunction · 0.85
flushAssistantMessageFunction · 0.85
handleItemStartedFunction · 0.85
handleItemDeltaFunction · 0.85
handleItemCompletedFunction · 0.85
publishStatusFunction · 0.70
ensureProjectPathFunction · 0.70

Tested by

no test coverage detected