pi-subagents 0.84.0 → 0.85.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.
Files changed (204) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/bundle/agents.js +3 -3
  3. package/bundle/child-tool-plan.js +2 -2
  4. package/bundle/{chunk-235AWJUQ.js → chunk-3UZ5FVVJ.js} +310 -101
  5. package/bundle/{chunk-F4ASL6OV.js → chunk-7MAE3DJV.js} +1 -1
  6. package/bundle/{chunk-4E7BKDTX.js → chunk-CS4O36CZ.js} +11 -156
  7. package/bundle/{chunk-VQVVHSY6.js → chunk-DV2NCNPR.js} +22 -11
  8. package/bundle/{chunk-G2Z6ZH26.js → chunk-GCSLVFCX.js} +1 -1
  9. package/bundle/{chunk-2S4K53MV.js → chunk-H2NLFTC5.js} +1 -1
  10. package/bundle/{chunk-NKQ6JNAS.js → chunk-HFTBF7SG.js} +2 -1
  11. package/bundle/chunk-HXRB42AF.js +108 -0
  12. package/bundle/{chunk-7BWGNDNK.js → chunk-IQIWF2VX.js} +190 -1177
  13. package/bundle/{chunk-XDQORLZ5.js → chunk-JNXT3MPI.js} +15 -6
  14. package/bundle/{chunk-J5YL7LYR.js → chunk-JO67XSKD.js} +59 -27
  15. package/bundle/{chunk-JG4QKI5M.js → chunk-JWYG26RE.js} +209 -93
  16. package/bundle/{chunk-C5P5CHYK.js → chunk-KDMFBYFM.js} +1 -1
  17. package/bundle/{chunk-V2BZYLEP.js → chunk-KEY3UQMQ.js} +7 -2
  18. package/bundle/{chunk-NENDSQUY.js → chunk-KZ34KQQH.js} +9 -6
  19. package/bundle/{chunk-AKOIVLA5.js → chunk-L2ENOFVZ.js} +76 -58
  20. package/bundle/{chunk-CGN2TVE7.js → chunk-LGMILZNE.js} +322 -18
  21. package/bundle/{chunk-L3WFKBEI.js → chunk-LTPH2DXH.js} +247 -153
  22. package/bundle/{chunk-2D52JFLF.js → chunk-N7B2KD74.js} +41 -117
  23. package/bundle/{chunk-PV63UFUR.js → chunk-O7CPL6H4.js} +183 -28
  24. package/bundle/{chunk-D3JAFGMO.js → chunk-PHZP3KHB.js} +1 -1
  25. package/bundle/{chunk-2DHZTCOL.js → chunk-PVIVCDG2.js} +2 -2
  26. package/bundle/{chunk-LFDBD4PW.js → chunk-QO75KJBT.js} +2 -2
  27. package/bundle/{chunk-SSG7IEP5.js → chunk-RQAUNAWG.js} +2 -2
  28. package/bundle/{chunk-PALJGGYC.js → chunk-RV5OGHLO.js} +6 -3
  29. package/bundle/chunk-T5V5BRCL.js +1067 -0
  30. package/bundle/{chunk-LNRJCP2Y.js → chunk-UX4SCV5N.js} +337 -207
  31. package/bundle/{chunk-DZDETGRJ.js → chunk-WOVMHDES.js} +231 -182
  32. package/bundle/control-channel.js +2 -2
  33. package/bundle/index.js +1 -1
  34. package/bundle/intercom-bridge.js +2 -2
  35. package/bundle/preflight.js +8 -8
  36. package/bundle/project-panes.js +3 -3
  37. package/docs/agents.md +17 -2
  38. package/docs/configuration.md +2 -2
  39. package/docs/extension-api.md +16 -1
  40. package/docs/workflows.md +30 -2
  41. package/package.json +1 -1
  42. package/src/agents/agent-management.js +27 -11
  43. package/src/agents/agent-memory.d.ts +1 -4
  44. package/src/agents/agent-memory.js +1 -4
  45. package/src/agents/agents.d.ts +1 -3
  46. package/src/agents/agents.js +7 -6
  47. package/src/agents/frontmatter.js +1 -8
  48. package/src/agents/global-npm-root.d.ts +1 -0
  49. package/src/agents/global-npm-root.js +11 -3
  50. package/src/agents/skills.d.ts +0 -3
  51. package/src/agents/skills.js +0 -3
  52. package/src/extension/config.js +7 -1
  53. package/src/extension/herdr-pi-bridge.js +10 -2
  54. package/src/extension/index.d.ts +0 -13
  55. package/src/extension/index.js +43 -32
  56. package/src/extension/public-execution.d.ts +1 -0
  57. package/src/extension/public-execution.js +4 -0
  58. package/src/extension/reply-workflow-script.js +24 -4
  59. package/src/extension/schemas.d.ts +8 -3
  60. package/src/extension/schemas.js +5 -3
  61. package/src/extension/session-switch.d.ts +25 -0
  62. package/src/extension/session-switch.js +138 -0
  63. package/src/extension/subagent-guide.d.ts +1 -1
  64. package/src/extension/subagent-guide.js +1 -1
  65. package/src/extension/subagent-launch-tool.d.ts +25 -0
  66. package/src/extension/subagent-launch-tool.js +48 -0
  67. package/src/extension/tool-activation.js +25 -11
  68. package/src/extension/tool-description.js +6 -0
  69. package/src/inspectors/herdr/actions.d.ts +0 -1
  70. package/src/inspectors/herdr/actions.js +0 -1
  71. package/src/inspectors/session-roots-codec.d.ts +0 -1
  72. package/src/inspectors/session-roots-codec.js +0 -1
  73. package/src/inspectors/tmux/actions.d.ts +0 -1
  74. package/src/inspectors/tmux/actions.js +0 -1
  75. package/src/integrations/herdr-status.js +3 -8
  76. package/src/intercom/native-supervisor-channel.js +65 -9
  77. package/src/runs/background/async-execution.d.ts +5 -9
  78. package/src/runs/background/async-execution.js +62 -27
  79. package/src/runs/background/async-job-tracker.js +12 -0
  80. package/src/runs/background/async-resume.d.ts +2 -1
  81. package/src/runs/background/async-resume.js +112 -39
  82. package/src/runs/background/async-retention.js +6 -1
  83. package/src/runs/background/auto-drain.js +2 -1
  84. package/src/runs/background/boot-id.d.ts +1 -3
  85. package/src/runs/background/boot-id.js +1 -3
  86. package/src/runs/background/completion-batcher.d.ts +3 -4
  87. package/src/runs/background/completion-batcher.js +2 -3
  88. package/src/runs/background/control-channel.d.ts +0 -6
  89. package/src/runs/background/control-channel.js +0 -6
  90. package/src/runs/background/fleet-view.js +2 -3
  91. package/src/runs/background/notify.d.ts +0 -2
  92. package/src/runs/background/notify.js +0 -2
  93. package/src/runs/background/result-watcher.d.ts +1 -0
  94. package/src/runs/background/result-watcher.js +59 -29
  95. package/src/runs/background/resume-guidance.js +4 -2
  96. package/src/runs/background/retained-children.js +2 -1
  97. package/src/runs/background/run-child-session.d.ts +0 -1
  98. package/src/runs/background/run-child-session.js +1 -1
  99. package/src/runs/background/run-status.js +4 -3
  100. package/src/runs/background/scheduled-runs.d.ts +3 -1
  101. package/src/runs/background/scheduled-runs.js +13 -16
  102. package/src/runs/background/subagent-runner.d.ts +2 -4
  103. package/src/runs/background/subagent-runner.js +9 -6
  104. package/src/runs/background/subagent-wait.js +12 -15
  105. package/src/runs/background/wait-config.d.ts +2 -0
  106. package/src/runs/background/wait-config.js +17 -3
  107. package/src/runs/background/wait-tool.js +4 -2
  108. package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
  109. package/src/runs/background/workflow-terminal-proof.js +0 -1
  110. package/src/runs/foreground/execution.d.ts +0 -3
  111. package/src/runs/foreground/execution.js +17 -9
  112. package/src/runs/foreground/subagent-executor.d.ts +3 -2
  113. package/src/runs/foreground/subagent-executor.js +107 -26
  114. package/src/runs/shared/child-commands.js +15 -2
  115. package/src/runs/shared/child-hooks.d.ts +1 -7
  116. package/src/runs/shared/child-hooks.js +13 -5
  117. package/src/runs/shared/child-launch.js +6 -2
  118. package/src/runs/shared/child-runtime-config.d.ts +0 -1
  119. package/src/runs/shared/child-session.d.ts +1 -1
  120. package/src/runs/shared/child-session.js +21 -2
  121. package/src/runs/shared/child-tool-plan.d.ts +0 -1
  122. package/src/runs/shared/child-tool-plan.js +0 -1
  123. package/src/runs/shared/claude-code-adapter.js +11 -0
  124. package/src/runs/shared/external-cli-runner.js +26 -6
  125. package/src/runs/shared/herdr-connection.js +2 -1
  126. package/src/runs/shared/herdr-pane-host.d.ts +2 -2
  127. package/src/runs/shared/herdr-pane-host.js +17 -1
  128. package/src/runs/shared/herdr-placed-run.js +48 -22
  129. package/src/runs/shared/lane-metadata.d.ts +0 -1
  130. package/src/runs/shared/lane-metadata.js +0 -1
  131. package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
  132. package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
  133. package/src/runs/shared/model-resolution.d.ts +2 -2
  134. package/src/runs/shared/model-resolution.js +7 -1
  135. package/src/runs/shared/model-scope.d.ts +1 -5
  136. package/src/runs/shared/model-scope.js +1 -5
  137. package/src/runs/shared/mutation-evidence.d.ts +1 -1
  138. package/src/runs/shared/mutation-evidence.js +52 -7
  139. package/src/runs/shared/nested-events.d.ts +1 -0
  140. package/src/runs/shared/nested-events.js +1 -1
  141. package/src/runs/shared/parallel-utils.d.ts +0 -1
  142. package/src/runs/shared/permissions.js +5 -3
  143. package/src/runs/shared/placement-host.d.ts +5 -1
  144. package/src/runs/shared/rex-pane-host.d.ts +0 -1
  145. package/src/runs/shared/rex-pane-host.js +0 -2
  146. package/src/runs/shared/run-launch-folder.d.ts +12 -0
  147. package/src/runs/shared/run-launch-folder.js +21 -0
  148. package/src/runs/shared/runner-launcher.d.ts +12 -1
  149. package/src/runs/shared/runner-launcher.js +16 -0
  150. package/src/runs/shared/single-output.d.ts +3 -3
  151. package/src/runs/shared/single-output.js +5 -3
  152. package/src/runs/shared/structured-output.d.ts +8 -0
  153. package/src/runs/shared/structured-output.js +30 -2
  154. package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
  155. package/src/runs/shared/subagent-prompt-runtime.js +4 -2
  156. package/src/runs/shared/tool-timeout.js +2 -1
  157. package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
  158. package/src/runs/shared/worktree-cleanup-plan.js +0 -1
  159. package/src/runs/shared/worktree.d.ts +3 -0
  160. package/src/runs/shared/worktree.js +20 -0
  161. package/src/shared/capacity-resilient-json.d.ts +1 -1
  162. package/src/shared/child-cache-retention.d.ts +1 -2
  163. package/src/shared/child-cache-retention.js +1 -2
  164. package/src/shared/fleet-transcript-reader.d.ts +51 -0
  165. package/src/shared/fleet-transcript-reader.js +333 -0
  166. package/src/shared/formatters.d.ts +0 -18
  167. package/src/shared/formatters.js +0 -18
  168. package/src/shared/session-succession.d.ts +16 -1
  169. package/src/shared/session-succession.js +41 -2
  170. package/src/shared/session-warnings.d.ts +7 -0
  171. package/src/shared/session-warnings.js +26 -0
  172. package/src/shared/settings.d.ts +0 -23
  173. package/src/shared/settings.js +3 -35
  174. package/src/shared/types.d.ts +28 -11
  175. package/src/shared/types.js +0 -12
  176. package/src/shared/utils.d.ts +0 -14
  177. package/src/shared/utils.js +0 -22
  178. package/src/shared/wait-tool-name.d.ts +8 -0
  179. package/src/shared/wait-tool-name.js +13 -0
  180. package/src/slash/slash-commands.js +2 -1
  181. package/src/slash/subagent-cost.d.ts +3 -2
  182. package/src/slash/subagent-cost.js +22 -3
  183. package/src/slash/subagents-admin.js +0 -1
  184. package/src/tui/fleet-status.d.ts +0 -5
  185. package/src/tui/fleet-status.js +4 -24
  186. package/src/tui/fleet-transcript.d.ts +1 -44
  187. package/src/tui/fleet-transcript.js +1 -327
  188. package/src/tui/fleet.js +6 -4
  189. package/src/tui/render.d.ts +0 -9
  190. package/src/tui/render.js +81 -47
  191. package/src/tui/subagent-messages.js +3 -2
  192. package/src/watchdog/register-child.d.ts +2 -3
  193. package/src/watchdog/register-child.js +2 -3
  194. package/src/watchdog/turn-delta.js +2 -1
  195. package/src/workflows/scripted-workflow.js +241 -20
  196. package/src/workflows/workflow-launch-record.d.ts +15 -6
  197. package/src/workflows/workflow-launch-record.js +30 -12
  198. package/src/workflows/workflow-resume-claim.js +2 -2
  199. package/src/workflows/workflow-resume.d.ts +1 -1
  200. package/src/workflows/workflow-resume.js +11 -8
  201. package/src/workflows/workflow-script-worker.d.ts +13 -0
  202. package/src/workflows/workflow-script-worker.js +79 -0
  203. package/workflow-script-process.cjs +36 -0
  204. package/workflow-script-worker.cjs +4 -1
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-7F6RKT6W.js";
4
4
  import {
5
5
  getAgentDir
6
- } from "./chunk-LNRJCP2Y.js";
6
+ } from "./chunk-UX4SCV5N.js";
7
7
 
