@timmyjl12/pi-subagents 0.0.0-stage → 0.20.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 (218) hide show
  1. package/CHANGELOG.md +827 -0
  2. package/CONTRIBUTING.md +72 -0
  3. package/LICENSE +21 -0
  4. package/README.md +1079 -2
  5. package/SECURITY.md +97 -0
  6. package/dist/abortable.d.ts +12 -0
  7. package/dist/abortable.js +42 -0
  8. package/dist/active-agents-prompt.d.ts +18 -0
  9. package/dist/active-agents-prompt.js +34 -0
  10. package/dist/advisor-status.d.ts +16 -0
  11. package/dist/advisor-status.js +74 -0
  12. package/dist/agent-color.d.ts +35 -0
  13. package/dist/agent-color.js +123 -0
  14. package/dist/agent-file-toggle.d.ts +125 -0
  15. package/dist/agent-file-toggle.js +264 -0
  16. package/dist/agent-manager.d.ts +485 -0
  17. package/dist/agent-manager.js +1380 -0
  18. package/dist/agent-runner.d.ts +319 -0
  19. package/dist/agent-runner.js +1128 -0
  20. package/dist/agent-types.d.ts +119 -0
  21. package/dist/agent-types.js +286 -0
  22. package/dist/child-context.d.ts +15 -0
  23. package/dist/child-context.js +181 -0
  24. package/dist/child-session-shutdown.d.ts +3 -0
  25. package/dist/child-session-shutdown.js +48 -0
  26. package/dist/context.d.ts +12 -0
  27. package/dist/context.js +56 -0
  28. package/dist/cross-extension-rpc.d.ts +66 -0
  29. package/dist/cross-extension-rpc.js +138 -0
  30. package/dist/custom-agents.d.ts +54 -0
  31. package/dist/custom-agents.js +386 -0
  32. package/dist/default-agents.d.ts +7 -0
  33. package/dist/default-agents.js +125 -0
  34. package/dist/enabled-models.d.ts +49 -0
  35. package/dist/enabled-models.js +145 -0
  36. package/dist/env.d.ts +6 -0
  37. package/dist/env.js +28 -0
  38. package/dist/error-log.d.ts +58 -0
  39. package/dist/error-log.js +168 -0
  40. package/dist/group-join.d.ts +32 -0
  41. package/dist/group-join.js +116 -0
  42. package/dist/index.d.ts +52 -0
  43. package/dist/index.js +3896 -0
  44. package/dist/invocation-config.d.ts +137 -0
  45. package/dist/invocation-config.js +129 -0
  46. package/dist/memory.d.ts +53 -0
  47. package/dist/memory.js +165 -0
  48. package/dist/mention-clone.d.ts +87 -0
  49. package/dist/mention-clone.js +178 -0
  50. package/dist/mention.d.ts +81 -0
  51. package/dist/mention.js +131 -0
  52. package/dist/model-resolver.d.ts +36 -0
  53. package/dist/model-resolver.js +95 -0
  54. package/dist/model-scope.d.ts +49 -0
  55. package/dist/model-scope.js +48 -0
  56. package/dist/nested-tools.d.ts +55 -0
  57. package/dist/nested-tools.js +299 -0
  58. package/dist/output-diagnostics.d.ts +11 -0
  59. package/dist/output-diagnostics.js +64 -0
  60. package/dist/output-file.d.ts +53 -0
  61. package/dist/output-file.js +248 -0
  62. package/dist/prompts.d.ts +61 -0
  63. package/dist/prompts.js +94 -0
  64. package/dist/recovery.d.ts +56 -0
  65. package/dist/recovery.js +341 -0
  66. package/dist/schedule-store.d.ts +44 -0
  67. package/dist/schedule-store.js +210 -0
  68. package/dist/schedule.d.ts +109 -0
  69. package/dist/schedule.js +359 -0
  70. package/dist/settings.d.ts +360 -0
  71. package/dist/settings.js +251 -0
  72. package/dist/skill-loader.d.ts +24 -0
  73. package/dist/skill-loader.js +93 -0
  74. package/dist/standalone-fallback.d.ts +30 -0
  75. package/dist/standalone-fallback.js +239 -0
  76. package/dist/status-note.d.ts +61 -0
  77. package/dist/status-note.js +85 -0
  78. package/dist/structured-output.d.ts +61 -0
  79. package/dist/structured-output.js +112 -0
  80. package/dist/terminal-progress.d.ts +115 -0
  81. package/dist/terminal-progress.js +206 -0
  82. package/dist/types.d.ts +382 -0
  83. package/dist/types.js +5 -0
  84. package/dist/ui/agent-mention.d.ts +82 -0
  85. package/dist/ui/agent-mention.js +187 -0
  86. package/dist/ui/agent-widget.d.ts +235 -0
  87. package/dist/ui/agent-widget.js +652 -0
  88. package/dist/ui/conversation-viewer.d.ts +105 -0
  89. package/dist/ui/conversation-viewer.js +540 -0
  90. package/dist/ui/fleet-list.d.ts +183 -0
  91. package/dist/ui/fleet-list.js +494 -0
  92. package/dist/ui/fleet-overlay.d.ts +172 -0
  93. package/dist/ui/fleet-overlay.js +691 -0
  94. package/dist/ui/native-transcript.d.ts +33 -0
  95. package/dist/ui/native-transcript.js +230 -0
  96. package/dist/ui/schedule-menu.d.ts +16 -0
  97. package/dist/ui/schedule-menu.js +94 -0
  98. package/dist/ui/select-item.d.ts +27 -0
  99. package/dist/ui/select-item.js +34 -0
  100. package/dist/ui/tool-progress.d.ts +22 -0
  101. package/dist/ui/tool-progress.js +56 -0
  102. package/dist/ui/viewer-keys.d.ts +20 -0
  103. package/dist/ui/viewer-keys.js +17 -0
  104. package/dist/ui/workflow-card.d.ts +175 -0
  105. package/dist/ui/workflow-card.js +332 -0
  106. package/dist/ui/workflow-dialog.d.ts +305 -0
  107. package/dist/ui/workflow-dialog.js +843 -0
  108. package/dist/ui/workflow-menu.d.ts +60 -0
  109. package/dist/ui/workflow-menu.js +147 -0
  110. package/dist/usage.d.ts +135 -0
  111. package/dist/usage.js +120 -0
  112. package/dist/workflow/collisions.d.ts +95 -0
  113. package/dist/workflow/collisions.js +88 -0
  114. package/dist/workflow/entry.d.ts +32 -0
  115. package/dist/workflow/entry.js +29 -0
  116. package/dist/workflow/host.d.ts +62 -0
  117. package/dist/workflow/host.js +363 -0
  118. package/dist/workflow/journal.d.ts +97 -0
  119. package/dist/workflow/journal.js +120 -0
  120. package/dist/workflow/json-schema.d.ts +51 -0
  121. package/dist/workflow/json-schema.js +111 -0
  122. package/dist/workflow/meta.d.ts +67 -0
  123. package/dist/workflow/meta.js +317 -0
  124. package/dist/workflow/progress.d.ts +224 -0
  125. package/dist/workflow/progress.js +361 -0
  126. package/dist/workflow/runtime.d.ts +334 -0
  127. package/dist/workflow/runtime.js +830 -0
  128. package/dist/workflow/saved.d.ts +90 -0
  129. package/dist/workflow/saved.js +203 -0
  130. package/dist/workflow/task.d.ts +136 -0
  131. package/dist/workflow/task.js +207 -0
  132. package/dist/workflow/tool-description.d.ts +38 -0
  133. package/dist/workflow/tool-description.js +199 -0
  134. package/dist/workflow/worker-source.d.ts +47 -0
  135. package/dist/workflow/worker-source.js +778 -0
  136. package/dist/worktree.d.ts +52 -0
  137. package/dist/worktree.js +164 -0
  138. package/dist/xml.d.ts +10 -0
  139. package/dist/xml.js +12 -0
  140. package/docs/FORK.md +40 -0
  141. package/docs/recovery.md +62 -0
  142. package/docs/rpc.md +189 -0
  143. package/docs/workflows.md +437 -0
  144. package/examples/agent-tool-description.md +43 -0
  145. package/examples/workflows/compose.js +51 -0
  146. package/examples/workflows/fan-out-audit.js +47 -0
  147. package/examples/workflows/gated-fix.js +60 -0
  148. package/examples/workflows/lib/count-child.js +27 -0
  149. package/examples/workflows/review-panel.js +63 -0
  150. package/examples/workflows/structured-findings.js +78 -0
  151. package/package.json +75 -6
  152. package/src/abortable.ts +43 -0
  153. package/src/active-agents-prompt.ts +39 -0
  154. package/src/advisor-status.ts +74 -0
  155. package/src/agent-color.ts +161 -0
  156. package/src/agent-file-toggle.ts +273 -0
  157. package/src/agent-manager.ts +1601 -0
  158. package/src/agent-runner.ts +1372 -0
  159. package/src/agent-types.ts +345 -0
  160. package/src/child-context.ts +173 -0
  161. package/src/child-session-shutdown.ts +46 -0
  162. package/src/context.ts +58 -0
  163. package/src/cross-extension-rpc.ts +198 -0
  164. package/src/custom-agents.ts +417 -0
  165. package/src/default-agents.ts +129 -0
  166. package/src/enabled-models.ts +180 -0
  167. package/src/env.ts +33 -0
  168. package/src/error-log.ts +193 -0
  169. package/src/group-join.ts +141 -0
  170. package/src/index.ts +4218 -0
  171. package/src/invocation-config.ts +230 -0
  172. package/src/memory.ts +179 -0
  173. package/src/mention-clone.ts +221 -0
  174. package/src/mention.ts +141 -0
  175. package/src/model-resolver.ts +118 -0
  176. package/src/model-scope.ts +70 -0
  177. package/src/nested-tools.ts +422 -0
  178. package/src/output-diagnostics.ts +68 -0
  179. package/src/output-file.ts +258 -0
  180. package/src/prompts.ts +151 -0
  181. package/src/recovery.ts +320 -0
  182. package/src/schedule-store.ts +201 -0
  183. package/src/schedule.ts +386 -0
  184. package/src/settings.ts +587 -0
  185. package/src/skill-loader.ts +102 -0
  186. package/src/standalone-fallback.ts +195 -0
  187. package/src/status-note.ts +90 -0
  188. package/src/structured-output.ts +130 -0
  189. package/src/terminal-progress.ts +215 -0
  190. package/src/types.ts +394 -0
  191. package/src/ui/agent-mention.ts +216 -0
  192. package/src/ui/agent-widget.ts +732 -0
  193. package/src/ui/conversation-viewer.ts +523 -0
  194. package/src/ui/fleet-list.ts +563 -0
  195. package/src/ui/fleet-overlay.ts +847 -0
  196. package/src/ui/native-transcript.ts +220 -0
  197. package/src/ui/schedule-menu.ts +105 -0
  198. package/src/ui/select-item.ts +45 -0
  199. package/src/ui/tool-progress.ts +67 -0
  200. package/src/ui/viewer-keys.ts +39 -0
  201. package/src/ui/workflow-card.ts +470 -0
  202. package/src/ui/workflow-dialog.ts +1115 -0
  203. package/src/ui/workflow-menu.ts +193 -0
  204. package/src/usage.ts +167 -0
  205. package/src/workflow/collisions.ts +123 -0
  206. package/src/workflow/entry.ts +47 -0
  207. package/src/workflow/host.ts +404 -0
  208. package/src/workflow/journal.ts +164 -0
  209. package/src/workflow/json-schema.ts +128 -0
  210. package/src/workflow/meta.ts +325 -0
  211. package/src/workflow/progress.ts +550 -0
  212. package/src/workflow/runtime.ts +1219 -0
  213. package/src/workflow/saved.ts +217 -0
  214. package/src/workflow/task.ts +302 -0
  215. package/src/workflow/tool-description.ts +200 -0
  216. package/src/workflow/worker-source.ts +781 -0
  217. package/src/worktree.ts +205 -0
  218. package/src/xml.ts +13 -0
