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
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  resolveWatchPath,
6
6
  writeAtomicJson
7
- } from "./chunk-LNRJCP2Y.js";
7
+ } from "./chunk-UX4SCV5N.js";
8
8
  import {
9
9
  POLL_INTERVAL_MS
10
10
  } from "./chunk-JEZOSEWG.js";
@@ -1,13 +1,15 @@
1
1
  import {
2
2
  isTrustedRecordedSessionFile,
3
3
  resolveSubagentRunId
4
- } from "./chunk-NENDSQUY.js";
4
+ } from "./chunk-KZ34KQQH.js";
5
5
  import {
6
6
  agentStreamOptions,
7
7
  opencodeSessionHeaders,
8
- ownsRun,
9
8
  resolveAsyncResumeTarget
10
- } from "./chunk-L3WFKBEI.js";
9
+ } from "./chunk-LTPH2DXH.js";
10
+ import {
11
+ ownsRun
12
+ } from "./chunk-HXRB42AF.js";
11
13
  import {
12
14
  currentCompletionOwnerId,
13
15
  listMissions,
@@ -16,12 +18,12 @@ import {
16
18
  reconcileAsyncRun,
17
19
  resolveAuthorityDecision,
18
20
  resolveMissionStoreLocation
19
- } from "./chunk-CGN2TVE7.js";
21
+ } from "./chunk-LGMILZNE.js";
20
22
  import {
21
23
  deliverInterruptRequest,
22
24
  queueRevivalBrief,
23
25
  requestAsyncSteer
24
- } from "./chunk-F4ASL6OV.js";
26
+ } from "./chunk-7MAE3DJV.js";
25
27
  import {
26
28
  formatShellCommand
27
29
  } from "./chunk-7J4ZXMY7.js";
@@ -32,7 +34,7 @@ import {
32
34
  tryLease,
33
35
  writeAtomicJson,
34
36
  writePrivateAtomicJson
35
- } from "./chunk-LNRJCP2Y.js";
37
+ } from "./chunk-UX4SCV5N.js";
36
38
  import {
37
39
  DIRS
38
40
  } from "./chunk-JEZOSEWG.js";
@@ -603,15 +605,12 @@ async function steerWorkflowForegroundTarget(input) {
603
605
  return { content: [{ type: "text", text: steeringReceipt(message, `Steering failed for foreground run ${control.runId} (request ${requestId}): ${outcome.reason ?? "unknown error"}`) }], isError: true, details: { mode: "management", results: [], steering } };
604
606
  }
605
607
 
606
- // src/tui/fleet-transcript.ts
608
+ // src/shared/fleet-transcript-reader.ts
607
609
  import * as fs3 from "node:fs";
608
610
  import * as path4 from "node:path";
