pi-subagent-manager 0.11.0 → 0.11.2
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.
- package/README.md +2 -2
- package/docs/tools-and-ui.md +10 -9
- package/package.json +1 -1
- package/src/index.ts +3 -1
- package/src/ui/live-agent-view.ts +104 -32
- package/src/ui/ui.ts +2 -2
package/README.md
CHANGED
|
@@ -68,11 +68,11 @@ They inherit your current model until you set preferences. Details: [docs/defaul
|
|
|
68
68
|
| ---------------- | ------------------------------------------------------ |
|
|
69
69
|
| `/agents` | Settings (mode, limits, model picking, tool filtering) |
|
|
70
70
|
| `/agents types` | Agent-type browser and editor |
|
|
71
|
-
| `/agents tree` | Fullscreen tree and
|
|
71
|
+
| `/agents tree` | Fullscreen tree and live viewer with manual steering (`/agents status` is an alias) |
|
|
72
72
|
| `/agents import` | Import agents from other subagent extensions |
|
|
73
73
|
| `/agents reload` | Reload definitions and settings |
|
|
74
74
|
|
|
75
|
-
A live **Agents** widget sits above the input box. Choose **Full** (the existing tree) or **Minimal** (colored status counts and running-agent token totals, plus the browser hint) under **Status Widget** in `/agents` settings. In the fullscreen tree, **Enter**
|
|
75
|
+
A live **Agents** widget sits above the input box. Choose **Full** (the existing tree) or **Minimal** (colored status counts and running-agent token totals, plus the browser hint) under **Status Widget** in `/agents` settings. In the fullscreen tree, **Enter** opens an agent's live view. Type in the bottom **Steer** input and press **Enter** to send it a steering message, including nested agents. **Tab** switches between input and transcript controls, **Escape** returns, and **i** in the tree opens existing thread actions. A status strip below the previews shows how many agents are running and **Press ← to open subagent browser**. Once the main turn ends and all subagents are idle, the preview collapses to a single status-count line; `/agents tree` still opens the full tree. While subagents are starting or running, press **Left** at the start of the main draft to open it; otherwise Left stays native. `/agents tree` remains available regardless of agent activity. See [live navigation](docs/tools-and-ui.md#live-agent-navigation) for controls and compatibility.
|
|
76
76
|
|
|
77
77
|
Experimental features are marked **[labs]** in settings. Enable **[labs] Nerd Font icons** in `/agents` to show role-specific icons beside agent names (off by default; requires a Nerd Font in your terminal). Custom agent types can set an optional `icon` or use **[labs] Icon** in `/agents types`. See [icon setup](docs/settings.md#labs-nerd-font-icons-nerdfonticons).
|
|
78
78
|
|
package/docs/tools-and-ui.md
CHANGED
|
@@ -56,24 +56,25 @@ Then `agent_wait` or `agent_status` on `/root/controller-security-research`.
|
|
|
56
56
|
|
|
57
57
|
Refreshes every second and keeps your selection, collapse state and scroll position.
|
|
58
58
|
|
|
59
|
-
### Live agent navigation
|
|
59
|
+
### Live agent navigation
|
|
60
60
|
|
|
61
|
-
The fullscreen watcher shows steer and agent messages in full, including the in-progress assistant reply. Tool calls, results, and other metadata show their name/status and only the first three wrapped lines of each arguments/output preview, followed by `...` when more is hidden. Use **i → Transcript** from the tree for retained tool details. Thinking is initially hidden (**t** toggles it).
|
|
61
|
+
The fullscreen watcher shows steer and agent messages in full, including the in-progress assistant reply. Tool calls, results, and other metadata show their name/status and only the first three wrapped lines of each arguments/output preview, followed by `...` when more is hidden. Use **i → Transcript** from the tree for retained tool details. Thinking is initially hidden (**t** toggles it with transcript controls focused). Inherited context is initially collapsed (**c** toggles it with transcript controls focused). Watching alone never starts a turn, switches sessions, or changes model/tool/resource ownership. Unsupported/custom content and images use safe text placeholders rather than native rich rendering. Legacy sessions without reliable inherited-prefix metadata show their whole transcript.
|
|
62
62
|
|
|
63
|
-
- **
|
|
64
|
-
- **
|
|
65
|
-
- **
|
|
63
|
+
- The bottom **Steer** input is focused initially. Type and press **Enter** to send to the inspected agent, including nested descendants, through the same service as `agent_steer`: running agents receive queued input; paused/completed/stopped agents resume their retained session. Empty input is ignored. Sending leaves the viewer open; failures are shown and preserve the draft for retry.
|
|
64
|
+
- **Tab** switches between steering input and transcript controls. While typing, **c/t/l/r** are ordinary text and **Home/End** move the input cursor. Pasting never submits by itself.
|
|
65
|
+
- **Up/Down, PageUp/PageDown** scroll and pause following in either mode. With transcript controls focused, **Home** scrolls to the start; **End** or **l** resumes following the live tail. Scroll/follow state is remembered per agent.
|
|
66
|
+
- **Ctrl+R** (or **r** with transcript controls focused) retries an unavailable observation without starting a turn. Starting threads are watchable; stopped/completed threads remain readable.
|
|
66
67
|
- Frames are sanitized, viewport-bounded and coalesced during bursts. Exit, root replacement and shutdown release observers/timers. Streaming deltas never enter persisted thread events.
|
|
67
68
|
|
|
68
69
|
#### Left-arrow entry
|
|
69
70
|
|
|
70
|
-
|
|
71
|
+
While any subagent is **starting or running**, press physical **Left (←)** at the beginning of the main draft (or in an empty input) to open the subagent browser. With no active subagents, or elsewhere in the draft, Left retains normal cursor movement. `/agents tree` remains available regardless of agent activity. Down is always native editing/history navigation. Autocomplete, jumps, paste and configured shortcuts take precedence. Navigating preserves the main draft/cursor and does not require the root to be idle.
|
|
71
72
|
|
|
72
73
|
Left-arrow entry is enabled by default in the TUI; `/agents tree` remains available everywhere. Pi has one custom-editor slot: installation is skipped if another factory owns it or an existing draft is nonempty, since the host cannot transfer cursor/undo/expanded-paste state. Load order can still let a later editor replace ours. Initial startup uses Pi's history hydration; replacement installations seed history once. Session-tree rebuilds keep the existing editor instance.
|
|
73
74
|
|
|
74
75
|
While navigation is open, the host fullscreen search shortcut is temporarily disabled through public keybindings to avoid stacking a second host overlay. The prior binding owner is restored only if no other extension replaced it. **Known host limitation:** if an unrelated extension stacks another overlay above navigation, Pi's custom-UI completion can close the newer overlay instead. Avoid concurrent extension-owned overlays; a host identity-targeted completion API is needed to remove this limitation. No private host access or unsupported overlay-lifecycle workaround is used.
|
|
75
76
|
|
|
76
|
-
Run `python3 scripts/live-agent-navigation-smoke.py` after `npm install` for credential-free, offline POSIX PTY checks in regular/fullscreen mode (entry, root return,
|
|
77
|
+
Run `python3 scripts/live-agent-navigation-smoke.py` after `npm install` for credential-free, offline POSIX PTY checks in regular/fullscreen mode (idle Left gating, explicit command entry, root return, resize and host-search suppression). No model prompts are submitted. Broader manual acceptance covers concurrent live turns, autocomplete/paste/undo interactions, remapped shortcuts and rich custom content.
|
|
77
78
|
|
|
78
79
|
## Agents widget
|
|
79
80
|
|
|
@@ -82,7 +83,7 @@ The widget above the input editor has two display modes, selected with **Status
|
|
|
82
83
|
- **Full** (default): the existing compact tree, at most twelve lines.
|
|
83
84
|
- **Minimal**: a summary line such as `3 running, 2 stopped, 1 failed, 1 paused ↑12k ↓3k`, with semantic theme colors. Starting agents count as running; completed agents are counted when present. Token totals include only currently starting/running agents, not the main conversation or settled threads. Use `/agents tree` for details.
|
|
84
85
|
|
|
85
|
-
Once the main turn has ended and no subagents are starting or running, either mode collapses to a single status-count line without the browser hint. The full tree remains available via `/agents tree
|
|
86
|
+
Once the main turn has ended and no subagents are starting or running, either mode collapses to a single status-count line without the browser hint. The full tree remains available via `/agents tree`; **Left** at the start of the draft opens it only while subagents are starting or running. A new main turn or active subagent restores the configured display mode.
|
|
86
87
|
|
|
87
88
|
In full mode:
|
|
88
89
|
|
|
@@ -90,7 +91,7 @@ In full mode:
|
|
|
90
91
|
- A second, indented line shows latest activity.
|
|
91
92
|
- Active branches are shown first; the most recent agents within each state are preferred when previews overflow. Overflow is counted, not listed.
|
|
92
93
|
- Time freezes while paused and resumes on continue.
|
|
93
|
-
- A small status strip below the previews shows the running count (including starting agents) and **Press ← to open subagent browser**, including when agents overflow.
|
|
94
|
+
- A small status strip below the previews shows the running count (including starting agents) and **Press ← to open subagent browser**, including when agents overflow. Full and minimal modes show the hint only while subagents are starting or running. RPC output omits the keyboard hint.
|
|
94
95
|
|
|
95
96
|
### Interrupts and stopping agents
|
|
96
97
|
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -80,7 +80,9 @@ export default function piSubagent(pi: ExtensionAPI): void {
|
|
|
80
80
|
initialHistory: seedHistory ? history : undefined,
|
|
81
81
|
generation: () => navigationGeneration,
|
|
82
82
|
canOpen: () => manager !== undefined && context?.mode === "tui" &&
|
|
83
|
-
limits.subagentMode !== "off" && !navigation.isOpen
|
|
83
|
+
limits.subagentMode !== "off" && !navigation.isOpen &&
|
|
84
|
+
manager.list().some((thread) => thread.path !== "/root" &&
|
|
85
|
+
(thread.state === "starting" || thread.state === "running")),
|
|
84
86
|
openTree: () => manager && context
|
|
85
87
|
? navigation.open(context, manager.scope("/root"), undefined, limits.nerdFontIcons) : undefined,
|
|
86
88
|
onError: (error) => context?.ui.notify(
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentMessage } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { getMarkdownTheme, type Theme } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import {
|
|
4
|
+
Input,
|
|
4
5
|
Key,
|
|
5
6
|
Markdown,
|
|
6
7
|
matchesKey,
|
|
@@ -51,7 +52,7 @@ function json(value: unknown): string {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
/**
|
|
55
|
+
/** Live transcript and manual steering. Never invoke tools' custom renderers or pass through raw controls. */
|
|
55
56
|
export class LiveAgentView {
|
|
56
57
|
private snapshot: TranscriptSnapshot | undefined;
|
|
57
58
|
private error: string | undefined;
|
|
@@ -63,6 +64,14 @@ export class LiveAgentView {
|
|
|
63
64
|
private scroll: ScrollView;
|
|
64
65
|
private content: string[] = [];
|
|
65
66
|
private restoreViewport = true;
|
|
67
|
+
private input = new Input({ prompt: "Steer > " });
|
|
68
|
+
private editing = true;
|
|
69
|
+
private focusedState = true;
|
|
70
|
+
private pasting = false;
|
|
71
|
+
private pasteTail = "";
|
|
72
|
+
private sending = false;
|
|
73
|
+
private steerStatus: string | undefined;
|
|
74
|
+
private steerFailed = false;
|
|
66
75
|
|
|
67
76
|
constructor(
|
|
68
77
|
private host: DialogHost,
|
|
@@ -77,9 +86,57 @@ export class LiveAgentView {
|
|
|
77
86
|
{ render: () => this.content, invalidate() {} },
|
|
78
87
|
{ follow: "end", overscroll: "contain", scrollbar: "hidden" },
|
|
79
88
|
);
|
|
89
|
+
this.input.focused = true;
|
|
90
|
+
this.input.onSubmit = (value) => void this.steer(value);
|
|
80
91
|
void this.attach();
|
|
81
92
|
}
|
|
82
93
|
|
|
94
|
+
get focused(): boolean {
|
|
95
|
+
return this.focusedState;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
set focused(value: boolean) {
|
|
99
|
+
this.focusedState = value;
|
|
100
|
+
this.input.focused = value && this.editing;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private async steer(value: string): Promise<void> {
|
|
104
|
+
const message = dialogText(value);
|
|
105
|
+
if (this.disposed || this.sending || !message.trim()) return;
|
|
106
|
+
this.sending = true;
|
|
107
|
+
this.steerFailed = false;
|
|
108
|
+
this.steerStatus = "Sending steering…";
|
|
109
|
+
this.host.requestRender();
|
|
110
|
+
try {
|
|
111
|
+
// Same root-scoped service as the Actions menu: queues a running turn or resumes a settled one.
|
|
112
|
+
await this.service.steer(this.path, message);
|
|
113
|
+
if (this.disposed) return;
|
|
114
|
+
if (this.input.getValue() === message) this.input.setValue("");
|
|
115
|
+
this.steerStatus = "Steering sent";
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (this.disposed) return;
|
|
118
|
+
this.steerFailed = true;
|
|
119
|
+
this.steerStatus = `Steering failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
120
|
+
} finally {
|
|
121
|
+
this.sending = false;
|
|
122
|
+
if (!this.disposed) this.host.requestRender();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private editInput(data: string): void {
|
|
127
|
+
// Keep paste chunks (including embedded Esc, Tab and Enter) out of navigation shortcuts.
|
|
128
|
+
const pasteData = this.pasteTail + data;
|
|
129
|
+
if (pasteData.includes("\x1b[200~")) this.pasting = true;
|
|
130
|
+
if (pasteData.includes("\x1b[201~")) this.pasting = false;
|
|
131
|
+
this.pasteTail = this.pasting ? pasteData.slice(-5) : "";
|
|
132
|
+
const before = this.input.getValue();
|
|
133
|
+
this.input.handleInput(data);
|
|
134
|
+
const safe = dialogText(this.input.getValue());
|
|
135
|
+
if (safe !== this.input.getValue()) this.input.setValue(safe);
|
|
136
|
+
if (safe !== before && !this.sending) this.steerStatus = undefined;
|
|
137
|
+
this.host.requestRender();
|
|
138
|
+
}
|
|
139
|
+
|
|
83
140
|
private async attach(): Promise<void> {
|
|
84
141
|
const attachment = ++this.attachment;
|
|
85
142
|
this.unsubscribe?.();
|
|
@@ -132,6 +189,7 @@ export class LiveAgentView {
|
|
|
132
189
|
|
|
133
190
|
invalidate(): void {
|
|
134
191
|
this.cache = new WeakMap();
|
|
192
|
+
this.input.invalidate();
|
|
135
193
|
}
|
|
136
194
|
|
|
137
195
|
dispose(): void {
|
|
@@ -146,28 +204,42 @@ export class LiveAgentView {
|
|
|
146
204
|
|
|
147
205
|
handleInput(data: string): void {
|
|
148
206
|
if (this.disposed) return;
|
|
207
|
+
if (this.pasting || (this.editing && data.includes("\x1b[200~"))) {
|
|
208
|
+
this.editInput(data);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
149
211
|
if (matchesKey(data, Key.escape)) return this.done("back");
|
|
150
212
|
if (matchesKey(data, Key.ctrl("q")) || matchesKey(data, Key.ctrl("c")))
|
|
151
213
|
return this.done("main");
|
|
152
|
-
if (data
|
|
214
|
+
if (matchesKey(data, Key.tab)) {
|
|
215
|
+
this.editing = !this.editing;
|
|
216
|
+
this.input.focused = this.focused && this.editing;
|
|
217
|
+
this.host.requestRender();
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (this.error && (matchesKey(data, Key.ctrl("r")) || (!this.editing && data === "r"))) {
|
|
153
221
|
void this.attach();
|
|
154
222
|
return;
|
|
155
223
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
this.invalidate();
|
|
159
|
-
} else if (data === "t") {
|
|
160
|
-
this.viewport.showThinking = !this.viewport.showThinking;
|
|
161
|
-
this.invalidate();
|
|
162
|
-
} else if (matchesKey(data, Key.up)) this.scroll.scrollBy(-1);
|
|
224
|
+
// Transcript scrolling remains available while composing; Home/End edit the input.
|
|
225
|
+
if (matchesKey(data, Key.up)) this.scroll.scrollBy(-1);
|
|
163
226
|
else if (matchesKey(data, Key.down)) this.scroll.scrollBy(1);
|
|
164
227
|
else if (matchesKey(data, Key.pageUp))
|
|
165
228
|
this.scroll.scrollBy(-Math.max(1, this.scroll.viewportHeight));
|
|
166
229
|
else if (matchesKey(data, Key.pageDown))
|
|
167
230
|
this.scroll.scrollBy(Math.max(1, this.scroll.viewportHeight));
|
|
168
|
-
else if (
|
|
231
|
+
else if (this.editing) {
|
|
232
|
+
this.editInput(data);
|
|
233
|
+
return;
|
|
234
|
+
} else if (data === "c") {
|
|
235
|
+
this.viewport.showInherited = !this.viewport.showInherited;
|
|
236
|
+
this.invalidate();
|
|
237
|
+
} else if (data === "t") {
|
|
238
|
+
this.viewport.showThinking = !this.viewport.showThinking;
|
|
239
|
+
this.invalidate();
|
|
240
|
+
} else if (matchesKey(data, Key.home)) this.scroll.scrollTo(0, { disableFollow: true });
|
|
169
241
|
else if (matchesKey(data, Key.end) || data === "l") this.scroll.scrollToEnd();
|
|
170
|
-
else return;
|
|
242
|
+
else return;
|
|
171
243
|
this.saveViewport();
|
|
172
244
|
this.host.requestRender();
|
|
173
245
|
}
|
|
@@ -287,7 +359,7 @@ export class LiveAgentView {
|
|
|
287
359
|
if (this.error)
|
|
288
360
|
body.push(
|
|
289
361
|
this.theme.fg("error", dialogText(`Attachment error: ${this.error}`)),
|
|
290
|
-
"
|
|
362
|
+
"Ctrl+R Retry · Esc Back · Ctrl+Q Back to main",
|
|
291
363
|
);
|
|
292
364
|
if (!snapshot) {
|
|
293
365
|
if (!this.error) body.push("Attaching to retained live session…");
|
|
@@ -335,7 +407,7 @@ export class LiveAgentView {
|
|
|
335
407
|
);
|
|
336
408
|
}
|
|
337
409
|
this.content = body;
|
|
338
|
-
const bodyHeight = Math.max(0, height -
|
|
410
|
+
const bodyHeight = Math.max(0, height - 4);
|
|
339
411
|
this.scroll.updateLayout(body.length, bodyHeight, () => this.scheduleRender());
|
|
340
412
|
if (this.restoreViewport) {
|
|
341
413
|
if (this.viewport.follow) this.scroll.scrollToEnd();
|
|
@@ -348,28 +420,28 @@ export class LiveAgentView {
|
|
|
348
420
|
while (visible.length < bodyHeight) visible.push("");
|
|
349
421
|
this.saveViewport();
|
|
350
422
|
const footer = this.error
|
|
351
|
-
? "
|
|
352
|
-
:
|
|
423
|
+
? "Ctrl+R Retry · Tab input/transcript · Esc tree · Ctrl+Q main"
|
|
424
|
+
: `${this.editing ? "Enter steer · Tab browse" : "Tab steer · Home/End scroll · c context · t thinking"} · Esc tree · Ctrl+Q main · ↑↓/PgUp/PgDn scroll · ${this.viewport.follow ? "following" : "scrolled"}`;
|
|
425
|
+
const input = this.input.render(columns)[0]!;
|
|
426
|
+
const status = this.theme.fg(
|
|
427
|
+
this.steerStatus ? (this.steerFailed ? "error" : "muted") : this.error ? "error" : "muted",
|
|
428
|
+
dialogText(
|
|
429
|
+
this.steerStatus ??
|
|
430
|
+
(this.error
|
|
431
|
+
? `Attachment error: ${this.error}`
|
|
432
|
+
: thread
|
|
433
|
+
? `${thread.task} · ${thread.status}`
|
|
434
|
+
: "Live transcript · Enter to steer"),
|
|
435
|
+
),
|
|
436
|
+
);
|
|
353
437
|
const lines =
|
|
354
438
|
height === 1
|
|
355
|
-
? [
|
|
439
|
+
? [input]
|
|
356
440
|
: height === 2
|
|
357
|
-
? [header,
|
|
358
|
-
:
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
this.error ? "error" : "muted",
|
|
362
|
-
dialogText(
|
|
363
|
-
this.error
|
|
364
|
-
? `Attachment error: ${this.error}`
|
|
365
|
-
: thread
|
|
366
|
-
? `${thread.task} · ${thread.status}`
|
|
367
|
-
: "Read-only observer",
|
|
368
|
-
),
|
|
369
|
-
),
|
|
370
|
-
...visible,
|
|
371
|
-
this.theme.fg("dim", footer),
|
|
372
|
-
];
|
|
441
|
+
? [header, input]
|
|
442
|
+
: height === 3
|
|
443
|
+
? [header, this.theme.fg("dim", footer), input]
|
|
444
|
+
: [header, status, ...visible, this.theme.fg("dim", footer), input];
|
|
373
445
|
return fillViewport(lines, width, height);
|
|
374
446
|
}
|
|
375
447
|
}
|
package/src/ui/ui.ts
CHANGED
|
@@ -473,7 +473,7 @@ export function renderAgentTree(
|
|
|
473
473
|
lines.push(agentLine(row, columns, theme, nerdFontIcons));
|
|
474
474
|
lines.push(activityLine(row, columns, theme));
|
|
475
475
|
}
|
|
476
|
-
lines.push(agentWidgetStatus(live, omitted, columns, theme, showBrowserHint));
|
|
476
|
+
lines.push(agentWidgetStatus(live, omitted, columns, theme, showBrowserHint && live > 0));
|
|
477
477
|
return lines;
|
|
478
478
|
}
|
|
479
479
|
|
|
@@ -521,7 +521,7 @@ export function renderAgentSummary(
|
|
|
521
521
|
const right = theme.fg("muted", `↑${formatCount(input)} ↓${formatCount(output)}`);
|
|
522
522
|
const columns = Math.max(0, width);
|
|
523
523
|
const lines = [fitLine(left, right, columns)];
|
|
524
|
-
if (showBrowserHint)
|
|
524
|
+
if (showBrowserHint && counts.running > 0)
|
|
525
525
|
lines.push(truncateToWidth(theme.fg("muted", AGENT_BROWSER_HINT), columns, ""));
|
|
526
526
|
return lines;
|
|
527
527
|
}
|