@@ -0,0 +1,172 @@
1
+ /**
2
+ * fleet-overlay.ts — model-picker-style two-pane fleet overlay.
3
+ *
4
+ * The full-screen counterpart to the below-editor FleetView list
5
+ * (`fleet-list.ts`, which stays the compact glanceable surface). Frame, top to
6
+ * bottom:
7
+ *
8
+ * ```
9
+ * ╭─ Subagents ─────────────────── 9 agents · 4 workflows ─╮
10
+ * │ │
11
+ * ├─ Fleet ────────────────┬───────────────────────────────┤
12
+ * │ ▾ Running 2 │ ● general-purpose │
13
+ * │ ❯ ● general-purpose … │ Sleep then report 2 │
14
+ * │ ● Explore find thing│ ───────── │
15
+ * │ ▾ Failed 1 │ Type general-purpose │
16
+ * │ ▾ Completed 1 │ Status running │
17
+ * │ │ Model provider/model │
18
+ * ├────────────────────────┴───────────────────────────────┤
19
+ * │ ↑↓ move · enter open · d dismiss · esc close │
20
+ * ╰────────────────────────────────────────────────────────╯
21
+ * ```
22
+ *
23
+ * Left pane: the complete session roster — running, paused, failed and
24
+ * completed runs, grouped into sections (headers are display-only, the cursor
25
+ * skips them). Unlike the widget, completed/failed agents do not drop out after
26
+ * a few seconds; rows live until the manager sweeps settled records (~10
27
+ * minutes after settle — see agent-manager.ts `cleanup()`), matching the
28
+ * retention the workflow dialog already documents. The manager is untouched:
29
+ * dismissal from this list (`d`) is an overlay-local view filter.
30
+ *
31
+ * Right pane: a detail card for the selected entry — type, description, status,
32
+ * model, thinking, elapsed, tokens, cost (when the `showCost` setting is on),
33
+ * and a short activity/result tail. Enter opens the existing full surface for
34
+ * the entry — the conversation overlay for an agent, the workflow inspector for
35
+ * a run — stacked over this one; Esc there returns here.
36
+ *
37
+ * Narrow terminals (below {@link TWO_PANE_MIN_WIDTH} columns) drop the left
38
+ * pane entirely: the detail card renders full width and carries a position
39
+ * marker (`3 of 9`), so the roster is still navigable by ↑/↓ without ever
40
+ * seeing the list — the same trade the model picker makes for its facet pane.
41
+ *
42
+ * Frame geometry mirrors the model picker's discipline (pi-model-picker
43
+ * src/picker.ts): a fixed chrome budget around one body, a target height of a
44
+ * fraction of the terminal capped at `rows - 2`, and an internal render floor
45
+ * of {@link MIN_RENDER_WIDTH} columns with narrower requests clipped back — so
46
+ * the frame never exceeds terminal width or height. Rendering uses pi-tui
47
+ * primitives and the structural widget `Theme` (fg/bold) only — no sibling
48
+ * imports, no hardcoded colors.
49
+ */
50
+ import { type Component, type Focusable } from "@earendil-works/pi-tui";
51
+ import type { AgentRecord } from "../types.js";
52
+ import { type AgentActivity, type Theme } from "./agent-widget.js";
53
+ import { type FleetWorkflow } from "./fleet-list.js";
54
+ /** Below this the left pane is dropped and the detail card runs full width. */
55
+ export declare const TWO_PANE_MIN_WIDTH = 72;
56
+ /**
57
+ * Internal rendering floor. A narrower request is laid out at this width and
58
+ * clipped back, so the layout arithmetic never degenerates.
59
+ */
60
+ export declare const MIN_RENDER_WIDTH = 40;
61
+ /**
62
+ * Total frame height for a terminal of `terminalRows`, including chrome.
63
+ * Mirrored from the model picker's guard: capped at `rows - 2` so the frame is
64
+ * never clipped by the overlay host, floored at one body row so the layout math
65
+ * always has somewhere to draw.
66
+ */
67
+ export declare function overlayHeightFor(terminalRows: number): number;
68
+ export type RosterEntry = {
69
+ readonly kind: "workflow";
70
+ readonly workflow: FleetWorkflow;
71
+ } | {
72
+ readonly kind: "agent";
73
+ readonly record: AgentRecord;
74
+ };
75
+ /** What the overlay reads from the host; every source is pulled live per render. */
76
+ export interface FleetOverlayDeps {
77
+ /** Render pump; the real pi `TUI` satisfies this structurally. */
78
+ readonly tui: {
79
+ requestRender(): void;
80
+ terminal: {
81
+ rows: number;
82
+ columns: number;
83
+ };
84
+ };
85
+ readonly theme: Theme;
86
+ /**
87
+ * Top-level agent records for the session; read on every render. Records
88
+ * without a session are filtered here (nothing to open behind them) — they
89
+ * are typically queued and row into view once they start.
90
+ */
91
+ readonly records: () => AgentRecord[];
92
+ /** Workflow runs as the fleet list sees them. */
93
+ readonly workflows: () => readonly FleetWorkflow[];
94
+ /** Live activity per running agent id, for the detail card's tail. */
95
+ readonly activity: ReadonlyMap<string, AgentActivity>;
96
+ /** Whether the detail card shows an estimated cost. Read per render. */
97
+ readonly showCost: () => boolean;
98
+ /** Opens the full conversation overlay for an agent, stacked over this one. */
99
+ readonly openAgent: (record: AgentRecord) => Promise<void> | void;
100
+ /** Opens the workflow inspector for a run, stacked over this one. */
101
+ readonly openWorkflow: (id: string) => Promise<void> | void;
102
+ readonly done: (result: undefined) => void;
103
+ readonly notify?: (message: string, type?: "info" | "warning" | "error") => void;
104
+ }
105
+ /**
106
+ * The fleet overlay. See the file header for the frame layout and the
107
+ * roster → detail navigation model.
108
+ */
109
+ export declare class FleetOverlay implements Component, Focusable {
110
+ private readonly deps;
111
+ private readonly theme;
112
+ private readonly glyphs;
113
+ /** `agent:<id>` / `workflow:<id>` of the highlighted row — key, never index. */
114
+ private selectedKey;
115
+ /** Fallback position when the keyed row is gone; the nearest survivor keeps the cursor. */
116
+ private selectedIndex;
117
+ private windowStart;
118
+ /** Settled rows the user dismissed from this view; overlay-local, manager untouched. */
119
+ private readonly dismissed;
120
+ private closed;
121
+ private layout;
122
+ private readonly timer;
123
+ private focusedFlag;
124
+ constructor(deps: FleetOverlayDeps);
125
+ get focused(): boolean;
126
+ set focused(value: boolean);
127
+ /**
128
+ * The full session roster. No linger cutoff — that window is the widget's
129
+ * glance behavior, not a property of the records; the manager keeps settled
130
+ * records long enough (~10 min) for this list to read as history.
131
+ */
132
+ private agentRecords;
133
+ /** Flat row list: section headers interleaved, entries newest-first within. */
134
+ private buildRows;
135
+ private entriesOf;
136
+ /** Re-seat the selection on the same key; a removed row falls to the nearest survivor. */
137
+ private reconcile;
138
+ private selectedEntry;
139
+ private move;
140
+ /** Pan the roster window so the highlighted entry's row is inside it. */
141
+ private ensureSelectionVisible;
142
+ /**
143
+ * Hand control back to the caller, which closes and disposes the overlay.
144
+ * Same done semantics as the conversation viewer: resolve with `undefined`.
145
+ */
146
+ private finish;
147
+ /** After a stacked view closes: put the cursor back on the entry it came from. */
148
+ private afterStackedClose;
149
+ private activate;
150
+ /** Remove the selected settled row from this view. Running work is not dismissible. */
151
+ private dismissSelected;
152
+ handleInput(data: string): void;
153
+ private terminalRows;
154
+ private layoutFor;
155
+ private renderSectionRow;
156
+ private renderEntryRow;
157
+ /** One ` Label value` row, already styled, never wider than `width`. */
158
+ private field;
159
+ /**
160
+ * The tail of what an agent just did or said: the live activity line while it
161
+ * works, the final answer once it settles, the message when it errored.
162
+ * Workflows have no per-run prose feed — the progress counters above carry it.
163
+ */
164
+ private agentTail;
165
+ private detailLines;
166
+ private headerRight;
167
+ private footerLine;
168
+ render(width: number): string[];
169
+ private renderFrame;
170
+ invalidate(): void;
171
+ dispose(): void;
172
+ }