8
8
  // src/intercom/intercom-bridge.ts
9
9
  import * as fs from "node:fs";
@@ -7,7 +7,7 @@ import {
7
7
  getAgentDir,
8
8
  getConfigDirName,
9
9
  getProjectConfigDir
10
- } from "./chunk-LNRJCP2Y.js";
10
+ } from "./chunk-UX4SCV5N.js";
11
11
  import {
12
12
  TEMP_ROOT_DIR
13
13
  } from "./chunk-JEZOSEWG.js";
@@ -353,7 +353,12 @@ function readJson(filePath) {
353
353
  // src/runs/shared/mcp-direct-tool-grant.ts
354
354
  var BUILTIN_TOOL_NAMES = /* @__PURE__ */ new Set(["read", "bash", "edit", "write", "grep", "find", "ls", "mcp"]);
355
355
  function normalizeMcpDirectToolSelectors(selectors) {
356
- return [...new Set((selectors ?? []).map((selector) => selector.replace(/\/+$/, "")).filter(Boolean))];
356
+ return [...new Set((selectors ?? []).map(trimTrailingSlashes).filter(Boolean))];
357
+ }
358
+ function trimTrailingSlashes(selector) {
359
+ let end = selector.length;
360
+ while (end > 0 && selector[end - 1] === "/") end -= 1;
361
+ return selector.slice(0, end);
357
362
  }
358
363
  function parseMcpDirectToolSelectors(selectors) {
359
364
  const servers = /* @__PURE__ */ new Set();
@@ -7,13 +7,15 @@ import {
7
7
  formatNestedRunStatusLines,
8
8
  isStoppableAsyncStatusStep,
9
9
  listAsyncRuns,
10
- ownsRun,
11
10
  resolveAsyncStatusChild,
12
11
  stopStoppableAsyncStatusChildren,
13
12
  summarizeContextModes,
14
13
  utf8Tail,
15
14
  workflowPreflightLaneForRuntimeKey
16
- } from "./chunk-L3WFKBEI.js";
15
+ } from "./chunk-LTPH2DXH.js";
16
+ import {
17
+ ownsRun
18
+ } from "./chunk-HXRB42AF.js";
17
19
  import {
18
20
  assertSafeNestedId,
19
21
  checkRecordedPidLiveness,
@@ -32,11 +34,11 @@ import {
32
34
  updateActiveRunIndex,
33
35
  validateModelResponseAliases,
34
36
  writeAsyncResultFile
35
- } from "./chunk-CGN2TVE7.js";
37
+ } from "./chunk-LGMILZNE.js";
36
38
  import {
37
39
  deliverStopRequest,
38
40
  stopInboxClosedPath
39
- } from "./chunk-F4ASL6OV.js";
41
+ } from "./chunk-7MAE3DJV.js";
40
42
  import {
41
43
  SUBAGENT_STOPPED_MESSAGE,
42
44
  formatDuration,
@@ -45,9 +47,10 @@ import {
45
47
  readStatus,
46
48
  shortenPath,
47
49
  validateAcceptanceInput,
50
+ waitToolName,
48
51
  writeAtomicJson,
49
52
  writePrivateAtomicJson
50
- } from "./chunk-LNRJCP2Y.js";
53
+ } from "./chunk-UX4SCV5N.js";
51
54
  import {
52
55
  DIRS
53
56
  } from "./chunk-JEZOSEWG.js";
