pi-subagent-manager 0.14.0 → 0.16.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 +3 -2
- package/docs/custom-agents.md +3 -0
- package/docs/settings.md +8 -1
- package/docs/tools-and-ui.md +4 -3
- package/package.json +1 -1
- package/src/index.ts +40 -9
- package/src/orch/manager.ts +65 -4
- package/src/prefs/settings.ts +12 -1
- package/src/types.ts +5 -0
- package/src/ui/agent-loader.ts +63 -0
- package/src/ui/live-agent-view.ts +117 -48
- package/src/ui/settings-ui.ts +32 -2
- package/src/ui/status-ui.ts +14 -8
- package/src/ui/thread-tree.ts +37 -11
- package/src/ui/tool-picker.ts +308 -0
- package/src/ui/ui.ts +77 -156
package/src/ui/ui.ts
CHANGED
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
serializeAgentType,
|
|
30
30
|
} from "../prefs/config.ts";
|
|
31
31
|
import { editModelPreferences, MODEL_EDITOR_CANCEL } from "./model-picker.ts";
|
|
32
|
+
import { editToolSelection, TOOL_EDITOR_CANCEL, type ToolEditorOptions } from "./tool-picker.ts";
|
|
32
33
|
import {
|
|
33
34
|
canOpenDialog,
|
|
34
35
|
dialogEditor,
|
|
@@ -39,8 +40,10 @@ import {
|
|
|
39
40
|
withDialogSession,
|
|
40
41
|
} from "./dialog.ts";
|
|
41
42
|
import { getModelPreferences } from "../prefs/models.ts";
|
|
42
|
-
import type { WidgetMode } from "../prefs/settings.ts";
|
|
43
|
-
import {
|
|
43
|
+
import type { LoaderStyle, WidgetMode } from "../prefs/settings.ts";
|
|
44
|
+
import { AGENT_PROGRESS_INTERVAL, agentProgressIcon, isAgentLoaderGlyph } from "./agent-loader.ts";
|
|
45
|
+
export { AGENT_PROGRESS_INTERVAL, agentProgressIcon } from "./agent-loader.ts";
|
|
46
|
+
import { buildStatusTree, lastStarted, type StatusRow } from "./thread-tree.ts";
|
|
44
47
|
import {
|
|
45
48
|
THINKING_LEVELS,
|
|
46
49
|
type AgentType,
|
|
@@ -91,33 +94,11 @@ function contrastPill(
|
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
/** Invalid/untrusted saved icons never reach the terminal. Names remain readable. */
|
|
94
|
-
export function agentTypeLabel(type: string, icon?: string, nerdFontIcons = false): string {
|
|
95
|
-
const
|
|
97
|
+
export function agentTypeLabel(type: string, icon?: string, nerdFontIcons = false, loaderIcon?: string): string {
|
|
98
|
+
const role = nerdFontIcons && typeof icon === "string" && /^\p{Co}$/u.test(icon)
|
|
96
99
|
? `${icon} ` : "";
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/** Nerd Fonts md-circle-slice-1..8: an equal-width, shape-changing progress cycle.
|
|
101
|
-
* Verified against https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/glyphnames.json.
|
|
102
|
-
*/
|
|
103
|
-
export const AGENT_PROGRESS_INTERVAL = 180;
|
|
104
|
-
const AGENT_PROGRESS_FRAMES = Array.from({ length: 8 }, (_, index) =>
|
|
105
|
-
String.fromCodePoint(0xf0a9e + index),
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
/** Keep the configured role icon for settled threads and non-animated/RPC output. */
|
|
109
|
-
export function agentProgressIcon(
|
|
110
|
-
thread: Pick<ThreadView, "state" | "icon">,
|
|
111
|
-
nerdFontIcons: boolean,
|
|
112
|
-
now = Date.now(),
|
|
113
|
-
animate = true,
|
|
114
|
-
): string | undefined {
|
|
115
|
-
if (!nerdFontIcons) return undefined;
|
|
116
|
-
if (animate && (thread.state === "starting" || thread.state === "running")) {
|
|
117
|
-
const frame = Math.floor(Math.max(0, now) / AGENT_PROGRESS_INTERVAL) % AGENT_PROGRESS_FRAMES.length;
|
|
118
|
-
return AGENT_PROGRESS_FRAMES[frame];
|
|
119
|
-
}
|
|
120
|
-
return thread.icon;
|
|
100
|
+
const progress = nerdFontIcons && loaderIcon && isAgentLoaderGlyph(loaderIcon) ? `${loaderIcon} ` : "";
|
|
101
|
+
return `${progress}${role}${sanitizeText(type)}`;
|
|
121
102
|
}
|
|
122
103
|
|
|
123
104
|
export function agentTypeBadge(
|
|
@@ -126,8 +107,9 @@ export function agentTypeBadge(
|
|
|
126
107
|
theme: AgentBadgeTheme,
|
|
127
108
|
icon?: string,
|
|
128
109
|
nerdFontIcons = false,
|
|
110
|
+
loaderIcon?: string,
|
|
129
111
|
): string {
|
|
130
|
-
return contrastPill(agentTypeLabel(type, icon, nerdFontIcons), color, theme);
|
|
112
|
+
return contrastPill(agentTypeLabel(type, icon, nerdFontIcons, loaderIcon), color, theme);
|
|
131
113
|
}
|
|
132
114
|
|
|
133
115
|
function agentPath(
|
|
@@ -204,6 +186,7 @@ export function renderThreads(
|
|
|
204
186
|
width: number,
|
|
205
187
|
theme: AgentBadgeTheme,
|
|
206
188
|
nerdFontIcons = false,
|
|
189
|
+
loaderStyle: LoaderStyle = "circle",
|
|
207
190
|
): string[] {
|
|
208
191
|
const priority = (thread: ThreadView) =>
|
|
209
192
|
thread.state === "starting" || thread.state === "running"
|
|
@@ -228,7 +211,8 @@ export function renderThreads(
|
|
|
228
211
|
? "warning"
|
|
229
212
|
: "accent";
|
|
230
213
|
const badge = agentTypeBadge(
|
|
231
|
-
thread.type, thread.color, theme,
|
|
214
|
+
thread.type, thread.color, theme, thread.icon, nerdFontIcons,
|
|
215
|
+
agentProgressIcon(thread, nerdFontIcons, Date.now(), true, loaderStyle),
|
|
232
216
|
);
|
|
233
217
|
const path = agentPath(thread.path, thread.color, theme);
|
|
234
218
|
const state = theme.fg(stateColor, `[${sanitizeText(thread.state)}]`);
|
|
@@ -262,7 +246,8 @@ interface AgentWidgetRenderOptions {
|
|
|
262
246
|
/** RPC widgets cannot open a terminal browser. */
|
|
263
247
|
showBrowserHint?: boolean;
|
|
264
248
|
nerdFontIcons?: boolean;
|
|
265
|
-
|
|
249
|
+
loaderStyle?: LoaderStyle;
|
|
250
|
+
/** RPC snapshots use a static running frame and never start an animation. */
|
|
266
251
|
animate?: boolean;
|
|
267
252
|
}
|
|
268
253
|
|
|
@@ -292,76 +277,6 @@ function statePriority(state: ThreadView["state"] | undefined): number {
|
|
|
292
277
|
return 2;
|
|
293
278
|
}
|
|
294
279
|
|
|
295
|
-
function explicitParent(
|
|
296
|
-
path: string,
|
|
297
|
-
threadsByPath: Map<string, ThreadView>,
|
|
298
|
-
): string | null {
|
|
299
|
-
if (path === WIDGET_ROOT) return null;
|
|
300
|
-
const thread = threadsByPath.get(path);
|
|
301
|
-
if (thread)
|
|
302
|
-
return thread.parent && thread.parent !== path ? thread.parent : null;
|
|
303
|
-
const index = path.lastIndexOf("/");
|
|
304
|
-
return index > 0 ? path.slice(0, index) : null;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/** Lowest state in the branch. Parent links define ancestry; cycles are guarded. */
|
|
308
|
-
function branchPriorityComparator(
|
|
309
|
-
threads: ThreadView[],
|
|
310
|
-
): (a: string, b: string) => number {
|
|
311
|
-
const threadsByPath = new Map<string, ThreadView>();
|
|
312
|
-
for (const thread of threads) {
|
|
313
|
-
if (thread?.path && !threadsByPath.has(thread.path))
|
|
314
|
-
threadsByPath.set(thread.path, thread);
|
|
315
|
-
}
|
|
316
|
-
const children = new Map<string, string[]>();
|
|
317
|
-
const link = (path: string, seen: Set<string>) => {
|
|
318
|
-
if (!path || seen.has(path)) return;
|
|
319
|
-
seen.add(path);
|
|
320
|
-
const parent = explicitParent(path, threadsByPath);
|
|
321
|
-
if (!parent || parent === path) return;
|
|
322
|
-
const list = children.get(parent) ?? [];
|
|
323
|
-
if (!list.includes(path)) list.push(path);
|
|
324
|
-
children.set(parent, list);
|
|
325
|
-
link(parent, seen);
|
|
326
|
-
};
|
|
327
|
-
link(WIDGET_ROOT, new Set());
|
|
328
|
-
for (const path of threadsByPath.keys()) link(path, new Set());
|
|
329
|
-
|
|
330
|
-
const subtree = new Map<string, number>();
|
|
331
|
-
const ancestors = new Map<string, number>();
|
|
332
|
-
const subtreeOf = (path: string, stack: Set<string>): number => {
|
|
333
|
-
const cached = subtree.get(path);
|
|
334
|
-
if (cached !== undefined) return cached;
|
|
335
|
-
const own = statePriority(threadsByPath.get(path)?.state);
|
|
336
|
-
if (stack.has(path)) return own;
|
|
337
|
-
stack.add(path);
|
|
338
|
-
let best = own;
|
|
339
|
-
for (const child of children.get(path) ?? [])
|
|
340
|
-
best = Math.min(best, subtreeOf(child, stack));
|
|
341
|
-
stack.delete(path);
|
|
342
|
-
subtree.set(path, best);
|
|
343
|
-
return best;
|
|
344
|
-
};
|
|
345
|
-
const ancestorOf = (path: string): number => {
|
|
346
|
-
const cached = ancestors.get(path);
|
|
347
|
-
if (cached !== undefined) return cached;
|
|
348
|
-
let best = 2;
|
|
349
|
-
const seen = new Set<string>();
|
|
350
|
-
let current: string | null = path;
|
|
351
|
-
while (current && !seen.has(current)) {
|
|
352
|
-
seen.add(current);
|
|
353
|
-
best = Math.min(best, statePriority(threadsByPath.get(current)?.state));
|
|
354
|
-
current = explicitParent(current, threadsByPath);
|
|
355
|
-
}
|
|
356
|
-
ancestors.set(path, best);
|
|
357
|
-
return best;
|
|
358
|
-
};
|
|
359
|
-
return (a, b) =>
|
|
360
|
-
subtreeOf(a, new Set()) - subtreeOf(b, new Set()) ||
|
|
361
|
-
ancestorOf(a) - ancestorOf(b) ||
|
|
362
|
-
(a < b ? -1 : a > b ? 1 : 0);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
280
|
function agentStateColor(
|
|
366
281
|
state: ThreadView["state"],
|
|
367
282
|
): "error" | "warning" | "accent" {
|
|
@@ -378,11 +293,12 @@ function agentLine(
|
|
|
378
293
|
theme: AgentBadgeTheme,
|
|
379
294
|
nerdFontIcons: boolean,
|
|
380
295
|
animate: boolean,
|
|
296
|
+
loaderStyle: LoaderStyle,
|
|
381
297
|
): string {
|
|
382
298
|
const thread = row.thread!;
|
|
383
299
|
const badge = agentTypeBadge(
|
|
384
|
-
thread.type, thread.color, theme,
|
|
385
|
-
agentProgressIcon(thread, nerdFontIcons, Date.now(), animate
|
|
300
|
+
thread.type, thread.color, theme, thread.icon, nerdFontIcons,
|
|
301
|
+
agentProgressIcon(thread, nerdFontIcons, Date.now(), animate, loaderStyle),
|
|
386
302
|
);
|
|
387
303
|
const left = `${row.prefix}${badge} ${agentPath(thread.path, thread.color, theme)} ${theme.fg(agentStateColor(thread.state), `[${sanitizeText(thread.state)}]`)} ${sanitizeText(thread.task)}`;
|
|
388
304
|
return fitLine(left, theme.fg("muted", threadMetrics(thread)), width);
|
|
@@ -421,7 +337,7 @@ function takeWidgetRows(rows: StatusRow[], budget: number): StatusRow[] {
|
|
|
421
337
|
(a, b) =>
|
|
422
338
|
statePriority(a.row.thread!.state) -
|
|
423
339
|
statePriority(b.row.thread!.state) ||
|
|
424
|
-
b.row.thread
|
|
340
|
+
lastStarted(b.row.thread) - lastStarted(a.row.thread) || a.index - b.index,
|
|
425
341
|
);
|
|
426
342
|
const chosen = new Set<number>();
|
|
427
343
|
let used = 0;
|
|
@@ -456,14 +372,10 @@ export function renderAgentTree(
|
|
|
456
372
|
threads: ThreadView[],
|
|
457
373
|
width: number,
|
|
458
374
|
theme: AgentBadgeTheme,
|
|
459
|
-
{ showBrowserHint = true, nerdFontIcons = false, animate = true }: AgentWidgetRenderOptions = {},
|
|
375
|
+
{ showBrowserHint = true, nerdFontIcons = false, animate = true, loaderStyle = "circle" }: AgentWidgetRenderOptions = {},
|
|
460
376
|
): string[] {
|
|
461
377
|
const columns = Math.max(0, width);
|
|
462
|
-
const rows = buildStatusTree(
|
|
463
|
-
threads,
|
|
464
|
-
new Set(),
|
|
465
|
-
branchPriorityComparator(threads),
|
|
466
|
-
);
|
|
378
|
+
const rows = buildStatusTree(threads, new Set());
|
|
467
379
|
const agents = rows.filter((row) => row.thread && row.path !== WIDGET_ROOT);
|
|
468
380
|
if (!agents.length) return [];
|
|
469
381
|
const live = agents.filter(
|
|
@@ -485,7 +397,7 @@ export function renderAgentTree(
|
|
|
485
397
|
lines.push(placeholderLine(row, columns, theme));
|
|
486
398
|
continue;
|
|
487
399
|
}
|
|
488
|
-
lines.push(agentLine(row, columns, theme, nerdFontIcons, animate));
|
|
400
|
+
lines.push(agentLine(row, columns, theme, nerdFontIcons, animate, loaderStyle));
|
|
489
401
|
}
|
|
490
402
|
lines.push(agentWidgetStatus(live, omitted, columns, theme, showBrowserHint));
|
|
491
403
|
return lines;
|
|
@@ -496,7 +408,7 @@ export function renderAgentSummary(
|
|
|
496
408
|
threads: ThreadView[],
|
|
497
409
|
width: number,
|
|
498
410
|
theme: Pick<Theme, "fg">,
|
|
499
|
-
{ showBrowserHint = true, nerdFontIcons = false, animate = true }: AgentWidgetRenderOptions = {},
|
|
411
|
+
{ showBrowserHint = true, nerdFontIcons = false, animate = true, loaderStyle = "circle" }: AgentWidgetRenderOptions = {},
|
|
500
412
|
): string[] {
|
|
501
413
|
const agents = new Map<string, ThreadView>();
|
|
502
414
|
for (const thread of threads) {
|
|
@@ -528,13 +440,14 @@ export function renderAgentSummary(
|
|
|
528
440
|
["paused", "warning"],
|
|
529
441
|
["completed", "success"],
|
|
530
442
|
];
|
|
531
|
-
const progress = counts.running > 0
|
|
532
|
-
? agentProgressIcon({ state: "running" }, nerdFontIcons, Date.now(), animate)
|
|
533
|
-
: undefined;
|
|
534
443
|
const left = statuses
|
|
535
444
|
.filter(([state]) => state === "running" || counts[state] > 0)
|
|
536
|
-
.map(([state, color]) =>
|
|
537
|
-
|
|
445
|
+
.map(([state, color]) => {
|
|
446
|
+
const progress = counts[state] > 0
|
|
447
|
+
? agentProgressIcon({ state }, nerdFontIcons, Date.now(), animate, loaderStyle)
|
|
448
|
+
: undefined;
|
|
449
|
+
return theme.fg(color, `${progress ? `${progress} ` : ""}${counts[state]} ${state}`);
|
|
450
|
+
})
|
|
538
451
|
.join(theme.fg("muted", ", ")) +
|
|
539
452
|
(showBrowserHint && counts.running > 0 ? theme.fg("muted", " · ← browser") : "");
|
|
540
453
|
const right = theme.fg("muted", `↑${formatCount(input)} ↓${formatCount(output)}`);
|
|
@@ -547,6 +460,7 @@ export function updateWidget(
|
|
|
547
460
|
mode: WidgetMode = "full",
|
|
548
461
|
nerdFontIcons = false,
|
|
549
462
|
rootTurnEnded = false,
|
|
463
|
+
loaderStyle: LoaderStyle = "circle",
|
|
550
464
|
): void {
|
|
551
465
|
if (!ctx.hasUI) return;
|
|
552
466
|
if (!threads.some((thread) => thread.path !== "/root")) {
|
|
@@ -560,7 +474,7 @@ export function updateWidget(
|
|
|
560
474
|
if (ctx.mode === "rpc") {
|
|
561
475
|
ctx.ui.setWidget(
|
|
562
476
|
"pi-subagent",
|
|
563
|
-
render(threads, 80, ctx.ui.theme, { showBrowserHint: false, nerdFontIcons, animate: false }),
|
|
477
|
+
render(threads, 80, ctx.ui.theme, { showBrowserHint: false, nerdFontIcons, loaderStyle, animate: false }),
|
|
564
478
|
AGENT_WIDGET_PLACEMENT,
|
|
565
479
|
);
|
|
566
480
|
return;
|
|
@@ -578,6 +492,7 @@ export function updateWidget(
|
|
|
578
492
|
render: (width) => render(snapshot, width, ctx.ui.theme, {
|
|
579
493
|
showBrowserHint: !settled,
|
|
580
494
|
nerdFontIcons,
|
|
495
|
+
loaderStyle,
|
|
581
496
|
}),
|
|
582
497
|
invalidate: () => {},
|
|
583
498
|
dispose: () => {
|
|
@@ -733,44 +648,15 @@ async function editToolList(
|
|
|
733
648
|
ctx: ExtensionCommandContext,
|
|
734
649
|
type: AgentType,
|
|
735
650
|
field: "allow" | "block",
|
|
651
|
+
options: ToolEditorOptions,
|
|
736
652
|
): Promise<void> {
|
|
737
|
-
const
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
"Enter exact tool names",
|
|
741
|
-
];
|
|
742
|
-
const current = type.tools?.[field];
|
|
743
|
-
const mode = await dialogMenu(
|
|
744
|
-
ctx,
|
|
745
|
-
`tools.${field} (${sanitizeText(toolListMenuValue(current))})`,
|
|
746
|
-
modes.map((label) => ({ id: label, label })),
|
|
747
|
-
{
|
|
748
|
-
selectedId:
|
|
749
|
-
current === undefined
|
|
750
|
-
? modes[0]
|
|
751
|
-
: current.length === 0
|
|
752
|
-
? modes[1]
|
|
753
|
-
: modes[2],
|
|
754
|
-
},
|
|
755
|
-
);
|
|
756
|
-
if (!mode) return;
|
|
757
|
-
if (mode === "Unset (use default policy)") {
|
|
653
|
+
const value = await editToolSelection(ctx, field, type.tools?.[field], options);
|
|
654
|
+
if (value === TOOL_EDITOR_CANCEL) return;
|
|
655
|
+
if (value === undefined) {
|
|
758
656
|
if (type.tools) delete type.tools[field];
|
|
759
657
|
} else {
|
|
760
|
-
const value =
|
|
761
|
-
mode === "Empty list"
|
|
762
|
-
? ""
|
|
763
|
-
: await dialogEditor(
|
|
764
|
-
ctx,
|
|
765
|
-
`tools.${field}: comma-separated exact names`,
|
|
766
|
-
type.tools?.[field]?.join(", ") ?? "",
|
|
767
|
-
);
|
|
768
|
-
if (value === undefined) return;
|
|
769
658
|
type.tools ??= {};
|
|
770
|
-
type.tools[field] = value
|
|
771
|
-
.split(",")
|
|
772
|
-
.map((name) => name.trim())
|
|
773
|
-
.filter(Boolean);
|
|
659
|
+
type.tools[field] = [...value];
|
|
774
660
|
}
|
|
775
661
|
if (type.tools && !Object.keys(type.tools).length) delete type.tools;
|
|
776
662
|
}
|
|
@@ -1042,6 +928,7 @@ const EDIT_MENU_ACTIONS = [
|
|
|
1042
928
|
"Edit frontmatter YAML",
|
|
1043
929
|
"External editor (entire Markdown)",
|
|
1044
930
|
"Save",
|
|
931
|
+
"Reset to bundled",
|
|
1045
932
|
"Cancel",
|
|
1046
933
|
] as const;
|
|
1047
934
|
|
|
@@ -1066,6 +953,7 @@ const EDIT_FIELD_LABELS: Record<EditMenuAction, string> = {
|
|
|
1066
953
|
"Edit frontmatter YAML": "Frontmatter YAML",
|
|
1067
954
|
"External editor (entire Markdown)": "External editor",
|
|
1068
955
|
Save: "Save",
|
|
956
|
+
"Reset to bundled": "Reset to bundled",
|
|
1069
957
|
Cancel: "Cancel",
|
|
1070
958
|
};
|
|
1071
959
|
|
|
@@ -1080,8 +968,8 @@ const EDIT_FIELD_HELP: Record<EditMenuAction, string> = {
|
|
|
1080
968
|
"Advisory display names to help pick a model. Not provider/model pins; never selected or required. One name per line; empty clears.",
|
|
1081
969
|
thinkingLevel: "Reasoning effort. Default follows the parent session.",
|
|
1082
970
|
"tools.allow":
|
|
1083
|
-
"
|
|
1084
|
-
"tools.block": "
|
|
971
|
+
"Pick session tools with checkboxes. Under Allowed (except blocked), an unset or empty allow list allows no tools.",
|
|
972
|
+
"tools.block": "Pick session tools to block. Blocked tools take precedence when the policy uses this list.",
|
|
1085
973
|
color: "Thread widget color with live preview.",
|
|
1086
974
|
icon: "Paste a single Nerd Font glyph from nerdfonts.com/cheat-sheet (not its name or codepoint).\nLeave blank to remove. Display requires [labs] Nerd Font icons in settings and a Nerd Font in your terminal.",
|
|
1087
975
|
systemPrompt: "Edit the Markdown prompt body in a multiline dialog.",
|
|
@@ -1093,6 +981,8 @@ const EDIT_FIELD_HELP: Record<EditMenuAction, string> = {
|
|
|
1093
981
|
"External editor (entire Markdown)":
|
|
1094
982
|
"Edit the complete definition using $VISUAL / $EDITOR.",
|
|
1095
983
|
Save: "Validate and save. Existing sessions keep their original configuration.",
|
|
984
|
+
"Reset to bundled":
|
|
985
|
+
"Delete this fork/override file and go back to the definition shipped with the extension. Unsaved edits are discarded.",
|
|
1096
986
|
Cancel: "Close without saving any edits.",
|
|
1097
987
|
};
|
|
1098
988
|
|
|
@@ -1205,15 +1095,17 @@ export async function editAgentTypes(
|
|
|
1205
1095
|
ctx: ExtensionCommandContext,
|
|
1206
1096
|
store: ConfigStore,
|
|
1207
1097
|
nerdFontIcons = false,
|
|
1098
|
+
toolEditor: ToolEditorOptions = { getAllTools: () => [], toolFiltering: "allowed" },
|
|
1208
1099
|
): Promise<void> {
|
|
1209
1100
|
if (!canOpenDialog(ctx)) return;
|
|
1210
|
-
await withDialogSession(ctx, (scoped) => editAgentTypesDialog(scoped, store, nerdFontIcons));
|
|
1101
|
+
await withDialogSession(ctx, (scoped) => editAgentTypesDialog(scoped, store, nerdFontIcons, toolEditor));
|
|
1211
1102
|
}
|
|
1212
1103
|
|
|
1213
1104
|
async function editAgentTypesDialog(
|
|
1214
1105
|
ctx: ExtensionCommandContext,
|
|
1215
1106
|
store: ConfigStore,
|
|
1216
1107
|
nerdFontIcons: boolean,
|
|
1108
|
+
toolEditor: ToolEditorOptions,
|
|
1217
1109
|
): Promise<void> {
|
|
1218
1110
|
while (true) {
|
|
1219
1111
|
const types = store.list();
|
|
@@ -1266,7 +1158,11 @@ async function editAgentTypesDialog(
|
|
|
1266
1158
|
const field = await dialogMenu(
|
|
1267
1159
|
ctx,
|
|
1268
1160
|
`Edit ${sanitizeText(draft.name)} (unsaved)`,
|
|
1269
|
-
EDIT_MENU_ACTIONS.
|
|
1161
|
+
EDIT_MENU_ACTIONS.filter(
|
|
1162
|
+
(action) =>
|
|
1163
|
+
action !== "Reset to bundled" ||
|
|
1164
|
+
(!isNew && !!original?.customization && !!original.baseSource),
|
|
1165
|
+
).map((action) => {
|
|
1270
1166
|
const decorated = editMenuLabel(action, draft);
|
|
1271
1167
|
const separator = decorated.indexOf(": ");
|
|
1272
1168
|
return {
|
|
@@ -1384,6 +1280,30 @@ async function editAgentTypesDialog(
|
|
|
1384
1280
|
);
|
|
1385
1281
|
break;
|
|
1386
1282
|
}
|
|
1283
|
+
if (field === "Reset to bundled") {
|
|
1284
|
+
if (!original?.customization || !original.baseSource) continue;
|
|
1285
|
+
const { scope, filePath } = original.customization;
|
|
1286
|
+
const confirmed = await dialogMenu(
|
|
1287
|
+
ctx,
|
|
1288
|
+
`Reset ${sanitizeText(original.name)}?`,
|
|
1289
|
+
[
|
|
1290
|
+
{
|
|
1291
|
+
id: "reset",
|
|
1292
|
+
label: "Reset",
|
|
1293
|
+
help: `Deletes ${filePath} and restores the ${original.baseSource ?? "bundled"} definition.`,
|
|
1294
|
+
},
|
|
1295
|
+
{ id: "keep", label: "Keep" },
|
|
1296
|
+
],
|
|
1297
|
+
{ selectedId: "keep" },
|
|
1298
|
+
);
|
|
1299
|
+
if (confirmed !== "reset") continue;
|
|
1300
|
+
store.removeCustomization(original.name, scope);
|
|
1301
|
+
ctx.ui.notify(
|
|
1302
|
+
`Reset ${sanitizeText(original.name)}: deleted ${sanitizeText(filePath)}; using the ${original.baseSource ?? "bundled"} definition.`,
|
|
1303
|
+
"info",
|
|
1304
|
+
);
|
|
1305
|
+
break;
|
|
1306
|
+
}
|
|
1387
1307
|
if (field === "Save scope") {
|
|
1388
1308
|
const scope = await chooseSaveScope(ctx, store, saveScope);
|
|
1389
1309
|
if (scope) saveScope = scope;
|
|
@@ -1491,6 +1411,7 @@ async function editAgentTypesDialog(
|
|
|
1491
1411
|
ctx,
|
|
1492
1412
|
candidate,
|
|
1493
1413
|
field === "tools.allow" ? "allow" : "block",
|
|
1414
|
+
toolEditor,
|
|
1494
1415
|
);
|
|
1495
1416
|
}
|
|
1496
1417
|
parseAgentType(serializeAgentType(candidate));
|