@xzzpig/pi-subagents 0.16.0 → 0.19.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 +233 -1
- package/README.md +5 -3
- package/agents/claude-code-writer.md +1 -0
- package/agents/codex-exec-writer.md +1 -0
- package/agents/cursor-agent-writer.md +1 -0
- package/agents/reviewer.md +3 -2
- package/agents/worker.md +3 -2
- package/docs/agents.md +34 -21
- package/docs/configuration.md +82 -7
- package/docs/extension-api.md +75 -8
- package/docs/missions.md +13 -13
- package/docs/models.md +7 -5
- package/docs/observability.md +23 -13
- package/docs/standalone-background.md +5 -5
- package/docs/tool-reference.md +98 -100
- package/docs/watchdog.md +2 -0
- package/docs/workflows.md +214 -162
- package/inspector-runner.mjs +1 -1
- package/node_modules/@xzzpig/pi-components/package.json +4 -4
- package/package.json +15 -9
- package/prompts/council.md +6 -3
- package/prompts/review-loop.md +1 -1
- package/runner-peer-loader.mjs +4 -7
- package/runner-peer-preload.mjs +5 -7
- package/skills/council-mode/SKILL.md +1 -1
- package/skills/pi-subagents/SKILL.md +13 -5
- package/skills/pi-subagents/references/constraints-and-recipes.md +8 -5
- package/skills/pi-subagents/references/execution-controls.md +72 -69
- package/skills/pi-subagents/references/management-authoring-rpc.md +4 -4
- package/skills/pi-subagents/references/multi-lane-orchestration.md +9 -1
- package/skills/pi-subagents/references/prompting-and-roles.md +52 -54
- package/src/agents/advertised-agent-prompt.ts +21 -41
- package/src/agents/agent-eject.ts +3 -3
- package/src/agents/agent-management.ts +63 -54
- package/src/agents/agent-memory.ts +90 -3
- package/src/agents/agent-serializer.ts +4 -4
- package/src/agents/agents.ts +132 -51
- package/src/agents/global-npm-root.ts +58 -0
- package/src/agents/proactive-skills.ts +4 -1
- package/src/agents/runtime-agent-registry.ts +14 -11
- package/src/agents/skills.ts +42 -9
- package/src/api/delegation.ts +15 -0
- package/src/api/inspectors.ts +27 -0
- package/src/api/preflight.ts +7 -2
- package/src/extension/config.ts +12 -4
- package/src/extension/control-notices.ts +3 -0
- package/src/extension/doctor.ts +10 -4
- package/src/extension/fanout-child.ts +20 -3
- package/src/extension/herdr-pi-bridge.ts +2 -0
- package/src/extension/index.ts +168 -206
- package/src/extension/public-execution.ts +69 -35
- package/src/extension/reply-workflow-script.ts +58 -0
- package/src/extension/rpc.ts +39 -11
- package/src/extension/schemas.ts +47 -138
- package/src/extension/subagent-guide.ts +12 -4
- package/src/extension/tool-activation.ts +146 -0
- package/src/extension/tool-description.ts +62 -27
- package/src/extension/upgrade-notice.ts +40 -0
- package/src/inspectors/ghostty/plugin.ts +13 -1
- package/src/inspectors/plugins.ts +70 -3
- package/src/integrations/herdr-status.ts +19 -3
- package/src/intercom/intercom-bridge.ts +2 -0
- package/src/intercom/native-supervisor-channel.ts +26 -16
- package/src/intercom/result-intercom.ts +4 -0
- package/src/runs/background/active-async-capacity.ts +3 -25
- package/src/runs/background/async-execution.ts +60 -95
- package/src/runs/background/async-job-tracker.ts +91 -56
- package/src/runs/background/async-resume.ts +16 -8
- package/src/runs/background/async-retention.ts +46 -16
- package/src/runs/background/async-status.ts +2 -0
- package/src/runs/background/await-async-run.ts +76 -0
- package/src/runs/background/binary-bootstrap.ts +34 -6
- package/src/runs/background/chain-root-attachment.ts +4 -4
- package/src/runs/background/control-channel.ts +18 -2
- package/src/runs/background/fleet-view.ts +51 -7
- package/src/runs/background/notify.ts +98 -7
- package/src/runs/background/pid-namespace.ts +18 -0
- package/src/runs/background/process-terminal-candidate.ts +98 -0
- package/src/runs/background/process-terminal.ts +17 -96
- package/src/runs/background/result-watcher.ts +1 -1
- package/src/runs/background/retained-children.ts +3 -2
- package/src/runs/background/run-child-session.ts +20 -6
- package/src/runs/background/run-id-resolver.ts +10 -5
- package/src/runs/background/run-status.ts +16 -4
- package/src/runs/background/runner-aliases.ts +54 -16
- package/src/runs/background/runner-child-launch.ts +4 -2
- package/src/runs/background/runner-startup-failure.ts +56 -0
- package/src/runs/background/scheduled-runs.ts +5 -5
- package/src/runs/background/stale-run-reconciler.ts +19 -3
- package/src/runs/background/subagent-runner-bootstrap.ts +276 -0
- package/src/runs/background/subagent-runner.ts +111 -288
- package/src/runs/background/wait-tool.ts +2 -0
- package/src/runs/background/workflow-terminal-proof.ts +68 -0
- package/src/runs/foreground/async-stop-action.ts +17 -3
- package/src/runs/foreground/execution.ts +111 -139
- package/src/runs/foreground/prompt-audit.ts +3 -9
- package/src/runs/foreground/subagent-executor.ts +715 -258
- package/src/runs/shared/acceptance.ts +167 -68
- package/src/runs/shared/async-status-projection.ts +5 -0
- package/src/runs/shared/capability-ceiling.ts +4 -1
- package/src/runs/shared/child-hooks.ts +1 -16
- package/src/runs/shared/child-launch.ts +37 -16
- package/src/runs/shared/child-runtime-config.ts +3 -0
- package/src/runs/shared/child-session.ts +144 -8
- package/src/runs/shared/child-tool-plan.ts +38 -116
- package/src/runs/shared/dynamic-fanout.ts +1 -1
- package/src/runs/shared/external-cli-runner.ts +3 -1
- package/src/runs/shared/external-job-bridge.ts +54 -0
- package/src/runs/shared/git-environment.ts +29 -0
- package/src/runs/shared/mcp-config-sources.ts +5 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.ts +104 -12
- package/src/runs/shared/mcp-direct-tool-grant.ts +22 -6
- package/src/runs/shared/model-resolution.ts +35 -10
- package/src/runs/shared/model-scope.ts +28 -9
- package/src/runs/shared/nested-events.ts +12 -0
- package/src/runs/shared/orca-progress-tabs.ts +3 -2
- package/src/runs/shared/parallel-utils.ts +4 -1
- package/src/runs/shared/pi-spawn.ts +1 -3
- package/src/runs/shared/single-output.ts +11 -2
- package/src/runs/shared/structured-output.ts +227 -7
- package/src/runs/shared/subagent-control.ts +2 -16
- package/src/runs/shared/subagent-prompt-runtime.ts +29 -5
- package/src/runs/shared/tool-availability.ts +2 -2
- package/src/runs/shared/tool-budget.ts +21 -0
- package/src/runs/shared/usage-reconciliation.ts +73 -0
- package/src/runs/shared/worktree.ts +36 -9
- package/src/shared/child-session-name.ts +4 -2
- package/src/shared/disabled-features.ts +123 -0
- package/src/shared/extension-context.ts +13 -0
- package/src/shared/fork-context.ts +11 -4
- package/src/shared/launch-contract.ts +1 -1
- package/src/shared/model-info.ts +9 -0
- package/src/shared/pruned-fork.ts +69 -56
- package/src/shared/settings.ts +1 -1
- package/src/shared/types.ts +73 -16
- package/src/slash/delegation-adapters.ts +25 -1
- package/src/slash/prompt-template-bridge.ts +18 -3
- package/src/slash/prompt-workflows.ts +12 -1
- package/src/slash/slash-commands.ts +17 -246
- package/src/slash/subagent-cost.ts +313 -0
- package/src/slash/subagents-admin.ts +4 -5
- package/src/tui/fleet-status.ts +38 -8
- package/src/tui/fleet.ts +21 -6
- package/src/tui/render.ts +166 -71
- package/src/tui/running-tone.ts +28 -0
- package/src/watchdog/diff-tool.ts +47 -12
- package/src/watchdog/permission-arbiter.ts +13 -15
- package/src/watchdog/register-child.ts +13 -5
- package/src/watchdog/register-main.ts +3 -3
- package/src/watchdog/review.ts +16 -16
- package/src/watchdog/runtime.ts +2 -1
- package/src/watchdog/turn-delta.ts +12 -6
- package/src/workflows/chat-progress.ts +2 -2
- package/src/workflows/scripted-workflow.ts +225 -59
- package/src/workflows/structured-workflow-scripts.ts +177 -0
- package/src/workflows/workflow-checklist.ts +6 -0
- package/src/workflows/workflow-child-summary.ts +4 -2
- package/src/workflows/workflow-receipt.ts +8 -2
- package/src/workflows/workflow-resources.ts +37 -12
- package/src/workflows/workflow-reuse.ts +120 -0
- package/src/workflows/workflow-revival.ts +123 -0
- package/src/workflows/workflow-settlement.ts +4 -1
- package/src/runs/shared/completion-evidence.ts +0 -89
- package/src/runs/shared/completion-guard.ts +0 -255
- package/src/runs/shared/llm-intent-arbiter.ts +0 -321
- package/src/runs/shared/task-intent.ts +0 -244
package/src/tui/render.ts
CHANGED
|
@@ -34,6 +34,8 @@ import { formatNestedAggregate } from "../runs/shared/nested-render.ts";
|
|
|
34
34
|
import { aggregateStepStatus, formatActivityLabel, formatAgentRunningLabel, formatParallelOutcome } from "../shared/status-format.ts";
|
|
35
35
|
import { contextModeBadge, contextModePrefix } from "../runs/shared/context-mode.ts";
|
|
36
36
|
import { shouldSuppressSingleStep, stripRepeatedAgentPrefix, withDuplicateLabelDiscriminators } from "./render-helpers.ts";
|
|
37
|
+
import { runningTone } from "./running-tone.ts";
|
|
38
|
+
import { childThinkingLevel, type ThinkingLevel } from "../shared/model-info.ts";
|
|
37
39
|
import { buildWorkflowChatProgressRows, type WorkflowChatProgressRow } from "../workflows/chat-progress.ts";
|
|
38
40
|
import { formatWorkflowPreflight, formatWorkflowPreflightPlanSummary, formatWorkflowPreflightWarningSummary, formatWorkflowPreflightWarnings } from "../workflows/workflow-preflight.ts";
|
|
39
41
|
import { encodeAsyncStatusSnapshotWidget } from "../runs/background/async-status-snapshot.ts";
|
|
@@ -83,23 +85,24 @@ function capCompactMainWindowResult(component: Component, layout: MainWindowRend
|
|
|
83
85
|
if (lines.length <= maxLines) return lines;
|
|
84
86
|
const visibleRows = maxLines === 1 ? 1 : maxLines - 1;
|
|
85
87
|
const hiddenCount = lines.length - visibleRows;
|
|
86
|
-
const hint = theme.fg("accent", `… ${hiddenCount} rows hidden · ${
|
|
88
|
+
const hint = theme.fg("accent", `… ${hiddenCount} rows hidden · ${expandKeyHint("to expand", "to view them")}`);
|
|
87
89
|
if (maxLines === 1) return [truncLine(`${lines[0] ?? ""} ${hint}`, width)];
|
|
88
90
|
return [...lines.slice(0, visibleRows), truncLine(hint, width)];
|
|
89
91
|
};
|
|
90
92
|
return capped;
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
+
function expandKeyHint(action: string, unconfiguredAction = action): string {
|
|
96
|
+
const shortcut = keyText("app.tools.expand");
|
|
97
|
+
return shortcut ? `Press ${shortcut} ${action}` : `Configure the expand key ${unconfiguredAction}`;
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
export function liveDetailHintText(): string {
|
|
98
|
-
return
|
|
101
|
+
return expandKeyHint("for live detail");
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
function workflowDetailHintText(): string {
|
|
102
|
-
return
|
|
105
|
+
return expandKeyHint("for details");
|
|
103
106
|
}
|
|
104
107
|
|
|
105
108
|
function foregroundSingleHintText(shortcut?: string): string {
|
|
@@ -880,6 +883,8 @@ type ResultPresentation = {
|
|
|
880
883
|
glyph: string;
|
|
881
884
|
label: "running" | "detached" | "stopped" | "paused" | "failed" | "partial" | "completed";
|
|
882
885
|
tone: "accent" | "warning" | "error" | "success";
|
|
886
|
+
/** Recorded thinking level of the one child a running presentation stands for. */
|
|
887
|
+
thinking?: ThinkingLevel;
|
|
883
888
|
};
|
|
884
889
|
|
|
885
890
|
function semanticResultPresentation(input: {
|
|
@@ -892,10 +897,11 @@ function semanticResultPresentation(input: {
|
|
|
892
897
|
completedWithoutOutput?: boolean;
|
|
893
898
|
seed?: number;
|
|
894
899
|
frame?: number;
|
|
900
|
+
thinking?: ThinkingLevel;
|
|
895
901
|
}): ResultPresentation {
|
|
896
902
|
if (input.running) {
|
|
897
903
|
const glyph = input.frame !== undefined ? runningGlyph((input.seed ?? 0) + input.frame) : runningGlyph(input.seed);
|
|
898
|
-
return { glyph, label: "running", tone: "accent" };
|
|
904
|
+
return { glyph, label: "running", tone: "accent", ...(input.thinking ? { thinking: input.thinking } : {}) };
|
|
899
905
|
}
|
|
900
906
|
if (input.detached) return { glyph: "■", label: "detached", tone: "warning" };
|
|
901
907
|
if (input.stopped) return { glyph: "■", label: "stopped", tone: "warning" };
|
|
@@ -940,18 +946,24 @@ function resultPresentation(result: Details["results"][number], output: string,
|
|
|
940
946
|
completedWithoutOutput: hasEmptyTextOutputWithoutOutputTarget(result.task, output),
|
|
941
947
|
seed,
|
|
942
948
|
frame,
|
|
949
|
+
thinking: childThinkingLevel(result, result.progress),
|
|
943
950
|
});
|
|
944
951
|
}
|
|
945
952
|
|
|
953
|
+
function presentationTone(presentation: ResultPresentation, theme: Theme): (text: string) => string {
|
|
954
|
+
return presentation.label === "running" ? runningTone(theme, presentation.thinking) : (text) => theme.fg(presentation.tone, text);
|
|
955
|
+
}
|
|
956
|
+
|
|
946
957
|
function resultGlyph(result: Details["results"][number], output: string, theme: Theme, running = isResultRunning(result), seed = progressRunningSeed(result.progress ?? result.progressSummary), frame?: number): string {
|
|
947
958
|
const presentation = resultPresentation(result, output, running, seed, frame);
|
|
948
|
-
return
|
|
959
|
+
return presentationTone(presentation, theme)(presentation.glyph);
|
|
949
960
|
}
|
|
950
961
|
|
|
951
962
|
function styledResultPresentation(presentation: ResultPresentation, theme: Theme): { glyph: string; label: string } {
|
|
963
|
+
const tone = presentationTone(presentation, theme);
|
|
952
964
|
return {
|
|
953
|
-
glyph:
|
|
954
|
-
label:
|
|
965
|
+
glyph: tone(presentation.glyph),
|
|
966
|
+
label: tone(presentation.label),
|
|
955
967
|
};
|
|
956
968
|
}
|
|
957
969
|
|
|
@@ -1249,8 +1261,12 @@ function widgetJobsRunningSeed(jobs: AsyncJobState[]): number | undefined {
|
|
|
1249
1261
|
return seed;
|
|
1250
1262
|
}
|
|
1251
1263
|
|
|
1264
|
+
function activeHeaderTone(theme: Theme, hasActive: boolean): (text: string) => string {
|
|
1265
|
+
return hasActive ? runningTone(theme) : (text) => theme.fg("dim", text);
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1252
1268
|
function widgetStatusGlyph(job: AsyncJobState, theme: Theme, frame?: number): string {
|
|
1253
|
-
if (job.status === "running") return theme.
|
|
1269
|
+
if (job.status === "running") return runningTone(theme, job.mode === "single" ? childThinkingLevel(job.steps?.[0]) : undefined)(runningGlyph(animatedSeed(widgetJobRunningSeed(job), frame)));
|
|
1254
1270
|
if (job.status === "queued") return theme.fg("muted", "◦");
|
|
1255
1271
|
if (job.status === "complete") return theme.fg("success", "✓");
|
|
1256
1272
|
if (job.status === "paused") return theme.fg("warning", "■");
|
|
@@ -1258,8 +1274,8 @@ function widgetStatusGlyph(job: AsyncJobState, theme: Theme, frame?: number): st
|
|
|
1258
1274
|
return theme.fg("error", "✗");
|
|
1259
1275
|
}
|
|
1260
1276
|
|
|
1261
|
-
function widgetStepGlyph(status: AsyncJobStep["status"], theme: Theme, seed?: number, frame?: number): string {
|
|
1262
|
-
if (status === "running") return theme
|
|
1277
|
+
function widgetStepGlyph(status: AsyncJobStep["status"], theme: Theme, seed?: number, frame?: number, thinking?: ThinkingLevel): string {
|
|
1278
|
+
if (status === "running") return runningTone(theme, thinking)(runningGlyph(animatedSeed(seed, frame)));
|
|
1263
1279
|
if (status === "complete" || status === "completed") return theme.fg("success", "✓");
|
|
1264
1280
|
if (status === "failed") return theme.fg("error", "✗");
|
|
1265
1281
|
if (status === "paused") return theme.fg("warning", "■");
|
|
@@ -1267,8 +1283,8 @@ function widgetStepGlyph(status: AsyncJobStep["status"], theme: Theme, seed?: nu
|
|
|
1267
1283
|
return theme.fg("muted", "◦");
|
|
1268
1284
|
}
|
|
1269
1285
|
|
|
1270
|
-
function widgetStepStatus(status: AsyncJobStep["status"], theme: Theme): string {
|
|
1271
|
-
if (status === "running") return theme
|
|
1286
|
+
function widgetStepStatus(status: AsyncJobStep["status"], theme: Theme, thinking?: ThinkingLevel): string {
|
|
1287
|
+
if (status === "running") return runningTone(theme, thinking)("running");
|
|
1272
1288
|
if (status === "complete" || status === "completed") return theme.fg("success", "complete");
|
|
1273
1289
|
if (status === "failed") return theme.fg("error", "failed");
|
|
1274
1290
|
if (status === "paused") return theme.fg("warning", "paused");
|
|
@@ -1282,8 +1298,8 @@ function workflowChecklistStateLabel(state: WorkflowChecklistState): string {
|
|
|
1282
1298
|
return state;
|
|
1283
1299
|
}
|
|
1284
1300
|
|
|
1285
|
-
function workflowChecklistGlyph(item: { state: WorkflowChecklistState; startedAt?: number; durationMs?: number; toolCount?: number; currentToolStartedAt?: number }, theme: Theme, frame?: number): string {
|
|
1286
|
-
if (item.state === "running") return theme.
|
|
1301
|
+
function workflowChecklistGlyph(item: { state: WorkflowChecklistState; startedAt?: number; durationMs?: number; toolCount?: number; currentToolStartedAt?: number; thinking?: ThinkingLevel }, theme: Theme, frame?: number): string {
|
|
1302
|
+
if (item.state === "running") return runningTone(theme, item.thinking)(runningGlyph(animatedSeed(runningSeed(item.startedAt, item.durationMs, item.toolCount, item.currentToolStartedAt), frame)));
|
|
1287
1303
|
if (item.state === "complete") return theme.fg("success", "✓");
|
|
1288
1304
|
if (item.state === "blocked") return theme.fg("error", "!");
|
|
1289
1305
|
if (item.state === "failed") return theme.fg("error", "✗");
|
|
@@ -1369,6 +1385,8 @@ function workflowChecklistWidgetLines(checklist: WorkflowChecklistProjection | u
|
|
|
1369
1385
|
interface CompactWorkflowLaneRow {
|
|
1370
1386
|
key: string;
|
|
1371
1387
|
state: WorkflowChecklistState;
|
|
1388
|
+
/** Recorded thinking level of the lane's child when the lane stands for exactly one. */
|
|
1389
|
+
thinking?: ThinkingLevel;
|
|
1372
1390
|
agent?: string;
|
|
1373
1391
|
mode?: string;
|
|
1374
1392
|
decision?: string;
|
|
@@ -1419,6 +1437,7 @@ function compactWorkflowLaneRow(key: string, items: readonly WorkflowChecklistIt
|
|
|
1419
1437
|
key: boundedLaneValue(key, 40) ?? key,
|
|
1420
1438
|
state,
|
|
1421
1439
|
agent: compactWorkflowLaneOwner(items),
|
|
1440
|
+
...(items.length === 1 && items[0]?.thinking ? { thinking: items[0].thinking } : {}),
|
|
1422
1441
|
...(lane?.mode ? { mode: lane.mode } : {}),
|
|
1423
1442
|
...(lane?.decision ? { decision: boundedLaneValue(lane.decision, 56) } : {}),
|
|
1424
1443
|
...(lane?.claims?.length ? { claims: boundedLaneValue(lane.claims.join(", "), 56) } : {}),
|
|
@@ -1492,7 +1511,7 @@ function compactWorkflowLaneLine(row: CompactWorkflowLaneRow, theme: Theme, inde
|
|
|
1492
1511
|
row.expectedOutput,
|
|
1493
1512
|
!row.mode && row.label ? row.label : undefined,
|
|
1494
1513
|
].filter((value): value is string => Boolean(value));
|
|
1495
|
-
return `${indent}${workflowChecklistGlyph({ state: row.state, durationMs: row.durationMs, toolCount: row.toolUses }, theme, frame)} ${theme.bold(row.key)}${owner ? ` ${theme.fg("dim", `· ${owner}`)}` : ""}${state ? ` ${theme.fg("dim", `· ${state}`)}` : ""}${intent.length ? ` ${theme.fg("dim", `· ${intent.join(" · ")}`)}` : ""}`;
|
|
1514
|
+
return `${indent}${workflowChecklistGlyph({ state: row.state, durationMs: row.durationMs, toolCount: row.toolUses, thinking: row.thinking }, theme, frame)} ${theme.bold(row.key)}${owner ? ` ${theme.fg("dim", `· ${owner}`)}` : ""}${state ? ` ${theme.fg("dim", `· ${state}`)}` : ""}${intent.length ? ` ${theme.fg("dim", `· ${intent.join(" · ")}`)}` : ""}`;
|
|
1496
1515
|
}
|
|
1497
1516
|
|
|
1498
1517
|
function compactWorkflowShortId(job: AsyncJobState): string {
|
|
@@ -1622,7 +1641,8 @@ function widgetParallelAgentDetails(job: AsyncJobState, theme: Theme, expanded =
|
|
|
1622
1641
|
const modelDisplay = modelThinkingBadge(theme, step.model, step.thinking);
|
|
1623
1642
|
const label = compactTaskText(step.description, step.label);
|
|
1624
1643
|
const display = step.sessionName?.trim() || (label ? `${label} (${step.agent})` : step.agent);
|
|
1625
|
-
|
|
1644
|
+
const thinking = childThinkingLevel(step);
|
|
1645
|
+
lines.push(` ${theme.fg("dim", `${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index), frame, thinking)} ${itemTitle} ${index + 1}/${total}: ${display} · ${widgetStepStatus(step.status, theme, thinking)}${modelDisplay}${activity ? ` · ${activity}` : ""}`)}`);
|
|
1626
1646
|
const lane = projectAsyncLane(job, step);
|
|
1627
1647
|
if (lane) lines.push(...formatLaneProjectionLines(lane, theme, " "));
|
|
1628
1648
|
for (const nestedLine of formatNestedWidgetLines(step.children, theme, width, expanded, job.updatedAt, expanded ? 8 : 6)) lines.push(` ${nestedLine}`);
|
|
@@ -2111,8 +2131,12 @@ function widgetStats(job: AsyncJobState, theme: Theme, projection = buildWorkflo
|
|
|
2111
2131
|
return statJoin(theme, parts);
|
|
2112
2132
|
}
|
|
2113
2133
|
|
|
2114
|
-
function widgetStepStats(theme: Theme, step: NonNullable<AsyncJobState["steps"]>[number]): string {
|
|
2134
|
+
function widgetStepStats(theme: Theme, step: NonNullable<AsyncJobState["steps"]>[number], snapshotNow = Date.now()): string {
|
|
2135
|
+
const externalElapsed = step.runner?.type === "external-cli" && step.externalProcess
|
|
2136
|
+
? step.externalProcess.durationMs ?? Math.max(0, (step.externalProcess.endedAt ?? snapshotNow) - step.externalProcess.startedAt)
|
|
2137
|
+
: undefined;
|
|
2115
2138
|
return statJoin(theme, [
|
|
2139
|
+
step.runner?.type === "external-cli" ? "external-cli" : "",
|
|
2116
2140
|
step.turnCount !== undefined ? `${step.turnCount} turns` : "",
|
|
2117
2141
|
step.toolCount !== undefined ? formatToolUseStat(step.toolCount) : "",
|
|
2118
2142
|
step.tokens
|
|
@@ -2120,7 +2144,7 @@ function widgetStepStats(theme: Theme, step: NonNullable<AsyncJobState["steps"]>
|
|
|
2120
2144
|
? formatContextUsage(step.tokens, step.contextLimit) ?? formatTokenUsage(step.tokens, "token")
|
|
2121
2145
|
: step.tokens.total ? formatTokenUsage(step.tokens, "token") : ""
|
|
2122
2146
|
: "",
|
|
2123
|
-
step.durationMs !== undefined ? formatDuration(step.durationMs) : "",
|
|
2147
|
+
externalElapsed !== undefined ? formatDuration(externalElapsed) : step.durationMs !== undefined ? formatDuration(step.durationMs) : "",
|
|
2124
2148
|
]);
|
|
2125
2149
|
}
|
|
2126
2150
|
|
|
@@ -2150,8 +2174,8 @@ function nestedRunName(run: NestedRunSummary): string {
|
|
|
2150
2174
|
return run.id;
|
|
2151
2175
|
}
|
|
2152
2176
|
|
|
2153
|
-
function nestedStatusGlyph(state: NestedRunSummary["state"] | NestedStepSummary["status"], theme: Theme, seed?: number): string {
|
|
2154
|
-
if (state === "running") return theme
|
|
2177
|
+
function nestedStatusGlyph(state: NestedRunSummary["state"] | NestedStepSummary["status"], theme: Theme, seed?: number, thinking?: ThinkingLevel): string {
|
|
2178
|
+
if (state === "running") return runningTone(theme, thinking)(runningGlyph(seed));
|
|
2155
2179
|
if (state === "complete" || state === "completed") return theme.fg("success", "✓");
|
|
2156
2180
|
if (state === "failed") return theme.fg("error", "✗");
|
|
2157
2181
|
if (state === "partial") return theme.fg("warning", "■");
|
|
@@ -2230,7 +2254,7 @@ function formatNestedWidgetLines(children: NestedRunSummary[] | undefined, theme
|
|
|
2230
2254
|
const name = "status" in step ? childDisplayName(step) : nestedRunName(step);
|
|
2231
2255
|
rows.push({
|
|
2232
2256
|
prefix,
|
|
2233
|
-
text: `${nestedTimestampPrefix(timestamp)}${nestedStatusGlyph(state, theme)} ${name} · ${state}${modelThinking ? ` · ${modelThinking}` : ""}${activity ? ` · ${activity}` : ""}${error}`,
|
|
2257
|
+
text: `${nestedTimestampPrefix(timestamp)}${nestedStatusGlyph(state, theme, undefined, childThinkingLevel(step))} ${name} · ${state}${modelThinking ? ` · ${modelThinking}` : ""}${activity ? ` · ${activity}` : ""}${error}`,
|
|
2234
2258
|
});
|
|
2235
2259
|
};
|
|
2236
2260
|
for (const child of children) {
|
|
@@ -2241,7 +2265,7 @@ function formatNestedWidgetLines(children: NestedRunSummary[] | undefined, theme
|
|
|
2241
2265
|
const ownerError = child.error ? ` · ${child.error}` : "";
|
|
2242
2266
|
rows.push({
|
|
2243
2267
|
prefix: "↳ ",
|
|
2244
|
-
text: `OWNER ${nestedStatusGlyph(child.state, theme, nestedRunSeed(child))} ${nestedRunName(child)} · ${child.state}${ownerModelThinking ? ` · ${ownerModelThinking}` : ""}${ownerActivity ? ` · ${ownerActivity}` : ""}${ownerError}`,
|
|
2268
|
+
text: `OWNER ${nestedStatusGlyph(child.state, theme, nestedRunSeed(child), childThinkingLevel(child))} ${nestedRunName(child)} · ${child.state}${ownerModelThinking ? ` · ${ownerModelThinking}` : ""}${ownerActivity ? ` · ${ownerActivity}` : ""}${ownerError}`,
|
|
2245
2269
|
});
|
|
2246
2270
|
for (const step of steps) appendLeaf(step, "↳ │ ", child.lastUpdate);
|
|
2247
2271
|
} else {
|
|
@@ -2280,7 +2304,7 @@ function formatNestedWidgetLines(children: NestedRunSummary[] | undefined, theme
|
|
|
2280
2304
|
const activity = nestedActivity(child, child.state, snapshotNow ?? child.lastUpdate);
|
|
2281
2305
|
const error = child.error ? ` · ${child.error}` : "";
|
|
2282
2306
|
const modelThinking = formatModelThinking(child.model, child.thinking);
|
|
2283
|
-
lines.push(theme.fg("dim", `${prefix}↳ ${nestedTimestampPrefix(formatClockTime(nestedRunEventTime(child)))}${nestedStatusGlyph(child.state, theme, nestedRunSeed(child))} ${nestedRunName(child)} · ${child.state}${modelThinking ? ` · ${modelThinking}` : ""} · ${activity}${error}`));
|
|
2307
|
+
lines.push(theme.fg("dim", `${prefix}↳ ${nestedTimestampPrefix(formatClockTime(nestedRunEventTime(child)))}${nestedStatusGlyph(child.state, theme, nestedRunSeed(child), childThinkingLevel(child))} ${nestedRunName(child)} · ${child.state}${modelThinking ? ` · ${modelThinking}` : ""} · ${activity}${error}`));
|
|
2284
2308
|
if (depth === maxDepth) {
|
|
2285
2309
|
const aggregate = formatNestedAggregate([...(child.steps?.flatMap((step) => step.children ?? []) ?? []), ...(child.children ?? [])]);
|
|
2286
2310
|
if (aggregate && lines.length < lineBudget) lines.push(theme.fg("dim", `${prefix} ↳ ${aggregate}`));
|
|
@@ -2289,7 +2313,7 @@ function formatNestedWidgetLines(children: NestedRunSummary[] | undefined, theme
|
|
|
2289
2313
|
for (const step of child.steps ?? []) {
|
|
2290
2314
|
if (lines.length >= lineBudget) return;
|
|
2291
2315
|
const modelThinking = formatModelThinking(step.model, step.thinking);
|
|
2292
|
-
lines.push(theme.fg("dim", `${prefix} ↳ ${nestedTimestampPrefix(nestedStepTimestamp(step, child.lastUpdate))}${nestedStatusGlyph(step.status, theme)} ${childDisplayName(step)} · ${step.status}${modelThinking ? ` · ${modelThinking}` : ""} · ${nestedActivity(step, step.status, snapshotNow ?? child.lastUpdate)}`));
|
|
2316
|
+
lines.push(theme.fg("dim", `${prefix} ↳ ${nestedTimestampPrefix(nestedStepTimestamp(step, child.lastUpdate))}${nestedStatusGlyph(step.status, theme, undefined, childThinkingLevel(step))} ${childDisplayName(step)} · ${step.status}${modelThinking ? ` · ${modelThinking}` : ""} · ${nestedActivity(step, step.status, snapshotNow ?? child.lastUpdate)}`));
|
|
2293
2317
|
append(step.children, depth + 1, `${prefix} `);
|
|
2294
2318
|
}
|
|
2295
2319
|
append(child.children, depth + 1, `${prefix} `);
|
|
@@ -2313,8 +2337,9 @@ function foregroundStyleWidgetStepLines(
|
|
|
2313
2337
|
): string[] {
|
|
2314
2338
|
const rowIndent = options?.rowIndent ?? " ";
|
|
2315
2339
|
const detailIndent = options?.detailIndent ?? " ";
|
|
2316
|
-
const
|
|
2317
|
-
const
|
|
2340
|
+
const thinking = childThinkingLevel(step);
|
|
2341
|
+
const status = widgetStepStatus(step.status, theme, thinking);
|
|
2342
|
+
const stats = widgetStepStats(theme, step, job.updatedAt);
|
|
2318
2343
|
const modelDisplay = modelThinkingBadge(theme, step.model, step.thinking);
|
|
2319
2344
|
const collapseDetails = shouldCollapseSingleChildDetails(job, step);
|
|
2320
2345
|
const displayName = collapseDetails ? singleChildAgentName(job, step) : childDisplayName(step);
|
|
@@ -2324,7 +2349,7 @@ function foregroundStyleWidgetStepLines(
|
|
|
2324
2349
|
const stageIdentity = stageName && stageName !== displayName ? `${stageName} (${displayName})` : stageName ?? displayName;
|
|
2325
2350
|
const rowLabel = collapseDetails ? displayName : (options?.rowLabel ?? `${itemTitle} ${index}/${total}: ${itemTitle === "Stage" ? stageIdentity : displayName}`);
|
|
2326
2351
|
const rowMarker = options?.rowMarker ? `${options.rowMarker} ` : "";
|
|
2327
|
-
const lines = [`${rowIndent}${rowMarker}${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index - 1), frame)} ${themeBold(theme, rowLabel)}${contextModeBadge(theme, step.context)} ${theme.fg("dim", "·")} ${status}${modelDisplay}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`];
|
|
2352
|
+
const lines = [`${rowIndent}${rowMarker}${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index - 1), frame, thinking)} ${themeBold(theme, rowLabel)}${contextModeBadge(theme, step.context)} ${theme.fg("dim", "·")} ${status}${modelDisplay}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`];
|
|
2328
2353
|
const lane = projectAsyncLane(job, step);
|
|
2329
2354
|
if (lane) lines.push(...formatLaneProjectionLines(lane, theme, detailIndent));
|
|
2330
2355
|
const task = collapseDetails ? singleChildTask(job, step) : compactTaskText(step.description, step.label);
|
|
@@ -2468,15 +2493,16 @@ function compactSingleWidgetLines(job: AsyncJobState, theme: Theme, width: numbe
|
|
|
2468
2493
|
lines.push(parallelWidgetGroupHeader(group, theme, frame));
|
|
2469
2494
|
for (const [rowIndex, row] of rows.entries()) {
|
|
2470
2495
|
const step = row.step;
|
|
2471
|
-
const
|
|
2496
|
+
const thinking = childThinkingLevel(step);
|
|
2497
|
+
const status = widgetStepStatus(step.status, theme, thinking);
|
|
2472
2498
|
const activity = widgetStepActivityLine(step, width, false, job.updatedAt);
|
|
2473
|
-
const stepStats = widgetStepStats(theme, step);
|
|
2499
|
+
const stepStats = widgetStepStats(theme, step, job.updatedAt);
|
|
2474
2500
|
const activitySuffix = activity ? ` ${theme.fg("dim", "·")} ${theme.fg("dim", activity)}` : "";
|
|
2475
2501
|
const modelDisplay = modelThinkingBadge(theme, step.model, step.thinking);
|
|
2476
2502
|
const task = compactTaskText(step.description, step.label);
|
|
2477
2503
|
const taskSuffix = task ? ` ${theme.fg("dim", "·")} ${theme.fg("dim", `task: ${task}`)}` : "";
|
|
2478
2504
|
const marker = rowIndex === rows.length - 1 && rowIndex >= group.total - 1 ? "└─" : "├─";
|
|
2479
|
-
lines.push(` ${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, row.index), frame)} ${themeBold(theme, row.rowLabel)}${contextModeBadge(theme, step.context)} ${theme.fg("dim", "·")} ${status}${modelDisplay}${taskSuffix}${activitySuffix}${stepStats ? ` ${theme.fg("dim", "·")} ${stepStats}` : ""}`);
|
|
2505
|
+
lines.push(` ${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, row.index), frame, thinking)} ${themeBold(theme, row.rowLabel)}${contextModeBadge(theme, step.context)} ${theme.fg("dim", "·")} ${status}${modelDisplay}${taskSuffix}${activitySuffix}${stepStats ? ` ${theme.fg("dim", "·")} ${stepStats}` : ""}`);
|
|
2480
2506
|
const lane = projectAsyncLane(job, step);
|
|
2481
2507
|
if (lane) lines.push(...formatLaneProjectionLines(lane, theme, " "));
|
|
2482
2508
|
for (const nestedLine of formatNestedWidgetLines(step.children, theme, width, false, job.updatedAt, 6)) lines.push(` ${nestedLine}`);
|
|
@@ -2550,7 +2576,8 @@ function buildSingleLineWidgetLines(jobs: AsyncJobState[], theme: Theme, width:
|
|
|
2550
2576
|
if (count > 0) parts.push(`${count} ${status}`);
|
|
2551
2577
|
}
|
|
2552
2578
|
if (!hasActive && counts.complete.length > 0) parts.push(`${counts.complete.length}/${jobs.length} done`);
|
|
2553
|
-
|
|
2579
|
+
const tone = activeHeaderTone(theme, hasActive);
|
|
2580
|
+
return [truncLine(`${tone(glyph)} ${tone("subagents")} (${parts.join(", ") || `${jobs.length} total`})`, width)];
|
|
2554
2581
|
}
|
|
2555
2582
|
|
|
2556
2583
|
function orderedWidgetJobs(jobs: AsyncJobState[]): AsyncJobState[] {
|
|
@@ -2602,12 +2629,29 @@ function selectProgressiveJobKeys(jobs: AsyncJobState[], previousKeys: string[],
|
|
|
2602
2629
|
return selected;
|
|
2603
2630
|
}
|
|
2604
2631
|
|
|
2605
|
-
|
|
2632
|
+
// Counts the leaf entries collectFleetStatusEntries (fleet-status.ts) makes for a running async job,
|
|
2633
|
+
// so this matches FleetView's "N active agents": a workflow counts only its loaded child runs;
|
|
2634
|
+
// another job counts its active steps, synthesized from `agents` when it has no steps.
|
|
2635
|
+
function runningLeafAgentCount(job: AsyncJobState, projectionFor: WorkflowWidgetProjectionLookup): number {
|
|
2636
|
+
if (job.mode === "workflow") return (projectionFor(job).children ?? []).reduce((total, child) => total + runningLeafAgentCount(child, projectionFor), 0);
|
|
2637
|
+
if (job.status !== "running") return 0;
|
|
2638
|
+
const sequential = job.mode === "chain" && !job.activeParallelGroup;
|
|
2639
|
+
const current = job.currentStep ?? 0;
|
|
2640
|
+
const steps = job.steps?.length
|
|
2641
|
+
? job.steps
|
|
2642
|
+
: job.agents?.map((_, index) => ({ index, status: sequential && index !== current ? "pending" : "running" }));
|
|
2643
|
+
if (!steps?.length) return 1;
|
|
2644
|
+
return steps.filter((step, offset) => ["running", "queued", "pending"].includes(step.status)
|
|
2645
|
+
&& !(step.status === "pending" && sequential && (step.index ?? offset) !== current)).length;
|
|
2646
|
+
}
|
|
2647
|
+
|
|
2648
|
+
function progressiveHeaderLine(jobs: AsyncJobState[], theme: Theme, width: number, frame: number | undefined, projectionFor: WorkflowWidgetProjectionLookup): string {
|
|
2606
2649
|
const counts = widgetHeaderCounts(jobs);
|
|
2607
2650
|
const hasActive = counts.running.length > 0 || counts.queued.length > 0;
|
|
2608
2651
|
const glyph = counts.running.length > 0 ? runningGlyph(animatedSeed(widgetJobsRunningSeed(counts.running), frame)) : hasActive ? "●" : "○";
|
|
2609
2652
|
const parts: string[] = [];
|
|
2610
|
-
|
|
2653
|
+
const runningAgents = jobs.reduce((total, job) => total + runningLeafAgentCount(job, projectionFor), 0);
|
|
2654
|
+
if (runningAgents > 0) parts.push(formatAgentRunningLabel(runningAgents));
|
|
2611
2655
|
if (counts.queued.length > 0) parts.push(`${counts.queued.length} queued`);
|
|
2612
2656
|
if (!hasActive) {
|
|
2613
2657
|
if (counts.failed.length > 0) parts.push(`${counts.failed.length} failed`);
|
|
@@ -2615,12 +2659,12 @@ function progressiveHeaderLine(jobs: AsyncJobState[], theme: Theme, width: numbe
|
|
|
2615
2659
|
if (counts.paused.length > 0) parts.push(`${counts.paused.length} paused`);
|
|
2616
2660
|
if (counts.complete.length > 0) parts.push(`${counts.complete.length}/${jobs.length} done`);
|
|
2617
2661
|
}
|
|
2618
|
-
|
|
2662
|
+
const tone = activeHeaderTone(theme, hasActive);
|
|
2663
|
+
return truncLine(`${tone(glyph)} ${tone("Async agents")} ${theme.fg("dim", "·")} ${theme.fg("dim", parts.join(", ") || `${jobs.length} total`)}`, width);
|
|
2619
2664
|
}
|
|
2620
2665
|
|
|
2621
|
-
function progressiveJobLine(job: AsyncJobState, theme: Theme, width: number, frame?: number, projection = buildWorkflowWidgetProjection(job)): string {
|
|
2666
|
+
function progressiveJobLine(job: AsyncJobState, theme: Theme, width: number, frame?: number, projection = buildWorkflowWidgetProjection(job), compactRows = job.mode === "workflow" ? compactWorkflowLaneRows(job, projection.checklist) : undefined): string {
|
|
2622
2667
|
const compactWorkflow = job.mode === "workflow";
|
|
2623
|
-
const compactRows = compactWorkflow ? compactWorkflowLaneRows(job, projection.checklist) : undefined;
|
|
2624
2668
|
const stats = compactWorkflow ? compactWorkflowStats(job, compactRows ?? [], theme, projection) : widgetStats(job, theme, projection, true);
|
|
2625
2669
|
if (compactWorkflow) {
|
|
2626
2670
|
const bottleneck = compactWorkflowBottleneck(compactRows ?? [], job);
|
|
@@ -2657,9 +2701,9 @@ function progressiveHiddenLine(hiddenJobs: AsyncJobState[], theme: Theme, width:
|
|
|
2657
2701
|
return truncLine(theme.fg("dim", ` +${hiddenJobs.length} more${parts.length ? ` (${parts.join(", ")})` : ""}`), width);
|
|
2658
2702
|
}
|
|
2659
2703
|
|
|
2660
|
-
function buildProgressiveWidgetLines(jobs: AsyncJobState[], theme: Theme, width: number, lockedRows: number, previousKeys: string[], frame?: number, projectionFor: WorkflowWidgetProjectionLookup = workflowWidgetProjectionLookup()): { lines: string[]; visibleJobKeys: string[] } {
|
|
2704
|
+
function buildProgressiveWidgetLines(jobs: AsyncJobState[], theme: Theme, width: number, lockedRows: number, previousKeys: string[], frame?: number, projectionFor: WorkflowWidgetProjectionLookup = workflowWidgetProjectionLookup()): { lines: string[]; visibleJobKeys: string[]; contentRows: number } {
|
|
2661
2705
|
const rowCount = Math.max(1, lockedRows);
|
|
2662
|
-
if (rowCount === 1) return { lines: buildSingleLineWidgetLines(jobs, theme, width, frame), visibleJobKeys: [] };
|
|
2706
|
+
if (rowCount === 1) return { lines: buildSingleLineWidgetLines(jobs, theme, width, frame), visibleJobKeys: [], contentRows: 1 };
|
|
2663
2707
|
|
|
2664
2708
|
const bodyRows = rowCount - 1;
|
|
2665
2709
|
let visibleJobKeys = selectProgressiveJobKeys(jobs, previousKeys, bodyRows);
|
|
@@ -2674,13 +2718,22 @@ function buildProgressiveWidgetLines(jobs: AsyncJobState[], theme: Theme, width:
|
|
|
2674
2718
|
hiddenJobs = jobs.filter((job) => !visibleJobKeys.includes(progressiveJobKey(job)));
|
|
2675
2719
|
}
|
|
2676
2720
|
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2721
|
+
// Rows left after every visible job line show the visible workflows' lanes.
|
|
2722
|
+
let spareRows = rowCount - 1 - visibleJobs.length - (hiddenJobs.length > 0 ? 1 : 0);
|
|
2723
|
+
const lines = [progressiveHeaderLine(jobs, theme, width, frame, projectionFor)];
|
|
2724
|
+
for (const job of visibleJobs) {
|
|
2725
|
+
const projection = projectionFor(job);
|
|
2726
|
+
const laneRows = job.mode === "workflow" ? compactWorkflowLaneRows(job, projection.checklist) : undefined;
|
|
2727
|
+
lines.push(progressiveJobLine(job, theme, width, frame, projection, laneRows));
|
|
2728
|
+
if (!laneRows || projection.inlineFleetCovered) continue;
|
|
2729
|
+
const shownLanes = laneRows.slice(0, Math.max(0, spareRows));
|
|
2730
|
+
for (const row of shownLanes) lines.push(truncLine(compactWorkflowLaneLine(row, theme, " ", frame), width));
|
|
2731
|
+
spareRows -= shownLanes.length;
|
|
2732
|
+
}
|
|
2681
2733
|
if (hiddenJobs.length > 0 && lines.length < rowCount) lines.push(progressiveHiddenLine(hiddenJobs, theme, width));
|
|
2734
|
+
const contentRows = Math.min(lines.length, rowCount);
|
|
2682
2735
|
while (lines.length < rowCount) lines.push(" ");
|
|
2683
|
-
return { lines: lines.slice(0, rowCount), visibleJobKeys };
|
|
2736
|
+
return { lines: lines.slice(0, rowCount), visibleJobKeys, contentRows };
|
|
2684
2737
|
}
|
|
2685
2738
|
|
|
2686
2739
|
function collapsedWidgetLineBudget(rows: number): number {
|
|
@@ -2703,7 +2756,7 @@ function fitWidgetLineBudget(lines: string[], theme: Theme, width: number, expan
|
|
|
2703
2756
|
const hiddenCount = lines.length - visibleLines;
|
|
2704
2757
|
const hint = expanded
|
|
2705
2758
|
? `… ${hiddenCount} live-detail lines hidden`
|
|
2706
|
-
: `… ${hiddenCount} lines hidden · ${
|
|
2759
|
+
: `… ${hiddenCount} lines hidden · ${expandKeyHint("to expand", "to view them")}`;
|
|
2707
2760
|
return [...lines.slice(0, visibleLines), truncLine(theme.fg("dim", hint), width)];
|
|
2708
2761
|
}
|
|
2709
2762
|
|
|
@@ -2723,9 +2776,17 @@ function fitAdaptiveWidgetLines(jobs: AsyncJobState[], buildLines: () => string[
|
|
|
2723
2776
|
}
|
|
2724
2777
|
|
|
2725
2778
|
if (hasMatchingSession && widgetLayoutSession?.tier === "progressive" && widgetLayoutSession.lockedRows !== undefined) {
|
|
2726
|
-
const
|
|
2727
|
-
|
|
2728
|
-
|
|
2779
|
+
const session = widgetLayoutSession;
|
|
2780
|
+
const lockedRows = widgetLayoutSession.lockedRows;
|
|
2781
|
+
let rendered = buildProgressiveWidgetLines(jobs, theme, width, lockedRows, session.visibleJobKeys, frame, projectionFor);
|
|
2782
|
+
// A job that starts after a content-sized lock can be hidden while the cap has room: grow the lock, never shrink it.
|
|
2783
|
+
const capRows = Math.min(availableRows, collapsedWidgetLineBudget(rows));
|
|
2784
|
+
if (rendered.visibleJobKeys.length < jobs.length && lockedRows < capRows) {
|
|
2785
|
+
rendered = buildProgressiveWidgetLines(jobs, theme, width, capRows, session.visibleJobKeys, frame, projectionFor);
|
|
2786
|
+
session.lockedRows = Math.max(lockedRows, rendered.contentRows);
|
|
2787
|
+
}
|
|
2788
|
+
session.visibleJobKeys = rendered.visibleJobKeys;
|
|
2789
|
+
return rendered.lines.slice(0, session.lockedRows);
|
|
2729
2790
|
}
|
|
2730
2791
|
|
|
2731
2792
|
const lines = buildLines();
|
|
@@ -2743,23 +2804,49 @@ function fitAdaptiveWidgetLines(jobs: AsyncJobState[], buildLines: () => string[
|
|
|
2743
2804
|
return buildSingleLineWidgetLines(jobs, theme, width, frame);
|
|
2744
2805
|
}
|
|
2745
2806
|
|
|
2746
|
-
|
|
2747
|
-
const rendered = buildProgressiveWidgetLines(jobs, theme, width,
|
|
2807
|
+
// Lock to the rows the content fills so the fixed-height card has no blank padding.
|
|
2808
|
+
const rendered = buildProgressiveWidgetLines(jobs, theme, width, Math.min(availableRows, collapsedWidgetLineBudget(rows)), [], frame, projectionFor);
|
|
2809
|
+
const lockedRows = rendered.contentRows;
|
|
2748
2810
|
widgetLayoutSession = { expanded, rows, columns, tier: "progressive", lockedRows, visibleJobKeys: rendered.visibleJobKeys };
|
|
2749
|
-
return rendered.lines;
|
|
2811
|
+
return rendered.lines.slice(0, lockedRows);
|
|
2750
2812
|
}
|
|
2751
2813
|
|
|
2752
2814
|
const asyncWidgetUpdates = new WeakMap<ExtensionContext["ui"], (jobs: AsyncJobState[]) => void>();
|
|
2753
2815
|
const inlineWorkflowCoverage = new WeakMap<ExtensionContext["ui"], ReadonlyMap<string, string>>();
|
|
2754
2816
|
const asyncWidgetInvalidations = new WeakMap<ExtensionContext["ui"], () => void>();
|
|
2755
2817
|
|
|
2756
|
-
|
|
2818
|
+
function inlineWorkflowDescendantShape(children: AsyncJobState["nestedChildren"]): unknown {
|
|
2819
|
+
return children?.map((child) => [child.id, child.agent, inlineWorkflowDescendantShape(child.children)]);
|
|
2820
|
+
}
|
|
2821
|
+
|
|
2822
|
+
function inlineWorkflowRowShape(job: AsyncJobState): unknown[] {
|
|
2823
|
+
return [
|
|
2824
|
+
job.asyncId,
|
|
2825
|
+
job.parentWorkflowRunId,
|
|
2826
|
+
job.workflowKey,
|
|
2827
|
+
job.mode,
|
|
2828
|
+
job.currentStep,
|
|
2829
|
+
job.activeParallelGroup,
|
|
2830
|
+
job.status,
|
|
2831
|
+
job.context,
|
|
2832
|
+
job.agents,
|
|
2833
|
+
job.steps?.map((step, index) => [
|
|
2834
|
+
step.index ?? index,
|
|
2835
|
+
step.workflowKey,
|
|
2836
|
+
step.agent,
|
|
2837
|
+
step.status,
|
|
2838
|
+
Boolean(step.runner),
|
|
2839
|
+
inlineWorkflowDescendantShape(step.children),
|
|
2840
|
+
]),
|
|
2841
|
+
inlineWorkflowDescendantShape(job.nestedChildren),
|
|
2842
|
+
job.hostSteps?.map((row) => [row.id, row.monitorKind, row.label]),
|
|
2843
|
+
Boolean(job.workflowGraph),
|
|
2844
|
+
];
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
/** Structural identity of the workflow rows that Fleet can cover. */
|
|
2757
2848
|
export function inlineWorkflowRenderKey(job: AsyncJobState, children: AsyncJobState[]): string {
|
|
2758
|
-
|
|
2759
|
-
return JSON.stringify([widgetRenderKey(job), children.map((child) => [
|
|
2760
|
-
child.asyncId, widgetRenderKey(child, true), child.context,
|
|
2761
|
-
child.steps?.map((step) => [Boolean(step.runner), step.tokens?.window]), Boolean(child.workflowGraph),
|
|
2762
|
-
])]);
|
|
2849
|
+
return JSON.stringify([inlineWorkflowRowShape(job), children.map(inlineWorkflowRowShape)]);
|
|
2763
2850
|
}
|
|
2764
2851
|
|
|
2765
2852
|
/** Presentation-only coverage from the mounted inline Fleet roster, never configuration. */
|
|
@@ -2827,7 +2914,11 @@ function buildWidgetComponent(jobs: AsyncJobState[], ui: ExtensionContext["ui"])
|
|
|
2827
2914
|
resetWidgetLayoutSession();
|
|
2828
2915
|
tui.requestRender();
|
|
2829
2916
|
};
|
|
2830
|
-
|
|
2917
|
+
const invalidateCoverage = (): void => {
|
|
2918
|
+
cachedLines = undefined;
|
|
2919
|
+
tui.requestRender();
|
|
2920
|
+
};
|
|
2921
|
+
asyncWidgetInvalidations.set(ui, invalidateCoverage);
|
|
2831
2922
|
const update = (nextJobs: AsyncJobState[]): void => {
|
|
2832
2923
|
jobs = nextJobs;
|
|
2833
2924
|
cachedLines = undefined;
|
|
@@ -2845,7 +2936,7 @@ function buildWidgetComponent(jobs: AsyncJobState[], ui: ExtensionContext["ui"])
|
|
|
2845
2936
|
},
|
|
2846
2937
|
dispose(): void {
|
|
2847
2938
|
if (asyncWidgetUpdates.get(ui) === update) asyncWidgetUpdates.delete(ui);
|
|
2848
|
-
if (asyncWidgetInvalidations.get(ui) ===
|
|
2939
|
+
if (asyncWidgetInvalidations.get(ui) === invalidateCoverage) asyncWidgetInvalidations.delete(ui);
|
|
2849
2940
|
},
|
|
2850
2941
|
});
|
|
2851
2942
|
container.render = (renderWidth: number): string[] => {
|
|
@@ -2908,7 +2999,8 @@ function buildWidgetLinesWithProjection(jobs: AsyncJobState[], theme: Theme, wid
|
|
|
2908
2999
|
const lines: string[] = [];
|
|
2909
3000
|
const hasActive = running.length > 0 || queued.length > 0;
|
|
2910
3001
|
const headerGlyph = running.length > 0 ? runningGlyph(animatedSeed(widgetJobsRunningSeed(running), frame)) : hasActive ? "●" : "○";
|
|
2911
|
-
|
|
3002
|
+
const tone = activeHeaderTone(theme, hasActive);
|
|
3003
|
+
lines.push(truncLine(`${tone(headerGlyph)} ${tone("Async agents")} ${theme.fg("dim", "· background")}`, width));
|
|
2912
3004
|
|
|
2913
3005
|
const items: string[][] = [];
|
|
2914
3006
|
let hiddenRunning = 0;
|
|
@@ -3060,18 +3152,18 @@ function renderSingleCompact(
|
|
|
3060
3152
|
return c;
|
|
3061
3153
|
}
|
|
3062
3154
|
|
|
3063
|
-
function workflowRowGlyph(row: WorkflowChatProgressRow, theme: Theme, frame?: number): string {
|
|
3155
|
+
function workflowRowGlyph(row: WorkflowChatProgressRow, theme: Theme, frame?: number, thinking?: ThinkingLevel): string {
|
|
3064
3156
|
if (row.state === "planned") return theme.fg("muted", "◦");
|
|
3065
|
-
if (row.state === "running") return theme
|
|
3157
|
+
if (row.state === "running") return runningTone(theme, thinking)(runningGlyph(frame));
|
|
3066
3158
|
if (row.state === "complete") return theme.fg("success", "✓");
|
|
3067
3159
|
if (row.state === "detached" || row.state === "stopped") return theme.fg("warning", "■");
|
|
3068
3160
|
return theme.fg("error", "✗");
|
|
3069
3161
|
}
|
|
3070
3162
|
|
|
3071
|
-
function workflowRowStateLabel(row: WorkflowChatProgressRow, theme: Theme): string {
|
|
3163
|
+
function workflowRowStateLabel(row: WorkflowChatProgressRow, theme: Theme, thinking?: ThinkingLevel): string {
|
|
3072
3164
|
const label = (row.state === "complete" ? "complete" : row.state).padEnd(8);
|
|
3073
3165
|
if (row.state === "planned") return theme.fg("dim", label);
|
|
3074
|
-
if (row.state === "running") return theme
|
|
3166
|
+
if (row.state === "running") return runningTone(theme, thinking)(label);
|
|
3075
3167
|
if (row.state === "complete") return theme.fg("success", label);
|
|
3076
3168
|
if (row.state === "detached" || row.state === "stopped") return theme.fg("warning", label);
|
|
3077
3169
|
return theme.fg("error", label);
|
|
@@ -3110,6 +3202,7 @@ function foregroundWorkflowChecklist(details: Details): WorkflowChecklistProject
|
|
|
3110
3202
|
label: node?.label ?? workflowLabelForResult(details, resultIndex) ?? result.task ?? result.agent,
|
|
3111
3203
|
phase: node?.phase,
|
|
3112
3204
|
agent: result.agent,
|
|
3205
|
+
thinking: result.thinking ?? progress?.thinking,
|
|
3113
3206
|
status,
|
|
3114
3207
|
context: result.context,
|
|
3115
3208
|
activityState: progress?.activityState,
|
|
@@ -3145,7 +3238,7 @@ function renderWorkflowChatProgress(d: Details, result: AgentToolResult<Details>
|
|
|
3145
3238
|
const workflow = d.workflow;
|
|
3146
3239
|
const rows = workflow ? buildWorkflowChatProgressRows(workflow.trace, d.preflight) : d.preflight ? buildWorkflowChatProgressRows([], d.preflight) : [];
|
|
3147
3240
|
const state = workflowOverallState(rows, workflow?.value !== undefined, result.isError);
|
|
3148
|
-
const glyph = state === "running" ? theme
|
|
3241
|
+
const glyph = state === "running" ? runningTone(theme)(runningGlyph(frame)) : state === "complete" ? theme.fg("success", "✓") : state === "paused" ? theme.fg("warning", "■") : theme.fg("error", "✗");
|
|
3149
3242
|
const width = getTermWidth() - 4;
|
|
3150
3243
|
const runId = d.runId ? d.runId.slice(0, 12) : "workflow";
|
|
3151
3244
|
const repoLabel = d.chatProgress?.repoLabel ?? (d.chatProgress?.repoRelation === "same" ? "same repo" : "other repo");
|
|
@@ -3166,8 +3259,10 @@ function renderWorkflowChatProgress(d: Details, result: AgentToolResult<Details>
|
|
|
3166
3259
|
}
|
|
3167
3260
|
const visible = visibleWorkflowRows(rows);
|
|
3168
3261
|
if (visible.hiddenRows > 0) c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}… ${visible.hiddenRows} older workflow rows hidden`), width), 0, 0));
|
|
3262
|
+
const childLevels = new Map((d.workflowChildren?.children ?? []).map((child) => [child.childId, childThinkingLevel(child)]));
|
|
3169
3263
|
for (const row of visible.rows) {
|
|
3170
|
-
const
|
|
3264
|
+
const thinking = childLevels.get(row.key);
|
|
3265
|
+
const status = workflowRowStateLabel(row, theme, thinking);
|
|
3171
3266
|
const label = row.label && row.label !== row.key ? ` ${oneLine(row.label)}` : "";
|
|
3172
3267
|
const duration = row.durationMs !== undefined ? ` ${theme.fg("dim", `· ${formatDuration(row.durationMs)}`)}` : "";
|
|
3173
3268
|
const run = row.runId ? ` ${theme.fg("dim", `[${row.runId.slice(0, 8)}]`)}` : "";
|
|
@@ -3179,7 +3274,7 @@ function renderWorkflowChatProgress(d: Details, result: AgentToolResult<Details>
|
|
|
3179
3274
|
row.preflight.expectedOutput ? `expected:${row.preflight.expectedOutput}` : undefined,
|
|
3180
3275
|
row.preflight.independence ? `independence:${row.preflight.independence}` : undefined,
|
|
3181
3276
|
].filter((value): value is string => Boolean(value)).join(" · ") : "";
|
|
3182
|
-
c.addChild(new Text(truncLine(`${rowIndent}${workflowRowGlyph(row, theme, frame)} ${status} ${theme.bold(row.key)}${label}${run}${duration}${error}${hints ? ` ${theme.fg("dim", `· ${hints}`)}` : ""}`, width), 0, 0));
|
|
3277
|
+
c.addChild(new Text(truncLine(`${rowIndent}${workflowRowGlyph(row, theme, frame, thinking)} ${status} ${theme.bold(row.key)}${label}${run}${duration}${error}${hints ? ` ${theme.fg("dim", `· ${hints}`)}` : ""}`, width), 0, 0));
|
|
3183
3278
|
}
|
|
3184
3279
|
if (workflow?.preflightWarnings?.length) {
|
|
3185
3280
|
const warningLines = expanded
|
|
@@ -3231,7 +3326,7 @@ function renderMultiCompact(d: Details, theme: Theme, layout: MainWindowRenderLa
|
|
|
3231
3326
|
seed: runningSeed(progressRunningSeed(totalSummary), d.currentStepIndex),
|
|
3232
3327
|
frame,
|
|
3233
3328
|
});
|
|
3234
|
-
const glyph =
|
|
3329
|
+
const glyph = presentationTone(aggregatePresentation, theme)(aggregatePresentation.glyph);
|
|
3235
3330
|
const contextBadge = contextModeBadge(theme, d.context);
|
|
3236
3331
|
const c = new Container();
|
|
3237
3332
|
const width = getTermWidth() - 4;
|
|
@@ -3339,7 +3434,7 @@ export function renderSubagentSummary(
|
|
|
3339
3434
|
const partial = Boolean(details && workflowGraphHasStatus(details, ["partial"]));
|
|
3340
3435
|
const state = running ? "running" : failed ? "failed" : stopped ? "stopped" : paused ? "paused" : partial ? "partial" : "completed";
|
|
3341
3436
|
const glyph = state === "running"
|
|
3342
|
-
? theme.
|
|
3437
|
+
? runningTone(theme, details?.mode === "single" && results.length === 1 ? childThinkingLevel(results[0], results[0]?.progress) : undefined)(STATIC_RUNNING_GLYPH)
|
|
3343
3438
|
: state === "completed"
|
|
3344
3439
|
? theme.fg("success", "✓")
|
|
3345
3440
|
: state === "failed"
|
|
@@ -3387,7 +3482,7 @@ export function renderSubagentResult(
|
|
|
3387
3482
|
const c = new Container();
|
|
3388
3483
|
const detailIndent = mainWindowIndent(layout, 1);
|
|
3389
3484
|
c.addChild(new Text(truncLine(`${contextPrefix}${compactLine} · ${lines.length} lines`, width), 0, 0));
|
|
3390
|
-
c.addChild(new Text(truncLine(theme.fg("accent", `${detailIndent}
|
|
3485
|
+
c.addChild(new Text(truncLine(theme.fg("accent", `${detailIndent}${expandKeyHint("for full output")}`), width), 0, 0));
|
|
3391
3486
|
return compact(c);
|
|
3392
3487
|
}
|
|
3393
3488
|
const c = new Container();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { ThinkingLevel } from "../shared/model-info.ts";
|
|
3
|
+
import { isStaleExtensionContextError, isUnboundExtensionRuntimeError } from "../shared/extension-context.ts";
|
|
4
|
+
|
|
5
|
+
type Theme = Pick<ExtensionContext["ui"]["theme"], "fg" | "getThinkingBorderColor">;
|
|
6
|
+
|
|
7
|
+
let mainThinkingLevelSource: () => ThinkingLevel | undefined = () => undefined;
|
|
8
|
+
|
|
9
|
+
/** Registers where the main session's current thinking level is read; glyphs that stand for several children take its color. */
|
|
10
|
+
export function setMainThinkingLevelSource(source: () => ThinkingLevel | undefined): void {
|
|
11
|
+
mainThinkingLevelSource = source;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Reads the main session's level through `read`; a stale or not-yet-bound Pi runtime has no level to show. */
|
|
15
|
+
export function readMainThinkingLevel(read: () => ThinkingLevel): ThinkingLevel | undefined {
|
|
16
|
+
try {
|
|
17
|
+
return read();
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (isStaleExtensionContextError(error) || isUnboundExtensionRuntimeError(error)) return undefined;
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The running tone of a glyph: Pi's prompt-box color for the recorded level of the one child it stands for, else for the main session's current level, else accent. */
|
|
25
|
+
export function runningTone(theme: Theme, childLevel?: ThinkingLevel): (text: string) => string {
|
|
26
|
+
const level = childLevel ?? mainThinkingLevelSource();
|
|
27
|
+
return level ? theme.getThinkingBorderColor(level) : (text) => theme.fg("accent", text);
|
|
28
|
+
}
|