pi-subagent-manager 1.6.1 → 1.7.1
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 +10 -0
- package/docs/pi-footer.md +2 -2
- package/docs/settings.md +6 -6
- package/docs/tools-and-ui.md +1 -1
- package/package.json +1 -1
- package/src/orch/runtime.ts +21 -43
- package/src/prefs/import-instructions.ts +3 -2
- package/src/ui/model-picker.ts +1 -1
- package/src/ui/settings-ui.ts +12 -12
package/README.md
CHANGED
|
@@ -12,6 +12,16 @@ Let pi hand work to helper agents in parallel. Watch what they're doing, give th
|
|
|
12
12
|
|
|
13
13
|
A real Pi session with a customized footer and Nerd Font: parallel work, nested delegation, watching, and steering. [Recording details](docs/demo.md) (37 seconds; pauses shortened).
|
|
14
14
|
|
|
15
|
+
## Check out my other Pi extensions
|
|
16
|
+
|
|
17
|
+
- [](https://github.com/championswimmer/pi-cache-graph) — Real-time prompt cache hit rates and token metrics.
|
|
18
|
+
- [](https://github.com/championswimmer/pi-checklist) — Session task checklist with dependencies and a TUI renderer.
|
|
19
|
+
- [](https://github.com/championswimmer/pi-context-decisions) — Selects relevant skills and optionally filters tools for each task.
|
|
20
|
+
- [](https://github.com/championswimmer/pi-context-prune) — Prunes verbose tool outputs from context while preserving history.
|
|
21
|
+
- [](https://github.com/championswimmer/pi-context-usage) — Dot-grid visualization of context window token usage.
|
|
22
|
+
- [](https://github.com/championswimmer/pi-gauge) — Live tokens/sec and TTFT in the status bar.
|
|
23
|
+
- [](https://github.com/championswimmer/pi-subagent-manager) — Delegate work to parallel subagents and monitor their progress.
|
|
24
|
+
|
|
15
25
|
## Install
|
|
16
26
|
|
|
17
27
|
Requires pi **0.99.2+**.
|
package/docs/pi-footer.md
CHANGED
|
@@ -10,7 +10,7 @@ The shared status key / event Widget ID is exactly **`subagent_cost`**. It is no
|
|
|
10
10
|
|
|
11
11
|
## Extension Status (recommended; default)
|
|
12
12
|
|
|
13
|
-
1. Open `/agents settings` → **
|
|
13
|
+
1. Open `/agents settings` → **Footer display** → **Location**, choose
|
|
14
14
|
**pi-footer status widget**, return to settings, and save with **Ctrl+S**.
|
|
15
15
|
2. Open `/footer`, choose **Edit lines**, select a row, and add **Extension Status**.
|
|
16
16
|
3. Set **Status key** to **`subagent_cost`** and enable **Raw value only**.
|
|
@@ -53,7 +53,7 @@ It clears the status with `ctx.ui.setStatus("subagent_cost", undefined)`.
|
|
|
53
53
|
|
|
54
54
|
## Pi Event Value (alternative)
|
|
55
55
|
|
|
56
|
-
1. Open `/agents settings` → **
|
|
56
|
+
1. Open `/agents settings` → **Footer display** → **Location**, choose
|
|
57
57
|
**pi-footer event**, return to settings, and save with **Ctrl+S**.
|
|
58
58
|
2. In `/footer`, add a **Pi Event Value** widget to the desired row.
|
|
59
59
|
3. Enter **Widget ID** as **`subagent_cost`** manually, replacing the generated ID,
|
package/docs/settings.md
CHANGED
|
@@ -65,13 +65,13 @@ Minimal mode groups starting agents with running agents and excludes the main co
|
|
|
65
65
|
|
|
66
66
|
## [labs] Nerd Font icons (`nerdFontIcons`)
|
|
67
67
|
|
|
68
|
-
Experimental
|
|
68
|
+
Experimental settings are tagged **[lab]** in their row labels. **[labs] Nerd Font icons** is an on/off toggle, **off by default**. Enable it in `/agents` and save with **Ctrl+S**, or set `"nerdFontIcons": true` in your settings file. Configure a [Nerd Font](https://www.nerdfonts.com/) in your terminal first; unsupported fonts may show boxes or incorrect glyphs. The extension does not install or detect fonts.
|
|
69
69
|
|
|
70
70
|
When enabled, an agent type’s optional `icon` appears before its readable name in the full widget, thread browsers, live watcher header, and type picker. Starting/running agents show the selected loader **before the original role icon**, never replacing it. Completed, paused, failed, and stopped agents show that loader family's corresponding static state icon before the role icon. Agents without a configured role icon still show their loader/state indicator. The one-line minimal widget uses the same family's indicators for aggregate status counts. Turning the setting off hides role icons without removing configured icons; portable loaders remain visible; RPC output keeps state indicators static. Saved settings apply immediately to newly rendered widgets and dialogs.
|
|
71
71
|
|
|
72
72
|
All six bundled agents have [role-specific icons](default-agents.md#nerd-font-icons). Add or change an icon with **[labs] Icon** in `/agents types`, or the optional `icon` frontmatter field in [your own agent](custom-agents.md#icons-labs). Retained threads keep the icon from their saved agent definition.
|
|
73
73
|
|
|
74
|
-
##
|
|
74
|
+
## Loader style (`loaderStyle`)
|
|
75
75
|
|
|
76
76
|
Choose a loader in `/agents` settings and save with **Ctrl+S**, or set `loaderStyle` in your settings file:
|
|
77
77
|
|
|
@@ -86,11 +86,11 @@ Choose a loader in `/agents` settings and save with **Ctrl+S**, or set `loaderSt
|
|
|
86
86
|
|
|
87
87
|
With **[labs] Nerd Font icons** off, the picker shows only Braille and ASCII palettes. With it on, all palettes are available. Saved Circle/Hourglass preferences render as ASCII while Nerd Fonts are off, without changing the saved preference. ASCII palettes use `+`, `=`, `!`, and `#` for completed, paused, failed, and stopped states. The compact ASCII animations are inspired by [cli-spinners](https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json) (`line`, `star2`, and `toggle13`).
|
|
88
88
|
|
|
89
|
-
The
|
|
89
|
+
The loader picker shows each available family's running animation frames and completed, paused, failed, and stopped icons, so you can compare all states before choosing. Starting uses the running animation. State indicators precede the role icon when role icons are enabled; the selected family also applies to the minimal widget's counts. In non-animated output, active agents use the family's first frame.
|
|
90
90
|
|
|
91
|
-
##
|
|
91
|
+
## Cost display (`costDisplay`)
|
|
92
92
|
|
|
93
|
-
Open **
|
|
93
|
+
Open **Footer display** in `/agents settings` to choose the location, display value, and icon, then return and save. The stable ID/key is **`subagent_cost`**.
|
|
94
94
|
|
|
95
95
|
| Value | Output |
|
|
96
96
|
| --- | --- |
|
|
@@ -189,7 +189,7 @@ Which model an agent gets when its session starts.
|
|
|
189
189
|
|
|
190
190
|
- Types with no `models` inherit the parent's model in both Pick First modes.
|
|
191
191
|
- Your list's order decides, not the scoped list's order.
|
|
192
|
-
- No match → spawn fails clearly. An empty `/scoped-models`
|
|
192
|
+
- No match → spawn fails clearly. An empty `/scoped-models` means unrestricted: all available models are eligible.
|
|
193
193
|
- `use-current` always uses the **main** session's model, even for nested or reopened agents. Thinking levels stay per-agent.
|
|
194
194
|
- `modelSuggestions` never affects this.
|
|
195
195
|
- Switching modes doesn't change already-open sessions.
|
package/docs/tools-and-ui.md
CHANGED
|
@@ -116,7 +116,7 @@ In full mode:
|
|
|
116
116
|
- Agents are ordered newest-started first (spawn or resume); a branch ranks by its most recently started agent. The most recently started agents are preferred when previews overflow. Overflow is counted, not listed.
|
|
117
117
|
- Time freezes while paused and resumes on continue.
|
|
118
118
|
- A small status strip below the previews shows the running count (including starting agents) and **Press ← to open subagent browser**, including when agents overflow. The full footer also shows **→ collapse**. Minimal mode keeps **← browser** inline so it stays one line (**← expand** when it is a session collapse of full). Browser hints appear only while subagents are starting or running; RPC output omits keyboard hints.
|
|
119
|
-
-
|
|
119
|
+
- The selected loader appears in the widget and fullscreen tree/live-view headers, before the role icon if enabled. Each family provides completed, paused, failed, and stopped state icons. The minimal summary uses the same indicators for its status counts. Preview all families and states under **Loader style**. Animation timers stop on settlement or disposal; RPC output stays static.
|
|
120
120
|
|
|
121
121
|
### Interrupts and stopping agents
|
|
122
122
|
|
package/package.json
CHANGED
package/src/orch/runtime.ts
CHANGED
|
@@ -36,12 +36,7 @@ import type {
|
|
|
36
36
|
SubagentExtensionSelection,
|
|
37
37
|
ToolFilteringMode,
|
|
38
38
|
} from "../prefs/settings.ts";
|
|
39
|
-
import {
|
|
40
|
-
modelIdentity,
|
|
41
|
-
getModelPreferences,
|
|
42
|
-
selectPreferredModel,
|
|
43
|
-
ModelPreferenceError,
|
|
44
|
-
} from "../prefs/models.ts";
|
|
39
|
+
import { modelIdentity, getModelPreferences, selectPreferredModel } from "../prefs/models.ts";
|
|
45
40
|
import {
|
|
46
41
|
THINKING_LEVELS,
|
|
47
42
|
type AgentType,
|
|
@@ -219,27 +214,18 @@ export function createDriverFactory(
|
|
|
219
214
|
const available = new Set(availableModelCandidates().map(({ model }) => modelIdentity(model)));
|
|
220
215
|
return scopedModels.filter(({ model }) => available.has(modelIdentity(model)));
|
|
221
216
|
};
|
|
217
|
+
// Pi represents an unrestricted scope with an empty array.
|
|
222
218
|
const selectTypeModelPreference = (
|
|
223
219
|
type: AgentType,
|
|
224
|
-
|
|
220
|
+
scopedModels: readonly ScopedModel[],
|
|
225
221
|
filtering: boolean,
|
|
226
222
|
) => {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
error instanceof Error &&
|
|
234
|
-
!error.message.includes("[]")
|
|
235
|
-
) {
|
|
236
|
-
const message = `${error.message} Current /scoped-models scope: [].`;
|
|
237
|
-
throw error instanceof ModelPreferenceError
|
|
238
|
-
? new ModelPreferenceError(message, error.scopedModelFiltering)
|
|
239
|
-
: new Error(message);
|
|
240
|
-
}
|
|
241
|
-
throw error;
|
|
242
|
-
}
|
|
223
|
+
const restricted = filtering && scopedModels.length > 0;
|
|
224
|
+
return selectPreferredModel(
|
|
225
|
+
type,
|
|
226
|
+
restricted ? availableScopedModels(scopedModels) : availableModelCandidates(),
|
|
227
|
+
restricted,
|
|
228
|
+
);
|
|
243
229
|
};
|
|
244
230
|
// Discovery and new/restored drivers share model selection and thinking inheritance.
|
|
245
231
|
const resolveInitialSettings = (
|
|
@@ -260,11 +246,8 @@ export function createDriverFactory(
|
|
|
260
246
|
id = ctx.model?.id;
|
|
261
247
|
} else if (preferences !== undefined) {
|
|
262
248
|
const filtering = mode === "pick-first-scoped";
|
|
263
|
-
const candidates = filtering
|
|
264
|
-
? availableScopedModels(normalizeScopedModels(ctx.scopedModels))
|
|
265
|
-
: availableModelCandidates();
|
|
266
249
|
({ provider, id } = parseModelIdentity(
|
|
267
|
-
selectTypeModelPreference(type,
|
|
250
|
+
selectTypeModelPreference(type, normalizeScopedModels(ctx.scopedModels), filtering)!,
|
|
268
251
|
));
|
|
269
252
|
} else if (restored?.model) {
|
|
270
253
|
provider = restored.model.provider;
|
|
@@ -372,9 +355,9 @@ export function createDriverFactory(
|
|
|
372
355
|
modelSelection === "use-current" ? undefined : getModelPreferences(options.type);
|
|
373
356
|
const filteringEnabled = () => getModelSelection() === "pick-first-scoped";
|
|
374
357
|
const selectModelPreference = (
|
|
375
|
-
|
|
358
|
+
scopedModels: readonly ScopedModel[],
|
|
376
359
|
filtering = filteringEnabled(),
|
|
377
|
-
) => selectTypeModelPreference(options.type,
|
|
360
|
+
) => selectTypeModelPreference(options.type, scopedModels, filtering);
|
|
378
361
|
const initialScopedModels = normalizeScopedModels(ctx.scopedModels);
|
|
379
362
|
const { provider, id, thinkingLevel } = resolveInitialSettings(
|
|
380
363
|
options.type,
|
|
@@ -721,10 +704,7 @@ export function createDriverFactory(
|
|
|
721
704
|
liveScopedModels: readonly ScopedModel[],
|
|
722
705
|
) => {
|
|
723
706
|
if (!filteringEnabled() || modelPreferences === undefined) return;
|
|
724
|
-
const preferredIdentity = selectModelPreference(
|
|
725
|
-
availableScopedModels(liveScopedModels),
|
|
726
|
-
true,
|
|
727
|
-
);
|
|
707
|
+
const preferredIdentity = selectModelPreference(liveScopedModels, true);
|
|
728
708
|
if (!preferredIdentity) return;
|
|
729
709
|
if (!currentIdentity) throw new Error(`Subagent ${options.path} has no selected model`);
|
|
730
710
|
if (currentIdentity !== preferredIdentity) {
|
|
@@ -751,10 +731,7 @@ export function createDriverFactory(
|
|
|
751
731
|
updateResolved();
|
|
752
732
|
return;
|
|
753
733
|
}
|
|
754
|
-
const preferredIdentity = selectModelPreference(
|
|
755
|
-
availableScopedModels(liveScopedModels),
|
|
756
|
-
true,
|
|
757
|
-
);
|
|
734
|
+
const preferredIdentity = selectModelPreference(liveScopedModels, true);
|
|
758
735
|
if (!preferredIdentity) {
|
|
759
736
|
updateResolved();
|
|
760
737
|
return;
|
|
@@ -862,7 +839,9 @@ export function createDriverFactory(
|
|
|
862
839
|
let disposed = false;
|
|
863
840
|
let running = false;
|
|
864
841
|
let aborted = false;
|
|
865
|
-
|
|
842
|
+
// Compaction can replace session.messages during a prompt, invalidating any saved index.
|
|
843
|
+
const promptResult: { lastAssistant?: AssistantMessage } = {};
|
|
844
|
+
const getLastAssistant = () => promptResult.lastAssistant;
|
|
866
845
|
// Subscribe after inherited/restored history is loaded; only new assistant events are counted.
|
|
867
846
|
let settledInput = 0;
|
|
868
847
|
let settledOutput = 0;
|
|
@@ -907,6 +886,8 @@ export function createDriverFactory(
|
|
|
907
886
|
);
|
|
908
887
|
const unsubscribe = session.subscribe((event) => {
|
|
909
888
|
transcript.accept(event);
|
|
889
|
+
if (running && event.type === "message_end" && event.message.role === "assistant")
|
|
890
|
+
promptResult.lastAssistant = event.message;
|
|
910
891
|
if (event.type === "tool_execution_start")
|
|
911
892
|
emit("activity", `Tool: ${event.toolName}`, toolArgumentSnippet(event.args));
|
|
912
893
|
if (event.type === "tool_execution_end")
|
|
@@ -967,17 +948,14 @@ export function createDriverFactory(
|
|
|
967
948
|
if (running) throw new Error("Subagent is already running; use steer instead");
|
|
968
949
|
running = true;
|
|
969
950
|
aborted = false;
|
|
970
|
-
|
|
951
|
+
promptResult.lastAssistant = undefined;
|
|
971
952
|
finalOutput = "";
|
|
972
953
|
try {
|
|
973
954
|
await enforceScopedModelPolicy();
|
|
974
955
|
await resumePending();
|
|
975
956
|
await session.prompt(message, { expandPromptTemplates: false });
|
|
976
957
|
await session.waitForIdle();
|
|
977
|
-
const last =
|
|
978
|
-
.slice(baseline)
|
|
979
|
-
.filter((msg) => msg.role === "assistant")
|
|
980
|
-
.at(-1);
|
|
958
|
+
const last = getLastAssistant();
|
|
981
959
|
if (aborted || last?.stopReason === "aborted") throw new Error("Subagent run aborted");
|
|
982
960
|
if (last?.stopReason === "error")
|
|
983
961
|
throw new Error(last.errorMessage || "Subagent model failed");
|
|
@@ -23,8 +23,9 @@ edit. Only these frontmatter keys are accepted:
|
|
|
23
23
|
- name: required safe ID matching /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/.
|
|
24
24
|
- description: required nonempty routing description (what work this agent is for).
|
|
25
25
|
- models: optional NONEMPTY ordered YAML array of exact provider/model-id identities.
|
|
26
|
-
First preference
|
|
27
|
-
|
|
26
|
+
First available preference in the CURRENT /scoped-models list wins. An empty scope is
|
|
27
|
+
unrestricted, so any available model is eligible. Matching is verbatim, not fuzzy.
|
|
28
|
+
None matching fails; there is no provider fallback.
|
|
28
29
|
Models with API pi-virtual cannot run as target children, even if scoped. Check the supplied
|
|
29
30
|
model API metadata; never pin a virtual model or inherit a pi-virtual parent. Ask for approval
|
|
30
31
|
to choose a physical scoped model instead, otherwise skip the definition. Do not silently
|
package/src/ui/model-picker.ts
CHANGED
|
@@ -431,7 +431,7 @@ export class OrderedModelEditorComponent extends Container {
|
|
|
431
431
|
|
|
432
432
|
private withScopeWarning(text: string): string {
|
|
433
433
|
if (this.scopedIdentities.size === 0) {
|
|
434
|
-
return `No
|
|
434
|
+
return `No scope restriction: Pick First (scoped) uses all available models. ${text}`;
|
|
435
435
|
}
|
|
436
436
|
return text;
|
|
437
437
|
}
|
package/src/ui/settings-ui.ts
CHANGED
|
@@ -259,7 +259,7 @@ async function configureFooterDisplay(
|
|
|
259
259
|
while (true) {
|
|
260
260
|
const action = await dialogMenu(
|
|
261
261
|
ctx,
|
|
262
|
-
"
|
|
262
|
+
"Footer display",
|
|
263
263
|
(
|
|
264
264
|
[
|
|
265
265
|
{
|
|
@@ -408,7 +408,7 @@ const MODEL_SELECTION_OPTIONS = [
|
|
|
408
408
|
id: "pick-first-scoped",
|
|
409
409
|
label: "Pick First (scoped)",
|
|
410
410
|
value: "First available preference in the session scope",
|
|
411
|
-
help: "Pick First (scoped):\nPick the first available model in the agent's models list that is also selected in the current session's /scoped-models.\nSkip unavailable models and providers without credentials.",
|
|
411
|
+
help: "Pick First (scoped):\nPick the first available model in the agent's models list that is also selected in the current session's /scoped-models. An empty scope allows all available models.\nSkip unavailable models and providers without credentials.",
|
|
412
412
|
},
|
|
413
413
|
{
|
|
414
414
|
id: "use-current",
|
|
@@ -419,7 +419,7 @@ const MODEL_SELECTION_OPTIONS = [
|
|
|
419
419
|
] as const;
|
|
420
420
|
|
|
421
421
|
const MODEL_SELECTION_HELP =
|
|
422
|
-
"Pick First (available): first preference with an enabled, authenticated provider in Pi.\nPick First (scoped): same, limited to the current session's /scoped-models.\nUse Current: ignore models and use the main session's current model; keep the agent's thinking level.\nOnly the models list affects runtime picking; modelSuggestions are search hints.\nSave and apply to affect agents when their sessions start.";
|
|
422
|
+
"Pick First (available): first preference with an enabled, authenticated provider in Pi.\nPick First (scoped): same, limited to the current session's /scoped-models when non-empty.\nUse Current: ignore models and use the main session's current model; keep the agent's thinking level.\nOnly the models list affects runtime picking; modelSuggestions are search hints.\nSave and apply to affect agents when their sessions start.";
|
|
423
423
|
|
|
424
424
|
export async function configureAgents(
|
|
425
425
|
ctx: ExtensionCommandContext,
|
|
@@ -537,10 +537,17 @@ async function configureAgentsDialog(
|
|
|
537
537
|
},
|
|
538
538
|
{
|
|
539
539
|
id: "costDisplay",
|
|
540
|
-
label: "
|
|
540
|
+
label: "Footer display",
|
|
541
541
|
value: COST_DISPLAY_OPTIONS.find((mode) => mode.id === draft.costDisplay)!.label,
|
|
542
542
|
help: "Configure footer location, displayed cost, and money icon in a submenu. Save and apply to update immediately.",
|
|
543
543
|
},
|
|
544
|
+
{
|
|
545
|
+
id: "loaderStyle",
|
|
546
|
+
label: "Loader style",
|
|
547
|
+
value:
|
|
548
|
+
AGENT_LOADERS[effectiveLoaderStyle(draft.loaderStyle, draft.nerdFontIcons)].label,
|
|
549
|
+
help: "Preview every animation frame and settled state.\nNerd Fonts Off: Braille (standard Unicode), ASCII, ASCII Star and ASCII Pulse. On: all palettes, including Circle and Hourglass.\nNerd-only saved styles fall back to ASCII while Nerd Fonts are off. Save and apply to update immediately.",
|
|
550
|
+
},
|
|
544
551
|
{
|
|
545
552
|
id: "housekeeping",
|
|
546
553
|
label: "[lab] Housekeeping model",
|
|
@@ -557,13 +564,6 @@ async function configureAgentsDialog(
|
|
|
557
564
|
value: draft.nerdFontIcons ? "On" : "Off",
|
|
558
565
|
help: "Experimental: display each agent type’s optional Nerd Font icon and unlock Nerd Font loader palettes.\nRequires a Nerd Font configured in your terminal; otherwise glyphs may appear as boxes.\nOff by default. Braille and ASCII loaders work with this Off. Save and apply to update immediately.",
|
|
559
566
|
},
|
|
560
|
-
{
|
|
561
|
-
id: "loaderStyle",
|
|
562
|
-
label: "[lab] Loader style",
|
|
563
|
-
value:
|
|
564
|
-
AGENT_LOADERS[effectiveLoaderStyle(draft.loaderStyle, draft.nerdFontIcons)].label,
|
|
565
|
-
help: "Preview every animation frame and settled state.\nNerd Fonts Off: Braille (standard Unicode), ASCII, ASCII Star and ASCII Pulse. On: all palettes, including Circle and Hourglass.\nNerd-only saved styles fall back to ASCII while Nerd Fonts are off. Save and apply to update immediately.",
|
|
566
|
-
},
|
|
567
567
|
{
|
|
568
568
|
id: "subagentExtensions",
|
|
569
569
|
label: "[lab] Subagent extensions",
|
|
@@ -679,7 +679,7 @@ async function configureAgentsDialog(
|
|
|
679
679
|
const styles = availableLoaderStyles(draft.nerdFontIcons);
|
|
680
680
|
const style = await dialogMenu(
|
|
681
681
|
ctx,
|
|
682
|
-
"
|
|
682
|
+
"Loader style",
|
|
683
683
|
LOADER_OPTIONS.filter((option) => styles.includes(option.id)),
|
|
684
684
|
{ selectedId: effectiveLoaderStyle(draft.loaderStyle, draft.nerdFontIcons) },
|
|
685
685
|
);
|