609
- import { getLanguageFromPath, highlightCode } from "@earendil-works/pi-coding-agent";
610
- import { Markdown, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
611
611
  var DEFAULT_MAX_RECORDS = 240;
612
612
  var DEFAULT_MAX_BYTES = 2 * 1024 * 1024;
613
613
  var MAX_MESSAGE_CHARS = 64 * 1024;
614
- var TOOL_PREVIEW_LINES = 7;
615
614
  function sanitizeJsonDisplayValue(value) {
616
615
  if (typeof value === "string") {
617
616
  const safe = safeTerminalText(value);
@@ -895,151 +894,6 @@ function readFleetTranscript(filePath, options) {
895
894
  ...warnings.length ? { warning: safeTerminalText(warnings.join(" ")) } : {}
896
895
  };
897
896
  }
898
- function statusGlyph(event, theme) {
899
- if (event.status === "running") return theme.fg("warning", "\u25CF");
900
- if (event.status === "error") return theme.fg("error", "\u2717");
901
- return theme.fg("success", "\u2713");
902
- }
903
- function jsonScalar(value) {
904
- if (typeof value === "string" && value.trim()) return value;
905
- if (typeof value === "number" || typeof value === "boolean") return String(value);
906
- return void 0;
907
- }
908
- function parseToolArgs(event) {
909
- if (!event.argsPayload) return void 0;
910
- try {
911
- return objectValue(JSON.parse(event.argsPayload));
912
- } catch {
913
- return void 0;
914
- }
915
- }
916
- function toolDuration(event) {
917
- if (event.startedAt === void 0 || event.endedAt === void 0) return void 0;
918
- return `${((event.endedAt - event.startedAt) / 1e3).toFixed(1)}s`;
919
- }
920
- function renderExpandedTool(event, width, theme) {
921
- const lines = [];
922
- const args = parseToolArgs(event);
923
- const glyph = statusGlyph(event, theme);
924
- const output = event.output ?? event.error;
925
- const outputColor = event.status === "error" ? "error" : "toolOutput";
926
- if (event.name === "bash") {
927
- const command = jsonScalar(args?.command) ?? event.args ?? "(unknown command)";
928
- lines.push(railLine(`${glyph} ${theme.fg("toolTitle", theme.bold(`$ ${command}`))}`, width, theme));
929
- if (output) {
930
- for (const outputLine of output.replace(/\s+$/, "").split(/\r?\n/)) {
931
- for (const wrapped of renderWrapped(theme.fg(outputColor, outputLine), Math.max(1, width - 4))) {
932
- lines.push(railLine(` ${wrapped}`, width, theme));
933
- }
934
- }
935
- }
936
- const duration = toolDuration(event);
937
- if (duration) lines.push(railLine(theme.fg("dim", ` Took ${duration}`), width, theme));
938
- return lines;
939
- }
940
- if (event.name === "read") {
941
- const filePath = jsonScalar(args?.path ?? args?.file_path);
942
- const language = filePath ? getLanguageFromPath(filePath) : void 0;
943
- const rendered = !output ? [] : event.status === "error" ? output.split("\n").map((line) => theme.fg("error", line)) : language ? highlightCode(output, language) : output.split("\n");
944
- lines.push(railLine(`${glyph} ${theme.fg("toolTitle", theme.bold(`read ${filePath ?? event.args ?? ""}`))}`, width, theme));
945
- for (const line of rendered) {
946
- for (const wrapped of renderWrapped(line, Math.max(1, width - 4))) lines.push(railLine(` ${wrapped}`, width, theme));
947
- }
948
- return lines;
949
- }
950
- lines.push(railLine(`${glyph} ${theme.fg("toolTitle", theme.bold(event.name))}`, width, theme));
951
- if (event.argsPayload) {
952
- lines.push(railLine(theme.fg("dim", " args"), width, theme));
953
- for (const argLine of event.argsPayload.split(/\r?\n/)) {
954
- for (const wrapped of renderWrapped(theme.fg("muted", argLine), Math.max(1, width - 4))) lines.push(railLine(` ${wrapped}`, width, theme));
955
- }
956
- }
957
- if (output) {
958
- lines.push(railLine(theme.fg(event.status === "error" ? "error" : "dim", event.status === "error" ? " error" : " output"), width, theme));
959
- for (const outputLine of output.split(/\r?\n/)) {
960
- for (const wrapped of renderWrapped(theme.fg(outputColor, outputLine), Math.max(1, width - 4))) lines.push(railLine(` ${wrapped}`, width, theme));
961
- }
962
- }
963
- return lines;
964
- }
965
- function bounded(text, width) {
966
- return truncateToWidth(text, Math.max(0, width));
967
- }
968
- function railLine(content, width, theme) {
969
- return bounded(`${theme.fg("borderMuted", "\u2502")} ${content}`, width);
970
- }
971
- function renderWrapped(text, width) {
972
- return wrapTextWithAnsi(text, Math.max(1, width));
973
- }
974
- function renderFleetTranscript(transcript, width, theme, markdownTheme, options = {}) {
975
- if (width <= 0) return [];
976
- const lines = [];
977
- if (transcript.truncated) lines.push(bounded(theme.fg("dim", "\u2191 Earlier activity omitted"), width));
978
- if (transcript.warning) {
979
- for (const line of renderWrapped(safeTerminalText(transcript.warning), Math.max(1, width - 2))) {
980
- lines.push(bounded(`${theme.fg("warning", "!")} ${theme.fg("warning", line)}`, width));
981
- }
982
- }
983
- for (const rawEvent of transcript.events) {
984
- const event = safeTranscriptEvent(rawEvent);
985
- if (event.kind === "tool") {
986
- if (options.expandedTools && (event.output || event.argsPayload || event.error)) {
987
- lines.push(...renderExpandedTool(event, width, theme));
988
- lines.push(railLine(theme.fg("dim", " x to collapse"), width, theme));
989
- continue;
990
- }
991
- const title = theme.fg("toolTitle", theme.bold(event.name));
992
- const args = event.args ? ` ${theme.fg("dim", event.args)}` : "";
993
- const suffix = event.status === "running" ? theme.fg("warning", " running") : "";
994
- lines.push(bounded(`${theme.fg("borderMuted", "\u251C\u2500")} ${statusGlyph(event, theme)} ${title}${args}${suffix}`, width));
995
- if (event.output && event.status !== "error" && event.name === "bash") {
996
- const outputLines = event.output.replace(/\s+$/, "").split(/\r?\n/);
997
- const visible = outputLines.slice(-TOOL_PREVIEW_LINES);
998
- const hidden = Math.max(0, outputLines.length - visible.length);
999
- for (const outputLine of visible) {
1000
- for (const wrapped of renderWrapped(theme.fg("toolOutput", outputLine), Math.max(1, width - 4))) {
1001
- lines.push(railLine(` ${wrapped}`, width, theme));
1002
- }
1003
- }
1004
- if (hidden > 0) lines.push(railLine(theme.fg("dim", ` \u2026 ${hidden} earlier lines \xB7 x to expand`), width, theme));
1005
- const duration = toolDuration(event);
1006
- lines.push(railLine(theme.fg("dim", ` Took${duration ? ` ${duration}` : ""}`), width, theme));
1007
- } else if (event.output && event.status !== "error") {
1008
- const summary = truncateToWidth(event.output.replace(/\s+/g, " ").trim(), Math.max(1, width - 18), "\u2026");
1009
- if (summary) lines.push(railLine(theme.fg("dim", ` ${summary} \xB7 x to expand`), width, theme));
1010
- }
1011
- if (event.error) {
1012
- for (const errorLine of renderWrapped(event.error, Math.max(1, width - 4))) {
1013
- lines.push(railLine(theme.fg("error", ` ${errorLine}`), width, theme));
1014
- }
1015
- }
1016
- continue;
1017
- }
1018
- if (event.kind === "notice") {
1019
- const color = event.tone === "error" ? "error" : event.tone === "warning" ? "warning" : "dim";
1020
- for (const noticeLine of renderWrapped(event.text, Math.max(1, width - 2))) {
1021
- lines.push(railLine(theme.fg(color, noticeLine), width, theme));
1022
- }
1023
- continue;
1024
- }
1025
- const assistant = event.kind === "assistant";
1026
- const label = assistant ? "Assistant" : "Supervisor";
1027
- const marker = assistant ? theme.fg("accent", "\u25C6") : theme.fg("warning", "\u25C7");
1028
- const model = assistant && event.model ? theme.fg("dim", ` \xB7 ${event.model}`) : "";
1029
- lines.push(bounded(`${marker} ${theme.bold(label)}${model}`, width));
1030
- if (assistant) {
1031
- const rendered = new Markdown(event.text, 0, 0, markdownTheme).render(Math.max(1, width - 2));
1032
- for (const markdownLine of rendered) lines.push(railLine(markdownLine, width, theme));
1033
- } else {
1034
- for (const userLine of renderWrapped(event.text, Math.max(1, width - 2))) {
1035
- lines.push(railLine(userLine, width, theme));
1036
- }
1037
- }
1038
- lines.push(theme.fg("borderMuted", "\u2502"));
1039
- }
1040
- while (lines.length > 0 && visibleWidth(lines.at(-1) ?? "") === 1) lines.pop();
1041
- return lines;
1042
- }
1043
897
 
1044
898
  // src/inspectors/types.ts
1045
899
  var INSPECTOR_ACTIONS = ["inspector.open", "inspector.command", "inspector.status", "inspector.close"];
@@ -1325,8 +1179,9 @@ export {
1325
1179
  resolveWorkflowForegroundSteeringTarget,
1326
1180
  steerWorkflowRun,
1327
1181
  steerWorkflowForegroundTarget,
1182
+ objectValue,
1183
+ safeTranscriptEvent,
1328
1184
  readFleetTranscript,
1329
- renderFleetTranscript,
1330
1185
  INSPECTOR_ACTIONS,
1331
1186
  handleInspectorAction,
1332
1187
  rewritePromptWithGuidance,
@@ -1,26 +1,32 @@
1
1
  import {
2
2
  rewriteSubagentPrompt
3
- } from "./chunk-XDQORLZ5.js";
3
+ } from "./chunk-JNXT3MPI.js";
4
4
  import {
5
5
  package_default
6
- } from "./chunk-NKQ6JNAS.js";
7
- import "./chunk-7BWGNDNK.js";
6
+ } from "./chunk-HFTBF7SG.js";
7
+ import {
8
+ WATCHDOG_DIFF_TOOL_NAME,
9
+ captureWatchdogDiffBaseline,
10
+ createWatchdogDiffTool
11
+ } from "./chunk-IQIWF2VX.js";
12
+ import "./chunk-LTPH2DXH.js";
13
+ import "./chunk-T5V5BRCL.js";
8
14
  import {
9
15
  MODEL_ONLY_TOOL
10
- } from "./chunk-L3WFKBEI.js";
16
+ } from "./chunk-HXRB42AF.js";
11
17
  import "./chunk-NF7IEKBH.js";
