@xzzpig/pi-subagents 0.24.2 → 0.25.1
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 +37 -0
- package/bundle/agent-management.js +4 -4
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/chunk-34TUUBRN.js +1107 -0
- package/bundle/{chunk-SW2VMNIU.js → chunk-5OD3OWTE.js} +2 -2
- package/bundle/{chunk-EUPJB4S7.js → chunk-5Z7JAORM.js} +196 -1219
- package/bundle/{chunk-LCDJWBVM.js → chunk-66JNFRFS.js} +1 -1
- package/bundle/{chunk-ED55MIC2.js → chunk-CGFF4WA3.js} +42 -19
- package/bundle/{chunk-TMHVDPYW.js → chunk-DLVPMML3.js} +263 -154
- package/bundle/{chunk-RU522D5W.js → chunk-FQPV4O6C.js} +183 -28
- package/bundle/chunk-HXRB42AF.js +108 -0
- package/bundle/{chunk-355ECEP2.js → chunk-IH7LQVEE.js} +29 -14
- package/bundle/{chunk-Z6TFJ6BR.js → chunk-INWSUNI6.js} +1 -1
- package/bundle/{chunk-CYY5UMJU.js → chunk-IXCEOEJT.js} +411 -249
- package/bundle/{chunk-WW76JRIX.js → chunk-JAXVBXGF.js} +1 -1
- package/bundle/{chunk-ICNYIALB.js → chunk-JH5H4CYJ.js} +784 -474
- package/bundle/{chunk-224WMDIV.js → chunk-JUYNN63E.js} +350 -123
- package/bundle/{chunk-35GII5EF.js → chunk-JWFLPSTP.js} +41 -117
- package/bundle/{chunk-XWWUDWUW.js → chunk-KRNBJPZ2.js} +670 -400
- package/bundle/{chunk-RB4GELQA.js → chunk-LPJEKHOY.js} +1 -1
- package/bundle/chunk-LYKG4FKH.js +523 -0
- package/bundle/{chunk-X6LOM3Z4.js → chunk-LZ3HBDTR.js} +161 -78
- package/bundle/{chunk-JEA2ZKUA.js → chunk-MMJQMPOK.js} +37 -165
- package/bundle/{chunk-FG6SQJAR.js → chunk-OGPOCGWX.js} +24 -6
- package/bundle/{chunk-FJWI64H7.js → chunk-RMSABUN3.js} +27 -13
- package/bundle/{chunk-H36HBZB2.js → chunk-SJPABBZG.js} +2 -2
- package/bundle/{chunk-4UH4WS4G.js → chunk-SNDCIJMK.js} +23 -12
- package/bundle/{chunk-O4D5PBVI.js → chunk-TM2K53NX.js} +3 -2
- package/bundle/{chunk-3U633XDZ.js → chunk-U3ZDUUTM.js} +11 -3
- package/bundle/{chunk-LVWU2HOO.js → chunk-ULGMXABL.js} +16 -7
- package/bundle/{chunk-WPW4V6HM.js → chunk-W7ZA6TYD.js} +2 -2
- package/bundle/{chunk-BQ2OAB4Q.js → chunk-WWDUNXSE.js} +67 -30
- package/bundle/{chunk-V2KFIGFH.js → chunk-XAC2XNAP.js} +503 -304
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +12 -10
- package/bundle/project-panes.js +3 -3
- package/bundle/workflow-resources.js +1 -1
- package/docs/agents.md +27 -6
- package/docs/configuration.md +20 -8
- package/docs/extension-api.md +18 -1
- package/docs/models.md +6 -2
- package/docs/observability.md +2 -0
- package/docs/tool-reference.md +7 -1
- package/docs/workflows.md +30 -2
- package/package.json +2 -2
- package/skills/pi-subagents/SKILL.md +15 -6
- package/skills/pi-subagents/references/prompting-and-roles.md +1 -0
- package/src/agents/agent-management.d.ts +1 -0
- package/src/agents/agent-management.js +46 -18
- package/src/agents/agent-memory.d.ts +1 -4
- package/src/agents/agent-memory.js +1 -4
- package/src/agents/agent-serializer.d.ts +2 -0
- package/src/agents/agent-serializer.js +1 -1
- package/src/agents/agents.d.ts +2 -3
- package/src/agents/agents.js +46 -20
- package/src/agents/frontmatter.js +1 -8
- package/src/agents/global-npm-root.d.ts +1 -0
- package/src/agents/global-npm-root.js +11 -3
- package/src/agents/skills.d.ts +0 -3
- package/src/agents/skills.js +0 -3
- package/src/api/preflight.d.ts +3 -1
- package/src/api/preflight.js +2 -0
- package/src/extension/config.d.ts +1 -0
- package/src/extension/config.js +13 -1
- package/src/extension/herdr-pi-bridge.js +10 -2
- package/src/extension/index.d.ts +0 -13
- package/src/extension/index.js +51 -37
- package/src/extension/public-execution.d.ts +1 -0
- package/src/extension/public-execution.js +4 -0
- package/src/extension/reply-workflow-script.js +24 -4
- package/src/extension/schemas.d.ts +12 -3
- package/src/extension/schemas.js +7 -3
- package/src/extension/session-switch.d.ts +25 -0
- package/src/extension/session-switch.js +138 -0
- package/src/extension/subagent-guide.d.ts +1 -1
- package/src/extension/subagent-guide.js +1 -1
- package/src/extension/subagent-launch-tool.d.ts +25 -0
- package/src/extension/subagent-launch-tool.js +48 -0
- package/src/extension/tool-activation.js +55 -15
- package/src/extension/tool-description.d.ts +1 -1
- package/src/extension/tool-description.js +14 -8
- package/src/inspectors/herdr/actions.d.ts +0 -1
- package/src/inspectors/herdr/actions.js +0 -1
- package/src/inspectors/session-roots-codec.d.ts +0 -1
- package/src/inspectors/session-roots-codec.js +0 -1
- package/src/inspectors/tmux/actions.d.ts +0 -1
- package/src/inspectors/tmux/actions.js +0 -1
- package/src/integrations/herdr-status.js +3 -8
- package/src/intercom/native-supervisor-channel.js +65 -9
- package/src/runs/background/async-execution.d.ts +7 -10
- package/src/runs/background/async-execution.js +66 -29
- package/src/runs/background/async-job-tracker.js +12 -0
- package/src/runs/background/async-resume.d.ts +2 -1
- package/src/runs/background/async-resume.js +114 -40
- package/src/runs/background/async-retention.d.ts +0 -2
- package/src/runs/background/async-retention.js +17 -6
- package/src/runs/background/async-status.d.ts +2 -0
- package/src/runs/background/async-status.js +4 -0
- package/src/runs/background/auto-drain.js +2 -1
- package/src/runs/background/boot-id.d.ts +1 -3
- package/src/runs/background/boot-id.js +1 -3
- package/src/runs/background/completion-batcher.d.ts +3 -4
- package/src/runs/background/completion-batcher.js +2 -3
- package/src/runs/background/control-channel.d.ts +0 -6
- package/src/runs/background/control-channel.js +0 -6
- package/src/runs/background/fleet-view.js +2 -3
- package/src/runs/background/notify.d.ts +0 -2
- package/src/runs/background/notify.js +0 -2
- package/src/runs/background/result-watcher.d.ts +1 -0
- package/src/runs/background/result-watcher.js +59 -29
- package/src/runs/background/resume-guidance.js +4 -2
- package/src/runs/background/retained-children.js +2 -1
- package/src/runs/background/run-child-session.d.ts +2 -3
- package/src/runs/background/run-child-session.js +5 -8
- package/src/runs/background/run-status.js +9 -7
- package/src/runs/background/runner-aliases.js +15 -0
- package/src/runs/background/scheduled-runs.d.ts +3 -1
- package/src/runs/background/scheduled-runs.js +13 -16
- package/src/runs/background/steering.d.ts +2 -11
- package/src/runs/background/steering.js +11 -6
- package/src/runs/background/subagent-runner.d.ts +2 -6
- package/src/runs/background/subagent-runner.js +88 -70
- package/src/runs/background/subagent-wait.js +12 -15
- package/src/runs/background/wait-config.d.ts +2 -0
- package/src/runs/background/wait-config.js +17 -3
- package/src/runs/background/wait-subscriptions.js +124 -12
- package/src/runs/background/wait-tool.js +4 -2
- package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
- package/src/runs/background/workflow-terminal-proof.js +0 -1
- package/src/runs/foreground/async-steering-action.js +24 -9
- package/src/runs/foreground/async-stop-action.d.ts +1 -1
- package/src/runs/foreground/async-stop-action.js +9 -1
- package/src/runs/foreground/execution.d.ts +0 -3
- package/src/runs/foreground/execution.js +68 -84
- package/src/runs/foreground/fork-tool-result-handler.d.ts +60 -0
- package/src/runs/foreground/fork-tool-result-handler.js +83 -0
- package/src/runs/foreground/prompt-audit.js +1 -0
- package/src/runs/foreground/subagent-executor.d.ts +5 -10
- package/src/runs/foreground/subagent-executor.js +164 -49
- package/src/runs/shared/acceptance.js +69 -26
- package/src/runs/shared/async-status-projection.d.ts +2 -0
- package/src/runs/shared/async-status-projection.js +10 -0
- package/src/runs/shared/child-commands.js +15 -2
- package/src/runs/shared/child-hooks.d.ts +1 -7
- package/src/runs/shared/child-hooks.js +13 -5
- package/src/runs/shared/child-launch.js +6 -2
- package/src/runs/shared/child-runtime-config.d.ts +0 -1
- package/src/runs/shared/child-session.d.ts +6 -5
- package/src/runs/shared/child-session.js +85 -38
- package/src/runs/shared/child-tool-plan.d.ts +0 -1
- package/src/runs/shared/child-tool-plan.js +0 -1
- package/src/runs/shared/claude-code-adapter.js +11 -0
- package/src/runs/shared/external-cli-contract.d.ts +49 -0
- package/src/runs/shared/external-cli-contract.js +18 -13
- package/src/runs/shared/external-cli-runner.js +26 -6
- package/src/runs/shared/herdr-connection.js +2 -1
- package/src/runs/shared/herdr-pane-host.d.ts +2 -2
- package/src/runs/shared/herdr-pane-host.js +17 -1
- package/src/runs/shared/herdr-placed-run.js +51 -24
- package/src/runs/shared/lane-metadata.d.ts +0 -1
- package/src/runs/shared/lane-metadata.js +0 -1
- package/src/runs/shared/mcp-config-sources.d.ts +4 -1
- package/src/runs/shared/mcp-config-sources.js +1 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -3
- package/src/runs/shared/mcp-direct-tool-allowlist.js +26 -17
- package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
- package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
- package/src/runs/shared/model-resolution.d.ts +20 -5
- package/src/runs/shared/model-resolution.js +55 -50
- package/src/runs/shared/model-scope.d.ts +1 -5
- package/src/runs/shared/model-scope.js +1 -5
- package/src/runs/shared/mutation-evidence.d.ts +1 -1
- package/src/runs/shared/mutation-evidence.js +52 -7
- package/src/runs/shared/nested-events.d.ts +1 -0
- package/src/runs/shared/nested-events.js +1 -1
- package/src/runs/shared/parallel-utils.d.ts +0 -1
- package/src/runs/shared/permissions.js +5 -3
- package/src/runs/shared/placement-host.d.ts +5 -1
- package/src/runs/shared/rex-pane-host.d.ts +0 -1
- package/src/runs/shared/rex-pane-host.js +0 -2
- package/src/runs/shared/run-launch-folder.d.ts +12 -0
- package/src/runs/shared/run-launch-folder.js +21 -0
- package/src/runs/shared/runner-launcher.d.ts +12 -1
- package/src/runs/shared/runner-launcher.js +16 -0
- package/src/runs/shared/single-output.d.ts +3 -3
- package/src/runs/shared/single-output.js +5 -3
- package/src/runs/shared/structured-output.d.ts +8 -0
- package/src/runs/shared/structured-output.js +40 -5
- package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
- package/src/runs/shared/subagent-prompt-runtime.js +18 -4
- package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
- package/src/runs/shared/supervisor-wait-timer.js +61 -0
- package/src/runs/shared/tool-timeout.js +2 -1
- package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
- package/src/runs/shared/worktree-cleanup-plan.js +0 -1
- package/src/runs/shared/worktree.d.ts +3 -0
- package/src/runs/shared/worktree.js +20 -0
- package/src/shared/artifacts.d.ts +1 -0
- package/src/shared/artifacts.js +132 -22
- package/src/shared/capacity-resilient-json.d.ts +1 -1
- package/src/shared/child-cache-retention.d.ts +1 -2
- package/src/shared/child-cache-retention.js +1 -2
- package/src/shared/fleet-transcript-reader.d.ts +64 -0
- package/src/shared/fleet-transcript-reader.js +376 -0
- package/src/shared/formatters.d.ts +0 -18
- package/src/shared/formatters.js +0 -18
- package/src/shared/pruned-fork.js +2 -2
- package/src/shared/reported-progress.d.ts +1 -0
- package/src/shared/reported-progress.js +12 -0
- package/src/shared/session-succession.d.ts +16 -1
- package/src/shared/session-succession.js +41 -2
- package/src/shared/session-warnings.d.ts +7 -0
- package/src/shared/session-warnings.js +26 -0
- package/src/shared/settings.d.ts +0 -23
- package/src/shared/settings.js +3 -35
- package/src/shared/status-format.d.ts +1 -0
- package/src/shared/status-format.js +1 -1
- package/src/shared/types.d.ts +108 -59
- package/src/shared/types.js +0 -12
- package/src/shared/utils.d.ts +3 -15
- package/src/shared/utils.js +4 -22
- package/src/shared/wait-tool-name.d.ts +8 -0
- package/src/shared/wait-tool-name.js +13 -0
- package/src/slash/slash-commands.js +2 -1
- package/src/slash/subagent-cost.d.ts +3 -2
- package/src/slash/subagent-cost.js +22 -3
- package/src/slash/subagents-admin.js +0 -1
- package/src/tui/fleet-native-transcript.js +1 -1
- package/src/tui/fleet-status.d.ts +0 -5
- package/src/tui/fleet-status.js +4 -24
- package/src/tui/fleet-transcript.d.ts +1 -57
- package/src/tui/fleet-transcript.js +4 -370
- package/src/tui/fleet.js +6 -4
- package/src/tui/render.d.ts +0 -9
- package/src/tui/render.js +194 -68
- package/src/tui/subagent-messages.js +3 -2
- package/src/watchdog/model-selection.js +2 -2
- package/src/watchdog/permission-arbiter.js +1 -0
- package/src/watchdog/register-child.d.ts +2 -3
- package/src/watchdog/register-child.js +2 -3
- package/src/watchdog/review.d.ts +0 -5
- package/src/watchdog/review.js +4 -3
- package/src/watchdog/turn-delta.js +2 -1
- package/src/workflows/scripted-workflow.d.ts +2 -0
- package/src/workflows/scripted-workflow.js +344 -59
- package/src/workflows/structured-workflow-scripts.d.ts +4 -3
- package/src/workflows/structured-workflow-scripts.js +32 -11
- package/src/workflows/workflow-launch-record.d.ts +15 -6
- package/src/workflows/workflow-launch-record.js +30 -12
- package/src/workflows/workflow-receipt.js +36 -53
- package/src/workflows/workflow-resources.js +4 -4
- package/src/workflows/workflow-resume-claim.d.ts +2 -0
- package/src/workflows/workflow-resume-claim.js +3 -3
- package/src/workflows/workflow-resume.d.ts +1 -1
- package/src/workflows/workflow-resume.js +13 -8
- package/src/workflows/workflow-script-worker.d.ts +13 -0
- package/src/workflows/workflow-script-worker.js +81 -0
- package/workflow-script-process.cjs +36 -0
- package/workflow-script-worker.cjs +4 -1
- package/bundle/chunk-U4ODUYAG.js +0 -235
package/src/tui/render.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rendering functions for subagent results
|
|
3
|
-
*/
|
|
4
1
|
import * as path from "node:path";
|
|
5
2
|
import { createHash } from "node:crypto";
|
|
6
3
|
import { getMarkdownTheme, keyText } from "@earendil-works/pi-coding-agent";
|
|
@@ -13,7 +10,7 @@ import { formatContextUsage, formatTokens, formatUsage, formatDuration, formatMo
|
|
|
13
10
|
import { getDisplayItems, getSingleResultOutput, PROMPT_REDACTED } from "../shared/utils.js";
|
|
14
11
|
import { flatToLogicalStepIndex } from "../runs/background/parallel-groups.js";
|
|
15
12
|
import { formatNestedAggregate } from "../runs/shared/nested-render.js";
|
|
16
|
-
import { aggregateStepStatus, formatActivityLabel, formatAgentRunningLabel, formatParallelOutcome } from "../shared/status-format.js";
|
|
13
|
+
import { aggregateStepStatus, formatActivityAge, formatActivityLabel, formatAgentRunningLabel, formatParallelOutcome } from "../shared/status-format.js";
|
|
17
14
|
import { contextModeBadge, contextModePrefix } from "../runs/shared/context-mode.js";
|
|
18
15
|
import { shouldSuppressSingleStep, stripRepeatedAgentPrefix, withDuplicateLabelDiscriminators } from "./render-helpers.js";
|
|
19
16
|
import { runningTone } from "./running-tone.js";
|
|
@@ -248,6 +245,33 @@ export function compactTaskText(task, label) {
|
|
|
248
245
|
return undefined;
|
|
249
246
|
return previewDisplayText(normalized, COMPACT_TASK_MAX_CHARS);
|
|
250
247
|
}
|
|
248
|
+
const EXPANDED_TASK_MAX_LINES = 8;
|
|
249
|
+
/** Runs on every spinner frame, so the task is cut to what the line cap can show before any sanitizing or wrapping. */
|
|
250
|
+
function expandedTaskLines(task, label, width) {
|
|
251
|
+
const taskText = task?.trim();
|
|
252
|
+
if (!taskText || taskText === PROMPT_REDACTED || width <= 0)
|
|
253
|
+
return undefined;
|
|
254
|
+
const shown = truncateDisplayText(taskText, EXPANDED_TASK_MAX_LINES * width);
|
|
255
|
+
const labelText = label?.trim() && label.trim() !== PROMPT_REDACTED ? sanitizeDisplayText(label) : "";
|
|
256
|
+
const head = labelText && labelText !== sanitizeDisplayText(shown) ? `${labelText} — ` : "";
|
|
257
|
+
const lines = [];
|
|
258
|
+
for (const rawLine of `task: ${head}${shown}`.split("\n")) {
|
|
259
|
+
const content = sanitizeDisplayText(rawLine);
|
|
260
|
+
if (!content) {
|
|
261
|
+
if (lines.length > 0 && lines[lines.length - 1] !== "")
|
|
262
|
+
lines.push("");
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
const indent = rawLine.match(/^[ \t]*/)[0].replace(/\t/g, " ").slice(0, Math.floor(width / 2));
|
|
266
|
+
for (const part of wrapPlainText(content, width - indent.length))
|
|
267
|
+
lines.push(`${indent}${part}`);
|
|
268
|
+
if (lines.length > EXPANDED_TASK_MAX_LINES)
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
if (lines.length <= EXPANDED_TASK_MAX_LINES && shown.length === taskText.length)
|
|
272
|
+
return lines;
|
|
273
|
+
return [...lines.slice(0, EXPANDED_TASK_MAX_LINES), "…"];
|
|
274
|
+
}
|
|
251
275
|
const LANE_VALUE_MAX_CHARS = 48;
|
|
252
276
|
function boundedLaneValue(value, maxChars = LANE_VALUE_MAX_CHARS) {
|
|
253
277
|
if (!value?.trim() || value.trim() === PROMPT_REDACTED)
|
|
@@ -595,6 +619,17 @@ function workflowLabelForResult(details, resultIndex) {
|
|
|
595
619
|
};
|
|
596
620
|
return details.workflowGraph ? visit(details.workflowGraph.nodes) : undefined;
|
|
597
621
|
}
|
|
622
|
+
function reportedProgressRow(progress, theme, indent, width) {
|
|
623
|
+
const text = progress.progressText?.trim();
|
|
624
|
+
if (!text)
|
|
625
|
+
return undefined;
|
|
626
|
+
let updated = "";
|
|
627
|
+
if (progress.progressUpdatedAt !== undefined) {
|
|
628
|
+
const age = formatActivityAge(Math.max(0, Date.now() - progress.progressUpdatedAt));
|
|
629
|
+
updated = age === "now" ? " · updated now" : ` · updated ${age} ago`;
|
|
630
|
+
}
|
|
631
|
+
return truncLine(theme.fg("dim", `${indent}progress: ${sanitizeDisplayText(text)}${updated}`), width);
|
|
632
|
+
}
|
|
598
633
|
function foregroundProgressForResult(details, resultIndex) {
|
|
599
634
|
const result = details.results[resultIndex];
|
|
600
635
|
if (result?.progress)
|
|
@@ -729,6 +764,31 @@ function visibleWorkflowRows(rows) {
|
|
|
729
764
|
hiddenRows: rows.length - selected.size,
|
|
730
765
|
};
|
|
731
766
|
}
|
|
767
|
+
/**
|
|
768
|
+
* Lines for at most `cap` rows: every unfinished row plus the newest finished ones, in order, with the
|
|
769
|
+
* older finished rows folded into one line, because live widgets list rows oldest first. When unfinished
|
|
770
|
+
* rows alone fill `cap`, only they are returned, possibly more than `cap`.
|
|
771
|
+
*/
|
|
772
|
+
function foldEarlierDoneLines(rows, cap, line, foldLine) {
|
|
773
|
+
if (rows.length <= cap)
|
|
774
|
+
return rows.map(line);
|
|
775
|
+
const unfinished = rows.filter((row) => row.state !== "complete");
|
|
776
|
+
if (unfinished.length >= cap)
|
|
777
|
+
return unfinished.map(line);
|
|
778
|
+
// rows.length > cap, so at least two rows fold into the one line.
|
|
779
|
+
const hidden = rows.length - cap + 1;
|
|
780
|
+
const lines = [];
|
|
781
|
+
let skipped = 0;
|
|
782
|
+
for (const row of rows) {
|
|
783
|
+
if (skipped < hidden && row.state === "complete") {
|
|
784
|
+
if (++skipped === hidden)
|
|
785
|
+
lines.push(foldLine(hidden));
|
|
786
|
+
continue;
|
|
787
|
+
}
|
|
788
|
+
lines.push(line(row));
|
|
789
|
+
}
|
|
790
|
+
return lines;
|
|
791
|
+
}
|
|
732
792
|
function snapshotNowForProgress(progress) {
|
|
733
793
|
if (progress.currentToolStartedAt !== undefined && progress.durationMs !== undefined)
|
|
734
794
|
return progress.currentToolStartedAt + progress.durationMs;
|
|
@@ -912,6 +972,8 @@ function widgetStepRenderKey(step, index, expanded = false) {
|
|
|
912
972
|
step.workflowKey,
|
|
913
973
|
step.phase,
|
|
914
974
|
step.label,
|
|
975
|
+
step.progressText,
|
|
976
|
+
step.progressUpdatedAt,
|
|
915
977
|
step.status,
|
|
916
978
|
step.activityState,
|
|
917
979
|
step.lastActivityAt,
|
|
@@ -1258,6 +1320,7 @@ function workflowChecklistItemLine(item, theme, indent, frame, includeError) {
|
|
|
1258
1320
|
return `${indent}${workflowChecklistGlyph(item, theme, frame)} ${theme.bold(identity || item.key)}${context}${state}${details ? ` ${theme.fg("dim", `· ${details}`)}` : ""}`;
|
|
1259
1321
|
}
|
|
1260
1322
|
const COLLAPSED_WORKFLOW_PHASE_LIMIT = 4;
|
|
1323
|
+
const EXPANDED_WIDGET_DONE_ITEMS = 4;
|
|
1261
1324
|
function workflowChecklistWidgetLines(checklist, theme, indent, expanded, frame, options = {}) {
|
|
1262
1325
|
if (!checklist?.total)
|
|
1263
1326
|
return [];
|
|
@@ -1266,6 +1329,12 @@ function workflowChecklistWidgetLines(checklist, theme, indent, expanded, frame,
|
|
|
1266
1329
|
const includeBottleneckOutput = options.includeBottleneckOutput ?? expanded;
|
|
1267
1330
|
const includeItemErrors = options.includeItemErrors ?? true;
|
|
1268
1331
|
const lines = includeSummary ? [`${indent}${theme.fg("dim", `Checklist ${formatWorkflowChecklistSummary(checklist)}`)}`] : [];
|
|
1332
|
+
const bottleneck = formatWorkflowChecklistBottleneck(checklist.bottleneck, { includeOutput: includeBottleneckOutput, includeError: !expanded });
|
|
1333
|
+
const tone = checklist.bottleneck?.state === "blocked" || checklist.bottleneck?.state === "failed" ? "error" : checklist.bottleneck?.state === "running" ? "accent" : "warning";
|
|
1334
|
+
const bottleneckLine = bottleneck ? `${indent}${theme.fg(tone, `bottleneck · ${bottleneck}`)}` : undefined;
|
|
1335
|
+
const liveExpanded = expanded && options.liveWidget === true;
|
|
1336
|
+
if (liveExpanded && bottleneckLine)
|
|
1337
|
+
lines.push(bottleneckLine);
|
|
1269
1338
|
const phases = !limitPhases || checklist.phases.length <= COLLAPSED_WORKFLOW_PHASE_LIMIT
|
|
1270
1339
|
? checklist.phases
|
|
1271
1340
|
: checklist.phases
|
|
@@ -1287,16 +1356,14 @@ function workflowChecklistWidgetLines(checklist, theme, indent, expanded, frame,
|
|
|
1287
1356
|
}, theme, frame);
|
|
1288
1357
|
lines.push(`${indent}${glyph} ${theme.bold(formatWorkflowChecklistPhase(phase))}`);
|
|
1289
1358
|
if (expanded) {
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1359
|
+
const items = [...phase.items].sort((left, right) => workflowChecklistItemPriority(left.state) - workflowChecklistItemPriority(right.state));
|
|
1360
|
+
const line = (item) => workflowChecklistItemLine(item, theme, `${indent} `, frame, includeItemErrors || item.kind === "host");
|
|
1361
|
+
const cap = liveExpanded ? items.filter((item) => item.state !== "complete").length + EXPANDED_WIDGET_DONE_ITEMS + 1 : items.length;
|
|
1362
|
+
lines.push(...foldEarlierDoneLines(items, cap, line, (hidden) => `${indent} ${theme.fg("dim", `… ${hidden} earlier done`)}`));
|
|
1293
1363
|
}
|
|
1294
1364
|
}
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
const tone = checklist.bottleneck?.state === "blocked" || checklist.bottleneck?.state === "failed" ? "error" : checklist.bottleneck?.state === "running" ? "accent" : "warning";
|
|
1298
|
-
lines.push(`${indent}${theme.fg(tone, `bottleneck · ${bottleneck}`)}`);
|
|
1299
|
-
}
|
|
1365
|
+
if (!liveExpanded && bottleneckLine)
|
|
1366
|
+
lines.push(bottleneckLine);
|
|
1300
1367
|
return lines;
|
|
1301
1368
|
}
|
|
1302
1369
|
function compactWorkflowLaneState(items) {
|
|
@@ -1473,24 +1540,25 @@ function compactWorkflowHeaderLine(job, theme, width) {
|
|
|
1473
1540
|
return full;
|
|
1474
1541
|
return `${theme.fg("toolTitle", themeBold(theme, `async workflow ${label}`))} ${theme.fg("dim", "· background")}`;
|
|
1475
1542
|
}
|
|
1476
|
-
|
|
1543
|
+
/** `lineBudget` is the room left for these lines; older done lanes fold so the newest and active ones fit. */
|
|
1544
|
+
function compactWorkflowWidgetBodyLines(job, theme, frame, projection, lineBudget) {
|
|
1477
1545
|
const rows = compactWorkflowLaneRows(job, projection.checklist);
|
|
1478
1546
|
const lines = [` ${compactWorkflowStats(job, rows, theme, projection)}`];
|
|
1479
1547
|
if (projection.inlineFleetCovered)
|
|
1480
1548
|
return [...lines, ` ${theme.fg("dim", "Workflow children shown in Fleet roster")}`];
|
|
1549
|
+
const bottleneck = compactWorkflowBottleneck(rows, job);
|
|
1550
|
+
const hint = job.status === "running" || rows.some((row) => row.state === "running");
|
|
1481
1551
|
if (rows.length) {
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
}
|
|
1552
|
+
const shown = rows.filter((row) => !projection.materializedKeys?.has(row.key));
|
|
1553
|
+
const cap = lineBudget === undefined ? shown.length : Math.max(1, lineBudget - lines.length - Number(Boolean(bottleneck)) - Number(hint));
|
|
1554
|
+
lines.push(...foldEarlierDoneLines(shown, cap, (row) => compactWorkflowLaneLine(row, theme, " ", frame), (hidden) => ` ${theme.fg("dim", `… ${hidden} earlier done`)}`));
|
|
1486
1555
|
}
|
|
1487
1556
|
else {
|
|
1488
1557
|
lines.push(` ${theme.fg("dim", "◦ waiting for workflow lanes")}`);
|
|
1489
1558
|
}
|
|
1490
|
-
const bottleneck = compactWorkflowBottleneck(rows, job);
|
|
1491
1559
|
if (bottleneck)
|
|
1492
1560
|
lines.push(` ${theme.fg(bottleneck.tone, `bottleneck · ${bottleneck.text}`)}`);
|
|
1493
|
-
if (
|
|
1561
|
+
if (hint)
|
|
1494
1562
|
lines.push(` ${theme.fg("accent", workflowDetailHintText())}`);
|
|
1495
1563
|
return lines;
|
|
1496
1564
|
}
|
|
@@ -1515,7 +1583,7 @@ function widgetStepActivity(step, snapshotNow) {
|
|
|
1515
1583
|
return activity;
|
|
1516
1584
|
return facts.join(" · ");
|
|
1517
1585
|
}
|
|
1518
|
-
function widgetChainDetails(job, theme, expanded = false, width = getTermWidth(), frame) {
|
|
1586
|
+
function widgetChainDetails(job, theme, expanded = false, width = getTermWidth(), frame, fullTask = false) {
|
|
1519
1587
|
if (!job.steps?.length)
|
|
1520
1588
|
return [];
|
|
1521
1589
|
const total = job.chainStepCount ?? job.steps.length;
|
|
@@ -1523,7 +1591,7 @@ function widgetChainDetails(job, theme, expanded = false, width = getTermWidth()
|
|
|
1523
1591
|
for (const span of buildAsyncChainStepSpans(total, job.steps.length, job.parallelGroups)) {
|
|
1524
1592
|
const steps = job.steps.slice(span.start, span.start + span.count);
|
|
1525
1593
|
if (span.isParallel) {
|
|
1526
|
-
lines.push(...parallelWidgetGroupDetails(job, theme, { steps, total: span.count, stepIndex: span.stepIndex, chainTotal: total }, expanded, width, frame, false));
|
|
1594
|
+
lines.push(...parallelWidgetGroupDetails(job, theme, { steps, total: span.count, stepIndex: span.stepIndex, chainTotal: total }, expanded, width, frame, false, fullTask));
|
|
1527
1595
|
continue;
|
|
1528
1596
|
}
|
|
1529
1597
|
const step = steps[0];
|
|
@@ -1531,20 +1599,26 @@ function widgetChainDetails(job, theme, expanded = false, width = getTermWidth()
|
|
|
1531
1599
|
lines.push(` ${theme.fg("dim", `◦ Step ${span.stepIndex + 1}/${total}: pending`)}`);
|
|
1532
1600
|
continue;
|
|
1533
1601
|
}
|
|
1534
|
-
lines.push(...foregroundStyleWidgetStepLines(job, theme, step, "Step", span.stepIndex + 1, total, expanded, width, frame));
|
|
1602
|
+
lines.push(...foregroundStyleWidgetStepLines(job, theme, step, "Step", span.stepIndex + 1, total, expanded, width, frame, { fullTask }));
|
|
1535
1603
|
}
|
|
1536
1604
|
return lines;
|
|
1537
1605
|
}
|
|
1538
|
-
function widgetParallelAgentDetails(job, theme, expanded = false, width = getTermWidth(), frame) {
|
|
1606
|
+
function widgetParallelAgentDetails(job, theme, expanded = false, width = getTermWidth(), frame, fullTask = false) {
|
|
1539
1607
|
if (!job.steps?.length)
|
|
1540
1608
|
return [];
|
|
1609
|
+
// Multi-job cards prefix every line with a 4-column tree continuation after this returns.
|
|
1610
|
+
const taskLines = (step, indent) => expanded && fullTask && step.status === "running"
|
|
1611
|
+
? (expandedTaskLines(step.description, step.label, width - indent.length - 4) ?? []).map((line) => `${indent}${theme.fg("dim", line)}`)
|
|
1612
|
+
: [];
|
|
1613
|
+
if (job.mode === "single")
|
|
1614
|
+
return job.steps.flatMap((step) => taskLines(step, " "));
|
|
1541
1615
|
if (job.mode !== "parallel" && job.mode !== "chain")
|
|
1542
1616
|
return [];
|
|
1543
1617
|
if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length)
|
|
1544
|
-
return widgetChainDetails(job, theme, expanded, width, frame);
|
|
1618
|
+
return widgetChainDetails(job, theme, expanded, width, frame, fullTask);
|
|
1545
1619
|
const group = activeParallelWidgetGroup(job);
|
|
1546
1620
|
if (group)
|
|
1547
|
-
return parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup));
|
|
1621
|
+
return parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup), fullTask);
|
|
1548
1622
|
const total = job.stepsTotal ?? job.steps.length;
|
|
1549
1623
|
const lines = [];
|
|
1550
1624
|
for (const [index, step] of job.steps.entries()) {
|
|
@@ -1556,6 +1630,7 @@ function widgetParallelAgentDetails(job, theme, expanded = false, width = getTer
|
|
|
1556
1630
|
const display = step.sessionName?.trim() || (label ? `${label} (${step.agent})` : step.agent);
|
|
1557
1631
|
const thinking = childThinkingLevel(step);
|
|
1558
1632
|
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}` : ""}`)}`);
|
|
1633
|
+
lines.push(...taskLines(step, " "));
|
|
1559
1634
|
const lane = projectAsyncLane(job, step);
|
|
1560
1635
|
if (lane)
|
|
1561
1636
|
lines.push(...formatLaneProjectionLines(lane, theme, " "));
|
|
@@ -1703,7 +1778,7 @@ function parallelWidgetGroupHeader(group, theme, frame) {
|
|
|
1703
1778
|
: "parallel group";
|
|
1704
1779
|
return ` ${widgetStepGlyph(status, theme, widgetStepsRunningSeed(group.steps), frame)} ${themeBold(theme, label)} ${theme.fg("dim", "·")} ${theme.fg("dim", formatParallelOutcome(group.steps, group.total))}`;
|
|
1705
1780
|
}
|
|
1706
|
-
function parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, prioritizeActive) {
|
|
1781
|
+
function parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, prioritizeActive, fullTask = false) {
|
|
1707
1782
|
const lines = [parallelWidgetGroupHeader(group, theme, frame)];
|
|
1708
1783
|
const rows = parallelWidgetStepRows(group.steps, group.total, prioritizeActive);
|
|
1709
1784
|
for (const [rowIndex, row] of rows.entries()) {
|
|
@@ -1714,6 +1789,7 @@ function parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, p
|
|
|
1714
1789
|
detailIndent: " ",
|
|
1715
1790
|
rowMarker: marker,
|
|
1716
1791
|
includeCurrentPath: true,
|
|
1792
|
+
fullTask,
|
|
1717
1793
|
}));
|
|
1718
1794
|
}
|
|
1719
1795
|
for (let index = rows.length; index < group.total; index++) {
|
|
@@ -2204,7 +2280,9 @@ function formatNestedWidgetLines(children, theme, width, expanded, snapshotNow,
|
|
|
2204
2280
|
append(children, 0, "");
|
|
2205
2281
|
return lines.map((line) => truncLine(line, width));
|
|
2206
2282
|
}
|
|
2207
|
-
function foregroundStyleWidgetStepLines(job, theme, step, itemTitle, index, total, expanded, width, frame,
|
|
2283
|
+
function foregroundStyleWidgetStepLines(job, theme, step, itemTitle, index, total, expanded, width, frame,
|
|
2284
|
+
/** `fullTask`: the widget has exactly one running child, so an expanded row may spend lines on its whole task. */
|
|
2285
|
+
options) {
|
|
2208
2286
|
const rowIndent = options?.rowIndent ?? " ";
|
|
2209
2287
|
const detailIndent = options?.detailIndent ?? " ";
|
|
2210
2288
|
const thinking = childThinkingLevel(step);
|
|
@@ -2223,9 +2301,16 @@ function foregroundStyleWidgetStepLines(job, theme, step, itemTitle, index, tota
|
|
|
2223
2301
|
const lane = projectAsyncLane(job, step);
|
|
2224
2302
|
if (lane)
|
|
2225
2303
|
lines.push(...formatLaneProjectionLines(lane, theme, detailIndent));
|
|
2226
|
-
|
|
2304
|
+
// Multi-job cards prefix every line with a 4-column tree continuation after this returns.
|
|
2305
|
+
const fullTask = expanded && options?.fullTask && step.status === "running" ? expandedTaskLines(step.description, step.label, width - detailIndent.length - 4) : undefined;
|
|
2306
|
+
const task = fullTask ? undefined : collapseDetails ? stepTaskSummary(step, displayName) : compactTaskText(step.description, step.label);
|
|
2307
|
+
for (const line of fullTask ?? [])
|
|
2308
|
+
lines.push(`${detailIndent}${theme.fg("dim", line)}`);
|
|
2227
2309
|
if (task)
|
|
2228
2310
|
lines.push(`${detailIndent}${theme.fg("dim", `task: ${task}`)}`);
|
|
2311
|
+
const progressRow = step.status === "running" ? reportedProgressRow(step, theme, detailIndent, width - 4) : undefined;
|
|
2312
|
+
if (progressRow)
|
|
2313
|
+
lines.push(progressRow);
|
|
2229
2314
|
const activity = widgetStepActivityLine(step, width, expanded, job.updatedAt);
|
|
2230
2315
|
const currentPath = options?.includeCurrentPath && step.currentPath ? shortenPath(step.currentPath) : undefined;
|
|
2231
2316
|
const activityWithPath = currentPath && activity && !activity.includes(currentPath)
|
|
@@ -2286,7 +2371,7 @@ function hostStepWidgetLines(job, theme, indent) {
|
|
|
2286
2371
|
lines.push(`${indent}${theme.fg("dim", `… +${rows.length - visible.length} host steps hidden`)}`);
|
|
2287
2372
|
return lines;
|
|
2288
2373
|
}
|
|
2289
|
-
function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection = buildWorkflowWidgetProjection(job)) {
|
|
2374
|
+
function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection = buildWorkflowWidgetProjection(job), fullTask = false) {
|
|
2290
2375
|
const steps = projection.steps.filter((step) => !projection.materializedKeys?.has(step.workflowKey ?? "") && !projection.materializedKeys?.has(step.runId ?? ""));
|
|
2291
2376
|
const checklist = widgetChecklistWithoutMaterializedChildren(projection);
|
|
2292
2377
|
if (!expanded && job.mode === "workflow") {
|
|
@@ -2296,7 +2381,7 @@ function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projec
|
|
|
2296
2381
|
const lane = projectAsyncLane(job, laneStepForJob(job, steps));
|
|
2297
2382
|
return [
|
|
2298
2383
|
...(expanded ? workflowPreflightLines(job) : []),
|
|
2299
|
-
...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame),
|
|
2384
|
+
...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame, { liveWidget: true }),
|
|
2300
2385
|
...(lane ? formatLaneProjectionLines(lane, theme, " ") : []),
|
|
2301
2386
|
...hostStepWidgetLines(job, theme, " "),
|
|
2302
2387
|
` ${theme.fg("dim", `⎿ ${widgetActivity(job)}`)}`,
|
|
@@ -2304,14 +2389,14 @@ function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projec
|
|
|
2304
2389
|
];
|
|
2305
2390
|
}
|
|
2306
2391
|
if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length)
|
|
2307
|
-
return widgetChainDetails(job, theme, expanded, width, frame);
|
|
2392
|
+
return widgetChainDetails(job, theme, expanded, width, frame, fullTask);
|
|
2308
2393
|
const lines = [
|
|
2309
2394
|
...(expanded ? workflowPreflightLines(job) : []),
|
|
2310
|
-
...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame, { includeItemErrors: !expanded }),
|
|
2395
|
+
...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame, { includeItemErrors: !expanded, liveWidget: true }),
|
|
2311
2396
|
];
|
|
2312
2397
|
const group = activeParallelWidgetGroup(job);
|
|
2313
2398
|
if (group) {
|
|
2314
|
-
lines.push(...parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup)));
|
|
2399
|
+
lines.push(...parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup), fullTask));
|
|
2315
2400
|
}
|
|
2316
2401
|
else {
|
|
2317
2402
|
const { stageProgress, plannedKeys } = projection;
|
|
@@ -2328,7 +2413,7 @@ function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projec
|
|
|
2328
2413
|
const itemTitle = isPlannedStage ? "Stage" : "Step";
|
|
2329
2414
|
const displayIndex = isPlannedStage ? (step.index ?? index) + 1 : plannedKeys ? ++extraStepIndex : index + 1;
|
|
2330
2415
|
const displayTotal = isPlannedStage ? stageTotal : extraStepCount;
|
|
2331
|
-
lines.push(...foregroundStyleWidgetStepLines(job, theme, step, itemTitle, displayIndex, displayTotal, expanded, width, frame));
|
|
2416
|
+
lines.push(...foregroundStyleWidgetStepLines(job, theme, step, itemTitle, displayIndex, displayTotal, expanded, width, frame, { fullTask }));
|
|
2332
2417
|
}
|
|
2333
2418
|
}
|
|
2334
2419
|
lines.push(...hostStepWidgetLines(job, theme, " "));
|
|
@@ -2339,9 +2424,10 @@ function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projec
|
|
|
2339
2424
|
}
|
|
2340
2425
|
return lines;
|
|
2341
2426
|
}
|
|
2342
|
-
|
|
2427
|
+
/** `reservedLines` are lines the caller renders after these, such as materialized workflow children. */
|
|
2428
|
+
function buildSingleWidgetLines(job, theme, width, expanded, frame, projection = buildWorkflowWidgetProjection(job), reservedLines = 0, fullTask = false) {
|
|
2343
2429
|
if ((!expanded || projection.inlineFleetCovered) && job.mode === "workflow")
|
|
2344
|
-
return [compactWorkflowHeaderLine(job, theme, width), ...compactWorkflowWidgetBodyLines(job, theme, frame, projection)].map((line) => truncLine(line, width));
|
|
2430
|
+
return [compactWorkflowHeaderLine(job, theme, width), ...compactWorkflowWidgetBodyLines(job, theme, frame, projection, widgetLineBudget(expanded) - 1 - reservedLines)].map((line) => truncLine(line, width));
|
|
2345
2431
|
const stats = widgetStats(job, theme, projection, !expanded);
|
|
2346
2432
|
const count = job.mode === "workflow"
|
|
2347
2433
|
? projection.checklist?.total ?? projection.stageProgress?.total ?? job.stepsTotal ?? job.agents?.length ?? job.steps?.length
|
|
@@ -2356,7 +2442,7 @@ function buildSingleWidgetLines(job, theme, width, expanded, frame, projection =
|
|
|
2356
2442
|
return [
|
|
2357
2443
|
`${theme.fg("toolTitle", themeBold(theme, title))} ${theme.fg("dim", "· background")}`,
|
|
2358
2444
|
...(collapseDetails ? [] : [summary]),
|
|
2359
|
-
...foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection),
|
|
2445
|
+
...foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection, fullTask),
|
|
2360
2446
|
].map((line) => truncLine(line, width));
|
|
2361
2447
|
}
|
|
2362
2448
|
function compactSingleWidgetLines(job, theme, width, frame, projection = buildWorkflowWidgetProjection(job)) {
|
|
@@ -2375,12 +2461,15 @@ function compactSingleWidgetLines(job, theme, width, frame, projection = buildWo
|
|
|
2375
2461
|
const status = widgetStepStatus(step.status, theme, thinking);
|
|
2376
2462
|
const activity = widgetStepActivityLine(step, width, false, job.updatedAt);
|
|
2377
2463
|
const stepStats = widgetStepStats(theme, step, job.updatedAt);
|
|
2378
|
-
const activitySuffix = activity ? ` ${theme.fg("dim", "·")} ${theme.fg("dim", activity)}` : "";
|
|
2379
2464
|
const modelDisplay = modelThinkingBadge(theme, step.model, step.thinking);
|
|
2380
2465
|
const task = compactTaskText(step.description, step.label);
|
|
2381
2466
|
const taskSuffix = task ? ` ${theme.fg("dim", "·")} ${theme.fg("dim", `task: ${task}`)}` : "";
|
|
2467
|
+
const activitySuffix = activity ? ` ${theme.fg("dim", "·")} ${theme.fg("dim", activity)}` : "";
|
|
2382
2468
|
const marker = rowIndex === rows.length - 1 && rowIndex >= group.total - 1 ? "└─" : "├─";
|
|
2383
2469
|
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}` : ""}`);
|
|
2470
|
+
const progressRow = step.status === "running" ? reportedProgressRow(step, theme, " ", width) : undefined;
|
|
2471
|
+
if (progressRow)
|
|
2472
|
+
lines.push(progressRow);
|
|
2384
2473
|
const lane = projectAsyncLane(job, step);
|
|
2385
2474
|
if (lane)
|
|
2386
2475
|
lines.push(...formatLaneProjectionLines(lane, theme, " "));
|
|
@@ -2632,10 +2721,9 @@ function buildProgressiveWidgetLines(jobs, theme, width, lockedRows, previousKey
|
|
|
2632
2721
|
lines.push(progressiveJobLine(job, theme, width, frame, projection, laneRows));
|
|
2633
2722
|
if (!laneRows || projection.inlineFleetCovered)
|
|
2634
2723
|
continue;
|
|
2635
|
-
const
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
spareRows -= shownLanes.length;
|
|
2724
|
+
const laneLines = foldEarlierDoneLines(laneRows, spareRows, (row) => truncLine(compactWorkflowLaneLine(row, theme, " ", frame), width), (hidden) => truncLine(` ${theme.fg("dim", `… ${hidden} earlier done`)}`, width)).slice(0, spareRows);
|
|
2725
|
+
lines.push(...laneLines);
|
|
2726
|
+
spareRows -= laneLines.length;
|
|
2639
2727
|
}
|
|
2640
2728
|
if (hiddenJobs.length > 0 && lines.length < rowCount)
|
|
2641
2729
|
lines.push(progressiveHiddenLine(hiddenJobs, theme, width));
|
|
@@ -2653,11 +2741,12 @@ function paddedWidgetLine(line, width) {
|
|
|
2653
2741
|
const text = ` ${truncLine(line, width - 2)} `;
|
|
2654
2742
|
return `${text}${" ".repeat(Math.max(0, width - visibleWidth(text)))}`;
|
|
2655
2743
|
}
|
|
2744
|
+
function widgetLineBudget(expanded) {
|
|
2745
|
+
const rows = currentTerminalRows();
|
|
2746
|
+
return expanded ? Math.max(12, Math.min(24, Math.floor(rows * 0.55))) : collapsedWidgetLineBudget(rows);
|
|
2747
|
+
}
|
|
2656
2748
|
function fitWidgetLineBudget(lines, theme, width, expanded) {
|
|
2657
|
-
const
|
|
2658
|
-
const budget = expanded
|
|
2659
|
-
? Math.max(12, Math.min(24, Math.floor(rows * 0.55)))
|
|
2660
|
-
: collapsedWidgetLineBudget(rows);
|
|
2749
|
+
const budget = widgetLineBudget(expanded);
|
|
2661
2750
|
if (lines.length <= budget)
|
|
2662
2751
|
return lines;
|
|
2663
2752
|
const visibleLines = Math.max(1, budget - 1);
|
|
@@ -2788,7 +2877,7 @@ function widgetChecklistWithoutMaterializedChildren(projection) {
|
|
|
2788
2877
|
return checklist;
|
|
2789
2878
|
return { ...checklist, phases: checklist.phases.map((phase) => ({ ...phase, items: phase.items.filter((item) => !materializedKeys.has(item.key)) })) };
|
|
2790
2879
|
}
|
|
2791
|
-
function materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor) {
|
|
2880
|
+
function materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor, fullTask = false) {
|
|
2792
2881
|
const { children, inlineFleetCovered } = projectionFor(job);
|
|
2793
2882
|
if (inlineFleetCovered || !children?.length)
|
|
2794
2883
|
return [];
|
|
@@ -2800,9 +2889,9 @@ function materializedWidgetChildLines(job, theme, width, expanded, frame, projec
|
|
|
2800
2889
|
const identity = child.workflowKey ?? child.asyncId;
|
|
2801
2890
|
const stats = widgetStats(child, theme, projection, !expanded);
|
|
2802
2891
|
lines.push(` ${last ? "└─" : "├─"} ${theme.bold(identity)} ${widgetStatusGlyph(child, theme, frame)} ${themeBold(theme, widgetJobName(child))}${contextModeBadge(theme, child.context)}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`);
|
|
2803
|
-
for (const detail of foregroundStyleWidgetDetails(child, theme, expanded, Math.max(0, width - 6), frame, projection))
|
|
2892
|
+
for (const detail of foregroundStyleWidgetDetails(child, theme, expanded, Math.max(0, width - 6), frame, projection, fullTask))
|
|
2804
2893
|
lines.push(` ${last ? " " : "│ "}${detail}`);
|
|
2805
|
-
for (const detail of materializedWidgetChildLines(child, theme, Math.max(0, width - 4), expanded, frame, projectionFor))
|
|
2894
|
+
for (const detail of materializedWidgetChildLines(child, theme, Math.max(0, width - 4), expanded, frame, projectionFor, fullTask))
|
|
2806
2895
|
lines.push(` ${detail}`);
|
|
2807
2896
|
}
|
|
2808
2897
|
if (shown.length < children.length)
|
|
@@ -2905,14 +2994,33 @@ function buildWidgetComponent(jobs, ui, initiallyCollapsed = false, layout) {
|
|
|
2905
2994
|
return component;
|
|
2906
2995
|
};
|
|
2907
2996
|
}
|
|
2997
|
+
/** Running children the widget shows, counted the way it renders them: a workflow step that has
|
|
2998
|
+
* its own child job is that job's row, so it counts once. */
|
|
2999
|
+
function runningWidgetChildCount(jobs, projectionFor) {
|
|
3000
|
+
let running = 0;
|
|
3001
|
+
for (const job of jobs) {
|
|
3002
|
+
const { steps, materializedKeys, children } = projectionFor(job);
|
|
3003
|
+
if (!steps.length && job.status === "running")
|
|
3004
|
+
running++;
|
|
3005
|
+
for (const step of steps) {
|
|
3006
|
+
if (step.status === "running" && !materializedKeys?.has(step.workflowKey ?? "") && !materializedKeys?.has(step.runId ?? ""))
|
|
3007
|
+
running++;
|
|
3008
|
+
}
|
|
3009
|
+
if (children?.length)
|
|
3010
|
+
running += runningWidgetChildCount(children, projectionFor);
|
|
3011
|
+
}
|
|
3012
|
+
return running;
|
|
3013
|
+
}
|
|
2908
3014
|
function buildWidgetLinesWithProjection(jobs, theme, width = getTermWidth(), expanded = false, frame, projectionFor = workflowWidgetProjectionLookup()) {
|
|
2909
3015
|
if (jobs.length === 0)
|
|
2910
3016
|
return [];
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
];
|
|
3017
|
+
// Expanded rows show a whole task only while exactly one child runs in the whole widget; with
|
|
3018
|
+
// more, the extra lines would push other running children past the widget's line budget.
|
|
3019
|
+
const fullTask = expanded && runningWidgetChildCount(jobs, projectionFor) === 1;
|
|
3020
|
+
if (jobs.length === 1) {
|
|
3021
|
+
const childLines = materializedWidgetChildLines(jobs[0], theme, width, expanded, frame, projectionFor, fullTask).map((line) => truncLine(line, width));
|
|
3022
|
+
return [...buildSingleWidgetLines(jobs[0], theme, width, expanded, frame, projectionFor(jobs[0]), childLines.length, fullTask), ...childLines];
|
|
3023
|
+
}
|
|
2916
3024
|
const running = jobs.filter((job) => job.status === "running");
|
|
2917
3025
|
const queued = jobs.filter((job) => job.status === "queued");
|
|
2918
3026
|
const finished = jobs.filter((job) => job.status !== "running" && job.status !== "queued");
|
|
@@ -2926,27 +3034,29 @@ function buildWidgetLinesWithProjection(jobs, theme, width = getTermWidth(), exp
|
|
|
2926
3034
|
let hiddenFinished = 0;
|
|
2927
3035
|
let queuedSummaryShown = false;
|
|
2928
3036
|
let slots = MAX_WIDGET_JOBS;
|
|
3037
|
+
const compactCards = [];
|
|
2929
3038
|
const appendJob = (job) => {
|
|
2930
3039
|
const projection = projectionFor(job);
|
|
2931
3040
|
const compactWorkflow = (!expanded || projection.inlineFleetCovered) && job.mode === "workflow";
|
|
2932
3041
|
const stats = compactWorkflow ? "" : widgetStats(job, theme, projection, !expanded);
|
|
2933
3042
|
const details = compactWorkflow
|
|
2934
|
-
?
|
|
2935
|
-
...compactWorkflowWidgetBodyLines(job, theme, frame, projection),
|
|
2936
|
-
]
|
|
3043
|
+
? compactWorkflowWidgetBodyLines(job, theme, frame, projection)
|
|
2937
3044
|
: [
|
|
2938
3045
|
` ${theme.fg("dim", `⎿ ${widgetActivity(job)}`)}`,
|
|
2939
3046
|
...widgetLaneDetailLines(job, theme, projection),
|
|
2940
|
-
...workflowChecklistWidgetLines(widgetChecklistWithoutMaterializedChildren(projection), theme, " ", expanded, frame, { includeItemErrors: !expanded || !job.steps?.length }),
|
|
2941
|
-
...widgetParallelAgentDetails(job, theme, expanded, width, frame),
|
|
3047
|
+
...workflowChecklistWidgetLines(widgetChecklistWithoutMaterializedChildren(projection), theme, " ", expanded, frame, { includeItemErrors: !expanded || !job.steps?.length, liveWidget: true }),
|
|
3048
|
+
...widgetParallelAgentDetails(job, theme, expanded, width, frame, fullTask),
|
|
2942
3049
|
];
|
|
2943
|
-
|
|
3050
|
+
const item = [
|
|
2944
3051
|
compactWorkflow
|
|
2945
3052
|
? compactWorkflowHeaderLine(job, theme, width)
|
|
2946
3053
|
: `${widgetStatusGlyph(job, theme, frame)} ${themeBold(theme, widgetJobName(job))}${contextModeBadge(theme, job.context)}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`,
|
|
2947
3054
|
...details,
|
|
2948
|
-
...materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor),
|
|
2949
|
-
]
|
|
3055
|
+
...materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor, fullTask),
|
|
3056
|
+
];
|
|
3057
|
+
items.push(item);
|
|
3058
|
+
if (compactWorkflow)
|
|
3059
|
+
compactCards.push({ item, job, projection, bodyLength: details.length });
|
|
2950
3060
|
};
|
|
2951
3061
|
for (const job of running) {
|
|
2952
3062
|
if (slots <= 0) {
|
|
@@ -2981,6 +3091,16 @@ function buildWidgetLinesWithProjection(jobs, theme, width = getTermWidth(), exp
|
|
|
2981
3091
|
parts.push(`${hiddenFinished} finished`);
|
|
2982
3092
|
items.push([theme.fg("dim", `+${hiddenTotal} more (${parts.join(", ")})`)]);
|
|
2983
3093
|
}
|
|
3094
|
+
// Fold the oldest done lanes of compact workflow cards by the overflow, so later cards and
|
|
3095
|
+
// materialized children stay inside the line budget.
|
|
3096
|
+
let overflow = 1 + items.reduce((sum, item) => sum + item.length, 0) - widgetLineBudget(expanded);
|
|
3097
|
+
for (const card of compactCards) {
|
|
3098
|
+
if (overflow <= 0)
|
|
3099
|
+
break;
|
|
3100
|
+
const body = compactWorkflowWidgetBodyLines(card.job, theme, frame, card.projection, card.bodyLength - overflow);
|
|
3101
|
+
card.item.splice(1, card.bodyLength, ...body);
|
|
3102
|
+
overflow -= card.bodyLength - body.length;
|
|
3103
|
+
}
|
|
2984
3104
|
for (let i = 0; i < items.length; i++) {
|
|
2985
3105
|
const item = items[i];
|
|
2986
3106
|
const last = i === items.length - 1;
|
|
@@ -2997,9 +3117,6 @@ export function buildWidgetLines(jobs, theme, width = getTermWidth(), expanded =
|
|
|
2997
3117
|
const { roots, projectionFor } = widgetJobTree(jobs, Date.now());
|
|
2998
3118
|
return buildWidgetLinesWithProjection(roots, theme, width, expanded, frame, projectionFor);
|
|
2999
3119
|
}
|
|
3000
|
-
/**
|
|
3001
|
-
* Render the async jobs widget
|
|
3002
|
-
*/
|
|
3003
3120
|
export function renderWidget(ctx, jobs, initiallyCollapsed = false, layout = "adaptive") {
|
|
3004
3121
|
// Advance round tracking on every widget update, including the empty-jobs
|
|
3005
3122
|
// cleanup path below, which never reaches container.render.
|
|
@@ -3044,6 +3161,9 @@ function renderSingleCompact(d, r, theme, layout, frame, foregroundDetachShortcu
|
|
|
3044
3161
|
const task = compactTaskText(r.task);
|
|
3045
3162
|
if (task)
|
|
3046
3163
|
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}task: ${task}`), width), 0, 0));
|
|
3164
|
+
const reportedRow = reportedProgressRow(r.progress, theme, detailIndent, width);
|
|
3165
|
+
if (reportedRow)
|
|
3166
|
+
c.addChild(new Text(reportedRow, 0, 0));
|
|
3047
3167
|
const progressSnapshotNow = snapshotNowForProgress(r.progress);
|
|
3048
3168
|
const activity = compactCurrentActivity(r.progress);
|
|
3049
3169
|
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}⎿ ${activity}`), width), 0, 0));
|
|
@@ -3326,6 +3446,9 @@ function renderMultiCompact(d, theme, layout, frame) {
|
|
|
3326
3446
|
if (task)
|
|
3327
3447
|
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}task: ${task}`), width), 0, 0));
|
|
3328
3448
|
}
|
|
3449
|
+
const reportedRow = rRunning && progressFromArray ? reportedProgressRow(progressFromArray, theme, detailIndent, width) : undefined;
|
|
3450
|
+
if (reportedRow)
|
|
3451
|
+
c.addChild(new Text(reportedRow, 0, 0));
|
|
3329
3452
|
if (rRunning && rProg && "status" in rProg) {
|
|
3330
3453
|
const liveProgress = rProg;
|
|
3331
3454
|
const activity = compactCurrentActivity(liveProgress);
|
|
@@ -3382,9 +3505,6 @@ export function renderSubagentSummary(result, options, theme) {
|
|
|
3382
3505
|
: details?.mode || "subagent";
|
|
3383
3506
|
return new Text(truncLine(`${glyph} ${theme.fg("toolTitle", theme.bold(label))} ${theme.fg("dim", "·")} ${theme.fg(state === "failed" ? "error" : state === "completed" ? "success" : state === "running" ? "accent" : "warning", state)}`, getTermWidth() - 4), 0, 0);
|
|
3384
3507
|
}
|
|
3385
|
-
/**
|
|
3386
|
-
* Render a subagent result
|
|
3387
|
-
*/
|
|
3388
3508
|
export function renderSubagentResult(result, options, theme, frame, rendererConfig, foregroundDetachShortcut) {
|
|
3389
3509
|
const layout = resolveMainWindowRenderLayout(rendererConfig);
|
|
3390
3510
|
const compact = (component) => capCompactMainWindowResult(component, layout, theme, !options.expanded);
|
|
@@ -3451,6 +3571,9 @@ export function renderSubagentResult(result, options, theme, frame, rendererConf
|
|
|
3451
3571
|
c.addChild(new Text(fit(theme.fg(r.exitCode !== 0 ? "error" : "dim", ` ⎿ ${resultStatusLine(r, output)}`)), 0, 0));
|
|
3452
3572
|
}
|
|
3453
3573
|
if (isRunning && r.progress) {
|
|
3574
|
+
const reportedRow = reportedProgressRow(r.progress, theme, " ", w);
|
|
3575
|
+
if (reportedRow)
|
|
3576
|
+
c.addChild(new Text(fit(reportedRow), 0, 0));
|
|
3454
3577
|
const progressSnapshotNow = snapshotNowForProgress(r.progress);
|
|
3455
3578
|
for (const nestedLine of formatNestedWidgetLines(r.children, theme, w, true, progressSnapshotNow, 12)) {
|
|
3456
3579
|
c.addChild(new Text(fit(` ${nestedLine}`), 0, 0));
|
|
@@ -3638,6 +3761,9 @@ export function renderSubagentResult(result, options, theme, frame, rendererConf
|
|
|
3638
3761
|
? r.task
|
|
3639
3762
|
: `${r.task.slice(0, taskMaxLen)}...`;
|
|
3640
3763
|
c.addChild(new Text(fit(theme.fg("dim", ` task: ${taskPreview}`)), 0, 0));
|
|
3764
|
+
const reportedRow = rRunning && progressFromArray ? reportedProgressRow(progressFromArray, theme, " ", w) : undefined;
|
|
3765
|
+
if (reportedRow)
|
|
3766
|
+
c.addChild(new Text(fit(reportedRow), 0, 0));
|
|
3641
3767
|
const outputTarget = extractOutputTarget(r.task);
|
|
3642
3768
|
if (outputTarget) {
|
|
3643
3769
|
c.addChild(new Text(fit(theme.fg("dim", ` output: ${outputTarget}`)), 0, 0));
|
|
@@ -8,6 +8,7 @@ import { safeTerminalText } from "../shared/display-text.js";
|
|
|
8
8
|
import { formatWatchdogWarningRenderText, stateLabels } from "../watchdog/render.js";
|
|
9
9
|
import { SUBAGENT_WATCHDOG_WARNING_TYPE, WATCHDOG_WARNING_IMPORTANCES, WATCHDOG_WARNING_SEVERITIES } from "../watchdog/types.js";
|
|
10
10
|
import { normalizeWatchdogWarningDetails } from "../watchdog/warning-format.js";
|
|
11
|
+
import { waitToolName } from "../shared/wait-tool-name.js";
|
|
11
12
|
/**
|
|
12
13
|
* Theme colors for the label. Pi's themes offer few non-status colors that read
|
|
13
14
|
* apart, so asks and attention notices, both a child needing the parent, share one,
|
|
@@ -122,8 +123,8 @@ function supervisorReminderHeadline(details, status) {
|
|
|
122
123
|
}
|
|
123
124
|
function waitSubscriptionHeadline(details) {
|
|
124
125
|
if (!isRecord(details) || typeof details.runId !== "string" || typeof details.outcome !== "string")
|
|
125
|
-
return [
|
|
126
|
-
return [
|
|
126
|
+
return [`${waitToolName()} fired`];
|
|
127
|
+
return [`${waitToolName()}: run ${details.runId} `, { status: details.outcome }];
|
|
127
128
|
}
|
|
128
129
|
/** Workflow child notices saved before render details existed are read from their first line. */
|
|
129
130
|
function workflowChildHeadline(message) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeModelSegment, resolveModelCandidate } from "../runs/shared/model-resolution.js";
|
|
1
|
+
import { knownModelProviders, normalizeModelSegment, resolveModelCandidate } from "../runs/shared/model-resolution.js";
|
|
2
2
|
import { getSupportedThinkingLevels, splitKnownThinkingSuffix, THINKING_LEVELS, toModelInfo, } from "../shared/model-info.js";
|
|
3
3
|
export const STRONG_WATCHDOG_THINKING = "high";
|
|
4
4
|
const STRONG_WATCHDOG_MODELS = {
|
|
@@ -53,7 +53,7 @@ export function resolveWatchdogModelInput(ctx, rawModel) {
|
|
|
53
53
|
throw new Error("Watchdog model must be a non-empty provider/model value.");
|
|
54
54
|
const availableModels = modelRegistryEntries(ctx);
|
|
55
55
|
const preferredProvider = typeof ctx.model?.provider === "string" ? ctx.model.provider : undefined;
|
|
56
|
-
const resolved = resolveModelCandidate(trimmed, availableModels, preferredProvider) ?? trimmed;
|
|
56
|
+
const resolved = resolveModelCandidate(trimmed, availableModels, preferredProvider, knownModelProviders(ctx.modelRegistry)) ?? trimmed;
|
|
57
57
|
const { baseModel, thinkingSuffix } = splitKnownThinkingSuffix(resolved);
|
|
58
58
|
const named = splitProviderModel(baseModel);
|
|
59
59
|
if (!named)
|
|
@@ -4,9 +4,8 @@ import { type ChildWatchdogConfig, type ChildWatchdogStatusEvent } from "./child
|
|
|
4
4
|
import { type ResolvedWatchdogConfig } from "./types.ts";
|
|
5
5
|
export declare function childResolvedConfig(config: ChildWatchdogConfig): ResolvedWatchdogConfig;
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* child's event stream.
|
|
7
|
+
* Status events go to the sink the hosting process passed in the child runtime
|
|
8
|
+
* config; the host folds them into the child's event stream.
|
|
10
9
|
*/
|
|
11
10
|
export declare function registerChildWatchdog(pi: ExtensionAPI, childConfig: ChildWatchdogConfig | undefined, writeStatus: ((event: ChildWatchdogStatusEvent) => void) | undefined, structuredTerminal?: {
|
|
12
11
|
captured: boolean;
|
|
@@ -34,9 +34,8 @@ function childWarningDetails(details, config) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* child's event stream.
|
|
37
|
+
* Status events go to the sink the hosting process passed in the child runtime
|
|
38
|
+
* config; the host folds them into the child's event stream.
|
|
40
39
|
*/
|
|
41
40
|
export function registerChildWatchdog(pi, childConfig, writeStatus, structuredTerminal) {
|
|
42
41
|
if (!childConfig)
|