fix: add Code Queue steer confirmation
This commit is contained in:
+198
-25
@@ -3,6 +3,7 @@ import { runCommand } from "./command";
|
||||
import { type UniDeskConfig, repoRoot, rootPath } from "./config";
|
||||
import { coreInternalFetch } from "./microservices";
|
||||
import { previewJson } from "./preview";
|
||||
import { createSteerId, type SteerDeliveryState } from "../../src/components/microservices/code-queue/src/steer-confirmation";
|
||||
import {
|
||||
codeAgentPortForModel,
|
||||
codeExecutionModes,
|
||||
@@ -220,6 +221,7 @@ interface SubmitRoutingRecommendation {
|
||||
|
||||
interface CodexSteerOptions {
|
||||
prompt: string;
|
||||
steerId: string | undefined;
|
||||
dryRun: boolean;
|
||||
retryAttempts: number;
|
||||
retryDelayMs: number;
|
||||
@@ -227,6 +229,11 @@ interface CodexSteerOptions {
|
||||
raw: boolean;
|
||||
}
|
||||
|
||||
interface CodexSteerConfirmOptions {
|
||||
steerId: string;
|
||||
raw: boolean;
|
||||
}
|
||||
|
||||
type CodexSteerFailureReason =
|
||||
| "backend-core-unreachable"
|
||||
| "code-queue-microservice-unregistered"
|
||||
@@ -237,6 +244,8 @@ type CodexSteerFailureReason =
|
||||
| "stable-proxy-failed"
|
||||
| "invalid-proxy-response";
|
||||
|
||||
type CodexSteerAcceptanceStatus = "accepted" | "not_accepted" | "accepted_response_timeout" | "unknown";
|
||||
|
||||
interface ClassifiedCodexSteerError {
|
||||
reason: CodexSteerFailureReason;
|
||||
scope: "backend-core" | "stable-proxy" | "code-queue-runtime" | "unknown";
|
||||
@@ -261,8 +270,12 @@ interface CodexSteerAttemptSummary {
|
||||
scope: ClassifiedCodexSteerError["scope"] | null;
|
||||
retryable: boolean;
|
||||
message: string | null;
|
||||
deliveryState?: CodexSteerDeliveryState | null;
|
||||
steerId?: string | null;
|
||||
}
|
||||
|
||||
type CodexSteerDeliveryState = SteerDeliveryState;
|
||||
|
||||
interface CompactTaskMutationResponseOptions {
|
||||
fullPrompt?: boolean;
|
||||
}
|
||||
@@ -443,6 +456,18 @@ function codeQueueProxyEquivalentCommand(targetPath: string, bodyJson: string):
|
||||
return `bun scripts/cli.ts microservice proxy code-queue ${targetPath} --method POST --body-json '${bodyJson}'`;
|
||||
}
|
||||
|
||||
function steerConfirmationPath(taskId: string, steerId: string): string {
|
||||
return `/api/tasks/${encodeURIComponent(taskId)}/steer-confirmation${queryString({ steerId })}`;
|
||||
}
|
||||
|
||||
function steerConfirmationCommand(taskId: string, steerId: string): string {
|
||||
return `bun scripts/cli.ts codex steer-confirm ${taskId} --steer-id ${steerId}`;
|
||||
}
|
||||
|
||||
function rawSteerConfirmationCommand(taskId: string, steerId: string): string {
|
||||
return `bun scripts/cli.ts microservice proxy code-queue ${steerConfirmationPath(taskId, steerId)} --raw`;
|
||||
}
|
||||
|
||||
function nonNegativeIntegerEnv(name: string, fallback: number): number {
|
||||
const raw = process.env[name];
|
||||
if (raw === undefined || raw.trim().length === 0) return fallback;
|
||||
@@ -745,6 +770,57 @@ function compactSteerFailureDiagnostics(diagnostics: ClassifiedCodexSteerError,
|
||||
};
|
||||
}
|
||||
|
||||
function compactSteerTraceConfirmation(value: unknown, taskId: string, steerId: string): Record<string, unknown> {
|
||||
const record = asRecord(value) ?? {};
|
||||
const confirmation = asRecord(record.confirmation) ?? record;
|
||||
const trace = asRecord(confirmation.trace);
|
||||
return {
|
||||
taskId: asString(confirmation.taskId) || taskId,
|
||||
steerId: asString(confirmation.steerId) || steerId,
|
||||
found: confirmation.found === true,
|
||||
accepted: confirmation.accepted === true,
|
||||
deliveryState: asString(confirmation.deliveryState) || (confirmation.found === true ? "accepted" : "unknown"),
|
||||
matchCount: asNumber(confirmation.matchCount, 0),
|
||||
trace: trace === null ? null : {
|
||||
seq: trace.seq ?? null,
|
||||
at: trace.at ?? null,
|
||||
method: trace.method ?? null,
|
||||
steerId: trace.steerId ?? steerId,
|
||||
promptChars: trace.promptChars ?? null,
|
||||
promptHash: trace.promptHash ?? null,
|
||||
promptOmitted: true,
|
||||
source: trace.source ?? null,
|
||||
},
|
||||
duplicateSuppressionKey: confirmation.duplicateSuppressionKey ?? steerId,
|
||||
promptOmitted: true,
|
||||
};
|
||||
}
|
||||
|
||||
function fetchSteerTraceConfirmation(taskId: string, steerId: string, fetcher: CodexResponseFetcher): Record<string, unknown> {
|
||||
const response = unwrapCodexResponse(fetcher(codeQueueProxyPath(steerConfirmationPath(taskId, steerId))));
|
||||
return compactSteerTraceConfirmation(response.body, taskId, steerId);
|
||||
}
|
||||
|
||||
function safeFetchSteerTraceConfirmation(taskId: string, steerId: string, fetcher: CodexResponseFetcher): Record<string, unknown> {
|
||||
try {
|
||||
return fetchSteerTraceConfirmation(taskId, steerId, fetcher);
|
||||
} catch (error) {
|
||||
return {
|
||||
taskId,
|
||||
steerId,
|
||||
found: false,
|
||||
accepted: false,
|
||||
deliveryState: "unknown",
|
||||
promptOmitted: true,
|
||||
lookupError: error instanceof Error ? error.message : String(error),
|
||||
commands: {
|
||||
retryLookup: steerConfirmationCommand(taskId, steerId),
|
||||
rawLookup: rawSteerConfirmationCommand(taskId, steerId),
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function unwrapSteerResponse(response: unknown, targetPath: string, stableProxyPath: string, rawProxyEquivalent: string): { ok: true; upstream: { ok: unknown; status: unknown }; body: Record<string, unknown> } | { ok: false; diagnostics: ClassifiedCodexSteerError; rawResponse: unknown } {
|
||||
const record = asRecord(response);
|
||||
const body = responseBody(record);
|
||||
@@ -763,7 +839,7 @@ function terminalStatusFromTask(task: Record<string, unknown> | null): string {
|
||||
return "";
|
||||
}
|
||||
|
||||
function compactTerminalSteerRejection(taskId: string, response: unknown): Record<string, unknown> | null {
|
||||
function compactTerminalSteerRejection(taskId: string, steerId: string, response: unknown): Record<string, unknown> | null {
|
||||
const record = asRecord(response);
|
||||
const body = responseBody(record);
|
||||
const task = asRecord(body?.task);
|
||||
@@ -775,9 +851,12 @@ function compactTerminalSteerRejection(taskId: string, response: unknown): Recor
|
||||
ok: false,
|
||||
steer: {
|
||||
accepted: false,
|
||||
status: "not_accepted",
|
||||
deliveryState: "not_accepted",
|
||||
steerId,
|
||||
reason: "task-already-terminal",
|
||||
taskId,
|
||||
status,
|
||||
taskStatus: status,
|
||||
terminalStatus: terminalStatus || null,
|
||||
lastUpdate,
|
||||
updatedAt: task?.updatedAt ?? null,
|
||||
@@ -833,7 +912,7 @@ function attachSteerDisclosure(
|
||||
return result;
|
||||
}
|
||||
|
||||
function steerSuccessAttempt(attempt: number, durationMs: number, upstream: { ok: unknown; status: unknown }): CodexSteerAttemptSummary {
|
||||
function steerSuccessAttempt(attempt: number, durationMs: number, upstream: { ok: unknown; status: unknown }, steerId?: string, deliveryState: CodexSteerDeliveryState = "accepted"): CodexSteerAttemptSummary {
|
||||
const status = typeof upstream.status === "number" && Number.isFinite(upstream.status) ? upstream.status : null;
|
||||
return {
|
||||
attempt,
|
||||
@@ -845,6 +924,8 @@ function steerSuccessAttempt(attempt: number, durationMs: number, upstream: { ok
|
||||
scope: null,
|
||||
retryable: false,
|
||||
message: "steer accepted by Code Queue",
|
||||
deliveryState,
|
||||
steerId: steerId ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -859,6 +940,8 @@ function steerFailureAttempt(attempt: number, durationMs: number, diagnostics: C
|
||||
scope: diagnostics.scope,
|
||||
retryable: diagnostics.retryable,
|
||||
message: diagnostics.message,
|
||||
deliveryState: null,
|
||||
steerId: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2512,6 +2595,10 @@ export function codexSteerTaskForTest(taskId: string, optionArgs: string[], fetc
|
||||
return codexSteerTask(taskId, optionArgs, fetcher);
|
||||
}
|
||||
|
||||
export function codexSteerTraceConfirmForTest(taskId: string, optionArgs: string[], fetcher: CodexResponseFetcher): unknown {
|
||||
return codexSteerTraceConfirm(taskId, optionArgs, fetcher);
|
||||
}
|
||||
|
||||
function isTerminalTaskStatus(status: unknown): boolean {
|
||||
return status === "succeeded" || status === "failed" || status === "canceled";
|
||||
}
|
||||
@@ -3980,6 +4067,8 @@ const steerPromptValueOptions = new Set([
|
||||
"--file",
|
||||
"--retry-attempts",
|
||||
"--retry-delay-ms",
|
||||
"--steer-id",
|
||||
"--steerId",
|
||||
]);
|
||||
|
||||
function referenceTaskIdsFromOptions(args: string[]): string[] {
|
||||
@@ -4089,13 +4178,16 @@ function parseSubmitOptions(args: string[]): CodexSubmitOptions {
|
||||
function parseSteerOptions(args: string[]): CodexSteerOptions {
|
||||
assertKnownOptions(args, {
|
||||
flags: ["--prompt-stdin", "--stdin", "--dry-run", "--no-retry", "--full", "--raw"],
|
||||
valueOptions: ["--prompt-file", "--file", "--retry-attempts", "--retry-delay-ms"],
|
||||
valueOptions: ["--prompt-file", "--file", "--retry-attempts", "--retry-delay-ms", "--steer-id", "--steerId"],
|
||||
}, "codex steer");
|
||||
const retryAttempts = hasFlag(args, "--no-retry")
|
||||
? 1
|
||||
: positiveIntegerOption(args, ["--retry-attempts"], defaultSteerRetryAttempts, maxSteerRetryAttempts);
|
||||
const steerId = optionValue(args, ["--steer-id", "--steerId"]);
|
||||
if (steerId !== undefined && !/^[A-Za-z0-9._:-]{8,128}$/u.test(steerId)) throw new Error("--steer-id must be 8-128 chars using letters, numbers, dot, underscore, colon, or dash");
|
||||
return {
|
||||
prompt: promptFromArgs(args, "codex steer", steerPromptValueOptions),
|
||||
steerId,
|
||||
dryRun: hasFlag(args, "--dry-run"),
|
||||
retryAttempts,
|
||||
retryDelayMs: nonNegativeIntegerOption(args, ["--retry-delay-ms"], defaultSteerRetryDelayMs, maxSteerRetryDelayMs),
|
||||
@@ -4104,6 +4196,17 @@ function parseSteerOptions(args: string[]): CodexSteerOptions {
|
||||
};
|
||||
}
|
||||
|
||||
function parseSteerConfirmOptions(args: string[]): CodexSteerConfirmOptions {
|
||||
assertKnownOptions(args, {
|
||||
flags: ["--raw"],
|
||||
valueOptions: ["--steer-id", "--steerId"],
|
||||
}, "codex steer-confirm");
|
||||
const steerId = optionValue(args, ["--steer-id", "--steerId"]);
|
||||
if (steerId === undefined) throw new Error("codex steer-confirm requires --steer-id <id>");
|
||||
if (!/^[A-Za-z0-9._:-]{8,128}$/u.test(steerId)) throw new Error("--steer-id must be 8-128 chars using letters, numbers, dot, underscore, colon, or dash");
|
||||
return { steerId, raw: hasFlag(args, "--raw") };
|
||||
}
|
||||
|
||||
function parsePromptLintOptions(args: string[]): CodexPromptLintOptions {
|
||||
assertKnownOptions(args, {
|
||||
flags: ["--prompt-stdin", "--stdin"],
|
||||
@@ -4193,6 +4296,18 @@ function compactSubmitTaskConfirmation(task: unknown): Record<string, unknown> {
|
||||
};
|
||||
}
|
||||
|
||||
function compactSteerTaskConfirmation(task: unknown, steerId: string): Record<string, unknown> {
|
||||
const compact = compactSubmitTaskConfirmation(task);
|
||||
const commands = asRecord(compact.commands) ?? {};
|
||||
return {
|
||||
...compact,
|
||||
commands: {
|
||||
...commands,
|
||||
traceConfirm: steerConfirmationCommand(asString(compact.id) || "<taskId>", steerId),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function orderedUniqueStringList(values: string[]): string[] {
|
||||
const seen = new Set<string>();
|
||||
const items: string[] = [];
|
||||
@@ -6133,27 +6248,31 @@ function codexInterruptTask(taskId: string): unknown {
|
||||
function codexSteerTask(taskId: string, args: string[], fetcher: CodexResponseFetcher = coreInternalFetch): unknown {
|
||||
const options = parseSteerOptions(args);
|
||||
const promptLint = buildPromptLiveAuthorizationLint(options.prompt);
|
||||
const steerId = options.steerId ?? createSteerId(taskId, options.prompt);
|
||||
const targetPath = `/api/tasks/${encodeURIComponent(taskId)}/steer`;
|
||||
const stableProxyPath = codeQueueProxyPath(targetPath);
|
||||
const rawProxyEquivalent = codeQueueProxyEquivalentCommand(targetPath, "{\"prompt\":\"...\"}");
|
||||
const rawProxyEquivalent = codeQueueProxyEquivalentCommand(targetPath, `{"prompt":"...","steerId":"${steerId}"}`);
|
||||
const prompt = textView(options.prompt, false, steerPromptPreviewChars);
|
||||
const request = {
|
||||
path: targetPath,
|
||||
stableProxyPath,
|
||||
method: "POST",
|
||||
steerId,
|
||||
retryPolicy: {
|
||||
defaultAttempts: defaultSteerRetryAttempts,
|
||||
maxAttempts: options.retryAttempts,
|
||||
delayMs: options.retryDelayMs,
|
||||
retryableReasons: ["stable-proxy-failed", "backend-core-unreachable"],
|
||||
deliveryConfirmation: "success confirms Code Queue accepted the steer request; repeated stable-proxy failures mean delivery is unconfirmed",
|
||||
deliveryConfirmation: "success confirms Code Queue accepted the steer request; timeout-like failures trigger a bounded trace confirmation lookup by steerId",
|
||||
idempotency: "the same steerId is reused for every CLI retry and suppresses duplicate trace injection on a backend that supports the contract",
|
||||
},
|
||||
bodySummary: {
|
||||
steerId,
|
||||
promptChars: options.prompt.length,
|
||||
promptPreviewChars: steerPromptPreviewChars,
|
||||
promptTruncated: prompt.truncated,
|
||||
},
|
||||
body: { prompt },
|
||||
body: { steerId, prompt },
|
||||
};
|
||||
if (options.dryRun) {
|
||||
return {
|
||||
@@ -6162,8 +6281,9 @@ function codexSteerTask(taskId: string, args: string[], fetcher: CodexResponseFe
|
||||
promptLint,
|
||||
request,
|
||||
commands: {
|
||||
run: `bun scripts/cli.ts codex steer ${taskId} --prompt-file <path>`,
|
||||
noRetry: `bun scripts/cli.ts codex steer ${taskId} --prompt-file <path> --no-retry`,
|
||||
run: `bun scripts/cli.ts codex steer ${taskId} --prompt-file <path> --steer-id ${steerId}`,
|
||||
noRetry: `bun scripts/cli.ts codex steer ${taskId} --prompt-file <path> --steer-id ${steerId} --no-retry`,
|
||||
traceConfirm: steerConfirmationCommand(taskId, steerId),
|
||||
rawProxy: rawProxyEquivalent,
|
||||
},
|
||||
};
|
||||
@@ -6173,16 +6293,16 @@ function codexSteerTask(taskId: string, args: string[], fetcher: CodexResponseFe
|
||||
let successfulResponse: { ok: true; upstream: { ok: unknown; status: unknown }; body: Record<string, unknown> } | null = null;
|
||||
for (let attempt = 1; attempt <= options.retryAttempts; attempt += 1) {
|
||||
const startedAt = Date.now();
|
||||
const response = unwrapSteerResponse(fetcher(stableProxyPath, { method: "POST", body: { prompt: options.prompt } }), targetPath, stableProxyPath, rawProxyEquivalent);
|
||||
const response = unwrapSteerResponse(fetcher(stableProxyPath, { method: "POST", body: { prompt: options.prompt, steerId } }), targetPath, stableProxyPath, rawProxyEquivalent);
|
||||
const durationMs = Date.now() - startedAt;
|
||||
if (response.ok) {
|
||||
attempts.push(steerSuccessAttempt(attempt, durationMs, response.upstream));
|
||||
attempts.push(steerSuccessAttempt(attempt, durationMs, response.upstream, asString(response.body.steerId) || steerId, asString(response.body.deliveryState) as CodexSteerDeliveryState || "accepted"));
|
||||
successfulResponse = response;
|
||||
break;
|
||||
}
|
||||
attempts.push(steerFailureAttempt(attempt, durationMs, response.diagnostics));
|
||||
failedResponse = response;
|
||||
const terminalRejection = compactTerminalSteerRejection(taskId, response.rawResponse);
|
||||
const terminalRejection = compactTerminalSteerRejection(taskId, steerId, response.rawResponse);
|
||||
if (terminalRejection !== null) {
|
||||
terminalRejection.commands = {
|
||||
...(asRecord(terminalRejection.commands) ?? {}),
|
||||
@@ -6197,15 +6317,23 @@ function codexSteerTask(taskId: string, args: string[], fetcher: CodexResponseFe
|
||||
if (successfulResponse === null) {
|
||||
const diagnostics = failedResponse?.diagnostics ?? classifySteerFailure(null, targetPath, stableProxyPath, rawProxyEquivalent);
|
||||
const transportDeliveryUnconfirmed = diagnostics.reason === "stable-proxy-failed" || diagnostics.reason === "backend-core-unreachable";
|
||||
const traceConfirmation = transportDeliveryUnconfirmed ? safeFetchSteerTraceConfirmation(taskId, steerId, fetcher) : null;
|
||||
const confirmedAccepted = asBoolean(traceConfirmation?.accepted);
|
||||
const deliveryState = confirmedAccepted ? "accepted_response_timeout" : transportDeliveryUnconfirmed ? "unknown" : "not_accepted";
|
||||
const acceptanceStatus: CodexSteerAcceptanceStatus = confirmedAccepted ? "accepted_response_timeout" : transportDeliveryUnconfirmed ? "unknown" : "not_accepted";
|
||||
const compactDiagnostics = compactSteerFailureDiagnostics(diagnostics, options.full);
|
||||
return {
|
||||
ok: false,
|
||||
ok: confirmedAccepted,
|
||||
steer: {
|
||||
accepted: false,
|
||||
accepted: confirmedAccepted,
|
||||
status: acceptanceStatus,
|
||||
deliveryState,
|
||||
steerId,
|
||||
promptChars: options.prompt.length,
|
||||
promptOmitted: true,
|
||||
attempts,
|
||||
deliveryUnconfirmed: transportDeliveryUnconfirmed,
|
||||
deliveryUnconfirmed: transportDeliveryUnconfirmed && !confirmedAccepted,
|
||||
duplicateSuppressionKey: steerId,
|
||||
retryPolicy: {
|
||||
attempted: attempts.length,
|
||||
maxAttempts: options.retryAttempts,
|
||||
@@ -6233,18 +6361,23 @@ function codexSteerTask(taskId: string, args: string[], fetcher: CodexResponseFe
|
||||
},
|
||||
operatorGuidance: {
|
||||
rawProxyEquivalentIsFallback: false,
|
||||
deliveryUnconfirmed: transportDeliveryUnconfirmed,
|
||||
nextStep: transportDeliveryUnconfirmed
|
||||
? "Check task liveness and retry codex steer from the main-server CLI or explicit SSH transport; do not treat a raw proxy failure as separate evidence that the task rejected the correction."
|
||||
deliveryUnconfirmed: transportDeliveryUnconfirmed && !confirmedAccepted,
|
||||
traceConfirmationChecked: traceConfirmation !== null,
|
||||
nextStep: confirmedAccepted
|
||||
? "The stable proxy response timed out, but trace confirmation found this steerId. Do not resend the same corrective prompt."
|
||||
: transportDeliveryUnconfirmed
|
||||
? "Run the bounded trace confirmation command before retrying. If it remains unknown, retry with the same steerId to avoid duplicate trace injection on an updated backend."
|
||||
: "Inspect the non-retryable reason before resubmitting the correction.",
|
||||
},
|
||||
},
|
||||
traceConfirmation,
|
||||
commands: {
|
||||
dryRun: `bun scripts/cli.ts codex steer ${taskId} --prompt-file <path> --dry-run`,
|
||||
retry: `bun scripts/cli.ts codex steer ${taskId} --prompt-file <path>`,
|
||||
noRetry: `bun scripts/cli.ts codex steer ${taskId} --prompt-file <path> --no-retry`,
|
||||
fullDetails: `bun scripts/cli.ts codex steer ${taskId} --prompt-file <path> --full`,
|
||||
rawDetails: `bun scripts/cli.ts codex steer ${taskId} --prompt-file <path> --raw`,
|
||||
dryRun: `bun scripts/cli.ts codex steer ${taskId} --prompt-file <path> --steer-id ${steerId} --dry-run`,
|
||||
retry: `bun scripts/cli.ts codex steer ${taskId} --prompt-file <path> --steer-id ${steerId}`,
|
||||
noRetry: `bun scripts/cli.ts codex steer ${taskId} --prompt-file <path> --steer-id ${steerId} --no-retry`,
|
||||
traceConfirm: steerConfirmationCommand(taskId, steerId),
|
||||
fullDetails: `bun scripts/cli.ts codex steer ${taskId} --prompt-file <path> --steer-id ${steerId} --full`,
|
||||
rawDetails: `bun scripts/cli.ts codex steer ${taskId} --prompt-file <path> --steer-id ${steerId} --raw`,
|
||||
rawProxy: rawProxyEquivalent,
|
||||
tasks: "bun scripts/cli.ts codex tasks --view supervisor --limit 20",
|
||||
health: "bun scripts/cli.ts microservice health code-queue",
|
||||
@@ -6258,14 +6391,23 @@ function codexSteerTask(taskId: string, args: string[], fetcher: CodexResponseFe
|
||||
...(options.raw ? { rawFailure: failedResponse?.rawResponse ?? null } : {}),
|
||||
};
|
||||
}
|
||||
const responseSteerId = asString(successfulResponse.body.steerId) || steerId;
|
||||
const traceConfirmation = compactSteerTraceConfirmation(successfulResponse.body.traceConfirmation, taskId, responseSteerId);
|
||||
const deliveryState = asString(successfulResponse.body.deliveryState) || asString(traceConfirmation.deliveryState) || "accepted";
|
||||
const duplicateSuppressed = successfulResponse.body.duplicateSuppressed === true;
|
||||
return {
|
||||
ok: true,
|
||||
upstream: successfulResponse.upstream,
|
||||
steer: {
|
||||
accepted: true,
|
||||
status: "accepted",
|
||||
deliveryState,
|
||||
steerId: responseSteerId,
|
||||
taskId,
|
||||
promptChars: options.prompt.length,
|
||||
promptOmitted: true,
|
||||
duplicateSuppressed,
|
||||
duplicateSuppressionKey: responseSteerId,
|
||||
attempts,
|
||||
retryPolicy: {
|
||||
attempted: attempts.length,
|
||||
@@ -6280,18 +6422,45 @@ function codexSteerTask(taskId: string, args: string[], fetcher: CodexResponseFe
|
||||
reason: "codex steer is a write operation; default output confirms delivery and provides drill-down commands without echoing prompt text or full task state.",
|
||||
},
|
||||
},
|
||||
task: compactSubmitTaskConfirmation(successfulResponse.body.task),
|
||||
traceConfirmation,
|
||||
task: compactSteerTaskConfirmation(successfulResponse.body.task, responseSteerId),
|
||||
queue: compactSubmitQueueConfirmation(successfulResponse.body.queue),
|
||||
commands: {
|
||||
show: `bun scripts/cli.ts codex task ${taskId}`,
|
||||
detail: `bun scripts/cli.ts codex task ${taskId} --detail`,
|
||||
trace: `bun scripts/cli.ts codex task ${taskId} --trace --tail --limit ${defaultTraceLimit}`,
|
||||
traceConfirm: steerConfirmationCommand(taskId, responseSteerId),
|
||||
output: `bun scripts/cli.ts codex output ${taskId} --tail --limit ${defaultOutputLimit}`,
|
||||
supervisor: `bun scripts/cli.ts codex tasks --view supervisor --limit ${defaultTasksLimit}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function codexSteerTraceConfirm(taskId: string, args: string[], fetcher: CodexResponseFetcher = coreInternalFetch): unknown {
|
||||
const options = parseSteerConfirmOptions(args);
|
||||
const path = steerConfirmationPath(taskId, options.steerId);
|
||||
const response = unwrapCodexResponse(fetcher(codeQueueProxyPath(path)));
|
||||
const confirmation = compactSteerTraceConfirmation(response.body, taskId, options.steerId);
|
||||
return {
|
||||
ok: asBoolean(confirmation.accepted),
|
||||
upstream: response.upstream,
|
||||
traceConfirmation: confirmation,
|
||||
delivery: {
|
||||
steerId: options.steerId,
|
||||
status: asBoolean(confirmation.accepted) ? "accepted" : "unknown",
|
||||
deliveryState: confirmation.deliveryState,
|
||||
promptOmitted: true,
|
||||
},
|
||||
commands: {
|
||||
task: `bun scripts/cli.ts codex task ${taskId}`,
|
||||
trace: `bun scripts/cli.ts codex task ${taskId} --trace --tail --limit ${defaultTraceLimit}`,
|
||||
retrySameSteerId: `bun scripts/cli.ts codex steer ${taskId} --prompt-file <path> --steer-id ${options.steerId}`,
|
||||
rawLookup: rawSteerConfirmationCommand(taskId, options.steerId),
|
||||
},
|
||||
...(options.raw ? { raw: response.body } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
export async function runCodeQueueCommand(config: UniDeskConfig, args: string[]): Promise<unknown> {
|
||||
const [action = "task", taskIdArg] = args;
|
||||
if (action === "prompt-lint" || action === "lint-prompt") {
|
||||
@@ -6350,5 +6519,9 @@ export async function runCodeQueueCommand(config: UniDeskConfig, args: string[])
|
||||
const taskId = requireTaskId(taskIdArg, "codex steer");
|
||||
return codexSteerTask(taskId, args.slice(2));
|
||||
}
|
||||
throw new Error("codex command must be one of: prompt-lint, submit, enqueue, task, summary, show, tasks, overview, unread, terminal-unread, output, judge, read, mark-read, dev-ready, health, skills-sync, pr-preflight, runtime-preflight, queues, queue list, queue create, queue merge, move, steer, interrupt, cancel");
|
||||
if (action === "steer-confirm" || action === "steer-confirmation") {
|
||||
const taskId = requireTaskId(taskIdArg, `codex ${action}`);
|
||||
return codexSteerTraceConfirm(taskId, args.slice(2));
|
||||
}
|
||||
throw new Error("codex command must be one of: prompt-lint, submit, enqueue, task, summary, show, tasks, overview, unread, terminal-unread, output, judge, read, mark-read, dev-ready, health, skills-sync, pr-preflight, runtime-preflight, queues, queue list, queue create, queue merge, move, steer, steer-confirm, interrupt, cancel");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user