pi-subagent-manager 1.11.0 → 1.12.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 +9 -9
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -47
- package/dist/orch/checklist-integration.js +2 -30
- package/dist/orch/context-entries.js +0 -2
- package/dist/orch/cost-ledger.js +0 -5
- package/dist/orch/diagnostics.js +0 -9
- package/dist/orch/extensions.js +0 -14
- package/dist/orch/housekeeping-usage.js +0 -5
- package/dist/orch/housekeeping.js +1 -34
- package/dist/orch/inherited-tools.js +0 -14
- package/dist/orch/mailbox.js +0 -1
- package/dist/orch/manager.js +4 -44
- package/dist/orch/paths.js +0 -4
- package/dist/orch/prompt.js +1 -5
- package/dist/orch/registry.js +1 -20
- package/dist/orch/runtime.js +1 -48
- package/dist/orch/tools.js +0 -2
- package/dist/orch/transcript.js +0 -11
- package/dist/prefs/agent-import.js +2 -10
- package/dist/prefs/config.js +3 -51
- package/dist/prefs/import-discovery.js +0 -15
- package/dist/prefs/import-instructions.js +0 -2
- package/dist/prefs/models.js +0 -1
- package/dist/prefs/settings.js +3 -17
- package/dist/types.js +0 -1
- package/dist/ui/agent-loader.js +0 -10
- package/dist/ui/agent-navigation-editor.js +0 -21
- package/dist/ui/cost-footer.js +3 -9
- package/dist/ui/dialog.js +1 -29
- package/dist/ui/import-picker.js +0 -20
- package/dist/ui/live-agent-view.js +0 -19
- package/dist/ui/model-picker.js +0 -20
- package/dist/ui/settings-ui.js +0 -8
- package/dist/ui/status-ui.js +0 -17
- package/dist/ui/thread-tree.js +1 -12
- package/dist/ui/tool-picker.js +1 -4
- package/dist/ui/transcript-tool.js +0 -9
- package/dist/ui/ui.js +1 -29
- package/package.json +3 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/orch/checklist-integration.d.ts +0 -48
- package/dist/orch/checklist-integration.d.ts.map +0 -1
- package/dist/orch/checklist-integration.js.map +0 -1
- package/dist/orch/context-entries.d.ts +0 -8
- package/dist/orch/context-entries.d.ts.map +0 -1
- package/dist/orch/context-entries.js.map +0 -1
- package/dist/orch/cost-ledger.d.ts +0 -16
- package/dist/orch/cost-ledger.d.ts.map +0 -1
- package/dist/orch/cost-ledger.js.map +0 -1
- package/dist/orch/diagnostics.d.ts +0 -13
- package/dist/orch/diagnostics.d.ts.map +0 -1
- package/dist/orch/diagnostics.js.map +0 -1
- package/dist/orch/extensions.d.ts +0 -15
- package/dist/orch/extensions.d.ts.map +0 -1
- package/dist/orch/extensions.js.map +0 -1
- package/dist/orch/housekeeping-usage.d.ts +0 -14
- package/dist/orch/housekeeping-usage.d.ts.map +0 -1
- package/dist/orch/housekeeping-usage.js.map +0 -1
- package/dist/orch/housekeeping.d.ts +0 -89
- package/dist/orch/housekeeping.d.ts.map +0 -1
- package/dist/orch/housekeeping.js.map +0 -1
- package/dist/orch/inherited-tools.d.ts +0 -18
- package/dist/orch/inherited-tools.d.ts.map +0 -1
- package/dist/orch/inherited-tools.js.map +0 -1
- package/dist/orch/mailbox.d.ts +0 -59
- package/dist/orch/mailbox.d.ts.map +0 -1
- package/dist/orch/mailbox.js.map +0 -1
- package/dist/orch/manager.d.ts +0 -82
- package/dist/orch/manager.d.ts.map +0 -1
- package/dist/orch/manager.js.map +0 -1
- package/dist/orch/paths.d.ts +0 -7
- package/dist/orch/paths.d.ts.map +0 -1
- package/dist/orch/paths.js.map +0 -1
- package/dist/orch/prompt.d.ts +0 -7
- package/dist/orch/prompt.d.ts.map +0 -1
- package/dist/orch/prompt.js.map +0 -1
- package/dist/orch/registry.d.ts +0 -49
- package/dist/orch/registry.d.ts.map +0 -1
- package/dist/orch/registry.js.map +0 -1
- package/dist/orch/runtime.d.ts +0 -11
- package/dist/orch/runtime.d.ts.map +0 -1
- package/dist/orch/runtime.js.map +0 -1
- package/dist/orch/tools.d.ts +0 -6
- package/dist/orch/tools.d.ts.map +0 -1
- package/dist/orch/tools.js.map +0 -1
- package/dist/orch/transcript.d.ts +0 -28
- package/dist/orch/transcript.d.ts.map +0 -1
- package/dist/orch/transcript.js.map +0 -1
- package/dist/prefs/agent-import.d.ts +0 -37
- package/dist/prefs/agent-import.d.ts.map +0 -1
- package/dist/prefs/agent-import.js.map +0 -1
- package/dist/prefs/config.d.ts +0 -108
- package/dist/prefs/config.d.ts.map +0 -1
- package/dist/prefs/config.js.map +0 -1
- package/dist/prefs/import-discovery.d.ts +0 -28
- package/dist/prefs/import-discovery.d.ts.map +0 -1
- package/dist/prefs/import-discovery.js.map +0 -1
- package/dist/prefs/import-instructions.d.ts +0 -3
- package/dist/prefs/import-instructions.d.ts.map +0 -1
- package/dist/prefs/import-instructions.js.map +0 -1
- package/dist/prefs/models.d.ts +0 -24
- package/dist/prefs/models.d.ts.map +0 -1
- package/dist/prefs/models.js.map +0 -1
- package/dist/prefs/settings.d.ts +0 -89
- package/dist/prefs/settings.d.ts.map +0 -1
- package/dist/prefs/settings.js.map +0 -1
- package/dist/types.d.ts +0 -293
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/ui/agent-loader.d.ts +0 -21
- package/dist/ui/agent-loader.d.ts.map +0 -1
- package/dist/ui/agent-loader.js.map +0 -1
- package/dist/ui/agent-navigation-editor.d.ts +0 -46
- package/dist/ui/agent-navigation-editor.d.ts.map +0 -1
- package/dist/ui/agent-navigation-editor.js.map +0 -1
- package/dist/ui/cost-footer.d.ts +0 -37
- package/dist/ui/cost-footer.d.ts.map +0 -1
- package/dist/ui/cost-footer.js.map +0 -1
- package/dist/ui/dialog.d.ts +0 -135
- package/dist/ui/dialog.d.ts.map +0 -1
- package/dist/ui/dialog.js.map +0 -1
- package/dist/ui/import-picker.d.ts +0 -38
- package/dist/ui/import-picker.d.ts.map +0 -1
- package/dist/ui/import-picker.js.map +0 -1
- package/dist/ui/live-agent-view.d.ts +0 -82
- package/dist/ui/live-agent-view.d.ts.map +0 -1
- package/dist/ui/live-agent-view.js.map +0 -1
- package/dist/ui/model-picker.d.ts +0 -109
- package/dist/ui/model-picker.d.ts.map +0 -1
- package/dist/ui/model-picker.js.map +0 -1
- package/dist/ui/settings-ui.d.ts +0 -17
- package/dist/ui/settings-ui.d.ts.map +0 -1
- package/dist/ui/settings-ui.js.map +0 -1
- package/dist/ui/status-ui.d.ts +0 -67
- package/dist/ui/status-ui.d.ts.map +0 -1
- package/dist/ui/status-ui.js.map +0 -1
- package/dist/ui/thread-tree.d.ts +0 -22
- package/dist/ui/thread-tree.d.ts.map +0 -1
- package/dist/ui/thread-tree.js.map +0 -1
- package/dist/ui/tool-picker.d.ts +0 -46
- package/dist/ui/tool-picker.d.ts.map +0 -1
- package/dist/ui/tool-picker.js.map +0 -1
- package/dist/ui/transcript-tool.d.ts +0 -2
- package/dist/ui/transcript-tool.d.ts.map +0 -1
- package/dist/ui/transcript-tool.js.map +0 -1
- package/dist/ui/ui.d.ts +0 -41
- package/dist/ui/ui.d.ts.map +0 -1
- package/dist/ui/ui.js.map +0 -1
- package/docs/assets/subagent-manager-demo.gif +0 -0
- package/docs/async-lifecycle.md +0 -153
- package/docs/custom-agents.md +0 -154
- package/docs/default-agents.md +0 -95
- package/docs/demo.md +0 -63
- package/docs/development.md +0 -75
- package/docs/importing-agents.md +0 -41
- package/docs/pi-footer.md +0 -128
- package/docs/research-claude.md +0 -258
- package/docs/research-codex.md +0 -143
- package/docs/research-default-agent-models.md +0 -121
- package/docs/research-model-audit-2026-10.md +0 -154
- package/docs/research-model-roles-coding.md +0 -99
- package/docs/research-model-roles-writing.md +0 -78
- package/docs/research-researcher-workflow.md +0 -97
- package/docs/settings.md +0 -293
- package/docs/subagent-extension-limitations.md +0 -98
- package/docs/threads.md +0 -73
- package/docs/tools-and-ui.md +0 -129
package/dist/orch/runtime.js
CHANGED
|
@@ -13,7 +13,6 @@ import { modelIdentity, getModelPreferences, selectPreferredModel } from "../pre
|
|
|
13
13
|
import { THINKING_LEVELS, } from "../types.js";
|
|
14
14
|
import { DIAGNOSTIC_CHANNEL, DIAGNOSTIC_PROBE_CHANNEL, respondDiagnosticCapability, diagnosticSink, diagnosticText, } from "./diagnostics.js";
|
|
15
15
|
const BUILTINS = ["read", "bash", "powershell", "edit", "write", "grep", "find", "ls"];
|
|
16
|
-
/** Persisted before transcript messages so older-leaf restores still carry ownership. */
|
|
17
16
|
const THREAD_OWNERSHIP_TYPE = "pi-subagent:thread:v1";
|
|
18
17
|
const SESSION_FILE_ERROR = "Subagent sessionFile must be a JSONL file inside this root's session directory";
|
|
19
18
|
function parseModelIdentity(identity) {
|
|
@@ -70,7 +69,6 @@ function ownershipFromTranscript(content) {
|
|
|
70
69
|
}
|
|
71
70
|
return undefined;
|
|
72
71
|
}
|
|
73
|
-
/** Orchestrator file for /root and independent roots; nested parents supply their own file. */
|
|
74
72
|
function resolveParentSession(options, rootSessionFile) {
|
|
75
73
|
if (options.parentSessionFile)
|
|
76
74
|
return options.parentSessionFile;
|
|
@@ -86,7 +84,6 @@ async function assertAcceptedSessionFile(sessionFile, sessionDir, legacyDir, roo
|
|
|
86
84
|
signal.throwIfAborted();
|
|
87
85
|
const legacyDirReal = await tryRealpath(legacyDir);
|
|
88
86
|
signal.throwIfAborted();
|
|
89
|
-
// Legacy root-scoped transcripts stay valid, including files nested under that directory.
|
|
90
87
|
if (file && legacyDirReal && isJsonlWithin(legacyDirReal, file))
|
|
91
88
|
return;
|
|
92
89
|
if (!file || path.dirname(file) !== sharedDir || !file.endsWith(".jsonl")) {
|
|
@@ -108,7 +105,6 @@ const SNIPPET_KEYS = [
|
|
|
108
105
|
"url",
|
|
109
106
|
"description",
|
|
110
107
|
];
|
|
111
|
-
/** Short single-line argument hint for housekeeping summaries; never shown verbatim as status. */
|
|
112
108
|
export function toolArgumentSnippet(args) {
|
|
113
109
|
if (args === null || args === undefined)
|
|
114
110
|
return undefined;
|
|
@@ -135,9 +131,7 @@ export function toolArgumentSnippet(args) {
|
|
|
135
131
|
.trim();
|
|
136
132
|
return clean ? clean.slice(0, 160) : undefined;
|
|
137
133
|
}
|
|
138
|
-
/** Isolated SDK sessions; configured extension reload is experimental and opt-in. */
|
|
139
134
|
export function createDriverFactory(getRootContext, getModelSelection = () => "pick-first-scoped", getToolFiltering = () => "allowed", getInheritedTools = () => ({ tools: [], activeNames: [] }), getSubagentExtensions = () => false) {
|
|
140
|
-
// Keep resolved settings even after disposal: descendants inherit settings, not the caller's history.
|
|
141
135
|
const resolved = new Map();
|
|
142
136
|
const normalizeScopedModels = (scopedModels) => scopedModels ?? [];
|
|
143
137
|
const availableModelCandidates = () => getRootContext()
|
|
@@ -147,12 +141,10 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
147
141
|
const available = new Set(availableModelCandidates().map(({ model }) => modelIdentity(model)));
|
|
148
142
|
return scopedModels.filter(({ model }) => available.has(modelIdentity(model)));
|
|
149
143
|
};
|
|
150
|
-
// Pi represents an unrestricted scope with an empty array.
|
|
151
144
|
const selectTypeModelPreference = (type, scopedModels, filtering) => {
|
|
152
145
|
const restricted = filtering && scopedModels.length > 0;
|
|
153
146
|
return selectPreferredModel(type, restricted ? availableScopedModels(scopedModels) : availableModelCandidates(), restricted);
|
|
154
147
|
};
|
|
155
|
-
// Discovery and new/restored drivers share model selection and thinking inheritance.
|
|
156
148
|
const resolveInitialSettings = (type, parentPath, restored) => {
|
|
157
149
|
const ctx = getRootContext();
|
|
158
150
|
const parent = parentPath
|
|
@@ -193,7 +185,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
193
185
|
const createDriver = async (options) => {
|
|
194
186
|
options.signal.throwIfAborted();
|
|
195
187
|
const ctx = getRootContext();
|
|
196
|
-
// Tool policy is a startup snapshot; retained live sessions keep their selected set.
|
|
197
188
|
const toolFiltering = getToolFiltering();
|
|
198
189
|
const extensionSelection = getSubagentExtensions();
|
|
199
190
|
const rootId = ctx.sessionManager.getSessionId();
|
|
@@ -208,7 +199,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
208
199
|
let sessionManager;
|
|
209
200
|
if (options.sessionFile) {
|
|
210
201
|
await assertAcceptedSessionFile(options.sessionFile, sessionDir, legacyDir, rootId, options.path, options.signal);
|
|
211
|
-
// Open the caller path, not its realpath, so retained sessionFile identity is stable.
|
|
212
202
|
sessionManager = SessionManager.open(path.resolve(options.sessionFile), sessionDir, ctx.cwd);
|
|
213
203
|
if (options.sessionLeafId !== undefined) {
|
|
214
204
|
if (options.sessionLeafId === null)
|
|
@@ -220,7 +210,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
220
210
|
else {
|
|
221
211
|
const parentSession = resolveParentSession(options, ctx.sessionManager.getSessionFile());
|
|
222
212
|
sessionManager = SessionManager.create(ctx.cwd, sessionDir, parentSession ? { parentSession } : undefined);
|
|
223
|
-
// Before transcript messages so an older restored leaf still has name and ownership as ancestors.
|
|
224
213
|
sessionManager.appendSessionInfo(`${options.type.name} ${options.path}`);
|
|
225
214
|
sessionManager.appendCustomEntry(THREAD_OWNERSHIP_TYPE, {
|
|
226
215
|
rootId,
|
|
@@ -228,7 +217,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
228
217
|
inheritedCount: options.inherited.length,
|
|
229
218
|
});
|
|
230
219
|
for (const message of options.inherited) {
|
|
231
|
-
// Summary messages are projections, not appendable SDK session entries.
|
|
232
220
|
if (message.role === "compactionSummary" || message.role === "branchSummary") {
|
|
233
221
|
sessionManager.appendMessage({
|
|
234
222
|
role: "user",
|
|
@@ -252,7 +240,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
252
240
|
}
|
|
253
241
|
const restored = options.sessionFile ? sessionManager.buildSessionContext() : undefined;
|
|
254
242
|
const modelSelection = getModelSelection();
|
|
255
|
-
// Use Current ignores definition preferences, including for restored/nested sessions.
|
|
256
243
|
const modelPreferences = modelSelection === "use-current" ? undefined : getModelPreferences(options.type);
|
|
257
244
|
const filteringEnabled = () => getModelSelection() === "pick-first-scoped";
|
|
258
245
|
const selectModelPreference = (scopedModels, filtering = filteringEnabled()) => selectTypeModelPreference(options.type, scopedModels, filtering);
|
|
@@ -306,7 +293,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
306
293
|
const toolNames = selectTools(options.type.tools, [...localNames, ...externalTools.map((tool) => tool.name)], toolFiltering);
|
|
307
294
|
const allowed = new Set(toolNames);
|
|
308
295
|
const rootActive = new Set(inherited.activeNames);
|
|
309
|
-
// Preserve deferred/codemode exposure rather than flooding model declarations with MCP tools.
|
|
310
296
|
const activeToolNames = toolNames.filter((name) => localNames.has(name) ||
|
|
311
297
|
rootActive.has(name) ||
|
|
312
298
|
(options.type.tools?.allow?.includes(name) && toolFiltering === "allowed"));
|
|
@@ -316,9 +302,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
316
302
|
? []
|
|
317
303
|
: selectSubagentExtensions(await discoverSubagentExtensions({ cwd: ctx.cwd, agentDir, projectTrusted }), extensionSelection);
|
|
318
304
|
const subagentExtensions = extensionPaths.length > 0;
|
|
319
|
-
// Keep discovery settings OUT of this loader: reload() resolves packages with
|
|
320
|
-
// auto-install enabled. An empty in-memory package/resource list ensures it
|
|
321
|
-
// only loads the already-resolved files and cannot install missing packages.
|
|
322
305
|
const settingsManager = SettingsManager.inMemory({ cacheWarming: "off" }, { projectTrusted });
|
|
323
306
|
let parkQueue = () => { };
|
|
324
307
|
const pauseBoundary = () => {
|
|
@@ -327,11 +310,9 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
327
310
|
parkQueue();
|
|
328
311
|
return { continue: false };
|
|
329
312
|
};
|
|
330
|
-
// A separate bus per driver: never share parent/other-child extension events.
|
|
331
313
|
const childEvents = createEventBus();
|
|
332
314
|
let diagnosticsClosed = false;
|
|
333
315
|
let diagnosticsInitialized = false;
|
|
334
|
-
// The startup signal belongs to one run; a stopped driver may be reused.
|
|
335
316
|
const diagnosticsUnavailable = () => diagnosticsClosed || (!diagnosticsInitialized && options.signal.aborted);
|
|
336
317
|
if (subagentExtensions)
|
|
337
318
|
childEvents.on(DIAGNOSTIC_PROBE_CHANNEL, (payload) => {
|
|
@@ -341,7 +322,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
341
322
|
respondDiagnosticCapability(payload);
|
|
342
323
|
}
|
|
343
324
|
catch {
|
|
344
|
-
/* Untrusted callbacks cannot escape into EventBus's stderr handler. */
|
|
345
325
|
}
|
|
346
326
|
});
|
|
347
327
|
if (subagentExtensions)
|
|
@@ -353,7 +333,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
353
333
|
getRootContext().ui.notify(diagnosticText(options.path, diagnostic), diagnostic.level);
|
|
354
334
|
}
|
|
355
335
|
catch {
|
|
356
|
-
// Agent-facing delivery remains available if the UI is absent/unavailable.
|
|
357
336
|
}
|
|
358
337
|
}));
|
|
359
338
|
const loader = new DefaultResourceLoader({
|
|
@@ -363,9 +342,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
363
342
|
settingsManager,
|
|
364
343
|
noExtensions: true,
|
|
365
344
|
additionalExtensionPaths: extensionPaths,
|
|
366
|
-
// Put bridges AFTER file extensions in the runner registry. First registration
|
|
367
|
-
// wins there, including tools registered by file extensions on session_start
|
|
368
|
-
// or later. SDK customTools would always override those child-local tools.
|
|
369
345
|
extensionsOverride: subagentExtensions
|
|
370
346
|
? (base) => {
|
|
371
347
|
const sourceInfo = createSyntheticSourceInfo("<subagent-inherited-tools>", {
|
|
@@ -412,8 +388,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
412
388
|
].join("\n\n"),
|
|
413
389
|
appendSystemPromptOverride: () => [],
|
|
414
390
|
extensionFactories: [
|
|
415
|
-
// These orchestrators must see the CHILD loadout. Forwarding root codemode would
|
|
416
|
-
// let scripts discover/call tools outside the child's allow/block policy.
|
|
417
391
|
...(allowed.has("codemode")
|
|
418
392
|
? [
|
|
419
393
|
subagentExtensions
|
|
@@ -451,8 +425,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
451
425
|
throw error;
|
|
452
426
|
}
|
|
453
427
|
const loadedExtensions = loader.getExtensions();
|
|
454
|
-
// Manager controls remain SDK custom tools so loaded extensions cannot replace
|
|
455
|
-
// them. With reload disabled, preserve the existing SDK bridge behavior exactly.
|
|
456
428
|
const customTools = [...options.tools, ...(subagentExtensions ? [] : externalTools)].filter((tool) => allowed.has(tool.name) && tool.name !== "codemode" && tool.name !== "tool_search");
|
|
457
429
|
let session;
|
|
458
430
|
try {
|
|
@@ -466,17 +438,12 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
466
438
|
settingsManager,
|
|
467
439
|
resourceLoader: loader,
|
|
468
440
|
sessionManager,
|
|
469
|
-
// SDK `tools` is both a registry allowlist and an initial active list.
|
|
470
|
-
// Register every permitted deferred tool, then narrow declarations after bind.
|
|
471
441
|
tools: toolNames,
|
|
472
442
|
customTools,
|
|
473
443
|
}));
|
|
474
444
|
}
|
|
475
445
|
catch (error) {
|
|
476
446
|
if (subagentExtensions) {
|
|
477
|
-
// No session was returned, so normal disposal is unavailable. Give loaded
|
|
478
|
-
// factories a shutdown-only runner with child-local metadata/persistence;
|
|
479
|
-
// unavailable session actions remain throwing stubs, not root bridges.
|
|
480
447
|
await (async () => {
|
|
481
448
|
const runner = new ExtensionRunner(loadedExtensions.extensions, loadedExtensions.runtime, ctx.cwd, sessionManager, new ModelRegistry(runtime));
|
|
482
449
|
try {
|
|
@@ -505,7 +472,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
505
472
|
runner.invalidate();
|
|
506
473
|
}
|
|
507
474
|
})().catch(() => {
|
|
508
|
-
// Best-effort cleanup must not hide the SDK's original startup failure.
|
|
509
475
|
});
|
|
510
476
|
}
|
|
511
477
|
diagnosticsClosed = true;
|
|
@@ -526,8 +492,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
526
492
|
session.dispose();
|
|
527
493
|
return;
|
|
528
494
|
}
|
|
529
|
-
// SDK dispose invalidates contexts but does not emit session_shutdown. Await
|
|
530
|
-
// handlers before invalidation so session-scoped resources can be released.
|
|
531
495
|
return (shutdownPromise ??= (async () => {
|
|
532
496
|
try {
|
|
533
497
|
await session.extensionRunner.emit({ type: "session_shutdown", reason: "quit" });
|
|
@@ -596,9 +560,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
596
560
|
updateResolved();
|
|
597
561
|
};
|
|
598
562
|
try {
|
|
599
|
-
// Factories have already run: abort/load failures must use the same awaited
|
|
600
|
-
// shutdown lifecycle as failures during extension binding, without emitting
|
|
601
|
-
// session_start or starting a model turn.
|
|
602
563
|
options.signal.throwIfAborted();
|
|
603
564
|
if (subagentExtensions && loadedExtensions.errors.length) {
|
|
604
565
|
throw new Error(`Subagent extension loading failed: ${loadedExtensions.errors
|
|
@@ -669,8 +630,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
669
630
|
session.clearQueue();
|
|
670
631
|
mailbox.clearQueuedInputs();
|
|
671
632
|
};
|
|
672
|
-
// In 0.99.2 a boundary's continue:false only declines EXTRA continuation;
|
|
673
|
-
// the public core hook is needed to stop automatic tool/steering continuation.
|
|
674
633
|
parkQueue = clearPromptQueues;
|
|
675
634
|
const finishTurn = session.agent.finishTurn;
|
|
676
635
|
session.agent.finishTurn = async (turn, signal) => {
|
|
@@ -685,10 +644,8 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
685
644
|
let disposed = false;
|
|
686
645
|
let running = false;
|
|
687
646
|
let aborted = false;
|
|
688
|
-
// Compaction can replace session.messages during a prompt, invalidating any saved index.
|
|
689
647
|
const promptResult = {};
|
|
690
648
|
const getLastAssistant = () => promptResult.lastAssistant;
|
|
691
|
-
// Subscribe after inherited/restored history is loaded; only new assistant events are counted.
|
|
692
649
|
let settledInput = 0;
|
|
693
650
|
let settledOutput = 0;
|
|
694
651
|
let settledCost;
|
|
@@ -722,9 +679,7 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
722
679
|
inheritedMetadata >= 0
|
|
723
680
|
? inheritedMetadata
|
|
724
681
|
: options.inherited.length;
|
|
725
|
-
const transcript = new TranscriptChannel(() => session.messages,
|
|
726
|
-
// A restored compaction has replaced the original inherited prefix.
|
|
727
|
-
session.messages.some((message) => message.role === "compactionSummary") ? 0 : inheritedCount);
|
|
682
|
+
const transcript = new TranscriptChannel(() => session.messages, session.messages.some((message) => message.role === "compactionSummary") ? 0 : inheritedCount);
|
|
728
683
|
const unsubscribe = session.subscribe((event) => {
|
|
729
684
|
transcript.accept(event);
|
|
730
685
|
if (running && event.type === "message_end" && event.message.role === "assistant")
|
|
@@ -860,7 +815,6 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
860
815
|
ensurePersistedSession();
|
|
861
816
|
const accepted = mailbox.accept("update", content);
|
|
862
817
|
emitCheckpoint();
|
|
863
|
-
// SDK session method is sendCustomMessage (ExtensionAPI calls it sendMessage).
|
|
864
818
|
await session.sendCustomMessage({
|
|
865
819
|
customType: "subagent-update",
|
|
866
820
|
content,
|
|
@@ -879,4 +833,3 @@ export function createDriverFactory(getRootContext, getModelSelection = () => "p
|
|
|
879
833
|
};
|
|
880
834
|
return Object.assign(createDriver, { resolveAgentSettings });
|
|
881
835
|
}
|
|
882
|
-
//# sourceMappingURL=runtime.js.map
|
package/dist/orch/tools.js
CHANGED
|
@@ -13,7 +13,6 @@ function result(value) {
|
|
|
13
13
|
details: value,
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
/** All threads see the same verbs, with caller identity bound by closure, never model input. */
|
|
17
16
|
export function agentTools(getManager, caller, getTypes, resolveSettings) {
|
|
18
17
|
const threads = () => getManager().scope(caller);
|
|
19
18
|
const make = (name, description, parameters, execute) => ({
|
|
@@ -111,4 +110,3 @@ export function agentTools(getManager, caller, getTypes, resolveSettings) {
|
|
|
111
110
|
}),
|
|
112
111
|
];
|
|
113
112
|
}
|
|
114
|
-
//# sourceMappingURL=tools.js.map
|
package/dist/orch/transcript.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** Clone once at the ownership boundary, then share immutable state across observers. */
|
|
2
1
|
export function immutableTranscriptValue(value) {
|
|
3
2
|
const copy = structuredClone(value);
|
|
4
3
|
const seen = new WeakSet();
|
|
@@ -8,14 +7,12 @@ export function immutableTranscriptValue(value) {
|
|
|
8
7
|
seen.add(item);
|
|
9
8
|
for (const child of Object.values(item))
|
|
10
9
|
freeze(child);
|
|
11
|
-
// Freezing populated typed-array views throws. Their storage was already cloned.
|
|
12
10
|
if (!ArrayBuffer.isView(item))
|
|
13
11
|
Object.freeze(item);
|
|
14
12
|
};
|
|
15
13
|
freeze(copy);
|
|
16
14
|
return copy;
|
|
17
15
|
}
|
|
18
|
-
/** SDK event projection. Committed history is copied at boundaries, never for each token. */
|
|
19
16
|
export class TranscriptChannel {
|
|
20
17
|
readMessages;
|
|
21
18
|
inheritedCount;
|
|
@@ -36,7 +33,6 @@ export class TranscriptChannel {
|
|
|
36
33
|
observe(listener) {
|
|
37
34
|
if (this.disposed)
|
|
38
35
|
throw new Error("Transcript channel is disposed");
|
|
39
|
-
// No await between registration and snapshot: a finalization cannot fall in a gap.
|
|
40
36
|
const registered = (snapshot) => listener(snapshot);
|
|
41
37
|
this.listeners.add(registered);
|
|
42
38
|
return { snapshot: this.current, unsubscribe: () => this.listeners.delete(registered) };
|
|
@@ -48,7 +44,6 @@ export class TranscriptChannel {
|
|
|
48
44
|
this.reduce(event);
|
|
49
45
|
}
|
|
50
46
|
catch (error) {
|
|
51
|
-
// Custom tool details can be non-cloneable. Observation must still never fail the run.
|
|
52
47
|
this.error = error instanceof Error ? error.message : String(error);
|
|
53
48
|
this.publish();
|
|
54
49
|
}
|
|
@@ -100,7 +95,6 @@ export class TranscriptChannel {
|
|
|
100
95
|
isError: event.isError,
|
|
101
96
|
state: "completed",
|
|
102
97
|
}));
|
|
103
|
-
// Nested calls have no transcript message. Bound their transient completed retention.
|
|
104
98
|
for (const [id, tool] of this.tools) {
|
|
105
99
|
if (this.tools.size <= 128)
|
|
106
100
|
break;
|
|
@@ -109,7 +103,6 @@ export class TranscriptChannel {
|
|
|
109
103
|
}
|
|
110
104
|
break;
|
|
111
105
|
case "compaction_end":
|
|
112
|
-
// Compaction may replace/reorder history; do not approximate it with append-only deltas.
|
|
113
106
|
if (event.result && !event.aborted)
|
|
114
107
|
this.inheritedCount = 0;
|
|
115
108
|
this.messages = immutableTranscriptValue(this.readMessages());
|
|
@@ -129,7 +122,6 @@ export class TranscriptChannel {
|
|
|
129
122
|
}
|
|
130
123
|
this.publish();
|
|
131
124
|
}
|
|
132
|
-
/** Non-turn custom delivery is not guaranteed to use core message events. */
|
|
133
125
|
reconcile() {
|
|
134
126
|
if (this.disposed)
|
|
135
127
|
return;
|
|
@@ -163,14 +155,11 @@ export class TranscriptChannel {
|
|
|
163
155
|
this.revision++;
|
|
164
156
|
this.current = this.snapshot();
|
|
165
157
|
for (const listener of this.listeners) {
|
|
166
|
-
// Watching is read-only: a broken renderer must not fail the agent's execution.
|
|
167
158
|
try {
|
|
168
159
|
listener(this.current);
|
|
169
160
|
}
|
|
170
161
|
catch {
|
|
171
|
-
/* observer owns its error reporting */
|
|
172
162
|
}
|
|
173
163
|
}
|
|
174
164
|
}
|
|
175
165
|
}
|
|
176
|
-
//# sourceMappingURL=transcript.js.map
|
|
@@ -7,7 +7,7 @@ import { selectImportAgents } from "../ui/import-picker.js";
|
|
|
7
7
|
import { MIGRATION_INSTRUCTIONS } from "./import-instructions.js";
|
|
8
8
|
import { dialogText } from "../ui/dialog.js";
|
|
9
9
|
export const IMPORT_REQUEST_PREFIX = "Import ONLY the agents I selected in the pi-subagent-manager migration picker.";
|
|
10
|
-
|
|
10
|
+
const IMPORT_CHILD_TOOLS = [
|
|
11
11
|
"read",
|
|
12
12
|
"bash",
|
|
13
13
|
"powershell",
|
|
@@ -26,7 +26,6 @@ export const IMPORT_CHILD_TOOLS = [
|
|
|
26
26
|
"agent_stop",
|
|
27
27
|
"agent_output",
|
|
28
28
|
];
|
|
29
|
-
// This records onboarding only. Limits remain in subagent-manager/settings.json.
|
|
30
29
|
const OFFER_MARKER = ".import-offered";
|
|
31
30
|
function statIfPresent(path) {
|
|
32
31
|
try {
|
|
@@ -46,7 +45,6 @@ function stateDirectory(agentDir, create) {
|
|
|
46
45
|
for (const path of [agentDir, directory]) {
|
|
47
46
|
let stat = statIfPresent(path);
|
|
48
47
|
if (!stat && create) {
|
|
49
|
-
// The host owns agentDir. Do not recursively create or follow unchecked parents.
|
|
50
48
|
mkdirSync(path);
|
|
51
49
|
stat = statIfPresent(path);
|
|
52
50
|
}
|
|
@@ -83,7 +81,7 @@ export function markImportOffered(agentDir) {
|
|
|
83
81
|
closeSync(fd);
|
|
84
82
|
}
|
|
85
83
|
}
|
|
86
|
-
|
|
84
|
+
function buildImportPrompt(options) {
|
|
87
85
|
return [
|
|
88
86
|
IMPORT_REQUEST_PREFIX,
|
|
89
87
|
MIGRATION_INSTRUCTIONS,
|
|
@@ -109,7 +107,6 @@ export function buildImportPrompt(options) {
|
|
|
109
107
|
}, null, 2),
|
|
110
108
|
].join("\n\n");
|
|
111
109
|
}
|
|
112
|
-
/** Discovery and consent only; the current conversation performs every semantic conversion/write. */
|
|
113
110
|
export async function offerAgentImport(pi, ctx, options) {
|
|
114
111
|
const firstRun = options.firstRun ?? false;
|
|
115
112
|
if (!ctx.hasUI || ctx.mode !== "tui") {
|
|
@@ -138,7 +135,6 @@ export async function offerAgentImport(pi, ctx, options) {
|
|
|
138
135
|
}
|
|
139
136
|
};
|
|
140
137
|
if (!found.candidates.length) {
|
|
141
|
-
// Retry an incomplete scan next startup, rather than permanently hiding unreadable definitions.
|
|
142
138
|
if (!found.diagnostics.length)
|
|
143
139
|
remember();
|
|
144
140
|
if (!firstRun)
|
|
@@ -181,10 +177,7 @@ export async function offerAgentImport(pi, ctx, options) {
|
|
|
181
177
|
parentModel: ctx.model ? `${ctx.model.provider}/${ctx.model.id}` : undefined,
|
|
182
178
|
parentModelApi: ctx.model?.api,
|
|
183
179
|
});
|
|
184
|
-
// This starts (or queues) a turn in the active root session, not another SDK session.
|
|
185
180
|
pi.sendUserMessage(prompt, { deliverAs: "followUp" });
|
|
186
|
-
// sendUserMessage is fire-and-forget. The root before_agent_start hook acknowledges
|
|
187
|
-
// accepted requests; authentication/model failures must leave first-run retryable.
|
|
188
181
|
ctx.ui.notify(`Asked the current session model to import ${candidates.length} selected agent(s).`, "info");
|
|
189
182
|
return true;
|
|
190
183
|
}
|
|
@@ -193,4 +186,3 @@ export async function offerAgentImport(pi, ctx, options) {
|
|
|
193
186
|
return false;
|
|
194
187
|
}
|
|
195
188
|
}
|
|
196
|
-
//# sourceMappingURL=agent-import.js.map
|
package/dist/prefs/config.js
CHANGED
|
@@ -5,7 +5,6 @@ import { randomUUID } from "node:crypto";
|
|
|
5
5
|
import { isMap, isScalar, parseDocument, stringify } from "yaml";
|
|
6
6
|
import { getModelPreferences } from "./models.js";
|
|
7
7
|
import { THINKING_LEVELS } from "../types.js";
|
|
8
|
-
// Pi semantic color tokens, resolved as concrete colors for agent name backgrounds.
|
|
9
8
|
export const AGENT_COLORS = [
|
|
10
9
|
"accent",
|
|
11
10
|
"border",
|
|
@@ -114,7 +113,6 @@ function record(value, label) {
|
|
|
114
113
|
throw new Error(`${label} must be a mapping`);
|
|
115
114
|
return value;
|
|
116
115
|
}
|
|
117
|
-
/** Advisory display names only. Empty means no suggestions; never a model pin. */
|
|
118
116
|
function modelSuggestionNames(value) {
|
|
119
117
|
if (!Array.isArray(value))
|
|
120
118
|
throw new Error("modelSuggestions must be an array of nonempty display names");
|
|
@@ -231,14 +229,14 @@ export function serializeAgentType(type) {
|
|
|
231
229
|
parseAgentType(content);
|
|
232
230
|
return content;
|
|
233
231
|
}
|
|
234
|
-
|
|
232
|
+
const AGENT_OVERRIDE_EXTENSIONS = [".yml", ".yaml"];
|
|
235
233
|
function overrideBaseName(file) {
|
|
236
234
|
for (const extension of AGENT_OVERRIDE_EXTENSIONS)
|
|
237
235
|
if (file.endsWith(extension))
|
|
238
236
|
return file.slice(0, -extension.length);
|
|
239
237
|
return undefined;
|
|
240
238
|
}
|
|
241
|
-
|
|
239
|
+
function isAgentOverrideFile(file) {
|
|
242
240
|
return overrideBaseName(file) !== undefined;
|
|
243
241
|
}
|
|
244
242
|
function nullableField(value, validate) {
|
|
@@ -246,11 +244,6 @@ function nullableField(value, validate) {
|
|
|
246
244
|
return null;
|
|
247
245
|
return validate(value);
|
|
248
246
|
}
|
|
249
|
-
/**
|
|
250
|
-
* Parse a settings-only `<name>.yml` override. Rejects prompt bodies and
|
|
251
|
-
* unknown fields; validates shared fields with the same rules as full
|
|
252
|
-
* definitions. `expectedName` (the file basename) must match `name` when set.
|
|
253
|
-
*/
|
|
254
247
|
export function parseAgentSettings(content, filePath, expectedName) {
|
|
255
248
|
const label = filePath ?? "Agent settings override";
|
|
256
249
|
try {
|
|
@@ -343,11 +336,6 @@ export function serializeAgentSettings(override) {
|
|
|
343
336
|
parseAgentSettings(content);
|
|
344
337
|
return content;
|
|
345
338
|
}
|
|
346
|
-
/**
|
|
347
|
-
* Merge a sparse settings override on top of a base definition. Unset fields
|
|
348
|
-
* follow the base; explicit null clears the field. The prompt body always
|
|
349
|
-
* comes from the base.
|
|
350
|
-
*/
|
|
351
339
|
export function mergeAgentSettings(base, override) {
|
|
352
340
|
const merged = structuredClone(base);
|
|
353
341
|
if (override.description !== undefined)
|
|
@@ -390,11 +378,6 @@ export function mergeAgentSettings(base, override) {
|
|
|
390
378
|
merged.systemPrompt = base.systemPrompt;
|
|
391
379
|
return merged;
|
|
392
380
|
}
|
|
393
|
-
/**
|
|
394
|
-
* Diff a draft against its base: only changed settings land in the override
|
|
395
|
-
* file, so untouched fields keep tracking bundled updates. The filename
|
|
396
|
-
* identifies the agent; an unchanged draft produces an empty mapping.
|
|
397
|
-
*/
|
|
398
381
|
export function diffAgentSettings(base, draft) {
|
|
399
382
|
const override = {};
|
|
400
383
|
if (draft.description !== base.description)
|
|
@@ -433,7 +416,6 @@ export function diffAgentSettings(base, draft) {
|
|
|
433
416
|
function sameSetting(before, after) {
|
|
434
417
|
return JSON.stringify(before ?? null) === JSON.stringify(after ?? null);
|
|
435
418
|
}
|
|
436
|
-
/** Retain existing explicit pins; update only settings actually edited in this draft. */
|
|
437
419
|
function updateAgentSettings(base, before, draft, existing) {
|
|
438
420
|
const result = structuredClone(existing);
|
|
439
421
|
const edits = diffAgentSettings(before, draft);
|
|
@@ -456,7 +438,6 @@ function updateAgentSettings(base, before, draft, existing) {
|
|
|
456
438
|
delete result.model;
|
|
457
439
|
}
|
|
458
440
|
if (edits.tools) {
|
|
459
|
-
// Whole-policy clears must keep clearing the untouched sibling, too.
|
|
460
441
|
if (result.tools === null)
|
|
461
442
|
result.tools = { allow: null, block: null };
|
|
462
443
|
const tools = result.tools ?? {};
|
|
@@ -480,7 +461,6 @@ export function selectTools(policy, available, mode = "allowed") {
|
|
|
480
461
|
const names = new Set(available);
|
|
481
462
|
if (mode === "all")
|
|
482
463
|
return [...names];
|
|
483
|
-
// Ignored lists do not participate in validation or tool selection.
|
|
484
464
|
const relevantPolicy = mode === "all-except-blocked"
|
|
485
465
|
? policy?.block === undefined
|
|
486
466
|
? {}
|
|
@@ -539,7 +519,6 @@ export class ConfigStore {
|
|
|
539
519
|
}
|
|
540
520
|
catch (error) {
|
|
541
521
|
this.diagnostics.push(`${directory}: ${String(error)}`);
|
|
542
|
-
// An unreadable override layer cannot safely expose lower-precedence policies.
|
|
543
522
|
this.types.clear();
|
|
544
523
|
this.bases.clear();
|
|
545
524
|
continue;
|
|
@@ -551,7 +530,6 @@ export class ConfigStore {
|
|
|
551
530
|
this.applyScopeLayer(directory, source, files);
|
|
552
531
|
}
|
|
553
532
|
}
|
|
554
|
-
/** Bundled layer: full `<name>.md` definitions only; overrides are rejected. */
|
|
555
533
|
loadBundledLayer(directory, files) {
|
|
556
534
|
const blocked = new Set();
|
|
557
535
|
const seenNames = new Set();
|
|
@@ -578,7 +556,6 @@ export class ConfigStore {
|
|
|
578
556
|
}
|
|
579
557
|
catch (error) {
|
|
580
558
|
blocked.add(file.slice(0, -3));
|
|
581
|
-
// Extract declared names even if another field or duplicate key is malformed.
|
|
582
559
|
try {
|
|
583
560
|
const doc = parseDocument(frontmatter(content).yaml);
|
|
584
561
|
if (isMap(doc.contents))
|
|
@@ -591,7 +568,6 @@ export class ConfigStore {
|
|
|
591
568
|
}
|
|
592
569
|
}
|
|
593
570
|
catch {
|
|
594
|
-
/* Filename still provides a fail-closed tombstone. */
|
|
595
571
|
}
|
|
596
572
|
this.diagnostics.push(`${filePath}: ${String(error)}`);
|
|
597
573
|
}
|
|
@@ -601,12 +577,6 @@ export class ConfigStore {
|
|
|
601
577
|
this.bases.delete(name);
|
|
602
578
|
}
|
|
603
579
|
}
|
|
604
|
-
/**
|
|
605
|
-
* User/project layer: `<name>.md` is a full fork (replaces the base),
|
|
606
|
-
* `<name>.yml` is a settings-only override merged on top of the base.
|
|
607
|
-
* Having both for one name, duplicate declarations, malformed files, or an
|
|
608
|
-
* override without a base fails closed for that agent name.
|
|
609
|
-
*/
|
|
610
580
|
applyScopeLayer(directory, scope, files) {
|
|
611
581
|
const blocked = new Set();
|
|
612
582
|
const forks = new Map();
|
|
@@ -657,7 +627,6 @@ export class ConfigStore {
|
|
|
657
627
|
}
|
|
658
628
|
}
|
|
659
629
|
catch {
|
|
660
|
-
/* Filename still provides a fail-closed tombstone. */
|
|
661
630
|
}
|
|
662
631
|
this.diagnostics.push(`${filePath}: ${String(error)}`);
|
|
663
632
|
}
|
|
@@ -696,7 +665,6 @@ export class ConfigStore {
|
|
|
696
665
|
}
|
|
697
666
|
}
|
|
698
667
|
catch {
|
|
699
|
-
/* Filename still provides a fail-closed tombstone. */
|
|
700
668
|
}
|
|
701
669
|
this.diagnostics.push(`${filePath}: ${String(error)}`);
|
|
702
670
|
}
|
|
@@ -778,7 +746,6 @@ export class ConfigStore {
|
|
|
778
746
|
? resolve(this.options.agentDir, SUBAGENT_MANAGER_DIR, AGENTS_DIR)
|
|
779
747
|
: resolve(this.options.cwd, ".pi", "agent", SUBAGENT_MANAGER_DIR, AGENTS_DIR);
|
|
780
748
|
}
|
|
781
|
-
// Manager-owned storage only. Do not scan legacy Pi agent packages.
|
|
782
749
|
scopeDirectories(scope) {
|
|
783
750
|
return [this.preferredScopeDirectory(scope)];
|
|
784
751
|
}
|
|
@@ -792,14 +759,12 @@ export class ConfigStore {
|
|
|
792
759
|
const projectAgent = join(projectPi, "agent");
|
|
793
760
|
return [base, projectPi, projectAgent, join(projectAgent, SUBAGENT_MANAGER_DIR), directory];
|
|
794
761
|
}
|
|
795
|
-
/** Base definition under the top customization, for diffing and read-only display. */
|
|
796
762
|
getBase(name) {
|
|
797
763
|
const base = this.bases.get(name);
|
|
798
764
|
return base ? structuredClone(base) : undefined;
|
|
799
765
|
}
|
|
800
|
-
/** Loaded definitions in cascade order, including lower-precedence scopes. */
|
|
801
766
|
getLayers(name) {
|
|
802
|
-
const current = this.get(name);
|
|
767
|
+
const current = this.get(name);
|
|
803
768
|
const layers = new Map();
|
|
804
769
|
for (const type of [
|
|
805
770
|
this.scopeBases.get("user")?.get(name),
|
|
@@ -811,7 +776,6 @@ export class ConfigStore {
|
|
|
811
776
|
}
|
|
812
777
|
return structuredClone([...layers.values()]);
|
|
813
778
|
}
|
|
814
|
-
/** Saved sparse keys, including explicit clears and pins equal to the base. */
|
|
815
779
|
getSettingsOverride(name, scope) {
|
|
816
780
|
const layer = this.getLayers(name).find((type) => type.source === scope);
|
|
817
781
|
if (layer?.customization?.kind !== "override")
|
|
@@ -819,7 +783,6 @@ export class ConfigStore {
|
|
|
819
783
|
const override = this.scopeOverrides.get(scope)?.get(name);
|
|
820
784
|
return override ? structuredClone(override) : undefined;
|
|
821
785
|
}
|
|
822
|
-
/** Definition below a specific save scope; never includes that scope or higher ones. */
|
|
823
786
|
getScopeBase(name, scope) {
|
|
824
787
|
const base = this.scopeBases.get(scope)?.get(name);
|
|
825
788
|
return base ? structuredClone(base) : undefined;
|
|
@@ -860,14 +823,12 @@ export class ConfigStore {
|
|
|
860
823
|
}
|
|
861
824
|
assertWritableDestination(filePath, scope) {
|
|
862
825
|
const directory = dirname(filePath);
|
|
863
|
-
// Reject redirected destination directories and files before writing.
|
|
864
826
|
for (const path of [...this.destinationBasePaths(scope, directory), filePath]) {
|
|
865
827
|
const stat = assertNotSymlinkPath(path);
|
|
866
828
|
if (path === filePath && stat && !stat.isFile())
|
|
867
829
|
throw new Error(`Unsafe agent destination: ${filePath}`);
|
|
868
830
|
}
|
|
869
831
|
}
|
|
870
|
-
/** Save a full `<name>.md` fork. Replaces the base definition entirely. */
|
|
871
832
|
save(type, scope, original) {
|
|
872
833
|
const content = serializeAgentType(type);
|
|
873
834
|
const validated = parseAgentType(content);
|
|
@@ -877,13 +838,6 @@ export class ConfigStore {
|
|
|
877
838
|
this.reload();
|
|
878
839
|
return this.get(validated.name);
|
|
879
840
|
}
|
|
880
|
-
/**
|
|
881
|
-
* Save a settings-only `<name>.yml` override merged on top of the base.
|
|
882
|
-
* The prompt body always comes from the base; only changed settings are
|
|
883
|
-
* written so untouched fields keep tracking bundled updates. Existing pins
|
|
884
|
-
* are retained; `original` is the pre-edit snapshot (also used to avoid
|
|
885
|
-
* copying inherited settings into another scope or from a stale draft).
|
|
886
|
-
*/
|
|
887
841
|
saveOverride(name, draft, scope, original) {
|
|
888
842
|
if (!NAME.test(name))
|
|
889
843
|
throw new Error("Unsafe agent name");
|
|
@@ -905,7 +859,6 @@ export class ConfigStore {
|
|
|
905
859
|
this.reload();
|
|
906
860
|
return this.get(name);
|
|
907
861
|
}
|
|
908
|
-
/** Remove a user/project customization so the base definition shows through. */
|
|
909
862
|
removeCustomization(name, scope) {
|
|
910
863
|
const current = this.types.get(name);
|
|
911
864
|
const customization = current?.customization;
|
|
@@ -923,4 +876,3 @@ export class ConfigStore {
|
|
|
923
876
|
this.reload();
|
|
924
877
|
}
|
|
925
878
|
}
|
|
926
|
-
//# sourceMappingURL=config.js.map
|