@xzzpig/pi-subagents 0.24.2 → 0.25.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 (258) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/bundle/agent-management.js +4 -4
  3. package/bundle/agents.js +3 -3
  4. package/bundle/child-tool-plan.js +2 -2
  5. package/bundle/chunk-34TUUBRN.js +1107 -0
  6. package/bundle/{chunk-SW2VMNIU.js → chunk-5OD3OWTE.js} +2 -2
  7. package/bundle/{chunk-XWWUDWUW.js → chunk-5YEOWNSD.js} +371 -135
  8. package/bundle/{chunk-EUPJB4S7.js → chunk-5Z7JAORM.js} +196 -1219
  9. package/bundle/{chunk-LCDJWBVM.js → chunk-66JNFRFS.js} +1 -1
  10. package/bundle/{chunk-4UH4WS4G.js → chunk-6MNRKUHY.js} +23 -12
  11. package/bundle/{chunk-ED55MIC2.js → chunk-CGFF4WA3.js} +42 -19
  12. package/bundle/{chunk-TMHVDPYW.js → chunk-DLVPMML3.js} +263 -154
  13. package/bundle/chunk-HXRB42AF.js +108 -0
  14. package/bundle/{chunk-355ECEP2.js → chunk-IH7LQVEE.js} +29 -14
  15. package/bundle/{chunk-CYY5UMJU.js → chunk-IJWITCC6.js} +411 -249
  16. package/bundle/{chunk-RU522D5W.js → chunk-IKFKH5EL.js} +369 -50
  17. package/bundle/{chunk-Z6TFJ6BR.js → chunk-INWSUNI6.js} +1 -1
  18. package/bundle/{chunk-JEA2ZKUA.js → chunk-IUDEI6FJ.js} +35 -200
  19. package/bundle/{chunk-WW76JRIX.js → chunk-JAXVBXGF.js} +1 -1
  20. package/bundle/{chunk-ICNYIALB.js → chunk-JH5H4CYJ.js} +784 -474
  21. package/bundle/{chunk-35GII5EF.js → chunk-JWFLPSTP.js} +41 -117
  22. package/bundle/{chunk-224WMDIV.js → chunk-KCJFGKVK.js} +350 -123
  23. package/bundle/{chunk-RB4GELQA.js → chunk-LPJEKHOY.js} +1 -1
  24. package/bundle/chunk-LYKG4FKH.js +523 -0
  25. package/bundle/{chunk-X6LOM3Z4.js → chunk-LZ3HBDTR.js} +161 -78
  26. package/bundle/{chunk-FG6SQJAR.js → chunk-OGPOCGWX.js} +24 -6
  27. package/bundle/{chunk-BQ2OAB4Q.js → chunk-OSVXFWPG.js} +67 -30
  28. package/bundle/{chunk-FJWI64H7.js → chunk-RMSABUN3.js} +27 -13
  29. package/bundle/{chunk-H36HBZB2.js → chunk-SJPABBZG.js} +2 -2
  30. package/bundle/{chunk-3U633XDZ.js → chunk-U3ZDUUTM.js} +11 -3
  31. package/bundle/{chunk-LVWU2HOO.js → chunk-ULGMXABL.js} +16 -7
  32. package/bundle/{chunk-WPW4V6HM.js → chunk-W7ZA6TYD.js} +2 -2
  33. package/bundle/{chunk-V2KFIGFH.js → chunk-XAC2XNAP.js} +503 -304
  34. package/bundle/{chunk-O4D5PBVI.js → chunk-YWXILP5N.js} +3 -2
  35. package/bundle/control-channel.js +2 -2
  36. package/bundle/index.js +1 -1
  37. package/bundle/intercom-bridge.js +2 -2
  38. package/bundle/preflight.js +12 -10
  39. package/bundle/project-panes.js +3 -3
  40. package/bundle/workflow-resources.js +1 -1
  41. package/docs/agents.md +27 -6
  42. package/docs/configuration.md +20 -8
  43. package/docs/extension-api.md +18 -1
  44. package/docs/models.md +6 -2
  45. package/docs/observability.md +2 -0
  46. package/docs/tool-reference.md +7 -1
  47. package/docs/workflows.md +30 -2
  48. package/package.json +2 -2
  49. package/skills/pi-subagents/SKILL.md +15 -6
  50. package/skills/pi-subagents/references/prompting-and-roles.md +1 -0
  51. package/src/agents/agent-management.d.ts +1 -0
  52. package/src/agents/agent-management.js +46 -18
  53. package/src/agents/agent-memory.d.ts +1 -4
  54. package/src/agents/agent-memory.js +1 -4
  55. package/src/agents/agent-serializer.d.ts +2 -0
  56. package/src/agents/agent-serializer.js +1 -1
  57. package/src/agents/agents.d.ts +2 -3
  58. package/src/agents/agents.js +46 -20
  59. package/src/agents/frontmatter.js +1 -8
  60. package/src/agents/global-npm-root.d.ts +1 -0
  61. package/src/agents/global-npm-root.js +11 -3
  62. package/src/agents/skills.d.ts +0 -3
  63. package/src/agents/skills.js +0 -3
  64. package/src/api/preflight.d.ts +3 -1
  65. package/src/api/preflight.js +2 -0
  66. package/src/extension/config.d.ts +1 -0
  67. package/src/extension/config.js +13 -1
  68. package/src/extension/herdr-pi-bridge.js +10 -2
  69. package/src/extension/index.d.ts +0 -13
  70. package/src/extension/index.js +51 -37
  71. package/src/extension/public-execution.d.ts +1 -0
  72. package/src/extension/public-execution.js +4 -0
  73. package/src/extension/reply-workflow-script.js +24 -4
  74. package/src/extension/schemas.d.ts +12 -3
  75. package/src/extension/schemas.js +7 -3
  76. package/src/extension/session-switch.d.ts +25 -0
  77. package/src/extension/session-switch.js +138 -0
  78. package/src/extension/subagent-guide.d.ts +1 -1
  79. package/src/extension/subagent-guide.js +1 -1
  80. package/src/extension/subagent-launch-tool.d.ts +25 -0
  81. package/src/extension/subagent-launch-tool.js +48 -0
  82. package/src/extension/tool-activation.js +55 -15
  83. package/src/extension/tool-description.d.ts +1 -1
  84. package/src/extension/tool-description.js +14 -8
  85. package/src/inspectors/herdr/actions.d.ts +0 -1
  86. package/src/inspectors/herdr/actions.js +0 -1
  87. package/src/inspectors/session-roots-codec.d.ts +0 -1
  88. package/src/inspectors/session-roots-codec.js +0 -1
  89. package/src/inspectors/tmux/actions.d.ts +0 -1
  90. package/src/inspectors/tmux/actions.js +0 -1
  91. package/src/integrations/herdr-status.js +3 -8
  92. package/src/intercom/native-supervisor-channel.js +65 -9
  93. package/src/runs/background/async-execution.d.ts +7 -10
  94. package/src/runs/background/async-execution.js +66 -29
  95. package/src/runs/background/async-job-tracker.js +12 -0
  96. package/src/runs/background/async-resume.d.ts +2 -1
  97. package/src/runs/background/async-resume.js +114 -40
  98. package/src/runs/background/async-retention.d.ts +0 -2
  99. package/src/runs/background/async-retention.js +17 -6
  100. package/src/runs/background/async-status.d.ts +2 -0
  101. package/src/runs/background/async-status.js +4 -0
  102. package/src/runs/background/auto-drain.js +2 -1
  103. package/src/runs/background/boot-id.d.ts +1 -3
  104. package/src/runs/background/boot-id.js +1 -3
  105. package/src/runs/background/completion-batcher.d.ts +3 -4
  106. package/src/runs/background/completion-batcher.js +2 -3
  107. package/src/runs/background/control-channel.d.ts +0 -6
  108. package/src/runs/background/control-channel.js +0 -6
  109. package/src/runs/background/fleet-view.js +2 -3
  110. package/src/runs/background/notify.d.ts +0 -2
  111. package/src/runs/background/notify.js +0 -2
  112. package/src/runs/background/result-watcher.d.ts +1 -0
  113. package/src/runs/background/result-watcher.js +59 -29
  114. package/src/runs/background/resume-guidance.js +4 -2
  115. package/src/runs/background/retained-children.js +2 -1
  116. package/src/runs/background/run-child-session.d.ts +2 -3
  117. package/src/runs/background/run-child-session.js +5 -8
  118. package/src/runs/background/run-status.js +9 -7
  119. package/src/runs/background/runner-aliases.js +15 -0
  120. package/src/runs/background/scheduled-runs.d.ts +3 -1
  121. package/src/runs/background/scheduled-runs.js +13 -16
  122. package/src/runs/background/steering.d.ts +2 -11
  123. package/src/runs/background/steering.js +11 -6
  124. package/src/runs/background/subagent-runner.d.ts +2 -6
  125. package/src/runs/background/subagent-runner.js +88 -70
  126. package/src/runs/background/subagent-wait.js +12 -15
  127. package/src/runs/background/wait-config.d.ts +2 -0
  128. package/src/runs/background/wait-config.js +17 -3
  129. package/src/runs/background/wait-subscriptions.js +124 -12
  130. package/src/runs/background/wait-tool.js +4 -2
  131. package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
  132. package/src/runs/background/workflow-terminal-proof.js +0 -1
  133. package/src/runs/foreground/async-steering-action.js +24 -9
  134. package/src/runs/foreground/async-stop-action.d.ts +1 -1
  135. package/src/runs/foreground/async-stop-action.js +9 -1
  136. package/src/runs/foreground/execution.d.ts +0 -3
  137. package/src/runs/foreground/execution.js +56 -24
  138. package/src/runs/foreground/prompt-audit.js +1 -0
  139. package/src/runs/foreground/subagent-executor.d.ts +5 -10
  140. package/src/runs/foreground/subagent-executor.js +164 -49
  141. package/src/runs/shared/acceptance.js +69 -26
  142. package/src/runs/shared/async-status-projection.d.ts +2 -0
  143. package/src/runs/shared/async-status-projection.js +10 -0
  144. package/src/runs/shared/child-commands.js +15 -2
  145. package/src/runs/shared/child-hooks.d.ts +1 -7
  146. package/src/runs/shared/child-hooks.js +13 -5
  147. package/src/runs/shared/child-launch.js +6 -2
  148. package/src/runs/shared/child-runtime-config.d.ts +0 -1
  149. package/src/runs/shared/child-session.d.ts +6 -5
  150. package/src/runs/shared/child-session.js +85 -38
  151. package/src/runs/shared/child-tool-plan.d.ts +0 -1
  152. package/src/runs/shared/child-tool-plan.js +0 -1
  153. package/src/runs/shared/claude-code-adapter.js +11 -0
  154. package/src/runs/shared/external-cli-contract.d.ts +49 -0
  155. package/src/runs/shared/external-cli-contract.js +18 -13
  156. package/src/runs/shared/external-cli-runner.js +26 -6
  157. package/src/runs/shared/herdr-connection.js +2 -1
  158. package/src/runs/shared/herdr-pane-host.d.ts +2 -2
  159. package/src/runs/shared/herdr-pane-host.js +17 -1
  160. package/src/runs/shared/herdr-placed-run.js +51 -24
  161. package/src/runs/shared/lane-metadata.d.ts +0 -1
  162. package/src/runs/shared/lane-metadata.js +0 -1
  163. package/src/runs/shared/mcp-config-sources.d.ts +4 -1
  164. package/src/runs/shared/mcp-config-sources.js +1 -1
  165. package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -3
  166. package/src/runs/shared/mcp-direct-tool-allowlist.js +26 -17
  167. package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
  168. package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
  169. package/src/runs/shared/model-resolution.d.ts +20 -5
  170. package/src/runs/shared/model-resolution.js +55 -50
  171. package/src/runs/shared/model-scope.d.ts +1 -5
  172. package/src/runs/shared/model-scope.js +1 -5
  173. package/src/runs/shared/mutation-evidence.d.ts +1 -1
  174. package/src/runs/shared/mutation-evidence.js +52 -7
  175. package/src/runs/shared/nested-events.d.ts +1 -0
  176. package/src/runs/shared/nested-events.js +1 -1
  177. package/src/runs/shared/parallel-utils.d.ts +0 -1
  178. package/src/runs/shared/permissions.js +5 -3
  179. package/src/runs/shared/placement-host.d.ts +5 -1
  180. package/src/runs/shared/rex-pane-host.d.ts +0 -1
  181. package/src/runs/shared/rex-pane-host.js +0 -2
  182. package/src/runs/shared/run-launch-folder.d.ts +12 -0
  183. package/src/runs/shared/run-launch-folder.js +21 -0
  184. package/src/runs/shared/runner-launcher.d.ts +12 -1
  185. package/src/runs/shared/runner-launcher.js +16 -0
  186. package/src/runs/shared/single-output.d.ts +3 -3
  187. package/src/runs/shared/single-output.js +5 -3
  188. package/src/runs/shared/structured-output.d.ts +8 -0
  189. package/src/runs/shared/structured-output.js +40 -5
  190. package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
  191. package/src/runs/shared/subagent-prompt-runtime.js +18 -4
  192. package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
  193. package/src/runs/shared/supervisor-wait-timer.js +61 -0
  194. package/src/runs/shared/tool-timeout.js +2 -1
  195. package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
  196. package/src/runs/shared/worktree-cleanup-plan.js +0 -1
  197. package/src/runs/shared/worktree.d.ts +3 -0
  198. package/src/runs/shared/worktree.js +20 -0
  199. package/src/shared/artifacts.d.ts +1 -0
  200. package/src/shared/artifacts.js +132 -22
  201. package/src/shared/capacity-resilient-json.d.ts +1 -1
  202. package/src/shared/child-cache-retention.d.ts +1 -2
  203. package/src/shared/child-cache-retention.js +1 -2
  204. package/src/shared/fleet-transcript-reader.d.ts +51 -0
  205. package/src/shared/fleet-transcript-reader.js +333 -0
  206. package/src/shared/formatters.d.ts +0 -18
  207. package/src/shared/formatters.js +0 -18
  208. package/src/shared/pruned-fork.js +2 -2
  209. package/src/shared/reported-progress.d.ts +1 -0
  210. package/src/shared/reported-progress.js +12 -0
  211. package/src/shared/session-succession.d.ts +16 -1
  212. package/src/shared/session-succession.js +41 -2
  213. package/src/shared/session-warnings.d.ts +7 -0
  214. package/src/shared/session-warnings.js +26 -0
  215. package/src/shared/settings.d.ts +0 -23
  216. package/src/shared/settings.js +3 -35
  217. package/src/shared/status-format.d.ts +1 -0
  218. package/src/shared/status-format.js +1 -1
  219. package/src/shared/types.d.ts +108 -59
  220. package/src/shared/types.js +0 -12
  221. package/src/shared/utils.d.ts +3 -15
  222. package/src/shared/utils.js +4 -22
  223. package/src/shared/wait-tool-name.d.ts +8 -0
  224. package/src/shared/wait-tool-name.js +13 -0
  225. package/src/slash/slash-commands.js +2 -1
  226. package/src/slash/subagent-cost.d.ts +3 -2
  227. package/src/slash/subagent-cost.js +22 -3
  228. package/src/slash/subagents-admin.js +0 -1
  229. package/src/tui/fleet-status.d.ts +0 -5
  230. package/src/tui/fleet-status.js +4 -24
  231. package/src/tui/fleet.js +6 -4
  232. package/src/tui/render.d.ts +0 -9
  233. package/src/tui/render.js +194 -68
  234. package/src/tui/subagent-messages.js +3 -2
  235. package/src/watchdog/model-selection.js +2 -2
  236. package/src/watchdog/permission-arbiter.js +1 -0
  237. package/src/watchdog/register-child.d.ts +2 -3
  238. package/src/watchdog/register-child.js +2 -3
  239. package/src/watchdog/review.d.ts +0 -5
  240. package/src/watchdog/review.js +4 -3
  241. package/src/watchdog/turn-delta.js +2 -1
  242. package/src/workflows/scripted-workflow.d.ts +2 -0
  243. package/src/workflows/scripted-workflow.js +344 -59
  244. package/src/workflows/structured-workflow-scripts.d.ts +4 -3
  245. package/src/workflows/structured-workflow-scripts.js +32 -11
  246. package/src/workflows/workflow-launch-record.d.ts +15 -6
  247. package/src/workflows/workflow-launch-record.js +30 -12
  248. package/src/workflows/workflow-receipt.js +36 -53
  249. package/src/workflows/workflow-resources.js +4 -4
  250. package/src/workflows/workflow-resume-claim.d.ts +2 -0
  251. package/src/workflows/workflow-resume-claim.js +3 -3
  252. package/src/workflows/workflow-resume.d.ts +1 -1
  253. package/src/workflows/workflow-resume.js +13 -8
  254. package/src/workflows/workflow-script-worker.d.ts +13 -0
  255. package/src/workflows/workflow-script-worker.js +81 -0
  256. package/workflow-script-process.cjs +36 -0
  257. package/workflow-script-worker.cjs +4 -1
  258. package/bundle/chunk-U4ODUYAG.js +0 -235
