@timmyjl12/pi-subagents 0.20.0 → 0.21.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/CHANGELOG.md +862 -827
- package/README.md +1125 -1080
- package/dist/active-agents-prompt.d.ts +31 -9
- package/dist/active-agents-prompt.js +73 -9
- package/dist/agent-color.js +9 -1
- package/dist/agent-file-toggle.d.ts +1 -1
- package/dist/agent-manager.d.ts +405 -18
- package/dist/agent-manager.js +1661 -131
- package/dist/agent-runner.d.ts +45 -6
- package/dist/agent-runner.js +109 -18
- package/dist/agent-types.d.ts +30 -7
- package/dist/agent-types.js +38 -9
- package/dist/awaited-result.d.ts +37 -0
- package/dist/awaited-result.js +150 -0
- package/dist/child-session-shutdown.d.ts +19 -1
- package/dist/child-session-shutdown.js +60 -11
- package/dist/cleanup-plans.d.ts +10 -0
- package/dist/cleanup-plans.js +112 -0
- package/dist/cross-extension-rpc.d.ts +8 -1
- package/dist/cross-extension-rpc.js +59 -5
- package/dist/custom-agents.d.ts +34 -9
- package/dist/custom-agents.js +308 -111
- package/dist/default-agents.d.ts +1 -1
- package/dist/env.d.ts +1 -1
- package/dist/error-log.d.ts +6 -0
- package/dist/error-log.js +8 -0
- package/dist/force-main-model.d.ts +21 -0
- package/dist/force-main-model.js +28 -0
- package/dist/goal-bridge.d.ts +155 -0
- package/dist/goal-bridge.js +305 -0
- package/dist/group-join.d.ts +5 -1
- package/dist/group-join.js +52 -7
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2827 -333
- package/dist/invocation-config.d.ts +30 -3
- package/dist/invocation-config.js +30 -1
- package/dist/memory.d.ts +1 -1
- package/dist/mention-clone.d.ts +1 -1
- package/dist/model-scope.d.ts +1 -1
- package/dist/nested-tools.d.ts +22 -1
- package/dist/nested-tools.js +120 -26
- package/dist/output-file.d.ts +15 -4
- package/dist/output-file.js +146 -43
- package/dist/prompts.d.ts +1 -1
- package/dist/recovery.d.ts +1 -1
- package/dist/report-cleanup.d.ts +204 -0
- package/dist/report-cleanup.js +1632 -0
- package/dist/report-store.d.ts +738 -0
- package/dist/report-store.js +3616 -0
- package/dist/schedule-store.d.ts +14 -6
- package/dist/schedule-store.js +88 -58
- package/dist/schedule.d.ts +20 -8
- package/dist/schedule.js +135 -74
- package/dist/settings.d.ts +39 -11
- package/dist/settings.js +22 -5
- package/dist/status-note.d.ts +1 -1
- package/dist/structured-output.d.ts +1 -1
- package/dist/types.d.ts +32 -3
- package/dist/ui/agent-mention.d.ts +2 -2
- package/dist/ui/agent-widget.d.ts +82 -13
- package/dist/ui/agent-widget.js +155 -37
- package/dist/ui/cleanup-preview.d.ts +59 -0
- package/dist/ui/cleanup-preview.js +466 -0
- package/dist/ui/conversation-viewer.d.ts +4 -4
- package/dist/ui/conversation-viewer.js +10 -6
- package/dist/ui/fleet-list.d.ts +3 -3
- package/dist/ui/fleet-list.js +3 -3
- package/dist/ui/fleet-overlay.d.ts +37 -6
- package/dist/ui/fleet-overlay.js +214 -18
- package/dist/ui/hub-feed.d.ts +52 -0
- package/dist/ui/hub-feed.js +148 -0
- package/dist/ui/native-transcript.js +5 -1
- package/dist/ui/schedule-menu.d.ts +1 -1
- package/dist/ui/schedule-menu.js +1 -1
- package/dist/ui/workflow-card.d.ts +4 -4
- package/dist/ui/workflow-dialog.d.ts +4 -4
- package/dist/ui/workflow-dialog.js +8 -3
- package/dist/ui/workflow-menu.d.ts +2 -2
- package/dist/usage.d.ts +12 -0
- package/dist/usage.js +28 -1
- package/dist/workflow/entry.d.ts +3 -3
- package/dist/workflow/host.d.ts +7 -4
- package/dist/workflow/host.js +162 -48
- package/dist/workflow/journal.d.ts +23 -7
- package/dist/workflow/journal.js +80 -23
- package/dist/workflow/progress.d.ts +1 -1
- package/dist/workflow/runtime.d.ts +45 -6
- package/dist/workflow/runtime.js +105 -16
- package/dist/workflow/task.d.ts +13 -4
- package/dist/workflow/task.js +7 -1
- package/dist/workflow/tool-description.d.ts +7 -2
- package/dist/workflow/tool-description.js +10 -5
- package/docs/{FORK.md → DEVELOPMENT.md} +4 -4
- package/docs/artifacts.md +93 -0
- package/docs/rpc.md +252 -189
- package/docs/runtime-performance.md +53 -0
- package/docs/workflows.md +48 -18
- package/examples/agent-tool-description.md +2 -2
- package/examples/workflows/review-panel.js +6 -3
- package/package.json +5 -5
- package/src/active-agents-prompt.ts +115 -39
- package/src/agent-color.ts +10 -2
- package/src/agent-file-toggle.ts +2 -2
- package/src/agent-manager.ts +3312 -1601
- package/src/agent-runner.ts +164 -36
- package/src/agent-types.ts +56 -11
- package/src/awaited-result.ts +187 -0
- package/src/child-session-shutdown.ts +114 -46
- package/src/cleanup-plans.ts +112 -0
- package/src/cross-extension-rpc.ts +68 -9
- package/src/custom-agents.ts +384 -112
- package/src/default-agents.ts +1 -1
- package/src/enabled-models.ts +1 -1
- package/src/env.ts +1 -1
- package/src/error-log.ts +10 -1
- package/src/force-main-model.ts +29 -0
- package/src/goal-bridge.ts +468 -0
- package/src/group-join.ts +56 -9
- package/src/index.ts +2987 -349
- package/src/invocation-config.ts +50 -4
- package/src/memory.ts +1 -1
- package/src/mention-clone.ts +3 -3
- package/src/model-scope.ts +1 -1
- package/src/nested-tools.ts +164 -33
- package/src/output-file.ts +168 -46
- package/src/prompts.ts +1 -1
- package/src/recovery.ts +2 -2
- package/src/report-cleanup.ts +2044 -0
- package/src/report-store.ts +4133 -0
- package/src/schedule-store.ts +244 -201
- package/src/schedule.ts +144 -80
- package/src/settings.ts +61 -16
- package/src/skill-loader.ts +1 -1
- package/src/standalone-fallback.ts +2 -2
- package/src/status-note.ts +1 -1
- package/src/structured-output.ts +1 -1
- package/src/types.ts +33 -3
- package/src/ui/agent-mention.ts +3 -3
- package/src/ui/agent-widget.ts +179 -45
- package/src/ui/cleanup-preview.ts +518 -0
- package/src/ui/conversation-viewer.ts +19 -15
- package/src/ui/fleet-list.ts +7 -7
- package/src/ui/fleet-overlay.ts +1048 -847
- package/src/ui/hub-feed.ts +179 -0
- package/src/ui/native-transcript.ts +7 -3
- package/src/ui/schedule-menu.ts +4 -4
- package/src/ui/workflow-card.ts +4 -4
- package/src/ui/workflow-dialog.ts +10 -6
- package/src/ui/workflow-menu.ts +4 -4
- package/src/usage.ts +53 -3
- package/src/workflow/collisions.ts +1 -1
- package/src/workflow/entry.ts +3 -3
- package/src/workflow/host.ts +174 -54
- package/src/workflow/journal.ts +80 -23
- package/src/workflow/progress.ts +1 -1
- package/src/workflow/runtime.ts +146 -23
- package/src/workflow/saved.ts +3 -3
- package/src/workflow/task.ts +18 -7
- package/src/workflow/tool-description.ts +10 -5
|
@@ -1,18 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main-session awareness of live subagents.
|
|
3
3
|
*
|
|
4
|
-
* A compact `<pi-subagents>`
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* A compact `<pi-subagents>` status message lists running/queued agents, so the
|
|
5
|
+
* main model can interpret "cancel that task" and choose the appropriate stop
|
|
6
|
+
* or steer tool.
|
|
7
|
+
*
|
|
8
|
+
* Delivered as a hidden custom message appended at the next prompt — and only
|
|
9
|
+
* when the list differs from the last one on the branch — rather than as a
|
|
10
|
+
* system-prompt section. A section edit rewrites the prompt head: providers
|
|
11
|
+
* without mid-conversation system messages (pi collapses them into the head)
|
|
12
|
+
* lose the whole cached prefix on every start and finish, and append-mode
|
|
13
|
+
* children inherit the volatile list through `ctx.getSystemPrompt()`. An
|
|
14
|
+
* appended message leaves everything already sent untouched.
|
|
7
15
|
*/
|
|
8
|
-
import type {
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
import type { SessionEntry } from "@earendil-works/pi-coding-agent";
|
|
17
|
+
import type { AgentRecord } from "./types.ts";
|
|
18
|
+
/** `customType` of the status message; `display: false` keeps it out of the TUI. */
|
|
19
|
+
export declare const ACTIVE_AGENTS_MESSAGE_TYPE = "subagents-active";
|
|
11
20
|
type ListedRecord = Pick<AgentRecord, "id" | "handle" | "alias" | "description" | "status" | "isBackground">;
|
|
21
|
+
/** The subset of a branch entry this module reads. */
|
|
22
|
+
type BranchEntry = Pick<SessionEntry, "type"> & {
|
|
23
|
+
id?: string;
|
|
24
|
+
customType?: string;
|
|
25
|
+
content?: unknown;
|
|
26
|
+
firstKeptEntryId?: string | null;
|
|
27
|
+
};
|
|
12
28
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
29
|
+
* List text for the running/queued agents, or undefined when there are none.
|
|
30
|
+
* Contains only stable fields — no durations or token counts — so the text
|
|
31
|
+
* changes only when the set of agents or their status does.
|
|
16
32
|
*/
|
|
17
33
|
export declare function buildActiveAgentsSection(records: readonly ListedRecord[]): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Status message content to append at this prompt, or undefined when the
|
|
36
|
+
* branch already carries the current list. Once agents drain, the model is
|
|
37
|
+
* told so exactly once; a branch that never listed any gets nothing.
|
|
38
|
+
*/
|
|
39
|
+
export declare function nextActiveAgentsMessage(records: readonly ListedRecord[], branch: readonly BranchEntry[]): string | undefined;
|
|
18
40
|
export {};
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main-session awareness of live subagents.
|
|
3
3
|
*
|
|
4
|
-
* A compact `<pi-subagents>`
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* A compact `<pi-subagents>` status message lists running/queued agents, so the
|
|
5
|
+
* main model can interpret "cancel that task" and choose the appropriate stop
|
|
6
|
+
* or steer tool.
|
|
7
|
+
*
|
|
8
|
+
* Delivered as a hidden custom message appended at the next prompt — and only
|
|
9
|
+
* when the list differs from the last one on the branch — rather than as a
|
|
10
|
+
* system-prompt section. A section edit rewrites the prompt head: providers
|
|
11
|
+
* without mid-conversation system messages (pi collapses them into the head)
|
|
12
|
+
* lose the whole cached prefix on every start and finish, and append-mode
|
|
13
|
+
* children inherit the volatile list through `ctx.getSystemPrompt()`. An
|
|
14
|
+
* appended message leaves everything already sent untouched.
|
|
7
15
|
*/
|
|
8
|
-
/**
|
|
9
|
-
export const
|
|
10
|
-
/** Rows listed in the
|
|
16
|
+
/** `customType` of the status message; `display: false` keeps it out of the TUI. */
|
|
17
|
+
export const ACTIVE_AGENTS_MESSAGE_TYPE = "subagents-active";
|
|
18
|
+
/** Rows listed in the message; the rest are summarized as a count. */
|
|
11
19
|
const MAX_ROWS = 10;
|
|
20
|
+
const NONE_ACTIVE = "No subagents are running or queued now.";
|
|
12
21
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
22
|
+
* List text for the running/queued agents, or undefined when there are none.
|
|
23
|
+
* Contains only stable fields — no durations or token counts — so the text
|
|
24
|
+
* changes only when the set of agents or their status does.
|
|
16
25
|
*/
|
|
17
26
|
export function buildActiveAgentsSection(records) {
|
|
18
27
|
const active = records.filter(r => r.status === "running" || r.status === "queued");
|
|
@@ -32,3 +41,58 @@ export function buildActiveAgentsSection(records) {
|
|
|
32
41
|
"If the user asks to cancel/stop one of these, call stop_subagent with its id or handle; to redirect it, call steer_subagent.",
|
|
33
42
|
].join("\n");
|
|
34
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* The branch as the model still sees it after compaction. Mirrors pi's
|
|
46
|
+
* `buildContextEntries`: the latest compaction entry stands in for everything
|
|
47
|
+
* before it, except the entries it retained (`firstKeptEntryId` onwards) and
|
|
48
|
+
* everything after it. A branch that is already projected — the compaction
|
|
49
|
+
* first — passes through unchanged.
|
|
50
|
+
*/
|
|
51
|
+
function projectedBranch(branch) {
|
|
52
|
+
let compactionAt = -1;
|
|
53
|
+
for (let i = branch.length - 1; i >= 0; i--) {
|
|
54
|
+
if (branch[i].type === "compaction") {
|
|
55
|
+
compactionAt = i;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (compactionAt < 0)
|
|
60
|
+
return branch;
|
|
61
|
+
const firstKept = branch[compactionAt].firstKeptEntryId;
|
|
62
|
+
const keptFrom = firstKept ? branch.findIndex(entry => entry.id === firstKept) : -1;
|
|
63
|
+
const retained = keptFrom >= 0 && keptFrom < compactionAt ? branch.slice(keptFrom, compactionAt) : [];
|
|
64
|
+
return [...retained, ...branch.slice(compactionAt + 1)];
|
|
65
|
+
}
|
|
66
|
+
/** Text of the latest status message the model still has on this branch. */
|
|
67
|
+
function lastAnnouncement(branch) {
|
|
68
|
+
const visible = projectedBranch(branch);
|
|
69
|
+
for (let i = visible.length - 1; i >= 0; i--) {
|
|
70
|
+
const entry = visible[i];
|
|
71
|
+
if (entry.type !== "custom_message" || entry.customType !== ACTIVE_AGENTS_MESSAGE_TYPE)
|
|
72
|
+
continue;
|
|
73
|
+
if (typeof entry.content === "string")
|
|
74
|
+
return entry.content;
|
|
75
|
+
if (!Array.isArray(entry.content))
|
|
76
|
+
return undefined;
|
|
77
|
+
return entry.content
|
|
78
|
+
.map((part) => (part.type === "text" && typeof part.text === "string" ? part.text : ""))
|
|
79
|
+
.join("");
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Status message content to append at this prompt, or undefined when the
|
|
85
|
+
* branch already carries the current list. Once agents drain, the model is
|
|
86
|
+
* told so exactly once; a branch that never listed any gets nothing.
|
|
87
|
+
*/
|
|
88
|
+
export function nextActiveAgentsMessage(records, branch) {
|
|
89
|
+
const list = buildActiveAgentsSection(records);
|
|
90
|
+
const last = lastAnnouncement(branch);
|
|
91
|
+
const wrap = (body) => `<pi-subagents>\n${body}\n</pi-subagents>`;
|
|
92
|
+
if (list) {
|
|
93
|
+
const text = wrap(list);
|
|
94
|
+
return text === last ? undefined : text;
|
|
95
|
+
}
|
|
96
|
+
const idle = wrap(NONE_ACTIVE);
|
|
97
|
+
return last === undefined || last === idle ? undefined : idle;
|
|
98
|
+
}
|
package/dist/agent-color.js
CHANGED
|
@@ -119,5 +119,13 @@ export function renderAgentName(type, theme, style = {}) {
|
|
|
119
119
|
if (!type)
|
|
120
120
|
return renderAgentNameLabel("Agent", undefined, theme, style);
|
|
121
121
|
const config = getConfig(type);
|
|
122
|
-
|
|
122
|
+
// displayName is user-authored config free text. Every caller feeds the
|
|
123
|
+
// result to a terminal ROW; a control byte here must not break the row.
|
|
124
|
+
// ANSI styling is added by renderAgentNameLabel after this flattening.
|
|
125
|
+
const displayName = config.displayName.replace(/\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g, " ")
|
|
126
|
+
.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, " ")
|
|
127
|
+
.replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]+/g, " ")
|
|
128
|
+
.replace(/\s+/g, " ")
|
|
129
|
+
.trim();
|
|
130
|
+
return renderAgentNameLabel(displayName || type, config.color, theme, style);
|
|
123
131
|
}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* reports `changed: false` for the spellings it cannot rewrite, so the caller
|
|
25
25
|
* refuses honestly rather than announcing a change it did not make.
|
|
26
26
|
*/
|
|
27
|
-
import type { AgentConfig } from "./types.
|
|
27
|
+
import type { AgentConfig } from "./types.ts";
|
|
28
28
|
export type AgentFileLocation = "project" | "workspace" | "personal";
|
|
29
29
|
export declare const projectAgentsDir: (cwd?: string) => string;
|
|
30
30
|
export declare const workspaceAgentsDir: (cwd?: string) => string;
|