12
18
  import {
13
19
  appendAgentRefinementOverlay
14
- } from "./chunk-LFDBD4PW.js";
15
- import "./chunk-CGN2TVE7.js";
20
+ } from "./chunk-QO75KJBT.js";
21
+ import "./chunk-LGMILZNE.js";
16
22
  import "./chunk-NIXWDZZV.js";
17
- import "./chunk-C5P5CHYK.js";
23
+ import "./chunk-KDMFBYFM.js";
18
24
  import "./chunk-7F6RKT6W.js";
19
25
  import {
20
26
  assertNoToolModifierEntries
21
- } from "./chunk-V2BZYLEP.js";
27
+ } from "./chunk-KEY3UQMQ.js";
22
28
  import "./chunk-CTPAE36Y.js";
23
- import "./chunk-D3JAFGMO.js";
29
+ import "./chunk-PHZP3KHB.js";
24
30
  import {
25
31
  HERDR_PI_MAX_FRAME_BYTES,
26
32
  HERDR_PI_PROTOCOL,
@@ -37,7 +43,7 @@ import {
37
43
  discoverAgents,
38
44
  resolveExistingReadPaths,
39
45
  resolveSkills
40
- } from "./chunk-LNRJCP2Y.js";
46
+ } from "./chunk-UX4SCV5N.js";
41
47
  import "./chunk-JEZOSEWG.js";