@@ -2,39 +2,40 @@ import {
2
2
  getLivePromptAudit,
3
3
  handleInspectorAction,
4
4
  readFleetTranscript,
5
- readTranscriptRecords,
6
- renderFleetTranscript,
7
5
  resolveWorkflowForegroundSteeringTarget,
8
6
  steerAsyncRun,
9
7
  steerWorkflowForegroundTarget
10
- } from "./chunk-JEA2ZKUA.js";
8
+ } from "./chunk-IUDEI6FJ.js";
11
9
  import {
12
10
  FLEET_STATUS_WIDGET_KEY,
13
11
  emitUiSpanSilent,
14
- reportFleetWarning,
15
12
  runningTone,
16
13
  stepTaskSummary
17
- } from "./chunk-X6LOM3Z4.js";
14
+ } from "./chunk-LZ3HBDTR.js";
18
15
  import {
19
16
  foregroundChildStateLabel,
20
17
  formatAsyncRunTranscript,
18
+ isTrustedRecordedSessionFile,
21
19
  stopAsyncRun
22
- } from "./chunk-LVWU2HOO.js";
20
+ } from "./chunk-ULGMXABL.js";
23
21
  import "./chunk-7J4ZXMY7.js";
24
22
  import {
25
23
  contextModeBadge,
26
24
  contextModeLabel,
27
25
  decodeUtf8Tail,
28
26
  listAsyncRuns
29
- } from "./chunk-TMHVDPYW.js";
30
- import "./chunk-ICNYIALB.js";
27
+ } from "./chunk-DLVPMML3.js";
28
+ import {
29
+ reportSessionWarning
30
+ } from "./chunk-HXRB42AF.js";
31
+ import "./chunk-JH5H4CYJ.js";
31
32
  import {
32
33
  getArtifactPaths,
33
34
  getArtifactsDir
34
- } from "./chunk-U4ODUYAG.js";
35
- import "./chunk-RB4GELQA.js";
35
+ } from "./chunk-LYKG4FKH.js";
36
+ import "./chunk-LPJEKHOY.js";
36
37
  import "./chunk-NIXWDZZV.js";
