@xzzpig/pi-subagents 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +477 -0
- package/README.md +2 -2
- package/agents/claude-code-writer.md +15 -0
- package/agents/claude-code.md +15 -0
- package/agents/codex-exec-writer.md +15 -0
- package/agents/codex-exec.md +15 -0
- package/agents/cursor-agent-writer.md +14 -0
- package/agents/cursor-agent.md +14 -0
- package/agents/reviewer.md +1 -1
- package/agents/scout.md +1 -1
- package/docs/agents.md +195 -39
- package/docs/configuration.md +81 -22
- package/docs/extension-api.md +69 -14
- package/docs/missions.md +2 -0
- package/docs/models.md +32 -9
- package/docs/observability.md +22 -20
- package/docs/tool-reference.md +123 -14
- package/docs/watchdog.md +92 -114
- package/docs/workflows.md +142 -4
- package/install.mjs +1 -1
- package/package.json +7 -6
- package/prompts/review-loop.md +2 -2
- package/skills/council-mode/SKILL.md +48 -243
- package/skills/council-mode/references/pass-contracts.md +150 -0
- package/skills/pi-subagents/SKILL.md +89 -35
- package/skills/pi-subagents/references/constraints-and-recipes.md +30 -234
- package/skills/pi-subagents/references/execution-controls.md +91 -15
- package/skills/pi-subagents/references/management-authoring-rpc.md +5 -5
- package/skills/pi-subagents/references/multi-lane-orchestration.md +13 -1
- package/skills/pi-subagents/references/prompting-and-roles.md +59 -31
- package/skills/pi-subagents/references/review-and-validation.md +73 -0
- package/src/agents/agent-management.ts +384 -115
- package/src/agents/agent-refinements.ts +4 -4
- package/src/agents/agent-serializer.ts +14 -2
- package/src/agents/agents.ts +935 -372
- package/src/agents/builtin-names.ts +6 -0
- package/src/agents/runtime-agent-events.ts +70 -0
- package/src/agents/runtime-agent-registry.ts +42 -21
- package/src/api/agents.ts +10 -5
- package/src/api/background-work.ts +12 -3
- package/src/api/capability-ceiling.ts +0 -1
- package/src/api/{pi-args.ts → child-tool-plan.ts} +1 -1
- package/src/api/delegation.ts +0 -7
- package/src/api/external-runs.ts +67 -4
- package/src/api/preflight.ts +77 -21
- package/src/api/shared-types.ts +6 -0
- package/src/extension/config.ts +90 -0
- package/src/extension/doctor.ts +5 -13
- package/src/extension/fanout-child.ts +14 -14
- package/src/extension/index.ts +115 -37
- package/src/extension/public-execution.ts +103 -15
- package/src/extension/rpc.ts +120 -25
- package/src/extension/schemas.ts +65 -29
- package/src/extension/tool-description.ts +48 -26
- package/src/inspectors/herdr/actions.ts +2 -1
- package/src/inspectors/herdr/inspector-runner.ts +21 -23
- package/src/inspectors/herdr/session-roots-codec.ts +42 -0
- package/src/integrations/herdr-status.ts +51 -3
- package/src/intercom/native-supervisor-channel.ts +138 -60
- package/src/intercom/result-intercom.ts +7 -0
- package/src/intercom/supervisor-ui.ts +243 -0
- package/src/profiles/profiles.ts +5 -6
- package/src/runs/background/active-async-capacity.ts +103 -18
- package/src/runs/background/async-execution.ts +417 -133
- package/src/runs/background/async-job-tracker.ts +95 -15
- package/src/runs/background/async-resume.ts +60 -28
- package/src/runs/background/async-retention.ts +20 -3
- package/src/runs/background/async-status-snapshot.ts +23 -261
- package/src/runs/background/async-status.ts +204 -14
- package/src/runs/background/auto-drain.ts +1 -1
- package/src/runs/background/chain-append.ts +8 -3
- package/src/runs/background/chain-root-attachment.ts +74 -8
- package/src/runs/background/control-channel.ts +4 -205
- package/src/runs/background/fleet-view.ts +38 -22
- package/src/runs/background/inspect-rpc.ts +8 -8
- package/src/runs/background/notify.ts +238 -12
- package/src/runs/background/process-terminal.ts +16 -0
- package/src/runs/background/result-delivery-ownership.ts +45 -0
- package/src/runs/background/result-files.ts +28 -14
- package/src/runs/background/result-watcher.ts +39 -16
- package/src/runs/background/resume-guidance.ts +2 -2
- package/src/runs/background/retained-children.ts +1 -1
- package/src/runs/background/run-child-session.ts +613 -0
- package/src/runs/background/run-status.ts +84 -17
- package/src/runs/background/runner-aliases.ts +125 -0
- package/src/runs/background/runner-child-sessions.ts +31 -0
- package/src/runs/background/scheduled-runs.ts +174 -18
- package/src/runs/background/stale-run-reconciler.ts +10 -4
- package/src/runs/background/steering.ts +8 -15
- package/src/runs/background/subagent-runner.ts +718 -1161
- package/src/runs/background/subagent-wait.ts +86 -31
- package/src/runs/background/terminal-run-index.ts +1 -1
- package/src/runs/background/wait-completions.ts +43 -2
- package/src/runs/background/wait-config.ts +23 -9
- package/src/runs/background/wait-tool.ts +26 -19
- package/src/runs/foreground/async-steering-action.ts +3 -19
- package/src/runs/foreground/execution.ts +489 -499
- package/src/runs/foreground/foreground-control.ts +13 -0
- package/src/runs/foreground/foreground-history.ts +23 -1
- package/src/runs/foreground/subagent-executor.ts +1223 -402
- package/src/runs/foreground/workflow-detach-reconcile.ts +140 -115
- package/src/runs/foreground/workflow-foreground-steering.ts +24 -98
- package/src/runs/shared/abort-recovery.ts +119 -0
- package/src/runs/shared/acceptance.ts +138 -36
- package/src/runs/shared/async-status-projection.ts +565 -0
- package/src/runs/shared/background-process-options.ts +9 -0
- package/src/runs/shared/capability-ceiling.ts +2 -2
- package/src/runs/shared/child-hooks.ts +25 -0
- package/src/runs/shared/child-identity.ts +32 -6
- package/src/runs/shared/child-launch-plan.ts +151 -0
- package/src/runs/shared/child-launch.ts +364 -0
- package/src/runs/shared/child-lifecycle.ts +25 -0
- package/src/runs/shared/child-runtime-config.ts +126 -0
- package/src/runs/shared/child-session.ts +366 -0
- package/src/runs/shared/child-tool-plan.ts +632 -0
- package/src/runs/shared/claude-code-adapter.ts +133 -0
- package/src/runs/shared/codex-exec-adapter.ts +129 -0
- package/src/runs/shared/completion-evidence.ts +89 -0
- package/src/runs/shared/completion-guard.ts +6 -5
- package/src/runs/shared/cursor-agent-adapter.ts +114 -0
- package/src/runs/shared/dynamic-fanout.ts +3 -3
- package/src/runs/shared/external-cli-contract.ts +167 -0
- package/src/runs/shared/external-cli-preflight.ts +138 -0
- package/src/runs/shared/external-cli-runner.ts +348 -55
- package/src/runs/shared/fast-mode-extension.ts +5 -5
- package/src/runs/shared/host-step-status.ts +231 -0
- package/src/runs/shared/lane-metadata.ts +126 -0
- package/src/runs/shared/launch-cwd.ts +16 -0
- package/src/runs/shared/long-running-guard.ts +2 -1
- package/src/runs/shared/mcp-config-sources.ts +422 -0
- package/src/runs/shared/mcp-direct-tool-allowlist.ts +222 -158
- package/src/runs/shared/mcp-direct-tool-grant.ts +194 -0
- package/src/runs/shared/model-exclusions.ts +139 -9
- package/src/runs/shared/model-fallback.ts +146 -14
- package/src/runs/shared/mutation-evidence.ts +57 -3
- package/src/runs/shared/nested-events.ts +99 -77
- package/src/runs/shared/nested-path.ts +0 -14
- package/src/runs/shared/nested-render.ts +9 -5
- package/src/runs/shared/orca-progress-tabs.ts +12 -7
- package/src/runs/shared/parallel-handoff.ts +423 -7
- package/src/runs/shared/parallel-utils.ts +20 -7
- package/src/runs/shared/permissions.ts +1 -14
- package/src/runs/shared/pi-spawn.ts +69 -35
- package/src/runs/shared/process-signal.ts +16 -0
- package/src/runs/shared/run-fanout-budget.ts +0 -13
- package/src/runs/shared/run-history.ts +21 -1
- package/src/runs/shared/runtime-acknowledged-extensions.ts +0 -27
- package/src/runs/shared/sandbox-profile-guard.ts +85 -0
- package/src/runs/shared/sandbox-startup-diagnostics.ts +54 -0
- package/src/runs/shared/single-output.ts +89 -22
- package/src/runs/shared/structured-output.ts +49 -9
- package/src/runs/shared/subagent-control.ts +6 -2
- package/src/runs/shared/subagent-prompt-runtime.ts +188 -365
- package/src/runs/shared/task-intent.ts +21 -7
- package/src/runs/shared/tool-availability.ts +18 -62
- package/src/runs/shared/tool-budget.ts +0 -14
- package/src/runs/shared/tool-timeout.ts +1 -1
- package/src/runs/shared/workflow-graph.ts +16 -0
- package/src/runs/shared/worktree-cleanup-plan.ts +866 -0
- package/src/runs/shared/worktree.ts +571 -62
- package/src/shared/atomic-json.ts +3 -1
- package/src/shared/child-session-name.ts +46 -0
- package/src/shared/extension-context.ts +24 -0
- package/src/shared/fork-context.ts +21 -12
- package/src/shared/fork-session-cwd.ts +27 -0
- package/src/shared/formatters.ts +18 -3
- package/src/shared/jsonl-writer.ts +11 -0
- package/src/shared/launch-contract.ts +11 -1
- package/src/shared/pruned-fork.ts +450 -0
- package/src/shared/sandbox-profile.ts +23 -0
- package/src/shared/session-file-trust.ts +19 -0
- package/src/shared/session-tokens.ts +14 -3
- package/src/shared/settings.ts +19 -105
- package/src/shared/shortcuts.ts +17 -0
- package/src/shared/thinking-ceiling.ts +0 -6
- package/src/shared/types.ts +545 -70
- package/src/shared/utils.ts +60 -93
- package/src/shared/workflow-child-permit.ts +207 -0
- package/src/slash/delegation-adapters.ts +1 -9
- package/src/slash/delegation-request.ts +0 -4
- package/src/slash/prompt-template-bridge.ts +37 -1
- package/src/slash/slash-bridge.ts +1 -2
- package/src/slash/slash-commands.ts +383 -116
- package/src/slash/slash-live-state.ts +22 -11
- package/src/slash/subagents-admin.ts +29 -12
- package/src/tui/fleet-native-transcript.ts +4 -0
- package/src/tui/fleet-status.ts +217 -82
- package/src/tui/fleet-transcript.ts +11 -5
- package/src/tui/fleet.ts +54 -28
- package/src/tui/render-helpers.ts +31 -0
- package/src/tui/render.ts +1429 -163
- package/src/watchdog/change-signature.ts +40 -1
- package/src/watchdog/child-status.ts +54 -34
- package/src/watchdog/diff-tool.ts +77 -0
- package/src/watchdog/emission-guard.ts +5 -3
- package/src/watchdog/guidance.ts +20 -0
- package/src/watchdog/register-child.ts +28 -25
- package/src/watchdog/register-main.ts +10 -9
- package/src/watchdog/render.ts +4 -5
- package/src/watchdog/review.ts +15 -4
- package/src/watchdog/rules.ts +70 -0
- package/src/watchdog/runtime.ts +75 -92
- package/src/watchdog/scope.ts +0 -11
- package/src/watchdog/settings.ts +48 -104
- package/src/watchdog/turn-delta.ts +1 -1
- package/src/watchdog/types.ts +18 -32
- package/src/watchdog/warning-format.ts +0 -1
- package/src/workflows/chat-progress.ts +7 -3
- package/src/workflows/host-command.ts +235 -0
- package/src/workflows/scripted-workflow.ts +988 -59
- package/src/workflows/workflow-checklist.ts +439 -0
- package/src/workflows/workflow-child-summary.ts +121 -0
- package/src/workflows/workflow-preflight.ts +297 -0
- package/src/workflows/workflow-receipt.ts +232 -6
- package/src/workflows/workflow-resources.ts +150 -0
- package/src/workflows/workflow-settlement.ts +246 -0
- package/src/runs/shared/child-protocol.ts +0 -401
- package/src/runs/shared/pi-args.ts +0 -935
- package/src/runs/shared/subagent-startup-retry.ts +0 -116
- package/src/runs/shared/turn-budget.ts +0 -98
- package/src/shared/post-exit-stdio-guard.ts +0 -85
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { formatDuration, formatModelThinking, formatTokens, shortenPath } from "../../shared/formatters.ts";
|
|
4
|
+
import { previewDisplayText } from "../../shared/display-text.ts";
|
|
4
5
|
import { formatActivityLabel, formatParallelOutcome } from "../../shared/status-format.ts";
|
|
5
|
-
import { type ActivityState, type AsyncJobStep, type AsyncParallelGroupStatus, type AsyncStatus, type CostSummary, type Details, type LaunchResolvedChildExtensionsV1, type RuntimeAcknowledgedChildExtensionsV1, type NestedRunSummary, type SteeringStatus, type SubagentRunMode, type TokenUsage, type TurnBudgetState, type UsageBudgetState } from "../../shared/types.ts";
|
|
6
|
+
import { type ActivityState, type AsyncJobStep, type AsyncParallelGroupStatus, type AsyncStatus, type CostSummary, type Details, type HostStepNodeV1, type HostStepState, type LaunchResolvedChildExtensionsV1, type RuntimeAcknowledgedChildExtensionsV1, type NestedRunSummary, type SteeringStatus, type SubagentRunMode, type TimeoutRecoveryProjection, type TokenUsage, type TurnBudgetState, type UsageBudgetState, type WorktreeNaming, type WorkflowPreflightV1, type WorkflowGraphSnapshot } from "../../shared/types.ts";
|
|
6
7
|
import type { ResolvedSubagentCapabilityCeiling, SubagentCapabilityAudit } from "../shared/capability-ceiling.ts";
|
|
7
8
|
import { readStatus } from "../../shared/utils.ts";
|
|
8
9
|
import { attachRootChildrenToSteps, buildNestedRouteIndex, findNestedRouteForRootId, type NestedRoute, projectNestedEvents } from "../shared/nested-events.ts";
|
|
@@ -16,16 +17,32 @@ import { ACTIVE_RUN_INDEX_DIR, DEFAULT_STALE_TERMINAL_ACTIVE_MARKER_MS, activeRu
|
|
|
16
17
|
import { readRecentTerminalRunIndex, TERMINAL_RUN_INDEX_DIR } from "./terminal-run-index.ts";
|
|
17
18
|
import { canScanAsyncRunPrefix } from "./run-id-query.ts";
|
|
18
19
|
import { asyncStatusChildIdentity } from "../shared/child-identity.ts";
|
|
20
|
+
import { parseWorkflowChildSummary } from "../../workflows/workflow-child-summary.ts";
|
|
21
|
+
import { assertWorkflowGraphHostSteps, hostStepReportName, hostStepVerdictLabel, validHostStepNodes } from "../shared/host-step-status.ts";
|
|
22
|
+
import { projectAsyncWorkflowRows } from "../shared/async-status-projection.ts";
|
|
23
|
+
import { validateAsyncStatusLaneMetadata } from "../shared/lane-metadata.ts";
|
|
24
|
+
import { formatWorkflowPreflightPlanSummary, formatWorkflowPreflightWarningSummary } from "../../workflows/workflow-preflight.ts";
|
|
25
|
+
import { workflowGraphStageNodes } from "../shared/workflow-graph.ts";
|
|
26
|
+
import { formatTimeoutRecoveryLines, projectTimeoutRecovery } from "../shared/mutation-evidence.ts";
|
|
27
|
+
import { formatWorkflowChecklistText, projectWorkflowChecklist } from "../../workflows/workflow-checklist.ts";
|
|
28
|
+
import { validateSandboxProfileName } from "../../shared/sandbox-profile.ts";
|
|
19
29
|
|
|
20
30
|
interface AsyncRunStepSummary {
|
|
21
31
|
index: number;
|
|
22
32
|
childId?: string;
|
|
23
33
|
agent: string;
|
|
34
|
+
/** Human-readable display name for the child session, when derived at launch. */
|
|
35
|
+
sessionName?: string;
|
|
24
36
|
context?: ContextMode;
|
|
25
37
|
label?: string;
|
|
26
38
|
description?: string;
|
|
27
39
|
phase?: string;
|
|
28
40
|
workflowKey?: string;
|
|
41
|
+
lane?: AsyncJobStep["lane"];
|
|
42
|
+
worktreePath?: string;
|
|
43
|
+
branch?: string;
|
|
44
|
+
provider?: "native" | "worktrunk";
|
|
45
|
+
naming?: WorktreeNaming;
|
|
29
46
|
runId?: string;
|
|
30
47
|
outputName?: string;
|
|
31
48
|
structured?: boolean;
|
|
@@ -47,7 +64,9 @@ interface AsyncRunStepSummary {
|
|
|
47
64
|
totalCost?: CostSummary;
|
|
48
65
|
skills?: string[];
|
|
49
66
|
model?: string;
|
|
67
|
+
contextLimit?: number;
|
|
50
68
|
thinking?: string;
|
|
69
|
+
sandbox?: string;
|
|
51
70
|
attemptedModels?: string[];
|
|
52
71
|
sessionFile?: string;
|
|
53
72
|
transcriptPath?: string;
|
|
@@ -56,6 +75,7 @@ interface AsyncRunStepSummary {
|
|
|
56
75
|
stopped?: boolean;
|
|
57
76
|
turnBudget?: TurnBudgetState;
|
|
58
77
|
turnBudgetExceeded?: boolean;
|
|
78
|
+
toolBudgetBlocked?: boolean;
|
|
59
79
|
wrapUpRequested?: boolean;
|
|
60
80
|
acceptance?: AsyncJobStep["acceptance"];
|
|
61
81
|
agentContract?: AsyncJobStep["agentContract"];
|
|
@@ -63,6 +83,7 @@ interface AsyncRunStepSummary {
|
|
|
63
83
|
review?: AsyncJobStep["review"];
|
|
64
84
|
effects?: AsyncJobStep["effects"];
|
|
65
85
|
processTerminal?: AsyncJobStep["processTerminal"];
|
|
86
|
+
timeoutRecovery?: TimeoutRecoveryProjection;
|
|
66
87
|
launchResolvedExtensions?: LaunchResolvedChildExtensionsV1;
|
|
67
88
|
runtimeAcknowledgedExtensions?: RuntimeAcknowledgedChildExtensionsV1;
|
|
68
89
|
capabilityCeiling?: ResolvedSubagentCapabilityCeiling;
|
|
@@ -75,7 +96,7 @@ export interface AsyncRunSummary {
|
|
|
75
96
|
asyncDir: string;
|
|
76
97
|
toolCallId?: string;
|
|
77
98
|
sessionId?: string;
|
|
78
|
-
state: "queued" | "running" | "complete" | "failed" | "paused" | "stopped" | "rejected";
|
|
99
|
+
state: "queued" | "running" | "complete" | "failed" | "partial" | "paused" | "stopped" | "rejected";
|
|
79
100
|
error?: string;
|
|
80
101
|
activityState?: ActivityState;
|
|
81
102
|
lastActivityAt?: number;
|
|
@@ -87,6 +108,7 @@ export interface AsyncRunSummary {
|
|
|
87
108
|
steering?: SteeringStatus;
|
|
88
109
|
mode: SubagentRunMode;
|
|
89
110
|
context?: ContextSummary;
|
|
111
|
+
sandbox?: string;
|
|
90
112
|
cwd?: string;
|
|
91
113
|
sessionRoot?: string;
|
|
92
114
|
startedAt: number;
|
|
@@ -103,6 +125,8 @@ export interface AsyncRunSummary {
|
|
|
103
125
|
chainStepCount?: number;
|
|
104
126
|
pendingAppends?: number;
|
|
105
127
|
parallelGroups?: AsyncParallelGroupStatus[];
|
|
128
|
+
hostSteps?: HostStepNodeV1[];
|
|
129
|
+
workflowGraph?: AsyncStatus["workflowGraph"];
|
|
106
130
|
steps: AsyncRunStepSummary[];
|
|
107
131
|
sessionDir?: string;
|
|
108
132
|
outputFile?: string;
|
|
@@ -120,7 +144,10 @@ export interface AsyncRunSummary {
|
|
|
120
144
|
capabilityAudit?: SubagentCapabilityAudit;
|
|
121
145
|
parentWorkflowRunId?: string;
|
|
122
146
|
workflowKey?: string;
|
|
147
|
+
lane?: AsyncStatus["lane"];
|
|
123
148
|
workflow?: Details["workflow"];
|
|
149
|
+
workflowChildren?: Details["workflowChildren"];
|
|
150
|
+
preflight?: WorkflowPreflightV1;
|
|
124
151
|
}
|
|
125
152
|
|
|
126
153
|
interface AsyncRunListOptions {
|
|
@@ -145,6 +172,48 @@ function getErrorMessage(error: unknown): string {
|
|
|
145
172
|
return error instanceof Error ? error.message : String(error);
|
|
146
173
|
}
|
|
147
174
|
|
|
175
|
+
function isAsyncStatusIsolationError(asyncDir: string, error: unknown): boolean {
|
|
176
|
+
const statusPath = path.join(asyncDir, "status.json");
|
|
177
|
+
const message = getErrorMessage(error);
|
|
178
|
+
return /^(?:Failed to (?:inspect|read|parse|validate) async status file|Invalid async status file) '/.test(message)
|
|
179
|
+
|| message.startsWith(`Invalid async status '${statusPath}'`)
|
|
180
|
+
|| message.startsWith(`Invalid host step '${statusPath}`)
|
|
181
|
+
|| /^(workflowChildren|Invalid workflowChildren)/.test(message);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function isolateCorruptActiveRun(asyncDir: string, runId: string, error: unknown, now?: () => number): void {
|
|
185
|
+
const statusPath = path.join(asyncDir, "status.json");
|
|
186
|
+
const processTerminal = readProcessTerminal(asyncDir, { runId });
|
|
187
|
+
let markerAge: number | undefined;
|
|
188
|
+
try {
|
|
189
|
+
markerAge = activeRunMarkerAgeMs(asyncDir, now?.());
|
|
190
|
+
} catch (markerError) {
|
|
191
|
+
console.error(`Failed to inspect corrupt async active-run marker for '${runId}':`, markerError);
|
|
192
|
+
}
|
|
193
|
+
const markerCanBeReleased = processTerminal?.state === "observed"
|
|
194
|
+
|| (markerAge !== undefined && markerAge > DEFAULT_STALE_TERMINAL_ACTIVE_MARKER_MS);
|
|
195
|
+
let markerAction = "active marker retained because runner liveness is unknown";
|
|
196
|
+
if (markerCanBeReleased) {
|
|
197
|
+
try {
|
|
198
|
+
releaseActiveRunIndex(asyncDir);
|
|
199
|
+
markerAction = processTerminal?.state === "observed"
|
|
200
|
+
? "active marker released after observed process-terminal proof"
|
|
201
|
+
: "stale active marker released";
|
|
202
|
+
} catch (releaseError) {
|
|
203
|
+
markerAction = `failed to release active marker: ${getErrorMessage(releaseError)}`;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
console.error(`[pi-subagents] Skipping corrupt active async run '${runId}' at '${statusPath}': ${getErrorMessage(error)}; ${markerAction}.`);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function sandboxProfileValue(value: unknown): string | undefined {
|
|
210
|
+
try {
|
|
211
|
+
return validateSandboxProfileName(value);
|
|
212
|
+
} catch {
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
148
217
|
function isNotFoundError(error: unknown): boolean {
|
|
149
218
|
return typeof error === "object"
|
|
150
219
|
&& error !== null
|
|
@@ -229,19 +298,34 @@ function deriveAsyncActivityState(asyncDir: string, status: AsyncStatus): { acti
|
|
|
229
298
|
}
|
|
230
299
|
|
|
231
300
|
function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string }, nestedWarnings: string[] = [], nestedRoute?: NestedRoute): AsyncRunSummary {
|
|
301
|
+
const statusPath = path.join(asyncDir, "status.json");
|
|
302
|
+
validateAsyncStatusLaneMetadata(status, `Invalid async status '${statusPath}'`);
|
|
303
|
+
const workflowChildren = parseWorkflowChildSummary(status.workflowChildren);
|
|
304
|
+
if (workflowChildren && workflowChildren.workflowRunId !== status.runId) throw new Error(`Invalid async status '${statusPath}': workflowChildren.workflowRunId does not match.`);
|
|
305
|
+
assertWorkflowGraphHostSteps(status.workflowGraph, statusPath, status.runId);
|
|
306
|
+
const hostSteps = validHostStepNodes(status.workflowGraph);
|
|
232
307
|
if (status.sessionId !== undefined && typeof status.sessionId !== "string") {
|
|
233
|
-
throw new Error(`Invalid async status '${
|
|
308
|
+
throw new Error(`Invalid async status '${statusPath}': sessionId must be a string.`);
|
|
234
309
|
}
|
|
310
|
+
if (status.outputFile !== undefined && typeof status.outputFile !== "string") throw new Error(`Invalid async status '${statusPath}': outputFile must be a string.`);
|
|
235
311
|
const { activityState, lastActivityAt } = deriveAsyncActivityState(asyncDir, status);
|
|
236
312
|
const processTerminal = readProcessTerminal(asyncDir, { runId: status.runId, runnerProcessInstanceId: status.processTerminal?.runnerProcessInstanceId })
|
|
237
313
|
?? sanitizeProcessTerminal(status.processTerminal, { runId: status.runId, runnerProcessInstanceId: status.processTerminal?.runnerProcessInstanceId }, path.join(asyncDir, "status.json"));
|
|
238
|
-
const
|
|
239
|
-
|
|
314
|
+
const nestedProjectionAllowed = nestedWarnings.length === 0;
|
|
315
|
+
// Degrade to the status-stored snapshot when the persisted budget is unavailable (e.g. removed
|
|
316
|
+
// by OS temp cleanup) instead of failing the whole run list; admission paths stay strict.
|
|
317
|
+
let runFanoutBudget: AsyncStatus["runFanoutBudget"] = status.runFanoutBudget;
|
|
318
|
+
try {
|
|
319
|
+
const runFanoutBudgetDescriptor = readRunFanoutBudgetDescriptor(asyncDir);
|
|
320
|
+
if (runFanoutBudgetDescriptor) runFanoutBudget = getRunFanoutBudgetSnapshot(runFanoutBudgetDescriptor);
|
|
321
|
+
} catch (error) {
|
|
322
|
+
nestedWarnings.push(`Run fan-out status unavailable: ${getErrorMessage(error)}`);
|
|
323
|
+
}
|
|
240
324
|
const steps = status.steps ?? [];
|
|
241
325
|
const chainStepCount = status.chainStepCount ?? steps.length;
|
|
242
326
|
const parallelGroups = normalizeParallelGroups(status.parallelGroups, steps.length, chainStepCount);
|
|
243
327
|
let nestedChildren: NestedRunSummary[] = [];
|
|
244
|
-
if (
|
|
328
|
+
if (nestedProjectionAllowed && nestedRoute) {
|
|
245
329
|
try {
|
|
246
330
|
// The route is resolved by the caller via buildNestedRouteIndex, so this
|
|
247
331
|
// avoids a fresh scan of the nested-events directory per run.
|
|
@@ -253,15 +337,23 @@ function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string
|
|
|
253
337
|
const summarizedSteps = steps.map((step, index) => {
|
|
254
338
|
const stepActivityState = step.activityState;
|
|
255
339
|
const stepLastActivityAt = step.lastActivityAt;
|
|
340
|
+
const timeoutRecovery = projectTimeoutRecovery(step.timeoutRecovery);
|
|
341
|
+
const sandbox = sandboxProfileValue(step.sandbox);
|
|
256
342
|
return {
|
|
257
343
|
index,
|
|
258
344
|
childId: asyncStatusChildIdentity(step, index),
|
|
259
345
|
agent: step.agent,
|
|
346
|
+
...(step.sessionName ? { sessionName: step.sessionName } : {}),
|
|
260
347
|
...(step.context ? { context: step.context } : {}),
|
|
261
348
|
...(step.label ? { label: step.label } : {}),
|
|
262
349
|
...(step.description ? { description: step.description } : {}),
|
|
263
350
|
...(step.phase ? { phase: step.phase } : {}),
|
|
264
351
|
...(step.workflowKey ? { workflowKey: step.workflowKey } : {}),
|
|
352
|
+
...(step.lane ? { lane: step.lane } : {}),
|
|
353
|
+
...(step.worktreePath ? { worktreePath: step.worktreePath } : {}),
|
|
354
|
+
...(step.branch ? { branch: step.branch } : {}),
|
|
355
|
+
...(step.provider ? { provider: step.provider } : {}),
|
|
356
|
+
...(step.naming ? { naming: step.naming } : {}),
|
|
265
357
|
...(step.runId ? { runId: step.runId } : {}),
|
|
266
358
|
...(step.outputName ? { outputName: step.outputName } : {}),
|
|
267
359
|
...(step.structured ? { structured: step.structured } : {}),
|
|
@@ -283,7 +375,9 @@ function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string
|
|
|
283
375
|
...(step.totalCost ? { totalCost: step.totalCost } : {}),
|
|
284
376
|
...(step.skills ? { skills: step.skills } : {}),
|
|
285
377
|
...(step.model ? { model: step.model } : {}),
|
|
378
|
+
...(step.contextLimit !== undefined ? { contextLimit: step.contextLimit } : {}),
|
|
286
379
|
...(step.thinking ? { thinking: step.thinking } : {}),
|
|
380
|
+
...(sandbox ? { sandbox } : {}),
|
|
287
381
|
...(step.thinkingCeiling ? { thinkingCeiling: step.thinkingCeiling } : {}),
|
|
288
382
|
...(step.attemptedModels ? { attemptedModels: step.attemptedModels } : {}),
|
|
289
383
|
...(step.sessionFile ? { sessionFile: step.sessionFile } : {}),
|
|
@@ -295,6 +389,7 @@ function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string
|
|
|
295
389
|
...(step.stopRequestedAt !== undefined ? { stopRequestedAt: step.stopRequestedAt } : {}),
|
|
296
390
|
...(step.turnBudget ? { turnBudget: step.turnBudget } : {}),
|
|
297
391
|
...(step.turnBudgetExceeded !== undefined ? { turnBudgetExceeded: step.turnBudgetExceeded } : {}),
|
|
392
|
+
...(step.toolBudgetBlocked !== undefined ? { toolBudgetBlocked: step.toolBudgetBlocked } : {}),
|
|
298
393
|
...(step.wrapUpRequested !== undefined ? { wrapUpRequested: step.wrapUpRequested } : {}),
|
|
299
394
|
...(step.acceptance ? { acceptance: step.acceptance } : {}),
|
|
300
395
|
...(step.agentContract ? { agentContract: step.agentContract } : {}),
|
|
@@ -304,13 +399,16 @@ function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string
|
|
|
304
399
|
...(step.execution ? { execution: step.execution } : {}),
|
|
305
400
|
...(step.review ? { review: step.review } : {}),
|
|
306
401
|
...(step.effects ? { effects: step.effects } : {}),
|
|
402
|
+
...(step.watchdog ? { watchdog: step.watchdog } : {}),
|
|
307
403
|
...(step.processTerminal ? { processTerminal: sanitizeProcessTerminal(step.processTerminal, { runId: status.runId, runnerProcessInstanceId: step.processTerminal.runnerProcessInstanceId }, `${path.join(asyncDir, "status.json")} step ${index}`) } : {}),
|
|
404
|
+
...(timeoutRecovery ? { timeoutRecovery } : {}),
|
|
308
405
|
...(step.capabilityCeiling ? { capabilityCeiling: step.capabilityCeiling } : {}),
|
|
309
406
|
...(step.capabilityAudit ? { capabilityAudit: step.capabilityAudit } : {}),
|
|
310
407
|
...(step.children?.length ? { children: step.children } : {}),
|
|
311
408
|
};
|
|
312
409
|
});
|
|
313
410
|
attachRootChildrenToSteps(status.runId || path.basename(asyncDir), summarizedSteps, nestedChildren);
|
|
411
|
+
const sandbox = sandboxProfileValue(status.sandbox);
|
|
314
412
|
return {
|
|
315
413
|
id: status.runId || path.basename(asyncDir),
|
|
316
414
|
asyncDir,
|
|
@@ -328,6 +426,7 @@ function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string
|
|
|
328
426
|
steering: status.steering,
|
|
329
427
|
mode: status.mode,
|
|
330
428
|
...(summarizeContextModes(summarizedSteps.map((step) => step.context)) ? { context: summarizeContextModes(summarizedSteps.map((step) => step.context)) } : {}),
|
|
429
|
+
...(sandbox ? { sandbox } : {}),
|
|
331
430
|
cwd: status.cwd,
|
|
332
431
|
...(status.sessionRoot ? { sessionRoot: status.sessionRoot } : {}),
|
|
333
432
|
startedAt: status.startedAt,
|
|
@@ -344,6 +443,8 @@ function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string
|
|
|
344
443
|
...(status.chainStepCount !== undefined ? { chainStepCount: status.chainStepCount } : {}),
|
|
345
444
|
...(status.pendingAppends !== undefined ? { pendingAppends: status.pendingAppends } : {}),
|
|
346
445
|
...(parallelGroups.length ? { parallelGroups } : {}),
|
|
446
|
+
...(hostSteps.length ? { hostSteps } : {}),
|
|
447
|
+
...(status.mode === "workflow" && status.workflowGraph ? { workflowGraph: status.workflowGraph } : {}),
|
|
347
448
|
steps: summarizedSteps,
|
|
348
449
|
...(nestedChildren.length ? { nestedChildren } : {}),
|
|
349
450
|
...(nestedWarnings.length ? { nestedWarnings } : {}),
|
|
@@ -356,7 +457,10 @@ function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string
|
|
|
356
457
|
...(status.capabilityAudit ? { capabilityAudit: status.capabilityAudit } : {}),
|
|
357
458
|
...(status.parentWorkflowRunId ? { parentWorkflowRunId: status.parentWorkflowRunId } : {}),
|
|
358
459
|
...(status.workflowKey ? { workflowKey: status.workflowKey } : {}),
|
|
460
|
+
...(status.lane ? { lane: status.lane } : {}),
|
|
359
461
|
...(status.workflow ? { workflow: status.workflow } : {}),
|
|
462
|
+
...(workflowChildren ? { workflowChildren } : {}),
|
|
463
|
+
...(status.preflight ? { preflight: status.preflight } : {}),
|
|
360
464
|
...(status.sessionDir ? { sessionDir: status.sessionDir } : {}),
|
|
361
465
|
...(status.outputFile ? { outputFile: status.outputFile } : {}),
|
|
362
466
|
...(status.totalTokens ? { totalTokens: status.totalTokens } : {}),
|
|
@@ -376,6 +480,7 @@ function sortRuns(runs: AsyncRunSummary[]): AsyncRunSummary[] {
|
|
|
376
480
|
case "running": return 0;
|
|
377
481
|
case "queued": return 1;
|
|
378
482
|
case "failed": return 2;
|
|
483
|
+
case "partial": return 2;
|
|
379
484
|
case "stopped": return 2;
|
|
380
485
|
case "paused": return 2;
|
|
381
486
|
case "complete": return 3;
|
|
@@ -450,10 +555,17 @@ export function listAsyncRuns(asyncDirRoot: string, options: AsyncRunListOptions
|
|
|
450
555
|
};
|
|
451
556
|
for (const entry of entries) {
|
|
452
557
|
const asyncDir = path.join(asyncDirRoot, entry);
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
558
|
+
let status: (AsyncStatus & { cwd?: string }) | null;
|
|
559
|
+
try {
|
|
560
|
+
const reconciliation = options.reconcile === false
|
|
561
|
+
? undefined
|
|
562
|
+
: reconcileAsyncRun(asyncDir, { resultsDir: options.resultsDir, kill: options.kill, now: options.now });
|
|
563
|
+
status = (reconciliation?.status ?? readStatus(asyncDir)) as (AsyncStatus & { cwd?: string }) | null;
|
|
564
|
+
} catch (error) {
|
|
565
|
+
if (!activeEntries.has(entry) || !isAsyncStatusIsolationError(asyncDir, error)) throw error;
|
|
566
|
+
isolateCorruptActiveRun(asyncDir, entry, error, options.now);
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
457
569
|
if (!status) {
|
|
458
570
|
if (activeEntries.has(entry)) updateActiveRunIndex(asyncDir, "failed");
|
|
459
571
|
continue;
|
|
@@ -479,7 +591,14 @@ export function listAsyncRuns(asyncDirRoot: string, options: AsyncRunListOptions
|
|
|
479
591
|
nestedWarnings.push(`Nested status unavailable: ${getErrorMessage(error)}`);
|
|
480
592
|
}
|
|
481
593
|
}
|
|
482
|
-
|
|
594
|
+
let summary: AsyncRunSummary;
|
|
595
|
+
try {
|
|
596
|
+
summary = statusToSummary(asyncDir, status, nestedWarnings, nestedRoute);
|
|
597
|
+
} catch (error) {
|
|
598
|
+
if (!activeEntries.has(entry) || !isAsyncStatusIsolationError(asyncDir, error)) throw error;
|
|
599
|
+
isolateCorruptActiveRun(asyncDir, entry, error, options.now);
|
|
600
|
+
continue;
|
|
601
|
+
}
|
|
483
602
|
runs.push(summary);
|
|
484
603
|
}
|
|
485
604
|
|
|
@@ -504,7 +623,7 @@ function formatActivityFacts(input: { activityState?: ActivityState; lastActivit
|
|
|
504
623
|
}
|
|
505
624
|
|
|
506
625
|
function formatStepLine(step: AsyncRunStepSummary): string {
|
|
507
|
-
const display = step.label ? `${step.label} (${step.agent})` : step.agent;
|
|
626
|
+
const display = step.sessionName?.trim() || (step.label ? `${step.label} (${step.agent})` : step.agent);
|
|
508
627
|
const context = contextModeLabel(step.context);
|
|
509
628
|
const phase = step.phase ? `[${step.phase}] ` : "";
|
|
510
629
|
const parts = [`${step.index + 1}. ${phase}${display}${context ? ` ${context}` : ""}`, step.status];
|
|
@@ -514,15 +633,61 @@ function formatStepLine(step: AsyncRunStepSummary): string {
|
|
|
514
633
|
if (modelThinking) parts.push(modelThinking);
|
|
515
634
|
if (step.durationMs !== undefined) parts.push(formatDuration(step.durationMs));
|
|
516
635
|
if (step.tokens) parts.push(`${formatTokens(step.tokens.total)} tok`);
|
|
636
|
+
if (step.lane) parts.push(`lane ${step.lane.key}`);
|
|
637
|
+
if (step.worktreePath) parts.push(`worktree ${shortenPath(step.worktreePath)} · branch ${step.branch ?? "unknown"}${step.provider ? ` · provider ${step.provider}` : ""}`);
|
|
517
638
|
return parts.join(" | ");
|
|
518
639
|
}
|
|
519
640
|
|
|
641
|
+
function formatHostStepLine(row: ReturnType<typeof projectAsyncWorkflowRows>[number]): string {
|
|
642
|
+
if (!row.kind) return "";
|
|
643
|
+
const state = hostStepVerdictLabel(row.state as HostStepState, row.verdict);
|
|
644
|
+
const details = [
|
|
645
|
+
row.provider ? `provider:${row.provider}` : undefined,
|
|
646
|
+
row.role ? `role:${row.role}` : undefined,
|
|
647
|
+
row.target,
|
|
648
|
+
row.detail,
|
|
649
|
+
row.reasonCode ? `reason:${row.reasonCode}` : undefined,
|
|
650
|
+
row.freshness?.stale ? "stale" : row.freshness?.observedRef ? `ref:${row.freshness.observedRef}` : undefined,
|
|
651
|
+
row.reportPath ? `out:${hostStepReportName(row.reportPath)}` : undefined,
|
|
652
|
+
].filter((value): value is string => Boolean(value));
|
|
653
|
+
return `host ${row.kind}: ${row.name} | ${state}${details.length ? ` | ${details.join(" | ")}` : ""}`;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
function workflowStageStateLabel(status: WorkflowGraphSnapshot["nodes"][number]["status"]): string {
|
|
657
|
+
switch (status) {
|
|
658
|
+
case "completed":
|
|
659
|
+
return "complete";
|
|
660
|
+
case "detached":
|
|
661
|
+
return "paused";
|
|
662
|
+
default:
|
|
663
|
+
return status;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
export function formatWorkflowStageLine(node: WorkflowGraphSnapshot["nodes"][number], index: number, total: number): string {
|
|
668
|
+
const state = workflowStageStateLabel(node.status);
|
|
669
|
+
const id = previewDisplayText(node.id, 160);
|
|
670
|
+
const label = node.label ? previewDisplayText(node.label, 160) : "";
|
|
671
|
+
const display = label && label !== id ? ` | ${label}` : "";
|
|
672
|
+
const agent = node.agent ? ` | ${previewDisplayText(node.agent, 80)}` : "";
|
|
673
|
+
const error = node.error ? ` | ${previewDisplayText(node.error, 240)}` : "";
|
|
674
|
+
return `stage ${index + 1}/${total}: ${id}${display}${agent} | ${state}${error}`;
|
|
675
|
+
}
|
|
676
|
+
|
|
520
677
|
export function formatAsyncRunOutputPath(run: Pick<AsyncRunSummary, "asyncDir" | "outputFile">): string | undefined {
|
|
521
678
|
if (!run.outputFile) return undefined;
|
|
522
679
|
return path.isAbsolute(run.outputFile) ? run.outputFile : path.join(run.asyncDir, run.outputFile);
|
|
523
680
|
}
|
|
524
681
|
|
|
525
|
-
export function formatAsyncRunProgressLabel(run: Pick<AsyncRunSummary, "mode" | "state" | "currentStep" | "chainStepCount" | "parallelGroups" | "steps">): string {
|
|
682
|
+
export function formatAsyncRunProgressLabel(run: Pick<AsyncRunSummary, "mode" | "state" | "currentStep" | "chainStepCount" | "parallelGroups" | "steps"> & { workflowGraph?: WorkflowGraphSnapshot }): string {
|
|
683
|
+
const graphStages = run.mode === "workflow" ? workflowGraphStageNodes(run.workflowGraph) : [];
|
|
684
|
+
if (graphStages.length > 0) {
|
|
685
|
+
const currentNode = graphStages.find((node) => node.id === run.workflowGraph?.currentNodeId);
|
|
686
|
+
if (currentNode && currentNode.status !== "completed") return `stage ${graphStages.indexOf(currentNode) + 1}/${graphStages.length}`;
|
|
687
|
+
const activeNode = graphStages.find((node) => node.status === "running") ?? graphStages.find((node) => node.status !== "completed");
|
|
688
|
+
if (activeNode) return `stage ${graphStages.indexOf(activeNode) + 1}/${graphStages.length}`;
|
|
689
|
+
return `stage ${graphStages.length}/${graphStages.length}`;
|
|
690
|
+
}
|
|
526
691
|
const stepCount = run.steps.length || 1;
|
|
527
692
|
const chainStepCount = run.chainStepCount ?? stepCount;
|
|
528
693
|
const groups = normalizeParallelGroups(run.parallelGroups, run.steps.length, chainStepCount);
|
|
@@ -549,7 +714,8 @@ function formatRunHeader(run: AsyncRunSummary): string {
|
|
|
549
714
|
const activity = formatActivityFacts(run);
|
|
550
715
|
const pending = run.pendingAppends ? ` | ${run.pendingAppends} pending append${run.pendingAppends === 1 ? "" : "s"}` : "";
|
|
551
716
|
const context = contextModeLabel(run.context);
|
|
552
|
-
|
|
717
|
+
const lane = run.lane ? ` | lane ${run.lane.key}` : "";
|
|
718
|
+
return `${run.id} | ${run.state}${activity ? ` | ${activity}` : ""} | ${run.mode}${context ? ` ${context}` : ""} | ${stepLabel}${pending}${lane} | ${cwd}`;
|
|
553
719
|
}
|
|
554
720
|
|
|
555
721
|
export function formatAsyncRunList(runs: AsyncRunSummary[], heading = "Active async runs"): string {
|
|
@@ -558,10 +724,34 @@ export function formatAsyncRunList(runs: AsyncRunSummary[], heading = "Active as
|
|
|
558
724
|
const lines = [`${heading}: ${runs.length}`, ""];
|
|
559
725
|
for (const run of runs) {
|
|
560
726
|
lines.push(`- ${formatRunHeader(run)}`);
|
|
727
|
+
if (run.preflight) lines.push(formatWorkflowPreflightPlanSummary(run.preflight, { indent: " " }));
|
|
728
|
+
const preflightWarning = formatWorkflowPreflightWarningSummary(run.workflow?.preflightWarnings, { indent: " " });
|
|
729
|
+
if (preflightWarning) lines.push(preflightWarning);
|
|
730
|
+
if (run.mode === "workflow") {
|
|
731
|
+
const checklist = projectWorkflowChecklist({
|
|
732
|
+
graph: run.workflowGraph,
|
|
733
|
+
steps: run.steps,
|
|
734
|
+
hostSteps: run.hostSteps,
|
|
735
|
+
preflight: run.preflight,
|
|
736
|
+
trace: run.workflow?.trace,
|
|
737
|
+
now: run.lastUpdate ?? run.endedAt ?? Date.now(),
|
|
738
|
+
});
|
|
739
|
+
lines.push(...formatWorkflowChecklistText(checklist, " ", { includeItems: false }));
|
|
740
|
+
}
|
|
561
741
|
for (const step of run.steps) {
|
|
562
742
|
lines.push(` ${formatStepLine(step)}`);
|
|
743
|
+
lines.push(...formatTimeoutRecoveryLines(step.timeoutRecovery, " "));
|
|
563
744
|
lines.push(...formatNestedRunStatusLines(step.children, { indent: " ", maxLines: 12 }));
|
|
564
745
|
}
|
|
746
|
+
const loadedWorkflowKeys = new Set(run.steps.flatMap((step) => step.workflowKey ? [step.workflowKey] : []));
|
|
747
|
+
const graphStages = run.mode === "workflow" ? workflowGraphStageNodes(run.workflowGraph) : [];
|
|
748
|
+
for (const [index, node] of graphStages.entries()) {
|
|
749
|
+
if (!loadedWorkflowKeys.has(node.id)) lines.push(` ${formatWorkflowStageLine(node, index, graphStages.length)}`);
|
|
750
|
+
}
|
|
751
|
+
for (const row of projectAsyncWorkflowRows([], run.hostSteps)) {
|
|
752
|
+
const line = formatHostStepLine(row);
|
|
753
|
+
if (line) lines.push(` ${line}`);
|
|
754
|
+
}
|
|
565
755
|
const attached = new Set(run.steps.flatMap((step) => step.children?.map((child) => child.id) ?? []));
|
|
566
756
|
const unattached = run.nestedChildren?.filter((child) => !attached.has(child.id)) ?? [];
|
|
567
757
|
lines.push(...formatNestedRunStatusLines(unattached, { indent: " ", maxLines: 12 }));
|
|
@@ -62,7 +62,7 @@ export async function drainOutstandingWork(deps: AutoDrainDeps): Promise<void> {
|
|
|
62
62
|
},
|
|
63
63
|
);
|
|
64
64
|
if (waitResult.isError) {
|
|
65
|
-
throw new Error(`Auto-drain failed for session '${sessionId}': ${resultText(waitResult) || "
|
|
65
|
+
throw new Error(`Auto-drain failed for session '${sessionId}': ${resultText(waitResult) || "bg_wait returned an error without details"}.`);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -3,8 +3,9 @@ import * as fs from "node:fs";
|
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { writeAtomicJson } from "../../shared/atomic-json.ts";
|
|
5
5
|
import { appendJsonl } from "../../shared/artifacts.ts";
|
|
6
|
-
import type {
|
|
6
|
+
import type { AsyncStatus, WorkflowGraphNode, WorkflowGraphSnapshot } from "../../shared/types.ts";
|
|
7
7
|
import { PROMPT_REDACTED, readStatus } from "../../shared/utils.ts";
|
|
8
|
+
import { deriveChildSessionName } from "../../shared/child-session-name.ts";
|
|
8
9
|
import type { DynamicRunnerGroup, ParallelStepGroup, RunnerStep, RunnerSubagentStep } from "../shared/parallel-utils.ts";
|
|
9
10
|
import { isDynamicRunnerGroup, isParallelGroup } from "../shared/parallel-utils.ts";
|
|
10
11
|
|
|
@@ -160,8 +161,10 @@ export function statusStepDescription(task: string | undefined): string | undefi
|
|
|
160
161
|
|
|
161
162
|
function statusStepForTask(task: RunnerSubagentStep): StatusStep {
|
|
162
163
|
const description = statusStepDescription(task.task);
|
|
164
|
+
const sessionName = task.sessionName ?? deriveChildSessionName({ agent: task.agent, task: task.task, label: task.label });
|
|
163
165
|
return {
|
|
164
166
|
agent: task.agent,
|
|
167
|
+
...(sessionName ? { sessionName } : {}),
|
|
165
168
|
...(description ? { description } : {}),
|
|
166
169
|
...(task.context ? { context: task.context } : {}),
|
|
167
170
|
phase: task.phase,
|
|
@@ -172,6 +175,7 @@ function statusStepForTask(task: RunnerSubagentStep): StatusStep {
|
|
|
172
175
|
...(task.sessionFile ? { sessionFile: task.sessionFile } : {}),
|
|
173
176
|
skills: task.skills,
|
|
174
177
|
model: task.model,
|
|
178
|
+
...(task.contextLimit !== undefined ? { contextLimit: task.contextLimit } : {}),
|
|
175
179
|
thinking: task.thinking,
|
|
176
180
|
attemptedModels: task.modelCandidates && task.modelCandidates.length > 0 ? task.modelCandidates : task.model ? [task.model] : undefined,
|
|
177
181
|
recentTools: [],
|
|
@@ -179,7 +183,7 @@ function statusStepForTask(task: RunnerSubagentStep): StatusStep {
|
|
|
179
183
|
};
|
|
180
184
|
}
|
|
181
185
|
|
|
182
|
-
function statusStepsForRunnerStep(step: RunnerStep
|
|
186
|
+
function statusStepsForRunnerStep(step: RunnerStep): StatusStep[] {
|
|
183
187
|
if (isParallelGroup(step)) return step.parallel.map(statusStepForTask);
|
|
184
188
|
if (isDynamicRunnerGroup(step)) {
|
|
185
189
|
return [{
|
|
@@ -189,6 +193,7 @@ function statusStepsForRunnerStep(step: RunnerStep, stepIndex: number): StatusSt
|
|
|
189
193
|
label: step.label ?? step.parallel.label ?? `Dynamic fanout (${step.collect.as})`,
|
|
190
194
|
outputName: step.collect.as,
|
|
191
195
|
structured: Boolean(step.collect.outputSchema),
|
|
196
|
+
...(step.parallel.contextLimit !== undefined ? { contextLimit: step.parallel.contextLimit } : {}),
|
|
192
197
|
status: "pending",
|
|
193
198
|
recentTools: [],
|
|
194
199
|
recentOutput: [],
|
|
@@ -295,7 +300,7 @@ export function appendRunnerStepsToStatus(input: {
|
|
|
295
300
|
for (const step of input.steps) {
|
|
296
301
|
const stepIndex = input.status.chainStepCount ?? input.status.steps?.length ?? 0;
|
|
297
302
|
const flatIndex = input.status.steps?.length ?? 0;
|
|
298
|
-
const statusSteps = statusStepsForRunnerStep(step
|
|
303
|
+
const statusSteps = statusStepsForRunnerStep(step);
|
|
299
304
|
input.status.steps ??= [];
|
|
300
305
|
input.status.steps.push(...statusSteps);
|
|
301
306
|
if (isParallelGroup(step)) {
|