pi-subagent-manager 1.13.1 → 1.14.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.
- package/dist/index.js +20 -4
- package/dist/orch/checklist-integration.js +5 -0
- package/dist/orch/housekeeping.js +1 -1
- package/dist/orch/runtime.js +1 -1
- package/dist/ui/agent-loader.js +7 -1
- package/dist/ui/live-agent-view.js +2 -2
- package/dist/ui/status-ui.js +2 -2
- package/dist/ui/ui.js +7 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CAPABILITY_PROBE_CHANNEL, respondDiagnosticCapability, diagnosticAgentText, } from "./orch/diagnostics.js";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { buildSessionContext, getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import { fuzzyFilter } from "@earendil-works/pi-tui";
|
|
4
|
+
import { fuzzyFilter, Text } from "@earendil-works/pi-tui";
|
|
5
5
|
import { ConfigStore } from "./prefs/config.js";
|
|
6
6
|
import { IMPORT_REQUEST_PREFIX, markImportOffered, offerAgentImport, } from "./prefs/agent-import.js";
|
|
7
7
|
import { ThreadManager } from "./orch/manager.js";
|
|
@@ -16,11 +16,12 @@ import { createInheritedToolSource } from "./orch/inherited-tools.js";
|
|
|
16
16
|
import { subagentPrompt } from "./orch/prompt.js";
|
|
17
17
|
import { ChecklistMetaMirror, checklistStatus } from "./orch/checklist-integration.js";
|
|
18
18
|
import { agentTools } from "./orch/tools.js";
|
|
19
|
-
import { editAgentTypes, updateWidget } from "./ui/ui.js";
|
|
19
|
+
import { agentStartupList, editAgentTypes, updateWidget } from "./ui/ui.js";
|
|
20
20
|
import { canOpenDialog, dialogMenu } from "./ui/dialog.js";
|
|
21
21
|
import { COST_ENTRY, CostLedger } from "./orch/cost-ledger.js";
|
|
22
22
|
import { readRegistry, RegistryWriter } from "./orch/registry.js";
|
|
23
23
|
import { CostFooterController } from "./ui/cost-footer.js";
|
|
24
|
+
const STARTUP_AGENTS_ENTRY = "pi-subagent:startup-agents:v1";
|
|
24
25
|
const ROOT_MAILBOX_ENTRY = "pi-subagent:root-mailbox:v1";
|
|
25
26
|
const ROOT_SUMMARY_MESSAGE = "pi-subagent:final-recap";
|
|
26
27
|
const ROOT_WAKE_MESSAGE = "pi-subagent:wake";
|
|
@@ -31,6 +32,12 @@ export default function piSubagent(pi) {
|
|
|
31
32
|
respondDiagnosticCapability(payload);
|
|
32
33
|
});
|
|
33
34
|
let context;
|
|
35
|
+
let startupAgents;
|
|
36
|
+
pi.registerEntryRenderer(STARTUP_AGENTS_ENTRY, (entry, _options, theme) => {
|
|
37
|
+
if (!startupAgents || entry.data?.id !== startupAgents.id)
|
|
38
|
+
return undefined;
|
|
39
|
+
return new Text(agentStartupList(startupAgents.agents, theme, startupAgents.icons), 0, 0);
|
|
40
|
+
});
|
|
34
41
|
const inheritedTools = createInheritedToolSource(pi);
|
|
35
42
|
let store = new ConfigStore({
|
|
36
43
|
cwd: process.cwd(),
|
|
@@ -590,11 +597,20 @@ export default function piSubagent(pi) {
|
|
|
590
597
|
};
|
|
591
598
|
pi.on("session_start", async (event, ctx) => {
|
|
592
599
|
capabilityActive = true;
|
|
600
|
+
startupAgents = undefined;
|
|
593
601
|
await attachSession(ctx, true, event.reason !== "startup");
|
|
594
|
-
if (limits.subagentMode !== "off")
|
|
602
|
+
if (limits.subagentMode !== "off") {
|
|
595
603
|
await importAgents(ctx, true);
|
|
604
|
+
if (event.reason === "startup" && ctx.hasUI && ctx.mode === "tui") {
|
|
605
|
+
startupAgents = { id: randomUUID(), agents: store.list(), icons: limits.nerdFontIcons };
|
|
606
|
+
pi.appendEntry(STARTUP_AGENTS_ENTRY, { id: startupAgents.id });
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
pi.on("session_tree", async (_event, ctx) => {
|
|
611
|
+
startupAgents = undefined;
|
|
612
|
+
await attachSession(ctx);
|
|
596
613
|
});
|
|
597
|
-
pi.on("session_tree", async (_event, ctx) => attachSession(ctx));
|
|
598
614
|
const stopWorkingThreads = async () => {
|
|
599
615
|
cancelSummary();
|
|
600
616
|
closeNavigation();
|
|
@@ -172,5 +172,10 @@ export function checklistGuidance(mode) {
|
|
|
172
172
|
? "As /root in orchestration mode you MUST use checklist_create, checklist_read and checklist_update to plan, track and report orchestration work: create a task for every delegated unit and keep statuses current."
|
|
173
173
|
: "When you track work with checklist_create, checklist_read or checklist_update, you may also label delegated tasks by agent. Using the checklist is optional in opportunistic mode.",
|
|
174
174
|
tagging,
|
|
175
|
+
...(mode === "orchestration"
|
|
176
|
+
? [
|
|
177
|
+
"For tasks needing an expanded plan, set meta.plan to the path of one local .txt or .md file; the assigned agent can read it if needed.",
|
|
178
|
+
]
|
|
179
|
+
: []),
|
|
175
180
|
].join("\n");
|
|
176
181
|
}
|
|
@@ -229,7 +229,7 @@ export function createHousekeepingCompleter(getContext, getModelIdentity, onUsag
|
|
|
229
229
|
timestamp: Date.now(),
|
|
230
230
|
},
|
|
231
231
|
],
|
|
232
|
-
}, { signal, maxTokens: 96, cacheRetention: "none" })
|
|
232
|
+
}, { signal, maxTokens: 96, cacheRetention: "none", sessionId: session?.sessionId })
|
|
233
233
|
.result();
|
|
234
234
|
const entry = reportHousekeepingUsage(session, response);
|
|
235
235
|
try {
|
package/dist/orch/runtime.js
CHANGED
|
@@ -373,7 +373,7 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
373
373
|
options.type.systemPrompt,
|
|
374
374
|
`Your thread path is ${options.path}.`,
|
|
375
375
|
options.parentPath
|
|
376
|
-
? `Your lexical parent is ${options.parentPath}; inherited conversation comes only from that parent.`
|
|
376
|
+
? `Your lexical parent is ${options.parentPath}; inherited conversation comes only from that parent. Treat it as historical context, not your assignment; do not replay its tasks or actions. Your initial assignment is the task message after that history; follow subsequent instructions for your thread.`
|
|
377
377
|
: "You are an independent root thread with no inherited history.",
|
|
378
378
|
"When finished, give your final answer normally so it can be handed back. To retain unfinished work without a final answer, call agent_pause (if available), then stop; resume only when instructed.",
|
|
379
379
|
delegationGuidance(options.canSpawnChildren !== false),
|
package/dist/ui/agent-loader.js
CHANGED
|
@@ -16,6 +16,7 @@ export const AGENT_LOADERS = {
|
|
|
16
16
|
label: "Braille",
|
|
17
17
|
requiresNerdFont: false,
|
|
18
18
|
frames: Array.from("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"),
|
|
19
|
+
interval: 120,
|
|
19
20
|
states: { completed: "✓", paused: "Ⅱ", failed: "×", stopped: "■" },
|
|
20
21
|
},
|
|
21
22
|
hourglass: {
|
|
@@ -49,10 +50,15 @@ export function availableLoaderStyles(nerdFontIcons) {
|
|
|
49
50
|
export function effectiveLoaderStyle(style, nerdFontIcons) {
|
|
50
51
|
return !nerdFontIcons && AGENT_LOADERS[style].requiresNerdFont ? "ascii" : style;
|
|
51
52
|
}
|
|
53
|
+
export function loaderInterval(style, nerdFontIcons) {
|
|
54
|
+
const { interval } = AGENT_LOADERS[effectiveLoaderStyle(style, nerdFontIcons)];
|
|
55
|
+
return interval ?? AGENT_PROGRESS_INTERVAL;
|
|
56
|
+
}
|
|
52
57
|
export function agentProgressIcon(thread, nerdFontIcons, now = Date.now(), animate = true, loaderStyle = "circle") {
|
|
53
58
|
const loader = AGENT_LOADERS[effectiveLoaderStyle(loaderStyle, nerdFontIcons)];
|
|
54
59
|
if (thread.state === "starting" || thread.state === "running") {
|
|
55
|
-
const
|
|
60
|
+
const interval = loader.interval ?? AGENT_PROGRESS_INTERVAL;
|
|
61
|
+
const index = animate ? Math.floor(Math.max(0, now) / interval) : 0;
|
|
56
62
|
return loader.frames[index % loader.frames.length];
|
|
57
63
|
}
|
|
58
64
|
return loader.states[thread.state];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getMarkdownTheme } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { Input, Key, Markdown, matchesKey, ScrollView, stripTerminalSequences, truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "@earendil-works/pi-tui";
|
|
3
3
|
import { dialogText } from "./dialog.js";
|
|
4
|
-
import {
|
|
4
|
+
import { agentProgressIcon, agentTypeLabel, loaderInterval } from "./ui.js";
|
|
5
5
|
import { renderTranscriptTool } from "./transcript-tool.js";
|
|
6
6
|
const DETAIL_CYCLE = ["full", "preview", "compact"];
|
|
7
7
|
export function fillViewport(lines, width, height) {
|
|
@@ -181,7 +181,7 @@ export class LiveAgentView {
|
|
|
181
181
|
this.progressTimer = undefined;
|
|
182
182
|
}
|
|
183
183
|
else if (this.progressTimer === undefined) {
|
|
184
|
-
this.progressTimer = setInterval(() => this.scheduleRender(),
|
|
184
|
+
this.progressTimer = setInterval(() => this.scheduleRender(), loaderInterval(this.loaderStyle, this.nerdFontIcons));
|
|
185
185
|
this.progressTimer.unref?.();
|
|
186
186
|
}
|
|
187
187
|
}
|
package/dist/ui/status-ui.js
CHANGED
|
@@ -2,7 +2,7 @@ import { getKeybindings, setKeybindings, Key, matchesKey, } from "@earendil-work
|
|
|
2
2
|
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
3
3
|
import { canOpenDialog, DIALOG_OPTIONS, DialogSession, scopeDialogContext, dialogMenu, dialogEditor, dialogHeight, dialogText, frameDialog, } from "./dialog.js";
|
|
4
4
|
import { buildStatusTree, threadActivity } from "./thread-tree.js";
|
|
5
|
-
import {
|
|
5
|
+
import { agentProgressIcon, agentTypeBadge, agentTypeLabel, loaderInterval, showThreads, threadMetrics, } from "./ui.js";
|
|
6
6
|
import { LiveAgentView, fillViewport } from "./live-agent-view.js";
|
|
7
7
|
export { buildStatusTree };
|
|
8
8
|
const ROOT = "/root";
|
|
@@ -93,7 +93,7 @@ export class StatusDialog {
|
|
|
93
93
|
const delay = this.service
|
|
94
94
|
.list()
|
|
95
95
|
.some((thread) => thread.path !== ROOT && (thread.state === "starting" || thread.state === "running"))
|
|
96
|
-
?
|
|
96
|
+
? loaderInterval(this.loaderStyle, this.nerdFontIcons)
|
|
97
97
|
: 1000;
|
|
98
98
|
if (this.timer !== undefined && this.refreshDelay === delay)
|
|
99
99
|
return;
|
package/dist/ui/ui.js
CHANGED
|
@@ -11,8 +11,8 @@ import { editModelPreferences, MODEL_EDITOR_CANCEL } from "./model-picker.js";
|
|
|
11
11
|
import { editToolSelection, TOOL_EDITOR_CANCEL } from "./tool-picker.js";
|
|
12
12
|
import { canOpenDialog, dialogEditor, dialogMenu, dialogHeight, frameDialog, DIALOG_OPTIONS, withDialogSession, } from "./dialog.js";
|
|
13
13
|
import { getModelPreferences } from "../prefs/models.js";
|
|
14
|
-
import {
|
|
15
|
-
export { AGENT_PROGRESS_INTERVAL, agentProgressIcon } from "./agent-loader.js";
|
|
14
|
+
import { agentProgressIcon, isAgentLoaderGlyph, loaderInterval } from "./agent-loader.js";
|
|
15
|
+
export { AGENT_PROGRESS_INTERVAL, agentProgressIcon, loaderInterval } from "./agent-loader.js";
|
|
16
16
|
import { buildStatusTree, lastStarted, threadActivity } from "./thread-tree.js";
|
|
17
17
|
import { THINKING_LEVELS, } from "../types.js";
|
|
18
18
|
export function sanitizeText(text) {
|
|
@@ -43,6 +43,10 @@ export function agentTypeLabel(type, icon, nerdFontIcons = false, loaderIcon) {
|
|
|
43
43
|
const progress = loaderIcon && isAgentLoaderGlyph(loaderIcon, nerdFontIcons) ? `${loaderIcon} ` : "";
|
|
44
44
|
return `${progress}${role}${sanitizeText(type)}`;
|
|
45
45
|
}
|
|
46
|
+
export function agentStartupList(agents, theme, nerdFontIcons) {
|
|
47
|
+
const names = agents.map((agent) => theme.fg(agentColorToken(agent.color), agentTypeLabel(agent.name, agent.icon, nerdFontIcons)));
|
|
48
|
+
return `${theme.fg("warning", "[Agents]")}\n ${names.length ? names.join(", ") : "(none)"}`;
|
|
49
|
+
}
|
|
46
50
|
export function agentTypeBadge(type, color, theme, icon, nerdFontIcons = false, loaderIcon) {
|
|
47
51
|
return contrastPill(agentTypeLabel(type, icon, nerdFontIcons, loaderIcon), color, theme);
|
|
48
52
|
}
|
|
@@ -282,7 +286,7 @@ export function updateWidget(ctx, threads, mode = "full", nerdFontIcons = false,
|
|
|
282
286
|
ctx.ui.setWidget("pi-subagent", (tui) => {
|
|
283
287
|
let timer;
|
|
284
288
|
if (snapshot.some(isLive)) {
|
|
285
|
-
timer = setInterval(() => tui.requestRender(),
|
|
289
|
+
timer = setInterval(() => tui.requestRender(), loaderInterval(loaderStyle, nerdFontIcons));
|
|
286
290
|
timer.unref();
|
|
287
291
|
}
|
|
288
292
|
return {
|