37
- import "./chunk-WW76JRIX.js";
38
+ import "./chunk-JAXVBXGF.js";
38
39
  import "./chunk-BGIYHF2W.js";
39
40
  import "./chunk-CTPAE36Y.js";
40
41
  import {
@@ -48,20 +49,22 @@ import {
48
49
  formatTokens,
49
50
  readStatus,
50
51
  shortenPath
51
- } from "./chunk-V2KFIGFH.js";
52
+ } from "./chunk-XAC2XNAP.js";
52
53
  import {
53
54
  DIRS
54
55
  } from "./chunk-UQDHXMUG.js";
55
56
  import "./chunk-QXASAHIA.js";
56
- import "./chunk-YFCK7H2S.js";
57
+ import {
58
+ safeTerminalText
59
+ } from "./chunk-YFCK7H2S.js";
57
60
 
58
61
  // src/tui/fleet.ts
59
- import * as fs from "node:fs";
60
- import * as path from "node:path";
62
+ import * as fs2 from "node:fs";
63
+ import * as path2 from "node:path";
61
64
  import {
62
65
  getMarkdownTheme
63
66
  } from "@earendil-works/pi-coding-agent";
64
- import { matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
67
+ import { matchesKey, truncateToWidth as truncateToWidth2, visibleWidth as visibleWidth2, wrapTextWithAnsi as wrapTextWithAnsi2 } from "@earendil-works/pi-tui";
65
68
 
66
69
  // src/tui/fleet-layout.ts
67
70
  function fleetLayout(width, rows, selected, items) {
@@ -143,6 +146,322 @@ function parseMouseWheelEvent(data) {
143
146
  return void 0;
144
147
  }
145
148
 
149
+ // src/tui/fleet-transcript.ts
150
+ import * as fs from "node:fs";
151
+ import * as path from "node:path";
152
+ import { getLanguageFromPath, highlightCode } from "@earendil-works/pi-coding-agent";
153
+ import { Markdown, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
154
+ var DEFAULT_MAX_RECORDS = 240;
155
+ var DEFAULT_MAX_BYTES = 2 * 1024 * 1024;
156
+ var MAX_MESSAGE_CHARS = 64 * 1024;
157
+ var TOOL_PREVIEW_LINES = 7;
158
+ function sanitizeJsonDisplayValue(value) {
159
+ if (typeof value === "string") {
160
+ const safe = safeTerminalText(value);
161
+ return { value: safe, changed: safe !== value };
162
+ }
163
+ if (Array.isArray(value)) {
164
+ const sanitized = value.map(sanitizeJsonDisplayValue);
165
+ return {
166
+ value: sanitized.map((entry) => entry.value),
167
+ changed: sanitized.some((entry) => entry.changed)
168
+ };
169
+ }
170
+ if (value && typeof value === "object") {
171
+ let changed = false;
172
+ const sanitized = /* @__PURE__ */ Object.create(null);
173
+ for (const [key, nested] of Object.entries(value)) {
174
+ const safeKey = safeTerminalText(key);
175
+ const safeValue = sanitizeJsonDisplayValue(nested);
176
+ sanitized[safeKey] = safeValue.value;
177
+ changed ||= safeKey !== key || safeValue.changed;
178
+ }
179
+ return { value: changed ? sanitized : value, changed };
180
+ }
181
+ return { value, changed: false };
182
+ }
183
+ function safeToolArgsPayload(payload) {
184
+ try {
185
+ const sanitized = sanitizeJsonDisplayValue(JSON.parse(payload));
186
+ return sanitized.changed ? JSON.stringify(sanitized.value) : safeTerminalText(payload);
187
+ } catch {
188
+ return safeTerminalText(payload);
189
+ }
190
+ }
191
+ function objectValue(value) {
192
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
193
+ }
194
+ function pathWithin(base, candidate) {
195
+ const resolvedBase = path.resolve(base);
196
+ const resolvedCandidate = path.resolve(candidate);
197
+ return resolvedCandidate === resolvedBase || resolvedCandidate.startsWith(`${resolvedBase}${path.sep}`);
198
+ }
199
+ function errorMessage(error) {
200
+ return error instanceof Error ? error.message : String(error);
201
+ }
202
+ function isNotFoundError(error) {
203
+ return Boolean(objectValue(error)?.code === "ENOENT");
204
+ }
205
+ function validateTranscriptPath(filePath, trustedRoots, trustedFiles = [], trustedFileRoot) {
206
+ if (trustedRoots.length === 0 && (!trustedFileRoot || trustedFiles.length === 0)) return { warning: `Transcript preview has no trusted root: ${filePath}` };
207
+ const resolvedPath = path.resolve(filePath);
208
+ const recordedCandidate = trustedFileRoot && pathWithin(trustedFileRoot, resolvedPath) && trustedFiles.some((file) => path.resolve(file) === resolvedPath);
209
+ if (!trustedRoots.some((root) => pathWithin(root, resolvedPath)) && !recordedCandidate) {
210
+ return { warning: `Transcript is outside trusted roots: ${filePath}` };
211
+ }
212
+ let stat;
213
+ try {
214
+ stat = fs.lstatSync(resolvedPath);
215
+ } catch (error) {
216
+ if (isNotFoundError(error)) return {};
217
+ return { warning: `Transcript could not be inspected: ${errorMessage(error)}` };
218
+ }
219
+ if (stat.isSymbolicLink()) return { warning: `Transcript preview refused a symlink: ${filePath}` };
220
+ if (!stat.isFile()) return { warning: `Transcript path is not a file: ${filePath}` };
221
+ try {
222
+ const realPath = fs.realpathSync(resolvedPath);
223
+ const realRoots = trustedRoots.filter((root) => fs.existsSync(root)).map((root) => fs.realpathSync(root));
224
+ if (!realRoots.some((root) => pathWithin(root, realPath)) && !isTrustedRecordedSessionFile(realPath, trustedFiles, trustedFileRoot)) {
225
+ return { warning: `Transcript resolves outside trusted roots: ${filePath}` };
226
+ }
227
+ return { resolvedPath: realPath };
228
+ } catch (error) {
229
+ return { warning: `Transcript path could not be resolved: ${errorMessage(error)}` };
230
+ }
231
+ }
232
+ function isCompleteRecord(line) {
233
+ if (!line?.trim()) return false;
234
+ try {
235
+ return objectValue(JSON.parse(line)) !== void 0;
236
+ } catch {
237
+ return false;
238
+ }
239
+ }
240
+ function readTailLines(filePath, maxBytes) {
241
+ let fd;
242
+ try {
243
+ const noFollow = typeof fs.constants.O_NOFOLLOW === "number" ? fs.constants.O_NOFOLLOW : 0;
244
+ fd = fs.openSync(filePath, fs.constants.O_RDONLY | noFollow);
245
+ const stat = fs.fstatSync(fd);
246
+ if (!stat.isFile()) return { lines: [], truncated: false, warning: `Transcript path is not a file: ${filePath}` };
247
+ if (stat.size === 0) return { lines: [], truncated: false };
248
+ const bytesToRead = Math.min(stat.size, maxBytes);
249
+ const start = stat.size - bytesToRead;
250
+ const buffer = Buffer.alloc(bytesToRead);
251
+ const bytesRead = fs.readSync(fd, buffer, 0, bytesToRead, start);
252
+ const content = buffer.subarray(0, bytesRead).toString("utf-8");
253
+ const endsWithNewline = content.endsWith("\n");
254
+ let lines = content.split(/\r?\n/);
255
+ if (start > 0 && lines.length > 0) lines = lines.slice(1);
256
+ if (lines.at(-1) === "") lines = lines.slice(0, -1);
257
+ else if (!endsWithNewline && !isCompleteRecord(lines.at(-1))) lines = lines.slice(0, -1);
258
+ return { lines, truncated: start > 0 };
259
+ } catch (error) {
260
+ return { lines: [], truncated: false, warning: `Transcript could not be read: ${errorMessage(error)}` };
261
+ } finally {
262
+ if (fd !== void 0) fs.closeSync(fd);
263
+ }
264
+ }
265
+ function safeTranscriptEvent(event) {
266
+ if (event.kind === "assistant") {
267
+ return {
268
+ ...event,
269
+ text: safeTerminalText(event.text),
270
+ ...event.model ? { model: safeTerminalText(event.model) } : {}
271
+ };
272
+ }
273
+ if (event.kind === "user" || event.kind === "notice") {
274
+ return { ...event, text: safeTerminalText(event.text) };
275
+ }
276
+ return {
277
+ ...event,
278
+ name: safeTerminalText(event.name),
279
+ ...event.args !== void 0 ? { args: safeTerminalText(event.args) } : {},
280
+ ...event.argsPayload !== void 0 ? { argsPayload: safeToolArgsPayload(event.argsPayload) } : {},
281
+ ...event.output !== void 0 ? { output: safeTerminalText(event.output) } : {},
282
+ ...event.error !== void 0 ? { error: safeTerminalText(event.error) } : {}
283
+ };
284
+ }
285
+ function readTranscriptRecords(filePath, options) {
286
+ const validated = validateTranscriptPath(filePath, options.trustedRoots);
287
+ if (!validated.resolvedPath) {
288
+ return { records: [], truncated: false, readFailed: true, ...validated.warning ? { warning: safeTerminalText(validated.warning) } : {} };
289
+ }
290
+ const maxRecords = Math.max(1, options.maxRecords ?? DEFAULT_MAX_RECORDS);
291
+ const tail = readTailLines(validated.resolvedPath, Math.max(1024, options.maxBytes ?? DEFAULT_MAX_BYTES));
292
+ const selected = tail.lines.slice(-maxRecords);
293
+ const records = [];
294
+ let malformed = 0;
295
+ for (const line of selected) {
296
+ if (!line.trim()) continue;
297
+ try {
298
+ const parsed = JSON.parse(line);
299
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
300
+ records.push(parsed);
301
+ } else {
302
+ malformed++;
303
+ }
304
+ } catch {
305
+ malformed++;
306
+ }
307
+ }
308
+ const warnings = [
309
+ tail.warning,
310
+ malformed > 0 ? `Skipped ${malformed} malformed transcript record${malformed === 1 ? "" : "s"}.` : void 0
311
+ ].filter((value) => Boolean(value));
312
+ return {
313
+ records,
314
+ ...tail.warning ? { readFailed: true } : {},
315
+ truncated: tail.truncated || tail.lines.length > maxRecords,
316
+ ...warnings.length ? { warning: safeTerminalText(warnings.join(" ")) } : {}
317
+ };
318
+ }
319
+ function statusGlyph(event, theme) {
320
+ if (event.status === "running") return theme.fg("warning", "\u25CF");
321
+ if (event.status === "error") return theme.fg("error", "\u2717");
322
+ return theme.fg("success", "\u2713");
323
+ }
324
+ function jsonScalar(value) {
325
+ if (typeof value === "string" && value.trim()) return value;
326
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
327
+ return void 0;
328
+ }
329
+ function parseToolArgs(event) {
330
+ if (!event.argsPayload) return void 0;
331
+ try {
332
+ return objectValue(JSON.parse(event.argsPayload));
333
+ } catch {
334
+ return void 0;
335
+ }
336
+ }
337
+ function toolDuration(event) {
338
+ if (event.startedAt === void 0 || event.endedAt === void 0) return void 0;
339
+ return `${((event.endedAt - event.startedAt) / 1e3).toFixed(1)}s`;
340
+ }
341
+ function renderExpandedTool(event, width, theme) {
342
+ const lines = [];
343
+ const args = parseToolArgs(event);
344
+ const glyph = statusGlyph(event, theme);
345
+ const output = event.output ?? event.error;
346
+ const outputColor = event.status === "error" ? "error" : "toolOutput";
347
+ if (event.name === "bash") {
348
+ const command = jsonScalar(args?.command) ?? event.args ?? "(unknown command)";
349
+ lines.push(railLine(`${glyph} ${theme.fg("toolTitle", theme.bold(`$ ${command}`))}`, width, theme));
350
+ if (output) {
351
+ for (const outputLine of output.replace(/\s+$/, "").split(/\r?\n/)) {
352
+ for (const wrapped of renderWrapped(theme.fg(outputColor, outputLine), Math.max(1, width - 4))) {
353
+ lines.push(railLine(` ${wrapped}`, width, theme));
354
+ }
355
+ }
356
+ }
357
+ const duration = toolDuration(event);
358
+ if (duration) lines.push(railLine(theme.fg("dim", ` Took ${duration}`), width, theme));
359
+ return lines;
360
+ }
361
+ if (event.name === "read") {
362
+ const filePath = jsonScalar(args?.path ?? args?.file_path);
363
+ const language = filePath ? getLanguageFromPath(filePath) : void 0;
364
+ const rendered = !output ? [] : event.status === "error" ? output.split("\n").map((line) => theme.fg("error", line)) : language ? highlightCode(output, language) : output.split("\n");
365
+ lines.push(railLine(`${glyph} ${theme.fg("toolTitle", theme.bold(`read ${filePath ?? event.args ?? ""}`))}`, width, theme));
366
+ for (const line of rendered) {
367
+ for (const wrapped of renderWrapped(line, Math.max(1, width - 4))) lines.push(railLine(` ${wrapped}`, width, theme));
368
+ }
369
+ return lines;
370
+ }
371
+ lines.push(railLine(`${glyph} ${theme.fg("toolTitle", theme.bold(event.name))}`, width, theme));
372
+ if (event.argsPayload) {
373
+ lines.push(railLine(theme.fg("dim", " args"), width, theme));
374
+ for (const argLine of event.argsPayload.split(/\r?\n/)) {
375
+ for (const wrapped of renderWrapped(theme.fg("muted", argLine), Math.max(1, width - 4))) lines.push(railLine(` ${wrapped}`, width, theme));
376
+ }
377
+ }
378
+ if (output) {
379
+ lines.push(railLine(theme.fg(event.status === "error" ? "error" : "dim", event.status === "error" ? " error" : " output"), width, theme));
380
+ for (const outputLine of output.split(/\r?\n/)) {
381
+ for (const wrapped of renderWrapped(theme.fg(outputColor, outputLine), Math.max(1, width - 4))) lines.push(railLine(` ${wrapped}`, width, theme));
382
+ }
383
+ }
384
+ return lines;
385
+ }
386
+ function bounded(text, width) {
387
+ return truncateToWidth(text, Math.max(0, width));
388
+ }
389
+ function railLine(content, width, theme) {
390
+ return bounded(`${theme.fg("borderMuted", "\u2502")} ${content}`, width);
391
+ }
392
+ function renderWrapped(text, width) {
393
+ return wrapTextWithAnsi(text, Math.max(1, width));
394
+ }
395
+ function renderFleetTranscript(transcript, width, theme, markdownTheme, options = {}) {
396
+ if (width <= 0) return [];
397
+ const lines = [];
398
+ if (transcript.truncated) lines.push(bounded(theme.fg("dim", "\u2191 Earlier activity omitted"), width));
399
+ if (transcript.warning) {
400
+ for (const line of renderWrapped(safeTerminalText(transcript.warning), Math.max(1, width - 2))) {
401
+ lines.push(bounded(`${theme.fg("warning", "!")} ${theme.fg("warning", line)}`, width));
402
+ }
403
+ }
404
+ for (const rawEvent of transcript.events) {
405
+ const event = safeTranscriptEvent(rawEvent);
406
+ if (event.kind === "tool") {
407
+ if (options.expandedTools && (event.output || event.argsPayload || event.error)) {
408
+ lines.push(...renderExpandedTool(event, width, theme));
409
+ lines.push(railLine(theme.fg("dim", " x to collapse"), width, theme));
410
+ continue;
411
+ }
412
+ const title = theme.fg("toolTitle", theme.bold(event.name));
413
+ const args = event.args ? ` ${theme.fg("dim", event.args)}` : "";
414
+ const suffix = event.status === "running" ? theme.fg("warning", " running") : "";
415
+ lines.push(bounded(`${theme.fg("borderMuted", "\u251C\u2500")} ${statusGlyph(event, theme)} ${title}${args}${suffix}`, width));
416
+ if (event.output && event.status !== "error" && event.name === "bash") {
417
+ const outputLines = event.output.replace(/\s+$/, "").split(/\r?\n/);
418
+ const visible = outputLines.slice(-TOOL_PREVIEW_LINES);
419
+ const hidden = Math.max(0, outputLines.length - visible.length);
420
+ for (const outputLine of visible) {
421
+ for (const wrapped of renderWrapped(theme.fg("toolOutput", outputLine), Math.max(1, width - 4))) {
422
+ lines.push(railLine(` ${wrapped}`, width, theme));
423
+ }
424
+ }
425
+ if (hidden > 0) lines.push(railLine(theme.fg("dim", ` \u2026 ${hidden} earlier lines \xB7 x to expand`), width, theme));
426
+ const duration = toolDuration(event);
427
+ lines.push(railLine(theme.fg("dim", ` Took${duration ? ` ${duration}` : ""}`), width, theme));
428
+ } else if (event.output && event.status !== "error") {
429
+ const summary = truncateToWidth(event.output.replace(/\s+/g, " ").trim(), Math.max(1, width - 18), "\u2026");
430
+ if (summary) lines.push(railLine(theme.fg("dim", ` ${summary} \xB7 x to expand`), width, theme));
431
+ }
432
+ if (event.error) {
433
+ for (const errorLine of renderWrapped(event.error, Math.max(1, width - 4))) {
434
+ lines.push(railLine(theme.fg("error", ` ${errorLine}`), width, theme));
435
+ }
436
+ }
437
+ continue;
438
+ }
439
+ if (event.kind === "notice") {
440
+ const color = event.tone === "error" ? "error" : event.tone === "warning" ? "warning" : "dim";
441
+ for (const noticeLine of renderWrapped(event.text, Math.max(1, width - 2))) {
442
+ lines.push(railLine(theme.fg(color, noticeLine), width, theme));
443
+ }
444
+ continue;
445
+ }
446
+ const assistant = event.kind === "assistant";
447
+ const label = assistant ? "Assistant" : "Supervisor";
448
+ const marker = assistant ? theme.fg("accent", "\u25C6") : theme.fg("warning", "\u25C7");
449
+ const model = assistant && event.model ? theme.fg("dim", ` \xB7 ${event.model}`) : "";
450
+ lines.push(bounded(`${marker} ${theme.bold(label)}${model}`, width));
451
+ if (assistant) {
452
+ const rendered = new Markdown(event.text, 0, 0, markdownTheme).render(Math.max(1, width - 2));
453
+ for (const markdownLine of rendered) lines.push(railLine(markdownLine, width, theme));
454
+ } else {
455
+ for (const userLine of renderWrapped(event.text, Math.max(1, width - 2))) {
456
+ lines.push(railLine(userLine, width, theme));
457
+ }
458
+ }
459
+ lines.push(theme.fg("borderMuted", "\u2502"));
460
+ }
461
+ while (lines.length > 0 && visibleWidth(lines.at(-1) ?? "") === 1) lines.pop();
462
+ return lines;
463
+ }
464
+
146
465
  // src/tui/fleet-native-transcript.ts
147
466
  var REQUIRED_NATIVE_EXPORTS = [
148
467
  "createTranscriptState",
@@ -598,7 +917,7 @@ function collectFleetSnapshot(state, options = {}) {
598
917
  entryLimit: MAX_FLEET_HISTORY_CANDIDATES,
599
918
  resultsDir: options.resultsDir ?? DIRS.results,
600
919
  reconcile: false,
601
- onCorruptStatus: (warning) => reportFleetWarning(state, warning)
920
+ onCorruptStatus: (warning) => reportSessionWarning(state, warning)
602
921
  }).filter((run) => !trackedIds.has(run.id));
603
922
  runs = [...trackedRuns, ...history];
604
923
  } else {
@@ -612,7 +931,7 @@ function collectFleetSnapshot(state, options = {}) {
612
931
  }
613
932
  if (state.currentSessionId) {
614
933
  try {
615
- for (const run of snapshotExternalRuns(state.currentSessionId, { ignoreMalformed: true, onMalformedRecord: (message) => reportFleetWarning(state, `Removed ${message}`) })) {
934
+ for (const run of snapshotExternalRuns(state.currentSessionId, { ignoreMalformed: true, onMalformedRecord: (message) => reportSessionWarning(state, `Removed ${message}`) })) {
616
935
  items.push({
617
936
  key: `external:${run.id}`,
618
937
  kind: "external",
@@ -679,7 +998,7 @@ function fleetItemThinkingLevel(item) {
679
998
  return void 0;
680
999
  }
681
1000
  }
682
- function statusGlyph(item, theme) {
1001
+ function statusGlyph2(item, theme) {
683
1002
  if (item.state === "running") return runningTone(theme, fleetItemThinkingLevel(item))("\u25CF");
684
1003
  if (item.state === "queued" || item.state === "pending") return theme.fg("muted", "\u25E6");
685
1004
  if (item.state === "complete" || item.state === "completed") return theme.fg("success", "\u2713");
@@ -697,7 +1016,7 @@ function promptAuditString(value) {
697
1016
  function authoredPromptSummary(text) {
698
1017
  if (typeof text !== "string") return void 0;
699
1018
  const summary = text.replace(/\s+/g, " ").trim();
700
- return summary ? truncateToWidth(summary, PROMPT_AUDIT_SUMMARY_WIDTH, "\u2026") : void 0;
1019
+ return summary ? truncateToWidth2(summary, PROMPT_AUDIT_SUMMARY_WIDTH, "\u2026") : void 0;
701
1020
  }
702
1021
  function foregroundAuthoredPromptSummary(item, state) {
703
1022
  if (!state.currentSessionId || item.control.sessionId !== state.currentSessionId) return void 0;
@@ -753,17 +1072,17 @@ function foregroundActiveDetail(item, state) {
753
1072
  ];
754
1073
  return lines.filter((line) => line !== void 0);
755
1074
  }
756
- function pathWithin(base, candidate) {
757
- const resolvedBase = path.resolve(base);
758
- const resolvedCandidate = path.resolve(candidate);
759
- return resolvedCandidate === resolvedBase || resolvedCandidate.startsWith(`${resolvedBase}${path.sep}`);
1075
+ function pathWithin2(base, candidate) {
1076
+ const resolvedBase = path2.resolve(base);
1077
+ const resolvedCandidate = path2.resolve(candidate);
1078
+ return resolvedCandidate === resolvedBase || resolvedCandidate.startsWith(`${resolvedBase}${path2.sep}`);
760
1079
  }
761
1080
  function trustedFileTail(filePath, trustedRoots) {
762
- const resolvedPath = path.resolve(filePath);
763
- if (trustedRoots.length === 0 || !trustedRoots.some((root) => pathWithin(root, resolvedPath))) return { warning: `output artifact is outside trusted roots: ${filePath}` };
1081
+ const resolvedPath = path2.resolve(filePath);
1082
+ if (trustedRoots.length === 0 || !trustedRoots.some((root) => pathWithin2(root, resolvedPath))) return { warning: `output artifact is outside trusted roots: ${filePath}` };
764
1083
  let stat;
765
1084
  try {
766
- stat = fs.lstatSync(resolvedPath);
1085
+ stat = fs2.lstatSync(resolvedPath);
767
1086
  } catch (error) {
768
1087
  if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return { unavailable: `output artifact unavailable: ${filePath}` };
769
1088
  return { warning: `output artifact could not be inspected: ${error instanceof Error ? error.message : String(error)}` };
@@ -771,17 +1090,17 @@ function trustedFileTail(filePath, trustedRoots) {
771
1090
  if (stat.isSymbolicLink()) return { warning: `output artifact refused a symlink: ${filePath}` };
772
1091
  if (!stat.isFile()) return { warning: `output artifact is not a file: ${filePath}` };
773
1092
  try {
774
- const realPath = fs.realpathSync(resolvedPath);
775
- const realRoots = trustedRoots.filter((root) => fs.existsSync(root)).map((root) => fs.realpathSync(root));
776
- if (!realRoots.some((root) => pathWithin(root, realPath))) return { warning: `output artifact resolves outside trusted roots: ${filePath}` };
777
- const fd = fs.openSync(realPath, "r");
1093
+ const realPath = fs2.realpathSync(resolvedPath);
1094
+ const realRoots = trustedRoots.filter((root) => fs2.existsSync(root)).map((root) => fs2.realpathSync(root));
1095
+ if (!realRoots.some((root) => pathWithin2(root, realPath))) return { warning: `output artifact resolves outside trusted roots: ${filePath}` };
1096
+ const fd = fs2.openSync(realPath, "r");
778
1097
  try {
779
1098
  const bytes = Math.min(stat.size, OUTPUT_TAIL_BYTES);
780
1099
  const buffer = Buffer.alloc(bytes);
781
- fs.readSync(fd, buffer, 0, bytes, stat.size - bytes);
1100
+ fs2.readSync(fd, buffer, 0, bytes, stat.size - bytes);
782
1101
  return { text: decodeUtf8Tail(buffer) };
783
1102
  } finally {
784
- fs.closeSync(fd);
1103
+ fs2.closeSync(fd);
785
1104
  }
786
1105
  } catch (error) {
787
1106
  return { warning: `output artifact could not be read: ${error instanceof Error ? error.message : String(error)}` };
@@ -789,7 +1108,7 @@ function trustedFileTail(filePath, trustedRoots) {
789
1108
  }
790
1109
  function foregroundRecentOutputLines(item, state) {
791
1110
  const outputPath = item.child.artifactPaths?.outputPath ?? item.child.savedOutputPath;
792
- const output = item.child.finalOutput ? { text: item.child.finalOutput } : outputPath ? trustedFileTail(path.isAbsolute(outputPath) ? outputPath : path.resolve(item.run.cwd, outputPath), uniquePaths([
1111
+ const output = item.child.finalOutput ? { text: item.child.finalOutput } : outputPath ? trustedFileTail(path2.isAbsolute(outputPath) ? outputPath : path2.resolve(item.run.cwd, outputPath), uniquePaths([
793
1112
  fleetArtifactsRoot(state, item.run.cwd),
794
1113
  fleetArtifactsRoot(state, state.baseCwd)
795
1114
  ])) : void 0;
@@ -887,7 +1206,7 @@ function asyncDetail(item, state) {
887
1206
  }
888
1207
  return lines;
889
1208
  }
890
- const outputPath = item.index !== void 0 ? path.join(item.run.asyncDir, `output-${item.index}.log`) : void 0;
1209
+ const outputPath = item.index !== void 0 ? path2.join(item.run.asyncDir, `output-${item.index}.log`) : void 0;
891
1210
  return [
892
1211
  `Run: ${item.runId}`,
893
1212
  "Source: async",
@@ -936,7 +1255,7 @@ function firstToolResultText(result, fallback) {
936
1255
  return { text, ...result.isError ? { isError: true } : {} };
937
1256
  }
938
1257
  function uniquePaths(values) {
939
- return [...new Set(values.filter((value) => Boolean(value)).map((value) => path.resolve(value)))];
1258
+ return [...new Set(values.filter((value) => Boolean(value)).map((value) => path2.resolve(value)))];
940
1259
  }
941
1260
  function fleetArtifactsRoot(state, cwd) {
942
1261
  return getArtifactsDir(
@@ -956,7 +1275,7 @@ function transcriptTarget(item, state) {
956
1275
  }
957
1276
  if (item.kind === "foreground-recent") {
958
1277
  if (!item.child.transcriptPath) return void 0;
959
- const transcriptPath2 = path.isAbsolute(item.child.transcriptPath) ? item.child.transcriptPath : path.resolve(item.run.cwd, item.child.transcriptPath);
1278
+ const transcriptPath2 = path2.isAbsolute(item.child.transcriptPath) ? item.child.transcriptPath : path2.resolve(item.run.cwd, item.child.transcriptPath);
960
1279
  return {
961
1280
  path: transcriptPath2,
962
1281
  trustedRoots: uniquePaths([
@@ -970,7 +1289,7 @@ function transcriptTarget(item, state) {
970
1289
  const recordedSessionFile = step?.sessionFile ?? item.run.sessionFile;
971
1290
  const recordedPath = step?.transcriptPath ?? recordedSessionFile;
972
1291
  if (!recordedPath) return void 0;
973
- const transcriptPath = path.isAbsolute(recordedPath) ? recordedPath : path.resolve(item.run.asyncDir, recordedPath);
1292
+ const transcriptPath = path2.isAbsolute(recordedPath) ? recordedPath : path2.resolve(item.run.asyncDir, recordedPath);
974
1293
  const trackedJob = state.fleetJobs?.get(item.runId) ?? state.asyncJobs.get(item.runId);
975
1294
  return {
976
1295
  path: transcriptPath,
@@ -1035,7 +1354,7 @@ function itemStats(item) {
1035
1354
  }
1036
1355
  function structuredHeader(item, width, theme, conversationState, promptSummary) {
1037
1356
  const lines = [];
1038
- lines.push(rightAligned(` ${statusGlyph(item, theme)} ${theme.bold(item.agent)}`, theme.fg("dim", item.state), width));
1357
+ lines.push(rightAligned(` ${statusGlyph2(item, theme)} ${theme.bold(item.agent)}`, theme.fg("dim", item.state), width));
1039
1358
  const child = "index" in item && item.index !== void 0 ? ` \xB7 child ${item.index + 1}` : "";
1040
1359
  const context = itemContext(item);
1041
1360
  const identity = `${itemSource(item)} \xB7 ${item.runId.slice(0, 8)}${child} \xB7 ${itemMode(item)}${context ? ` ${context}` : ""}`;
@@ -1044,20 +1363,20 @@ function structuredHeader(item, width, theme, conversationState, promptSummary)
1044
1363
  if (stats.length) lines.push(` ${theme.fg("muted", stats.join(" \xB7 "))}`);
1045
1364
  if (promptSummary) lines.push(` ${theme.fg("muted", `Task: ${promptSummary}`)}`);
1046
1365
  lines.push(`${theme.fg("accent", "Conversation")} ${theme.fg("dim", `\xB7 ${conversationState}`)}`);
1047
- return lines.map((line) => truncateToWidth(line, width));
1366
+ return lines.map((line) => truncateToWidth2(line, width));
1048
1367
  }
1049
1368
  function fit(text, width) {
1050
- const clipped = truncateToWidth(text, Math.max(0, width));
1051
- return clipped + " ".repeat(Math.max(0, width - visibleWidth(clipped)));
1369
+ const clipped = truncateToWidth2(text, Math.max(0, width));
1370
+ return clipped + " ".repeat(Math.max(0, width - visibleWidth2(clipped)));
1052
1371
  }
1053
1372
  function rightAligned(left, right, width) {
1054
- const rightWidth = visibleWidth(right);
1373
+ const rightWidth = visibleWidth2(right);
1055
1374
  const leftWidth = Math.max(0, width - rightWidth - 1);
1056
1375
  return fit(left, leftWidth) + " ".repeat(Math.max(1, width - leftWidth - rightWidth)) + fit(right, rightWidth);
1057
1376
  }
1058
1377
  function transcriptFingerprint(filePath) {
1059
1378
  try {
1060
- const stat = fs.statSync(filePath, { bigint: true });
1379
+ const stat = fs2.statSync(filePath, { bigint: true });
1061
1380
  return `${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
1062
1381
  } catch {
1063
1382
  return "missing";
@@ -1568,7 +1887,7 @@ var SubagentFleetComponent = class {
1568
1887
  const name = task && item.kind === "async" && item.step ? item.step.agent : item.agent;
1569
1888
  const agent = index === this.selected ? this.theme.bold(name) : name;
1570
1889
  const identity = task ?? item.runId.slice(0, 8);
1571
- const left = `${marker} ${statusGlyph(item, this.theme)} ${agent}${context} ${this.theme.fg("dim", `\xB7 ${identity}`)}`;
1890
+ const left = `${marker} ${statusGlyph2(item, this.theme)} ${agent}${context} ${this.theme.fg("dim", `\xB7 ${identity}`)}`;
1572
1891
  return rightAligned(left, this.theme.fg("dim", item.state), layout.roster.width);
1573
1892
  });
1574
1893
  }
@@ -1612,7 +1931,7 @@ var SubagentFleetComponent = class {
1612
1931
  this.theme.fg("accent", viewLabel),
1613
1932
  promptText
1614
1933
  ];
1615
- const body = raw.filter((line) => line !== void 0).flatMap((line) => wrapTextWithAnsi(line, Math.max(1, width)));
1934
+ const body = raw.filter((line) => line !== void 0).flatMap((line) => wrapTextWithAnsi2(line, Math.max(1, width)));
1616
1935
  return { header: [], body: this.withActionLines(body) };
1617
1936
  }
1618
1937
  wrappedDetail(width) {
@@ -1637,7 +1956,7 @@ var SubagentFleetComponent = class {
1637
1956
  const lines = [];
1638
1957
  for (const line of raw) {
1639
1958
  const styled = /^(Run|State|Mode|Source|Child|Agent|Model|Task):/.test(line) ? this.theme.bold(line) : /^(Transcript|Result transcript tail)/.test(line) ? this.theme.fg("accent", line) : /^(Output|Session|Transcript file|Artifacts):/.test(line) ? this.theme.fg("muted", line) : /^Transcript preview warning:/.test(line) ? this.theme.fg("warning", line) : line;
1640
- const wrapped = wrapTextWithAnsi(styled, Math.max(1, width));
1959
+ const wrapped = wrapTextWithAnsi2(styled, Math.max(1, width));
1641
1960
  lines.push(...wrapped.length ? wrapped : [""]);
1642
1961
  }
1643
1962
  return { header: [], body: this.withActionLines(lines) };
@@ -1645,7 +1964,7 @@ var SubagentFleetComponent = class {
1645
1964
  render(width) {
1646
1965
  const layout = fleetLayout(width, this.tui.terminal?.rows ?? 32, this.selected, this.snapshot.items);
1647
1966
  this.renderedLayout = layout;
1648
- if (!layout) return [truncateToWidth("Subagent fleet needs at least 36 columns. Esc closes.", width)];
1967
+ if (!layout) return [truncateToWidth2("Subagent fleet needs at least 36 columns. Esc closes.", width)];
1649
1968
  const innerWidth = width - 2;
1650
1969
  const { bodyHeight } = layout;
1651
1970
  const rosterWidth = layout.roster.width;
@@ -1662,7 +1981,7 @@ var SubagentFleetComponent = class {
1662
1981
  const lines = [this.theme.fg("border", `\u256D${"\u2500".repeat(innerWidth)}\u256E`)];
1663
1982
  const selected = this.snapshot.items[this.selected];
1664
1983
  const title = selected?.kind === "external" ? ` ${this.theme.bold("Fleet inspector")} ${this.theme.fg("dim", "\xB7 external display-only")}` : ` ${this.theme.bold("Subagent fleet inspector")} ${this.theme.fg("dim", "\xB7 live controls")}`;
1665
- const selectedStatus = selected ? `${statusGlyph(selected, this.theme)} ${selected.agent} \xB7 ${selected.state} ` : this.theme.fg("dim", "no children ");
1984
+ const selectedStatus = selected ? `${statusGlyph2(selected, this.theme)} ${selected.agent} \xB7 ${selected.state} ` : this.theme.fg("dim", "no children ");
1666
1985
  lines.push(this.theme.fg("border", "\u2502") + rightAligned(title, selectedStatus, innerWidth) + this.theme.fg("border", "\u2502"));
1667
1986
  lines.push(this.theme.fg("border", `\u251C${"\u2500".repeat(rosterWidth)}\u252C${"\u2500".repeat(detailWidth)}\u2524`));
1668
1987
  for (let index = 0; index < bodyHeight; index++) {
@@ -1675,7 +1994,7 @@ var SubagentFleetComponent = class {
1675
1994
  const footer = this.promptAuditOpen ? ` j/k child \xB7 1/2/3 view \xB7 g redo with guidance \xB7 c copy \xB7 wheel \u2191\u2193 \xB7 Esc close Prompt Audit \xB7 ${position}` : selected?.kind === "external" ? ` ${bindingLabel(this.keybindings, "selectUp")}/${bindingLabel(this.keybindings, "selectDown")} job \xB7 display-only \xB7 ${bindingLabel(this.keybindings, "refresh")} refresh \xB7 wheel \u2191\u2193 \xB7 ${bindingLabel(this.keybindings, "close")} close \xB7 ${position}` : ` ${bindingLabel(this.keybindings, "selectUp")}/${bindingLabel(this.keybindings, "selectDown")} agent \xB7 p Prompt Audit \xB7 ${bindingLabel(this.keybindings, "inspect")} Inspect \xB7 ${bindingLabel(this.keybindings, "steer")} steer \xB7 ${bindingLabel(this.keybindings, "stop")} stop \xB7 ${bindingLabel(this.keybindings, "toggleTools")} tools \xB7 ${bindingLabel(this.keybindings, "toggleThinking")} thinking \xB7 ${bindingLabel(this.keybindings, "toggleRenderer")} view \xB7 ${bindingLabel(this.keybindings, "refresh")} refresh \xB7 wheel \u2191\u2193 \xB7 ${bindingLabel(this.keybindings, "close")} close \xB7 ${position}`;
1676
1995
  lines.push(this.theme.fg("border", "\u2502") + fit(this.theme.fg("dim", footer), innerWidth) + this.theme.fg("border", "\u2502"));
1677
1996
  lines.push(this.theme.fg("border", `\u2570${"\u2500".repeat(innerWidth)}\u256F`));
1678
- return lines.map((line) => truncateToWidth(line, width));
1997
+ return lines.map((line) => truncateToWidth2(line, width));
1679
1998
  }
1680
1999
  invalidate() {
1681
2000
  this.renderedLayout = void 0;
@@ -10,7 +10,7 @@ import {
10
10
  validatePermissionRules,
11
11
  validateSandboxProfileName,
12
12
  validateToolBudgetConfig
13
- } from "./chunk-V2KFIGFH.js";
13
+ } from "./chunk-XAC2XNAP.js";
14
14
 
15
15
  // src/agents/runtime-agent-registry.ts
16
16
  var RUNTIME_AGENT_REGISTRY_KEY = "pi-subagents.runtime-agents.v1";