MCPcopy Create free account
hub / github.com/SethGammon/Citadel / executeCodexScenario

Function executeCodexScenario

scripts/skill-bench.js:678–720  ·  view source on GitHub ↗
(scenario, codexCmd, tmpDir)

Source from the content-addressed store, hash-verified

676}
677
678function executeCodexScenario(scenario, codexCmd, tmpDir) {
679 const outputPath = path.join(tmpDir, '.planning', 'benchmark-results', `${scenario.skill}-${scenario.name}-codex.md`);
680 fs.mkdirSync(path.dirname(outputPath), { recursive: true });
681 const codexArgs = buildCodexExecArgs({
682 projectRoot: tmpDir,
683 sandbox: CODEX_SANDBOX,
684 model: CODEX_MODEL,
685 outputLastMessagePath: outputPath,
686 prompt: scenario.input,
687 json: true,
688 });
689 if (CODEX_SERVICE_TIER) {
690 codexArgs.splice(1, 0, '-c', `service_tier="${CODEX_SERVICE_TIER}"`);
691 }
692 try {
693 const output = execFileSync(
694 codexCmd,
695 codexArgs,
696 {
697 cwd: tmpDir,
698 timeout: scenario.timeout,
699 encoding: 'utf8',
700 env: {
701 ...process.env,
702 CITADEL_RUNTIME: 'codex',
703 },
704 maxBuffer: 10 * 1024 * 1024,
705 }
706 );
707 const finalMessage = fs.existsSync(outputPath) ? fs.readFileSync(outputPath, 'utf8') : '';
708 return { output: finalMessage || output, rawOutput: output, error: null, timedOut: false, command: ['codex', ...codexArgs].join(' ') };
709 } catch (err) {
710 if (err.killed) {
711 return { output: err.stdout || '', error: 'timed out', timedOut: true, command: ['codex', ...codexArgs].join(' ') };
712 }
713 return {
714 output: err.stdout || '',
715 error: err.message || 'unknown error',
716 timedOut: false,
717 command: ['codex', ...codexArgs].join(' '),
718 };
719 }
720}
721
722// ── Assertion running ─────────────────────────────────────────────────────────
723

Callers 1

mainFunction · 0.85

Calls 1

buildCodexExecArgsFunction · 0.85

Tested by

no test coverage detected