@xzzpig/pi-subagents 0.7.0 → 0.9.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 +456 -4
- package/README.md +3 -3
- 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 +13 -3
- package/agents/scout.md +1 -1
- package/docs/agents.md +154 -42
- package/docs/configuration.md +85 -26
- package/docs/extension-api.md +81 -16
- package/docs/missions.md +2 -0
- package/docs/models.md +75 -11
- package/docs/observability.md +34 -21
- package/docs/tool-reference.md +142 -18
- package/docs/watchdog.md +92 -114
- package/docs/workflows.md +148 -4
- package/index.ts +10 -1
- package/install.mjs +1 -1
- package/package.json +7 -6
- package/prompts/council.md +19 -7
- package/prompts/parallel-review.md +5 -1
- package/prompts/review-loop.md +11 -7
- package/skills/council-mode/SKILL.md +44 -215
- package/skills/council-mode/references/pass-contracts.md +150 -0
- package/skills/pi-subagents/SKILL.md +90 -32
- package/skills/pi-subagents/references/constraints-and-recipes.md +34 -223
- package/skills/pi-subagents/references/execution-controls.md +104 -19
- package/skills/pi-subagents/references/management-authoring-rpc.md +5 -5
- package/skills/pi-subagents/references/multi-lane-orchestration.md +16 -4
- package/skills/pi-subagents/references/prompting-and-roles.md +71 -36
- package/skills/pi-subagents/references/review-and-validation.md +73 -0
- package/src/agents/agent-management.ts +471 -114
- package/src/agents/agent-refinements.ts +4 -4
- package/src/agents/agent-serializer.ts +16 -4
- package/src/agents/agents.ts +1076 -351
- package/src/agents/builtin-names.ts +6 -0
- package/src/agents/runtime-agent-events.ts +70 -0
- package/src/agents/runtime-agent-registry.ts +31 -20
- 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-job-provider.ts +10 -1
- package/src/api/external-runs.ts +67 -4
- package/src/api/preflight.ts +97 -34
- package/src/api/project-panes.ts +2 -0
- package/src/api/shared-types.ts +6 -0
- package/src/extension/config.ts +90 -0
- package/src/extension/doctor.ts +15 -13
- package/src/extension/fanout-child.ts +17 -16
- package/src/extension/index.ts +139 -41
- package/src/extension/public-execution.ts +113 -22
- package/src/extension/rpc.ts +182 -13
- package/src/extension/schemas.ts +63 -21
- package/src/extension/tool-description.ts +48 -23
- package/src/extension/tool-result.ts +19 -0
- package/src/inspectors/herdr/actions.ts +2 -1
- package/src/inspectors/herdr/client.ts +3 -3
- package/src/inspectors/herdr/focus.ts +55 -0
- package/src/inspectors/herdr/inspector-runner.ts +21 -23
- package/src/inspectors/herdr/project-panes.ts +228 -44
- package/src/inspectors/herdr/session-roots-codec.ts +42 -0
- package/src/integrations/herdr-status.ts +75 -5
- package/src/intercom/native-supervisor-channel.ts +138 -60
- package/src/intercom/result-intercom.ts +2 -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 +492 -125
- package/src/runs/background/async-job-tracker.ts +127 -28
- package/src/runs/background/async-resume.ts +67 -29
- package/src/runs/background/async-retention.ts +21 -4
- package/src/runs/background/async-status-snapshot.ts +23 -261
- package/src/runs/background/async-status.ts +199 -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 +79 -8
- package/src/runs/background/control-channel.ts +101 -214
- package/src/runs/background/fleet-view.ts +38 -22
- package/src/runs/background/inspect-rpc.ts +8 -8
- package/src/runs/background/notify.ts +295 -8
- 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 +43 -19
- 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 +99 -18
- 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 +13 -4
- package/src/runs/background/steering.ts +8 -15
- package/src/runs/background/subagent-runner.ts +959 -1159
- 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 +45 -2
- package/src/runs/background/wait-config.ts +23 -9
- package/src/runs/background/wait-tool.ts +27 -19
- package/src/runs/foreground/async-steering-action.ts +3 -19
- package/src/runs/foreground/async-stop-action.ts +23 -2
- package/src/runs/foreground/execution.ts +585 -481
- package/src/runs/foreground/foreground-control.ts +13 -0
- package/src/runs/foreground/foreground-history.ts +26 -3
- package/src/runs/foreground/subagent-executor.ts +1549 -410
- package/src/runs/foreground/workflow-detach-reconcile.ts +141 -104
- 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 +147 -39
- package/src/runs/shared/agent-contract.ts +1 -1
- 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 +62 -0
- package/src/runs/shared/child-launch-plan.ts +151 -0
- package/src/runs/shared/child-launch.ts +314 -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 +342 -0
- package/src/runs/shared/child-tool-plan.ts +540 -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 +57 -6
- package/src/runs/shared/cursor-agent-adapter.ts +114 -0
- package/src/runs/shared/dynamic-fanout.ts +4 -4
- package/src/runs/shared/extension-bindings.ts +78 -0
- 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 +349 -54
- package/src/runs/shared/external-job-bridge.ts +53 -37
- package/src/runs/shared/external-job-runner.ts +126 -23
- package/src/runs/shared/fast-mode-extension.ts +10 -0
- 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 +141 -10
- package/src/runs/shared/model-fallback.ts +187 -33
- package/src/runs/shared/model-scope.ts +106 -39
- package/src/runs/shared/mutation-evidence.ts +199 -0
- package/src/runs/shared/nested-events.ts +38 -48
- 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 +83 -16
- package/src/runs/shared/parallel-handoff.ts +423 -7
- package/src/runs/shared/parallel-utils.ts +28 -5
- 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/single-output.ts +89 -22
- package/src/runs/shared/structured-output.ts +61 -7
- package/src/runs/shared/subagent-control.ts +6 -2
- package/src/runs/shared/subagent-prompt-runtime.ts +216 -360
- package/src/runs/shared/task-intent.ts +21 -7
- package/src/runs/shared/tool-availability.ts +18 -64
- 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 +20 -6
- package/src/shared/pruned-fork.ts +450 -0
- package/src/shared/session-file-trust.ts +19 -0
- package/src/shared/session-tokens.ts +14 -3
- package/src/shared/settings.ts +21 -102
- package/src/shared/shortcuts.ts +17 -0
- package/src/shared/thinking-ceiling.ts +46 -0
- package/src/shared/types.ts +644 -75
- 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 +278 -90
- 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 +1433 -166
- 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/permission-arbiter.ts +59 -52
- 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 +1142 -69
- 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 -858
- 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
package/src/tui/fleet-status.ts
CHANGED
|
@@ -2,8 +2,13 @@ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
|
2
2
|
import { type EditorComponent, isKeyRelease, Key, matchesKey, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
3
3
|
import { snapshotExternalRuns } from "../api/external-runs.ts";
|
|
4
4
|
import { formatModelThinking } from "../shared/formatters.ts";
|
|
5
|
-
import type { AsyncJobStep, FleetViewPlacement, NestedRunSummary, NestedStepSummary, SubagentState } from "../shared/types.ts";
|
|
5
|
+
import type { AsyncJobState, AsyncJobStep, FleetViewPlacement, HerdrProjectPaneSnapshot, HostStepState, HostStepVerdict, NestedRunSummary, NestedStepSummary, SubagentState } from "../shared/types.ts";
|
|
6
|
+
import { projectAsyncWorkflowRows, type AsyncStatusWorkflowRow } from "../runs/shared/async-status-projection.ts";
|
|
7
|
+
import { contextModeLabel } from "../runs/shared/context-mode.ts";
|
|
6
8
|
import { formatWorkflowJsonPreview } from "../workflows/scripted-workflow.ts";
|
|
9
|
+
import { hostStepReportName, hostStepVerdictLabel } from "../runs/shared/host-step-status.ts";
|
|
10
|
+
import { isStaleExtensionContextError } from "../shared/extension-context.ts";
|
|
11
|
+
import { formatWorkflowChecklistBottleneck, formatWorkflowChecklistPhase, formatWorkflowChecklistSummary, projectWorkflowChecklist, type WorkflowChecklistPhase, type WorkflowChecklistProjection } from "../workflows/workflow-checklist.ts";
|
|
7
12
|
|
|
8
13
|
export const FLEET_STATUS_WIDGET_KEY = "subagent-fleet-status";
|
|
9
14
|
|
|
@@ -17,6 +22,7 @@ type FleetStatusTui = {
|
|
|
17
22
|
};
|
|
18
23
|
type FleetStatusEntry = {
|
|
19
24
|
key: string;
|
|
25
|
+
surface?: "project-pane";
|
|
20
26
|
parentKey?: string;
|
|
21
27
|
workflowWrapper?: boolean;
|
|
22
28
|
agent: string;
|
|
@@ -24,20 +30,13 @@ type FleetStatusEntry = {
|
|
|
24
30
|
description?: string;
|
|
25
31
|
startedAt: number;
|
|
26
32
|
tokens: number;
|
|
33
|
+
window?: number;
|
|
27
34
|
state: string;
|
|
28
35
|
external?: true;
|
|
36
|
+
projectPane?: HerdrProjectPaneSnapshot;
|
|
29
37
|
nestedChildren?: NestedRunSummary[];
|
|
30
|
-
workflowRows?:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
type FleetWorkflowRow = {
|
|
34
|
-
name: string;
|
|
35
|
-
state: AsyncJobStep["status"];
|
|
36
|
-
modelThinking?: string;
|
|
37
|
-
activity?: string;
|
|
38
|
-
startedAt?: number;
|
|
39
|
-
tokens?: number;
|
|
40
|
-
overflow?: number;
|
|
38
|
+
workflowRows?: AsyncStatusWorkflowRow[];
|
|
39
|
+
workflowChecklist?: WorkflowChecklistProjection;
|
|
41
40
|
};
|
|
42
41
|
|
|
43
42
|
type FleetNestedRow = {
|
|
@@ -53,7 +52,8 @@ type FleetNestedRow = {
|
|
|
53
52
|
type FleetTreeRow =
|
|
54
53
|
| { kind: "owner"; entry: FleetStatusEntry }
|
|
55
54
|
| { kind: "child"; entry: FleetStatusEntry; last: boolean }
|
|
56
|
-
| { kind: "workflow"; ownerKey: string;
|
|
55
|
+
| { kind: "workflow-phase"; ownerKey: string; phase: WorkflowChecklistPhase; last: boolean }
|
|
56
|
+
| { kind: "workflow"; ownerKey: string; row: AsyncStatusWorkflowRow; last: boolean }
|
|
57
57
|
| { kind: "nested"; ownerKey: string; row: FleetNestedRow; last: boolean };
|
|
58
58
|
|
|
59
59
|
export interface FleetStatusOptions {
|
|
@@ -70,12 +70,15 @@ export function formatFleetElapsed(ms: number): string {
|
|
|
70
70
|
return `${Math.max(0, Math.round(ms / 1000))}s`;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
export function formatFleetTokens(count: number): string {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
export function formatFleetTokens(count: number, window?: number): string {
|
|
74
|
+
const compact = (value: number): string => value >= 1_000_000
|
|
75
|
+
? `${(value / 1_000_000).toFixed(1)}M`
|
|
76
|
+
: value >= 1_000
|
|
77
|
+
? `${(value / 1_000).toFixed(1)}k`
|
|
78
|
+
: `${Math.max(0, Math.round(value))}`;
|
|
79
|
+
return window !== undefined
|
|
80
|
+
? `↓ ${compact(window)} window · ${compact(count)} spent`
|
|
81
|
+
: `↓ ${compact(count)} tokens`;
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
function rightAlign(left: string, right: string, width: number): string {
|
|
@@ -104,44 +107,12 @@ function nestedActivity(node: NestedRunSummary | NestedStepSummary): string | un
|
|
|
104
107
|
return undefined;
|
|
105
108
|
}
|
|
106
109
|
|
|
107
|
-
function
|
|
108
|
-
if (step.currentTool) return `tool ${step.currentTool}`;
|
|
109
|
-
if (step.currentPath) return step.currentPath.split(/[\\/]/).at(-1);
|
|
110
|
-
if (step.activityState === "needs_attention") return "needs attention";
|
|
111
|
-
if (step.activityState === "active_long_running") return "long-running";
|
|
112
|
-
if (step.turnCount !== undefined) return `${step.turnCount} turns`;
|
|
113
|
-
if (step.toolCount !== undefined) return `${step.toolCount} tools`;
|
|
114
|
-
return undefined;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function workflowStepName(step: AsyncJobStep, index: number): string {
|
|
118
|
-
const key = step.workflowKey ?? `step ${index + 1}`;
|
|
119
|
-
const label = step.label && step.label !== key ? ` · ${step.label}` : "";
|
|
120
|
-
const phase = step.phase ? `${step.phase}: ` : "";
|
|
121
|
-
return `${phase}${key}${label} (${step.agent})`;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function workflowFleetRows(steps: AsyncJobStep[] | undefined): FleetWorkflowRow[] {
|
|
125
|
-
return (steps ?? []).map((step, index) => {
|
|
126
|
-
const modelThinking = formatModelThinking(step.model, step.thinking) || undefined;
|
|
127
|
-
const activity = workflowStepActivity(step);
|
|
128
|
-
return {
|
|
129
|
-
name: workflowStepName(step, index),
|
|
130
|
-
state: step.status,
|
|
131
|
-
...(modelThinking ? { modelThinking } : {}),
|
|
132
|
-
...(activity ? { activity } : {}),
|
|
133
|
-
...(step.startedAt !== undefined ? { startedAt: step.startedAt } : {}),
|
|
134
|
-
...(step.tokens?.total !== undefined ? { tokens: step.tokens.total } : {}),
|
|
135
|
-
};
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function visibleWorkflowRows(rows: FleetWorkflowRow[] | undefined, visibleLimit: number): FleetWorkflowRow[] {
|
|
110
|
+
function visibleWorkflowRows(rows: AsyncStatusWorkflowRow[] | undefined, visibleLimit: number): AsyncStatusWorkflowRow[] {
|
|
140
111
|
if (!rows?.length) return [];
|
|
141
112
|
if (rows.length <= visibleLimit) return rows;
|
|
142
113
|
const selected = new Set<number>();
|
|
143
114
|
for (const [index, row] of rows.entries()) {
|
|
144
|
-
if (row
|
|
115
|
+
if (!isWorkflowRowTerminal(row)) selected.add(index);
|
|
145
116
|
if (selected.size >= visibleLimit) break;
|
|
146
117
|
}
|
|
147
118
|
for (let index = rows.length - 1; index >= 0 && selected.size < visibleLimit; index--) selected.add(index);
|
|
@@ -149,9 +120,26 @@ function visibleWorkflowRows(rows: FleetWorkflowRow[] | undefined, visibleLimit:
|
|
|
149
120
|
return [{ name: `… +${rows.length - visible.length} hidden workflow steps`, state: "complete", overflow: rows.length - visible.length }, ...visible];
|
|
150
121
|
}
|
|
151
122
|
|
|
152
|
-
function
|
|
123
|
+
function visibleWorkflowPhases(checklist: WorkflowChecklistProjection | undefined, visibleLimit: number): WorkflowChecklistPhase[] {
|
|
124
|
+
const phases = checklist?.phases ?? [];
|
|
125
|
+
if (phases.length <= visibleLimit) return phases;
|
|
126
|
+
const selected = new Set<number>();
|
|
127
|
+
for (const [index, phase] of phases.entries()) {
|
|
128
|
+
if (phase.state !== "complete") selected.add(index);
|
|
129
|
+
if (selected.size >= visibleLimit) break;
|
|
130
|
+
}
|
|
131
|
+
for (let index = phases.length - 1; index >= 0 && selected.size < visibleLimit; index--) selected.add(index);
|
|
132
|
+
return [...selected].sort((left, right) => left - right).map((index) => phases[index]!);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function isWorkflowRowTerminal(row: AsyncStatusWorkflowRow): boolean {
|
|
136
|
+
if (row.kind) return row.state === "done" || row.state === "cancelled" || row.state === "error";
|
|
137
|
+
return row.state === "complete" || row.state === "completed";
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function nestedStatusGlyph(state: FleetNestedRow["state"] | "planned", theme: Theme): string {
|
|
153
141
|
if (state === "running") return theme.fg("accent", "●");
|
|
154
|
-
if (state === "queued" || state === "pending") return theme.fg("muted", "◦");
|
|
142
|
+
if (state === "queued" || state === "pending" || state === "planned") return theme.fg("muted", "◦");
|
|
155
143
|
if (state === "complete" || state === "completed") return theme.fg("success", "✓");
|
|
156
144
|
if (state === "failed" || state === "rejected") return theme.fg("error", "✗");
|
|
157
145
|
return theme.fg("warning", "■");
|
|
@@ -251,10 +239,11 @@ function fleetTreeRows(entries: FleetStatusEntry[]): FleetTreeRow[] {
|
|
|
251
239
|
if (entry.parentKey && entryKeys.has(entry.parentKey)) continue;
|
|
252
240
|
rows.push({ kind: "owner", entry });
|
|
253
241
|
const attached = childrenByParent.get(entry.key) ?? [];
|
|
242
|
+
const workflowPhases = visibleWorkflowPhases(entry.workflowChecklist, attached.length > 0 ? 2 : 4);
|
|
254
243
|
const workflowRows = visibleWorkflowRows(entry.workflowRows, attached.length > 0 ? 2 : 4);
|
|
255
244
|
for (const [index, child] of attached.entries()) {
|
|
256
245
|
const nested = nestedFleetRows(child.nestedChildren, 3);
|
|
257
|
-
const laterRows = index < attached.length - 1 || workflowRows.length > 0 || Boolean(entry.nestedChildren?.length);
|
|
246
|
+
const laterRows = index < attached.length - 1 || workflowPhases.length > 0 || workflowRows.length > 0 || Boolean(entry.nestedChildren?.length);
|
|
258
247
|
rows.push({ kind: "child", entry: child, last: !laterRows && nested.length === 0 });
|
|
259
248
|
for (const [nestedIndex, row] of nested.entries()) rows.push({
|
|
260
249
|
kind: "nested",
|
|
@@ -263,6 +252,12 @@ function fleetTreeRows(entries: FleetStatusEntry[]): FleetTreeRow[] {
|
|
|
263
252
|
last: nestedIndex === nested.length - 1 && !laterRows,
|
|
264
253
|
});
|
|
265
254
|
}
|
|
255
|
+
for (const [index, phase] of workflowPhases.entries()) rows.push({
|
|
256
|
+
kind: "workflow-phase",
|
|
257
|
+
ownerKey: entry.key,
|
|
258
|
+
phase,
|
|
259
|
+
last: index === workflowPhases.length - 1 && workflowRows.length === 0 && !entry.nestedChildren?.length,
|
|
260
|
+
});
|
|
266
261
|
for (const [index, row] of workflowRows.entries()) rows.push({ kind: "workflow", ownerKey: entry.key, row, last: index === workflowRows.length - 1 && !entry.nestedChildren?.length });
|
|
267
262
|
const nested = nestedFleetRows(entry.nestedChildren, attached.length > 0 ? 3 : 4);
|
|
268
263
|
for (const [index, row] of nested.entries()) rows.push({ kind: "nested", ownerKey: entry.key, row, last: index === nested.length - 1 });
|
|
@@ -270,21 +265,58 @@ function fleetTreeRows(entries: FleetStatusEntry[]): FleetTreeRow[] {
|
|
|
270
265
|
return rows;
|
|
271
266
|
}
|
|
272
267
|
|
|
273
|
-
function isStaleExtensionContextError(error: unknown): boolean {
|
|
274
|
-
// Pi currently exposes stale contexts as plain Errors without a stable code or subtype.
|
|
275
|
-
return error instanceof Error
|
|
276
|
-
&& (error.message.includes("This extension ctx is stale")
|
|
277
|
-
|| error.message.includes("Extension context no longer active"));
|
|
278
|
-
}
|
|
279
|
-
|
|
280
268
|
function foregroundDescription(control: { parentWorkflowRunId?: string; workflowKey?: string }, description: string | undefined): string | undefined {
|
|
281
269
|
if (!control.parentWorkflowRunId) return description;
|
|
282
270
|
const workflow = `workflow child: ${control.parentWorkflowRunId}${control.workflowKey ? ` (${control.workflowKey})` : ""}`;
|
|
283
271
|
return description ? `${workflow} · ${description}` : workflow;
|
|
284
272
|
}
|
|
285
273
|
|
|
274
|
+
function workflowIdentityCandidates(step: Pick<AsyncJobStep, "workflowKey" | "runId">): string[] {
|
|
275
|
+
return [...new Set([step.workflowKey, step.runId].filter((value): value is string => typeof value === "string" && value.length > 0))];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function asyncJobIdentityCandidates(job: AsyncJobState): string[] {
|
|
279
|
+
return [...new Set([job.workflowKey, job.asyncId].filter((value): value is string => typeof value === "string" && value.length > 0))];
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function linkedWorkflowParentKey(parentWorkflowRunId: string | undefined, activeWorkflowKeys: ReadonlySet<string>): string | undefined {
|
|
283
|
+
if (!parentWorkflowRunId) return undefined;
|
|
284
|
+
const parentKey = `async:${parentWorkflowRunId}`;
|
|
285
|
+
return activeWorkflowKeys.has(parentKey) ? parentKey : undefined;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function workflowStepsWithoutMaterializedChildren(steps: AsyncJobStep[] | undefined, materializedChildIds: ReadonlySet<string> | undefined): AsyncJobStep[] | undefined {
|
|
289
|
+
if (!steps?.length || !materializedChildIds?.size) return steps;
|
|
290
|
+
return steps.filter((step) => !workflowIdentityCandidates(step).some((identity) => materializedChildIds.has(identity)));
|
|
291
|
+
}
|
|
292
|
+
|
|
286
293
|
function activeLeafAgentCount(entries: FleetStatusEntry[]): number {
|
|
287
|
-
return entries.filter((entry) => !entry.workflowWrapper).length;
|
|
294
|
+
return entries.filter((entry) => !entry.workflowWrapper && !entry.surface).length;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function projectPaneNeedsAttention(pane: HerdrProjectPaneSnapshot): boolean {
|
|
298
|
+
return ["attention", "blocked", "paused", "failed", "error"].some((status) => pane.agentStatus.includes(status))
|
|
299
|
+
|| pane.summary?.includes("⚠") === true;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function projectName(projectRoot: string): string {
|
|
303
|
+
return projectRoot.split(/[\\/]/).filter(Boolean).at(-1) ?? projectRoot;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function projectPaneEntries(state: SubagentState): FleetStatusEntry[] {
|
|
307
|
+
return [...(state.herdrProjectPanes?.values() ?? [])]
|
|
308
|
+
.filter((pane) => pane.state === "open")
|
|
309
|
+
.sort((left, right) => left.openedAt.localeCompare(right.openedAt) || left.projectRoot.localeCompare(right.projectRoot))
|
|
310
|
+
.map((pane) => ({
|
|
311
|
+
key: `project-pane:${pane.projectRoot}`,
|
|
312
|
+
surface: "project-pane" as const,
|
|
313
|
+
agent: `${projectName(pane.projectRoot)} · ${pane.paneId}`,
|
|
314
|
+
description: pane.summary,
|
|
315
|
+
startedAt: Date.parse(pane.openedAt) || pane.refreshedAt,
|
|
316
|
+
tokens: 0,
|
|
317
|
+
state: pane.agentStatus || "unknown",
|
|
318
|
+
projectPane: pane,
|
|
319
|
+
}));
|
|
288
320
|
}
|
|
289
321
|
|
|
290
322
|
export function collectFleetStatusEntries(state: SubagentState): FleetStatusEntry[] {
|
|
@@ -292,12 +324,30 @@ export function collectFleetStatusEntries(state: SubagentState): FleetStatusEntr
|
|
|
292
324
|
const activeWorkflowKeys = new Set([...state.asyncJobs.values()]
|
|
293
325
|
.filter((job) => job.mode === "workflow" && isActiveState(job.status))
|
|
294
326
|
.map((job) => `async:${job.asyncId}`));
|
|
327
|
+
const materializedChildrenByWorkflow = new Map<string, Set<string>>();
|
|
328
|
+
for (const job of state.asyncJobs.values()) {
|
|
329
|
+
if (!isActiveState(job.status) || !job.parentWorkflowRunId) continue;
|
|
330
|
+
const parentKey = linkedWorkflowParentKey(job.parentWorkflowRunId, activeWorkflowKeys);
|
|
331
|
+
if (!parentKey) continue;
|
|
332
|
+
const childIds = materializedChildrenByWorkflow.get(parentKey) ?? new Set<string>();
|
|
333
|
+
for (const identity of asyncJobIdentityCandidates(job)) childIds.add(identity);
|
|
334
|
+
materializedChildrenByWorkflow.set(parentKey, childIds);
|
|
335
|
+
}
|
|
295
336
|
for (const control of state.foregroundControls.values()) {
|
|
296
|
-
const
|
|
297
|
-
const linkedParentKey = parentKey && activeWorkflowKeys.has(parentKey) ? parentKey : undefined;
|
|
337
|
+
const linkedParentKey = linkedWorkflowParentKey(control.parentWorkflowRunId, activeWorkflowKeys);
|
|
298
338
|
if (control.activeChildren) {
|
|
339
|
+
const nestedChildren = control.nestedChildren ?? [];
|
|
340
|
+
const nestedChildrenByParentStep = new Map<number, NestedRunSummary[]>();
|
|
341
|
+
for (const nested of nestedChildren) {
|
|
342
|
+
if (nested.parentStepIndex === undefined) continue;
|
|
343
|
+
const children = nestedChildrenByParentStep.get(nested.parentStepIndex) ?? [];
|
|
344
|
+
children.push(nested);
|
|
345
|
+
nestedChildrenByParentStep.set(nested.parentStepIndex, children);
|
|
346
|
+
}
|
|
299
347
|
for (const child of [...control.activeChildren.values()].sort((left, right) => left.index - right.index)) {
|
|
300
348
|
const modelThinking = formatModelThinking(child.model, child.thinking) || undefined;
|
|
349
|
+
const childNestedChildren = nestedChildrenByParentStep.get(child.index)
|
|
350
|
+
?? (control.activeChildren.size === 1 && nestedChildren.length ? nestedChildren : undefined);
|
|
301
351
|
entries.push({
|
|
302
352
|
key: `foreground-active:${control.runId}:${child.index}`,
|
|
303
353
|
...(linkedParentKey ? { parentKey: linkedParentKey } : {}),
|
|
@@ -306,10 +356,9 @@ export function collectFleetStatusEntries(state: SubagentState): FleetStatusEntr
|
|
|
306
356
|
description: foregroundDescription(control, child.description),
|
|
307
357
|
startedAt: child.startedAt,
|
|
308
358
|
tokens: child.tokens ?? 0,
|
|
359
|
+
...(child.window !== undefined ? { window: child.window } : {}),
|
|
309
360
|
state: "running",
|
|
310
|
-
...(
|
|
311
|
-
? { nestedChildren: control.nestedChildren!.filter((nested) => nested.parentStepIndex === child.index) }
|
|
312
|
-
: control.activeChildren.size === 1 && control.nestedChildren?.length ? { nestedChildren: control.nestedChildren } : {}),
|
|
361
|
+
...(childNestedChildren?.length ? { nestedChildren: childNestedChildren } : {}),
|
|
313
362
|
});
|
|
314
363
|
}
|
|
315
364
|
continue;
|
|
@@ -323,6 +372,7 @@ export function collectFleetStatusEntries(state: SubagentState): FleetStatusEntr
|
|
|
323
372
|
description: foregroundDescription(control, control.description),
|
|
324
373
|
startedAt: control.startedAt,
|
|
325
374
|
tokens: control.tokens ?? 0,
|
|
375
|
+
...(control.window !== undefined ? { window: control.window } : {}),
|
|
326
376
|
state: "running",
|
|
327
377
|
...(control.nestedChildren?.length ? { nestedChildren: control.nestedChildren } : {}),
|
|
328
378
|
});
|
|
@@ -331,17 +381,31 @@ export function collectFleetStatusEntries(state: SubagentState): FleetStatusEntr
|
|
|
331
381
|
for (const job of state.asyncJobs.values()) {
|
|
332
382
|
if (!isActiveState(job.status)) continue;
|
|
333
383
|
const startedAt = job.startedAt ?? job.updatedAt ?? Date.now();
|
|
384
|
+
const linkedParentKey = linkedWorkflowParentKey(job.parentWorkflowRunId, activeWorkflowKeys);
|
|
334
385
|
if (job.mode === "workflow") {
|
|
335
386
|
const latestEmit = job.workflow?.emits?.length ? formatWorkflowJsonPreview(job.workflow.emits.at(-1), 120) : undefined;
|
|
387
|
+
const workflowSteps = workflowStepsWithoutMaterializedChildren(job.steps, materializedChildrenByWorkflow.get(`async:${job.asyncId}`));
|
|
388
|
+
const workflowRows = projectAsyncWorkflowRows(workflowSteps, job.workflowGraph ?? job.hostSteps, job.preflight);
|
|
389
|
+
const workflowChecklist = projectWorkflowChecklist({
|
|
390
|
+
graph: job.workflowGraph,
|
|
391
|
+
steps: job.steps,
|
|
392
|
+
hostSteps: job.hostSteps,
|
|
393
|
+
preflight: job.preflight,
|
|
394
|
+
trace: job.workflow?.trace,
|
|
395
|
+
now: job.updatedAt ?? Date.now(),
|
|
396
|
+
});
|
|
336
397
|
entries.push({
|
|
337
398
|
key: `async:${job.asyncId}`,
|
|
399
|
+
...(linkedParentKey ? { parentKey: linkedParentKey } : {}),
|
|
338
400
|
workflowWrapper: true,
|
|
339
401
|
agent: "workflow",
|
|
340
402
|
description: latestEmit !== undefined ? `latest emit: ${latestEmit}` : job.description,
|
|
341
403
|
startedAt,
|
|
342
404
|
tokens: job.totalTokens?.total ?? 0,
|
|
405
|
+
...(job.totalTokens?.window !== undefined ? { window: job.totalTokens.window } : {}),
|
|
343
406
|
state: job.status,
|
|
344
|
-
...(
|
|
407
|
+
...(workflowRows.length ? { workflowRows } : {}),
|
|
408
|
+
...(workflowChecklist.total ? { workflowChecklist } : {}),
|
|
345
409
|
...(job.nestedChildren?.length ? { nestedChildren: job.nestedChildren } : {}),
|
|
346
410
|
});
|
|
347
411
|
continue;
|
|
@@ -356,10 +420,12 @@ export function collectFleetStatusEntries(state: SubagentState): FleetStatusEntr
|
|
|
356
420
|
if (!steps?.length) {
|
|
357
421
|
entries.push({
|
|
358
422
|
key: `async:${job.asyncId}`,
|
|
423
|
+
...(linkedParentKey ? { parentKey: linkedParentKey } : {}),
|
|
359
424
|
agent: job.mode ?? "subagent",
|
|
360
425
|
description: job.description,
|
|
361
426
|
startedAt,
|
|
362
427
|
tokens: job.totalTokens?.total ?? 0,
|
|
428
|
+
...(job.totalTokens?.window !== undefined ? { window: job.totalTokens.window } : {}),
|
|
363
429
|
state: job.status,
|
|
364
430
|
...(job.nestedChildren?.length ? { nestedChildren: job.nestedChildren } : {}),
|
|
365
431
|
});
|
|
@@ -372,11 +438,15 @@ export function collectFleetStatusEntries(state: SubagentState): FleetStatusEntr
|
|
|
372
438
|
const modelThinking = formatModelThinking(step.model, step.thinking) || undefined;
|
|
373
439
|
entries.push({
|
|
374
440
|
key: `async:${job.asyncId}:${index}`,
|
|
441
|
+
...(linkedParentKey ? { parentKey: linkedParentKey } : {}),
|
|
375
442
|
agent: step.label ? `${step.label} (${step.agent})` : step.agent,
|
|
376
443
|
...(modelThinking ? { modelThinking } : {}),
|
|
377
444
|
description: step.description ?? job.description,
|
|
378
445
|
startedAt: step.startedAt ?? startedAt,
|
|
379
446
|
tokens: step.tokens?.total ?? (steps.length === 1 ? job.totalTokens?.total ?? 0 : 0),
|
|
447
|
+
...((step.tokens?.window ?? (steps.length === 1 ? job.totalTokens?.window : undefined)) !== undefined
|
|
448
|
+
? { window: step.tokens?.window ?? job.totalTokens?.window }
|
|
449
|
+
: {}),
|
|
380
450
|
state: step.status,
|
|
381
451
|
...((step.children?.length ?? 0) > 0
|
|
382
452
|
? { nestedChildren: step.children }
|
|
@@ -406,6 +476,7 @@ export function collectFleetStatusEntries(state: SubagentState): FleetStatusEntr
|
|
|
406
476
|
}
|
|
407
477
|
}
|
|
408
478
|
|
|
479
|
+
entries.push(...projectPaneEntries(state));
|
|
409
480
|
return entries.sort((left, right) => left.startedAt - right.startedAt || left.key.localeCompare(right.key));
|
|
410
481
|
}
|
|
411
482
|
|
|
@@ -483,7 +554,7 @@ export class SubagentFleetStatus {
|
|
|
483
554
|
this.clearWidget();
|
|
484
555
|
return;
|
|
485
556
|
}
|
|
486
|
-
if (this.
|
|
557
|
+
if (!this.hasInlineSurface()) {
|
|
487
558
|
this.active = false;
|
|
488
559
|
this.selectedKey = "main";
|
|
489
560
|
this.lastRenderKey = "";
|
|
@@ -511,7 +582,12 @@ export class SubagentFleetStatus {
|
|
|
511
582
|
this.lastRenderKey = renderKey;
|
|
512
583
|
return;
|
|
513
584
|
}
|
|
514
|
-
if (renderKey === this.lastRenderKey)
|
|
585
|
+
if (renderKey === this.lastRenderKey) {
|
|
586
|
+
// Repaint anyway while anything is running so the wall-clock
|
|
587
|
+
// spinner animates between state changes (500ms tick).
|
|
588
|
+
if (this.entries.some((entry) => entry.state === "running")) this.tui?.requestRender();
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
515
591
|
this.lastRenderKey = renderKey;
|
|
516
592
|
this.tui?.requestRender();
|
|
517
593
|
}
|
|
@@ -578,26 +654,39 @@ export class SubagentFleetStatus {
|
|
|
578
654
|
}
|
|
579
655
|
|
|
580
656
|
render(width: number, theme: Theme): string[] {
|
|
581
|
-
if (this.
|
|
657
|
+
if (!this.hasInlineSurface()) return [];
|
|
582
658
|
if (!this.active) {
|
|
583
|
-
const
|
|
659
|
+
const workEntries = this.entries.filter((entry) => !entry.surface);
|
|
660
|
+
const projectEntries = this.entries.filter((entry) => entry.surface === "project-pane");
|
|
661
|
+
const tokens = workEntries.reduce((total, entry) => total + entry.tokens, 0);
|
|
662
|
+
const nativeEntries = workEntries.filter((entry) => !entry.external);
|
|
663
|
+
const window = nativeEntries.length > 0 && nativeEntries.every((entry) => entry.window !== undefined)
|
|
664
|
+
? nativeEntries.reduce((total, entry) => total + entry.window!, 0)
|
|
665
|
+
: undefined;
|
|
584
666
|
const capacity = this.state.activeAsyncCapacity;
|
|
585
|
-
const hasNativeRows =
|
|
667
|
+
const hasNativeRows = workEntries.some((entry) => !entry.external);
|
|
586
668
|
const showNativeSummary = hasNativeRows || Boolean(capacity?.used);
|
|
587
669
|
const asyncRuns = capacity && showNativeSummary ? `Async runs ${capacity.used}/${capacity.limit || "∞"}` : "";
|
|
588
|
-
const activeEntries = activeLeafAgentCount(
|
|
589
|
-
const noun =
|
|
670
|
+
const activeEntries = activeLeafAgentCount(workEntries);
|
|
671
|
+
const noun = workEntries.some((entry) => entry.external) ? "job" : "agent";
|
|
590
672
|
const agents = activeEntries > 0 ? `${activeEntries} active ${noun}${activeEntries === 1 ? "" : "s"}` : "";
|
|
591
|
-
const
|
|
592
|
-
const
|
|
593
|
-
|
|
673
|
+
const paneAttention = projectEntries.filter((entry) => entry.projectPane && projectPaneNeedsAttention(entry.projectPane)).length;
|
|
674
|
+
const panes = projectEntries.length > 0 ? `${projectEntries.length} pane${projectEntries.length === 1 ? "" : "s"}${paneAttention ? ` (${paneAttention} ⚠)` : ""}` : "";
|
|
675
|
+
const label = [agents, asyncRuns, panes].filter(Boolean).join(" · ");
|
|
676
|
+
const detail = [showNativeSummary ? formatFleetTokens(tokens, window) : undefined, "↓/← to inspect"].filter(Boolean).join(" · ");
|
|
677
|
+
return [truncateToWidth(` ${theme.fg("muted", label)}${label && detail ? " · " : ""}${theme.fg("dim", detail)}`, width)];
|
|
594
678
|
}
|
|
595
679
|
const roster = this.rosterKeys();
|
|
596
680
|
const selectedIndex = Math.max(0, roster.indexOf(this.selectedKey));
|
|
681
|
+
const rosterIndexByKey = new Map<string, number>();
|
|
682
|
+
for (const [index, entry] of this.entries.entries()) {
|
|
683
|
+
if (!rosterIndexByKey.has(entry.key)) rosterIndexByKey.set(entry.key, index + 1);
|
|
684
|
+
}
|
|
597
685
|
const lines = [truncateToWidth(` ${theme.fg("dim", "↑↓/jk select · enter inspect · esc back")}`, width), ""];
|
|
598
686
|
lines.push(truncateToWidth(` ${this.bullet(0, selectedIndex, theme)} main`, width));
|
|
599
687
|
|
|
600
|
-
const
|
|
688
|
+
const workEntries = this.entries.filter((entry) => !entry.surface);
|
|
689
|
+
const tree = fleetTreeRows(workEntries);
|
|
601
690
|
const selectedTreeIndex = Math.max(0, tree.findIndex((row) => (row.kind === "owner" || row.kind === "child") && row.entry.key === this.selectedKey));
|
|
602
691
|
const visibleCount = Math.min(this.maxAgentRows, tree.length);
|
|
603
692
|
const start = selectedTreeIndex < visibleCount ? 0 : selectedTreeIndex - visibleCount + 1;
|
|
@@ -606,24 +695,44 @@ export class SubagentFleetStatus {
|
|
|
606
695
|
for (let index = start; index < start + visibleCount; index++) {
|
|
607
696
|
const row = tree[index]!;
|
|
608
697
|
if (row.kind === "owner" || row.kind === "child") {
|
|
609
|
-
const
|
|
610
|
-
lines.push(this.renderEntry(
|
|
698
|
+
const rosterIndex = rosterIndexByKey.get(row.entry.key) ?? 0;
|
|
699
|
+
lines.push(this.renderEntry(rosterIndex, selectedIndex, row.entry, width, theme, row.kind === "child" ? (row.last ? "└─" : "├─") : undefined));
|
|
611
700
|
} else if (row.kind === "workflow") {
|
|
612
701
|
lines.push(this.renderWorkflowRow(row.row, row.last, width, theme));
|
|
702
|
+
} else if (row.kind === "workflow-phase") {
|
|
703
|
+
lines.push(this.renderWorkflowPhaseRow(row.phase, row.last, width, theme));
|
|
613
704
|
} else {
|
|
614
705
|
lines.push(this.renderNestedRow(row.row, row.last, width, theme));
|
|
615
706
|
}
|
|
616
707
|
}
|
|
617
708
|
if (hiddenBelow > 0) lines.push(rightAlign("", theme.fg("dim", `↓ ${hiddenBelow} more`), width));
|
|
709
|
+
this.renderProjectPaneSection(lines, selectedIndex, width, theme, rosterIndexByKey);
|
|
618
710
|
return lines;
|
|
619
711
|
}
|
|
620
712
|
|
|
713
|
+
private renderProjectPaneSection(lines: string[], selectedIndex: number, width: number, theme: Theme, rosterIndexByKey: ReadonlyMap<string, number>): void {
|
|
714
|
+
const entries = this.entries.filter((entry) => entry.surface === "project-pane");
|
|
715
|
+
if (!entries.length) return;
|
|
716
|
+
lines.push("", truncateToWidth(` ${theme.fg("dim", "project panes")}`, width));
|
|
717
|
+
for (const entry of entries) {
|
|
718
|
+
const rosterIndex = rosterIndexByKey.get(entry.key) ?? 0;
|
|
719
|
+
lines.push(this.renderEntry(rosterIndex, selectedIndex, entry, width, theme));
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
|
|
621
724
|
private renderEntry(rosterIndex: number, selectedIndex: number, entry: FleetStatusEntry, width: number, theme: Theme, branch?: string): string {
|
|
622
725
|
const agent = entry.modelThinking ? `${entry.agent} (${entry.modelThinking})` : entry.agent;
|
|
623
726
|
const prefix = branch ? ` ${branch}` : " ";
|
|
624
|
-
const
|
|
727
|
+
const checklist = entry.workflowWrapper && entry.workflowChecklist
|
|
728
|
+
? ` · checklist ${formatWorkflowChecklistSummary(entry.workflowChecklist)}${entry.workflowChecklist.bottleneck ? ` · bottleneck ${formatWorkflowChecklistBottleneck(entry.workflowChecklist.bottleneck)}` : ""}`
|
|
729
|
+
: "";
|
|
730
|
+
const left = `${prefix} ${this.bullet(rosterIndex, selectedIndex, theme)} ${theme.fg("muted", agent)} · ${entry.state}${checklist}`;
|
|
625
731
|
const elapsed = Date.now() - entry.startedAt;
|
|
626
|
-
const
|
|
732
|
+
const rightText = entry.projectPane
|
|
733
|
+
? `${entry.projectPane.summary ?? "—"} · ${formatFleetElapsed(Date.now() - entry.projectPane.refreshedAt)} ago`
|
|
734
|
+
: entry.external ? formatFleetElapsed(elapsed) : `${formatFleetElapsed(elapsed)} · ${formatFleetTokens(entry.tokens, entry.window)}`;
|
|
735
|
+
const right = theme.fg("dim", rightText);
|
|
627
736
|
return rightAlign(left, right, width);
|
|
628
737
|
}
|
|
629
738
|
|
|
@@ -638,16 +747,65 @@ export class SubagentFleetStatus {
|
|
|
638
747
|
return truncateToWidth(`${left}${theme.fg("dim", elapsed)}`, width);
|
|
639
748
|
}
|
|
640
749
|
|
|
641
|
-
private
|
|
750
|
+
private workflowRowGlyph(row: AsyncStatusWorkflowRow, theme: Theme): string {
|
|
751
|
+
if (!row.kind) return nestedStatusGlyph(row.state as FleetNestedRow["state"], theme);
|
|
752
|
+
const state = row.state as HostStepState;
|
|
753
|
+
if (state === "pending") return theme.fg("muted", "◦");
|
|
754
|
+
if (state === "running") return theme.fg("accent", "●");
|
|
755
|
+
if (state === "done") return row.verdict === "pass" ? theme.fg("success", "✓") : row.verdict === "fail" ? theme.fg("error", "✗") : theme.fg("warning", "■");
|
|
756
|
+
if (state === "error") return theme.fg("error", "✗");
|
|
757
|
+
return theme.fg("warning", "■");
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
private workflowRowStateLabel(row: AsyncStatusWorkflowRow, theme: Theme): string {
|
|
761
|
+
const state = row.kind ? hostStepVerdictLabel(row.state as HostStepState, row.verdict as HostStepVerdict | undefined) : row.state;
|
|
762
|
+
if (state === "running") return theme.fg("accent", state);
|
|
763
|
+
if (state === "pending" || state === "queued") return theme.fg("muted", state);
|
|
764
|
+
if (state === "pass" || state === "complete" || state === "completed") return theme.fg("success", state === "pass" ? "pass" : "complete");
|
|
765
|
+
if (state === "fail" || state === "failed" || state === "error") return theme.fg("error", state === "fail" ? "fail" : state);
|
|
766
|
+
return theme.fg("warning", state);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
private renderWorkflowPhaseRow(phase: WorkflowChecklistPhase, last: boolean, width: number, theme: Theme): string {
|
|
770
|
+
const marker = last ? "└─" : "├─";
|
|
771
|
+
const glyph = phase.state === "complete"
|
|
772
|
+
? theme.fg("success", "✓")
|
|
773
|
+
: phase.state === "running"
|
|
774
|
+
? theme.fg("accent", "●")
|
|
775
|
+
: phase.state === "blocked" || phase.state === "failed"
|
|
776
|
+
? theme.fg("error", phase.state === "blocked" ? "!" : "✗")
|
|
777
|
+
: phase.state === "queued"
|
|
778
|
+
? theme.fg("muted", "◦")
|
|
779
|
+
: theme.fg("warning", "■");
|
|
780
|
+
return truncateToWidth(` ${marker} ${glyph} ${theme.fg("muted", formatWorkflowChecklistPhase(phase))}`, width);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
private renderWorkflowRow(row: AsyncStatusWorkflowRow, last: boolean, width: number, theme: Theme): string {
|
|
642
784
|
const marker = last ? "└─" : "├─";
|
|
643
785
|
const indent = " ";
|
|
644
786
|
if (row.overflow !== undefined) return truncateToWidth(`${indent}${marker} ${theme.fg("dim", `+${row.overflow} hidden workflow steps`)}`, width);
|
|
787
|
+
const context = contextModeLabel(row.context);
|
|
645
788
|
const modelThinking = row.modelThinking ? ` (${row.modelThinking})` : "";
|
|
646
789
|
const activity = row.activity ? ` · ${row.activity}` : "";
|
|
647
|
-
const
|
|
790
|
+
const kind = row.kind ? `${row.kind}: ` : "";
|
|
791
|
+
const hints = row.preflight ? [
|
|
792
|
+
row.preflight.mode ? `mode:${row.preflight.mode}` : undefined,
|
|
793
|
+
row.preflight.decision ? `decision:${row.preflight.decision}` : undefined,
|
|
794
|
+
row.preflight.claims?.length ? `claims:${row.preflight.claims.join(",")}` : undefined,
|
|
795
|
+
row.preflight.expectedOutput ? `expected:${row.preflight.expectedOutput}` : undefined,
|
|
796
|
+
row.preflight.independence ? `independence:${row.preflight.independence}` : undefined,
|
|
797
|
+
].filter((value): value is string => Boolean(value)).join(" · ") : "";
|
|
798
|
+
const left = `${indent}${marker} ${this.workflowRowGlyph(row, theme)} ${theme.fg("muted", `${kind}${row.name}${context ? ` ${context}` : ""}${modelThinking}`)} · ${this.workflowRowStateLabel(row, theme)}${activity}${hints ? ` · ${hints}` : ""}`;
|
|
648
799
|
const details = [
|
|
649
800
|
row.startedAt !== undefined ? formatFleetElapsed(Date.now() - row.startedAt) : undefined,
|
|
650
|
-
row.tokens !== undefined ? formatFleetTokens(row.tokens) : undefined,
|
|
801
|
+
row.tokens !== undefined ? formatFleetTokens(row.tokens, row.window) : undefined,
|
|
802
|
+
row.provider ? `provider:${row.provider}` : undefined,
|
|
803
|
+
row.role ? `role:${row.role}` : undefined,
|
|
804
|
+
row.target,
|
|
805
|
+
row.detail,
|
|
806
|
+
row.reasonCode ? `reason:${row.reasonCode}` : undefined,
|
|
807
|
+
row.freshness?.stale ? "stale" : row.freshness?.observedRef ? `ref:${row.freshness.observedRef}` : undefined,
|
|
808
|
+
row.reportPath ? `out:${hostStepReportName(row.reportPath)}` : undefined,
|
|
651
809
|
].filter(Boolean).join(" · ");
|
|
652
810
|
return truncateToWidth(`${left}${details ? theme.fg("dim", ` · ${details}`) : ""}`, width);
|
|
653
811
|
}
|
|
@@ -692,6 +850,7 @@ export class SubagentFleetStatus {
|
|
|
692
850
|
entries: this.entries.map((entry) => this.active
|
|
693
851
|
? [
|
|
694
852
|
entry.key,
|
|
853
|
+
entry.surface,
|
|
695
854
|
entry.parentKey,
|
|
696
855
|
entry.agent,
|
|
697
856
|
entry.state,
|
|
@@ -700,13 +859,32 @@ export class SubagentFleetStatus {
|
|
|
700
859
|
entry.external,
|
|
701
860
|
Math.round((now - entry.startedAt) / 1000),
|
|
702
861
|
entry.tokens,
|
|
862
|
+
entry.workflowChecklist ? [
|
|
863
|
+
entry.workflowChecklist.total,
|
|
864
|
+
entry.workflowChecklist.done,
|
|
865
|
+
entry.workflowChecklist.running,
|
|
866
|
+
entry.workflowChecklist.queued,
|
|
867
|
+
entry.workflowChecklist.blocked,
|
|
868
|
+
entry.workflowChecklist.failed,
|
|
869
|
+
entry.workflowChecklist.phases.map((phase) => [phase.key, phase.state, phase.done, phase.total, phase.running, phase.queued, phase.blocked, phase.failed, phase.items.map((item) => [item.key, item.state, item.currentTool, item.currentPath, item.durationMs, item.toolCount, item.error])]),
|
|
870
|
+
] : undefined,
|
|
703
871
|
visibleWorkflowRows(entry.workflowRows, entry.parentKey ? 2 : 4).map((row) => [
|
|
872
|
+
row.kind,
|
|
704
873
|
row.name,
|
|
705
874
|
row.state,
|
|
875
|
+
row.context,
|
|
706
876
|
row.modelThinking,
|
|
707
877
|
row.activity,
|
|
708
878
|
row.startedAt,
|
|
709
879
|
row.tokens,
|
|
880
|
+
row.provider,
|
|
881
|
+
row.role,
|
|
882
|
+
row.verdict,
|
|
883
|
+
row.reasonCode,
|
|
884
|
+
row.detail,
|
|
885
|
+
row.target,
|
|
886
|
+
row.freshness,
|
|
887
|
+
row.reportPath,
|
|
710
888
|
row.overflow,
|
|
711
889
|
]),
|
|
712
890
|
nestedFleetRows(entry.nestedChildren, entry.parentKey ? 3 : 4).map((row) => [
|
|
@@ -719,10 +897,14 @@ export class SubagentFleetStatus {
|
|
|
719
897
|
row.overflow,
|
|
720
898
|
]),
|
|
721
899
|
]
|
|
722
|
-
: [entry.key, entry.state, entry.external, entry.tokens]),
|
|
900
|
+
: [entry.key, entry.state, entry.external, entry.surface, entry.tokens, entry.projectPane?.refreshedAt, entry.projectPane?.summary]),
|
|
723
901
|
});
|
|
724
902
|
}
|
|
725
903
|
|
|
904
|
+
private hasInlineSurface(): boolean {
|
|
905
|
+
return this.entries.length > 0 || Boolean(this.state.activeAsyncCapacity?.used);
|
|
906
|
+
}
|
|
907
|
+
|
|
726
908
|
private getActiveUiContext(): ExtensionContext | undefined {
|
|
727
909
|
const ctx = this.ctx;
|
|
728
910
|
if (!ctx) return undefined;
|
|
@@ -737,7 +919,13 @@ export class SubagentFleetStatus {
|
|
|
737
919
|
|
|
738
920
|
private clearWidget(): void {
|
|
739
921
|
if (!this.widgetRegistered) return;
|
|
740
|
-
|
|
922
|
+
try {
|
|
923
|
+
this.ui?.setWidget(FLEET_STATUS_WIDGET_KEY, undefined);
|
|
924
|
+
} catch (error) {
|
|
925
|
+
if (!isStaleExtensionContextError(error)) throw error;
|
|
926
|
+
this.clearUiRegistration();
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
741
929
|
this.widgetRegistered = false;
|
|
742
930
|
this.tui = undefined;
|
|
743
931
|
}
|