@@ -403,7 +406,7 @@ function formatDetachedForegroundFleetLines(runs) {
403
406
  const childSummary = detachedChildren.map((child) => `${fleetChildDisplayName(child)} #${child.index}`).join(", ");
404
407
  lines.push(`- ${run.runId} | detached | ${run.mode}${childSummary ? ` | ${childSummary}` : ""}`);
405
408
  lines.push(` status: subagent({ action: "status", id: "${run.runId}" })`);
406
- lines.push(` recovery: reply to the supervisor request first, then wait with bg_wait({ id: "${run.runId}" }); do not resume or launch a replacement while any child remains detached.`);
409
+ lines.push(` recovery: reply to the supervisor request first, then wait with ${waitToolName()}({ id: "${run.runId}" }); do not resume or launch a replacement while any child remains detached.`);
407
410
  }
408
411
  return lines;
409
412
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  buildWorkflowChatProgressRows
3
- } from "./chunk-NENDSQUY.js";
3
+ } from "./chunk-KZ34KQQH.js";
4
4
  import {
5
5
  aggregateStepStatus,
6
6
  contextModeBadge,
@@ -17,21 +17,23 @@ import {
17
17
  formatWorkflowPreflightPlanSummary,
18
18
  formatWorkflowPreflightWarningSummary,
19
19
  formatWorkflowPreflightWarnings,
20
- isStaleExtensionContextError,
21
- isUnboundExtensionRuntimeError,
22
- ownerSessionIds,
23
20
  projectAsyncStatusSnapshot,
24
21
  projectAsyncWorkflowRows,
25
22
  projectWorkflowChecklist,
26
- withCachedUiContext,
27
23
  workflowGraphStageNodes
28
- } from "./chunk-L3WFKBEI.js";
24
+ } from "./chunk-LTPH2DXH.js";
25
+ import {
26
+ isStaleExtensionContextError,
27
+ isUnboundExtensionRuntimeError,
28
+ ownerSessionIds,
29
+ reportSessionWarning
30
+ } from "./chunk-HXRB42AF.js";
29
31
  import {
30
32
  flatToLogicalStepIndex,
31
33
  formatWorkflowJsonPreview,
32
34
  hostStepReportName,
33
35
  hostStepVerdictLabel
34
- } from "./chunk-CGN2TVE7.js";
36
+ } from "./chunk-LGMILZNE.js";
35
37
  import {
36
38
  snapshotExternalRuns
37
39
  } from "./chunk-UKG4V45O.js";