42
48
  import "./chunk-YFCK7H2S.js";
43
49
  import "./chunk-QXASAHIA.js";
@@ -240,9 +246,11 @@ ${resolvedSystemPrompt}` } : void 0;
240
246
  const resolved = resolveRemoteHerdrResources(process.cwd(), { agent: resources.agent, ...resources.skills ? { skills: resources.skills } : {}, ...resources.toolCeiling ? { toolCeiling: resources.toolCeiling } : {}, ...resources.reads !== void 0 ? { reads: resources.reads } : {} }, context ? pi.getActiveTools() : []);
241
247
  resolvedSystemPrompt = resolved.systemPrompt;
242
248
  resolvedContextPolicy = resolved;
249
+ if (resolved.tools.includes(WATCHDOG_DIFF_TOOL_NAME) && !pi.getAllTools().some((tool) => tool.name === WATCHDOG_DIFF_TOOL_NAME)) pi.registerTool(createWatchdogDiffTool(captureWatchdogDiffBaseline(process.cwd()), { workingTreeAtLaunch: true }));
243
250
  pi.setActiveTools(resolved.tools);
244
251
  const acknowledged = context ? pi.getActiveTools() : [];
245
- if (acknowledged.some((tool) => !resolved.tools.includes(tool)) || resolved.tools.some((tool) => !acknowledged.includes(tool))) throw new Error("Remote Pi did not apply the resolved active-tool set exactly.");
252
+ const missing = resolved.tools.filter((tool) => !acknowledged.includes(tool)), extra = acknowledged.filter((tool) => !resolved.tools.includes(tool));
253
+ if (missing.length || extra.length) throw new Error(`Remote Pi did not apply the resolved active-tool set exactly (${[...missing.length ? [`not available: ${missing.join(", ")}`] : [], ...extra.length ? [`unexpected: ${extra.join(", ")}`] : []].join("; ")}).`);
246
254
  configured = true;
247
255
  send({ type: "configured", requestId: frame.requestId, nativeSessionId, agent: resolved.agent, skills: resolved.skills, model: context?.model?.provider && context.model.id ? `${context.model.provider}/${context.model.id}` : void 0, tools: acknowledged });
248
256
  continue;
@@ -258,9 +266,12 @@ ${resolvedSystemPrompt}` } : void 0;
258
266
  send({ type: "prepared", requestId: frame.requestId, nativeSessionId });
