Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions plugins/codex/scripts/codex-companion.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function printUsage() {
" node scripts/codex-companion.mjs setup [--enable-review-gate|--disable-review-gate] [--json]",
" node scripts/codex-companion.mjs review [--wait|--background] [--base <ref>] [--scope <auto|working-tree|branch>]",
" node scripts/codex-companion.mjs adversarial-review [--wait|--background] [--base <ref>] [--scope <auto|working-tree|branch>] [focus text]",
" node scripts/codex-companion.mjs task [--background] [--write] [--resume-last|--resume|--fresh] [--model <model|spark>] [--effort <none|minimal|low|medium|high|xhigh>] [prompt]",
" node scripts/codex-companion.mjs task [--background] [--write] [--fast] [--resume-last|--resume|--fresh] [--model <model|spark>] [--effort <none|minimal|low|medium|high|xhigh>] [prompt]",
" node scripts/codex-companion.mjs status [job-id] [--all] [--json]",
" node scripts/codex-companion.mjs result [job-id] [--json]",
" node scripts/codex-companion.mjs cancel [job-id] [--json]"
Expand Down Expand Up @@ -486,6 +486,7 @@ async function executeTaskRun(request) {
model: request.model,
effort: request.effort,
sandbox: request.write ? "workspace-write" : "read-only",
serviceTier: request.fast ? "fast" : null,
onProgress: request.onProgress,
persistThread: true,
threadName: resumeThreadId ? null : buildPersistentTaskThreadName(request.prompt || DEFAULT_CONTINUE_PROMPT)
Expand Down Expand Up @@ -598,15 +599,16 @@ function buildTaskJob(workspaceRoot, taskMetadata, write) {
});
}

function buildTaskRequest({ cwd, model, effort, prompt, write, resumeLast, jobId }) {
function buildTaskRequest({ cwd, model, effort, prompt, write, resumeLast, jobId, fast }) {
return {
cwd,
model,
effort,
prompt,
write,
resumeLast,
jobId
jobId,
fast
};
}

Expand Down Expand Up @@ -732,7 +734,7 @@ async function handleReview(argv) {
async function handleTask(argv) {
const { options, positionals } = parseCommandInput(argv, {
valueOptions: ["model", "effort", "cwd", "prompt-file"],
booleanOptions: ["json", "write", "resume-last", "resume", "fresh", "background"],
booleanOptions: ["json", "write", "resume-last", "resume", "fresh", "background", "fast"],
aliasMap: {
m: "model"
}
Expand All @@ -750,6 +752,7 @@ async function handleTask(argv) {
throw new Error("Choose either --resume/--resume-last or --fresh.");
}
const write = Boolean(options.write);
const fast = Boolean(options.fast);
const taskMetadata = buildTaskRunMetadata({
prompt,
resumeLast
Expand All @@ -767,7 +770,8 @@ async function handleTask(argv) {
prompt,
write,
resumeLast,
jobId: job.id
jobId: job.id,
fast
});
const { payload } = enqueueBackgroundTask(cwd, job, request);
outputCommandResult(payload, renderQueuedTaskLaunch(payload), options.json);
Expand All @@ -784,6 +788,7 @@ async function handleTask(argv) {
effort,
prompt,
write,
fast,
resumeLast,
jobId: job.id,
onProgress: progress
Expand Down
14 changes: 12 additions & 2 deletions plugins/codex/scripts/lib/codex.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function cleanCodexStderr(stderr) {

/** @returns {ThreadStartParams} */
function buildThreadParams(cwd, options = {}) {
return {
const params = {
cwd,
model: options.model ?? null,
approvalPolicy: options.approvalPolicy ?? "never",
Expand All @@ -63,17 +63,25 @@ function buildThreadParams(cwd, options = {}) {
ephemeral: options.ephemeral ?? true,
experimentalRawEvents: false
};
if (options.serviceTier) {
params.serviceTier = options.serviceTier;
}
return params;
}

/** @returns {ThreadResumeParams} */
function buildResumeParams(threadId, cwd, options = {}) {
return {
const params = {
threadId,
cwd,
model: options.model ?? null,
approvalPolicy: options.approvalPolicy ?? "never",
sandbox: options.sandbox ?? "read-only"
};
if (options.serviceTier) {
params.serviceTier = options.serviceTier;
}
return params;
}

/** @returns {UserInput[]} */
Expand Down Expand Up @@ -975,6 +983,7 @@ export async function runAppServerTurn(cwd, options = {}) {
const response = await resumeThread(client, options.resumeThreadId, cwd, {
model: options.model,
sandbox: options.sandbox,
serviceTier: options.serviceTier,
ephemeral: false
});
threadId = response.thread.id;
Expand All @@ -983,6 +992,7 @@ export async function runAppServerTurn(cwd, options = {}) {
const response = await startThread(client, cwd, {
model: options.model,
sandbox: options.sandbox,
serviceTier: options.serviceTier,
ephemeral: options.persistThread ? false : true,
threadName: options.persistThread ? options.threadName : options.threadName ?? null
});
Expand Down