@@ -49,7 +51,7 @@ import {
49
51
  getSingleResultOutput,
50
52
  shortenPath,
51
53
  unresolvedChildWatchdogBlockers
52
- } from "./chunk-LNRJCP2Y.js";
54
+ } from "./chunk-UX4SCV5N.js";
53
55
  import {
54
56
  MAX_WIDGET_JOBS,
55
57
  WIDGET_ANIMATION_INTERVAL_MS,
@@ -722,6 +724,22 @@ function visibleWorkflowRows(rows) {
722
724
  hiddenRows: rows.length - selected.size
723
725
  };
724
726
  }
727
+ function foldEarlierDoneLines(rows, cap, line, foldLine) {
728
+ if (rows.length <= cap) return rows.map(line);
729
+ const unfinished = rows.filter((row) => row.state !== "complete");
730
+ if (unfinished.length >= cap) return unfinished.map(line);
731
+ const hidden = rows.length - cap + 1;
732
+ const lines = [];
733
+ let skipped = 0;
734
+ for (const row of rows) {
735
+ if (skipped < hidden && row.state === "complete") {
736
+ if (++skipped === hidden) lines.push(foldLine(hidden));
737
+ continue;
738
+ }
739
+ lines.push(line(row));
740
+ }
741
+ return lines;
742
+ }
725
743
  function snapshotNowForProgress(progress) {
726
744
  if (progress.currentToolStartedAt !== void 0 && progress.durationMs !== void 0) return progress.currentToolStartedAt + progress.durationMs;
727
745
  return progress.lastActivityAt;
@@ -1155,6 +1173,7 @@ function workflowChecklistItemLine(item, theme, indent, frame, includeError) {
1155
1173
  return `${indent}${workflowChecklistGlyph(item, theme, frame)} ${theme.bold(identity || item.key)}${context}${state}${details ? ` ${theme.fg("dim", `\xB7 ${details}`)}` : ""}`;
1156
1174
  }
1157
1175
  var COLLAPSED_WORKFLOW_PHASE_LIMIT = 4;
1176
+ var EXPANDED_WIDGET_DONE_ITEMS = 4;
1158
1177
  function workflowChecklistWidgetLines(checklist, theme, indent, expanded, frame, options = {}) {
1159
1178
  if (!checklist?.total) return [];
1160
1179
  const includeSummary = options.includeSummary ?? true;
@@ -1162,6 +1181,11 @@ function workflowChecklistWidgetLines(checklist, theme, indent, expanded, frame,
1162
1181
  const includeBottleneckOutput = options.includeBottleneckOutput ?? expanded;
1163
1182
  const includeItemErrors = options.includeItemErrors ?? true;
1164
1183
  const lines = includeSummary ? [`${indent}${theme.fg("dim", `Checklist ${formatWorkflowChecklistSummary(checklist)}`)}`] : [];
1184
+ const bottleneck = formatWorkflowChecklistBottleneck(checklist.bottleneck, { includeOutput: includeBottleneckOutput, includeError: !expanded });
1185
+ const tone = checklist.bottleneck?.state === "blocked" || checklist.bottleneck?.state === "failed" ? "error" : checklist.bottleneck?.state === "running" ? "accent" : "warning";
1186
+ const bottleneckLine = bottleneck ? `${indent}${theme.fg(tone, `bottleneck \xB7 ${bottleneck}`)}` : void 0;
1187
+ const liveExpanded = expanded && options.liveWidget === true;
1188
+ if (liveExpanded && bottleneckLine) lines.push(bottleneckLine);
1165
1189
  const phases = !limitPhases || checklist.phases.length <= COLLAPSED_WORKFLOW_PHASE_LIMIT ? checklist.phases : checklist.phases.map((phase, index) => ({ phase, index })).sort((left, right) => Number(left.phase.state !== "running") - Number(right.phase.state !== "running") || Number(left.phase.state === "complete") - Number(right.phase.state === "complete") || left.index - right.index).slice(0, COLLAPSED_WORKFLOW_PHASE_LIMIT).sort((left, right) => left.index - right.index).map(({ phase }) => phase);
1166
1190
  for (const phase of phases) {
1167
1191
  const phaseItem = phase.items.find((item) => item.state === "running") ?? phase.items[0];
@@ -1174,16 +1198,13 @@ function workflowChecklistWidgetLines(checklist, theme, indent, expanded, frame,
1174
1198
  }, theme, frame);
1175
1199
  lines.push(`${indent}${glyph} ${theme.bold(formatWorkflowChecklistPhase(phase))}`);
1176
1200
  if (expanded) {
1177
- for (const item of [...phase.items].sort((left, right) => workflowChecklistItemPriority(left.state) - workflowChecklistItemPriority(right.state))) {
1178
- lines.push(workflowChecklistItemLine(item, theme, `${indent} `, frame, includeItemErrors || item.kind === "host"));
1179
- }
1201
+ const items = [...phase.items].sort((left, right) => workflowChecklistItemPriority(left.state) - workflowChecklistItemPriority(right.state));
1202
+ const line = (item) => workflowChecklistItemLine(item, theme, `${indent} `, frame, includeItemErrors || item.kind === "host");
1203
+ const cap = liveExpanded ? items.filter((item) => item.state !== "complete").length + EXPANDED_WIDGET_DONE_ITEMS + 1 : items.length;
1204
+ lines.push(...foldEarlierDoneLines(items, cap, line, (hidden) => `${indent} ${theme.fg("dim", `\u2026 ${hidden} earlier done`)}`));
1180
1205
  }
1181
1206
  }
1182
- const bottleneck = formatWorkflowChecklistBottleneck(checklist.bottleneck, { includeOutput: includeBottleneckOutput, includeError: !expanded });
1183
- if (bottleneck) {
1184
- const tone = checklist.bottleneck?.state === "blocked" || checklist.bottleneck?.state === "failed" ? "error" : checklist.bottleneck?.state === "running" ? "accent" : "warning";
1185
- lines.push(`${indent}${theme.fg(tone, `bottleneck \xB7 ${bottleneck}`)}`);
1186
- }
1207
+ if (!liveExpanded && bottleneckLine) lines.push(bottleneckLine);
1187
1208
  return lines;
1188
1209
  }
1189
1210
  function compactWorkflowLaneState(items) {
@@ -1349,20 +1370,21 @@ function compactWorkflowHeaderLine(job, theme, width) {
1349
1370
  if (width === void 0 || visibleWidth2(full) <= width) return full;
1350
1371
  return `${theme.fg("toolTitle", themeBold(theme, `async workflow ${label}`))} ${theme.fg("dim", "\xB7 background")}`;
1351
1372
  }
1352
- function compactWorkflowWidgetBodyLines(job, theme, frame, projection) {
1373
+ function compactWorkflowWidgetBodyLines(job, theme, frame, projection, lineBudget) {
1353
1374
  const rows = compactWorkflowLaneRows(job, projection.checklist);
1354
1375
  const lines = [` ${compactWorkflowStats(job, rows, theme, projection)}`];
1355
1376
  if (projection.inlineFleetCovered) return [...lines, ` ${theme.fg("dim", "Workflow children shown in Fleet roster")}`];
1377
+ const bottleneck = compactWorkflowBottleneck(rows, job);
1378
+ const hint = job.status === "running" || rows.some((row) => row.state === "running");
1356
1379
  if (rows.length) {
1357
- for (const row of rows) {
1358
- if (!projection.materializedKeys?.has(row.key)) lines.push(compactWorkflowLaneLine(row, theme, " ", frame));
1359
- }
1380
+ const shown = rows.filter((row) => !projection.materializedKeys?.has(row.key));
1381
+ const cap = lineBudget === void 0 ? shown.length : Math.max(1, lineBudget - lines.length - Number(Boolean(bottleneck)) - Number(hint));
1382
+ lines.push(...foldEarlierDoneLines(shown, cap, (row) => compactWorkflowLaneLine(row, theme, " ", frame), (hidden) => ` ${theme.fg("dim", `\u2026 ${hidden} earlier done`)}`));
1360
1383
  } else {
1361
1384
  lines.push(` ${theme.fg("dim", "\u25E6 waiting for workflow lanes")}`);
1362
1385
  }
1363
- const bottleneck = compactWorkflowBottleneck(rows, job);
1364
1386
  if (bottleneck) lines.push(` ${theme.fg(bottleneck.tone, `bottleneck \xB7 ${bottleneck.text}`)}`);
1365
- if (job.status === "running" || rows.some((row) => row.state === "running")) lines.push(` ${theme.fg("accent", workflowDetailHintText())}`);
1387
+ if (hint) lines.push(` ${theme.fg("accent", workflowDetailHintText())}`);
1366
1388
  return lines;
1367
1389
  }
1368
1390
  function widgetStepActivity(step, snapshotNow) {
@@ -2011,7 +2033,7 @@ function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projec
2011
2033
  const lane = projectAsyncLane(job, laneStepForJob(job, steps));
2012
2034
  return [
2013
2035
  ...expanded ? workflowPreflightLines(job) : [],
2014
- ...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame),
2036
+ ...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame, { liveWidget: true }),
2015
2037
  ...lane ? formatLaneProjectionLines(lane, theme, " ") : [],
2016
2038
  ...hostStepWidgetLines(job, theme, " "),
2017
2039
  ` ${theme.fg("dim", `\u23BF ${widgetActivity(job)}`)}`,
@@ -2021,7 +2043,7 @@ function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projec
2021
2043
  if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length) return widgetChainDetails(job, theme, expanded, width, frame);
2022
2044
  const lines = [
2023
2045
  ...expanded ? workflowPreflightLines(job) : [],
2024
- ...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame, { includeItemErrors: !expanded })
2046
+ ...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame, { includeItemErrors: !expanded, liveWidget: true })
2025
2047
  ];
