Files
boss/local-agent/codex-task-runner.mjs

52 lines
1.2 KiB
JavaScript

export function buildCodexTaskExecution(config, task, outputFile) {
const targetThreadRef =
String(task?.targetCodexThreadRef || task?.targetThreadId || "").trim();
const targetFolderRef =
String(task?.targetCodexFolderRef || config.masterAgentWorkdir || process.cwd()).trim() ||
process.cwd();
const prompt = String(task?.executionPrompt || "");
if (
targetThreadRef &&
(task?.taskType === "conversation_reply" || task?.taskType === "dispatch_execution")
) {
const args = [
"exec",
"resume",
"--skip-git-repo-check",
"-o",
outputFile,
];
if (config.masterAgentModel) {
args.push("-m", config.masterAgentModel);
}
args.push(targetThreadRef, prompt);
return {
mode: "resume",
cwd: targetFolderRef,
args,
};
}
const args = [
"exec",
"--ephemeral",
"--skip-git-repo-check",
"-C",
config.masterAgentWorkdir || process.cwd(),
"-s",
config.masterAgentSandbox || "workspace-write",
"-o",
outputFile,
];
if (config.masterAgentModel) {
args.push("-m", config.masterAgentModel);
}
args.push(prompt);
return {
mode: "ephemeral",
cwd: config.masterAgentWorkdir || process.cwd(),
args,
};
}