@esso0428/pi-subagents 0.17.6 → 0.17.7

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 (260) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/CONTRIBUTING.md +4 -0
  3. package/dist/abortable.d.ts +13 -0
  4. package/dist/abortable.d.ts.map +1 -0
  5. package/dist/abortable.js +43 -0
  6. package/dist/abortable.js.map +1 -0
  7. package/dist/agent-color.d.ts +36 -0
  8. package/dist/agent-color.d.ts.map +1 -0
  9. package/dist/agent-color.js +124 -0
  10. package/dist/agent-color.js.map +1 -0
  11. package/dist/agent-file-toggle.d.ts +126 -0
  12. package/dist/agent-file-toggle.d.ts.map +1 -0
  13. package/dist/agent-file-toggle.js +259 -0
  14. package/dist/agent-file-toggle.js.map +1 -0
  15. package/dist/agent-history.d.ts +4 -0
  16. package/dist/agent-history.d.ts.map +1 -1
  17. package/dist/agent-history.js +47 -1
  18. package/dist/agent-history.js.map +1 -1
  19. package/dist/agent-manager.d.ts +370 -56
  20. package/dist/agent-manager.d.ts.map +1 -1
  21. package/dist/agent-manager.js +1123 -409
  22. package/dist/agent-manager.js.map +1 -1
  23. package/dist/agent-runner.d.ts +100 -10
  24. package/dist/agent-runner.d.ts.map +1 -1
  25. package/dist/agent-runner.js +166 -21
  26. package/dist/agent-runner.js.map +1 -1
  27. package/dist/agent-types.d.ts +57 -5
  28. package/dist/agent-types.d.ts.map +1 -1
  29. package/dist/agent-types.js +164 -32
  30. package/dist/agent-types.js.map +1 -1
  31. package/dist/child-context.d.ts +3 -0
  32. package/dist/child-context.d.ts.map +1 -0
  33. package/dist/child-context.js +13 -0
  34. package/dist/child-context.js.map +1 -0
  35. package/dist/cross-extension-rpc.d.ts +23 -3
  36. package/dist/cross-extension-rpc.d.ts.map +1 -1
  37. package/dist/cross-extension-rpc.js +79 -17
  38. package/dist/cross-extension-rpc.js.map +1 -1
  39. package/dist/custom-agents.d.ts +38 -1
  40. package/dist/custom-agents.d.ts.map +1 -1
  41. package/dist/custom-agents.js +164 -12
  42. package/dist/custom-agents.js.map +1 -1
  43. package/dist/index.d.ts +34 -0
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +1908 -495
  46. package/dist/index.js.map +1 -1
  47. package/dist/invocation-config.d.ts +87 -2
  48. package/dist/invocation-config.d.ts.map +1 -1
  49. package/dist/invocation-config.js +71 -3
  50. package/dist/invocation-config.js.map +1 -1
  51. package/dist/mention-clone.d.ts +88 -0
  52. package/dist/mention-clone.d.ts.map +1 -0
  53. package/dist/mention-clone.js +154 -0
  54. package/dist/mention-clone.js.map +1 -0
  55. package/dist/mention.d.ts +82 -0
  56. package/dist/mention.d.ts.map +1 -0
  57. package/dist/mention.js +132 -0
  58. package/dist/mention.js.map +1 -0
  59. package/dist/model-resolver.d.ts +17 -0
  60. package/dist/model-resolver.d.ts.map +1 -1
  61. package/dist/model-resolver.js +15 -0
  62. package/dist/model-resolver.js.map +1 -1
  63. package/dist/model-scope.d.ts +50 -0
  64. package/dist/model-scope.d.ts.map +1 -0
  65. package/dist/model-scope.js +49 -0
  66. package/dist/model-scope.js.map +1 -0
  67. package/dist/nested-tools.d.ts +57 -0
  68. package/dist/nested-tools.d.ts.map +1 -0
  69. package/dist/nested-tools.js +301 -0
  70. package/dist/nested-tools.js.map +1 -0
  71. package/dist/output-file.d.ts +22 -3
  72. package/dist/output-file.d.ts.map +1 -1
  73. package/dist/output-file.js +58 -7
  74. package/dist/output-file.js.map +1 -1
  75. package/dist/prompts.d.ts +23 -0
  76. package/dist/prompts.d.ts.map +1 -1
  77. package/dist/prompts.js +20 -2
  78. package/dist/prompts.js.map +1 -1
  79. package/dist/schedule.d.ts.map +1 -1
  80. package/dist/schedule.js +36 -15
  81. package/dist/schedule.js.map +1 -1
  82. package/dist/settings.d.ts +228 -2
  83. package/dist/settings.d.ts.map +1 -1
  84. package/dist/settings.js +94 -0
  85. package/dist/settings.js.map +1 -1
  86. package/dist/status-note.d.ts +49 -1
  87. package/dist/status-note.d.ts.map +1 -1
  88. package/dist/status-note.js +62 -1
  89. package/dist/status-note.js.map +1 -1
  90. package/dist/structured-output.d.ts +62 -0
  91. package/dist/structured-output.d.ts.map +1 -0
  92. package/dist/structured-output.js +113 -0
  93. package/dist/structured-output.js.map +1 -0
  94. package/dist/types.d.ts +176 -10
  95. package/dist/types.d.ts.map +1 -1
  96. package/dist/ui/agent-mention.d.ts +83 -0
  97. package/dist/ui/agent-mention.d.ts.map +1 -0
  98. package/dist/ui/agent-mention.js +188 -0
  99. package/dist/ui/agent-mention.js.map +1 -0
  100. package/dist/ui/agent-widget.d.ts +96 -75
  101. package/dist/ui/agent-widget.d.ts.map +1 -1
  102. package/dist/ui/agent-widget.js +397 -420
  103. package/dist/ui/agent-widget.js.map +1 -1
  104. package/dist/ui/conversation-blocks.d.ts.map +1 -1
  105. package/dist/ui/conversation-blocks.js +6 -0
  106. package/dist/ui/conversation-blocks.js.map +1 -1
  107. package/dist/ui/conversation-timeline.d.ts +10 -2
  108. package/dist/ui/conversation-timeline.d.ts.map +1 -1
  109. package/dist/ui/conversation-timeline.js +130 -23
  110. package/dist/ui/conversation-timeline.js.map +1 -1
  111. package/dist/ui/conversation-viewer.d.ts +15 -5
  112. package/dist/ui/conversation-viewer.d.ts.map +1 -1
  113. package/dist/ui/conversation-viewer.js +202 -50
  114. package/dist/ui/conversation-viewer.js.map +1 -1
  115. package/dist/ui/fleet-list.d.ts +198 -0
  116. package/dist/ui/fleet-list.d.ts.map +1 -0
  117. package/dist/ui/fleet-list.js +487 -0
  118. package/dist/ui/fleet-list.js.map +1 -0
  119. package/dist/ui/schedule-menu.d.ts.map +1 -1
  120. package/dist/ui/schedule-menu.js +6 -7
  121. package/dist/ui/schedule-menu.js.map +1 -1
  122. package/dist/ui/select-item.d.ts +28 -0
  123. package/dist/ui/select-item.d.ts.map +1 -0
  124. package/dist/ui/select-item.js +35 -0
  125. package/dist/ui/select-item.js.map +1 -0
  126. package/dist/ui/workflow-card.d.ts +176 -0
  127. package/dist/ui/workflow-card.d.ts.map +1 -0
  128. package/dist/ui/workflow-card.js +333 -0
  129. package/dist/ui/workflow-card.js.map +1 -0
  130. package/dist/ui/workflow-dialog.d.ts +306 -0
  131. package/dist/ui/workflow-dialog.d.ts.map +1 -0
  132. package/dist/ui/workflow-dialog.js +844 -0
  133. package/dist/ui/workflow-dialog.js.map +1 -0
  134. package/dist/ui/workflow-menu.d.ts +61 -0
  135. package/dist/ui/workflow-menu.d.ts.map +1 -0
  136. package/dist/ui/workflow-menu.js +148 -0
  137. package/dist/ui/workflow-menu.js.map +1 -0
  138. package/dist/usage.d.ts +86 -1
  139. package/dist/usage.d.ts.map +1 -1
  140. package/dist/usage.js +72 -1
  141. package/dist/usage.js.map +1 -1
  142. package/dist/workflow/collisions.d.ts +96 -0
  143. package/dist/workflow/collisions.d.ts.map +1 -0
  144. package/dist/workflow/collisions.js +89 -0
  145. package/dist/workflow/collisions.js.map +1 -0
  146. package/dist/workflow/entry.d.ts +33 -0
  147. package/dist/workflow/entry.d.ts.map +1 -0
  148. package/dist/workflow/entry.js +30 -0
  149. package/dist/workflow/entry.js.map +1 -0
  150. package/dist/workflow/host.d.ts +63 -0
  151. package/dist/workflow/host.d.ts.map +1 -0
  152. package/dist/workflow/host.js +363 -0
  153. package/dist/workflow/host.js.map +1 -0
  154. package/dist/workflow/journal.d.ts +98 -0
  155. package/dist/workflow/journal.d.ts.map +1 -0
  156. package/dist/workflow/journal.js +121 -0
  157. package/dist/workflow/journal.js.map +1 -0
  158. package/dist/workflow/json-schema.d.ts +52 -0
  159. package/dist/workflow/json-schema.d.ts.map +1 -0
  160. package/dist/workflow/json-schema.js +112 -0
  161. package/dist/workflow/json-schema.js.map +1 -0
  162. package/dist/workflow/meta.d.ts +68 -0
  163. package/dist/workflow/meta.d.ts.map +1 -0
  164. package/dist/workflow/meta.js +318 -0
  165. package/dist/workflow/meta.js.map +1 -0
  166. package/dist/workflow/progress.d.ts +225 -0
  167. package/dist/workflow/progress.d.ts.map +1 -0
  168. package/dist/workflow/progress.js +362 -0
  169. package/dist/workflow/progress.js.map +1 -0
  170. package/dist/workflow/runtime.d.ts +335 -0
  171. package/dist/workflow/runtime.d.ts.map +1 -0
  172. package/dist/workflow/runtime.js +831 -0
  173. package/dist/workflow/runtime.js.map +1 -0
  174. package/dist/workflow/saved.d.ts +91 -0
  175. package/dist/workflow/saved.d.ts.map +1 -0
  176. package/dist/workflow/saved.js +204 -0
  177. package/dist/workflow/saved.js.map +1 -0
  178. package/dist/workflow/task.d.ts +137 -0
  179. package/dist/workflow/task.d.ts.map +1 -0
  180. package/dist/workflow/task.js +208 -0
  181. package/dist/workflow/task.js.map +1 -0
  182. package/dist/workflow/tool-description.d.ts +39 -0
  183. package/dist/workflow/tool-description.d.ts.map +1 -0
  184. package/dist/workflow/tool-description.js +200 -0
  185. package/dist/workflow/tool-description.js.map +1 -0
  186. package/dist/workflow/worker-source.d.ts +48 -0
  187. package/dist/workflow/worker-source.d.ts.map +1 -0
  188. package/dist/workflow/worker-source.js +779 -0
  189. package/dist/workflow/worker-source.js.map +1 -0
  190. package/dist/worktree.d.ts +10 -3
  191. package/dist/worktree.d.ts.map +1 -1
  192. package/dist/worktree.js +58 -54
  193. package/dist/worktree.js.map +1 -1
  194. package/dist/xml.d.ts +11 -0
  195. package/dist/xml.d.ts.map +1 -0
  196. package/dist/xml.js +13 -0
  197. package/dist/xml.js.map +1 -0
  198. package/docs/rpc.md +183 -0
  199. package/docs/superpowers/plans/2026-09-30-upstream-event-workflow-partial-history.md +195 -0
  200. package/docs/superpowers/specs/2026-09-30-upstream-event-workflow-partial-history-design.md +49 -0
  201. package/docs/workflows.md +437 -0
  202. package/examples/agent-tool-description.md +7 -7
  203. package/examples/workflows/compose.js +51 -0
  204. package/examples/workflows/fan-out-audit.js +47 -0
  205. package/examples/workflows/gated-fix.js +60 -0
  206. package/examples/workflows/lib/count-child.js +27 -0
  207. package/examples/workflows/review-panel.js +63 -0
  208. package/examples/workflows/structured-findings.js +78 -0
  209. package/package.json +1 -1
  210. package/src/abortable.ts +43 -0
  211. package/src/agent-color.ts +161 -0
  212. package/src/agent-file-toggle.ts +269 -0
  213. package/src/agent-history.ts +54 -2
  214. package/src/agent-manager.ts +1263 -402
  215. package/src/agent-runner.ts +251 -27
  216. package/src/agent-types.ts +188 -32
  217. package/src/child-context.ts +15 -0
  218. package/src/cross-extension-rpc.ts +96 -20
  219. package/src/custom-agents.ts +170 -13
  220. package/src/index.ts +2024 -537
  221. package/src/invocation-config.ts +118 -3
  222. package/src/mention-clone.ts +196 -0
  223. package/src/mention.ts +141 -0
  224. package/src/model-resolver.ts +18 -0
  225. package/src/model-scope.ts +70 -0
  226. package/src/nested-tools.ts +424 -0
  227. package/src/output-file.ts +61 -6
  228. package/src/prompts.ts +45 -2
  229. package/src/schedule.ts +35 -14
  230. package/src/settings.ts +312 -2
  231. package/src/status-note.ts +66 -1
  232. package/src/structured-output.ts +130 -0
  233. package/src/types.ts +177 -10
  234. package/src/ui/agent-mention.ts +216 -0
  235. package/src/ui/agent-widget.ts +389 -441
  236. package/src/ui/conversation-blocks.ts +6 -0
  237. package/src/ui/conversation-timeline.ts +139 -25
  238. package/src/ui/conversation-viewer.ts +212 -48
  239. package/src/ui/fleet-list.ts +558 -0
  240. package/src/ui/schedule-menu.ts +9 -8
  241. package/src/ui/select-item.ts +45 -0
  242. package/src/ui/workflow-card.ts +470 -0
  243. package/src/ui/workflow-dialog.ts +1115 -0
  244. package/src/ui/workflow-menu.ts +193 -0
  245. package/src/usage.ts +109 -2
  246. package/src/workflow/collisions.ts +123 -0
  247. package/src/workflow/entry.ts +47 -0
  248. package/src/workflow/host.ts +403 -0
  249. package/src/workflow/journal.ts +164 -0
  250. package/src/workflow/json-schema.ts +128 -0
  251. package/src/workflow/meta.ts +325 -0
  252. package/src/workflow/progress.ts +550 -0
  253. package/src/workflow/runtime.ts +1219 -0
  254. package/src/workflow/saved.ts +217 -0
  255. package/src/workflow/task.ts +302 -0
  256. package/src/workflow/tool-description.ts +200 -0
  257. package/src/workflow/worker-source.ts +781 -0
  258. package/src/worktree.ts +69 -55
  259. package/src/xml.ts +13 -0
  260. package/vitest.config.ts +0 -18