2026
2048
  const group = activeParallelWidgetGroup(job);
2027
2049
  if (group) {
@@ -2048,8 +2070,8 @@ function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projec
2048
2070
  }
2049
2071
  return lines;
2050
2072
  }
2051
- function buildSingleWidgetLines(job, theme, width, expanded, frame, projection = buildWorkflowWidgetProjection(job)) {
2052
- if ((!expanded || projection.inlineFleetCovered) && job.mode === "workflow") return [compactWorkflowHeaderLine(job, theme, width), ...compactWorkflowWidgetBodyLines(job, theme, frame, projection)].map((line) => truncLine(line, width));
2073
+ function buildSingleWidgetLines(job, theme, width, expanded, frame, projection = buildWorkflowWidgetProjection(job), reservedLines = 0) {
2074
+ if ((!expanded || projection.inlineFleetCovered) && job.mode === "workflow") return [compactWorkflowHeaderLine(job, theme, width), ...compactWorkflowWidgetBodyLines(job, theme, frame, projection, widgetLineBudget(expanded) - 1 - reservedLines)].map((line) => truncLine(line, width));
2053
2075
  const stats = widgetStats(job, theme, projection, !expanded);
2054
2076
  const count = job.mode === "workflow" ? projection.checklist?.total ?? projection.stageProgress?.total ?? job.stepsTotal ?? job.agents?.length ?? job.steps?.length : job.mode === "chain" ? job.chainStepCount : projection.stageProgress?.total ?? job.stepsTotal ?? job.agents?.length ?? job.steps?.length;
2055
2077
  const mode = widgetJobName(job);
@@ -2283,9 +2305,9 @@ function buildProgressiveWidgetLines(jobs, theme, width, lockedRows, previousKey
2283
2305
  const laneRows = job.mode === "workflow" ? compactWorkflowLaneRows(job, projection.checklist) : void 0;
2284
2306
  lines.push(progressiveJobLine(job, theme, width, frame, projection, laneRows));
2285
2307
  if (!laneRows || projection.inlineFleetCovered) continue;
2286
- const shownLanes = laneRows.slice(0, Math.max(0, spareRows));
2287
- for (const row of shownLanes) lines.push(truncLine(compactWorkflowLaneLine(row, theme, " ", frame), width));
2288
- spareRows -= shownLanes.length;
2308
+ const laneLines = foldEarlierDoneLines(laneRows, spareRows, (row) => truncLine(compactWorkflowLaneLine(row, theme, " ", frame), width), (hidden) => truncLine(` ${theme.fg("dim", `\u2026 ${hidden} earlier done`)}`, width)).slice(0, spareRows);
2309
+ lines.push(...laneLines);
2310
+ spareRows -= laneLines.length;
2289
2311
  }
2290
2312
  if (hiddenJobs.length > 0 && lines.length < rowCount) lines.push(progressiveHiddenLine(hiddenJobs, theme, width));
2291
2313
  const contentRows = Math.min(lines.length, rowCount);
@@ -2300,9 +2322,12 @@ function paddedWidgetLine(line, width) {
2300
2322
  const text = ` ${truncLine(line, width - 2)} `;
2301
2323
  return `${text}${" ".repeat(Math.max(0, width - visibleWidth2(text)))}`;
2302
2324
  }
2325
+ function widgetLineBudget(expanded) {
2326
+ const rows = currentTerminalRows();
2327
+ return expanded ? Math.max(12, Math.min(24, Math.floor(rows * 0.55))) : collapsedWidgetLineBudget(rows);
2328
+ }
2303
2329
  function fitWidgetLineBudget(lines, theme, width, expanded) {
2304
- const rows = process.stdout.rows || 30;
2305
- const budget = expanded ? Math.max(12, Math.min(24, Math.floor(rows * 0.55))) : collapsedWidgetLineBudget(rows);
2330
+ const budget = widgetLineBudget(expanded);
2306
2331
  if (lines.length <= budget) return lines;
2307
2332
  const visibleLines = Math.max(1, budget - 1);
2308
2333
  const hiddenCount = lines.length - visibleLines;
@@ -2514,10 +2539,10 @@ function buildWidgetComponent(jobs, ui, initiallyCollapsed = false, layout) {
2514
2539
  }
2515
2540
  function buildWidgetLinesWithProjection(jobs, theme, width = getTermWidth(), expanded = false, frame, projectionFor = workflowWidgetProjectionLookup()) {
2516
2541
  if (jobs.length === 0) return [];
2517
- if (jobs.length === 1) return [
2518
- ...buildSingleWidgetLines(jobs[0], theme, width, expanded, frame, projectionFor(jobs[0])),
2519
- ...materializedWidgetChildLines(jobs[0], theme, width, expanded, frame, projectionFor).map((line) => truncLine(line, width))
2520
- ];
2542
+ if (jobs.length === 1) {
2543
+ const childLines = materializedWidgetChildLines(jobs[0], theme, width, expanded, frame, projectionFor).map((line) => truncLine(line, width));
2544
+ return [...buildSingleWidgetLines(jobs[0], theme, width, expanded, frame, projectionFor(jobs[0]), childLines.length), ...childLines];
2545
+ }
2521
2546
  const running = jobs.filter((job) => job.status === "running");
2522
2547
  const queued = jobs.filter((job) => job.status === "queued");
2523
2548
  const finished = jobs.filter((job) => job.status !== "running" && job.status !== "queued");
@@ -2531,23 +2556,24 @@ function buildWidgetLinesWithProjection(jobs, theme, width = getTermWidth(), exp
2531
2556
  let hiddenFinished = 0;
2532
2557
  let queuedSummaryShown = false;
2533
2558
  let slots = MAX_WIDGET_JOBS;
2559
+ const compactCards = [];
2534
2560
  const appendJob = (job) => {
2535
2561
  const projection = projectionFor(job);
2536
2562
  const compactWorkflow = (!expanded || projection.inlineFleetCovered) && job.mode === "workflow";
2537
2563
  const stats = compactWorkflow ? "" : widgetStats(job, theme, projection, !expanded);
2538
- const details = compactWorkflow ? [
2539
- ...compactWorkflowWidgetBodyLines(job, theme, frame, projection)
2540
- ] : [
2564
+ const details = compactWorkflow ? compactWorkflowWidgetBodyLines(job, theme, frame, projection) : [
2541
2565
  ` ${theme.fg("dim", `\u23BF ${widgetActivity(job)}`)}`,
2542
2566
  ...widgetLaneDetailLines(job, theme, projection),
2543
- ...workflowChecklistWidgetLines(widgetChecklistWithoutMaterializedChildren(projection), theme, " ", expanded, frame, { includeItemErrors: !expanded || !job.steps?.length }),
2567
+ ...workflowChecklistWidgetLines(widgetChecklistWithoutMaterializedChildren(projection), theme, " ", expanded, frame, { includeItemErrors: !expanded || !job.steps?.length, liveWidget: true }),
2544
2568
  ...widgetParallelAgentDetails(job, theme, expanded, width, frame)
2545
2569
  ];
2546
- items.push([
2570
+ const item = [
2547
2571
  compactWorkflow ? compactWorkflowHeaderLine(job, theme, width) : `${widgetStatusGlyph(job, theme, frame)} ${themeBold(theme, widgetJobName(job))}${contextModeBadge(theme, job.context)}${stats ? ` ${theme.fg("dim", "\xB7")} ${stats}` : ""}`,
2548
2572
  ...details,
2549
2573
  ...materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor)
2550
- ]);
2574
+ ];
2575
+ items.push(item);
2576
+ if (compactWorkflow) compactCards.push({ item, job, projection, bodyLength: details.length });
2551
2577
  };
2552
2578
  for (const job of running) {
2553
2579
  if (slots <= 0) {
@@ -2579,6 +2605,13 @@ function buildWidgetLinesWithProjection(jobs, theme, width = getTermWidth(), exp
2579
2605
  if (hiddenFinished > 0) parts.push(`${hiddenFinished} finished`);
2580
2606
  items.push([theme.fg("dim", `+${hiddenTotal} more (${parts.join(", ")})`)]);
2581
2607
  }
2608
+ let overflow = 1 + items.reduce((sum, item) => sum + item.length, 0) - widgetLineBudget(expanded);
2609
+ for (const card of compactCards) {
2610
+ if (overflow <= 0) break;
2611
+ const body = compactWorkflowWidgetBodyLines(card.job, theme, frame, card.projection, card.bodyLength - overflow);
2612
+ card.item.splice(1, card.bodyLength, ...body);
2613
+ overflow -= card.bodyLength - body.length;
2614
+ }
2582
2615
  for (let i = 0; i < items.length; i++) {
2583
2616
  const item = items[i];
2584
2617
  const last = i === items.length - 1;
@@ -3462,20 +3495,6 @@ function projectPaneEntries(state) {
3462
3495
  projectPane: pane
3463
3496
  }));
3464
3497
  }
3465
- var reportedFleetWarnings = /* @__PURE__ */ new Set();
3466
- function reportFleetWarning(state, message) {
3467
- if (reportedFleetWarnings.has(message)) return;
3468
- reportedFleetWarnings.add(message);
3469
- const text = `[pi-subagents] ${message}`;
3470
- const cached = state.lastUiContext;
3471
- const notified = withCachedUiContext(cached, () => {
3472
- if (state.lastUiContext === cached) state.lastUiContext = null;
3473
- }, (ctx) => {
3474
- ctx.ui.notify(text, "warning");
3475
- return true;
3476
- });
3477
- if (!notified) console.warn(text);
3478
- }
3479
3498
  function collectFleetStatusEntries(state) {
3480
3499
  const now = Date.now();
3481
3500
  const entries = [];
@@ -3604,7 +3623,7 @@ function collectFleetStatusEntries(state) {
3604
3623
  }
3605
3624
  if (state.currentSessionId) {
3606
3625
  try {
3607
- for (const run of snapshotExternalRuns(state.currentSessionId, { ignoreMalformed: true, onMalformedRecord: (message) => reportFleetWarning(state, `Removed ${message}`) })) {
3626
+ for (const run of snapshotExternalRuns(state.currentSessionId, { ignoreMalformed: true, onMalformedRecord: (message) => reportSessionWarning(state, `Removed ${message}`) })) {
3608
3627
  if (!isActiveState(run.state)) continue;
3609
3628
  entries.push({
3610
3629
  key: `external:${run.id}`,
@@ -3617,7 +3636,7 @@ function collectFleetStatusEntries(state) {
3617
3636
  });
3618
3637
  }
3619
3638
  } catch (cause) {
3620
- reportFleetWarning(state, `Failed to inspect external jobs: ${cause instanceof Error ? cause.message : String(cause)}`);
3639
+ reportSessionWarning(state, `Failed to inspect external jobs: ${cause instanceof Error ? cause.message : String(cause)}`);
3621
3640
  }
3622
3641
  }
3623
3642
  entries.push(...projectPaneEntries(state));
@@ -4159,6 +4178,5 @@ export {
4159
4178
  renderSubagentResult,
4160
4179
  FLEET_STATUS_WIDGET_KEY,
4161
4180
  resolveFleetViewPlacement,
4162
- reportFleetWarning,
4163
4181
  SubagentFleetStatus
4164
4182
  };