259
267
  }
260
268
  } catch (error) {
269
+ context?.ui?.notify(`pi-subagents bridge: ${error.message}`, "error");
261
270
  socket.destroy(error);
262
271
  }
263
272
  });
273
+ socket.on("error", () => {
274
+ });
264
275
  socket.on("close", () => {
265
276
  if (client === socket) client = void 0;
266
277
  });
@@ -8,7 +8,7 @@ import {
8
8
  validateCodeOwnedProfileRunner,
9
9
  validatePermissionRules,
10
10
  validateToolBudgetConfig
11
- } from "./chunk-LNRJCP2Y.js";
11
+ } from "./chunk-UX4SCV5N.js";
12
12
 
13
13
  // src/agents/runtime-agent-registry.ts
14
14
  var RUNTIME_AGENT_REGISTRY_KEY = "pi-subagents.runtime-agents.v1";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  registerRuntimeAgent
3
- } from "./chunk-G2Z6ZH26.js";
3
+ } from "./chunk-GCSLVFCX.js";
4
4
 
5
5
  // src/agents/runtime-agent-events.ts
6
6
  var RUNTIME_AGENT_REGISTER_EVENT = "pi-subagents:runtime-agent-register:v1";
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "pi-subagents",
4
- version: "0.84.0",
4
+ version: "0.85.0",
5
5
  private: true,
6
6
  description: "Pi extension for single-agent delegation and scripted multi-agent workflows",
7
7
  author: "Nico Bailon",