@@ -0,0 +1,176 @@
1
+ /**
2
+ * workflow-card.ts — the inline transcript card for a running workflow.
3
+ *
4
+ * ```
5
+ * ▸ Workflow review-changes 3/7 agents · 1m12s
6
+ * Review changed files across dimensions, verify each finding
7
+ * ╭─ Review
8
+ * │ ├─ ✔ review:bugs · Explore · haiku · 18.4k · 12 tool calls · 42s
9
+ * │ ├─ ⟳ review:perf · Explore · 8 tool calls · 21s
10
+ * │ └─ ⟳ review:security
11
+ * ╰─ Verify
12
+ * └─ ⟳ verify:auth.ts · Plan · 3 tool calls · 9s
13
+ * ⎿ scanned 41 changed files
14
+ * ```
15
+ *
16
+ * Two things about this file are easy to get wrong.
17
+ *
18
+ * **The glyphs are not the dialog's glyphs.** The inline row keys off the *raw*
19
+ * entry `state` (start | progress | done | error), not the derived display
20
+ * state, so a skipped or blocked agent renders as a plain ✘ here while the
21
+ * workflows dialog distinguishes them. `displayState` is deliberately not
22
+ * consulted below.
23
+ *
24
+ * **The layout is pure.** `layoutWorkflowCard` returns coloured segments and
25
+ * never touches a theme or a terminal, so the same layout drives the `Workflow`
26
+ * tool's `renderResult` and a standalone session entry (a workflow launched from
27
+ * a CLI flag has no tool call to attach to). Theme application is the thin
28
+ * `styleWorkflowCardLines` wrapper on top.
29
+ *
30
+ * All state derivation lives in `src/workflow/progress.ts`; this file only
31
+ * arranges what that module returns.
32
+ */
33
+ import { Text } from "@earendil-works/pi-tui";
34
+ import type { WorkflowEntryData } from "../workflow/entry.js";
35
+ import type { WorkflowMeta } from "../workflow/meta.js";
36
+ import { type WorkflowAgentEntry, type WorkflowEntry, type WorkflowRunStatus } from "../workflow/progress.js";
37
+ import type { Theme } from "./agent-widget.js";
38
+ /**
39
+ * Header re-render cadence. Claude Code ticks the workflow clock once a second,
40
+ * not at the 80ms spinner cadence — the running glyph is static, so there is
41
+ * nothing to animate faster than the elapsed time changes.
42
+ */
43
+ export declare const WORKFLOW_TICK_MS = 1000;
44
+ export interface WorkflowGlyphs {
45
+ /** Tool-title pointer, matching the Agent tool's `▸`. */
46
+ pointer: string;
47
+ tick: string;
48
+ cross: string;
49
+ /** Running/queued. A static glyph, hence no spinner inline. */
50
+ running: string;
51
+ /** First and subsequent phase groups. */
52
+ groupTop: string;
53
+ /** A group that is neither the first nor the last. */
54
+ groupMid: string;
55
+ /** The last phase group. */
56
+ groupBottom: string;
57
+ /** Continuation rail under a non-final group. */
58
+ vertical: string;
59
+ branch: string;
60
+ lastBranch: string;
61
+ /** Log-line prefix, matching the Agent tool's result lines. */
62
+ log: string;
63
+ warning: string;
64
+ }
65
+ export declare const UNICODE_GLYPHS: WorkflowGlyphs;
66
+ /**
67
+ * The `figures` ASCII tier, for terminals that cannot draw the box set. Every
68
+ * glyph keeps its unicode counterpart's column width so the tree stays aligned
69
+ * either way.
70
+ */
71
+ export declare const ASCII_GLYPHS: WorkflowGlyphs;
72
+ /**
73
+ * pi theme keys. Claude Code's palette maps as success→success, error→error,
74
+ * subtle→dim, permission→warning for a blocked row and accent for selection;
75
+ * an undefined colour means "leave it at the terminal default", which is what
76
+ * the recovered inline mapping asks for on a running row.
77
+ *
78
+ * `accent` is unused by the card and exists for the workflows dialog, which
79
+ * shares these segment types.
80
+ */
81
+ export type WorkflowCardColor = "success" | "error" | "warning" | "dim" | "muted" | "toolTitle" | "accent";
82
+ export interface WorkflowCardSegment {
83
+ text: string;
84
+ color?: WorkflowCardColor;
85
+ bold?: boolean;
86
+ }
87
+ export type WorkflowCardLine = WorkflowCardSegment[];
88
+ /** The subset of the task record the card reads. */
89
+ export interface WorkflowCardTask {
90
+ status: WorkflowRunStatus;
91
+ workflowName?: string;
92
+ summary?: string;
93
+ description?: string;
94
+ startTime: number;
95
+ endTime?: number;
96
+ totalPausedMs?: number;
97
+ }
98
+ export interface WorkflowCardInput {
99
+ progress: readonly WorkflowEntry[];
100
+ task: WorkflowCardTask;
101
+ meta?: WorkflowMeta;
102
+ /** Agents the runtime has scheduled, which can exceed those that have reported. */
103
+ agentCount?: number;
104
+ /** Total tokens for the size warning; summed from the entries when omitted. */
105
+ totalTokens?: number;
106
+ agentCap?: number;
107
+ tokenCap?: number;
108
+ now?: number;
109
+ width?: number;
110
+ /** Swap in the ASCII glyph tier for terminals without unicode. */
111
+ ascii?: boolean;
112
+ /**
113
+ * Lead with `▸ SubagentWorkflow`.
114
+ *
115
+ * True where the card stands alone — the session entry a flag-launched run
116
+ * writes, which has no tool call above it to say what it is. False as a tool
117
+ * result, where the call line directly above already does.
118
+ */
119
+ showToolTitle?: boolean;
120
+ }
121
+ /** `18.4k` / `1.2M` — bare magnitude, since the row already reads as a stat. */
122
+ export declare function formatCompactTokens(count: number): string;
123
+ /**
124
+ * One label for the model pair. A fallback that never differed from the primary
125
+ * would just be noise, so it only shows when the run actually has two models in
126
+ * play.
127
+ */
128
+ export declare function formatModel(entry: WorkflowAgentEntry, opts?: {
129
+ canonical?: boolean;
130
+ }): string | undefined;
131
+ /**
132
+ * The thinking level, and what was asked for when it was not honoured.
133
+ *
134
+ * Separate from {@link formatModel} because a row can have one without the
135
+ * other: an `agent()` that named no model still runs at some level, and a level
136
+ * pi clamped is worth saying so about even when the model is unremarkable.
137
+ */
138
+ export declare function formatThinking(entry: WorkflowAgentEntry): string | undefined;
139
+ /**
140
+ * What a row replayed from a resume journal says instead of a duration.
141
+ *
142
+ * Shared with the dialog so both views name the same thing the same way — the
143
+ * card shows it inline while the run happens, the dialog on the agent's row.
144
+ */
145
+ export declare const REPLAYED_ANNOTATION = "from resume journal";
146
+ /**
147
+ * The `·`-separated tail of an agent row, in the recovered order: agentType,
148
+ * model, tokens, toolCalls, durationMs. Absent values drop out entirely rather
149
+ * than rendering a placeholder.
150
+ */
151
+ export declare function agentStatSegments(entry: WorkflowAgentEntry): string[];
152
+ /** Trim a line to `width`, cutting inside whichever segment crosses the edge. */
153
+ export declare function clampLine(line: WorkflowCardLine, width: number): WorkflowCardLine;
154
+ /**
155
+ * Build the card.
156
+ *
157
+ * Everything derived — the phase tree, the header counts, the logs, the size
158
+ * warning — comes from `progress.ts`; what happens here is purely arrangement.
159
+ */
160
+ export declare function layoutWorkflowCard(input: WorkflowCardInput): WorkflowCardLine[];
161
+ /** The card as plain text — what the layout tests assert against. */
162
+ export declare function plainWorkflowCardLines(lines: readonly WorkflowCardLine[]): string[];
163
+ /** Apply the theme. Nothing here changes the layout, only its colours. */
164
+ export declare function styleWorkflowCardLines(lines: readonly WorkflowCardLine[], theme: Theme): string[];
165
+ /** The card as a component, for a tool result or a session entry renderer. */
166
+ export declare function renderWorkflowCard(input: WorkflowCardInput, theme: Theme): Text;
167
+ /**
168
+ * The card for a session entry, from the JSON a flag-launched run persisted.
169
+ *
170
+ * The same layout the tool result uses, not a second one — the only difference
171
+ * is `showToolTitle`, because a session entry stands alone and nothing above it
172
+ * says what it is. Returns undefined for an entry with no data, which is what
173
+ * pi's renderer contract wants for "nothing to draw".
174
+ */
175
+ export declare function renderWorkflowEntryCard(data: WorkflowEntryData | undefined, theme: Theme): Text | undefined;
176
+ //# sourceMappingURL=workflow-card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-card.d.ts","sourceRoot":"","sources":["../../src/ui/workflow-card.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAA0B,IAAI,EAAiC,MAAM,wBAAwB,CAAC;AACrG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAOL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,m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EAAqE;AACrE,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,GAAG,MAAM,EAAE,CAEnF;AAED,0EAA0E;AAC1E,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE,CASjG;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAE/E;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,CAkB3G"}
@@ -0,0 +1,333 @@
1
+ /**
2
+ * workflow-card.ts — the inline transcript card for a running workflow.
3
+ *
4
+ * ```
5
+ * ▸ Workflow review-changes 3/7 agents · 1m12s
6
+ * Review changed files across dimensions, verify each finding
7
+ * ╭─ Review
8
+ * │ ├─ ✔ review:bugs · Explore · haiku · 18.4k · 12 tool calls · 42s
9
+ * │ ├─ ⟳ review:perf · Explore · 8 tool calls · 21s
10
+ * │ └─ ⟳ review:security
11
+ * ╰─ Verify
12
+ * └─ ⟳ verify:auth.ts · Plan · 3 tool calls · 9s
13
+ * ⎿ scanned 41 changed files
14
+ * ```
15
+ *
16
+ * Two things about this file are easy to get wrong.
17
+ *
18
+ * **The glyphs are not the dialog's glyphs.** The inline row keys off the *raw*
19
+ * entry `state` (start | progress | done | error), not the derived display
20
+ * state, so a skipped or blocked agent renders as a plain ✘ here while the
21
+ * workflows dialog distinguishes them. `displayState` is deliberately not
22
+ * consulted below.
23
+ *
24
+ * **The layout is pure.** `layoutWorkflowCard` returns coloured segments and
25
+ * never touches a theme or a terminal, so the same layout drives the `Workflow`
26
+ * tool's `renderResult` and a standalone session entry (a workflow launched from
27
+ * a CLI flag has no tool call to attach to). Theme application is the thin
28
+ * `styleWorkflowCardLines` wrapper on top.
29
+ *
30
+ * All state derivation lives in `src/workflow/progress.ts`; this file only
31
+ * arranges what that module returns.
32
+ */
33
+ import { stripTerminalSequences, Text, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
34
+ import { buildPhaseGroups, collapse, formatDuration, header, sizeWarning, stats, } from "../workflow/progress.js";
35
+ /**
36
+ * Header re-render cadence. Claude Code ticks the workflow clock once a second,
37
+ * not at the 80ms spinner cadence — the running glyph is static, so there is
38
+ * nothing to animate faster than the elapsed time changes.
39
+ */
40
+ export const WORKFLOW_TICK_MS = 1000;
41
+ /** Widest label column before stats stop being aligned and just follow the label. */
42
+ const LABEL_COLUMN_MAX = 28;
43
+ /** Fallback width when the caller does not know the terminal's. */
44
+ const DEFAULT_WIDTH = 80;
45
+ export const UNICODE_GLYPHS = {
46
+ pointer: "▸",
47
+ tick: "✔",
48
+ cross: "✘",
49
+ running: "⟳",
50
+ groupTop: "╭─",
51
+ groupMid: "├─",
52
+ groupBottom: "╰─",
53
+ vertical: "│",
54
+ branch: "├─",
55
+ lastBranch: "└─",
56
+ log: "⎿",
57
+ warning: "⚠",
58
+ };
59
+ /**
60
+ * The `figures` ASCII tier, for terminals that cannot draw the box set. Every
61
+ * glyph keeps its unicode counterpart's column width so the tree stays aligned
62
+ * either way.
63
+ */
64
+ export const ASCII_GLYPHS = {
65
+ pointer: ">",
66
+ tick: "√",
67
+ cross: "×",
68
+ running: "*",
69
+ groupTop: ",-",
70
+ groupMid: "|-",
71
+ groupBottom: "`-",
72
+ vertical: "|",
73
+ branch: "|-",
74
+ lastBranch: "`-",
75
+ log: "\\",
76
+ warning: "!",
77
+ };
78
+ /* ------------------------------------------------------------------------- *
79
+ * Formatting
80
+ * ------------------------------------------------------------------------- */
81
+ /** `18.4k` / `1.2M` — bare magnitude, since the row already reads as a stat. */
82
+ export function formatCompactTokens(count) {
83
+ if (count >= 1_000_000)
84
+ return `${(count / 1_000_000).toFixed(1)}M`;
85
+ if (count >= 1_000)
86
+ return `${(count / 1_000).toFixed(1)}k`;
87
+ return `${count}`;
88
+ }
89
+ /**
90
+ * One label for the model pair. A fallback that never differed from the primary
91
+ * would just be noise, so it only shows when the run actually has two models in
92
+ * play.
93
+ */
94
+ export function formatModel(entry, opts) {
95
+ const { fallbackModel, requestedModel } = entry;
96
+ // `canonical` is for surfaces with the width for `provider/model-id`; the
97
+ // tight rows take the short label. Chosen here rather than by the caller
98
+ // swapping fields, which would leave `fallbackModel` in the other spelling.
99
+ const model = opts?.canonical ? entry.modelId ?? entry.model : entry.model;
100
+ const primary = model && fallbackModel && model !== fallbackModel ? `${model}→${fallbackModel}` : model ?? fallbackModel;
101
+ if (primary === undefined)
102
+ return undefined;
103
+ // Disclosed rather than substituted: a model an agent file pinned over the
104
+ // script's is still a model the script did not get (#182). Same rule as
105
+ // `buildInvocationTags`' `asked()` — only when the two actually differ, so a
106
+ // request that was honoured says nothing.
107
+ return requestedModel !== undefined && requestedModel !== primary
108
+ ? `${primary} (asked ${requestedModel})`
109
+ : primary;
110
+ }
111
+ /**
112
+ * The thinking level, and what was asked for when it was not honoured.
113
+ *
114
+ * Separate from {@link formatModel} because a row can have one without the
115
+ * other: an `agent()` that named no model still runs at some level, and a level
116
+ * pi clamped is worth saying so about even when the model is unremarkable.
117
+ */
118
+ export function formatThinking(entry) {
119
+ const { thinking, requestedThinking } = entry;
120
+ if (!thinking)
121
+ return undefined;
122
+ return requestedThinking !== undefined && requestedThinking !== thinking
123
+ ? `thinking: ${thinking} (asked ${requestedThinking})`
124
+ : `thinking: ${thinking}`;
125
+ }
126
+ /**
127
+ * What a row replayed from a resume journal says instead of a duration.
128
+ *
129
+ * Shared with the dialog so both views name the same thing the same way — the
130
+ * card shows it inline while the run happens, the dialog on the agent's row.
131
+ */
132
+ export const REPLAYED_ANNOTATION = "from resume journal";
133
+ /**
134
+ * The `·`-separated tail of an agent row, in the recovered order: agentType,
135
+ * model, tokens, toolCalls, durationMs. Absent values drop out entirely rather
136
+ * than rendering a placeholder.
137
+ */
138
+ export function agentStatSegments(entry) {
139
+ const parts = [];
140
+ if (entry.agentType)
141
+ parts.push(entry.agentType);
142
+ const model = formatModel(entry);
143
+ if (model)
144
+ parts.push(model);
145
+ if (entry.tokens)
146
+ parts.push(formatCompactTokens(entry.tokens));
147
+ if (entry.toolCalls)
148
+ parts.push(`${entry.toolCalls} tool call${entry.toolCalls === 1 ? "" : "s"}`);
149
+ if (entry.durationMs)
150
+ parts.push(formatDuration(entry.durationMs));
151
+ return parts;
152
+ }
153
+ /**
154
+ * The recovered inline mapping — keyed on the raw entry state. `skipped` and
155
+ * `blocked` are not distinguished here; that is the dialog's job.
156
+ */
157
+ function rowGlyph(entry, glyphs) {
158
+ if (entry.state === "done")
159
+ return { text: glyphs.tick, color: "success" };
160
+ if (entry.state === "error")
161
+ return { text: glyphs.cross, color: "error" };
162
+ return { text: glyphs.running };
163
+ }
164
+ /* ------------------------------------------------------------------------- *
165
+ * Layout
166
+ * ------------------------------------------------------------------------- */
167
+ /** Trim a line to `width`, cutting inside whichever segment crosses the edge. */
168
+ export function clampLine(line, width) {
169
+ const clamped = [];
170
+ let used = 0;
171
+ for (const segment of line) {
172
+ const segmentWidth = visibleWidth(segment.text);
173
+ if (used + segmentWidth <= width) {
174
+ clamped.push(segment);
175
+ used += segmentWidth;
176
+ continue;
177
+ }
178
+ const room = width - used;
179
+ // truncateToWidth wraps its ellipsis in resets, which would leak escape
180
+ // codes into a layout that is supposed to be plain text until it is themed.
181
+ if (room > 0) {
182
+ clamped.push({ ...segment, text: stripTerminalSequences(truncateToWidth(segment.text, room, "…")) });
183
+ }
184
+ return clamped;
185
+ }
186
+ return clamped;
187
+ }
188
+ const lineWidth = (line) => line.reduce((sum, s) => sum + visibleWidth(s.text), 0);
189
+ /**
190
+ * Build the card.
191
+ *
192
+ * Everything derived — the phase tree, the header counts, the logs, the size
193
+ * warning — comes from `progress.ts`; what happens here is purely arrangement.
194
+ */
195
+ export function layoutWorkflowCard(input) {
196
+ const glyphs = input.ascii ? ASCII_GLYPHS : UNICODE_GLYPHS;
197
+ const width = Math.max(1, input.width ?? DEFAULT_WIDTH);
198
+ const now = input.now ?? Date.now();
199
+ const groups = buildPhaseGroups(input.progress, input.meta?.phases);
200
+ const { agents, logs } = collapse(input.progress);
201
+ const totals = stats(input.progress, input.agentCount ?? 0);
202
+ const head = header(input.task, input.meta, groups, input.agentCount ?? 0, now);
203
+ const lines = [];
204
+ // ---- Header: `<name>` with the stats flush right ----
205
+ // The tool name appears only when nothing above the card already carries it.
206
+ // As a tool result there is a `▸ SubagentWorkflow …` call line directly above,
207
+ // and repeating it put two near-identical pointer lines back to back.
208
+ const left = input.showToolTitle
209
+ ? [
210
+ { text: `${glyphs.pointer} `, color: "toolTitle" },
211
+ { text: "SubagentWorkflow", color: "toolTitle", bold: true },
212
+ { text: " " },
213
+ { text: head.name, color: "muted" },
214
+ ]
215
+ : [{ text: " " }, { text: head.name, color: "toolTitle", bold: true }];
216
+ const statsWidth = visibleWidth(head.stats);
217
+ const clampedLeft = clampLine(left, Math.max(0, width - statsWidth - 1));
218
+ const gap = Math.max(1, width - lineWidth(clampedLeft) - statsWidth);
219
+ lines.push([...clampedLeft, { text: " ".repeat(gap) }, { text: head.stats, color: "dim" }]);
220
+ if (head.subtext)
221
+ lines.push(clampLine([{ text: ` ${head.subtext}`, color: "dim" }], width));
222
+ // ---- Phase tree ----
223
+ // Stats line up in one column across the whole card, not per group, so the
224
+ // eye can scan them; a label past the cap just pushes its own stats along.
225
+ const labelColumn = Math.min(LABEL_COLUMN_MAX, Math.max(0, ...groups.flatMap(group => group.agents.map(a => visibleWidth(a.label)))));
226
+ groups.forEach((group, groupIndex) => {
227
+ const lastGroup = groupIndex === groups.length - 1;
228
+ lines.push(clampLine([
229
+ { text: " " },
230
+ // One box, not a stack of them: only the first group opens it and
231
+ // only the last closes it. Everything between branches off the side,
232
+ // or three phases read as three half-drawn boxes.
233
+ {
234
+ text: `${lastGroup ? glyphs.groupBottom
235
+ : groupIndex === 0 ? glyphs.groupTop
236
+ : glyphs.groupMid} `,
237
+ color: "dim",
238
+ },
239
+ { text: group.title },
240
+ ], width));
241
+ const rail = lastGroup ? " " : `${glyphs.vertical} `;
242
+ group.agents.forEach((entry, agentIndex) => {
243
+ const lastAgent = agentIndex === group.agents.length - 1;
244
+ const segments = [
245
+ { text: " " },
246
+ { text: rail, color: "dim" },
247
+ { text: `${lastAgent ? glyphs.lastBranch : glyphs.branch} `, color: "dim" },
248
+ rowGlyph(entry, glyphs),
249
+ { text: " " },
250
+ ];
251
+ // Prepended rather than folded into `agentStatSegments`, which is the
252
+ // ported stat tail in its recovered order. A replayed agent otherwise
253
+ // renders as a tick with no tokens and no duration — indistinguishable
254
+ // from one that somehow did the work for free.
255
+ const statParts = entry.cached
256
+ ? [REPLAYED_ANNOTATION, ...agentStatSegments(entry)]
257
+ : agentStatSegments(entry);
258
+ const pad = Math.max(0, labelColumn - visibleWidth(entry.label));
259
+ segments.push({ text: statParts.length > 0 ? entry.label + " ".repeat(pad) : entry.label });
260
+ for (const part of statParts) {
261
+ segments.push({ text: " · ", color: "dim" }, { text: part, color: "dim" });
262
+ }
263
+ lines.push(clampLine(segments, width));
264
+ });
265
+ });
266
+ // ---- log() output, below the tree ----
267
+ for (const message of logs) {
268
+ const [first, ...rest] = message.split("\n");
269
+ lines.push(clampLine([{ text: ` ${glyphs.log} ${first}`, color: "dim" }], width));
270
+ for (const continuation of rest) {
271
+ lines.push(clampLine([{ text: ` ${continuation}`, color: "dim" }], width));
272
+ }
273
+ }
274
+ // ---- Size warning ----
275
+ const totalTokens = input.totalTokens ?? agents.reduce((sum, entry) => sum + (entry.tokens ?? 0), 0);
276
+ const warning = sizeWarning({
277
+ scheduledAgents: Math.max(input.agentCount ?? 0, totals.total),
278
+ startedAgents: totals.started,
279
+ totalTokens,
280
+ agentCap: input.agentCap,
281
+ tokenCap: input.tokenCap,
282
+ });
283
+ if (warning) {
284
+ lines.push(clampLine([{ text: ` ${glyphs.warning} Large workflow · /agents → Workflows to stop`, color: "warning" }], width));
285
+ }
286
+ return lines;
287
+ }
288
+ /* ------------------------------------------------------------------------- *
289
+ * Rendering
290
+ * ------------------------------------------------------------------------- */
291
+ /** The card as plain text — what the layout tests assert against. */
292
+ export function plainWorkflowCardLines(lines) {
293
+ return lines.map(line => line.map(segment => segment.text).join(""));
294
+ }
295
+ /** Apply the theme. Nothing here changes the layout, only its colours. */
296
+ export function styleWorkflowCardLines(lines, theme) {
297
+ return lines.map(line => line
298
+ .map(segment => {
299
+ const text = segment.bold ? theme.bold(segment.text) : segment.text;
300
+ return segment.color ? theme.fg(segment.color, text) : text;
301
+ })
302
+ .join(""));
303
+ }
304
+ /** The card as a component, for a tool result or a session entry renderer. */
305
+ export function renderWorkflowCard(input, theme) {
306
+ return new Text(styleWorkflowCardLines(layoutWorkflowCard(input), theme).join("\n"), 0, 0);
307
+ }
308
+ /**
309
+ * The card for a session entry, from the JSON a flag-launched run persisted.
310
+ *
311
+ * The same layout the tool result uses, not a second one — the only difference
312
+ * is `showToolTitle`, because a session entry stands alone and nothing above it
313
+ * says what it is. Returns undefined for an entry with no data, which is what
314
+ * pi's renderer contract wants for "nothing to draw".
315
+ */
316
+ export function renderWorkflowEntryCard(data, theme) {
317
+ if (!data)
318
+ return undefined;
319
+ return renderWorkflowCard({
320
+ progress: data.progress,
321
+ task: {
322
+ status: data.status,
323
+ workflowName: data.name,
324
+ startTime: data.startTime,
325
+ endTime: data.endTime,
326
+ },
327
+ meta: data.meta,
328
+ agentCount: data.agentCount,
329
+ totalTokens: data.totalTokens,
330
+ showToolTitle: true,
331
+ }, theme);
332
+ }
333
+ //# sourceMappingURL=workflow-card.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-card.js","sourceRoot":"","sources":["../../src/ui/workflow-card.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,sBAAsB,EAAE,IAAI,EAAE,eAAe,EAAE,YAA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