@esso0428/pi-subagents 0.17.6 → 0.17.8
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 +14 -0
- package/CONTRIBUTING.md +4 -0
- package/dist/abortable.d.ts +13 -0
- package/dist/abortable.d.ts.map +1 -0
- package/dist/abortable.js +43 -0
- package/dist/abortable.js.map +1 -0
- package/dist/agent-color.d.ts +36 -0
- package/dist/agent-color.d.ts.map +1 -0
- package/dist/agent-color.js +124 -0
- package/dist/agent-color.js.map +1 -0
- package/dist/agent-file-toggle.d.ts +126 -0
- package/dist/agent-file-toggle.d.ts.map +1 -0
- package/dist/agent-file-toggle.js +259 -0
- package/dist/agent-file-toggle.js.map +1 -0
- package/dist/agent-history.d.ts +4 -0
- package/dist/agent-history.d.ts.map +1 -1
- package/dist/agent-history.js +47 -1
- package/dist/agent-history.js.map +1 -1
- package/dist/agent-manager.d.ts +370 -56
- package/dist/agent-manager.d.ts.map +1 -1
- package/dist/agent-manager.js +1123 -409
- package/dist/agent-manager.js.map +1 -1
- package/dist/agent-runner.d.ts +100 -10
- package/dist/agent-runner.d.ts.map +1 -1
- package/dist/agent-runner.js +166 -21
- package/dist/agent-runner.js.map +1 -1
- package/dist/agent-types.d.ts +57 -5
- package/dist/agent-types.d.ts.map +1 -1
- package/dist/agent-types.js +164 -32
- package/dist/agent-types.js.map +1 -1
- package/dist/child-context.d.ts +3 -0
- package/dist/child-context.d.ts.map +1 -0
- package/dist/child-context.js +13 -0
- package/dist/child-context.js.map +1 -0
- package/dist/cross-extension-rpc.d.ts +23 -3
- package/dist/cross-extension-rpc.d.ts.map +1 -1
- package/dist/cross-extension-rpc.js +79 -17
- package/dist/cross-extension-rpc.js.map +1 -1
- package/dist/custom-agents.d.ts +38 -1
- package/dist/custom-agents.d.ts.map +1 -1
- package/dist/custom-agents.js +164 -12
- package/dist/custom-agents.js.map +1 -1
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1912 -492
- package/dist/index.js.map +1 -1
- package/dist/invocation-config.d.ts +87 -2
- package/dist/invocation-config.d.ts.map +1 -1
- package/dist/invocation-config.js +71 -3
- package/dist/invocation-config.js.map +1 -1
- package/dist/mention-clone.d.ts +88 -0
- package/dist/mention-clone.d.ts.map +1 -0
- package/dist/mention-clone.js +154 -0
- package/dist/mention-clone.js.map +1 -0
- package/dist/mention.d.ts +82 -0
- package/dist/mention.d.ts.map +1 -0
- package/dist/mention.js +132 -0
- package/dist/mention.js.map +1 -0
- package/dist/model-resolver.d.ts +17 -0
- package/dist/model-resolver.d.ts.map +1 -1
- package/dist/model-resolver.js +15 -0
- package/dist/model-resolver.js.map +1 -1
- package/dist/model-scope.d.ts +50 -0
- package/dist/model-scope.d.ts.map +1 -0
- package/dist/model-scope.js +49 -0
- package/dist/model-scope.js.map +1 -0
- package/dist/nested-tools.d.ts +57 -0
- package/dist/nested-tools.d.ts.map +1 -0
- package/dist/nested-tools.js +301 -0
- package/dist/nested-tools.js.map +1 -0
- package/dist/output-file.d.ts +22 -3
- package/dist/output-file.d.ts.map +1 -1
- package/dist/output-file.js +58 -7
- package/dist/output-file.js.map +1 -1
- package/dist/prompts.d.ts +23 -0
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +20 -2
- package/dist/prompts.js.map +1 -1
- package/dist/schedule.d.ts.map +1 -1
- package/dist/schedule.js +36 -15
- package/dist/schedule.js.map +1 -1
- package/dist/settings.d.ts +228 -2
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +94 -0
- package/dist/settings.js.map +1 -1
- package/dist/status-note.d.ts +49 -1
- package/dist/status-note.d.ts.map +1 -1
- package/dist/status-note.js +62 -1
- package/dist/status-note.js.map +1 -1
- package/dist/structured-output.d.ts +62 -0
- package/dist/structured-output.d.ts.map +1 -0
- package/dist/structured-output.js +113 -0
- package/dist/structured-output.js.map +1 -0
- package/dist/types.d.ts +176 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/agent-mention.d.ts +83 -0
- package/dist/ui/agent-mention.d.ts.map +1 -0
- package/dist/ui/agent-mention.js +188 -0
- package/dist/ui/agent-mention.js.map +1 -0
- package/dist/ui/agent-widget.d.ts +97 -75
- package/dist/ui/agent-widget.d.ts.map +1 -1
- package/dist/ui/agent-widget.js +398 -420
- package/dist/ui/agent-widget.js.map +1 -1
- package/dist/ui/conversation-blocks.d.ts.map +1 -1
- package/dist/ui/conversation-blocks.js +6 -0
- package/dist/ui/conversation-blocks.js.map +1 -1
- package/dist/ui/conversation-timeline.d.ts +10 -2
- package/dist/ui/conversation-timeline.d.ts.map +1 -1
- package/dist/ui/conversation-timeline.js +130 -23
- package/dist/ui/conversation-timeline.js.map +1 -1
- package/dist/ui/conversation-viewer.d.ts +15 -5
- package/dist/ui/conversation-viewer.d.ts.map +1 -1
- package/dist/ui/conversation-viewer.js +202 -50
- package/dist/ui/conversation-viewer.js.map +1 -1
- package/dist/ui/fleet-list.d.ts +198 -0
- package/dist/ui/fleet-list.d.ts.map +1 -0
- package/dist/ui/fleet-list.js +487 -0
- package/dist/ui/fleet-list.js.map +1 -0
- package/dist/ui/schedule-menu.d.ts.map +1 -1
- package/dist/ui/schedule-menu.js +6 -7
- package/dist/ui/schedule-menu.js.map +1 -1
- package/dist/ui/select-item.d.ts +28 -0
- package/dist/ui/select-item.d.ts.map +1 -0
- package/dist/ui/select-item.js +35 -0
- package/dist/ui/select-item.js.map +1 -0
- package/dist/ui/workflow-card.d.ts +176 -0
- package/dist/ui/workflow-card.d.ts.map +1 -0
- package/dist/ui/workflow-card.js +333 -0
- package/dist/ui/workflow-card.js.map +1 -0
- package/dist/ui/workflow-dialog.d.ts +306 -0
- package/dist/ui/workflow-dialog.d.ts.map +1 -0
- package/dist/ui/workflow-dialog.js +844 -0
- package/dist/ui/workflow-dialog.js.map +1 -0
- package/dist/ui/workflow-menu.d.ts +61 -0
- package/dist/ui/workflow-menu.d.ts.map +1 -0
- package/dist/ui/workflow-menu.js +148 -0
- package/dist/ui/workflow-menu.js.map +1 -0
- package/dist/usage.d.ts +86 -1
- package/dist/usage.d.ts.map +1 -1
- package/dist/usage.js +72 -1
- package/dist/usage.js.map +1 -1
- package/dist/workflow/collisions.d.ts +96 -0
- package/dist/workflow/collisions.d.ts.map +1 -0
- package/dist/workflow/collisions.js +89 -0
- package/dist/workflow/collisions.js.map +1 -0
- package/dist/workflow/entry.d.ts +33 -0
- package/dist/workflow/entry.d.ts.map +1 -0
- package/dist/workflow/entry.js +30 -0
- package/dist/workflow/entry.js.map +1 -0
- package/dist/workflow/host.d.ts +63 -0
- package/dist/workflow/host.d.ts.map +1 -0
- package/dist/workflow/host.js +363 -0
- package/dist/workflow/host.js.map +1 -0
- package/dist/workflow/journal.d.ts +98 -0
- package/dist/workflow/journal.d.ts.map +1 -0
- package/dist/workflow/journal.js +121 -0
- package/dist/workflow/journal.js.map +1 -0
- package/dist/workflow/json-schema.d.ts +52 -0
- package/dist/workflow/json-schema.d.ts.map +1 -0
- package/dist/workflow/json-schema.js +112 -0
- package/dist/workflow/json-schema.js.map +1 -0
- package/dist/workflow/meta.d.ts +68 -0
- package/dist/workflow/meta.d.ts.map +1 -0
- package/dist/workflow/meta.js +318 -0
- package/dist/workflow/meta.js.map +1 -0
- package/dist/workflow/progress.d.ts +225 -0
- package/dist/workflow/progress.d.ts.map +1 -0
- package/dist/workflow/progress.js +362 -0
- package/dist/workflow/progress.js.map +1 -0
- package/dist/workflow/runtime.d.ts +335 -0
- package/dist/workflow/runtime.d.ts.map +1 -0
- package/dist/workflow/runtime.js +831 -0
- package/dist/workflow/runtime.js.map +1 -0
- package/dist/workflow/saved.d.ts +91 -0
- package/dist/workflow/saved.d.ts.map +1 -0
- package/dist/workflow/saved.js +204 -0
- package/dist/workflow/saved.js.map +1 -0
- package/dist/workflow/task.d.ts +137 -0
- package/dist/workflow/task.d.ts.map +1 -0
- package/dist/workflow/task.js +208 -0
- package/dist/workflow/task.js.map +1 -0
- package/dist/workflow/tool-description.d.ts +39 -0
- package/dist/workflow/tool-description.d.ts.map +1 -0
- package/dist/workflow/tool-description.js +200 -0
- package/dist/workflow/tool-description.js.map +1 -0
- package/dist/workflow/worker-source.d.ts +48 -0
- package/dist/workflow/worker-source.d.ts.map +1 -0
- package/dist/workflow/worker-source.js +779 -0
- package/dist/workflow/worker-source.js.map +1 -0
- package/dist/worktree.d.ts +10 -3
- package/dist/worktree.d.ts.map +1 -1
- package/dist/worktree.js +58 -54
- package/dist/worktree.js.map +1 -1
- package/dist/xml.d.ts +11 -0
- package/dist/xml.d.ts.map +1 -0
- package/dist/xml.js +13 -0
- package/dist/xml.js.map +1 -0
- package/docs/rpc.md +183 -0
- package/docs/superpowers/plans/2026-09-30-upstream-event-workflow-partial-history.md +195 -0
- package/docs/superpowers/specs/2026-09-30-upstream-event-workflow-partial-history-design.md +49 -0
- package/docs/workflows.md +437 -0
- package/examples/agent-tool-description.md +7 -7
- package/examples/workflows/compose.js +51 -0
- package/examples/workflows/fan-out-audit.js +47 -0
- package/examples/workflows/gated-fix.js +60 -0
- package/examples/workflows/lib/count-child.js +27 -0
- package/examples/workflows/review-panel.js +63 -0
- package/examples/workflows/structured-findings.js +78 -0
- package/package.json +1 -1
- package/src/abortable.ts +43 -0
- package/src/agent-color.ts +161 -0
- package/src/agent-file-toggle.ts +269 -0
- package/src/agent-history.ts +54 -2
- package/src/agent-manager.ts +1263 -402
- package/src/agent-runner.ts +251 -27
- package/src/agent-types.ts +188 -32
- package/src/child-context.ts +15 -0
- package/src/cross-extension-rpc.ts +96 -20
- package/src/custom-agents.ts +170 -13
- package/src/index.ts +2029 -536
- package/src/invocation-config.ts +118 -3
- package/src/mention-clone.ts +196 -0
- package/src/mention.ts +141 -0
- package/src/model-resolver.ts +18 -0
- package/src/model-scope.ts +70 -0
- package/src/nested-tools.ts +424 -0
- package/src/output-file.ts +61 -6
- package/src/prompts.ts +45 -2
- package/src/schedule.ts +35 -14
- package/src/settings.ts +312 -2
- package/src/status-note.ts +66 -1
- package/src/structured-output.ts +130 -0
- package/src/types.ts +177 -10
- package/src/ui/agent-mention.ts +216 -0
- package/src/ui/agent-widget.ts +393 -441
- package/src/ui/conversation-blocks.ts +6 -0
- package/src/ui/conversation-timeline.ts +139 -25
- package/src/ui/conversation-viewer.ts +212 -48
- package/src/ui/fleet-list.ts +558 -0
- package/src/ui/schedule-menu.ts +9 -8
- package/src/ui/select-item.ts +45 -0
- package/src/ui/workflow-card.ts +470 -0
- package/src/ui/workflow-dialog.ts +1115 -0
- package/src/ui/workflow-menu.ts +193 -0
- package/src/usage.ts +109 -2
- package/src/workflow/collisions.ts +123 -0
- package/src/workflow/entry.ts +47 -0
- package/src/workflow/host.ts +403 -0
- package/src/workflow/journal.ts +164 -0
- package/src/workflow/json-schema.ts +128 -0
- package/src/workflow/meta.ts +325 -0
- package/src/workflow/progress.ts +550 -0
- package/src/workflow/runtime.ts +1219 -0
- package/src/workflow/saved.ts +217 -0
- package/src/workflow/task.ts +302 -0
- package/src/workflow/tool-description.ts +200 -0
- package/src/workflow/worker-source.ts +781 -0
- package/src/worktree.ts +69 -55
- package/src/xml.ts +13 -0
- package/vitest.config.ts +0 -18
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agent-mention.ts — what `@` can address, and the suggestions pi renders for it.
|
|
3
|
+
*
|
|
4
|
+
* A subagent is addressable whether or not it is currently running: a live
|
|
5
|
+
* record is messaged or resumed, an evicted one whose session is still on disk
|
|
6
|
+
* is reopened, and an agent *type* with no instance at all is started. That is
|
|
7
|
+
* the point of the handle — `@explore` means the Explore agent, not "the
|
|
8
|
+
* Explore process that happens to exist right now" — so the roster below unions
|
|
9
|
+
* all three, and the dispatcher and the popup read the same list.
|
|
10
|
+
*
|
|
11
|
+
* Rows are per *agent*, not per handle. An agent given a `name` holds two names
|
|
12
|
+
* (its alias and its type-derived handle) and both resolve, but it lists once,
|
|
13
|
+
* under the alias, with its type moved into the description so the row still
|
|
14
|
+
* says what it is.
|
|
15
|
+
*
|
|
16
|
+
* pi's `CombinedAutocompleteProvider` already owns `@`, where it means "attach a
|
|
17
|
+
* file". Extensions can wrap it (`ctx.ui.addAutocompleteProvider`), so this
|
|
18
|
+
* provider adds the `@` tokens that name an agent and delegates everything else
|
|
19
|
+
* — including all of `applyCompletion`, whose `@`-branch already inserts
|
|
20
|
+
* `item.value` plus a trailing space, which is exactly what a handle needs.
|
|
21
|
+
*
|
|
22
|
+
* Matching mirrors Claude Code: case-insensitive prefix, not fuzzy. What it does
|
|
23
|
+
* NOT mirror is Claude Code dropping files whenever an agent matches. Here `@` is
|
|
24
|
+
* pi's file picker first, and the handles are additive, so a token matching both
|
|
25
|
+
* lists both — agents first. Suppressing on any match sounds narrow and is not:
|
|
26
|
+
* an empty token prefix-matches every handle, so a bare `@` — the gesture people
|
|
27
|
+
* use to browse files — would offer no files at all, and a single letter
|
|
28
|
+
* beginning any handle would do the same.
|
|
29
|
+
*
|
|
30
|
+
* Both halves ship under ONE `prefix`, which is sound because wherever BOTH sides
|
|
31
|
+
* produce rows they measured the same span. pi's `extractAtPrefix` takes the
|
|
32
|
+
* token after the last of `{space, tab, ", ', =}` and keeps it only if it starts
|
|
33
|
+
* with `@`; `MENTION_TRIGGER` matches `@[\w-]*` at the cursor, after start-of-line
|
|
34
|
+
* or `[\s。、?!]`. Where those two disagree, exactly one side answers and there
|
|
35
|
+
* is nothing to merge: `@src/index.ts` and `@"my file` are pi's alone (no handle
|
|
36
|
+
* matches), `=@ex` is pi's alone (`=` is a delimiter to pi, not a boundary to us),
|
|
37
|
+
* and `。@ex` is ours alone (the reverse). A merged response therefore never
|
|
38
|
+
* carries a prefix from one side and an item from the other.
|
|
39
|
+
*
|
|
40
|
+
* Offering never-started types is a deliberate step beyond Claude Code, whose
|
|
41
|
+
* registry holds only live tasks, so an agent you had not launched yet was
|
|
42
|
+
* unaddressable.
|
|
43
|
+
*/
|
|
44
|
+
import { handleBase, MENTION_TRIGGER } from "../mention.js";
|
|
45
|
+
/**
|
|
46
|
+
* Everything `@` can reach, in the order the popup lists it: steerable agents
|
|
47
|
+
* first, then the other live ones earliest-launched, then agent types with no
|
|
48
|
+
* live instance. A type whose handle a record already holds is omitted — that
|
|
49
|
+
* name addresses the existing agent, which is what makes `@explore` mean
|
|
50
|
+
* "message the one that's running" and only otherwise "start one".
|
|
51
|
+
*/
|
|
52
|
+
export function mentionRoster(manager, types,
|
|
53
|
+
// Identity by default: a caller with no registry to consult gets the raw
|
|
54
|
+
// type, which is also what `getConfig` falls back to when no label is set.
|
|
55
|
+
displayNameOf = type => type) {
|
|
56
|
+
const live = (r) => r.status === "running" || r.status === "queued";
|
|
57
|
+
const records = manager.listAgents()
|
|
58
|
+
.filter(r => r.handle !== undefined && r.parentAgentId === undefined)
|
|
59
|
+
.sort((a, b) => (Number(live(b)) - Number(live(a))) || (a.startedAt - b.startedAt));
|
|
60
|
+
const taken = new Set();
|
|
61
|
+
const targets = [];
|
|
62
|
+
// One row per agent, not per handle. An aliased agent lists under its alias
|
|
63
|
+
// only — both names resolve, but showing two rows for one agent reads as two
|
|
64
|
+
// agents. The type handle stays addressable whether or not it is listed.
|
|
65
|
+
for (const record of records) {
|
|
66
|
+
const handle = record.alias ?? record.handle;
|
|
67
|
+
taken.add(handle.toLowerCase());
|
|
68
|
+
if (record.handle)
|
|
69
|
+
taken.add(record.handle.toLowerCase());
|
|
70
|
+
targets.push({ kind: "record", handle, record, typeLabel: displayNameOf(record.type) });
|
|
71
|
+
}
|
|
72
|
+
// Then agents that are gone but whose conversation can be reopened. After the
|
|
73
|
+
// live ones: a running agent is the likelier target, and this keeps the
|
|
74
|
+
// ordering "what exists now, then what can be brought back, then what can be
|
|
75
|
+
// started".
|
|
76
|
+
for (const entry of manager.listTombstones()) {
|
|
77
|
+
const handle = entry.alias ?? entry.handle;
|
|
78
|
+
if (taken.has(handle.toLowerCase()))
|
|
79
|
+
continue;
|
|
80
|
+
taken.add(handle.toLowerCase());
|
|
81
|
+
taken.add(entry.handle.toLowerCase());
|
|
82
|
+
targets.push({ kind: "tombstone", handle, entry, typeLabel: displayNameOf(entry.type) });
|
|
83
|
+
}
|
|
84
|
+
for (const type of types) {
|
|
85
|
+
const handle = handleBase(type.name);
|
|
86
|
+
if (taken.has(handle))
|
|
87
|
+
continue;
|
|
88
|
+
taken.add(handle);
|
|
89
|
+
targets.push({ kind: "type", handle, type: type.name, description: type.description });
|
|
90
|
+
}
|
|
91
|
+
return targets;
|
|
92
|
+
}
|
|
93
|
+
export function createMentionProvider(current, roster, isEnabled) {
|
|
94
|
+
// One warning per provider, not per keystroke: `getSuggestions` runs on every
|
|
95
|
+
// character typed after `@`, so an unguarded log would bury the terminal in
|
|
96
|
+
// the time it takes to finish a word.
|
|
97
|
+
let warnedInnerFailure = false;
|
|
98
|
+
return {
|
|
99
|
+
// Only `@` — the contract is "characters that should naturally trigger
|
|
100
|
+
// THIS provider", and pi unions each wrapper's own set onto the outermost
|
|
101
|
+
// one itself (interactive-mode.js:432), so re-declaring the wrapped
|
|
102
|
+
// provider's characters here would both misreport us and duplicate that.
|
|
103
|
+
triggerCharacters: ["@"],
|
|
104
|
+
async getSuggestions(lines, cursorLine, cursorCol, options) {
|
|
105
|
+
const mine = isEnabled() ? mentionItems(roster(), lines[cursorLine] ?? "", cursorCol) : null;
|
|
106
|
+
// Asked unconditionally: pi owns `@` and must keep answering for it even
|
|
107
|
+
// when a handle matches too. That is the same work vanilla pi does on any
|
|
108
|
+
// `@` keystroke — a capped `fd` search, or nothing at all when the host
|
|
109
|
+
// configured no `fd` path — but we now do it on tokens we used to answer
|
|
110
|
+
// alone, so it must not be able to take the popup down with it. The
|
|
111
|
+
// wrapped provider is not always pi's: another extension may sit inside
|
|
112
|
+
// us, and before this it was never called for a token naming an agent.
|
|
113
|
+
// try/catch, not `.catch()`: a provider that throws SYNCHRONOUSLY never
|
|
114
|
+
// returns the promise a `.catch()` would attach to, and the throw escapes
|
|
115
|
+
// this method as a rejection — which pi does not handle either
|
|
116
|
+
// (components/editor.js:1892 awaits with no catch of its own).
|
|
117
|
+
let theirs = null;
|
|
118
|
+
try {
|
|
119
|
+
theirs = await current.getSuggestions(lines, cursorLine, cursorCol, options);
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
// Safe to treat as "no files": pi discards any response whose request is
|
|
123
|
+
// no longer current, so an aborted search that surfaces as a rejection
|
|
124
|
+
// cannot leave a stale popup behind (`isAutocompleteRequestCurrent`).
|
|
125
|
+
// Warned rather than swallowed outright — the failure is invisible in
|
|
126
|
+
// the popup, and the same `console.warn` channel already carries this
|
|
127
|
+
// extension's other non-fatal failures.
|
|
128
|
+
if (!warnedInnerFailure) {
|
|
129
|
+
warnedInnerFailure = true;
|
|
130
|
+
console.warn("[pi-subagents] the autocomplete provider below us failed; showing agent rows only:", err);
|
|
131
|
+
}
|
|
132
|
+
theirs = null;
|
|
133
|
+
}
|
|
134
|
+
if (!mine)
|
|
135
|
+
return theirs;
|
|
136
|
+
if (!theirs)
|
|
137
|
+
return mine;
|
|
138
|
+
// Agents first: there are a handful of them against pi's 20 file rows, and
|
|
139
|
+
// a handle buried under fuzzy path matches is a handle nobody finds. The
|
|
140
|
+
// prefix is ours by the span argument in the header — identical to pi's
|
|
141
|
+
// whenever both sides have something to say.
|
|
142
|
+
return { items: [...mine.items, ...theirs.items], prefix: mine.prefix };
|
|
143
|
+
},
|
|
144
|
+
applyCompletion(lines, cursorLine, cursorCol, item, prefix) {
|
|
145
|
+
return current.applyCompletion(lines, cursorLine, cursorCol, item, prefix);
|
|
146
|
+
},
|
|
147
|
+
shouldTriggerFileCompletion(lines, cursorLine, cursorCol) {
|
|
148
|
+
return current.shouldTriggerFileCompletion?.(lines, cursorLine, cursorCol) ?? true;
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/** Suggestions for the `@…` token under the cursor, or null when it names no agent. */
|
|
153
|
+
function mentionItems(roster, line, cursorCol) {
|
|
154
|
+
const match = MENTION_TRIGGER.exec(line.slice(0, cursorCol));
|
|
155
|
+
if (!match)
|
|
156
|
+
return null;
|
|
157
|
+
const typed = match[2].toLowerCase();
|
|
158
|
+
const items = [];
|
|
159
|
+
for (const target of roster) {
|
|
160
|
+
if (!target.handle.toLowerCase().startsWith(typed))
|
|
161
|
+
continue;
|
|
162
|
+
items.push({ value: `@${target.handle}`, label: `@${target.handle}`, description: describeTarget(target) });
|
|
163
|
+
}
|
|
164
|
+
return items.length > 0 ? { items, prefix: `@${match[2]}` } : null;
|
|
165
|
+
}
|
|
166
|
+
/** Name the action that will actually happen, so the list never mispromises. */
|
|
167
|
+
function describeTarget(target) {
|
|
168
|
+
if (target.kind === "type")
|
|
169
|
+
return `start agent · ${summarize(target.description)}`;
|
|
170
|
+
if (target.kind === "tombstone") {
|
|
171
|
+
// No status: the record is gone, and "completed" would imply one is still
|
|
172
|
+
// being tracked. The type carries the identity the handle may not.
|
|
173
|
+
return `resume · ${target.typeLabel} · ${target.entry.description}`;
|
|
174
|
+
}
|
|
175
|
+
const { status, description, alias } = target.record;
|
|
176
|
+
const action = status === "running" || status === "queued" ? "send message" : "resume";
|
|
177
|
+
// A row listed under its alias has lost the type its handle would have shown,
|
|
178
|
+
// so name it — `@auth-audit` alone says nothing about what the agent is.
|
|
179
|
+
// A type-derived row already reads as its type and would just repeat itself.
|
|
180
|
+
const identity = alias ? `${target.typeLabel} · ` : "";
|
|
181
|
+
return `${action} · ${identity}${status} · ${description}`;
|
|
182
|
+
}
|
|
183
|
+
/** First sentence of an agent description, clipped — these run to paragraphs. */
|
|
184
|
+
function summarize(description) {
|
|
185
|
+
const first = (description.match(/^.*?[.!?](?=\s|$)/s)?.[0] ?? description).replace(/\s+/g, " ").trim();
|
|
186
|
+
return first.length > 60 ? `${first.slice(0, 59).trimEnd()}…` : first;
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=agent-mention.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-mention.js","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OAAO,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;AACxE,CAAC"}
|
|
@@ -4,17 +4,19 @@
|
|
|
4
4
|
* Displays a tree of agents with animated spinners, live stats, and activity descriptions.
|
|
5
5
|
* Uses the callback form of setWidget for themed rendering.
|
|
6
6
|
*/
|
|
7
|
-
import type
|
|
8
|
-
import type { AgentInvocation,
|
|
7
|
+
import { type AgentManager } from "../agent-manager.js";
|
|
8
|
+
import type { AgentInvocation, SubagentType, WidgetMode } from "../types.js";
|
|
9
9
|
import { type LifetimeUsage, type SessionLike } from "../usage.js";
|
|
10
10
|
/** Maximum number of rendered lines before overflow collapse kicks in. */
|
|
11
11
|
export declare const MAX_WIDGET_LINES = 12;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
/** Number of lines available above an editor, retaining room for the prompt. */
|
|
13
|
+
export declare function getWidgetLineBudget(terminalRows: number): number;
|
|
14
|
+
export type AgentWidgetOpenMode = "live" | "history";
|
|
15
|
+
export interface AgentWidgetOptions {
|
|
16
|
+
canOpenHistory?: (record: import("../types.js").AgentRecord) => boolean;
|
|
17
|
+
onOpen?: (record: import("../types.js").AgentRecord, mode: AgentWidgetOpenMode) => void;
|
|
18
|
+
showCost?: () => boolean;
|
|
19
|
+
}
|
|
18
20
|
/** Braille spinner frames for animated running indicator. */
|
|
19
21
|
export declare const SPINNER: string[];
|
|
20
22
|
/** Statuses that indicate an error/non-success outcome (used for linger behavior and icon rendering). */
|
|
@@ -23,18 +25,6 @@ export type Theme = {
|
|
|
23
25
|
fg(color: string, text: string): string;
|
|
24
26
|
bold(text: string): string;
|
|
25
27
|
};
|
|
26
|
-
export type AgentWidgetOpenMode = "live" | "history";
|
|
27
|
-
export type AgentWidgetOpenCallback = (record: AgentRecord, mode: AgentWidgetOpenMode) => void | Promise<void>;
|
|
28
|
-
export type AgentWidgetOptions = {
|
|
29
|
-
canOpenHistory: (record: AgentRecord) => boolean;
|
|
30
|
-
onOpen: AgentWidgetOpenCallback;
|
|
31
|
-
};
|
|
32
|
-
/** @deprecated Use AgentWidgetOpenMode. */
|
|
33
|
-
export type AgentOpenMode = AgentWidgetOpenMode;
|
|
34
|
-
/** @deprecated Use AgentWidgetOpenCallback. */
|
|
35
|
-
export type AgentOpenCallback = AgentWidgetOpenCallback;
|
|
36
|
-
/** @deprecated Use AgentWidgetOptions.canOpenHistory. */
|
|
37
|
-
export type AgentHistoryCapability = AgentWidgetOptions["canOpenHistory"];
|
|
38
28
|
export type UICtx = {
|
|
39
29
|
setStatus(key: string, text: string | undefined): void;
|
|
40
30
|
setWidget(key: string, content: undefined | ((tui: any, theme: Theme) => {
|
|
@@ -43,11 +33,11 @@ export type UICtx = {
|
|
|
43
33
|
}), options?: {
|
|
44
34
|
placement?: "aboveEditor" | "belowEditor";
|
|
45
35
|
}): void;
|
|
46
|
-
onTerminalInput(handler: (data: string) => {
|
|
36
|
+
onTerminalInput?(handler: (data: string) => {
|
|
47
37
|
consume?: boolean;
|
|
48
38
|
data?: string;
|
|
49
39
|
} | undefined): () => void;
|
|
50
|
-
getEditorText(): string;
|
|
40
|
+
getEditorText?(): string;
|
|
51
41
|
};
|
|
52
42
|
/** Per-agent live activity state. */
|
|
53
43
|
export interface AgentActivity {
|
|
@@ -59,7 +49,7 @@ export interface AgentActivity {
|
|
|
59
49
|
turnCount: number;
|
|
60
50
|
/** Effective max turns for this agent (undefined = unlimited). */
|
|
61
51
|
maxTurns?: number;
|
|
62
|
-
/** Lifetime usage
|
|
52
|
+
/** Lifetime token usage, including partial runs. */
|
|
63
53
|
lifetimeUsage: LifetimeUsage;
|
|
64
54
|
}
|
|
65
55
|
/** Metadata attached to Agent tool results for custom rendering. */
|
|
@@ -75,7 +65,7 @@ export interface AgentDetails {
|
|
|
75
65
|
activity?: string;
|
|
76
66
|
/** Current spinner frame index (for animated running indicator). */
|
|
77
67
|
spinnerFrame?: number;
|
|
78
|
-
/** Short
|
|
68
|
+
/** Short label for the model the run used, e.g. "haiku 4.5". */
|
|
79
69
|
modelName?: string;
|
|
80
70
|
/** Notable config tags (e.g. ["thinking: high", "isolated"]). */
|
|
81
71
|
tags?: string[];
|
|
@@ -83,6 +73,8 @@ export interface AgentDetails {
|
|
|
83
73
|
turnCount?: number;
|
|
84
74
|
/** Effective max turns (undefined = unlimited). */
|
|
85
75
|
maxTurns?: number;
|
|
76
|
+
/** Estimated cost in USD; 0 when the model has no pricing data. */
|
|
77
|
+
cost?: number;
|
|
86
78
|
agentId?: string;
|
|
87
79
|
error?: string;
|
|
88
80
|
}
|
|
@@ -90,6 +82,20 @@ export interface AgentDetails {
|
|
|
90
82
|
export declare function fgPreservingNestedStyles(theme: Theme, color: string, text: string): string;
|
|
91
83
|
/** Format a token count compactly: "33.8k token", "1.2M token". */
|
|
92
84
|
export declare function formatTokens(count: number): string;
|
|
85
|
+
/**
|
|
86
|
+
* Format a cost as `~$0.0042`, or "" when there is nothing to show.
|
|
87
|
+
*
|
|
88
|
+
* The tilde is load-bearing: this is pi's own estimate from the model's listed
|
|
89
|
+
* rates, not a billed figure, and the surfaces that print it sit next to token
|
|
90
|
+
* counts that ARE exact.
|
|
91
|
+
*
|
|
92
|
+
* Nothing is printed for zero, which is also what a model with no pricing data
|
|
93
|
+
* reports: `$0.00` beside a local model's tokens would claim its cost was
|
|
94
|
+
* measured and found to be nothing, rather than never measured at all. For the
|
|
95
|
+
* same reason a real cost too small for four decimals reads `<$0.0001` — it was
|
|
96
|
+
* measured, and rounding it to `~$0.0000` would say the opposite.
|
|
97
|
+
*/
|
|
98
|
+
export declare function formatCost(cost: number): string;
|
|
93
99
|
/**
|
|
94
100
|
* Token count with optional context-fill % and compaction-count annotations.
|
|
95
101
|
* Thresholds for percent: <70% dim, 70–85% warning, ≥85% error.
|
|
@@ -111,9 +117,16 @@ export declare function formatDuration(startedAt: number, completedAt?: number):
|
|
|
111
117
|
export declare function getDisplayName(type: SubagentType): string;
|
|
112
118
|
/** Short label for prompt mode: "twin" for append, nothing for replace (the default). */
|
|
113
119
|
export declare function getPromptModeLabel(type: SubagentType): string | undefined;
|
|
114
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* Mode label is not included — callers add it where they want it.
|
|
122
|
+
*
|
|
123
|
+
* Both model forms come back so each surface can pick by width; the
|
|
124
|
+
* "(asked X)" annotation is applied here rather than by callers, so a value the
|
|
125
|
+
* spawn did not honor cannot be rendered as though it had been (#182).
|
|
126
|
+
*/
|
|
115
127
|
export declare function buildInvocationTags(invocation: AgentInvocation | undefined): {
|
|
116
128
|
modelName?: string;
|
|
129
|
+
modelId?: string;
|
|
117
130
|
tags: string[];
|
|
118
131
|
};
|
|
119
132
|
/** Build a human-readable activity string from currently-running tools or response text. */
|
|
@@ -121,32 +134,54 @@ export declare function describeActivity(activeTools: Map<string, string>, respo
|
|
|
121
134
|
export declare class AgentWidget {
|
|
122
135
|
private manager;
|
|
123
136
|
private agentActivity;
|
|
124
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* Read live at render time. Selects which agents the widget shows — see
|
|
139
|
+
* `WidgetMode`. Defaults to `"all"` when a caller supplies no policy; the
|
|
140
|
+
* extension supplies one defaulting to `"background"`.
|
|
141
|
+
*/
|
|
125
142
|
private mode;
|
|
126
|
-
private options;
|
|
127
143
|
private uiCtx;
|
|
128
144
|
private widgetFrame;
|
|
129
145
|
private widgetInterval;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
private selectedAgentId;
|
|
135
|
-
/** Last logical roster index of the selected row, used when it disappears. */
|
|
136
|
-
private selectedRosterIndex;
|
|
137
|
-
/** First logical row currently represented by the bounded viewport. */
|
|
138
|
-
private viewportStart;
|
|
146
|
+
/** Tracks how many turns each finished agent has survived. Key: agent ID, Value: turns since finished. */
|
|
147
|
+
private finishedTurnAge;
|
|
148
|
+
/** How many extra turns errors/aborted agents linger (completed agents clear after 1 turn). */
|
|
149
|
+
private static readonly ERROR_LINGER_TURNS;
|
|
139
150
|
/** Whether the widget callback is currently registered with the TUI. */
|
|
140
151
|
private widgetRegistered;
|
|
141
152
|
/** Cached TUI reference from widget factory callback, used for requestRender(). */
|
|
142
153
|
private tui;
|
|
143
154
|
/** Last status bar text, used to avoid redundant setStatus calls. */
|
|
144
155
|
private lastStatusText;
|
|
145
|
-
|
|
146
|
-
private
|
|
156
|
+
private lastSnapshot;
|
|
157
|
+
private inputCleanup;
|
|
158
|
+
private navigationActive;
|
|
159
|
+
private selectedAgentId;
|
|
160
|
+
private viewportStart;
|
|
161
|
+
private selectedRosterIndex;
|
|
162
|
+
private openOptions;
|
|
163
|
+
private showCost;
|
|
164
|
+
private showModel;
|
|
147
165
|
constructor(manager: AgentManager, agentActivity: Map<string, AgentActivity>,
|
|
148
|
-
/**
|
|
149
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Read live at render time. Selects which agents the widget shows — see
|
|
168
|
+
* `WidgetMode`. Defaults to `"all"` when a caller supplies no policy; the
|
|
169
|
+
* extension supplies one defaulting to `"background"`.
|
|
170
|
+
*/
|
|
171
|
+
mode?: () => WidgetMode,
|
|
172
|
+
/**
|
|
173
|
+
* Read live at render time, like `mode`. Whether running agents show an
|
|
174
|
+
* estimated cost beside their token count. Defaults to off — the extension
|
|
175
|
+
* supplies the user's `showCost` setting.
|
|
176
|
+
*/
|
|
177
|
+
/**
|
|
178
|
+
* Read live at render time, like `mode`. Whether running agents name the
|
|
179
|
+
* model driving them and the thinking level it is running at. Defaults to
|
|
180
|
+
* off — the extension supplies the user's `showModel` setting — because the
|
|
181
|
+
* row is already dense and the same pair is on the tool result and in the
|
|
182
|
+
* conversation viewer unconditionally.
|
|
183
|
+
*/
|
|
184
|
+
showCostOrOptions?: (() => boolean) | AgentWidgetOptions, showModel?: () => boolean);
|
|
150
185
|
/**
|
|
151
186
|
* Agents eligible for the widget, per the current `WidgetMode`:
|
|
152
187
|
* - `off`: none (the widget's existing empty-state path hides it entirely).
|
|
@@ -160,41 +195,30 @@ export declare class AgentWidget {
|
|
|
160
195
|
*/
|
|
161
196
|
private widgetAgents;
|
|
162
197
|
/** Set the UI context (grabbed from first tool execution). */
|
|
163
|
-
setUICtx(ctx: UICtx):
|
|
164
|
-
/** Request a render on the currently registered TUI without touching input. */
|
|
165
|
-
requestUiRefresh(force?: boolean): boolean;
|
|
166
|
-
/** Called on each new turn (tool_execution_start). */
|
|
167
|
-
onTurnStart(): void;
|
|
168
|
-
/** Keep the spinner/elapsed-time timer alive only while a visible agent runs. */
|
|
169
|
-
ensureTimer(): void;
|
|
170
|
-
private syncTimer;
|
|
198
|
+
setUICtx(ctx: UICtx): void;
|
|
171
199
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
200
|
+
* Called on each new turn (tool_execution_start).
|
|
201
|
+
* Ages finished agents and clears those that have lingered long enough.
|
|
174
202
|
*/
|
|
175
|
-
|
|
203
|
+
onTurnStart(): void;
|
|
204
|
+
/** Ensure the widget update timer is running. */
|
|
205
|
+
ensureTimer(): void;
|
|
206
|
+
/** Check if a finished agent should still be shown in the widget. */
|
|
207
|
+
private shouldShowFinished;
|
|
208
|
+
/** Record an agent as finished (call when agent completes). */
|
|
209
|
+
markFinished(agentId: string): void;
|
|
176
210
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
211
|
+
* Drop an agent's finished-age (call when a settled agent starts running
|
|
212
|
+
* again, i.e. a background resume). markFinished only seeds an age it has not
|
|
213
|
+
* seen before, so a resumed agent would otherwise keep the age from its
|
|
214
|
+
* previous run — already past the linger limit, hiding the new run's
|
|
215
|
+
* completion line entirely.
|
|
182
216
|
*/
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
private
|
|
186
|
-
private
|
|
187
|
-
private
|
|
188
|
-
/** Resume navigation from the retained row, or select the first row. */
|
|
189
|
-
private activate;
|
|
190
|
-
/** Move the selected row, activating only from an empty focused editor. */
|
|
191
|
-
private moveSelection;
|
|
192
|
-
private openSelected;
|
|
193
|
-
/** Handle terminal input before it reaches the focused prompt editor. */
|
|
194
|
-
handleKey(data: string): {
|
|
195
|
-
consume?: boolean;
|
|
196
|
-
data?: string;
|
|
197
|
-
} | undefined;
|
|
217
|
+
markRunning(agentId: string): void;
|
|
218
|
+
private navigationAgents;
|
|
219
|
+
private updateViewport;
|
|
220
|
+
private handleInput;
|
|
221
|
+
private requestUiRefresh;
|
|
198
222
|
/** Render a finished agent line. */
|
|
199
223
|
private renderFinishedLine;
|
|
200
224
|
/**
|
|
@@ -202,10 +226,8 @@ export declare class AgentWidget {
|
|
|
202
226
|
* reading live state each time instead of capturing it in a closure.
|
|
203
227
|
*/
|
|
204
228
|
private renderWidget;
|
|
205
|
-
/**
|
|
206
|
-
|
|
207
|
-
/** Force an immediate widget update. `advanceSpinner` is reserved for the timer. */
|
|
208
|
-
update(advanceSpinner?: boolean): void;
|
|
229
|
+
/** Force an immediate widget update. */
|
|
230
|
+
update(): void;
|
|
209
231
|
dispose(): void;
|
|
210
232
|
}
|
|
211
233
|
//# sourceMappingURL=agent-widget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-widget.d.ts","sourceRoot":"","sources":["../../src/ui/agent-widget.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"agent-widget.d.ts","sourceRoot":"","sources":["../../src/ui/agent-widget.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,qBAAqB,CAAC;AAEzE,OAAO,KAAK,EAAE,eAAe,EAAe,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAA+D,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAA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