@@ -51,6 +51,7 @@ var package_default = {
51
51
  "src/**/*.ts",
52
52
  "*.mjs",
53
53
  "workflow-script-worker.cjs",
54
+ "workflow-script-process.cjs",
54
55
  "agents/",
55
56
  "skills/**/*",
56
57
  "prompts/**/*",
@@ -0,0 +1,108 @@
1
+ // src/shared/session-succession.ts
2
+ var SUCCESSION_KEY = /* @__PURE__ */ Symbol.for("pi-subagents.session-succession");
3
+ var MAX_INHERITED_SESSIONS = 8;
4
+ var MAX_RECORDED_SESSIONS = 64;
5
+ var KEPT_WORK_KEY = /* @__PURE__ */ Symbol.for("pi-subagents.sessions-keeping-work");
6
+ function successions() {
7
+ const runtime = globalThis;
8
+ runtime[SUCCESSION_KEY] ??= /* @__PURE__ */ new Map();
9
+ return runtime[SUCCESSION_KEY];
10
+ }
11
+ function keptWork() {
12
+ const runtime = globalThis;
13
+ runtime[KEPT_WORK_KEY] ??= /* @__PURE__ */ new Set();
14
+ return runtime[KEPT_WORK_KEY];
15
+ }
16
+ function keepSessionWork(sessionId) {
17
+ keptWork().delete(sessionId);
18
+ keptWork().add(sessionId);
19
+ while (keptWork().size > MAX_RECORDED_SESSIONS) keptWork().delete(keptWork().values().next().value);
20
+ }
21
+ function releaseSessionWork(sessionId) {
22
+ keptWork().delete(sessionId);
23
+ }
24
+ function recordSessionReplacement(sessionId, previousSessionId) {
25
+ const inherited = keptWork().has(previousSessionId) ? [] : [previousSessionId, ...successions().get(previousSessionId) ?? []];
26
+ const own = keptWork().has(sessionId) ? successions().get(sessionId) ?? [] : [];
27
+ const chain = [.../* @__PURE__ */ new Set([...inherited, ...own])].filter((id) => id !== sessionId);
28
+ successions().delete(sessionId);
29
+ successions().set(sessionId, chain.slice(0, MAX_INHERITED_SESSIONS));
30
+ while (successions().size > MAX_RECORDED_SESSIONS) successions().delete(successions().keys().next().value);
31
+ }
32
+ function recordSessionStart(sessionId, startup) {
33
+ if (startup) {
34
+ successions().delete(sessionId);
35
+ keptWork().delete(sessionId);
36
+ }
37
+ for (const [id, chain] of successions()) {
38
+ if (chain.includes(sessionId)) successions().set(id, chain.filter((inherited) => inherited !== sessionId));
39
+ }
40
+ }
41
+ function inheritedSessionIds(sessionId) {
42
+ return successions().get(sessionId) ?? [];
43
+ }
44
+
45
+ // src/shared/extension-context.ts
46
+ var MODEL_ONLY_TOOL = { exposure: "model-only" };
47
+ function isStaleExtensionContextError(error) {
48
+ return error instanceof Error && /extension ctx is stale|extension context no longer active|stale after session replacement or reload/i.test(error.message);
49
+ }
50
+ function canRenderComponents(ctx) {
51
+ return ctx.mode === "tui" || process.env.PI_SUBAGENTS_COMPONENT_UI === "1";
52
+ }
53
+ function isUnboundExtensionRuntimeError(error) {
54
+ return error instanceof Error && /extension runtime not initialized/i.test(error.message);
55
+ }
56
+ function withCachedUiContext(ctx, onStale, run) {
57
+ if (!ctx) return void 0;
58
+ try {
59
+ if (!ctx.hasUI) return void 0;
60
+ return run(ctx);
61
+ } catch (error) {
62
+ if (!isStaleExtensionContextError(error)) throw error;
63
+ onStale();
64
+ return void 0;
65
+ }
66
+ }
67
+
68
+ // src/shared/session-warnings.ts
69
+ var reportedWarnings = /* @__PURE__ */ new WeakMap();
70
+ function reportSessionWarning(state, message, key = message) {
71
+ let reported = reportedWarnings.get(state);
72
+ if (!reported) reportedWarnings.set(state, reported = /* @__PURE__ */ new Set());
73
+ if (reported.has(key)) return;
74
+ reported.add(key);
75
+ const text = `[pi-subagents] ${message}`;
76
+ const cached = state.lastUiContext;
77
+ const notified = withCachedUiContext(cached, () => {
78
+ if (state.lastUiContext === cached) state.lastUiContext = null;
79
+ }, (ctx) => {
80
+ ctx.ui.notify(text, "warning");
81
+ return true;
82
+ });
83
+ if (!notified) console.warn(text);
84
+ }
85
+
86
+ // src/runs/shared/run-ownership.ts
87
+ function ownerSessionIds(sessionId) {
88
+ return /* @__PURE__ */ new Set([sessionId, ...inheritedSessionIds(sessionId)]);
89
+ }
90
+ function ownsRun(currentSessionId, runSessionId) {
91
+ return currentSessionId ? ownerSessionIds(currentSessionId).has(runSessionId) : false;
92
+ }
93
+
94
+ export {
95
+ keepSessionWork,
96
+ releaseSessionWork,
97
+ recordSessionReplacement,
98
+ recordSessionStart,
99
+ inheritedSessionIds,
100
+ ownerSessionIds,
101
+ ownsRun,
102
+ MODEL_ONLY_TOOL,
103
+ isStaleExtensionContextError,
104
+ canRenderComponents,
105
+ isUnboundExtensionRuntimeError,
106
+ withCachedUiContext,
107
+ reportSessionWarning
108
+ };