docs: record sub2api timeout closeout and agentrun cli updates

This commit is contained in:
Codex
2026-06-11 03:31:53 +00:00
parent b76987b342
commit 27f6e4812a
10 changed files with 1100 additions and 174 deletions
+20 -29
View File
@@ -27,10 +27,11 @@ assertCondition(
);
assertCondition(
agentRunUsage.some((line) => line.includes("queue submit --json-stdin --dry-run"))
&& agentRunUsage.some((line) => line.includes("queue dispatch <taskId> --json-stdin --dry-run"))
&& agentRunUsage.some((line) => line.includes("queue commander --reader-id cli --limit 20")),
"AgentRun help must expose stdin-first queue dry-run and compact commander usage",
agentRunUsage.some((line) => line.includes("agentrun get tasks --queue commander --limit 20"))
&& agentRunUsage.some((line) => line.includes("agentrun describe task/<taskId>"))
&& agentRunUsage.some((line) => line.includes("agentrun events run/<runId> --after-seq 0 --limit 100"))
&& agentRunUsage.some((line) => line.includes("agentrun logs session/<sessionId> --tail 100")),
"AgentRun help must expose Kubernetes-style resource observation primitives",
agentRunUsage,
);
@@ -41,37 +42,27 @@ assertCondition(
);
assertCondition(
agentRunUsage.some((line) => line.includes("queue show <taskId> --full"))
&& agentRunUsage.some((line) => line.includes("runs show <runId>"))
&& agentRunUsage.some((line) => line.includes("runs result <runId> --command-id <commandId>"))
&& agentRunUsage.some((line) => line.includes("commands show <commandId> --run-id <runId>"))
&& agentRunUsage.some((line) => line.includes("runner jobs --run-id <runId> --command-id <commandId>"))
&& agentRunUsage.some((line) => line.includes("runner job-status <runnerJobId> --run-id <runId>"))
&& !agentRunUsage.some((line) => line.includes("queue lifecycle")),
"AgentRun help must expose queue progressive disclosure through existing show/run/command/runner commands without a lifecycle command",
agentRunUsage.some((line) => line.includes("agentrun result run/<runId> --command <commandId>"))
&& agentRunUsage.some((line) => line.includes("agentrun ack task/<taskId> --reader-id cli"))
&& agentRunUsage.some((line) => line.includes("agentrun cancel task/<taskId> --reason <text> --dry-run"))
&& agentRunUsage.some((line) => line.includes("agentrun create task --aipod Artificer --prompt-stdin"))
&& agentRunUsage.some((line) => line.includes("agentrun apply -f - --dry-run"))
&& agentRunUsage.some((line) => line.includes("agentrun steer session/<sessionId> --prompt-stdin"))
&& agentRunUsage.some((line) => line.includes("agentrun send session/<sessionId> --aipod Artificer --prompt-stdin")),
"AgentRun help must expose resource lifecycle control primitives",
agentRunUsage,
);
const submitStdinIndex = agentRunUsage.findIndex((line) => line.includes("queue submit --json-stdin"));
const submitFileIndex = agentRunUsage.findIndex((line) => line.includes("queue submit --json-file"));
const dispatchStdinIndex = agentRunUsage.findIndex((line) => line.includes("queue dispatch <taskId> --json-stdin"));
const dispatchFileIndex = agentRunUsage.findIndex((line) => line.includes("queue dispatch <taskId> --json-file"));
assertCondition(
submitStdinIndex >= 0
&& dispatchStdinIndex >= 0
&& submitFileIndex > submitStdinIndex
&& dispatchFileIndex > dispatchStdinIndex
&& !agentRunUsage.some((line) => line.includes("queue submit --json-file <task.json> --dry-run"))
&& !agentRunUsage.some((line) => line.includes("queue dispatch <taskId> --json-file <dispatch.json> --dry-run")),
"AgentRun help must present heredoc/stdin before reusable file fallbacks",
agentRunUsage,
(agentRunHelp() as { output?: unknown }).output === "human by default; use -o json|yaml or --raw for machine/debug output",
"AgentRun help must declare human output as the default and machine output as opt-in",
agentRunHelp(),
);
const globalHelp = JSON.stringify(rootHelp());
assertCondition(
globalHelp.includes("agentrun aipod-specs|queue|runs|commands|runner|sessions|control-plane|git-mirror"),
globalHelp.includes("agentrun get|describe|events|logs|result|ack|cancel|create|apply|steer|send"),
"global help must index AgentRun v0.1 entrypoints",
rootHelp(),
);
@@ -105,10 +96,10 @@ console.log(JSON.stringify({
checks: [
"AgentRun command help exposes cleanup-runs and cleanup-released-pvs",
"AgentRun command help exposes targeted control-plane status drill-down options",
"AgentRun command help exposes queue dry-run and compact commander usage",
"AgentRun command help exposes resource observation primitives",
"AgentRun command help hides the v01 lane from user-facing CLI entrypoints",
"AgentRun command help exposes queue progressive disclosure without queue lifecycle",
"AgentRun command help presents heredoc/stdin before reusable file fallbacks",
"AgentRun command help exposes resource lifecycle control primitives",
"AgentRun command help declares human output by default",
"global help indexes AgentRun v0.1 entrypoints",
"AgentRun control-plane status degrades empty runtime JSON snippets",
"AgentRun CLI bridge selects remote frontend backend in runner/no-Docker environments",
+17 -10
View File
@@ -1,7 +1,7 @@
import { readConfig } from "./src/config";
import { debugDispatch, debugHealth, debugTask, isDebugDispatchCommand, type DebugDispatchCommand } from "./src/debug";
import { isRebuildableService, rebuildService, stackLogs, stackStatus, startStack, stopStack, unsupportedRebuildService } from "./src/docker";
import { emitError, emitJson } from "./src/output";
import { emitError, emitJson, emitText, isRenderedCliResult } from "./src/output";
import { cancelJob, jobWithTail, listJobs, listJobsSummary, readJob, runJob } from "./src/jobs";
import { checkHelp, parseCheckOptions, runChecks, runRecoveryGuardrailsCheck } from "./src/check";
import { runSsh } from "./src/ssh";
@@ -232,6 +232,22 @@ async function main(): Promise<void> {
return;
}
if (top === "agentrun") {
const { runAgentRunCommand } = await import("./src/agentrun");
const agentRunArgs = args.slice(1);
const config = agentRunArgs.length === 0 || agentRunArgs.some(isHelpToken) ? null : readConfig();
const result = await runAgentRunCommand(config, agentRunArgs);
const ok = (result as { ok?: unknown }).ok !== false;
if (isRenderedCliResult(result)) {
emitText(result.renderedText);
if (!ok) process.exitCode = 1;
return;
}
emitJson(commandName, result, ok);
if (!ok) process.exitCode = 1;
return;
}
const namespaceHelp = await staticNamespaceHelp(args);
if (namespaceHelp !== null) {
emitJson(commandName, namespaceHelp);
@@ -313,15 +329,6 @@ async function main(): Promise<void> {
return;
}
if (top === "agentrun") {
const { runAgentRunCommand } = await import("./src/agentrun");
const result = await runAgentRunCommand(readConfig(), args.slice(1));
const ok = (result as { ok?: unknown }).ok !== false;
emitJson(commandName, result, ok);
if (!ok) process.exitCode = 1;
return;
}
if (top === "platform-infra") {
const { runPlatformInfraCommand } = await import("./src/platform-infra");
const result = await runPlatformInfraCommand(readConfig(), args.slice(1));
+956 -45
View File
File diff suppressed because it is too large Load Diff
+27 -27
View File
@@ -57,7 +57,7 @@ export function rootHelp(): unknown {
{ command: "commander contract|plan --dry-run|smoke --dry-run|approval request --dry-run|prompt-lint --kind gpt55-pr", description: "Host Codex commander skeleton contract, no-daemon smoke plan, dry-run approval preview, and advisory GPT-5.5 PR prompt boundary lint without live bridges, message sends, or submit gating." },
{ command: "hwlab nodes control-plane|git-mirror|secret --node G14 --lane v03", description: "Manage HWLAB node/lane runtime prerequisites for v0.3+ with the node identity passed as data instead of a command family." },
{ command: "hwlab g14 monitor-prs | hwlab g14 control-plane status|apply|trigger-current|runtime-migration|cleanup-runs|cleanup-released-pvs | hwlab g14 git-mirror status|apply|sync|flush | hwlab g14 tools-image status|build", description: "Start the legacy G14 PR monitor, run bounded v0.2 Tekton/Argo control-plane, manual PipelineRun trigger, runtime migration, CI workspace retention, manual devops-infra git mirror/relay maintenance, or fixed HWLAB CI tools image actions; long confirmed trigger/sync/flush actions return async jobs by default." },
{ command: "agentrun aipod-specs|queue|runs|commands|runner|sessions|control-plane|git-mirror", description: "Use AgentRun v0.1 AipodSpec, Queue, Run, Command, read-only runner status, and Sessions through the official G14 CLI bridge, plus bounded Tekton/Argo and git-mirror operations." },
{ command: "agentrun get|describe|events|logs|result|ack|cancel|create|apply|steer|send|control-plane|git-mirror", description: "Use AgentRun v0.1 resource primitives with low-noise human output by default; legacy bridge groups remain available for raw compatibility." },
{ command: "platform-infra sub2api plan|apply|status|validate|codex-pool", description: "Deploy Sub2API in G14 platform-infra, manage the YAML-controlled Codex upstream pool, expose the unified API through FRP when needed, and configure master ~/.codex without printing API keys." },
{ command: "hwlab cd audit --env dev | hwlab cd status --env dev | hwlab cd apply --env dev --dry-run", description: "Legacy D601 HWLAB DEV CD wrapper kept for explicit old-path diagnostics; current HWLAB rollout uses G14 GitOps." },
{ command: "code-agent-sandbox", description: "Independent Code Agent Sandbox service skeleton for adapter, mode, and credential-boundary diagnostics." },
@@ -65,7 +65,7 @@ export function rootHelp(): unknown {
{ command: "schedule upsert-pgdata-backup [--time HH:MM] [--remote-base /SERVER_DATA/UNIDESK_PG_DATA]", description: "Create or update the daily PGDATA physical backup task that uploads monthly rotated archives to Baidu Netdisk." },
{ command: "codex deploy <commitId> [--provider-id D601] [--timeout-ms N]", description: "Disabled legacy Code Queue deploy path; use the dev-only artifact consumer instead." },
{ command: "codex prompt-lint [prompt|--prompt-file path|--prompt-stdin]", description: "Dry-run lint a runner prompt for DEV test class read-only/live-read/live-mutating authorization without echoing prompt text or touching live services." },
{ command: "codex submit|steer|resume|queue create|queue merge|move", description: "Frozen legacy Code Queue write commands; use agentrun queue and agentrun sessions for new commander work. Historical codex task/tasks/output/read/unread/queues remain available for archive troubleshooting." },
{ command: "codex submit|steer|resume|queue create|queue merge|move", description: "Frozen legacy Code Queue write commands; use agentrun create/apply/steer/send for new commander work. Historical codex task/tasks/output/read/unread/queues remain available for archive troubleshooting." },
{ command: "codex skills-sync --dry-run [--full]", description: "Inspect the controlled runner skills hostPath lifecycle contract without copying files, restarting services, reading secrets, or mutating live runner paths." },
{ command: "codex execution-plane [--full|--raw]", description: "Read-only D601 native k3s Code Queue execution-plane inspection; compares formal deployments, deprecated Compose residuals, commit markers, pod digest, and mounted worktree HEAD." },
{ command: "codex pr-preflight [--remote] [--push-dry-run --push-dry-run-ref refs/heads/probe/<name>] [--pr-create-dry-run --pr-create-dry-run-head <head>] [--issue N] [--full|--raw]", description: "Read-only PR admission check with compact commander output by default; use --full or --raw to expand the full runtime preflight, tool, and observation payload." },
@@ -76,10 +76,10 @@ export function rootHelp(): unknown {
{ command: "codex read <taskId>", description: "Mark one reviewed terminal task read and return terminal metadata plus final response; prompt/tool logs stay behind drill-down commands." },
{ command: "codex dev-ready", description: "Fetch execution-container readiness, including sanitized skill injection status from /api/dev-ready." },
{ command: "codex judge <taskId> --attempt N [--dry-run] [--include-prompt]", description: "Replay one stored Code Queue attempt through the same judge context builder and MiniMax judge call path used by the live queue worker." },
{ command: "codex steer <taskId> / codex resume <taskId>", description: "Frozen legacy execution mutation entries; use agentrun sessions steer/read/cancel/output/trace against AgentRun sessions instead." },
{ command: "codex steer <taskId> / codex resume <taskId>", description: "Frozen legacy execution mutation entries; use agentrun steer/send/logs/events/result/ack/cancel against AgentRun resources instead." },
{ command: "codex steer-confirm <taskId> --steer-id <id> [--raw]", description: "Read-only lookup for a steerId in task trace so deliveryUnconfirmed can be resolved without resending the corrective prompt." },
{ command: "codex interrupt|cancel <taskId>", description: "Request interrupt for a running Code Queue task, or cancel a queued/retry_wait task, through the same private proxy." },
{ command: "codex queues [--full|--all] [--limit N] [--page N|--offset N]", description: "Read legacy Code Queue archive summaries. Legacy queue create/merge and move are frozen; use agentrun queue for new work." },
{ command: "codex queues [--full|--all] [--limit N] [--page N|--offset N]", description: "Read legacy Code Queue archive summaries. Legacy queue create/merge and move are frozen; use agentrun create/apply/get/cancel for new work." },
{ command: "job list [--limit N] [--include-command]", description: "List async jobs from .state/jobs with a bounded default page and progress summaries." },
{ command: "job status <jobId|latest> [--tail-bytes N]", description: "Show job state with a structured progress summary and bounded stdout/stderr tails." },
{ command: "job cancel <jobId>", description: "Cancel a queued/running async job through the .state/jobs control entry and keep a terminal canceled record." },
@@ -385,11 +385,11 @@ function codexHelp(): unknown {
usage: [
"bun scripts/cli.ts codex deploy <commitId> # disabled legacy deployment entry",
"bun scripts/cli.ts codex prompt-lint [prompt|--prompt-file path|--prompt-stdin]",
"bun scripts/cli.ts agentrun queue commander --reader-id cli",
"bun scripts/cli.ts agentrun aipod-specs show Artificer",
"bun scripts/cli.ts agentrun queue submit --aipod Artificer --prompt-stdin",
"bun scripts/cli.ts agentrun queue submit --json-stdin <<'JSON'",
"bun scripts/cli.ts agentrun sessions trace <sessionId> --after-seq 0 --limit 100",
"bun scripts/cli.ts agentrun get tasks --queue commander --limit 20",
"bun scripts/cli.ts agentrun describe aipodspec/Artificer",
"bun scripts/cli.ts agentrun create task --aipod Artificer --prompt-stdin",
"bun scripts/cli.ts agentrun apply -f - --dry-run",
"bun scripts/cli.ts agentrun logs session/<sessionId> --tail 100",
"bun scripts/cli.ts codex submit # frozen legacy write entry; returns legacy-code-queue-frozen",
"bun scripts/cli.ts codex task <taskId> [--detail] [--trace --tail|--from-start|--after-seq N|--before-seq N --limit N] [--full]",
"bun scripts/cli.ts codex tasks [--view commander|supervisor|full] [--queue id] [--status succeeded,running] [--unread|--unread-only] [--limit N] [--before-id id]",
@@ -402,7 +402,7 @@ function codexHelp(): unknown {
"bun scripts/cli.ts codex execution-plane [--full|--raw]",
"bun scripts/cli.ts codex pr-preflight [--remote] [--push-dry-run --push-dry-run-ref refs/heads/probe/<name>] [--pr-create-dry-run --pr-create-dry-run-head <head>] [--issue N] [--full|--raw]",
"bun scripts/cli.ts codex judge <taskId> --attempt N [--dry-run] [--include-prompt]",
"bun scripts/cli.ts agentrun sessions steer <sessionId> --prompt-stdin",
"bun scripts/cli.ts agentrun steer session/<sessionId> --prompt-stdin",
"bun scripts/cli.ts codex steer <taskId> # frozen legacy write entry",
"bun scripts/cli.ts codex resume <taskId> # frozen legacy write entry",
"bun scripts/cli.ts codex steer-confirm <taskId> --steer-id <id> [--raw]",
@@ -419,11 +419,11 @@ function codexHelp(): unknown {
executionMode: {
validModes: ["default", "windows-native"],
boundary: "Legacy Code Queue submit is frozen; new runtime placement is selected by AgentRun Queue payloads.",
permissionVisibility: "Legacy Code Queue read commands expose historical runner metadata only; new tasks use AgentRun Queue/Sessions.",
permissionVisibility: "Legacy Code Queue read commands expose historical runner metadata only; new tasks use AgentRun resource primitives.",
},
submitSummary: {
default: "codex submit/enqueue now returns ok=false, frozen=true, degradedReason=legacy-code-queue-frozen and AgentRun replacement commands.",
replacement: "Use bun scripts/cli.ts agentrun queue submit --json-stdin with a quoted heredoc for new one-shot work; reserve --json-file for reusable reviewed files.",
replacement: "Use bun scripts/cli.ts agentrun apply -f - with a quoted YAML heredoc for structured work, or agentrun create task --aipod Artificer --prompt-stdin for one prompt task.",
noDoubleWrite: "UniDesk does not mirror AgentRun submissions into old Code Queue and does not migrate old history into AgentRun.",
rawDrillDown: "Use codex tasks/task/output/read/unread/queues only for legacy archive inspection.",
},
@@ -453,10 +453,10 @@ function codexHelp(): unknown {
},
examples: {
promptLint: "bun scripts/cli.ts codex prompt-lint --prompt-file /tmp/code-queue-prompt.md",
agentRunCommander: "bun scripts/cli.ts agentrun queue commander --reader-id cli",
agentRunAipod: "bun scripts/cli.ts agentrun queue submit --aipod Artificer --prompt-stdin",
agentRunSubmit: "bun scripts/cli.ts agentrun queue submit --json-stdin <<'JSON'",
agentRunTrace: "bun scripts/cli.ts agentrun sessions trace <sessionId> --after-seq 0 --limit 100",
agentRunCommander: "bun scripts/cli.ts agentrun get tasks --queue commander --limit 20",
agentRunAipod: "bun scripts/cli.ts agentrun create task --aipod Artificer --prompt-stdin",
agentRunSubmit: "bun scripts/cli.ts agentrun apply -f - --dry-run",
agentRunTrace: "bun scripts/cli.ts agentrun logs session/<sessionId> --tail 100",
frozenLegacySubmit: "bun scripts/cli.ts codex submit --prompt-file /tmp/code-queue-prompt.md",
},
disclosure: {
@@ -482,7 +482,7 @@ function codexHelp(): unknown {
embeddedIn: [],
reference: "docs/reference/code-queue-supervision.md#dev-测试授权分级",
},
description: "Operate legacy Code Queue as a read-only archive through bounded task/output/read/unread/queues views. New task dispatch, retry/resume, steer, queue mutation, move, and workdir mutation are frozen and replaced by AgentRun Queue/Sessions via bun scripts/cli.ts agentrun queue|sessions.",
description: "Operate legacy Code Queue as a read-only archive through bounded task/output/read/unread/queues views. New task dispatch, retry/resume, steer, queue mutation, move, and workdir mutation are frozen and replaced by AgentRun resource primitives via bun scripts/cli.ts agentrun get|describe|events|logs|result|ack|cancel|create|apply|steer|send.",
};
}
@@ -597,19 +597,19 @@ function artifactRegistryHelp(): unknown {
function agentRunHelpSummary(): unknown {
return {
command: "agentrun aipod-specs|queue|runs|commands|runner|sessions|control-plane|git-mirror",
output: "json",
command: "agentrun get|describe|events|logs|result|ack|cancel|create|apply|steer|send|control-plane|git-mirror",
output: "human by default; use -o json|yaml or --raw",
usage: [
"bun scripts/cli.ts agentrun aipod-specs show Artificer",
"bun scripts/cli.ts agentrun queue commander --reader-id cli",
"bun scripts/cli.ts agentrun queue show <taskId>",
"bun scripts/cli.ts agentrun runs show <runId>",
"bun scripts/cli.ts agentrun commands show <commandId> --run-id <runId>",
"bun scripts/cli.ts agentrun runner jobs --run-id <runId> --command-id <commandId>",
"bun scripts/cli.ts agentrun sessions trace <sessionId> --after-seq 0 --limit 100",
"bun scripts/cli.ts agentrun get tasks --queue commander --limit 20",
"bun scripts/cli.ts agentrun describe task/<taskId>",
"bun scripts/cli.ts agentrun events run/<runId> --after-seq 0 --limit 100",
"bun scripts/cli.ts agentrun logs session/<sessionId> --tail 100",
"bun scripts/cli.ts agentrun result run/<runId> --command <commandId>",
"bun scripts/cli.ts agentrun ack task/<taskId>",
"bun scripts/cli.ts agentrun create task --aipod Artificer --prompt-stdin",
"bun scripts/cli.ts agentrun control-plane status",
],
description: "Operate AgentRun v0.1 AipodSpec, queue, run, command, read-only runner status, sessions, and G14 control-plane entrypoints with progressive disclosure: queue commander -> queue show -> runs/commands/runner/session detail.",
description: "Operate AgentRun v0.1 resources with Kubernetes-style verbs and progressive disclosure. Legacy queue/runs/commands/runner/sessions bridge groups remain for raw compatibility.",
};
}
+19
View File
@@ -10,6 +10,13 @@ export interface JsonEnvelope<T> {
error?: unknown;
}
export interface RenderedCliResult {
ok: boolean;
command: string;
renderedText: string;
contentType: "text/plain" | "application/json" | "application/yaml";
}
const GH_OUTPUT_DUMP_THRESHOLD_BYTES = 20 * 1024;
const OUTPUT_DUMP_PREVIEW_CHARS = 2000;
const OUTPUT_DUMP_DIR = join(tmpdir(), "unidesk-cli-output");
@@ -33,6 +40,18 @@ export function emitJson<T>(command: string, data: T, ok = true): void {
safeStdoutWrite(renderEnvelope(command, envelope));
}
export function isRenderedCliResult(value: unknown): value is RenderedCliResult {
return typeof value === "object"
&& value !== null
&& typeof (value as { renderedText?: unknown }).renderedText === "string"
&& typeof (value as { command?: unknown }).command === "string"
&& typeof (value as { ok?: unknown }).ok === "boolean";
}
export function emitText(text: string): void {
safeStdoutWrite(text.endsWith("\n") ? text : `${text}\n`);
}
export function emitError(command: string, error: unknown): void {
const payload = normalizeErrorPayload(command, error);
const envelope: JsonEnvelope<never> = { ok: false, command, error: payload };