@timmyjl12/pi-subagents 0.20.0 → 0.21.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/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 +3612 -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 +4130 -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
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hub-feed.ts — pure data for the fleet overlay's live panes (omp Agent Hub parity).
|
|
3
|
+
*
|
|
4
|
+
* - `transcriptTail`: the last few events of one agent's child session — prompts,
|
|
5
|
+
* replies, tool calls and failed results — for the right pane under the detail card.
|
|
6
|
+
* - `activityFeed`: the same events across every agent, newest first, for the
|
|
7
|
+
* Activity tab, with All / Errors / Responses / Tools filters.
|
|
8
|
+
* - `treeOrder`: parent → child ordering for the tree view.
|
|
9
|
+
*
|
|
10
|
+
* Everything is derived from `session.messages` on render; no extra state is
|
|
11
|
+
* recorded, so the feed can never disagree with the conversation viewer.
|
|
12
|
+
*/
|
|
13
|
+
export const ACTIVITY_FILTERS = ["all", "errors", "responses", "tools"];
|
|
14
|
+
function oneLine(text, max = 240) {
|
|
15
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
16
|
+
return flat.length > max ? `${flat.slice(0, max - 1)}…` : flat;
|
|
17
|
+
}
|
|
18
|
+
function textOf(content) {
|
|
19
|
+
if (typeof content === "string")
|
|
20
|
+
return content;
|
|
21
|
+
if (!Array.isArray(content))
|
|
22
|
+
return "";
|
|
23
|
+
return content
|
|
24
|
+
.map(part => (part && typeof part === "object" && part.type === "text" ? String(part.text ?? "") : ""))
|
|
25
|
+
.filter(Boolean)
|
|
26
|
+
.join(" ");
|
|
27
|
+
}
|
|
28
|
+
/** Compact `name(arg)` label: the first string argument says the most (path, pattern, command). */
|
|
29
|
+
function toolLabel(part) {
|
|
30
|
+
const name = typeof part.name === "string" ? part.name : "tool";
|
|
31
|
+
const args = part.arguments && typeof part.arguments === "object" ? Object.values(part.arguments) : [];
|
|
32
|
+
const first = args.find(value => typeof value === "string");
|
|
33
|
+
return first ? `${name}(${oneLine(first, 80)})` : `${name}()`;
|
|
34
|
+
}
|
|
35
|
+
/** Events of one message, in order. */
|
|
36
|
+
export function eventsOf(message) {
|
|
37
|
+
const m = (message ?? {});
|
|
38
|
+
const at = typeof m.timestamp === "number" ? m.timestamp : undefined;
|
|
39
|
+
const events = [];
|
|
40
|
+
if (m.role === "user") {
|
|
41
|
+
const text = oneLine(textOf(m.content));
|
|
42
|
+
if (text)
|
|
43
|
+
events.push({ kind: "prompt", text, at });
|
|
44
|
+
}
|
|
45
|
+
else if (m.role === "assistant") {
|
|
46
|
+
if (Array.isArray(m.content)) {
|
|
47
|
+
for (const part of m.content) {
|
|
48
|
+
if (part?.type === "text" && typeof part.text === "string" && part.text.trim()) {
|
|
49
|
+
events.push({ kind: "response", text: oneLine(part.text), at });
|
|
50
|
+
}
|
|
51
|
+
else if (part?.type === "toolCall") {
|
|
52
|
+
events.push({ kind: "tool", text: toolLabel(part), at });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (m.stopReason === "error" && typeof m.errorMessage === "string") {
|
|
57
|
+
events.push({ kind: "error", text: oneLine(m.errorMessage), at });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else if (m.role === "toolResult" && m.isError === true) {
|
|
61
|
+
const name = typeof m.toolName === "string" ? m.toolName : "tool";
|
|
62
|
+
events.push({ kind: "error", text: `${name} failed: ${oneLine(textOf(m.content), 160)}`, at });
|
|
63
|
+
}
|
|
64
|
+
return events;
|
|
65
|
+
}
|
|
66
|
+
function messagesOf(record) {
|
|
67
|
+
const messages = record.session?.messages;
|
|
68
|
+
return Array.isArray(messages) ? messages : [];
|
|
69
|
+
}
|
|
70
|
+
/** The last `max` events of an agent's session, oldest → newest (bottom is live). */
|
|
71
|
+
export function transcriptTail(record, max) {
|
|
72
|
+
if (max <= 0)
|
|
73
|
+
return [];
|
|
74
|
+
const messages = messagesOf(record);
|
|
75
|
+
const out = [];
|
|
76
|
+
// Walk backwards and stop early: a long session never pays for its whole history.
|
|
77
|
+
for (let i = messages.length - 1; i >= 0 && out.length < max; i -= 1) {
|
|
78
|
+
const events = eventsOf(messages[i]);
|
|
79
|
+
for (let j = events.length - 1; j >= 0 && out.length < max; j -= 1)
|
|
80
|
+
out.push(events[j]);
|
|
81
|
+
}
|
|
82
|
+
return out.reverse();
|
|
83
|
+
}
|
|
84
|
+
function matchesFilter(kind, filter) {
|
|
85
|
+
if (filter === "all")
|
|
86
|
+
return true;
|
|
87
|
+
if (filter === "errors")
|
|
88
|
+
return kind === "error";
|
|
89
|
+
if (filter === "responses")
|
|
90
|
+
return kind === "response";
|
|
91
|
+
return kind === "tool";
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Combined log across agents, newest first. Each agent contributes at most
|
|
95
|
+
* `perAgent` recent events so one chatty agent cannot crowd out the rest.
|
|
96
|
+
*/
|
|
97
|
+
export function activityFeed(records, options) {
|
|
98
|
+
const perAgent = options.perAgent ?? 60;
|
|
99
|
+
const entries = [];
|
|
100
|
+
let order = 0;
|
|
101
|
+
for (const record of records) {
|
|
102
|
+
const agent = record.alias ?? record.handle ?? record.type;
|
|
103
|
+
for (const event of transcriptTail(record, perAgent)) {
|
|
104
|
+
if (!matchesFilter(event.kind, options.filter))
|
|
105
|
+
continue;
|
|
106
|
+
entries.push({ ...event, agentId: record.id, agent, order: order++ });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
entries.sort((a, b) => (b.at ?? 0) - (a.at ?? 0) || b.order - a.order);
|
|
110
|
+
return entries.slice(0, options.limit).map(({ order: _order, ...entry }) => entry);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Parent → child order. Roots are the given top-level records in their given
|
|
114
|
+
* order; each child follows its parent, oldest first. Orphans (parent swept)
|
|
115
|
+
* surface as roots so nothing disappears.
|
|
116
|
+
*
|
|
117
|
+
* `hidden` drops a row from the output without dropping what is under it: the
|
|
118
|
+
* subtree is still traversed, one level up, so a view filter (a dismissed row)
|
|
119
|
+
* can never re-insert the row it removed or hide its descendants.
|
|
120
|
+
*/
|
|
121
|
+
export function treeOrder(roots, all, hidden) {
|
|
122
|
+
const children = new Map();
|
|
123
|
+
const ids = new Set(all.map(record => record.id));
|
|
124
|
+
for (const record of all) {
|
|
125
|
+
const parent = record.parentAgentId;
|
|
126
|
+
if (!parent || !ids.has(parent))
|
|
127
|
+
continue;
|
|
128
|
+
const list = children.get(parent) ?? [];
|
|
129
|
+
list.push(record);
|
|
130
|
+
children.set(parent, list);
|
|
131
|
+
}
|
|
132
|
+
const out = [];
|
|
133
|
+
const seen = new Set();
|
|
134
|
+
const visit = (record, depth) => {
|
|
135
|
+
if (seen.has(record.id))
|
|
136
|
+
return;
|
|
137
|
+
seen.add(record.id);
|
|
138
|
+
const hiddenHere = hidden?.(record) ?? false;
|
|
139
|
+
if (!hiddenHere)
|
|
140
|
+
out.push({ record, depth });
|
|
141
|
+
for (const child of (children.get(record.id) ?? []).sort((a, b) => a.startedAt - b.startedAt)) {
|
|
142
|
+
visit(child, hiddenHere ? depth : depth + 1);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
for (const root of roots)
|
|
146
|
+
visit(root, 0);
|
|
147
|
+
return out;
|
|
148
|
+
}
|
|
@@ -62,7 +62,10 @@ export class NativeTranscript {
|
|
|
62
62
|
}
|
|
63
63
|
else if (event.type === "tool_execution_end") {
|
|
64
64
|
this.ensureTool(event.toolCallId, event.toolName, {});
|
|
65
|
-
|
|
65
|
+
// Same shape pi's own transcript hands the card: renderers read durationMs.
|
|
66
|
+
this.updateTool(event.toolCallId, {
|
|
67
|
+
...event.result, isError: event.isError, ...(event.durationMs === undefined ? {} : { durationMs: event.durationMs }),
|
|
68
|
+
}, false);
|
|
66
69
|
}
|
|
67
70
|
else if (event.type === "compaction_end" && event.result && !event.aborted) {
|
|
68
71
|
this.hydrate();
|
|
@@ -88,6 +91,7 @@ export class NativeTranscript {
|
|
|
88
91
|
return existing;
|
|
89
92
|
const component = new ToolExecutionComponent(name, id, args, {
|
|
90
93
|
showImages: this.session.settingsManager?.getShowImages() ?? true,
|
|
94
|
+
outputPad: this.session.settingsManager?.getOutputPad() ?? 1,
|
|
91
95
|
}, this.renderers(name), this.tui, this.cwd);
|
|
92
96
|
component.setExpanded(this.expanded);
|
|
93
97
|
const entry = {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* if real demand emerges.
|
|
9
9
|
*/
|
|
10
10
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
11
|
-
import type { SubagentScheduler } from "../schedule.
|
|
11
|
+
import type { SubagentScheduler } from "../schedule.ts";
|
|
12
12
|
/**
|
|
13
13
|
* List scheduled jobs; selecting one opens a cancel-confirm with details.
|
|
14
14
|
* Returns when the user backs out or after a cancellation.
|
package/dist/ui/schedule-menu.js
CHANGED
|
@@ -89,6 +89,6 @@ export async function showSchedulesMenu(ctx, scheduler) {
|
|
|
89
89
|
const ok = await ctx.ui.confirm(`Cancel "${job.name}"?`, formatDetails(job, scheduler));
|
|
90
90
|
if (!ok)
|
|
91
91
|
return;
|
|
92
|
-
scheduler.removeJob(job.id);
|
|
92
|
+
await scheduler.removeJob(job.id);
|
|
93
93
|
ctx.ui.notify(`Cancelled "${job.name}".`, "info");
|
|
94
94
|
}
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
* arranges what that module returns.
|
|
32
32
|
*/
|
|
33
33
|
import { Text } from "@earendil-works/pi-tui";
|
|
34
|
-
import type { WorkflowEntryData } from "../workflow/entry.
|
|
35
|
-
import type { WorkflowMeta } from "../workflow/meta.
|
|
36
|
-
import { type WorkflowAgentEntry, type WorkflowEntry, type WorkflowRunStatus } from "../workflow/progress.
|
|
37
|
-
import type { Theme } from "./agent-widget.
|
|
34
|
+
import type { WorkflowEntryData } from "../workflow/entry.ts";
|
|
35
|
+
import type { WorkflowMeta } from "../workflow/meta.ts";
|
|
36
|
+
import { type WorkflowAgentEntry, type WorkflowEntry, type WorkflowRunStatus } from "../workflow/progress.ts";
|
|
37
|
+
import type { Theme } from "./agent-widget.ts";
|
|
38
38
|
/**
|
|
39
39
|
* Header re-render cadence. Claude Code ticks the workflow clock once a second,
|
|
40
40
|
* not at the 80ms spinner cadence — the running glyph is static, so there is
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
* arranges what that module returns.
|
|
41
41
|
*/
|
|
42
42
|
import { type Component, type TUI } from "@earendil-works/pi-tui";
|
|
43
|
-
import type { WorkflowMeta } from "../workflow/meta.
|
|
44
|
-
import { type PhaseGroup, type WorkflowAgentEntry, type WorkflowDisplayState, type WorkflowEntry } from "../workflow/progress.
|
|
45
|
-
import { type Theme } from "./agent-widget.
|
|
46
|
-
import { type WorkflowCardLine, type WorkflowCardSegment, type WorkflowCardTask } from "./workflow-card.
|
|
43
|
+
import type { WorkflowMeta } from "../workflow/meta.ts";
|
|
44
|
+
import { type PhaseGroup, type WorkflowAgentEntry, type WorkflowDisplayState, type WorkflowEntry } from "../workflow/progress.ts";
|
|
45
|
+
import { type Theme } from "./agent-widget.ts";
|
|
46
|
+
import { type WorkflowCardLine, type WorkflowCardSegment, type WorkflowCardTask } from "./workflow-card.ts";
|
|
47
47
|
/**
|
|
48
48
|
* Most rows the frame will ever draw between its top and bottom edges.
|
|
49
49
|
*
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
*/
|
|
42
42
|
import { matchesKey, stripTerminalSequences, truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "@earendil-works/pi-tui";
|
|
43
43
|
import { buildPhaseGroups, displayState, formatDuration, header, isLive, } from "../workflow/progress.js";
|
|
44
|
-
import { SPINNER } from "./agent-widget.js";
|
|
44
|
+
import { flattenRow, SPINNER } from "./agent-widget.js";
|
|
45
45
|
import { ASCII_GLYPHS, clampLine, formatCompactTokens, formatModel, formatThinking, REPLAYED_ANNOTATION, styleWorkflowCardLines, UNICODE_GLYPHS, } from "./workflow-card.js";
|
|
46
46
|
/** Fallback width when the caller does not know the terminal's. */
|
|
47
47
|
const DEFAULT_WIDTH = 80;
|
|
@@ -283,7 +283,9 @@ function frameTitle(title, width, glyphs) {
|
|
|
283
283
|
// own truncation does the width arithmetic, including wide characters; its
|
|
284
284
|
// ellipsis arrives wrapped in resets, which are stripped for the same reason
|
|
285
285
|
// `clampLine` strips them — the layout stays plain text until it is themed.
|
|
286
|
-
|
|
286
|
+
// Flattened first: a title is a workflow/task label (arbitrary text), and a
|
|
287
|
+
// control byte in it would make one frame row occupy two terminal rows.
|
|
288
|
+
const shown = stripTerminalSequences(truncateToWidth(flattenRow(title), room, glyphs.ellipsis));
|
|
287
289
|
const rule = Math.max(0, width - visibleWidth(shown) - 2);
|
|
288
290
|
// Clamped as well as computed: at a terminal narrow enough that `room` hits
|
|
289
291
|
// zero the marker alone is already wider than the cell, and a title that
|
|
@@ -401,7 +403,10 @@ function detailHeading(title, suffixes, width) {
|
|
|
401
403
|
return clampLine(line, width);
|
|
402
404
|
}
|
|
403
405
|
/** A detail body line, indented under its heading. */
|
|
404
|
-
const detailBody = (text, width) =>
|
|
406
|
+
const detailBody = (text, width) =>
|
|
407
|
+
// Flattened, whitespace preserved: the body carries indented report text and
|
|
408
|
+
// an activity body, neither of which may contain a row-breaking character.
|
|
409
|
+
clampLine([{ text: flattenRow(` ${text}`), color: "dim" }], width);
|
|
405
410
|
/** The row for one agent, as it appears in whichever pane is listing agents. */
|
|
406
411
|
function agentRow(options) {
|
|
407
412
|
const { entry, selected, glyphs, width } = options;
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* `/workflows:2`, which breaks the bare name for both).
|
|
15
15
|
*/
|
|
16
16
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
17
|
-
import type { AgentRecord } from "../types.
|
|
18
|
-
import { type WorkflowTask } from "../workflow/task.
|
|
17
|
+
import type { AgentRecord } from "../types.ts";
|
|
18
|
+
import { type WorkflowTask } from "../workflow/task.ts";
|
|
19
19
|
/** Everything the menu and the inspector need from the extension around them. */
|
|
20
20
|
export interface WorkflowMenuDeps {
|
|
21
21
|
/**
|
package/dist/usage.d.ts
CHANGED
|
@@ -113,6 +113,18 @@ export type SessionStatsLike = {
|
|
|
113
113
|
};
|
|
114
114
|
export type SessionLike = {
|
|
115
115
|
getSessionStats(): SessionStatsLike;
|
|
116
|
+
getContextUsage?(): {
|
|
117
|
+
percent: number | null;
|
|
118
|
+
} | undefined;
|
|
119
|
+
sessionManager?: {
|
|
120
|
+
getLeafId(): string | null;
|
|
121
|
+
getEntryCount?(): number;
|
|
122
|
+
};
|
|
123
|
+
model?: {
|
|
124
|
+
contextWindow?: number;
|
|
125
|
+
};
|
|
126
|
+
messages?: readonly unknown[];
|
|
127
|
+
isCompacting?: boolean;
|
|
116
128
|
};
|
|
117
129
|
/**
|
|
118
130
|
* Session-scoped token count: input + output + cacheWrite as reported by
|
package/dist/usage.js
CHANGED
|
@@ -80,6 +80,7 @@ export class PendingUsagePool {
|
|
|
80
80
|
return drained;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
const contextDisplayCache = new WeakMap();
|
|
83
84
|
/**
|
|
84
85
|
* Session-scoped token count: input + output + cacheWrite as reported by
|
|
85
86
|
* upstream `getSessionStats().tokens` for the *current* session window.
|
|
@@ -112,9 +113,35 @@ export function getSessionContextPercent(session) {
|
|
|
112
113
|
if (!session)
|
|
113
114
|
return null;
|
|
114
115
|
try {
|
|
115
|
-
|
|
116
|
+
// These SDK accessors are constant-cost. In particular, routedModel and
|
|
117
|
+
// getContextUsage themselves search/project history and cannot form the key.
|
|
118
|
+
const manager = session.sessionManager;
|
|
119
|
+
const leafId = manager?.getLeafId() ?? null;
|
|
120
|
+
const entryCount = manager?.getEntryCount?.();
|
|
121
|
+
const model = session.model;
|
|
122
|
+
const contextWindow = model?.contextWindow;
|
|
123
|
+
const messages = session.messages;
|
|
124
|
+
const messageCount = messages?.length ?? 0;
|
|
125
|
+
const lastMessage = messages?.[messageCount - 1];
|
|
126
|
+
const compacting = session.isCompacting;
|
|
127
|
+
const cached = manager ? contextDisplayCache.get(session) : undefined;
|
|
128
|
+
if (cached && cached.manager === manager && cached.leafId === leafId
|
|
129
|
+
&& cached.entryCount === entryCount && cached.model === model && cached.contextWindow === contextWindow
|
|
130
|
+
&& cached.messages === messages && cached.messageCount === messageCount
|
|
131
|
+
&& cached.lastMessage === lastMessage && cached.compacting === compacting)
|
|
132
|
+
return cached.percent;
|
|
133
|
+
const percent = session.getContextUsage
|
|
134
|
+
? session.getContextUsage()?.percent ?? null
|
|
135
|
+
: session.getSessionStats().contextUsage?.percent ?? null;
|
|
136
|
+
// Structural session doubles without a revision source must remain live.
|
|
137
|
+
if (manager)
|
|
138
|
+
contextDisplayCache.set(session, {
|
|
139
|
+
manager, leafId, entryCount, model, contextWindow, messages, messageCount, lastMessage, compacting, percent,
|
|
140
|
+
});
|
|
141
|
+
return percent;
|
|
116
142
|
}
|
|
117
143
|
catch {
|
|
144
|
+
// A transient read failure must not poison the next frame's cache.
|
|
118
145
|
return null;
|
|
119
146
|
}
|
|
120
147
|
}
|
package/dist/workflow/entry.d.ts
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
* lives in `ui/workflow-card.ts` (`renderWorkflowEntryCard`), so the shape a
|
|
13
13
|
* session file stores does not depend on the code that draws it.
|
|
14
14
|
*/
|
|
15
|
-
import type { WorkflowMeta } from "./meta.
|
|
16
|
-
import type { WorkflowEntry, WorkflowRunStatus } from "./progress.
|
|
17
|
-
import type { WorkflowTask } from "./task.
|
|
15
|
+
import type { WorkflowMeta } from "./meta.ts";
|
|
16
|
+
import type { WorkflowEntry, WorkflowRunStatus } from "./progress.ts";
|
|
17
|
+
import type { WorkflowTask } from "./task.ts";
|
|
18
18
|
/** `customType` of the session entry a flag-launched workflow renders through. */
|
|
19
19
|
export declare const WORKFLOW_ENTRY_TYPE = "subagents:workflow";
|
|
20
20
|
/** The persisted snapshot of a settled run. */
|
package/dist/workflow/host.d.ts
CHANGED
|
@@ -16,8 +16,11 @@
|
|
|
16
16
|
* on completion: `resume` reaches back to a child that has already
|
|
17
17
|
* finished.
|
|
18
18
|
* - **agent type and model.** Resolved through `resolveSpawnType` and
|
|
19
|
-
* `
|
|
20
|
-
*
|
|
19
|
+
* `resolveAgentInvocationConfig` — the same dispatch and the same
|
|
20
|
+
* pin-outranks-call precedence the `Agent` tool uses — so a workflow and a
|
|
21
|
+
* tool call use the same pin precedence. Unresolved pins and unconfigured
|
|
22
|
+
* economical defaults fail rather than inherit the parent's model;
|
|
23
|
+
* deliberately selected twins/custom roles remain supported.
|
|
21
24
|
* - **failure.** A strict worktree-isolation failure throws out of
|
|
22
25
|
* `spawnAndWait`; the script must see that as an agent that failed
|
|
23
26
|
* (`{ok: false}` → `null`), not as an unhandled rejection that takes the
|
|
@@ -32,8 +35,8 @@
|
|
|
32
35
|
* the two happened, never both.
|
|
33
36
|
*/
|
|
34
37
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
35
|
-
import type { AgentManager } from "../agent-manager.
|
|
36
|
-
import type { WorkflowHost } from "./runtime.
|
|
38
|
+
import type { AgentManager } from "../agent-manager.ts";
|
|
39
|
+
import type { WorkflowHost } from "./runtime.ts";
|
|
37
40
|
/**
|
|
38
41
|
* Wall-clock bound on a `gate` command. Generous — a gate is routinely a test
|
|
39
42
|
* suite — but not unbounded: `pi.exec` reports a timeout as `killed`, and a
|