fix: simplify agentrun cli entrypoints
This commit is contained in:
@@ -34,6 +34,24 @@ assertCondition(
|
||||
agentRunUsage,
|
||||
);
|
||||
|
||||
assertCondition(
|
||||
!agentRunUsage.some((line) => line.includes("agentrun v01")),
|
||||
"AgentRun help must hide the v01 lane from user-facing CLI entrypoints",
|
||||
agentRunUsage,
|
||||
);
|
||||
|
||||
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,
|
||||
);
|
||||
|
||||
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"));
|
||||
@@ -53,7 +71,7 @@ assertCondition(
|
||||
const globalHelp = JSON.stringify(rootHelp());
|
||||
|
||||
assertCondition(
|
||||
globalHelp.includes("agentrun v01 aipod-specs|queue|sessions|control-plane|git-mirror"),
|
||||
globalHelp.includes("agentrun aipod-specs|queue|runs|commands|runner|sessions|control-plane|git-mirror"),
|
||||
"global help must index AgentRun v0.1 entrypoints",
|
||||
rootHelp(),
|
||||
);
|
||||
@@ -73,6 +91,8 @@ console.log(JSON.stringify({
|
||||
"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 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",
|
||||
"global help indexes AgentRun v0.1 entrypoints",
|
||||
"AgentRun control-plane status degrades empty runtime JSON snippets",
|
||||
|
||||
@@ -31,6 +31,9 @@ const commandName = displayCommandName(args);
|
||||
|
||||
function displayCommandName(parts: string[]): string {
|
||||
if (parts.length === 0) return "help";
|
||||
if (parts[0] === "agentrun" && parts[1] === "v01") {
|
||||
return ["agentrun", ...parts.slice(2)].join(" ").trim();
|
||||
}
|
||||
if (parts[0] === "codex" && (parts[1] === "submit" || parts[1] === "enqueue")) {
|
||||
const shown = ["codex", parts[1]];
|
||||
const shownValueOptions = new Set([
|
||||
|
||||
@@ -58,7 +58,7 @@ function assertLegacyFrozenWrite(result: { status: number | null; stdout: string
|
||||
assertCondition(data.degradedReason === "legacy-code-queue-frozen", `${command} should use the legacy frozen reason`, data);
|
||||
assertCondition(data.command === command, `${command} frozen payload should identify the command`, data);
|
||||
const replacement = nestedRecord(data, ["replacement"]);
|
||||
assertCondition(String(replacement.sessionsSteer || "").includes("agentrun v01 sessions steer"), `${command} should point to AgentRun sessions steer`, replacement);
|
||||
assertCondition(String(replacement.sessionsSteer || "").includes("agentrun sessions steer"), `${command} should point to AgentRun sessions steer`, replacement);
|
||||
const legacy = nestedRecord(data, ["legacy"]);
|
||||
assertCondition(legacy.noDoubleWrite === true, `${command} should document no double-write`, legacy);
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ function assertLegacyFrozenWrite(result: { status: number | null; stdout: string
|
||||
assertCondition(data.degradedReason === "legacy-code-queue-frozen", `${command} should use the legacy frozen reason`, data);
|
||||
assertCondition(data.command === command, `${command} frozen payload should identify the command`, data);
|
||||
const replacement = nestedRecord(data, ["replacement"]);
|
||||
assertCondition(String(replacement.queueSubmit || "").includes("agentrun v01 queue submit"), `${command} should point to AgentRun queue submit`, replacement);
|
||||
assertCondition(String(replacement.sessionsSteer || "").includes("agentrun v01 sessions steer"), `${command} should point to AgentRun sessions steer`, replacement);
|
||||
assertCondition(String(replacement.queueSubmit || "").includes("agentrun queue submit"), `${command} should point to AgentRun queue submit`, replacement);
|
||||
assertCondition(String(replacement.sessionsSteer || "").includes("agentrun sessions steer"), `${command} should point to AgentRun sessions steer`, replacement);
|
||||
const legacy = nestedRecord(data, ["legacy"]);
|
||||
assertCondition(legacy.noDoubleWrite === true, `${command} should document no double-write`, legacy);
|
||||
}
|
||||
@@ -145,8 +145,8 @@ export function runCodeQueueCliSubmitPromptContract(): JsonRecord {
|
||||
assertCondition(recommended.includes("--prompt-stdin") && recommended.includes("--prompt-file"), "help should recommend stdin and file prompt sources", promptInput);
|
||||
assertCondition(String(promptInput.sourceRule || "").includes("Exactly one prompt source"), "help should document exact prompt source rule", promptInput);
|
||||
assertCondition(String(submitSummary.default || "").includes("legacy-code-queue-frozen"), "help submit summary should document frozen reason", submitSummary);
|
||||
assertCondition(String(submitSummary.replacement || "").includes("agentrun v01 queue submit"), "help should point new submissions at AgentRun", submitSummary);
|
||||
assertCondition(String(examples.agentRunSubmit || "").includes("agentrun v01 queue submit"), "help examples should include AgentRun submit", examples);
|
||||
assertCondition(String(submitSummary.replacement || "").includes("agentrun queue submit"), "help should point new submissions at AgentRun", submitSummary);
|
||||
assertCondition(String(examples.agentRunSubmit || "").includes("agentrun queue submit"), "help examples should include AgentRun submit", examples);
|
||||
|
||||
return {
|
||||
ok: true,
|
||||
|
||||
@@ -34,8 +34,8 @@ function assertLegacyFrozenWrite(result: { status: number | null; stdout: string
|
||||
assertCondition(data.mutation === false, `${command} frozen payload should be non-mutating`, data);
|
||||
assertCondition(data.degradedReason === "legacy-code-queue-frozen", `${command} should use the legacy frozen reason`, data);
|
||||
const replacement = nestedRecord(data, ["replacement"]);
|
||||
assertCondition(String(replacement.queueSubmit || "").includes("agentrun v01 queue submit"), `${command} should point to AgentRun queue submit`, replacement);
|
||||
assertCondition(String(replacement.sessionsSteer || "").includes("agentrun v01 sessions steer"), `${command} should point to AgentRun sessions steer`, replacement);
|
||||
assertCondition(String(replacement.queueSubmit || "").includes("agentrun queue submit"), `${command} should point to AgentRun queue submit`, replacement);
|
||||
assertCondition(String(replacement.sessionsSteer || "").includes("agentrun sessions steer"), `${command} should point to AgentRun sessions steer`, replacement);
|
||||
}
|
||||
|
||||
function runCli(args: string[], stdin?: string): { status: number | null; stdout: string; stderr: string; json: JsonRecord | null } {
|
||||
|
||||
@@ -91,7 +91,7 @@ function assertLegacyFrozenWrite(result: { status: number | null; stdout: string
|
||||
assertCondition(data.degradedReason === "legacy-code-queue-frozen", `${command} should use the legacy frozen reason`, data);
|
||||
assertCondition(data.command === command, `${command} frozen payload should identify the command`, data);
|
||||
const replacement = nestedRecord(data, ["replacement"]);
|
||||
assertCondition(String(replacement.sessionsSteer || "").includes("agentrun v01 sessions steer"), `${command} should point to AgentRun sessions steer`, replacement);
|
||||
assertCondition(String(replacement.sessionsSteer || "").includes("agentrun sessions steer"), `${command} should point to AgentRun sessions steer`, replacement);
|
||||
const legacy = nestedRecord(data, ["legacy"]);
|
||||
assertCondition(legacy.noDoubleWrite === true, `${command} should document no double-write`, legacy);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ function assertLegacyFrozenWrite(result: { status: number | null; stdout: string
|
||||
assertCondition(data.mutation === false, `${command} frozen payload should be non-mutating`, data);
|
||||
assertCondition(data.degradedReason === "legacy-code-queue-frozen", `${command} should use the legacy frozen reason`, data);
|
||||
const replacement = nestedRecord(data, ["replacement"]);
|
||||
assertCondition(String(replacement.queueSubmit || "").includes("agentrun v01 queue submit"), `${command} should point to AgentRun queue submit`, replacement);
|
||||
assertCondition(String(replacement.queueSubmit || "").includes("agentrun queue submit"), `${command} should point to AgentRun queue submit`, replacement);
|
||||
const legacy = nestedRecord(data, ["legacy"]);
|
||||
assertCondition(legacy.noDoubleWrite === true, `${command} should document no double-write`, legacy);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ assertCondition(
|
||||
&& storageBody.includes('"agentrun"')
|
||||
&& storageBody.includes('"byOwnerGroup"')
|
||||
&& storageBody.includes("hwlab g14 control-plane cleanup-runs")
|
||||
&& storageBody.includes("agentrun v01 control-plane cleanup-runs")
|
||||
&& storageBody.includes("agentrun control-plane cleanup-runs")
|
||||
&& storageBody.includes("hostPath")
|
||||
&& storageBody.includes("activeMountPods")
|
||||
&& storageBody.includes("estimatedBytes")
|
||||
|
||||
@@ -50,7 +50,7 @@ function assertLegacyFrozenWrite(result: { status: number | null; stdout: string
|
||||
assertCondition(data.mutation === false, `${command} frozen payload should be non-mutating`, data);
|
||||
assertCondition(data.degradedReason === "legacy-code-queue-frozen", `${command} should use the legacy frozen reason`, data);
|
||||
const replacement = asRecord(data.replacement, "replacement");
|
||||
assertCondition(String(replacement.queueSubmit || "").includes("agentrun v01 queue submit"), `${command} should point to AgentRun queue submit`, replacement);
|
||||
assertCondition(String(replacement.queueSubmit || "").includes("agentrun queue submit"), `${command} should point to AgentRun queue submit`, replacement);
|
||||
}
|
||||
|
||||
const completePrompt = `
|
||||
|
||||
+176
-94
@@ -23,76 +23,113 @@ const mirrorToolsImage = "127.0.0.1:5000/hwlab/hwlab-ci-node-tools:node22-alpine
|
||||
|
||||
export function agentRunHelp(): unknown {
|
||||
return {
|
||||
command: "agentrun v01 control-plane status|trigger-current|refresh|cleanup-runs|cleanup-released-pvs | git-mirror status|sync|flush | aipod-specs list|show|render|apply|delete | queue submit|list|show|stats|commander|read|cancel|dispatch|refresh | sessions ps|show|turn|steer|cancel|output|trace|read",
|
||||
command: "agentrun control-plane status|trigger-current|refresh|cleanup-runs|cleanup-released-pvs | git-mirror status|sync|flush | aipod-specs list|show|render|apply|delete | queue submit|list|show|stats|commander|read|cancel|dispatch|refresh | runs show|events|result | commands show|result | runner jobs|job-status | sessions ps|show|turn|steer|cancel|output|trace|read",
|
||||
output: "json",
|
||||
usage: [
|
||||
"bun scripts/cli.ts agentrun v01 queue commander --reader-id cli",
|
||||
"bun scripts/cli.ts agentrun v01 queue commander --reader-id cli --limit 20",
|
||||
"bun scripts/cli.ts agentrun v01 aipod-specs list",
|
||||
"bun scripts/cli.ts agentrun v01 aipod-specs show Artificer",
|
||||
"bun scripts/cli.ts agentrun v01 aipod-specs render Artificer --prompt-stdin",
|
||||
"bun scripts/cli.ts agentrun v01 aipod-specs apply --yaml-stdin --dry-run",
|
||||
"bun scripts/cli.ts agentrun v01 queue submit --json-stdin <<'JSON'",
|
||||
"bun scripts/cli.ts agentrun v01 queue submit --json-stdin --dry-run <<'JSON'",
|
||||
"bun scripts/cli.ts agentrun v01 queue submit --aipod Artificer --prompt-stdin --idempotency-key <key>",
|
||||
"bun scripts/cli.ts agentrun v01 queue submit --aipod Artificer --prompt-stdin --dry-run",
|
||||
"bun scripts/cli.ts agentrun v01 queue submit --json-file <task.json> # reusable reviewed file fallback",
|
||||
"bun scripts/cli.ts agentrun v01 queue dispatch <taskId> --json-stdin <<'JSON'",
|
||||
"bun scripts/cli.ts agentrun v01 queue dispatch <taskId> --json-stdin --dry-run <<'JSON'",
|
||||
"bun scripts/cli.ts agentrun v01 queue dispatch <taskId> --json-file <dispatch.json> # reusable reviewed file fallback",
|
||||
"bun scripts/cli.ts agentrun v01 queue cancel <taskId> --reason <text> --dry-run",
|
||||
"bun scripts/cli.ts agentrun v01 sessions trace <sessionId> --after-seq 0 --limit 100",
|
||||
"bun scripts/cli.ts agentrun v01 sessions output <sessionId> --after-seq 0 --limit 100",
|
||||
"bun scripts/cli.ts agentrun v01 sessions turn --aipod Artificer --prompt-stdin",
|
||||
"bun scripts/cli.ts agentrun v01 sessions steer <sessionId> --prompt-stdin",
|
||||
"bun scripts/cli.ts agentrun v01 sessions read <sessionId> --reader-id cli",
|
||||
"bun scripts/cli.ts agentrun v01 control-plane status",
|
||||
"bun scripts/cli.ts agentrun v01 control-plane status --full",
|
||||
"bun scripts/cli.ts agentrun v01 control-plane status --pipeline-run agentrun-v01-ci-<short-sha>",
|
||||
"bun scripts/cli.ts agentrun v01 control-plane status --source-commit <full-sha>",
|
||||
"bun scripts/cli.ts agentrun v01 control-plane trigger-current --dry-run",
|
||||
"bun scripts/cli.ts agentrun v01 control-plane trigger-current --confirm",
|
||||
"bun scripts/cli.ts agentrun v01 control-plane refresh --dry-run",
|
||||
"bun scripts/cli.ts agentrun v01 control-plane refresh --confirm",
|
||||
"bun scripts/cli.ts agentrun v01 control-plane cleanup-runs --min-age-minutes 30 --limit 200 --dry-run",
|
||||
"bun scripts/cli.ts agentrun v01 control-plane cleanup-runs --min-age-minutes 30 --limit 200 --confirm",
|
||||
"bun scripts/cli.ts agentrun v01 control-plane cleanup-released-pvs --limit 200 --dry-run",
|
||||
"bun scripts/cli.ts agentrun v01 control-plane cleanup-released-pvs --limit 200 --confirm",
|
||||
"bun scripts/cli.ts agentrun v01 git-mirror status",
|
||||
"bun scripts/cli.ts agentrun v01 git-mirror status --full",
|
||||
"bun scripts/cli.ts agentrun v01 git-mirror sync --confirm",
|
||||
"bun scripts/cli.ts agentrun v01 git-mirror flush --confirm",
|
||||
"bun scripts/cli.ts agentrun queue commander --reader-id cli",
|
||||
"bun scripts/cli.ts agentrun queue commander --reader-id cli --limit 20",
|
||||
"bun scripts/cli.ts agentrun queue commander --reader-id cli --full",
|
||||
"bun scripts/cli.ts agentrun queue commander --reader-id cli --raw",
|
||||
"bun scripts/cli.ts agentrun aipod-specs list",
|
||||
"bun scripts/cli.ts agentrun aipod-specs show Artificer",
|
||||
"bun scripts/cli.ts agentrun aipod-specs render Artificer --prompt-stdin",
|
||||
"bun scripts/cli.ts agentrun aipod-specs apply --yaml-stdin --dry-run",
|
||||
"bun scripts/cli.ts agentrun queue submit --json-stdin <<'JSON'",
|
||||
"bun scripts/cli.ts agentrun queue submit --json-stdin --dry-run <<'JSON'",
|
||||
"bun scripts/cli.ts agentrun queue submit --aipod Artificer --prompt-stdin --idempotency-key <key>",
|
||||
"bun scripts/cli.ts agentrun queue submit --aipod Artificer --prompt-stdin --dry-run",
|
||||
"bun scripts/cli.ts agentrun queue submit --json-file <task.json> # reusable reviewed file fallback",
|
||||
"bun scripts/cli.ts agentrun queue show <taskId>",
|
||||
"bun scripts/cli.ts agentrun queue show <taskId> --full",
|
||||
"bun scripts/cli.ts agentrun queue show <taskId> --raw",
|
||||
"bun scripts/cli.ts agentrun queue dispatch <taskId> --json-stdin <<'JSON'",
|
||||
"bun scripts/cli.ts agentrun queue dispatch <taskId> --json-stdin --dry-run <<'JSON'",
|
||||
"bun scripts/cli.ts agentrun queue dispatch <taskId> --json-file <dispatch.json> # reusable reviewed file fallback",
|
||||
"bun scripts/cli.ts agentrun queue cancel <taskId> --reason <text> --dry-run",
|
||||
"bun scripts/cli.ts agentrun runs show <runId>",
|
||||
"bun scripts/cli.ts agentrun runs show <runId> --full",
|
||||
"bun scripts/cli.ts agentrun runs result <runId> --command-id <commandId>",
|
||||
"bun scripts/cli.ts agentrun runs events <runId> --after-seq 0 --limit 100 --tail-summary",
|
||||
"bun scripts/cli.ts agentrun commands show <commandId> --run-id <runId>",
|
||||
"bun scripts/cli.ts agentrun commands show <commandId> --run-id <runId> --full",
|
||||
"bun scripts/cli.ts agentrun commands result <commandId> --run-id <runId>",
|
||||
"bun scripts/cli.ts agentrun runner jobs --run-id <runId> --command-id <commandId>",
|
||||
"bun scripts/cli.ts agentrun runner job-status <runnerJobId> --run-id <runId>",
|
||||
"bun scripts/cli.ts agentrun sessions trace <sessionId> --after-seq 0 --limit 100",
|
||||
"bun scripts/cli.ts agentrun sessions output <sessionId> --after-seq 0 --limit 100",
|
||||
"bun scripts/cli.ts agentrun sessions turn --aipod Artificer --prompt-stdin",
|
||||
"bun scripts/cli.ts agentrun sessions steer <sessionId> --prompt-stdin",
|
||||
"bun scripts/cli.ts agentrun sessions read <sessionId> --reader-id cli",
|
||||
"bun scripts/cli.ts agentrun control-plane status",
|
||||
"bun scripts/cli.ts agentrun control-plane status --full",
|
||||
"bun scripts/cli.ts agentrun control-plane status --pipeline-run agentrun-v01-ci-<short-sha>",
|
||||
"bun scripts/cli.ts agentrun control-plane status --source-commit <full-sha>",
|
||||
"bun scripts/cli.ts agentrun control-plane trigger-current --dry-run",
|
||||
"bun scripts/cli.ts agentrun control-plane trigger-current --confirm",
|
||||
"bun scripts/cli.ts agentrun control-plane refresh --dry-run",
|
||||
"bun scripts/cli.ts agentrun control-plane refresh --confirm",
|
||||
"bun scripts/cli.ts agentrun control-plane cleanup-runs --min-age-minutes 30 --limit 200 --dry-run",
|
||||
"bun scripts/cli.ts agentrun control-plane cleanup-runs --min-age-minutes 30 --limit 200 --confirm",
|
||||
"bun scripts/cli.ts agentrun control-plane cleanup-released-pvs --limit 200 --dry-run",
|
||||
"bun scripts/cli.ts agentrun control-plane cleanup-released-pvs --limit 200 --confirm",
|
||||
"bun scripts/cli.ts agentrun git-mirror status",
|
||||
"bun scripts/cli.ts agentrun git-mirror status --full",
|
||||
"bun scripts/cli.ts agentrun git-mirror sync --confirm",
|
||||
"bun scripts/cli.ts agentrun git-mirror flush --confirm",
|
||||
],
|
||||
description: "Operate AgentRun v0.1 Queue, Sessions, and AipodSpec through the official G14 /root/agentrun-v01 CLI, plus bounded Tekton/Argo control-plane and devops-infra git mirror actions through UniDesk routes. Queue/session/aipod-spec commands are direct AgentRun CLI calls, not a UniDesk Code Queue adapter or double-write path.",
|
||||
description: "Operate AgentRun v0.1 Queue, Sessions, Runs, Commands, Runner job status, and AipodSpec through the official G14 /root/agentrun-v01 CLI, plus bounded Tekton/Argo control-plane and devops-infra git mirror actions through UniDesk routes. Queue/session/aipod-spec/run/command/runner-read commands are direct AgentRun CLI calls, not a UniDesk Code Queue adapter or double-write path.",
|
||||
};
|
||||
}
|
||||
|
||||
export async function runAgentRunCommand(config: UniDeskConfig, args: string[]): Promise<Record<string, unknown>> {
|
||||
const [lane, group, action] = args;
|
||||
if (lane !== "v01") return unsupported(args);
|
||||
const route = normalizeAgentRunCommandArgs(args);
|
||||
const { group, action, actionArgs } = route;
|
||||
if (group === "control-plane") {
|
||||
if (action === "status") return await status(config, parseStatusOptions(args.slice(3)));
|
||||
if (action === "trigger-current") return await triggerCurrent(config, parseTriggerOptions(args.slice(3)));
|
||||
if (action === "refresh") return await refresh(config, parseConfirmOptions(args.slice(3)));
|
||||
if (action === "cleanup-runs") return await cleanupRuns(config, parseCleanupRunsOptions(args.slice(3)));
|
||||
if (action === "cleanup-released-pvs") return await cleanupReleasedPvs(config, parseCleanupReleasedPvOptions(args.slice(3)));
|
||||
if (action === "status") return await status(config, parseStatusOptions(actionArgs));
|
||||
if (action === "trigger-current") return await triggerCurrent(config, parseTriggerOptions(actionArgs));
|
||||
if (action === "refresh") return await refresh(config, parseConfirmOptions(actionArgs));
|
||||
if (action === "cleanup-runs") return await cleanupRuns(config, parseCleanupRunsOptions(actionArgs));
|
||||
if (action === "cleanup-released-pvs") return await cleanupReleasedPvs(config, parseCleanupReleasedPvOptions(actionArgs));
|
||||
}
|
||||
if (group === "git-mirror") {
|
||||
if (action === "status") return await gitMirrorStatus(config, parseDisclosureOptions(args.slice(3)));
|
||||
if (action === "status") return await gitMirrorStatus(config, parseDisclosureOptions(actionArgs));
|
||||
if (action === "sync" || action === "flush") {
|
||||
const options = parseGitMirrorOptions(args.slice(3));
|
||||
if (options.confirm && !options.wait) return startAsyncAgentRunJob(`agentrun_v01_git_mirror_${action}`, ["bun", "scripts/cli.ts", "agentrun", "v01", "git-mirror", action, "--confirm", "--wait", "--timeout-seconds", String(options.timeoutSeconds)], `Run AgentRun v0.1 git mirror ${action} on G14`);
|
||||
const options = parseGitMirrorOptions(actionArgs);
|
||||
if (options.confirm && !options.wait) return startAsyncAgentRunJob(`agentrun_v01_git_mirror_${action}`, ["bun", "scripts/cli.ts", "agentrun", "git-mirror", action, "--confirm", "--wait", "--timeout-seconds", String(options.timeoutSeconds)], `Run AgentRun v0.1 git mirror ${action} on G14`);
|
||||
return await runGitMirrorJob(config, action, options);
|
||||
}
|
||||
}
|
||||
if (isOfficialAgentRunCliBridgeGroup(group)) {
|
||||
return await runOfficialAgentRunCli(config, group, args.slice(2));
|
||||
if (group === "runner" && (action === "jobs" || action === "job-status")) {
|
||||
return await runOfficialAgentRunCli(config, group, route.forwardArgs);
|
||||
}
|
||||
return unsupported(args);
|
||||
if (isOfficialAgentRunCliBridgeGroup(group)) {
|
||||
return await runOfficialAgentRunCli(config, group, route.forwardArgs);
|
||||
}
|
||||
return unsupported(route.canonicalArgs);
|
||||
}
|
||||
|
||||
function isOfficialAgentRunCliBridgeGroup(group: string | undefined): group is AgentRunOfficialCliBridgeGroup {
|
||||
return group === "queue" || group === "sessions" || group === "aipod-specs" || group === "aipods";
|
||||
return group === "queue" || group === "sessions" || group === "aipod-specs" || group === "aipods" || group === "runs" || group === "commands";
|
||||
}
|
||||
|
||||
interface AgentRunCommandRoute {
|
||||
canonicalArgs: string[];
|
||||
group: string | undefined;
|
||||
action: string | undefined;
|
||||
actionArgs: string[];
|
||||
forwardArgs: string[];
|
||||
}
|
||||
|
||||
function normalizeAgentRunCommandArgs(args: string[]): AgentRunCommandRoute {
|
||||
const canonicalArgs = args[0] === "v01" ? args.slice(1) : args;
|
||||
const [group, action, ...actionArgs] = canonicalArgs;
|
||||
return {
|
||||
canonicalArgs,
|
||||
group,
|
||||
action,
|
||||
actionArgs,
|
||||
forwardArgs: canonicalArgs.slice(1),
|
||||
};
|
||||
}
|
||||
|
||||
interface TriggerOptions {
|
||||
@@ -189,6 +226,7 @@ function parseStatusOptions(args: string[]): StatusOptions {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function parseTriggerOptions(args: string[]): TriggerOptions {
|
||||
return parseConfirmOptions(args);
|
||||
}
|
||||
@@ -360,7 +398,7 @@ async function status(config: UniDeskConfig, options: StatusOptions): Promise<Re
|
||||
};
|
||||
return {
|
||||
ok: source.exitCode === 0 && k3s.exitCode === 0 && mirror.ok === true,
|
||||
command: "agentrun v01 control-plane status",
|
||||
command: "agentrun control-plane status",
|
||||
lane: "v0.1",
|
||||
summary,
|
||||
target,
|
||||
@@ -397,16 +435,16 @@ async function status(config: UniDeskConfig, options: StatusOptions): Promise<Re
|
||||
raw: options.raw,
|
||||
stdoutTailOmitted: !(options.full || options.raw),
|
||||
rawGitMirrorOmitted: !options.raw,
|
||||
expandWith: `bun scripts/cli.ts agentrun v01 control-plane status${statusTargetArg(options, target)} --full`,
|
||||
rawWith: `bun scripts/cli.ts agentrun v01 control-plane status${statusTargetArg(options, target)} --raw`,
|
||||
expandWith: `bun scripts/cli.ts agentrun control-plane status${statusTargetArg(options, target)} --full`,
|
||||
rawWith: `bun scripts/cli.ts agentrun control-plane status${statusTargetArg(options, target)} --raw`,
|
||||
},
|
||||
next: {
|
||||
statusByPipelineRun: pipelineRun ? `bun scripts/cli.ts agentrun v01 control-plane status --pipeline-run ${pipelineRun} --full` : null,
|
||||
statusBySourceCommit: sourceCommit ? `bun scripts/cli.ts agentrun v01 control-plane status --source-commit ${sourceCommit} --full` : null,
|
||||
statusByPipelineRun: pipelineRun ? `bun scripts/cli.ts agentrun control-plane status --pipeline-run ${pipelineRun} --full` : null,
|
||||
statusBySourceCommit: sourceCommit ? `bun scripts/cli.ts agentrun control-plane status --source-commit ${sourceCommit} --full` : null,
|
||||
taskRuns: pipelineRun ? `trans G14:k3s kubectl get taskrun -n ${ciNamespace} -l tekton.dev/pipelineRun=${pipelineRun} -o wide` : null,
|
||||
logs: pipelineRun ? `trans G14:k3s logs -n ${ciNamespace} -l tekton.dev/pipelineRun=${pipelineRun} --tail 120` : null,
|
||||
triggerCurrent: "bun scripts/cli.ts agentrun v01 control-plane trigger-current --confirm",
|
||||
refresh: "bun scripts/cli.ts agentrun v01 control-plane refresh --confirm",
|
||||
triggerCurrent: "bun scripts/cli.ts agentrun control-plane trigger-current --confirm",
|
||||
refresh: "bun scripts/cli.ts agentrun control-plane refresh --confirm",
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -446,7 +484,7 @@ async function triggerCurrent(config: UniDeskConfig, options: TriggerOptions): P
|
||||
const sourceCommit = matchLine(source.stdout, "sourceCommit=");
|
||||
const pipelineRun = sourceCommit ? pipelineRunName(sourceCommit) : null;
|
||||
if (source.exitCode !== 0 || !sourceCommit || !isGitSha(sourceCommit) || !pipelineRun) {
|
||||
return { ok: false, command: "agentrun v01 control-plane trigger-current", degradedReason: "source-head-unresolved", source: compactCapture(source) };
|
||||
return { ok: false, command: "agentrun control-plane trigger-current", degradedReason: "source-head-unresolved", source: compactCapture(source) };
|
||||
}
|
||||
const plan = {
|
||||
lane: "v0.1",
|
||||
@@ -466,7 +504,7 @@ async function triggerCurrent(config: UniDeskConfig, options: TriggerOptions): P
|
||||
if (options.dryRun || !options.confirm) {
|
||||
return {
|
||||
ok: true,
|
||||
command: "agentrun v01 control-plane trigger-current",
|
||||
command: "agentrun control-plane trigger-current",
|
||||
dryRun: true,
|
||||
plan,
|
||||
gitMirrorPreSync: {
|
||||
@@ -474,7 +512,7 @@ async function triggerCurrent(config: UniDeskConfig, options: TriggerOptions): P
|
||||
reason: mirrorRequirement.reason,
|
||||
before: mirrorBefore.summary,
|
||||
},
|
||||
next: { confirm: "bun scripts/cli.ts agentrun v01 control-plane trigger-current --confirm" },
|
||||
next: { confirm: "bun scripts/cli.ts agentrun control-plane trigger-current --confirm" },
|
||||
};
|
||||
}
|
||||
let gitMirrorPreSync: Record<string, unknown> = {
|
||||
@@ -490,7 +528,7 @@ async function triggerCurrent(config: UniDeskConfig, options: TriggerOptions): P
|
||||
if (synced.ok !== true || afterRequirement.required !== false) {
|
||||
return {
|
||||
ok: false,
|
||||
command: "agentrun v01 control-plane trigger-current",
|
||||
command: "agentrun control-plane trigger-current",
|
||||
dryRun: false,
|
||||
degradedReason: "git-mirror-local-v01-not-current-after-sync",
|
||||
plan,
|
||||
@@ -501,13 +539,13 @@ async function triggerCurrent(config: UniDeskConfig, options: TriggerOptions): P
|
||||
const created = await capture(config, g14K3sRoute, ["script", "--", triggerScript(sourceCommit, pipelineRun)]);
|
||||
return {
|
||||
ok: created.exitCode === 0,
|
||||
command: "agentrun v01 control-plane trigger-current",
|
||||
command: "agentrun control-plane trigger-current",
|
||||
dryRun: false,
|
||||
plan,
|
||||
gitMirrorPreSync,
|
||||
created: compactCapture(created),
|
||||
next: {
|
||||
status: "bun scripts/cli.ts agentrun v01 control-plane status",
|
||||
status: "bun scripts/cli.ts agentrun control-plane status",
|
||||
logs: `trans G14:k3s logs -n ${ciNamespace} -l tekton.dev/pipelineRun=${pipelineRun} --tail 120`,
|
||||
},
|
||||
};
|
||||
@@ -530,21 +568,21 @@ async function refresh(config: UniDeskConfig, options: ConfirmOptions): Promise<
|
||||
if (options.dryRun || !options.confirm) {
|
||||
return {
|
||||
ok: true,
|
||||
command: "agentrun v01 control-plane refresh",
|
||||
command: "agentrun control-plane refresh",
|
||||
dryRun: true,
|
||||
plan,
|
||||
next: { confirm: "bun scripts/cli.ts agentrun v01 control-plane refresh --confirm" },
|
||||
next: { confirm: "bun scripts/cli.ts agentrun control-plane refresh --confirm" },
|
||||
};
|
||||
}
|
||||
const refreshed = await capture(config, g14K3sRoute, ["script", "--", refreshScript()]);
|
||||
return {
|
||||
ok: source.exitCode === 0 && refreshed.exitCode === 0,
|
||||
command: "agentrun v01 control-plane refresh",
|
||||
command: "agentrun control-plane refresh",
|
||||
dryRun: false,
|
||||
plan,
|
||||
source: compactCapture(source),
|
||||
refreshed: compactCapture(refreshed),
|
||||
next: { status: "bun scripts/cli.ts agentrun v01 control-plane status" },
|
||||
next: { status: "bun scripts/cli.ts agentrun control-plane status" },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -555,7 +593,7 @@ async function cleanupRuns(config: UniDeskConfig, options: CleanupRunsOptions):
|
||||
const base = {
|
||||
...payload,
|
||||
ok,
|
||||
command: "agentrun v01 control-plane cleanup-runs",
|
||||
command: "agentrun control-plane cleanup-runs",
|
||||
mode: options.dryRun || !options.confirm ? "dry-run" : "confirmed-cleanup",
|
||||
namespace: ciNamespace,
|
||||
minAgeMinutes: options.minAgeMinutes,
|
||||
@@ -568,7 +606,7 @@ async function cleanupRuns(config: UniDeskConfig, options: CleanupRunsOptions):
|
||||
dryRun: true,
|
||||
mutation: false,
|
||||
next: {
|
||||
confirm: `bun scripts/cli.ts agentrun v01 control-plane cleanup-runs --min-age-minutes ${options.minAgeMinutes} --limit ${options.limit} --confirm`,
|
||||
confirm: `bun scripts/cli.ts agentrun control-plane cleanup-runs --min-age-minutes ${options.minAgeMinutes} --limit ${options.limit} --confirm`,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -577,8 +615,8 @@ async function cleanupRuns(config: UniDeskConfig, options: CleanupRunsOptions):
|
||||
dryRun: false,
|
||||
mutation: true,
|
||||
followUp: {
|
||||
status: "bun scripts/cli.ts agentrun v01 control-plane status",
|
||||
releasedPvs: `bun scripts/cli.ts agentrun v01 control-plane cleanup-released-pvs --limit ${options.limit} --dry-run`,
|
||||
status: "bun scripts/cli.ts agentrun control-plane status",
|
||||
releasedPvs: `bun scripts/cli.ts agentrun control-plane cleanup-released-pvs --limit ${options.limit} --dry-run`,
|
||||
diskPressure: "trans G14:k3s kubectl get node ubuntu-rog-zephyrus-g14-ga401iv-ga401iv -o jsonpath='{range .status.conditions[*]}{.type}{\"=\"}{.status}{\" \"}{.reason}{\"\\n\"}{end}'",
|
||||
},
|
||||
};
|
||||
@@ -591,7 +629,7 @@ async function cleanupReleasedPvs(config: UniDeskConfig, options: CleanupRelease
|
||||
const base = {
|
||||
...payload,
|
||||
ok,
|
||||
command: "agentrun v01 control-plane cleanup-released-pvs",
|
||||
command: "agentrun control-plane cleanup-released-pvs",
|
||||
mode: options.dryRun || !options.confirm ? "dry-run" : "confirmed-cleanup",
|
||||
namespace: ciNamespace,
|
||||
limit: options.limit,
|
||||
@@ -603,7 +641,7 @@ async function cleanupReleasedPvs(config: UniDeskConfig, options: CleanupRelease
|
||||
dryRun: true,
|
||||
mutation: false,
|
||||
next: {
|
||||
confirm: `bun scripts/cli.ts agentrun v01 control-plane cleanup-released-pvs --limit ${options.limit} --confirm`,
|
||||
confirm: `bun scripts/cli.ts agentrun control-plane cleanup-released-pvs --limit ${options.limit} --confirm`,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -612,7 +650,7 @@ async function cleanupReleasedPvs(config: UniDeskConfig, options: CleanupRelease
|
||||
dryRun: false,
|
||||
mutation: true,
|
||||
followUp: {
|
||||
cleanupRuns: `bun scripts/cli.ts agentrun v01 control-plane cleanup-runs --min-age-minutes 30 --limit ${options.limit} --dry-run`,
|
||||
cleanupRuns: `bun scripts/cli.ts agentrun control-plane cleanup-runs --min-age-minutes 30 --limit ${options.limit} --dry-run`,
|
||||
diskPressure: "trans G14:k3s kubectl get node ubuntu-rog-zephyrus-g14-ga401iv-ga401iv -o jsonpath='{range .status.conditions[*]}{.type}{\"=\"}{.status}{\" \"}{.reason}{\"\\n\"}{end}'",
|
||||
},
|
||||
};
|
||||
@@ -1167,7 +1205,7 @@ async function gitMirrorStatus(config: UniDeskConfig, options: DisclosureOptions
|
||||
const summary = observation.summary;
|
||||
return {
|
||||
ok: observation.ok,
|
||||
command: "agentrun v01 git-mirror status",
|
||||
command: "agentrun git-mirror status",
|
||||
namespace: gitMirrorNamespace,
|
||||
readUrl: gitMirrorReadUrl,
|
||||
writeUrl: gitMirrorWriteUrl,
|
||||
@@ -1180,12 +1218,12 @@ async function gitMirrorStatus(config: UniDeskConfig, options: DisclosureOptions
|
||||
raw: options.raw,
|
||||
rawOmitted: !options.raw,
|
||||
probeTailOmitted: !(options.full || options.raw),
|
||||
expandWith: "bun scripts/cli.ts agentrun v01 git-mirror status --full",
|
||||
rawWith: "bun scripts/cli.ts agentrun v01 git-mirror status --raw",
|
||||
expandWith: "bun scripts/cli.ts agentrun git-mirror status --full",
|
||||
rawWith: "bun scripts/cli.ts agentrun git-mirror status --raw",
|
||||
},
|
||||
next: {
|
||||
sync: "bun scripts/cli.ts agentrun v01 git-mirror sync --confirm",
|
||||
flush: summary.pendingFlush === true ? "bun scripts/cli.ts agentrun v01 git-mirror flush --confirm" : null,
|
||||
sync: "bun scripts/cli.ts agentrun git-mirror sync --confirm",
|
||||
flush: summary.pendingFlush === true ? "bun scripts/cli.ts agentrun git-mirror flush --confirm" : null,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1218,7 +1256,7 @@ async function runGitMirrorJob(config: UniDeskConfig, action: "sync" | "flush",
|
||||
const jobName = `${action === "sync" ? gitMirrorSyncJobPrefix : gitMirrorFlushJobPrefix}-${Date.now().toString(36)}`.slice(0, 63);
|
||||
const manifest = gitMirrorJobManifest(action, jobName);
|
||||
const manifestB64 = Buffer.from(JSON.stringify(manifest), "utf8").toString("base64");
|
||||
const command = `agentrun v01 git-mirror ${action}`;
|
||||
const command = `agentrun git-mirror ${action}`;
|
||||
if (options.dryRun || !options.confirm) {
|
||||
return {
|
||||
ok: true,
|
||||
@@ -1243,8 +1281,8 @@ async function runGitMirrorJob(config: UniDeskConfig, action: "sync" | "flush",
|
||||
result: compactCapture(created),
|
||||
status,
|
||||
next: {
|
||||
status: "bun scripts/cli.ts agentrun v01 git-mirror status",
|
||||
wait: `bun scripts/cli.ts agentrun v01 git-mirror ${action} --confirm --wait`,
|
||||
status: "bun scripts/cli.ts agentrun git-mirror status",
|
||||
wait: `bun scripts/cli.ts agentrun git-mirror ${action} --confirm --wait`,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1261,8 +1299,8 @@ async function runGitMirrorJob(config: UniDeskConfig, action: "sync" | "flush",
|
||||
wait,
|
||||
status,
|
||||
next: {
|
||||
status: "bun scripts/cli.ts agentrun v01 git-mirror status",
|
||||
flush: action === "sync" && status.summary && record(status.summary).pendingFlush === true ? "bun scripts/cli.ts agentrun v01 git-mirror flush --confirm" : null,
|
||||
status: "bun scripts/cli.ts agentrun git-mirror status",
|
||||
flush: action === "sync" && status.summary && record(status.summary).pendingFlush === true ? "bun scripts/cli.ts agentrun git-mirror flush --confirm" : null,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1511,7 +1549,7 @@ function gitMirrorStatusSummary(raw: string): Record<string, unknown> {
|
||||
gitopsInSync: Boolean(localGitops && githubGitops && localGitops === githubGitops),
|
||||
githubInSync: Boolean(localV01 && githubV01 && localV01 === githubV01 && (!localGitops || localGitops === githubGitops)),
|
||||
flushNeeded: pendingFlush === true,
|
||||
flushCommand: pendingFlush === true ? "bun scripts/cli.ts agentrun v01 git-mirror flush --confirm" : null,
|
||||
flushCommand: pendingFlush === true ? "bun scripts/cli.ts agentrun git-mirror flush --confirm" : null,
|
||||
exactFetch: record(refs).exactFetch ?? null,
|
||||
lastSync,
|
||||
lastFlush,
|
||||
@@ -1565,18 +1603,18 @@ interface PreparedAgentRunCliArgs {
|
||||
stdinPayload: AgentRunCliForwardedStdin | null;
|
||||
}
|
||||
|
||||
type AgentRunOfficialCliBridgeGroup = "queue" | "sessions" | "aipod-specs" | "aipods";
|
||||
type AgentRunOfficialCliBridgeGroup = "queue" | "sessions" | "aipod-specs" | "aipods" | "runs" | "commands" | "runner";
|
||||
|
||||
async function runOfficialAgentRunCli(config: UniDeskConfig, group: AgentRunOfficialCliBridgeGroup, args: string[]): Promise<Record<string, unknown>> {
|
||||
const prepared = prepareOfficialAgentRunCliArgs([group, ...args]);
|
||||
const command = `agentrun v01 ${prepared.args.join(" ")}`.trim();
|
||||
const command = `agentrun ${prepared.args.join(" ")}`.trim();
|
||||
const bridge = agentRunQueueBridgeMetadata(prepared.materializedFiles, prepared.stdinPayload);
|
||||
const script = officialAgentRunCliScript(prepared);
|
||||
const result = await capture(config, g14SourceRoute, ["script", "--", script]);
|
||||
const payload = captureJsonPayload(result);
|
||||
if (result.exitCode === 0 && Object.keys(payload).length > 0) {
|
||||
return {
|
||||
...payload,
|
||||
...rewriteOfficialAgentRunCliDrillDown(payload),
|
||||
command,
|
||||
bridge,
|
||||
};
|
||||
@@ -1600,6 +1638,50 @@ async function runOfficialAgentRunCli(config: UniDeskConfig, group: AgentRunOffi
|
||||
};
|
||||
}
|
||||
|
||||
function rewriteOfficialAgentRunCliDrillDown(value: Record<string, unknown>): Record<string, unknown> {
|
||||
return rewriteRecordCommands(value);
|
||||
}
|
||||
|
||||
function rewriteRecordCommands(value: unknown): Record<string, unknown> {
|
||||
return record(rewriteOfficialCommandValue(value));
|
||||
}
|
||||
|
||||
function rewriteOfficialCommandValue(value: unknown): unknown {
|
||||
if (Array.isArray(value)) return value.map((item) => rewriteOfficialCommandValue(item));
|
||||
if (typeof value !== "object" || value === null) return value;
|
||||
const rewritten: Record<string, unknown> = {};
|
||||
for (const [key, item] of Object.entries(value)) {
|
||||
rewritten[key] = shouldRewriteOfficialCommandField(key) ? rewriteOfficialCommandFieldValue(item) : rewriteOfficialCommandValue(item);
|
||||
}
|
||||
return rewritten;
|
||||
}
|
||||
|
||||
function rewriteOfficialCommandFieldValue(value: unknown): unknown {
|
||||
if (typeof value === "string") return rewriteOfficialCommandString(value);
|
||||
if (Array.isArray(value)) return value.map((item) => rewriteOfficialCommandFieldValue(item));
|
||||
if (typeof value !== "object" || value === null) return value;
|
||||
const rewritten: Record<string, unknown> = {};
|
||||
for (const [key, item] of Object.entries(value)) {
|
||||
rewritten[key] = rewriteOfficialCommandFieldValue(item);
|
||||
}
|
||||
return rewritten;
|
||||
}
|
||||
|
||||
function shouldRewriteOfficialCommandField(key: string): boolean {
|
||||
return key === "pollCommands" || key === "drillDownCommands" || key === "recoveryActions" || key === "logPath";
|
||||
}
|
||||
|
||||
function rewriteOfficialCommandString(value: string): string {
|
||||
const trimmed = value.trim();
|
||||
if (trimmed.startsWith("./scripts/agentrun ")) {
|
||||
return `bun scripts/cli.ts agentrun ${trimmed.slice("./scripts/agentrun ".length)}`;
|
||||
}
|
||||
if (trimmed.startsWith("kubectl ") || trimmed.includes(" kubectl ")) {
|
||||
return "Use bun scripts/cli.ts agentrun runner jobs --run-id <runId> --command-id <commandId> or runner job-status <runnerJobId> --run-id <runId>; direct kubectl is intentionally hidden behind the AgentRun CLI bridge.";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function prepareOfficialAgentRunCliArgs(args: string[]): PreparedAgentRunCliArgs {
|
||||
const fileFlags = new Set(["--json-file", "--prompt-file", "--runner-json-file"]);
|
||||
const remoteTmpDir = `/tmp/unidesk-agentrun-cli-${Date.now()}-${process.pid}-${Math.random().toString(36).slice(2)}`;
|
||||
@@ -1871,9 +1953,9 @@ function buildAgentRunTargetValidation(input: {
|
||||
warnings,
|
||||
interruptedOrUnknown: state === "pipeline-status-unknown" || state === "missing-pipelinerun",
|
||||
nextActions: {
|
||||
inspectPipelineRun: input.pipelineRun ? `bun scripts/cli.ts agentrun v01 control-plane status --pipeline-run ${input.pipelineRun} --full` : null,
|
||||
inspectSourceCommit: input.sourceCommit ? `bun scripts/cli.ts agentrun v01 control-plane status --source-commit ${input.sourceCommit} --full` : null,
|
||||
triggerCurrent: "bun scripts/cli.ts agentrun v01 control-plane trigger-current --confirm",
|
||||
inspectPipelineRun: input.pipelineRun ? `bun scripts/cli.ts agentrun control-plane status --pipeline-run ${input.pipelineRun} --full` : null,
|
||||
inspectSourceCommit: input.sourceCommit ? `bun scripts/cli.ts agentrun control-plane status --source-commit ${input.sourceCommit} --full` : null,
|
||||
triggerCurrent: "bun scripts/cli.ts agentrun control-plane trigger-current --confirm",
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1966,6 +2048,6 @@ function unsupported(args: string[]): Record<string, unknown> {
|
||||
ok: false,
|
||||
command: `agentrun ${args.join(" ")}`.trim(),
|
||||
degradedReason: "unsupported-command",
|
||||
message: "supported commands: agentrun v01 aipod-specs list|show|render|apply|delete; agentrun v01 queue submit|list|show|stats|commander|read|cancel|dispatch|refresh; agentrun v01 sessions ps|show|turn|steer|cancel|output|trace|read; agentrun v01 control-plane status|trigger-current|refresh; agentrun v01 git-mirror status|sync|flush",
|
||||
message: "supported commands: agentrun aipod-specs list|show|render|apply|delete; agentrun queue submit|list|show|stats|commander|read|cancel|dispatch|refresh; agentrun runs show|events|result; agentrun commands show|result; agentrun runner jobs|job-status; agentrun sessions ps|show|turn|steer|cancel|output|trace|read; agentrun control-plane status|trigger-current|refresh; agentrun git-mirror status|sync|flush",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -65,14 +65,14 @@ const maxSteerRetryDelayMs = 5_000;
|
||||
const codexTaskStatuses = ["queued", "running", "judging", "retry_wait", "succeeded", "failed", "canceled"] as const;
|
||||
const codexTerminalTaskStatuses = ["succeeded", "failed", "canceled"] as const;
|
||||
const agentRunQueueReplacementCommands = {
|
||||
queueCommander: "bun scripts/cli.ts agentrun v01 queue commander --reader-id cli",
|
||||
queueSubmit: "bun scripts/cli.ts agentrun v01 queue submit --json-stdin <<'JSON'",
|
||||
queueDispatch: "bun scripts/cli.ts agentrun v01 queue dispatch <taskId> --json-stdin <<'JSON'",
|
||||
sessionsTrace: "bun scripts/cli.ts agentrun v01 sessions trace <sessionId> --after-seq 0 --limit 100",
|
||||
sessionsOutput: "bun scripts/cli.ts agentrun v01 sessions output <sessionId> --after-seq 0 --limit 100",
|
||||
sessionsSteer: "bun scripts/cli.ts agentrun v01 sessions steer <sessionId> --prompt-stdin <<'EOF'",
|
||||
sessionsRead: "bun scripts/cli.ts agentrun v01 sessions read <sessionId> --reader-id cli",
|
||||
queueCancel: "bun scripts/cli.ts agentrun v01 queue cancel <taskId> --reason <text>",
|
||||
queueCommander: "bun scripts/cli.ts agentrun queue commander --reader-id cli",
|
||||
queueSubmit: "bun scripts/cli.ts agentrun queue submit --json-stdin <<'JSON'",
|
||||
queueDispatch: "bun scripts/cli.ts agentrun queue dispatch <taskId> --json-stdin <<'JSON'",
|
||||
sessionsTrace: "bun scripts/cli.ts agentrun sessions trace <sessionId> --after-seq 0 --limit 100",
|
||||
sessionsOutput: "bun scripts/cli.ts agentrun sessions output <sessionId> --after-seq 0 --limit 100",
|
||||
sessionsSteer: "bun scripts/cli.ts agentrun sessions steer <sessionId> --prompt-stdin <<'EOF'",
|
||||
sessionsRead: "bun scripts/cli.ts agentrun sessions read <sessionId> --reader-id cli",
|
||||
queueCancel: "bun scripts/cli.ts agentrun queue cancel <taskId> --reason <text>",
|
||||
};
|
||||
const codexTaskStatusAliases: Record<string, string> = {
|
||||
completed: "succeeded",
|
||||
|
||||
@@ -707,8 +707,8 @@ def ci_storage_snapshot():
|
||||
"releasedPvs": "bun scripts/cli.ts hwlab g14 control-plane cleanup-released-pvs --lane all --limit 200 --dry-run",
|
||||
},
|
||||
"agentrun": {
|
||||
"dryRun": "bun scripts/cli.ts agentrun v01 control-plane cleanup-runs --min-age-minutes 30 --limit 200 --dry-run",
|
||||
"releasedPvs": "bun scripts/cli.ts agentrun v01 control-plane cleanup-released-pvs --limit 200 --dry-run",
|
||||
"dryRun": "bun scripts/cli.ts agentrun control-plane cleanup-runs --min-age-minutes 30 --limit 200 --dry-run",
|
||||
"releasedPvs": "bun scripts/cli.ts agentrun control-plane cleanup-released-pvs --limit 200 --dry-run",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -922,7 +922,7 @@ def collect_growth_snapshot(observed_at, preflight):
|
||||
"trend": "bun scripts/cli.ts gc remote %s trend --history-limit %s" % (PROVIDER_ID, int(OPTIONS.get("historyLimit") or 12)),
|
||||
"registryPlan": "bun scripts/cli.ts gc remote %s plan --target-use-percent 70 --include-hwlab-registry --limit 50" % PROVIDER_ID,
|
||||
"hwlabCiRetention": "bun scripts/cli.ts hwlab g14 control-plane cleanup-runs --lane v02 --min-age-minutes 30 --limit 200 --dry-run",
|
||||
"agentrunRetention": "bun scripts/cli.ts agentrun v01 control-plane cleanup-runs --min-age-minutes 30 --limit 200 --dry-run",
|
||||
"agentrunRetention": "bun scripts/cli.ts agentrun control-plane cleanup-runs --min-age-minutes 30 --limit 200 --dry-run",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
+26
-22
@@ -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 v01 aipod-specs|queue|sessions|control-plane|git-mirror", description: "Use AgentRun v0.1 AipodSpec, Queue, and Sessions as the active commander entry through the official G14 CLI bridge, plus bounded Tekton/Argo and git-mirror operations." },
|
||||
{ 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: "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 v01 queue and agentrun v01 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 queue and agentrun sessions 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 v01 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 sessions steer/read/cancel/output/trace against AgentRun sessions 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 v01 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 queue 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 v01 queue commander --reader-id cli",
|
||||
"bun scripts/cli.ts agentrun v01 aipod-specs show Artificer",
|
||||
"bun scripts/cli.ts agentrun v01 queue submit --aipod Artificer --prompt-stdin",
|
||||
"bun scripts/cli.ts agentrun v01 queue submit --json-stdin <<'JSON'",
|
||||
"bun scripts/cli.ts agentrun v01 sessions trace <sessionId> --after-seq 0 --limit 100",
|
||||
"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 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 v01 sessions steer <sessionId> --prompt-stdin",
|
||||
"bun scripts/cli.ts agentrun sessions steer <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]",
|
||||
@@ -423,7 +423,7 @@ function codexHelp(): unknown {
|
||||
},
|
||||
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 v01 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 queue submit --json-stdin with a quoted heredoc for new one-shot work; reserve --json-file for reusable reviewed files.",
|
||||
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 v01 queue commander --reader-id cli",
|
||||
agentRunAipod: "bun scripts/cli.ts agentrun v01 queue submit --aipod Artificer --prompt-stdin",
|
||||
agentRunSubmit: "bun scripts/cli.ts agentrun v01 queue submit --json-stdin <<'JSON'",
|
||||
agentRunTrace: "bun scripts/cli.ts agentrun v01 sessions trace <sessionId> --after-seq 0 --limit 100",
|
||||
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",
|
||||
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 v01 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 Queue/Sessions via bun scripts/cli.ts agentrun queue|sessions.",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -597,15 +597,19 @@ function artifactRegistryHelp(): unknown {
|
||||
|
||||
function agentRunHelpSummary(): unknown {
|
||||
return {
|
||||
command: "agentrun v01 aipod-specs|queue|sessions|control-plane|git-mirror",
|
||||
command: "agentrun aipod-specs|queue|runs|commands|runner|sessions|control-plane|git-mirror",
|
||||
output: "json",
|
||||
usage: [
|
||||
"bun scripts/cli.ts agentrun v01 aipod-specs show Artificer",
|
||||
"bun scripts/cli.ts agentrun v01 queue commander --reader-id cli",
|
||||
"bun scripts/cli.ts agentrun v01 sessions trace <sessionId> --after-seq 0 --limit 100",
|
||||
"bun scripts/cli.ts agentrun v01 control-plane status",
|
||||
"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 control-plane status",
|
||||
],
|
||||
description: "Operate AgentRun v0.1 AipodSpec, queue, sessions, and G14 control-plane entrypoints.",
|
||||
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.",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -352,7 +352,7 @@ function summarizeGitMirrorJobProgress(job: JobRecord, stdoutTail: string, stder
|
||||
nextCommand: job.status === "running"
|
||||
? `bun scripts/cli.ts job status ${job.id} --tail-bytes 12000`
|
||||
: job.name.startsWith("agentrun_")
|
||||
? "bun scripts/cli.ts agentrun v01 git-mirror status"
|
||||
? "bun scripts/cli.ts agentrun git-mirror status"
|
||||
: "bun scripts/cli.ts hwlab g14 git-mirror status",
|
||||
};
|
||||
}
|
||||
|
||||
+11
-2
@@ -97,14 +97,23 @@ function renderEnvelope<T>(command: string, envelope: JsonEnvelope<T>): string {
|
||||
}
|
||||
|
||||
function shouldDumpLargeOutput(command: string, text: string, envelope: JsonEnvelope<unknown>): boolean {
|
||||
if (!(command === "gh" || command.startsWith("gh "))) return false;
|
||||
if (process.env.UNIDESK_CLI_GH_OUTPUT_DUMP_DISABLED === "1") return false;
|
||||
if (!isLargeOutputDumpCommand(command)) return false;
|
||||
if (process.env.UNIDESK_CLI_GH_OUTPUT_DUMP_DISABLED === "1" || process.env.UNIDESK_CLI_OUTPUT_DUMP_DISABLED === "1") return false;
|
||||
if (typeof envelope.data === "object" && envelope.data !== null && (envelope.data as { noDump?: unknown }).noDump === true) return false;
|
||||
const threshold = configuredDumpThresholdBytes();
|
||||
return Buffer.byteLength(text, "utf8") > threshold;
|
||||
}
|
||||
|
||||
function isLargeOutputDumpCommand(command: string): boolean {
|
||||
return command === "gh" || command.startsWith("gh ") || command === "agentrun" || command.startsWith("agentrun ");
|
||||
}
|
||||
|
||||
function configuredDumpThresholdBytes(): number {
|
||||
const genericRaw = process.env.UNIDESK_CLI_OUTPUT_DUMP_THRESHOLD_BYTES;
|
||||
if (genericRaw !== undefined && genericRaw.trim().length > 0) {
|
||||
const genericValue = Number(genericRaw);
|
||||
if (Number.isInteger(genericValue) && genericValue > 0) return genericValue;
|
||||
}
|
||||
const raw = process.env.UNIDESK_CLI_GH_OUTPUT_DUMP_THRESHOLD_BYTES;
|
||||
if (raw === undefined || raw.trim().length === 0) return GH_OUTPUT_DUMP_THRESHOLD_BYTES;
|
||||
const value = Number(raw);
|
||||
|
||||
Reference in New Issue
Block a user