@timmyjl12/pi-subagents 0.0.0-stage → 0.20.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 +827 -0
- package/CONTRIBUTING.md +72 -0
- package/LICENSE +21 -0
- package/README.md +1079 -2
- package/SECURITY.md +97 -0
- package/dist/abortable.d.ts +12 -0
- package/dist/abortable.js +42 -0
- package/dist/active-agents-prompt.d.ts +18 -0
- package/dist/active-agents-prompt.js +34 -0
- package/dist/advisor-status.d.ts +16 -0
- package/dist/advisor-status.js +74 -0
- package/dist/agent-color.d.ts +35 -0
- package/dist/agent-color.js +123 -0
- package/dist/agent-file-toggle.d.ts +125 -0
- package/dist/agent-file-toggle.js +264 -0
- package/dist/agent-manager.d.ts +485 -0
- package/dist/agent-manager.js +1380 -0
- package/dist/agent-runner.d.ts +319 -0
- package/dist/agent-runner.js +1128 -0
- package/dist/agent-types.d.ts +119 -0
- package/dist/agent-types.js +286 -0
- package/dist/child-context.d.ts +15 -0
- package/dist/child-context.js +181 -0
- package/dist/child-session-shutdown.d.ts +3 -0
- package/dist/child-session-shutdown.js +48 -0
- package/dist/context.d.ts +12 -0
- package/dist/context.js +56 -0
- package/dist/cross-extension-rpc.d.ts +66 -0
- package/dist/cross-extension-rpc.js +138 -0
- package/dist/custom-agents.d.ts +54 -0
- package/dist/custom-agents.js +386 -0
- package/dist/default-agents.d.ts +7 -0
- package/dist/default-agents.js +125 -0
- package/dist/enabled-models.d.ts +49 -0
- package/dist/enabled-models.js +145 -0
- package/dist/env.d.ts +6 -0
- package/dist/env.js +28 -0
- package/dist/error-log.d.ts +58 -0
- package/dist/error-log.js +168 -0
- package/dist/group-join.d.ts +32 -0
- package/dist/group-join.js +116 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +3896 -0
- package/dist/invocation-config.d.ts +137 -0
- package/dist/invocation-config.js +129 -0
- package/dist/memory.d.ts +53 -0
- package/dist/memory.js +165 -0
- package/dist/mention-clone.d.ts +87 -0
- package/dist/mention-clone.js +178 -0
- package/dist/mention.d.ts +81 -0
- package/dist/mention.js +131 -0
- package/dist/model-resolver.d.ts +36 -0
- package/dist/model-resolver.js +95 -0
- package/dist/model-scope.d.ts +49 -0
- package/dist/model-scope.js +48 -0
- package/dist/nested-tools.d.ts +55 -0
- package/dist/nested-tools.js +299 -0
- package/dist/output-diagnostics.d.ts +11 -0
- package/dist/output-diagnostics.js +64 -0
- package/dist/output-file.d.ts +53 -0
- package/dist/output-file.js +248 -0
- package/dist/prompts.d.ts +61 -0
- package/dist/prompts.js +94 -0
- package/dist/recovery.d.ts +56 -0
- package/dist/recovery.js +341 -0
- package/dist/schedule-store.d.ts +44 -0
- package/dist/schedule-store.js +210 -0
- package/dist/schedule.d.ts +109 -0
- package/dist/schedule.js +359 -0
- package/dist/settings.d.ts +360 -0
- package/dist/settings.js +251 -0
- package/dist/skill-loader.d.ts +24 -0
- package/dist/skill-loader.js +93 -0
- package/dist/standalone-fallback.d.ts +30 -0
- package/dist/standalone-fallback.js +239 -0
- package/dist/status-note.d.ts +61 -0
- package/dist/status-note.js +85 -0
- package/dist/structured-output.d.ts +61 -0
- package/dist/structured-output.js +112 -0
- package/dist/terminal-progress.d.ts +115 -0
- package/dist/terminal-progress.js +206 -0
- package/dist/types.d.ts +382 -0
- package/dist/types.js +5 -0
- package/dist/ui/agent-mention.d.ts +82 -0
- package/dist/ui/agent-mention.js +187 -0
- package/dist/ui/agent-widget.d.ts +235 -0
- package/dist/ui/agent-widget.js +652 -0
- package/dist/ui/conversation-viewer.d.ts +105 -0
- package/dist/ui/conversation-viewer.js +540 -0
- package/dist/ui/fleet-list.d.ts +183 -0
- package/dist/ui/fleet-list.js +494 -0
- package/dist/ui/fleet-overlay.d.ts +172 -0
- package/dist/ui/fleet-overlay.js +691 -0
- package/dist/ui/native-transcript.d.ts +33 -0
- package/dist/ui/native-transcript.js +230 -0
- package/dist/ui/schedule-menu.d.ts +16 -0
- package/dist/ui/schedule-menu.js +94 -0
- package/dist/ui/select-item.d.ts +27 -0
- package/dist/ui/select-item.js +34 -0
- package/dist/ui/tool-progress.d.ts +22 -0
- package/dist/ui/tool-progress.js +56 -0
- package/dist/ui/viewer-keys.d.ts +20 -0
- package/dist/ui/viewer-keys.js +17 -0
- package/dist/ui/workflow-card.d.ts +175 -0
- package/dist/ui/workflow-card.js +332 -0
- package/dist/ui/workflow-dialog.d.ts +305 -0
- package/dist/ui/workflow-dialog.js +843 -0
- package/dist/ui/workflow-menu.d.ts +60 -0
- package/dist/ui/workflow-menu.js +147 -0
- package/dist/usage.d.ts +135 -0
- package/dist/usage.js +120 -0
- package/dist/workflow/collisions.d.ts +95 -0
- package/dist/workflow/collisions.js +88 -0
- package/dist/workflow/entry.d.ts +32 -0
- package/dist/workflow/entry.js +29 -0
- package/dist/workflow/host.d.ts +62 -0
- package/dist/workflow/host.js +363 -0
- package/dist/workflow/journal.d.ts +97 -0
- package/dist/workflow/journal.js +120 -0
- package/dist/workflow/json-schema.d.ts +51 -0
- package/dist/workflow/json-schema.js +111 -0
- package/dist/workflow/meta.d.ts +67 -0
- package/dist/workflow/meta.js +317 -0
- package/dist/workflow/progress.d.ts +224 -0
- package/dist/workflow/progress.js +361 -0
- package/dist/workflow/runtime.d.ts +334 -0
- package/dist/workflow/runtime.js +830 -0
- package/dist/workflow/saved.d.ts +90 -0
- package/dist/workflow/saved.js +203 -0
- package/dist/workflow/task.d.ts +136 -0
- package/dist/workflow/task.js +207 -0
- package/dist/workflow/tool-description.d.ts +38 -0
- package/dist/workflow/tool-description.js +199 -0
- package/dist/workflow/worker-source.d.ts +47 -0
- package/dist/workflow/worker-source.js +778 -0
- package/dist/worktree.d.ts +52 -0
- package/dist/worktree.js +164 -0
- package/dist/xml.d.ts +10 -0
- package/dist/xml.js +12 -0
- package/docs/FORK.md +40 -0
- package/docs/recovery.md +62 -0
- package/docs/rpc.md +189 -0
- package/docs/workflows.md +437 -0
- package/examples/agent-tool-description.md +43 -0
- 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 +75 -6
- package/src/abortable.ts +43 -0
- package/src/active-agents-prompt.ts +39 -0
- package/src/advisor-status.ts +74 -0
- package/src/agent-color.ts +161 -0
- package/src/agent-file-toggle.ts +273 -0
- package/src/agent-manager.ts +1601 -0
- package/src/agent-runner.ts +1372 -0
- package/src/agent-types.ts +345 -0
- package/src/child-context.ts +173 -0
- package/src/child-session-shutdown.ts +46 -0
- package/src/context.ts +58 -0
- package/src/cross-extension-rpc.ts +198 -0
- package/src/custom-agents.ts +417 -0
- package/src/default-agents.ts +129 -0
- package/src/enabled-models.ts +180 -0
- package/src/env.ts +33 -0
- package/src/error-log.ts +193 -0
- package/src/group-join.ts +141 -0
- package/src/index.ts +4218 -0
- package/src/invocation-config.ts +230 -0
- package/src/memory.ts +179 -0
- package/src/mention-clone.ts +221 -0
- package/src/mention.ts +141 -0
- package/src/model-resolver.ts +118 -0
- package/src/model-scope.ts +70 -0
- package/src/nested-tools.ts +422 -0
- package/src/output-diagnostics.ts +68 -0
- package/src/output-file.ts +258 -0
- package/src/prompts.ts +151 -0
- package/src/recovery.ts +320 -0
- package/src/schedule-store.ts +201 -0
- package/src/schedule.ts +386 -0
- package/src/settings.ts +587 -0
- package/src/skill-loader.ts +102 -0
- package/src/standalone-fallback.ts +195 -0
- package/src/status-note.ts +90 -0
- package/src/structured-output.ts +130 -0
- package/src/terminal-progress.ts +215 -0
- package/src/types.ts +394 -0
- package/src/ui/agent-mention.ts +216 -0
- package/src/ui/agent-widget.ts +732 -0
- package/src/ui/conversation-viewer.ts +523 -0
- package/src/ui/fleet-list.ts +563 -0
- package/src/ui/fleet-overlay.ts +847 -0
- package/src/ui/native-transcript.ts +220 -0
- package/src/ui/schedule-menu.ts +105 -0
- package/src/ui/select-item.ts +45 -0
- package/src/ui/tool-progress.ts +67 -0
- package/src/ui/viewer-keys.ts +39 -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 +167 -0
- package/src/workflow/collisions.ts +123 -0
- package/src/workflow/entry.ts +47 -0
- package/src/workflow/host.ts +404 -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 +205 -0
- package/src/xml.ts +13 -0
|
@@ -0,0 +1,216 @@
|
|
|
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
|
+
|
|
45
|
+
import type { AutocompleteItem, AutocompleteProvider, AutocompleteSuggestions } from "@earendil-works/pi-tui";
|
|
46
|
+
import type { AgentManager } from "../agent-manager.js";
|
|
47
|
+
import { handleBase, MENTION_TRIGGER } from "../mention.js";
|
|
48
|
+
import type { AgentRecord, AgentTombstone } from "../types.js";
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* One thing `@` can address, and what sending to it will do. `typeLabel` is the
|
|
52
|
+
* agent's `display_name`, resolved by the caller: this module stays independent
|
|
53
|
+
* of the type registry, but the popup must agree with FleetView and the widget,
|
|
54
|
+
* which both render the label rather than the raw type.
|
|
55
|
+
*/
|
|
56
|
+
export type MentionTarget =
|
|
57
|
+
| { kind: "record"; handle: string; record: AgentRecord; typeLabel: string }
|
|
58
|
+
| { kind: "tombstone"; handle: string; entry: AgentTombstone; typeLabel: string }
|
|
59
|
+
| { kind: "type"; handle: string; type: string; description: string };
|
|
60
|
+
|
|
61
|
+
/** The registry facts the roster needs, so it stays independent of agent-types. */
|
|
62
|
+
export type TypeInfo = { name: string; description: string };
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Everything `@` can reach, in the order the popup lists it: steerable agents
|
|
66
|
+
* first, then the other live ones earliest-launched, then agent types with no
|
|
67
|
+
* live instance. A type whose handle a record already holds is omitted — that
|
|
68
|
+
* name addresses the existing agent, which is what makes `@explore` mean
|
|
69
|
+
* "message the one that's running" and only otherwise "start one".
|
|
70
|
+
*/
|
|
71
|
+
export function mentionRoster(
|
|
72
|
+
manager: AgentManager,
|
|
73
|
+
types: readonly TypeInfo[],
|
|
74
|
+
// Identity by default: a caller with no registry to consult gets the raw
|
|
75
|
+
// type, which is also what `getConfig` falls back to when no label is set.
|
|
76
|
+
displayNameOf: (type: string) => string = type => type,
|
|
77
|
+
): MentionTarget[] {
|
|
78
|
+
const live = (r: AgentRecord) => r.status === "running" || r.status === "queued";
|
|
79
|
+
const records = manager.listAgents()
|
|
80
|
+
.filter(r => r.handle !== undefined && r.parentAgentId === undefined)
|
|
81
|
+
.sort((a, b) => (Number(live(b)) - Number(live(a))) || (a.startedAt - b.startedAt));
|
|
82
|
+
|
|
83
|
+
const taken = new Set<string>();
|
|
84
|
+
const targets: MentionTarget[] = [];
|
|
85
|
+
|
|
86
|
+
// One row per agent, not per handle. An aliased agent lists under its alias
|
|
87
|
+
// only — both names resolve, but showing two rows for one agent reads as two
|
|
88
|
+
// agents. The type handle stays addressable whether or not it is listed.
|
|
89
|
+
for (const record of records) {
|
|
90
|
+
const handle = record.alias ?? record.handle!;
|
|
91
|
+
taken.add(handle.toLowerCase());
|
|
92
|
+
if (record.handle) taken.add(record.handle.toLowerCase());
|
|
93
|
+
targets.push({ kind: "record", handle, record, typeLabel: displayNameOf(record.type) });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Then agents that are gone but whose conversation can be reopened. After the
|
|
97
|
+
// live ones: a running agent is the likelier target, and this keeps the
|
|
98
|
+
// ordering "what exists now, then what can be brought back, then what can be
|
|
99
|
+
// started".
|
|
100
|
+
for (const entry of manager.listTombstones()) {
|
|
101
|
+
const handle = entry.alias ?? entry.handle;
|
|
102
|
+
if (taken.has(handle.toLowerCase())) continue;
|
|
103
|
+
taken.add(handle.toLowerCase());
|
|
104
|
+
taken.add(entry.handle.toLowerCase());
|
|
105
|
+
targets.push({ kind: "tombstone", handle, entry, typeLabel: displayNameOf(entry.type) });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
for (const type of types) {
|
|
109
|
+
const handle = handleBase(type.name);
|
|
110
|
+
if (taken.has(handle)) continue;
|
|
111
|
+
taken.add(handle);
|
|
112
|
+
targets.push({ kind: "type", handle, type: type.name, description: type.description });
|
|
113
|
+
}
|
|
114
|
+
return targets;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function createMentionProvider(
|
|
118
|
+
current: AutocompleteProvider,
|
|
119
|
+
roster: () => MentionTarget[],
|
|
120
|
+
isEnabled: () => boolean,
|
|
121
|
+
): AutocompleteProvider {
|
|
122
|
+
// One warning per provider, not per keystroke: `getSuggestions` runs on every
|
|
123
|
+
// character typed after `@`, so an unguarded log would bury the terminal in
|
|
124
|
+
// the time it takes to finish a word.
|
|
125
|
+
let warnedInnerFailure = false;
|
|
126
|
+
return {
|
|
127
|
+
// Only `@` — the contract is "characters that should naturally trigger
|
|
128
|
+
// THIS provider", and pi unions each wrapper's own set onto the outermost
|
|
129
|
+
// one itself (interactive-mode.js:432), so re-declaring the wrapped
|
|
130
|
+
// provider's characters here would both misreport us and duplicate that.
|
|
131
|
+
triggerCharacters: ["@"],
|
|
132
|
+
|
|
133
|
+
async getSuggestions(lines, cursorLine, cursorCol, options): Promise<AutocompleteSuggestions | null> {
|
|
134
|
+
const mine = isEnabled() ? mentionItems(roster(), lines[cursorLine] ?? "", cursorCol) : null;
|
|
135
|
+
// Asked unconditionally: pi owns `@` and must keep answering for it even
|
|
136
|
+
// when a handle matches too. That is the same work vanilla pi does on any
|
|
137
|
+
// `@` keystroke — a capped `fd` search, or nothing at all when the host
|
|
138
|
+
// configured no `fd` path — but we now do it on tokens we used to answer
|
|
139
|
+
// alone, so it must not be able to take the popup down with it. The
|
|
140
|
+
// wrapped provider is not always pi's: another extension may sit inside
|
|
141
|
+
// us, and before this it was never called for a token naming an agent.
|
|
142
|
+
// try/catch, not `.catch()`: a provider that throws SYNCHRONOUSLY never
|
|
143
|
+
// returns the promise a `.catch()` would attach to, and the throw escapes
|
|
144
|
+
// this method as a rejection — which pi does not handle either
|
|
145
|
+
// (components/editor.js:1892 awaits with no catch of its own).
|
|
146
|
+
let theirs: AutocompleteSuggestions | null = null;
|
|
147
|
+
try {
|
|
148
|
+
theirs = await current.getSuggestions(lines, cursorLine, cursorCol, options);
|
|
149
|
+
} catch (err) {
|
|
150
|
+
// Safe to treat as "no files": pi discards any response whose request is
|
|
151
|
+
// no longer current, so an aborted search that surfaces as a rejection
|
|
152
|
+
// cannot leave a stale popup behind (`isAutocompleteRequestCurrent`).
|
|
153
|
+
// Warned rather than swallowed outright — the failure is invisible in
|
|
154
|
+
// the popup, and the same `console.warn` channel already carries this
|
|
155
|
+
// extension's other non-fatal failures.
|
|
156
|
+
if (!warnedInnerFailure) {
|
|
157
|
+
warnedInnerFailure = true;
|
|
158
|
+
console.warn("[pi-subagents] the autocomplete provider below us failed; showing agent rows only:", err);
|
|
159
|
+
}
|
|
160
|
+
theirs = null;
|
|
161
|
+
}
|
|
162
|
+
if (!mine) return theirs;
|
|
163
|
+
if (!theirs) return mine;
|
|
164
|
+
// Agents first: there are a handful of them against pi's 20 file rows, and
|
|
165
|
+
// a handle buried under fuzzy path matches is a handle nobody finds. The
|
|
166
|
+
// prefix is ours by the span argument in the header — identical to pi's
|
|
167
|
+
// whenever both sides have something to say.
|
|
168
|
+
return { items: [...mine.items, ...theirs.items], prefix: mine.prefix };
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
applyCompletion(lines, cursorLine, cursorCol, item, prefix) {
|
|
172
|
+
return current.applyCompletion(lines, cursorLine, cursorCol, item, prefix);
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
shouldTriggerFileCompletion(lines, cursorLine, cursorCol) {
|
|
176
|
+
return current.shouldTriggerFileCompletion?.(lines, cursorLine, cursorCol) ?? true;
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Suggestions for the `@…` token under the cursor, or null when it names no agent. */
|
|
182
|
+
function mentionItems(roster: MentionTarget[], line: string, cursorCol: number): AutocompleteSuggestions | null {
|
|
183
|
+
const match = MENTION_TRIGGER.exec(line.slice(0, cursorCol));
|
|
184
|
+
if (!match) return null;
|
|
185
|
+
|
|
186
|
+
const typed = match[2].toLowerCase();
|
|
187
|
+
const items: AutocompleteItem[] = [];
|
|
188
|
+
for (const target of roster) {
|
|
189
|
+
if (!target.handle.toLowerCase().startsWith(typed)) continue;
|
|
190
|
+
items.push({ value: `@${target.handle}`, label: `@${target.handle}`, description: describeTarget(target) });
|
|
191
|
+
}
|
|
192
|
+
return items.length > 0 ? { items, prefix: `@${match[2]}` } : null;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** Name the action that will actually happen, so the list never mispromises. */
|
|
196
|
+
function describeTarget(target: MentionTarget): string {
|
|
197
|
+
if (target.kind === "type") return `start agent · ${summarize(target.description)}`;
|
|
198
|
+
if (target.kind === "tombstone") {
|
|
199
|
+
// No status: the record is gone, and "completed" would imply one is still
|
|
200
|
+
// being tracked. The type carries the identity the handle may not.
|
|
201
|
+
return `resume · ${target.typeLabel} · ${target.entry.description}`;
|
|
202
|
+
}
|
|
203
|
+
const { status, description, alias } = target.record;
|
|
204
|
+
const action = status === "running" || status === "queued" ? "send message" : "resume";
|
|
205
|
+
// A row listed under its alias has lost the type its handle would have shown,
|
|
206
|
+
// so name it — `@auth-audit` alone says nothing about what the agent is.
|
|
207
|
+
// A type-derived row already reads as its type and would just repeat itself.
|
|
208
|
+
const identity = alias ? `${target.typeLabel} · ` : "";
|
|
209
|
+
return `${action} · ${identity}${status} · ${description}`;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** First sentence of an agent description, clipped — these run to paragraphs. */
|
|
213
|
+
function summarize(description: string): string {
|
|
214
|
+
const first = (description.match(/^.*?[.!?](?=\s|$)/s)?.[0] ?? description).replace(/\s+/g, " ").trim();
|
|
215
|
+
return first.length > 60 ? `${first.slice(0, 59).trimEnd()}…` : first;
|
|
216
|
+
}
|