pi-subagent-manager 0.13.0 → 0.15.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/README.md +2 -2
- package/docs/custom-agents.md +3 -0
- package/docs/settings.md +8 -1
- package/docs/tools-and-ui.md +9 -4
- package/package.json +1 -1
- package/src/index.ts +48 -15
- package/src/orch/manager.ts +21 -4
- package/src/orch/prompt.ts +8 -3
- package/src/orch/runtime.ts +107 -52
- package/src/orch/tools.ts +37 -15
- package/src/prefs/models.ts +19 -2
- package/src/prefs/settings.ts +12 -1
- package/src/types.ts +9 -0
- package/src/ui/agent-loader.ts +63 -0
- package/src/ui/live-agent-view.ts +117 -48
- package/src/ui/settings-ui.ts +25 -1
- package/src/ui/status-ui.ts +14 -8
- package/src/ui/thread-tree.ts +37 -11
- package/src/ui/ui.ts +65 -119
package/src/prefs/models.ts
CHANGED
|
@@ -36,6 +36,21 @@ export function modelIdentity(model: { provider: string; id: string }): string {
|
|
|
36
36
|
return `${model.provider}/${model.id}`;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
export class ModelPreferenceError extends Error {
|
|
40
|
+
constructor(
|
|
41
|
+
message: string,
|
|
42
|
+
readonly scopedModelFiltering: boolean,
|
|
43
|
+
) {
|
|
44
|
+
super(message);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get summary(): string {
|
|
48
|
+
return this.scopedModelFiltering
|
|
49
|
+
? "No preferred model is available in /scoped-models; update the scope or this type's models."
|
|
50
|
+
: "No preferred model is available; check provider credentials or this type's models.";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
39
54
|
export function selectPreferredModel(
|
|
40
55
|
type: { name: string; models?: unknown; model?: unknown },
|
|
41
56
|
eligibleModels: readonly { model: { provider: string; id: string } }[],
|
|
@@ -50,11 +65,13 @@ export function selectPreferredModel(
|
|
|
50
65
|
const preferenceList = `[${preferences.join(", ")}]`;
|
|
51
66
|
const availableList = available.length === 0 ? "(none)" : `[${available.join(", ")}]`;
|
|
52
67
|
if (!scopedModelFiltering) {
|
|
53
|
-
throw new
|
|
68
|
+
throw new ModelPreferenceError(
|
|
54
69
|
`Agent type ${JSON.stringify(type.name)} prefers models ${preferenceList}, but none are available. Available models: ${availableList}. Update this agent type's models list.`,
|
|
70
|
+
false,
|
|
55
71
|
);
|
|
56
72
|
}
|
|
57
|
-
throw new
|
|
73
|
+
throw new ModelPreferenceError(
|
|
58
74
|
`Agent type ${JSON.stringify(type.name)} prefers scoped models ${preferenceList}, but none are available in /scoped-models. Available scoped models: ${availableList}. Update /scoped-models or this agent type's models list.`,
|
|
75
|
+
true,
|
|
59
76
|
);
|
|
60
77
|
}
|
package/src/prefs/settings.ts
CHANGED
|
@@ -19,6 +19,9 @@ export type SubagentMode = (typeof SUBAGENT_MODES)[number];
|
|
|
19
19
|
export const WIDGET_MODES = ["full", "minimal"] as const;
|
|
20
20
|
export type WidgetMode = (typeof WIDGET_MODES)[number];
|
|
21
21
|
|
|
22
|
+
export const LOADER_STYLES = ["circle", "braille", "hourglass"] as const;
|
|
23
|
+
export type LoaderStyle = (typeof LOADER_STYLES)[number];
|
|
24
|
+
|
|
22
25
|
export const TOOL_FILTERING_MODES = ["allowed", "all-except-blocked", "all"] as const;
|
|
23
26
|
export type ToolFilteringMode = (typeof TOOL_FILTERING_MODES)[number];
|
|
24
27
|
|
|
@@ -34,6 +37,7 @@ export interface ManagerSettings {
|
|
|
34
37
|
toolFiltering: ToolFilteringMode;
|
|
35
38
|
widgetMode: WidgetMode;
|
|
36
39
|
nerdFontIcons: boolean;
|
|
40
|
+
loaderStyle: LoaderStyle;
|
|
37
41
|
finalRecap: boolean;
|
|
38
42
|
maxLevels: number;
|
|
39
43
|
maxConcurrent: number;
|
|
@@ -50,11 +54,12 @@ export const DEFAULT_MANAGER_SETTINGS: ManagerSettings = {
|
|
|
50
54
|
toolFiltering: "allowed",
|
|
51
55
|
widgetMode: "full",
|
|
52
56
|
nerdFontIcons: false,
|
|
57
|
+
loaderStyle: "circle",
|
|
53
58
|
finalRecap: false,
|
|
54
59
|
};
|
|
55
60
|
|
|
56
61
|
const KEYS = [
|
|
57
|
-
"maxLevels", "maxConcurrent", "maxThreads", "modelSelection", "subagentMode", "toolFiltering", "widgetMode", "nerdFontIcons", "finalRecap",
|
|
62
|
+
"maxLevels", "maxConcurrent", "maxThreads", "modelSelection", "subagentMode", "toolFiltering", "widgetMode", "nerdFontIcons", "loaderStyle", "finalRecap",
|
|
58
63
|
] as const;
|
|
59
64
|
const MAX_LEVELS = 32;
|
|
60
65
|
|
|
@@ -95,6 +100,7 @@ function requirement(key: (typeof KEYS)[number]): string {
|
|
|
95
100
|
if (key === "nerdFontIcons" || key === "finalRecap") return `${key} must be a boolean`;
|
|
96
101
|
if (key === "subagentMode") return "subagentMode must be off, opportunistic or orchestration";
|
|
97
102
|
if (key === "widgetMode") return "widgetMode must be full or minimal";
|
|
103
|
+
if (key === "loaderStyle") return "loaderStyle must be circle, braille or hourglass";
|
|
98
104
|
if (key === "toolFiltering") return "toolFiltering must be allowed, all-except-blocked or all";
|
|
99
105
|
if (key === "modelSelection")
|
|
100
106
|
return "modelSelection must be pick-first-available, pick-first-scoped or use-current";
|
|
@@ -148,6 +154,11 @@ function parseSettings(content: string): Partial<ManagerSettings> {
|
|
|
148
154
|
layer.widgetMode = value as WidgetMode;
|
|
149
155
|
continue;
|
|
150
156
|
}
|
|
157
|
+
if (key === "loaderStyle") {
|
|
158
|
+
if (!LOADER_STYLES.includes(value as LoaderStyle)) throw new Error(requirement(key));
|
|
159
|
+
layer.loaderStyle = value as LoaderStyle;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
151
162
|
if (key === "modelSelection") {
|
|
152
163
|
if (!MODEL_SELECTION_MODES.includes(value as ModelSelectionMode))
|
|
153
164
|
throw new Error(requirement(key));
|
package/src/types.ts
CHANGED
|
@@ -3,6 +3,10 @@ import type { ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
|
3
3
|
|
|
4
4
|
export const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"] as const;
|
|
5
5
|
export type ThinkingLevel = (typeof THINKING_LEVELS)[number];
|
|
6
|
+
export interface ResolvedAgentSettings {
|
|
7
|
+
model: string;
|
|
8
|
+
thinkingLevel: ThinkingLevel;
|
|
9
|
+
}
|
|
6
10
|
export interface AgentType {
|
|
7
11
|
name: string;
|
|
8
12
|
description: string;
|
|
@@ -57,6 +61,8 @@ export interface ThreadView {
|
|
|
57
61
|
elapsedMs?: number;
|
|
58
62
|
/** Current run start. Live only; omitted from saved views so reloads do not count offline time. */
|
|
59
63
|
startedAt?: number;
|
|
64
|
+
/** Most recent run start (spawn or resume). Persisted; orders the agent tree newest-first. */
|
|
65
|
+
lastStartedAt?: number;
|
|
60
66
|
/** Cumulative input tokens, including cache read/write. Live views include the in-progress message. */
|
|
61
67
|
inputTokens?: number;
|
|
62
68
|
/** Cumulative output tokens. Live views include the in-progress message. */
|
|
@@ -148,6 +154,7 @@ export interface SavedThreadView {
|
|
|
148
154
|
sessionLeafId?: string | null;
|
|
149
155
|
/** Frozen cumulative active time. `startedAt` is intentionally not persisted. */
|
|
150
156
|
elapsedMs?: number;
|
|
157
|
+
lastStartedAt?: number;
|
|
151
158
|
inputTokens?: number;
|
|
152
159
|
outputTokens?: number;
|
|
153
160
|
}
|
|
@@ -186,6 +193,8 @@ export interface ManagerOptions {
|
|
|
186
193
|
getType(name: string): AgentType;
|
|
187
194
|
toolsFor(path: string): ToolDefinition[];
|
|
188
195
|
onEvent?(event: ThreadEvent): void;
|
|
196
|
+
/** Notification failures are diagnostic only; they must never interrupt a runner. */
|
|
197
|
+
onEventError?(error: unknown, event: ThreadEvent): void;
|
|
189
198
|
/** Maximum levels including the main conversation as L1; defaults to 3. */
|
|
190
199
|
maxLevels?: number;
|
|
191
200
|
/** @deprecated Internal legacy path-depth override; prefer maxLevels. */
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { LoaderStyle } from "../prefs/settings.ts";
|
|
2
|
+
import type { ThreadView } from "../types.ts";
|
|
3
|
+
|
|
4
|
+
export const AGENT_PROGRESS_INTERVAL = 180;
|
|
5
|
+
|
|
6
|
+
type SettledState = Exclude<ThreadView["state"], "starting" | "running">;
|
|
7
|
+
|
|
8
|
+
/** Built-in glyphs only; role icons are validated separately and never replaced. */
|
|
9
|
+
export const AGENT_LOADERS: Record<
|
|
10
|
+
LoaderStyle,
|
|
11
|
+
{
|
|
12
|
+
label: string;
|
|
13
|
+
frames: readonly string[];
|
|
14
|
+
states: Record<SettledState, string>;
|
|
15
|
+
}
|
|
16
|
+
> = {
|
|
17
|
+
circle: {
|
|
18
|
+
label: "Circle",
|
|
19
|
+
// Nerd Fonts md-circle-slice-1..8, check-circle, pause-circle, close-circle, stop-circle.
|
|
20
|
+
frames: Array.from({ length: 8 }, (_, index) => String.fromCodePoint(0xf0a9e + index)),
|
|
21
|
+
states: {
|
|
22
|
+
completed: "\u{f05e0}",
|
|
23
|
+
paused: "\u{f03e5}",
|
|
24
|
+
failed: "\u{f0159}",
|
|
25
|
+
stopped: "\u{f0666}",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
braille: {
|
|
29
|
+
label: "Braille",
|
|
30
|
+
frames: Array.from("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"),
|
|
31
|
+
states: { completed: "✓", paused: "Ⅱ", failed: "×", stopped: "■" },
|
|
32
|
+
},
|
|
33
|
+
hourglass: {
|
|
34
|
+
label: "Hourglass",
|
|
35
|
+
// Nerd Fonts fa-hourglass-start/half/end, pause, times-circle, stop.
|
|
36
|
+
frames: ["\uf251", "\uf252", "\uf253"],
|
|
37
|
+
states: { completed: "\uf253", paused: "\uf04c", failed: "\uf057", stopped: "\uf04d" },
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** RPC/non-animated hosts use the first running frame and all settled indicators. */
|
|
42
|
+
export function agentProgressIcon(
|
|
43
|
+
thread: Pick<ThreadView, "state">,
|
|
44
|
+
nerdFontIcons: boolean,
|
|
45
|
+
now = Date.now(),
|
|
46
|
+
animate = true,
|
|
47
|
+
loaderStyle: LoaderStyle = "circle",
|
|
48
|
+
): string | undefined {
|
|
49
|
+
if (!nerdFontIcons) return undefined;
|
|
50
|
+
const loader = AGENT_LOADERS[loaderStyle];
|
|
51
|
+
if (thread.state === "starting" || thread.state === "running") {
|
|
52
|
+
const index = animate ? Math.floor(Math.max(0, now) / AGENT_PROGRESS_INTERVAL) : 0;
|
|
53
|
+
return loader.frames[index % loader.frames.length];
|
|
54
|
+
}
|
|
55
|
+
return loader.states[thread.state];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Restrict the separate label prefix to trusted, single built-in loader glyphs. */
|
|
59
|
+
export function isAgentLoaderGlyph(glyph: string): boolean {
|
|
60
|
+
return Object.values(AGENT_LOADERS).some(
|
|
61
|
+
(loader) => loader.frames.includes(glyph) || Object.values(loader.states).includes(glyph),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -14,6 +14,9 @@ import {
|
|
|
14
14
|
import type { ThreadService, TranscriptSnapshot } from "../types.ts";
|
|
15
15
|
import { dialogText, type DialogHost } from "./dialog.ts";
|
|
16
16
|
import { AGENT_PROGRESS_INTERVAL, agentProgressIcon, agentTypeLabel } from "./ui.ts";
|
|
17
|
+
import type { LoaderStyle } from "../prefs/settings.ts";
|
|
18
|
+
|
|
19
|
+
type ThemeBg = Parameters<Theme["bg"]>[0];
|
|
17
20
|
|
|
18
21
|
/** Transcript detail level cycled by the t key: full → preview → compact. */
|
|
19
22
|
export type TranscriptDetail = "full" | "preview" | "compact";
|
|
@@ -65,7 +68,10 @@ export class LiveAgentView {
|
|
|
65
68
|
private unsubscribe: (() => void) | undefined;
|
|
66
69
|
private renderTimer: ReturnType<typeof setTimeout> | undefined;
|
|
67
70
|
private progressTimer: ReturnType<typeof setInterval> | undefined;
|
|
68
|
-
private cache = new WeakMap<
|
|
71
|
+
private cache = new WeakMap<
|
|
72
|
+
object,
|
|
73
|
+
{ width: number; detail: TranscriptDetail; lines: string[] }
|
|
74
|
+
>();
|
|
69
75
|
private scroll: ScrollView;
|
|
70
76
|
private content: string[] = [];
|
|
71
77
|
private restoreViewport = true;
|
|
@@ -86,6 +92,7 @@ export class LiveAgentView {
|
|
|
86
92
|
private viewport: AgentViewportState,
|
|
87
93
|
private done: (result: "back" | "main") => void,
|
|
88
94
|
private nerdFontIcons = false,
|
|
95
|
+
private loaderStyle: LoaderStyle = "circle",
|
|
89
96
|
) {
|
|
90
97
|
this.scroll = new ScrollView(
|
|
91
98
|
{ render: () => this.content, invalidate() {} },
|
|
@@ -187,7 +194,10 @@ export class LiveAgentView {
|
|
|
187
194
|
|
|
188
195
|
private syncProgress(): void {
|
|
189
196
|
const state = this.snapshot?.thread?.state;
|
|
190
|
-
const active =
|
|
197
|
+
const active =
|
|
198
|
+
this.nerdFontIcons &&
|
|
199
|
+
!this.disposed &&
|
|
200
|
+
!this.error &&
|
|
191
201
|
(state === "starting" || state === "running");
|
|
192
202
|
if (!active) {
|
|
193
203
|
if (this.progressTimer !== undefined) clearInterval(this.progressTimer);
|
|
@@ -275,6 +285,23 @@ export class LiveAgentView {
|
|
|
275
285
|
return this.viewport.detail ?? "preview";
|
|
276
286
|
}
|
|
277
287
|
|
|
288
|
+
/** One column of horizontal padding on each side of the transcript. */
|
|
289
|
+
private pad(lines: string[]): string[] {
|
|
290
|
+
return lines.map((line) => ` ${line}`);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** Full-width themed band with one column of padding, like pi's tool boxes. */
|
|
294
|
+
private band(lines: string[], token: ThemeBg, width: number): string[] {
|
|
295
|
+
const inner = Math.max(1, width - 2);
|
|
296
|
+
return lines.map((line) => {
|
|
297
|
+
const clipped = truncateToWidth(line, inner, "", true);
|
|
298
|
+
return this.theme.bg(
|
|
299
|
+
token,
|
|
300
|
+
` ${clipped}${" ".repeat(Math.max(0, inner - visibleWidth(clipped)))} `,
|
|
301
|
+
);
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
278
305
|
private wrap(value: string, width: number): string[] {
|
|
279
306
|
return text(value)
|
|
280
307
|
.split("\n")
|
|
@@ -320,28 +347,39 @@ export class LiveAgentView {
|
|
|
320
347
|
return lines;
|
|
321
348
|
}
|
|
322
349
|
|
|
350
|
+
/** Renders padded rows: `width` is the full transcript width. Tool calls get a themed band. */
|
|
323
351
|
private blocks(content: unknown, width: number): string[] {
|
|
324
|
-
|
|
325
|
-
if (!Array.isArray(content)) return this.
|
|
352
|
+
const inner = Math.max(1, width - 2);
|
|
353
|
+
if (!Array.isArray(content)) return this.pad(this.blockLines(content, inner));
|
|
326
354
|
return content.flatMap((value) => {
|
|
327
355
|
const block = object(value);
|
|
328
|
-
if (
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
const rendered = this.markdown(String(block.thinking ?? "[redacted thinking]"), width, true);
|
|
336
|
-
if (this.detail === "full" || rendered.length <= 3) return rendered;
|
|
337
|
-
return [...rendered.slice(0, 3), this.theme.fg("dim", "...")];
|
|
338
|
-
}
|
|
339
|
-
if (block.type === "toolCall")
|
|
340
|
-
return this.toolCall(String(block.name), block.arguments, width);
|
|
341
|
-
return this.preview(json(block), width);
|
|
356
|
+
if (block?.type === "toolCall")
|
|
357
|
+
return this.band(
|
|
358
|
+
this.toolCall(String(block.name), block.arguments, inner),
|
|
359
|
+
"toolSuccessBg",
|
|
360
|
+
width,
|
|
361
|
+
);
|
|
362
|
+
return this.pad(this.blockLines(value, inner));
|
|
342
363
|
});
|
|
343
364
|
}
|
|
344
365
|
|
|
366
|
+
private blockLines(value: unknown, width: number): string[] {
|
|
367
|
+
if (typeof value === "string") return this.markdown(value, width);
|
|
368
|
+
const block = object(value);
|
|
369
|
+
if (!block) return this.wrap(json(value), width);
|
|
370
|
+
if (block.type === "text") return this.markdown(String(block.text ?? ""), width);
|
|
371
|
+
if (block.type === "image") return ["[Image — text-only observer]"];
|
|
372
|
+
if (block.type === "thinking") {
|
|
373
|
+
if (this.detail === "compact")
|
|
374
|
+
return [this.theme.fg("dim", "[Thinking hidden · t cycles view]")];
|
|
375
|
+
// Thinking is model-authored Markdown; preview truncates the rendered lines, not the source.
|
|
376
|
+
const rendered = this.markdown(String(block.thinking ?? "[redacted thinking]"), width, true);
|
|
377
|
+
if (this.detail === "full" || rendered.length <= 3) return rendered;
|
|
378
|
+
return [...rendered.slice(0, 3), this.theme.fg("dim", "...")];
|
|
379
|
+
}
|
|
380
|
+
return this.preview(json(block), width);
|
|
381
|
+
}
|
|
382
|
+
|
|
345
383
|
private message(message: AgentMessage, width: number): string[] {
|
|
346
384
|
const cached = this.cache.get(message);
|
|
347
385
|
if (cached && cached.width === width && cached.detail === this.detail) return cached.lines;
|
|
@@ -352,17 +390,30 @@ export class LiveAgentView {
|
|
|
352
390
|
: message.role;
|
|
353
391
|
const collapsed = !["user", "assistant", "custom"].includes(message.role);
|
|
354
392
|
const content = data.content ?? data.summary ?? data.output ?? data;
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
""
|
|
365
|
-
|
|
393
|
+
const inner = Math.max(1, width - 2);
|
|
394
|
+
const heading = this.theme.fg(data.isError ? "error" : "accent", dialogText(label));
|
|
395
|
+
const errors = data.errorMessage
|
|
396
|
+
? (collapsed
|
|
397
|
+
? this.preview(String(data.errorMessage), inner)
|
|
398
|
+
: this.wrap(String(data.errorMessage), inner)
|
|
399
|
+
).map((line) => this.theme.fg("error", line))
|
|
400
|
+
: [];
|
|
401
|
+
const lines =
|
|
402
|
+
message.role === "toolResult"
|
|
403
|
+
? [
|
|
404
|
+
...this.band(
|
|
405
|
+
[heading, ...this.preview(content, inner), ...errors],
|
|
406
|
+
data.isError ? "toolErrorBg" : "customMessageBg",
|
|
407
|
+
width,
|
|
408
|
+
),
|
|
409
|
+
"",
|
|
410
|
+
]
|
|
411
|
+
: [
|
|
412
|
+
...this.pad([heading]),
|
|
413
|
+
...(collapsed ? this.pad(this.preview(content, inner)) : this.blocks(content, width)),
|
|
414
|
+
...this.pad(errors),
|
|
415
|
+
"",
|
|
416
|
+
];
|
|
366
417
|
this.cache.set(message, { width, detail: this.detail, lines });
|
|
367
418
|
return lines;
|
|
368
419
|
}
|
|
@@ -448,7 +499,9 @@ export class LiveAgentView {
|
|
|
448
499
|
}
|
|
449
500
|
case "ls": {
|
|
450
501
|
const limit = num("limit");
|
|
451
|
-
lines = [
|
|
502
|
+
lines = [
|
|
503
|
+
`${title("ls")} ${path ?? "."}${limit != null ? detail(` (limit ${limit})`) : ""}`,
|
|
504
|
+
];
|
|
452
505
|
break;
|
|
453
506
|
}
|
|
454
507
|
default:
|
|
@@ -474,34 +527,36 @@ export class LiveAgentView {
|
|
|
474
527
|
const columns = Math.max(1, width);
|
|
475
528
|
const snapshot = this.snapshot;
|
|
476
529
|
const thread = snapshot?.thread;
|
|
530
|
+
const inner = Math.max(1, columns - 2);
|
|
477
531
|
const header = this.theme.fg(
|
|
478
532
|
"accent",
|
|
479
533
|
dialogText(
|
|
480
|
-
`${this.path} · ${agentTypeLabel(thread?.type ?? "agent", thread ? agentProgressIcon(thread, this.nerdFontIcons)
|
|
534
|
+
`${this.path} · ${agentTypeLabel(thread?.type ?? "agent", thread?.icon, this.nerdFontIcons, thread ? agentProgressIcon(thread, this.nerdFontIcons, Date.now(), true, this.loaderStyle) : undefined)} · ${thread?.state ?? "attaching"} — Watching — main continues`,
|
|
481
535
|
),
|
|
482
536
|
);
|
|
483
537
|
const body: string[] = [];
|
|
484
538
|
if (this.error)
|
|
485
539
|
body.push(
|
|
486
|
-
this.theme.fg("error", dialogText(`Attachment error: ${this.error}`))
|
|
487
|
-
"Ctrl+R Retry · Esc Back · Ctrl+Q Back to main",
|
|
540
|
+
` ${this.theme.fg("error", dialogText(`Attachment error: ${this.error}`))}`,
|
|
541
|
+
" Ctrl+R Retry · Esc Back · Ctrl+Q Back to main",
|
|
488
542
|
);
|
|
489
543
|
if (!snapshot) {
|
|
490
|
-
if (!this.error) body.push("Attaching to retained live session…");
|
|
544
|
+
if (!this.error) body.push(" Attaching to retained live session…");
|
|
491
545
|
} else {
|
|
492
546
|
if (snapshot.inheritedCount)
|
|
493
547
|
body.push(
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
548
|
+
" " +
|
|
549
|
+
this.theme.fg(
|
|
550
|
+
"dim",
|
|
551
|
+
`${snapshot.inheritedCount} inherited messages ${this.viewport.showInherited ? "shown" : "collapsed"} · c toggle`,
|
|
552
|
+
),
|
|
498
553
|
);
|
|
499
554
|
const start = this.viewport.showInherited ? 0 : snapshot.inheritedCount;
|
|
500
555
|
for (const message of snapshot.messages.slice(start))
|
|
501
556
|
body.push(...this.message(message, columns));
|
|
502
557
|
if (snapshot.assistant)
|
|
503
558
|
body.push(
|
|
504
|
-
this.theme.fg("warning", "Assistant streaming…")
|
|
559
|
+
` ${this.theme.fg("warning", "Assistant streaming…")}`,
|
|
505
560
|
...this.message(snapshot.assistant, columns),
|
|
506
561
|
);
|
|
507
562
|
const committedResults = new Set(
|
|
@@ -511,23 +566,29 @@ export class LiveAgentView {
|
|
|
511
566
|
);
|
|
512
567
|
for (const tool of snapshot.tools) {
|
|
513
568
|
if (committedResults.has(tool.toolCallId)) continue;
|
|
514
|
-
const call = this.toolCall(tool.toolName, tool.args,
|
|
569
|
+
const call = this.toolCall(tool.toolName, tool.args, inner);
|
|
515
570
|
call[0] = `${call[0]} ${this.theme.fg(
|
|
516
571
|
tool.isError ? "error" : "warning",
|
|
517
572
|
dialogText(
|
|
518
573
|
`— ${tool.state}${tool.isError ? " (error)" : ""}${tool.parentToolCallId ? " (nested)" : ""}`,
|
|
519
574
|
),
|
|
520
575
|
)}`;
|
|
521
|
-
body.push(...call);
|
|
576
|
+
body.push(...this.band(call, "toolSuccessBg", columns));
|
|
522
577
|
if (tool.result !== undefined && this.detail !== "compact")
|
|
523
|
-
body.push(
|
|
578
|
+
body.push(
|
|
579
|
+
...this.band(
|
|
580
|
+
this.preview(object(tool.result)?.content ?? tool.result, inner),
|
|
581
|
+
tool.isError ? "toolErrorBg" : "customMessageBg",
|
|
582
|
+
columns,
|
|
583
|
+
),
|
|
584
|
+
);
|
|
524
585
|
body.push("");
|
|
525
586
|
}
|
|
526
587
|
if (!body.length)
|
|
527
588
|
body.push(
|
|
528
589
|
thread?.state === "starting"
|
|
529
|
-
? "Starting — waiting for transcript attachment…"
|
|
530
|
-
: "No retained messages yet.",
|
|
590
|
+
? " Starting — waiting for transcript attachment…"
|
|
591
|
+
: " No retained messages yet.",
|
|
531
592
|
);
|
|
532
593
|
}
|
|
533
594
|
this.content = body;
|
|
@@ -546,7 +607,7 @@ export class LiveAgentView {
|
|
|
546
607
|
const footer = this.error
|
|
547
608
|
? "Ctrl+R Retry · Tab input/transcript · Esc tree · Ctrl+Q main"
|
|
548
609
|
: `${this.editing ? "Enter steer · Tab browse" : `Tab steer · Home/End scroll · c context · t view:${this.detail}`} · Esc tree · Ctrl+Q main · ↑↓/PgUp/PgDn scroll · ${this.viewport.follow ? "following" : "scrolled"}`;
|
|
549
|
-
const input = this.input.render(
|
|
610
|
+
const input = ` ${this.input.render(inner)[0]!}`;
|
|
550
611
|
const status = this.theme.fg(
|
|
551
612
|
this.steerStatus ? (this.steerFailed ? "error" : "muted") : this.error ? "error" : "muted",
|
|
552
613
|
dialogText(
|
|
@@ -558,14 +619,22 @@ export class LiveAgentView {
|
|
|
558
619
|
: "Live transcript · Enter to steer"),
|
|
559
620
|
),
|
|
560
621
|
);
|
|
622
|
+
// Chrome rows share the transcript's one-column side padding; `visible` is already padded.
|
|
623
|
+
const chrome = (line: string) => ` ${truncateToWidth(line, inner, "")}`;
|
|
561
624
|
const lines =
|
|
562
625
|
height === 1
|
|
563
626
|
? [input]
|
|
564
627
|
: height === 2
|
|
565
|
-
? [header, input]
|
|
628
|
+
? [chrome(header), input]
|
|
566
629
|
: height === 3
|
|
567
|
-
? [header, this.theme.fg("dim", footer), input]
|
|
568
|
-
: [
|
|
630
|
+
? [chrome(header), chrome(this.theme.fg("dim", footer)), input]
|
|
631
|
+
: [
|
|
632
|
+
chrome(header),
|
|
633
|
+
chrome(status),
|
|
634
|
+
...visible,
|
|
635
|
+
chrome(this.theme.fg("dim", footer)),
|
|
636
|
+
input,
|
|
637
|
+
];
|
|
569
638
|
return fillViewport(lines, width, height);
|
|
570
639
|
}
|
|
571
640
|
}
|
package/src/ui/settings-ui.ts
CHANGED
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
} from "./dialog.ts";
|
|
9
9
|
import {
|
|
10
10
|
DEFAULT_MANAGER_SETTINGS,
|
|
11
|
+
LOADER_STYLES,
|
|
12
|
+
type LoaderStyle,
|
|
11
13
|
loadManagerSaveScope,
|
|
12
14
|
saveManagerSaveScope,
|
|
13
15
|
saveManagerSettings,
|
|
@@ -18,6 +20,17 @@ import {
|
|
|
18
20
|
type WidgetMode,
|
|
19
21
|
} from "../prefs/settings.ts";
|
|
20
22
|
import { editAgentTypes } from "./ui.ts";
|
|
23
|
+
import { AGENT_LOADERS } from "./agent-loader.ts";
|
|
24
|
+
|
|
25
|
+
const LOADER_OPTIONS = LOADER_STYLES.map((id) => {
|
|
26
|
+
const loader = AGENT_LOADERS[id];
|
|
27
|
+
return {
|
|
28
|
+
id,
|
|
29
|
+
label: loader.label,
|
|
30
|
+
value: `${loader.frames.join(" ")} · ${Object.values(loader.states).join(" ")}`,
|
|
31
|
+
help: `Each row: all starting/running frames · completed, paused, failed, stopped.\nStarting/running: ${loader.frames.join(" ")}\nCompleted: ${loader.states.completed} · Paused: ${loader.states.paused}\nFailed: ${loader.states.failed} · Stopped: ${loader.states.stopped}\nRequires [labs] Nerd Font icons On. The loader appears before the unchanged role icon.`,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
21
34
|
|
|
22
35
|
const FIELDS = [
|
|
23
36
|
{
|
|
@@ -195,7 +208,13 @@ async function configureAgentsDialog(
|
|
|
195
208
|
id: "nerdFontIcons",
|
|
196
209
|
label: "[labs] Nerd Font icons",
|
|
197
210
|
value: draft.nerdFontIcons ? "On" : "Off",
|
|
198
|
-
help: "Experimental: display each agent type’s optional icon.\nRequires a Nerd Font configured in your terminal; otherwise glyphs may appear as boxes.\nOff by default. Save and apply to update the widget immediately.",
|
|
211
|
+
help: "Experimental: display each agent type’s optional icon, preceded by its loader/state indicator.\nRequires a Nerd Font configured in your terminal; otherwise glyphs may appear as boxes.\nOff by default. Save and apply to update the widget immediately.",
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
id: "loaderStyle",
|
|
215
|
+
label: "[labs] Loader style",
|
|
216
|
+
value: AGENT_LOADERS[draft.loaderStyle].label,
|
|
217
|
+
help: "Choose Circle, Braille or Hourglass. Preview every animation frame and settled state for all families.\nRequires [labs] Nerd Font icons On. Circle is the default.\nSave and apply to update the widget immediately.",
|
|
199
218
|
},
|
|
200
219
|
{
|
|
201
220
|
id: "finalRecap",
|
|
@@ -286,6 +305,11 @@ async function configureAgentsDialog(
|
|
|
286
305
|
draft.widgetMode = mode as WidgetMode;
|
|
287
306
|
} else if (action === "nerdFontIcons") {
|
|
288
307
|
draft.nerdFontIcons = !draft.nerdFontIcons;
|
|
308
|
+
} else if (action === "loaderStyle") {
|
|
309
|
+
const style = await dialogMenu(ctx, "[labs] Loader style", LOADER_OPTIONS, {
|
|
310
|
+
selectedId: draft.loaderStyle,
|
|
311
|
+
});
|
|
312
|
+
if (LOADER_STYLES.includes(style as LoaderStyle)) draft.loaderStyle = style as LoaderStyle;
|
|
289
313
|
} else if (action === "finalRecap") {
|
|
290
314
|
draft.finalRecap = !draft.finalRecap;
|
|
291
315
|
} else if (action === "scope") {
|
package/src/ui/status-ui.ts
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
frameDialog,
|
|
25
25
|
} from "./dialog.ts";
|
|
26
26
|
import type { ThreadService } from "../types.ts";
|
|
27
|
+
import type { LoaderStyle } from "../prefs/settings.ts";
|
|
27
28
|
import { buildStatusTree, type StatusRow } from "./thread-tree.ts";
|
|
28
29
|
import {
|
|
29
30
|
AGENT_PROGRESS_INTERVAL, agentProgressIcon, agentTypeBadge, agentTypeLabel, showThreads, threadMetrics,
|
|
@@ -109,6 +110,7 @@ export class StatusDialog {
|
|
|
109
110
|
fullscreen?: boolean;
|
|
110
111
|
},
|
|
111
112
|
private nerdFontIcons = false,
|
|
113
|
+
private loaderStyle: LoaderStyle = "circle",
|
|
112
114
|
) {
|
|
113
115
|
this.state = navigation?.state ?? { selectedPath: selected || ROOT, collapsed: new Set() };
|
|
114
116
|
}
|
|
@@ -260,7 +262,7 @@ export class StatusDialog {
|
|
|
260
262
|
const status = dialogText(thread.status);
|
|
261
263
|
return [
|
|
262
264
|
this.theme.fg(selected ? "accent" : base, head),
|
|
263
|
-
this.theme.fg(base, `${agentTypeLabel(thread.type, thread.icon, this.nerdFontIcons)} ${path} `),
|
|
265
|
+
this.theme.fg(base, `${agentTypeLabel(thread.type, thread.icon, this.nerdFontIcons, agentProgressIcon(thread, this.nerdFontIcons, Date.now(), true, this.loaderStyle))} ${path} `),
|
|
264
266
|
this.theme.fg(hint, state),
|
|
265
267
|
this.theme.fg(base, ` ${status}`),
|
|
266
268
|
].join("");
|
|
@@ -268,8 +270,8 @@ export class StatusDialog {
|
|
|
268
270
|
const rest = [thread.path, thread.state, thread.status]
|
|
269
271
|
.map((part) => dialogText(part))
|
|
270
272
|
.join(" ");
|
|
271
|
-
const badge = agentTypeBadge(thread.type, thread.color, this.theme,
|
|
272
|
-
agentProgressIcon(thread, this.nerdFontIcons), this.
|
|
273
|
+
const badge = agentTypeBadge(thread.type, thread.color, this.theme, thread.icon, this.nerdFontIcons,
|
|
274
|
+
agentProgressIcon(thread, this.nerdFontIcons, Date.now(), true, this.loaderStyle));
|
|
273
275
|
if (selected)
|
|
274
276
|
return `${this.theme.fg("accent", head)}${badge} ${this.theme.fg("accent", rest)}`;
|
|
275
277
|
return `${head}${badge} ${rest}`;
|
|
@@ -337,6 +339,7 @@ async function showAgentDialog(
|
|
|
337
339
|
selected?: string;
|
|
338
340
|
inspect?: (path: string) => Promise<void>;
|
|
339
341
|
nerdFontIcons?: boolean;
|
|
342
|
+
loaderStyle?: LoaderStyle;
|
|
340
343
|
} = {},
|
|
341
344
|
): Promise<void> {
|
|
342
345
|
const open = options.inspect ?? ((path: string) => showThreads(ctx, service, path));
|
|
@@ -347,7 +350,7 @@ async function showAgentDialog(
|
|
|
347
350
|
let dialog: StatusDialog | undefined;
|
|
348
351
|
try {
|
|
349
352
|
const chosen = await ctx.ui.custom<string | undefined>((host, theme, _keys, done) => {
|
|
350
|
-
dialog = new StatusDialog(host, theme, service, done, selected, options.title, undefined, options.nerdFontIcons);
|
|
353
|
+
dialog = new StatusDialog(host, theme, service, done, selected, options.title, undefined, options.nerdFontIcons, options.loaderStyle);
|
|
351
354
|
dialog.startRefresh();
|
|
352
355
|
return dialog;
|
|
353
356
|
}, DIALOG_OPTIONS);
|
|
@@ -367,9 +370,10 @@ export async function showAgentStatus(
|
|
|
367
370
|
service: ThreadService,
|
|
368
371
|
inspect?: (path: string) => Promise<void>,
|
|
369
372
|
nerdFontIcons = false,
|
|
373
|
+
loaderStyle: LoaderStyle = "circle",
|
|
370
374
|
): Promise<void> {
|
|
371
375
|
if (!canOpenDialog(ctx)) return;
|
|
372
|
-
await showAgentDialog(ctx, service, { inspect, nerdFontIcons });
|
|
376
|
+
await showAgentDialog(ctx, service, { inspect, nerdFontIcons, loaderStyle });
|
|
373
377
|
}
|
|
374
378
|
|
|
375
379
|
/** Root-owned navigation state. Opening and closing never changes the executing session. */
|
|
@@ -390,7 +394,7 @@ export class AgentNavigationController {
|
|
|
390
394
|
this.session = undefined;
|
|
391
395
|
}
|
|
392
396
|
|
|
393
|
-
open(ctx: ExtensionContext, service: ThreadService, selectedPath?: string, nerdFontIcons = false): Promise<void> {
|
|
397
|
+
open(ctx: ExtensionContext, service: ThreadService, selectedPath?: string, nerdFontIcons = false, loaderStyle: LoaderStyle = "circle"): Promise<void> {
|
|
394
398
|
if (this.opening) return this.opening;
|
|
395
399
|
if (!canOpenDialog(ctx)) return Promise.resolve();
|
|
396
400
|
if (selectedPath) this.tree.selectedPath = selectedPath;
|
|
@@ -471,6 +475,7 @@ export class AgentNavigationController {
|
|
|
471
475
|
actions: (path) => finish({ kind: "actions", path }),
|
|
472
476
|
},
|
|
473
477
|
nerdFontIcons,
|
|
478
|
+
loaderStyle,
|
|
474
479
|
);
|
|
475
480
|
treeDialog.startRefresh();
|
|
476
481
|
return treeDialog;
|
|
@@ -488,7 +493,7 @@ export class AgentNavigationController {
|
|
|
488
493
|
}
|
|
489
494
|
const result = await session.mount<"back" | "main">(
|
|
490
495
|
(tui, activeTheme, _keys, finish) =>
|
|
491
|
-
new LiveAgentView(tui, activeTheme, service, chosen.path, viewport!, finish, nerdFontIcons),
|
|
496
|
+
new LiveAgentView(tui, activeTheme, service, chosen.path, viewport!, finish, nerdFontIcons, loaderStyle),
|
|
492
497
|
);
|
|
493
498
|
if (result !== "back") break;
|
|
494
499
|
}
|
|
@@ -534,11 +539,12 @@ export async function showAgentTree(
|
|
|
534
539
|
service: ThreadService,
|
|
535
540
|
selectedPath?: string,
|
|
536
541
|
nerdFontIcons = false,
|
|
542
|
+
loaderStyle: LoaderStyle = "circle",
|
|
537
543
|
): Promise<void> {
|
|
538
544
|
let navigation = navigationByService.get(service);
|
|
539
545
|
if (!navigation) {
|
|
540
546
|
navigation = new AgentNavigationController();
|
|
541
547
|
navigationByService.set(service, navigation);
|
|
542
548
|
}
|
|
543
|
-
await navigation.open(ctx, service, selectedPath, nerdFontIcons);
|
|
549
|
+
await navigation.open(ctx, service, selectedPath, nerdFontIcons, loaderStyle);
|
|
544
550
|
}
|