@esso0428/pi-subagents 0.17.14 → 0.17.15

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.
@@ -1,198 +0,0 @@
1
- /**
2
- * fleet-list.ts — Claude Code-style "FleetView" list rendered below the editor.
3
- *
4
- * Shows `main` + each running/queued subagent as a navigable list. Pressing ↓ (or
5
- * ←) at an empty prompt activates the list; ↑/↓ move the selection (filled ● marker),
6
- * Enter opens the selected agent's live conversation overlay, Esc returns to the prompt.
7
- * A viewer stays open when its agent finishes; finished agents linger briefly in the list.
8
- *
9
- * Mechanics (see plan): the list is a `belowEditor` widget (render-only), and ALL key
10
- * handling goes through `onTerminalInput` — which fires before the focused editor and
11
- * can `consume` keys — gated on `getEditorText() === ""` so normal typing is untouched.
12
- */
13
- import { type AgentManager } from "../agent-manager.js";
14
- import type { ViewerMarkdownMode } from "../types.js";
15
- import { type AgentActivity, type Theme } from "./agent-widget.js";
16
- /** Minimal UI surface the FleetView needs from `ctx.ui` (structural subset). */
17
- export type FleetUICtx = {
18
- setWidget(key: string, content: undefined | ((tui: any, theme: Theme) => {
19
- render(width: number): string[];
20
- invalidate(): void;
21
- dispose?(): void;
22
- }), options?: {
23
- placement?: "aboveEditor" | "belowEditor";
24
- }): void;
25
- onTerminalInput(handler: (data: string) => {
26
- consume?: boolean;
27
- data?: string;
28
- } | undefined): () => void;
29
- getEditorText(): string;
30
- notify(message: string, type?: "info" | "warning" | "error"): void;
31
- custom<T>(factory: (tui: any, theme: Theme, keybindings: any, done: (result: T) => void) => {
32
- render(width: number): string[];
33
- invalidate(): void;
34
- dispose?(): void;
35
- }, options?: {
36
- overlay?: boolean;
37
- overlayOptions?: unknown;
38
- onHandle?: (handle: unknown) => void;
39
- }): Promise<T>;
40
- };
41
- /**
42
- * A workflow run, as the fleet list needs to see it.
43
- *
44
- * Narrow on purpose: the list knows nothing about `WorkflowTask`, the runtime
45
- * or the dialog, so it stays as testable as it was when it only held agents.
46
- * The extension maps its tasks into this shape and injects an opener.
47
- */
48
- export interface FleetWorkflow {
49
- id: string;
50
- /** The `meta.name` of the run, or its id when the script named nothing. */
51
- name: string;
52
- status: "running" | "completed" | "failed" | "killed" | "paused";
53
- doneCount: number;
54
- totalCount: number;
55
- startedAt: number;
56
- /** Set once the run settles, which is what freezes its clock. */
57
- completedAt?: number;
58
- tokens: number;
59
- }
60
- /** `11s` — integer seconds, no decimal/suffix (matches Claude Code, unlike formatMs). */
61
- export declare function formatFleetElapsed(ms: number): string;
62
- /** `↓ 13.1k tokens` — down-arrow prefix, compact magnitude, plural "tokens". */
63
- export declare function formatFleetTokens(count: number): string;
64
- export declare class FleetList {
65
- private manager;
66
- private agentActivity;
67
- /**
68
- * Read live at render time. Whether each row shows an estimated cost after
69
- * its token count. Defaults to off — the extension supplies the user's
70
- * `showCost` setting.
71
- */
72
- private showCost;
73
- /**
74
- * The user's `viewerMarkdown` setting, for a conversation overlay opened
75
- * from here. Read live rather than captured, because the viewer's `m` key
76
- * changes it while the overlay is up. Omitted → the viewer's own default.
77
- */
78
- private viewerMarkdown?;
79
- /**
80
- * Persist a mode chosen with `m` in that overlay, so the key means the same
81
- * thing here as it does from `/agents` — one setting, not one per entry
82
- * point. Omitted → `m` still cycles, viewer-locally.
83
- */
84
- private onViewerMarkdown?;
85
- private cwd?;
86
- private ui;
87
- private tui;
88
- private inputUnsub;
89
- private widgetRegistered;
90
- private timer;
91
- private enabled;
92
- /** Whether arrow keys currently navigate the list (vs. flow to the editor). */
93
- private active;
94
- /** 0 = `main`, 1..N = subagents. */
95
- private selectedIndex;
96
- /** Set while a conversation overlay is open; calling it closes the overlay. */
97
- private viewerClose;
98
- private viewingAgentId;
99
- /** Injected by the extension; absent until workflows are wired (or at all). */
100
- private workflowSource;
101
- private openWorkflow;
102
- /**
103
- * Set while the workflow inspector is up.
104
- *
105
- * It does the two jobs `viewerClose` does for an agent's overlay — keep the
106
- * list out of the dialog's keys, and remember which row to come back to —
107
- * minus the close handle, because that overlay belongs to the extension.
108
- */
109
- private viewingWorkflowId;
110
- constructor(manager: AgentManager, agentActivity: Map<string, AgentActivity>,
111
- /**
112
- * Read live at render time. Whether each row shows an estimated cost after
113
- * its token count. Defaults to off — the extension supplies the user's
114
- * `showCost` setting.
115
- */
116
- showCost?: () => boolean,
117
- /**
118
- * The user's `viewerMarkdown` setting, for a conversation overlay opened
119
- * from here. Read live rather than captured, because the viewer's `m` key
120
- * changes it while the overlay is up. Omitted → the viewer's own default.
121
- */
122
- viewerMarkdown?: (() => ViewerMarkdownMode) | undefined,
123
- /**
124
- * Persist a mode chosen with `m` in that overlay, so the key means the same
125
- * thing here as it does from `/agents` — one setting, not one per entry
126
- * point. Omitted → `m` still cycles, viewer-locally.
127
- */
128
- onViewerMarkdown?: ((mode: ViewerMarkdownMode) => void) | undefined, cwd?: string | undefined);
129
- setCwd(cwd: string): void;
130
- setEnabled(enabled: boolean): void;
131
- /** Capture the UI context and (re)register the global input handler. */
132
- setUICtx(ui: FleetUICtx, registerInput?: boolean): void;
133
- /** Ensure the re-render timer is running (called when an agent spawns). */
134
- ensureTimer(): void;
135
- /**
136
- * Called when an agent finishes. The viewer (if open on it) stays open so the
137
- * final output remains readable, and the row lingers in the list — just refresh.
138
- */
139
- onAgentFinished(_id: string): void;
140
- dispose(): void;
141
- /** Re-register/refresh the below-editor widget; clears it when nothing remains. */
142
- update(): void;
143
- /**
144
- * Agents shown in the list, ordered earliest-launched first so the ones you
145
- * started sooner sit at the top. Every row is openable (has a session), so Enter
146
- * never dead-ends. Included: running/queued, plus the agent currently being
147
- * viewed, plus recently-finished ones (they linger briefly before dropping out).
148
- * Pending agents with no session yet are hidden until they start.
149
- * (`listAgents()` is newest-first, so we re-sort.)
150
- */
151
- private agentRecords;
152
- /**
153
- * Wire workflow runs into the list.
154
- *
155
- * Injected rather than constructed here because the fleet list predates
156
- * workflows and must keep working without them — a session with the feature
157
- * switched off never calls this, and the roster is agents-only exactly as
158
- * before.
159
- */
160
- setWorkflowSource(source: () => readonly FleetWorkflow[], open: (id: string) => Promise<void> | void): void;
161
- /** Live runs, plus recently settled ones — the same linger the agents get. */
162
- private workflows;
163
- /**
164
- * Runs sit above the agents rather than interleaved by start time: a run owns
165
- * most of the agents under it, so listing the container first is what makes
166
- * the list read as a hierarchy rather than a shuffle.
167
- */
168
- private roster;
169
- private clampSelection;
170
- /** Returns `{consume:true}` to swallow a key, or undefined to let it through. */
171
- handleKey(data: string): {
172
- consume?: boolean;
173
- data?: string;
174
- } | undefined;
175
- /**
176
- * True when pi's prompt editor owns the keyboard. pi's editor is an `Editor`
177
- * subclass (CustomEditor) while every dialog/selector is not, and the loader
178
- * aliases pi-tui to pi's own copy, so `instanceof` is a reliable identity
179
- * check. `focusedComponent` is TUI-private (no public accessor), hence the
180
- * best-effort peek: unknowable focus (no tui seen yet, nothing focused)
181
- * counts as the editor so activation keeps working.
182
- */
183
- private editorHasFocus;
184
- private deactivate;
185
- private openSelected;
186
- /** Reset overlay state and return to the list (on close, auto-close, or error). */
187
- private clearViewer;
188
- private renderBar;
189
- private bullet;
190
- /**
191
- * A run's row. Shaped like an agent's — bullet, kind, name, stats flush right
192
- * — so the two read as one list, with the agent count where an agent has its
193
- * description and the same elapsed/token tail.
194
- */
195
- private renderWorkflowRow;
196
- private renderAgentRow;
197
- }
198
- //# sourceMappingURL=fleet-list.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fleet-list.d.ts","sourceRoot":"","sources":["../../src/ui/fleet-list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAe,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAE,KAAK,aAAa,EAAc,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAY/E,gFAAgF;AAChF,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,CACP,GAAG,EAAE,M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