pi-subagents 0.86.0 → 0.87.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/{chunk-7QA7ZA46.js → chunk-2D2DQGC2.js} +9 -9
- package/bundle/{chunk-UR7OW5S7.js → chunk-2NY5PCKQ.js} +11 -5
- package/bundle/{chunk-PYOAIN3V.js → chunk-3CVOAS77.js} +2 -2
- package/bundle/{chunk-YK3QYNLE.js → chunk-6O7YH2QV.js} +1 -1
- package/bundle/{chunk-ZJJCPV3L.js → chunk-AIL46SZU.js} +8 -6
- package/bundle/{chunk-S2Q75LP3.js → chunk-BFF6YDK6.js} +1 -1
- package/bundle/{chunk-QGO6HXHG.js → chunk-C3KWLXDH.js} +79 -63
- package/bundle/{chunk-NAFLUJ26.js → chunk-C5QWQSSM.js} +1 -1
- package/bundle/{chunk-O3YH7XIY.js → chunk-DGTZKYIE.js} +25 -24
- package/bundle/{chunk-77ASNIEM.js → chunk-ESWW6XSX.js} +1 -1
- package/bundle/{chunk-BWC2LVII.js → chunk-EYGBK6CE.js} +166 -60
- package/bundle/{chunk-3RKFH2UZ.js → chunk-HDICKROY.js} +5 -5
- package/bundle/{chunk-QM3JGE4W.js → chunk-JLDQ6YUR.js} +12 -12
- package/bundle/{chunk-A637IMAO.js → chunk-LFKMM3UH.js} +2 -2
- package/bundle/{chunk-WN2E5XHN.js → chunk-LZKVUWIY.js} +4 -4
- package/bundle/{chunk-6VD7BGIC.js → chunk-M2VBGET6.js} +2 -2
- package/bundle/{chunk-7ZUFN6ME.js → chunk-OOE3R7IQ.js} +1 -1
- package/bundle/{chunk-7ADDXUGF.js → chunk-OTLDAYEQ.js} +5 -5
- package/bundle/{chunk-2IYBCYFU.js → chunk-OZCPYJEY.js} +75 -33
- package/bundle/{chunk-GJGTMLPE.js → chunk-PGU4TZV3.js} +79 -32
- package/bundle/{chunk-374MZFF4.js → chunk-SIAQXPJ4.js} +6 -8
- package/bundle/{chunk-LGINOOY5.js → chunk-USRX7QXD.js} +2 -2
- package/bundle/{chunk-5H4BICQZ.js → chunk-VFUFOZBU.js} +1 -1
- package/bundle/{chunk-NF7IEKBH.js → chunk-W2BZS6UC.js} +27 -13
- package/bundle/{chunk-ZPY5QZCS.js → chunk-W52LJANO.js} +1 -1
- package/bundle/{chunk-GRJHIXYF.js → chunk-XSDYTXHF.js} +18 -11
- package/bundle/{chunk-BGXEAYUM.js → chunk-XV7RTWTS.js} +3 -3
- package/bundle/{chunk-BU6PFPVX.js → chunk-YEXKJJVS.js} +12 -7
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +12 -10
- package/bundle/project-panes.js +3 -3
- package/bundle/workflow-resources.js +1 -1
- package/docs/agents.md +3 -3
- package/docs/configuration.md +12 -4
- package/docs/extension-api.md +2 -0
- package/docs/models.md +6 -2
- package/docs/tool-reference.md +1 -0
- package/package.json +1 -1
- package/skills/pi-subagents/SKILL.md +7 -4
- package/skills/pi-subagents/references/prompting-and-roles.md +1 -0
- package/src/agents/agent-management.js +10 -6
- package/src/agents/agent-serializer.d.ts +2 -0
- package/src/agents/agent-serializer.js +1 -1
- package/src/agents/agents.js +37 -12
- package/src/api/preflight.d.ts +3 -1
- package/src/api/preflight.js +2 -0
- package/src/extension/index.js +4 -2
- package/src/extension/schemas.d.ts +2 -0
- package/src/extension/schemas.js +1 -0
- package/src/runs/background/async-execution.d.ts +2 -1
- package/src/runs/background/async-execution.js +4 -2
- package/src/runs/background/runner-aliases.js +15 -0
- package/src/runs/background/wait-subscriptions.js +124 -12
- package/src/runs/foreground/async-stop-action.d.ts +1 -1
- package/src/runs/foreground/async-stop-action.js +9 -1
- package/src/runs/foreground/execution.js +1 -0
- package/src/runs/foreground/subagent-executor.d.ts +1 -0
- package/src/runs/foreground/subagent-executor.js +51 -8
- package/src/runs/shared/child-session.d.ts +5 -4
- package/src/runs/shared/child-session.js +43 -33
- package/src/runs/shared/herdr-placed-run.js +3 -2
- package/src/runs/shared/mcp-config-sources.d.ts +2 -1
- package/src/runs/shared/mcp-config-sources.js +1 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.js +5 -6
- package/src/runs/shared/model-resolution.d.ts +19 -4
- package/src/runs/shared/model-resolution.js +50 -51
- package/src/shared/artifacts.js +25 -13
- package/src/shared/pruned-fork.js +2 -2
- package/src/shared/types.d.ts +14 -0
- package/src/watchdog/model-selection.js +2 -2
- package/src/watchdog/review.js +2 -2
- package/src/workflows/scripted-workflow.d.ts +2 -0
- package/src/workflows/scripted-workflow.js +103 -39
- package/src/workflows/structured-workflow-scripts.d.ts +4 -3
- package/src/workflows/structured-workflow-scripts.js +32 -11
- package/src/workflows/workflow-resources.js +4 -4
- package/src/workflows/workflow-resume-claim.d.ts +2 -0
- package/src/workflows/workflow-resume-claim.js +1 -1
- package/src/workflows/workflow-resume.d.ts +1 -1
- package/src/workflows/workflow-resume.js +3 -1
|
@@ -387,12 +387,15 @@ export function createDefaultChildSessionFactory(options = {}) {
|
|
|
387
387
|
const loadPiCodingAgent = options.loadPiCodingAgent ?? loadHostPiCodingAgent;
|
|
388
388
|
const shutdownTimeoutMs = options.shutdownTimeoutMs ?? 5_000;
|
|
389
389
|
let runtime;
|
|
390
|
-
const live = new
|
|
390
|
+
const live = new Map();
|
|
391
391
|
/** Extension shutdowns still running for disposed children; `dispose()` waits for them. */
|
|
392
392
|
const shutdowns = new Set();
|
|
393
393
|
/** Launches still waiting for their MCP tools; `dispose()` ends the wait and waits for their shutdown. */
|
|
394
394
|
const mcpWaits = new Map();
|
|
395
|
-
let
|
|
395
|
+
let globalDisposals = 0;
|
|
396
|
+
/** Per-parent disposal epochs: a child's launch aborts only when its own parent's scope (or the whole process) was disposed while it started. */
|
|
397
|
+
const parentDisposals = new Map();
|
|
398
|
+
const parentDisposalEpoch = (parent) => parentDisposals.get(parent) ?? 0;
|
|
396
399
|
const sharedRuntime = async (pi) => {
|
|
397
400
|
runtime ??= pi.ModelRuntime.create().catch((error) => {
|
|
398
401
|
runtime = undefined;
|
|
@@ -400,9 +403,32 @@ export function createDefaultChildSessionFactory(options = {}) {
|
|
|
400
403
|
});
|
|
401
404
|
return runtime;
|
|
402
405
|
};
|
|
406
|
+
const disposeMatching = async (matches) => {
|
|
407
|
+
for (const [cancel, wait] of mcpWaits)
|
|
408
|
+
if (matches(wait.parent))
|
|
409
|
+
cancel.abort();
|
|
410
|
+
const children = [...live.keys()].filter((child) => !child.detached && matches(live.get(child)));
|
|
411
|
+
for (const child of children)
|
|
412
|
+
child.shutDown = true;
|
|
413
|
+
await Promise.allSettled(children.map((child) => child.abort()));
|
|
414
|
+
for (const child of children) {
|
|
415
|
+
try {
|
|
416
|
+
void child.dispose();
|
|
417
|
+
}
|
|
418
|
+
catch { /* best effort */ }
|
|
419
|
+
}
|
|
420
|
+
await Promise.allSettled([
|
|
421
|
+
...shutdowns,
|
|
422
|
+
...[...mcpWaits.values()].filter((wait) => matches(wait.parent)).map((wait) => wait.ready),
|
|
423
|
+
]);
|
|
424
|
+
if (live.size === 0)
|
|
425
|
+
runtime = undefined;
|
|
426
|
+
};
|
|
403
427
|
return {
|
|
404
428
|
async create(launch) {
|
|
405
|
-
const
|
|
429
|
+
const globalDisposalsAtStart = globalDisposals;
|
|
430
|
+
const parentEpochAtStart = parentDisposalEpoch(launch.parentSessionFile);
|
|
431
|
+
const disposedSinceStart = () => globalDisposals !== globalDisposalsAtStart || parentDisposalEpoch(launch.parentSessionFile) !== parentEpochAtStart;
|
|
406
432
|
const pi = await loadPiCodingAgent();
|
|
407
433
|
const builtinMcpTools = launch.builtinMcpTools ?? [];
|
|
408
434
|
let readinessTool;
|
|
@@ -603,12 +629,12 @@ export function createDefaultChildSessionFactory(options = {}) {
|
|
|
603
629
|
if (builtinMcp) {
|
|
604
630
|
const cancel = new AbortController();
|
|
605
631
|
const signal = launch.signal ? AbortSignal.any([cancel.signal, launch.signal]) : cancel.signal;
|
|
606
|
-
if (
|
|
632
|
+
if (disposedSinceStart())
|
|
607
633
|
cancel.abort();
|
|
608
634
|
const ready = (async () => {
|
|
609
635
|
try {
|
|
610
636
|
await builtinMcp.waitForTools(signal, () => loader.getExtensions().errors.find(({ path }) => path === "builtin:mcp")?.error);
|
|
611
|
-
if (
|
|
637
|
+
if (disposedSinceStart())
|
|
612
638
|
throw new Error("The child session factory was disposed while the child waited for its MCP tools.");
|
|
613
639
|
if (signal.aborted)
|
|
614
640
|
throw new Error("The child launch was cancelled while waiting for its MCP tools.");
|
|
@@ -621,7 +647,7 @@ export function createDefaultChildSessionFactory(options = {}) {
|
|
|
621
647
|
throw error;
|
|
622
648
|
}
|
|
623
649
|
})();
|
|
624
|
-
mcpWaits.set(cancel, ready);
|
|
650
|
+
mcpWaits.set(cancel, { ready, parent: launch.parentSessionFile });
|
|
625
651
|
try {
|
|
626
652
|
await ready;
|
|
627
653
|
}
|
|
@@ -656,26 +682,16 @@ export function createDefaultChildSessionFactory(options = {}) {
|
|
|
656
682
|
get virtualModelId() { return session.model?.api === "pi-virtual" ? `${session.model.provider}/${session.model.id}` : undefined; },
|
|
657
683
|
get contextWindow() { return session.model?.contextWindow; },
|
|
658
684
|
};
|
|
659
|
-
live.
|
|
685
|
+
live.set(child, launch.parentSessionFile);
|
|
660
686
|
return child;
|
|
661
687
|
},
|
|
662
688
|
async dispose() {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
await Promise.allSettled(children.map((child) => child.abort()));
|
|
670
|
-
for (const child of children) {
|
|
671
|
-
try {
|
|
672
|
-
void child.dispose();
|
|
673
|
-
}
|
|
674
|
-
catch { /* best effort */ }
|
|
675
|
-
}
|
|
676
|
-
await Promise.allSettled([...shutdowns, ...mcpWaits.values()]);
|
|
677
|
-
if (live.size === 0)
|
|
678
|
-
runtime = undefined;
|
|
689
|
+
globalDisposals += 1;
|
|
690
|
+
await disposeMatching(() => true);
|
|
691
|
+
},
|
|
692
|
+
async disposeForParent(parentSessionFile) {
|
|
693
|
+
parentDisposals.set(parentSessionFile, parentDisposalEpoch(parentSessionFile) + 1);
|
|
694
|
+
await disposeMatching((parent) => parent === parentSessionFile);
|
|
679
695
|
},
|
|
680
696
|
};
|
|
681
697
|
}
|
|
@@ -691,10 +707,8 @@ function createLazyPlacementFactory(local) {
|
|
|
691
707
|
const factory = async () => placed ??= (await import("./herdr-placed-run.js")).createPlacementAwareChildSessionFactory(local);
|
|
692
708
|
return {
|
|
693
709
|
async create(launch) { return launch.machine ? (await factory()).create(launch) : local.create(launch); },
|
|
694
|
-
async dispose() {
|
|
695
|
-
|
|
696
|
-
else
|
|
697
|
-
await local.dispose(); },
|
|
710
|
+
async dispose() { await (placed ?? local).dispose(); },
|
|
711
|
+
async disposeForParent(parentSessionFile) { await (placed ?? local).disposeForParent(parentSessionFile); },
|
|
698
712
|
};
|
|
699
713
|
}
|
|
700
714
|
/** Default factory including pane-native placement; detached runners use the same boundary. */
|
|
@@ -719,10 +733,6 @@ export function childSessionFactoryModule() {
|
|
|
719
733
|
export function setChildSessionFactoryModule(modulePath) {
|
|
720
734
|
activeFactoryModule = modulePath;
|
|
721
735
|
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
const factory = activeFactory;
|
|
725
|
-
if (!factory)
|
|
726
|
-
return;
|
|
727
|
-
await factory.dispose();
|
|
736
|
+
export async function disposeChildSessionsForParent(parentSessionFile) {
|
|
737
|
+
await activeFactory?.disposeForParent(parentSessionFile);
|
|
728
738
|
}
|
|
@@ -399,7 +399,8 @@ async function startPlacedPiSession(launch, owner, policy) {
|
|
|
399
399
|
}
|
|
400
400
|
function createPlacedPiSession(launch) { return launch.machine?.provider === "rex" ? createRexPiSession(launch) : createHerdrPiSession(launch); }
|
|
401
401
|
export function createPlacementAwareChildSessionFactory(local, createRemote = createPlacedPiSession) {
|
|
402
|
-
const remote = new
|
|
402
|
+
const remote = new Map();
|
|
403
403
|
return { async create(launch) { if (!launch.machine)
|
|
404
|
-
return local.create(launch); serializeHerdrPiLaunch(launch); const child = await createRemote(launch); remote.
|
|
404
|
+
return local.create(launch); serializeHerdrPiLaunch(launch); const child = await createRemote(launch); remote.set(child, launch.parentSessionFile); return child; }, async dispose() { await Promise.allSettled([...remote.keys()].map((child) => child.dispose())); remote.clear(); await local.dispose(); }, async disposeForParent(parentSessionFile) { const matching = [...remote].filter(([, parent]) => parent === parentSessionFile).map(([child]) => child); await Promise.allSettled(matching.map((child) => child.dispose())); for (const child of matching)
|
|
405
|
+
remote.delete(child); await local.disposeForParent(parentSessionFile); } };
|
|
405
406
|
}
|
|
@@ -22,7 +22,8 @@ export interface McpServerDefinition {
|
|
|
22
22
|
/** Per-server override of the global `settings.toolPrefix`, matching the adapter. */
|
|
23
23
|
toolPrefix?: McpToolPrefix;
|
|
24
24
|
protocolVersion?: string;
|
|
25
|
-
|
|
25
|
+
/** Validated so adapter configs load; `mcp:` selectors do not read it. */
|
|
26
|
+
directTools?: boolean | string[] | "search";
|
|
26
27
|
httpTransport?: string;
|
|
27
28
|
pluginDataDir?: string;
|
|
28
29
|
literalEnv?: boolean;
|
|
@@ -33,7 +33,7 @@ export function isMcpServerDefinition(value) {
|
|
|
33
33
|
return false;
|
|
34
34
|
if (value.auth !== undefined && value.auth !== "oauth" && value.auth !== "bearer" && value.auth !== false)
|
|
35
35
|
return false;
|
|
36
|
-
return value.directTools === undefined || typeof value.directTools === "boolean" || isStringArray(value.directTools);
|
|
36
|
+
return value.directTools === undefined || typeof value.directTools === "boolean" || value.directTools === "search" || isStringArray(value.directTools);
|
|
37
37
|
}
|
|
38
38
|
function isRecord(value) {
|
|
39
39
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -292,10 +292,8 @@ function parseSettings(value) {
|
|
|
292
292
|
if (!isRecord(value))
|
|
293
293
|
return undefined;
|
|
294
294
|
const toolPrefix = value.toolPrefix === "server" || value.toolPrefix === "short" || value.toolPrefix === "none" || value.toolPrefix === "mcp" ? value.toolPrefix : undefined;
|
|
295
|
-
const directTools = typeof value.directTools === "boolean" ? value.directTools : undefined;
|
|
296
295
|
const settings = {
|
|
297
296
|
...(toolPrefix ? { toolPrefix } : {}),
|
|
298
|
-
...(directTools !== undefined ? { directTools } : {}),
|
|
299
297
|
...(value.agentPluginPaths !== undefined ? { agentPluginPaths: value.agentPluginPaths } : {}),
|
|
300
298
|
};
|
|
301
299
|
return Object.keys(settings).length ? settings : undefined;
|
|
@@ -414,7 +412,8 @@ function interpolateEnvRecord(values) {
|
|
|
414
412
|
}
|
|
415
413
|
function interpolateEnvVars(value) {
|
|
416
414
|
return value
|
|
417
|
-
|
|
415
|
+
// `${NAME:-default}` uses the default only when NAME is unset, as pi-mcp-adapter and Claude Code do.
|
|
416
|
+
.replace(/\$\{(\w+)(?::-([^}]*))?\}/g, (_, name, fallback) => process.env[name] ?? fallback ?? "")
|
|
418
417
|
.replace(/\$env:(\w+)/g, (_, name) => process.env[name] ?? "")
|
|
419
418
|
.replace(/\{env:(\w+)\}/g, (_, name) => process.env[name] ?? "");
|
|
420
419
|
}
|
|
@@ -425,9 +424,9 @@ function interpolateSecretExpression(value) {
|
|
|
425
424
|
}
|
|
426
425
|
function getMissingEnvVars(value) {
|
|
427
426
|
const missing = new Set();
|
|
428
|
-
for (const match of value.matchAll(/\$\{(\w+)
|
|
429
|
-
const name = match[1] ?? match[
|
|
430
|
-
if (name && process.env[name] === undefined)
|
|
427
|
+
for (const match of value.matchAll(/\$\{(\w+)(:-[^}]*)?\}|\$env:(\w+)|\{env:(\w+)\}/g)) {
|
|
428
|
+
const name = match[1] ?? match[3] ?? match[4];
|
|
429
|
+
if (name && match[2] === undefined && process.env[name] === undefined)
|
|
431
430
|
missing.add(name);
|
|
432
431
|
}
|
|
433
432
|
return [...missing];
|
|
@@ -35,18 +35,31 @@ export declare function scopedModelIdsFromContext(ctx: {
|
|
|
35
35
|
* repeated separators.
|
|
36
36
|
*/
|
|
37
37
|
export declare function normalizeModelSegment(segment: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Every provider in Pi's full catalog, signed in or not, read only when a query's prefix is not an available
|
|
40
|
+
* provider. Without it, a query naming a provider the user is not signed in to would be read as an `owner/name` id
|
|
41
|
+
* and could match that id under another provider (OpenRouter's `anthropic/...` copies), running and billing a
|
|
42
|
+
* different account.
|
|
43
|
+
*/
|
|
44
|
+
export type KnownProviders = () => readonly string[];
|
|
45
|
+
/** {@link KnownProviders} for one launch; the full catalog is copied at most once. */
|
|
46
|
+
export declare function knownModelProviders(registry: {
|
|
47
|
+
getAll(): ReadonlyArray<{
|
|
48
|
+
provider: string;
|
|
49
|
+
}>;
|
|
50
|
+
}): KnownProviders;
|
|
38
51
|
/**
|
|
39
52
|
* Fuzzy-resolve a base model id (thinking suffix already stripped) against the
|
|
40
53
|
* registry, tolerating separator, case, and optional date-stamp differences so
|
|
41
54
|
* users do not have to spell provider/model exactly. A slash is a provider
|
|
42
|
-
* prefix only when that prefix is a
|
|
55
|
+
* prefix only when that prefix is a known provider; otherwise the whole
|
|
43
56
|
* string is the model id (Hugging Face `owner/name`). A qualified provider
|
|
44
57
|
* query only matches within the named provider — this never silently switches
|
|
45
58
|
* providers for security/cost-sensitive configs. Returns the matched `fullId`,
|
|
46
59
|
* or `undefined` when there is no match or the match is ambiguous across
|
|
47
60
|
* providers (and no `preferredProvider` disambiguates).
|
|
48
61
|
*/
|
|
49
|
-
export declare function fuzzyResolveModel(baseModel: string, availableModels: AvailableModelInfo[], preferredProvider?: string): string | undefined;
|
|
62
|
+
export declare function fuzzyResolveModel(baseModel: string, availableModels: AvailableModelInfo[], preferredProvider?: string, knownProviders?: KnownProviders): string | undefined;
|
|
50
63
|
/**
|
|
51
64
|
* Resolve a possibly-loose model id to a canonical `provider/id` (plus any
|
|
52
65
|
* thinking suffix). Exact registry matches win; fuzzy normalization
|
|
@@ -54,9 +67,9 @@ export declare function fuzzyResolveModel(baseModel: string, availableModels: Av
|
|
|
54
67
|
* spelling differences still resolve. Never switches providers for a qualified
|
|
55
68
|
* query.
|
|
56
69
|
*/
|
|
57
|
-
export declare function resolveModelCandidate(model: string | undefined, availableModels: AvailableModelInfo[] | undefined, preferredProvider?: string): string | undefined;
|
|
70
|
+
export declare function resolveModelCandidate(model: string | undefined, availableModels: AvailableModelInfo[] | undefined, preferredProvider?: string, knownProviders?: KnownProviders): string | undefined;
|
|
58
71
|
/** A configured pin that launch refuses because the registry cannot resolve it. An empty registry checks nothing. */
|
|
59
|
-
export declare function isUnavailableSubagentModel(model: string | undefined, availableModels: AvailableModelInfo[] | undefined, preferredProvider?: string): boolean;
|
|
72
|
+
export declare function isUnavailableSubagentModel(model: string | undefined, availableModels: AvailableModelInfo[] | undefined, preferredProvider?: string, knownProviders?: KnownProviders): boolean;
|
|
60
73
|
export interface ResolveSubagentModelOverrideOptions {
|
|
61
74
|
/** When set with `enforce: true`, out-of-scope models are rejected. */
|
|
62
75
|
scope?: ModelScopeCheckRule | ModelScopeCheckRule[];
|
|
@@ -64,6 +77,7 @@ export interface ResolveSubagentModelOverrideOptions {
|
|
|
64
77
|
source?: ModelSource;
|
|
65
78
|
/** Called for warn-severity violations instead of `console.warn`. */
|
|
66
79
|
onWarn?: (violation: ModelScopeViolation) => void;
|
|
80
|
+
knownProviders?: KnownProviders;
|
|
67
81
|
}
|
|
68
82
|
/**
|
|
69
83
|
* Resolve the `--model` override passed to a spawned subagent.
|
|
@@ -92,6 +106,7 @@ export interface ResolveModelSelectionOptions {
|
|
|
92
106
|
/** The primary model came from the running parent session, not configuration. */
|
|
93
107
|
primaryModelFromParent?: boolean;
|
|
94
108
|
origin?: ModelOrigin;
|
|
109
|
+
knownProviders?: KnownProviders;
|
|
95
110
|
}
|
|
96
111
|
export declare function resolveModelOrigin(input: {
|
|
97
112
|
explicitModel?: string | boolean;
|
|
@@ -88,20 +88,26 @@ function stripTrailingDateStamp(segment) {
|
|
|
88
88
|
return compact[1];
|
|
89
89
|
return segment;
|
|
90
90
|
}
|
|
91
|
-
function isRegisteredProvider(provider, availableModels) {
|
|
91
|
+
function isRegisteredProvider(provider, availableModels, knownProviders) {
|
|
92
92
|
const normalized = normalizeModelSegment(provider);
|
|
93
|
-
return availableModels.some((entry) => normalizeModelSegment(entry.provider) === normalized)
|
|
93
|
+
return availableModels.some((entry) => normalizeModelSegment(entry.provider) === normalized)
|
|
94
|
+
|| (knownProviders?.().some((name) => normalizeModelSegment(name) === normalized) ?? false);
|
|
95
|
+
}
|
|
96
|
+
/** {@link KnownProviders} for one launch; the full catalog is copied at most once. */
|
|
97
|
+
export function knownModelProviders(registry) {
|
|
98
|
+
let providers;
|
|
99
|
+
return () => providers ??= [...new Set(registry.getAll().map((model) => model.provider))];
|
|
94
100
|
}
|
|
95
101
|
/**
|
|
96
|
-
* Split `provider/id` only when the first path segment is a
|
|
102
|
+
* Split `provider/id` only when the first path segment is a known provider.
|
|
97
103
|
* Hugging Face-style `owner/name` ids therefore stay intact unless `owner` is
|
|
98
|
-
* itself a provider
|
|
104
|
+
* itself a provider Pi knows. `:` and `.` keep the same rule.
|
|
99
105
|
*/
|
|
100
|
-
function splitQualifiedModelQuery(baseModel, availableModels) {
|
|
106
|
+
function splitQualifiedModelQuery(baseModel, availableModels, knownProviders) {
|
|
101
107
|
const slashIdx = baseModel.indexOf("/");
|
|
102
108
|
if (slashIdx !== -1) {
|
|
103
109
|
const providerPart = baseModel.slice(0, slashIdx);
|
|
104
|
-
if (isRegisteredProvider(providerPart, availableModels)) {
|
|
110
|
+
if (isRegisteredProvider(providerPart, availableModels, knownProviders)) {
|
|
105
111
|
return { queryProvider: normalizeModelSegment(providerPart), queryIdRaw: baseModel.slice(slashIdx + 1) };
|
|
106
112
|
}
|
|
107
113
|
return { queryIdRaw: baseModel };
|
|
@@ -112,7 +118,7 @@ function splitQualifiedModelQuery(baseModel, availableModels) {
|
|
|
112
118
|
if (separatorIdx <= 0)
|
|
113
119
|
continue;
|
|
114
120
|
const providerPart = baseModel.slice(0, separatorIdx);
|
|
115
|
-
if (!isRegisteredProvider(providerPart, availableModels))
|
|
121
|
+
if (!isRegisteredProvider(providerPart, availableModels, knownProviders))
|
|
116
122
|
continue;
|
|
117
123
|
return { queryProvider: normalizeModelSegment(providerPart), queryIdRaw: baseModel.slice(separatorIdx + 1) };
|
|
118
124
|
}
|
|
@@ -129,17 +135,17 @@ function resolveExactIdMatches(baseModel, availableModels, preferredProvider) {
|
|
|
129
135
|
return exactMatches[0].fullId;
|
|
130
136
|
return undefined;
|
|
131
137
|
}
|
|
132
|
-
function resolveBaseModelCandidate(baseModel, availableModels, preferredProvider) {
|
|
138
|
+
function resolveBaseModelCandidate(baseModel, availableModels, preferredProvider, knownProviders) {
|
|
133
139
|
const exact = availableModels.find((entry) => entry.fullId === baseModel);
|
|
134
140
|
if (exact)
|
|
135
141
|
return exact.fullId;
|
|
136
|
-
const { queryProvider } = splitQualifiedModelQuery(baseModel, availableModels);
|
|
142
|
+
const { queryProvider } = splitQualifiedModelQuery(baseModel, availableModels, knownProviders);
|
|
137
143
|
if (queryProvider === undefined) {
|
|
138
144
|
const exactId = resolveExactIdMatches(baseModel, availableModels, preferredProvider);
|
|
139
145
|
if (exactId)
|
|
140
146
|
return exactId;
|
|
141
147
|
}
|
|
142
|
-
const fuzzy = fuzzyResolveModel(baseModel, availableModels, preferredProvider);
|
|
148
|
+
const fuzzy = fuzzyResolveModel(baseModel, availableModels, preferredProvider, knownProviders);
|
|
143
149
|
if (fuzzy || queryProvider === undefined)
|
|
144
150
|
return fuzzy;
|
|
145
151
|
// Some catalogs (OpenRouter's `openrouter/auto-beta`) repeat the provider inside the id.
|
|
@@ -151,15 +157,15 @@ function resolveBaseModelCandidate(baseModel, availableModels, preferredProvider
|
|
|
151
157
|
* Fuzzy-resolve a base model id (thinking suffix already stripped) against the
|
|
152
158
|
* registry, tolerating separator, case, and optional date-stamp differences so
|
|
153
159
|
* users do not have to spell provider/model exactly. A slash is a provider
|
|
154
|
-
* prefix only when that prefix is a
|
|
160
|
+
* prefix only when that prefix is a known provider; otherwise the whole
|
|
155
161
|
* string is the model id (Hugging Face `owner/name`). A qualified provider
|
|
156
162
|
* query only matches within the named provider — this never silently switches
|
|
157
163
|
* providers for security/cost-sensitive configs. Returns the matched `fullId`,
|
|
158
164
|
* or `undefined` when there is no match or the match is ambiguous across
|
|
159
165
|
* providers (and no `preferredProvider` disambiguates).
|
|
160
166
|
*/
|
|
161
|
-
export function fuzzyResolveModel(baseModel, availableModels, preferredProvider) {
|
|
162
|
-
const { queryProvider, queryIdRaw } = splitQualifiedModelQuery(baseModel, availableModels);
|
|
167
|
+
export function fuzzyResolveModel(baseModel, availableModels, preferredProvider, knownProviders) {
|
|
168
|
+
const { queryProvider, queryIdRaw } = splitQualifiedModelQuery(baseModel, availableModels, knownProviders);
|
|
163
169
|
const queryId = normalizeModelSegment(queryIdRaw);
|
|
164
170
|
const queryIdNoDate = stripTrailingDateStamp(queryId);
|
|
165
171
|
const candidates = availableModels.filter((entry) => {
|
|
@@ -189,40 +195,41 @@ export function fuzzyResolveModel(baseModel, availableModels, preferredProvider)
|
|
|
189
195
|
* spelling differences still resolve. Never switches providers for a qualified
|
|
190
196
|
* query.
|
|
191
197
|
*/
|
|
192
|
-
export function resolveModelCandidate(model, availableModels, preferredProvider) {
|
|
198
|
+
export function resolveModelCandidate(model, availableModels, preferredProvider, knownProviders) {
|
|
193
199
|
if (!model)
|
|
194
200
|
return undefined;
|
|
195
201
|
if (!availableModels || availableModels.length === 0)
|
|
196
202
|
return model;
|
|
197
|
-
const resolvedWhole = resolveBaseModelCandidate(model, availableModels, preferredProvider);
|
|
203
|
+
const resolvedWhole = resolveBaseModelCandidate(model, availableModels, preferredProvider, knownProviders);
|
|
198
204
|
if (resolvedWhole)
|
|
199
205
|
return resolvedWhole;
|
|
200
206
|
const { baseModel, thinkingSuffix } = splitThinkingSuffix(model);
|
|
201
207
|
if (!thinkingSuffix)
|
|
202
208
|
return model;
|
|
203
|
-
const resolvedBase = resolveBaseModelCandidate(baseModel, availableModels, preferredProvider);
|
|
209
|
+
const resolvedBase = resolveBaseModelCandidate(baseModel, availableModels, preferredProvider, knownProviders);
|
|
204
210
|
if (resolvedBase)
|
|
205
211
|
return `${resolvedBase}${thinkingSuffix}`;
|
|
206
212
|
return model;
|
|
207
213
|
}
|
|
208
|
-
function resolveSubagentModelCandidate(model, availableModels, preferredProvider) {
|
|
214
|
+
function resolveSubagentModelCandidate(model, availableModels, preferredProvider, knownProviders) {
|
|
209
215
|
if (!availableModels || availableModels.length === 0)
|
|
210
216
|
return model;
|
|
211
|
-
const resolvedWhole = resolveBaseModelCandidate(model, availableModels, preferredProvider);
|
|
217
|
+
const resolvedWhole = resolveBaseModelCandidate(model, availableModels, preferredProvider, knownProviders);
|
|
212
218
|
if (resolvedWhole)
|
|
213
219
|
return resolvedWhole;
|
|
214
220
|
const { baseModel, thinkingSuffix } = splitThinkingSuffix(model);
|
|
215
|
-
const resolvedBase = thinkingSuffix ? resolveBaseModelCandidate(baseModel, availableModels, preferredProvider) : undefined;
|
|
221
|
+
const resolvedBase = thinkingSuffix ? resolveBaseModelCandidate(baseModel, availableModels, preferredProvider, knownProviders) : undefined;
|
|
216
222
|
return resolvedBase ? `${resolvedBase}${thinkingSuffix}` : undefined;
|
|
217
223
|
}
|
|
218
|
-
function suggestAlternateProviderModel(model, availableModels) {
|
|
224
|
+
function suggestAlternateProviderModel(model, availableModels, knownProviders) {
|
|
219
225
|
if (!availableModels || availableModels.length === 0)
|
|
220
226
|
return undefined;
|
|
221
227
|
const { baseModel, thinkingSuffix } = splitThinkingSuffix(model);
|
|
222
|
-
const { queryProvider, queryIdRaw } = splitQualifiedModelQuery(baseModel, availableModels);
|
|
228
|
+
const { queryProvider, queryIdRaw } = splitQualifiedModelQuery(baseModel, availableModels, knownProviders);
|
|
223
229
|
if (queryProvider === undefined)
|
|
224
230
|
return undefined;
|
|
225
|
-
|
|
231
|
+
// Without knownProviders the whole query reads as an owner/name id, which finds catalogs such as OpenRouter's `anthropic/...`.
|
|
232
|
+
const suggestion = resolveBaseModelCandidate(queryIdRaw, availableModels) ?? resolveBaseModelCandidate(baseModel, availableModels);
|
|
226
233
|
if (!suggestion)
|
|
227
234
|
return undefined;
|
|
228
235
|
const matched = availableModels.find((entry) => entry.fullId === suggestion);
|
|
@@ -232,11 +239,11 @@ function suggestAlternateProviderModel(model, availableModels) {
|
|
|
232
239
|
}
|
|
233
240
|
const MAX_MODEL_CANDIDATES = 5;
|
|
234
241
|
/** Exact registry ids for an unresolved request: the same id under any provider first, then near spellings. */
|
|
235
|
-
function closestModelCandidates(model, availableModels) {
|
|
242
|
+
function closestModelCandidates(model, availableModels, knownProviders) {
|
|
236
243
|
if (!availableModels || availableModels.length === 0)
|
|
237
244
|
return [];
|
|
238
245
|
const { baseModel, thinkingSuffix } = splitThinkingSuffix(model);
|
|
239
|
-
const { queryProvider, queryIdRaw } = splitQualifiedModelQuery(baseModel, availableModels);
|
|
246
|
+
const { queryProvider, queryIdRaw } = splitQualifiedModelQuery(baseModel, availableModels, knownProviders);
|
|
240
247
|
const queryId = normalizeModelSegment(queryIdRaw);
|
|
241
248
|
const queryIdNoDate = stripTrailingDateStamp(queryId);
|
|
242
249
|
return availableModels
|
|
@@ -257,18 +264,18 @@ function closestModelCandidates(model, availableModels) {
|
|
|
257
264
|
.map((entry) => `${entry.fullId}${thinkingSuffix}`);
|
|
258
265
|
}
|
|
259
266
|
/** A configured pin that launch refuses because the registry cannot resolve it. An empty registry checks nothing. */
|
|
260
|
-
export function isUnavailableSubagentModel(model, availableModels, preferredProvider) {
|
|
267
|
+
export function isUnavailableSubagentModel(model, availableModels, preferredProvider, knownProviders) {
|
|
261
268
|
const trimmed = model?.trim();
|
|
262
269
|
if (!trimmed || trimmed === INHERIT_MODEL || !availableModels?.length)
|
|
263
270
|
return false;
|
|
264
|
-
return resolveSubagentModelCandidate(trimmed, availableModels, preferredProvider) === undefined;
|
|
271
|
+
return resolveSubagentModelCandidate(trimmed, availableModels, preferredProvider, knownProviders) === undefined;
|
|
265
272
|
}
|
|
266
|
-
function resolveRequiredSubagentModelCandidate(model, availableModels, preferredProvider) {
|
|
267
|
-
const resolved = resolveSubagentModelCandidate(model, availableModels, preferredProvider);
|
|
273
|
+
function resolveRequiredSubagentModelCandidate(model, availableModels, preferredProvider, knownProviders) {
|
|
274
|
+
const resolved = resolveSubagentModelCandidate(model, availableModels, preferredProvider, knownProviders);
|
|
268
275
|
if (resolved)
|
|
269
276
|
return resolved;
|
|
270
|
-
const suggestion = suggestAlternateProviderModel(model, availableModels);
|
|
271
|
-
const candidates = closestModelCandidates(model, availableModels).filter((candidate) => candidate !== suggestion);
|
|
277
|
+
const suggestion = suggestAlternateProviderModel(model, availableModels, knownProviders);
|
|
278
|
+
const candidates = closestModelCandidates(model, availableModels, knownProviders).filter((candidate) => candidate !== suggestion);
|
|
272
279
|
throw new Error(`Unknown subagent model '${model}' in the active Pi model registry.${suggestion ? ` Did you mean '${suggestion}'?` : ""}${candidates.length ? ` Closest registry models: ${candidates.join(", ")}.` : ""}`);
|
|
273
280
|
}
|
|
274
281
|
function defaultScopeWarn(violation) {
|
|
@@ -322,25 +329,19 @@ export function resolveSubagentModelOverride(requestedModel, parentModel, availa
|
|
|
322
329
|
if (!parentModel)
|
|
323
330
|
throwForUnresolvedEnforcedReservedScope(options?.scope, explicit === undefined || options?.source === "inherited");
|
|
324
331
|
let resolved;
|
|
325
|
-
let resolvedFromRegistry = explicit === undefined;
|
|
326
332
|
if (explicit === undefined) {
|
|
327
333
|
resolved = parentModel ? `${parentModel.provider}/${parentModel.id}` : undefined;
|
|
328
334
|
}
|
|
335
|
+
else if (options?.source === "explicit") {
|
|
336
|
+
resolved = resolveRequiredSubagentModelCandidate(explicit, availableModels, preferredProvider, options.knownProviders);
|
|
337
|
+
}
|
|
329
338
|
else {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
335
|
-
else if (candidate) {
|
|
336
|
-
resolved = candidate;
|
|
337
|
-
resolvedFromRegistry = true;
|
|
338
|
-
}
|
|
339
|
-
else {
|
|
340
|
-
resolved = explicit;
|
|
341
|
-
}
|
|
339
|
+
resolved = resolveSubagentModelCandidate(explicit, availableModels, preferredProvider, options?.knownProviders);
|
|
340
|
+
// An inherited model the registry does not know passes through unchecked.
|
|
341
|
+
if (!resolved)
|
|
342
|
+
return explicit;
|
|
342
343
|
}
|
|
343
|
-
if (resolved && options?.scope
|
|
344
|
+
if (resolved && options?.scope) {
|
|
344
345
|
const source = explicit === undefined ? "inherited" : (options.source ?? "inherited");
|
|
345
346
|
enforceModelScopes(resolved, options.scope, source, options.onWarn);
|
|
346
347
|
}
|
|
@@ -374,14 +375,12 @@ export function resolveModelSelection(model, availableModels, preferredProvider,
|
|
|
374
375
|
const origin = options?.origin ?? (options?.primaryModelFromParent ? "inherited" : "configured");
|
|
375
376
|
const requestedModel = origin === "inherited" ? undefined : model;
|
|
376
377
|
const scopes = configuredScopes(options?.scope);
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
378
|
+
let resolved = model?.trim();
|
|
379
|
+
if (model && (origin === "explicit" || (origin !== "inherited" && !options?.primaryModelFromParent))) {
|
|
380
|
+
resolved = resolveRequiredSubagentModelCandidate(model.trim(), availableModels, preferredProvider, options?.knownProviders);
|
|
381
|
+
if (origin === "explicit")
|
|
382
|
+
enforceModelScopes(resolved, scopes, "explicit", options?.onWarn);
|
|
381
383
|
}
|
|
382
|
-
const resolved = model && (origin === "inherited" || origin === "explicit" || options?.primaryModelFromParent)
|
|
383
|
-
? model.trim()
|
|
384
|
-
: model ? resolveRequiredSubagentModelCandidate(model.trim(), availableModels, preferredProvider) : undefined;
|
|
385
384
|
if (resolved && scopes.some((scope) => scope.enforce === true && scope.strict === true)) {
|
|
386
385
|
enforceModelScopes(resolved, scopes, "inherited", options?.onWarn);
|
|
387
386
|
}
|
package/src/shared/artifacts.js
CHANGED
|
@@ -3,6 +3,8 @@ import * as path from "node:path";
|
|
|
3
3
|
import { CHAIN_RUNS_DIR, TEMP_ARTIFACTS_DIR } from "./types.js";
|
|
4
4
|
import { getAgentDir } from "./utils.js";
|
|
5
5
|
const CLEANUP_MARKER_FILE = ".last-cleanup";
|
|
6
|
+
// Kept worktrees can outlive cleanupDays; their handoff record and the patches it points to must stay with them.
|
|
7
|
+
const RETAINED_ARTIFACT_DIRS = new Set(["handoffs", "worktree-diffs"]);
|
|
6
8
|
export const PROJECT_SUBAGENTS_RELATIVE_DIR = ".pi/subagents";
|
|
7
9
|
const PROJECT_ARTIFACT_PATHS = [
|
|
8
10
|
`${PROJECT_SUBAGENTS_RELATIVE_DIR}/artifacts/output.md`,
|
|
@@ -228,23 +230,33 @@ export function cleanupOldArtifacts(dir, maxAgeDays) {
|
|
|
228
230
|
}
|
|
229
231
|
const maxAgeMs = maxAgeDays * 24 * 60 * 60 * 1000;
|
|
230
232
|
const cutoff = now - maxAgeMs;
|
|
231
|
-
for (const
|
|
232
|
-
if (
|
|
233
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
234
|
+
if (entry.name === CLEANUP_MARKER_FILE || (entry.isDirectory() && RETAINED_ARTIFACT_DIRS.has(entry.name)))
|
|
233
235
|
continue;
|
|
234
|
-
|
|
235
|
-
try {
|
|
236
|
-
const stat = fs.statSync(filePath);
|
|
237
|
-
if (stat.mtimeMs < cutoff) {
|
|
238
|
-
fs.unlinkSync(filePath);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
catch {
|
|
242
|
-
// Artifact cleanup is best-effort housekeeping. Skip files that disappear
|
|
243
|
-
// or become unreadable while scanning so one bad entry does not block the rest.
|
|
244
|
-
}
|
|
236
|
+
removeOldEntry(path.join(dir, entry.name), cutoff);
|
|
245
237
|
}
|
|
246
238
|
fs.writeFileSync(markerPath, String(now));
|
|
247
239
|
}
|
|
240
|
+
function removeOldEntry(entryPath, cutoff) {
|
|
241
|
+
try {
|
|
242
|
+
const stat = fs.lstatSync(entryPath);
|
|
243
|
+
// Read the folder's age before emptying it: removing its files makes it look new.
|
|
244
|
+
const old = stat.mtimeMs < cutoff;
|
|
245
|
+
if (!stat.isDirectory()) {
|
|
246
|
+
if (old)
|
|
247
|
+
fs.unlinkSync(entryPath);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
for (const name of fs.readdirSync(entryPath))
|
|
251
|
+
removeOldEntry(path.join(entryPath, name), cutoff);
|
|
252
|
+
if (old && fs.readdirSync(entryPath).length === 0)
|
|
253
|
+
fs.rmdirSync(entryPath);
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
// Artifact cleanup is best-effort housekeeping. Skip entries that disappear
|
|
257
|
+
// or become unreadable while scanning so one bad entry does not block the rest.
|
|
258
|
+
}
|
|
259
|
+
}
|
|
248
260
|
export function cleanupAllArtifactDirs(maxAgeDays) {
|
|
249
261
|
cleanupOldArtifacts(TEMP_ARTIFACTS_DIR, maxAgeDays);
|
|
250
262
|
const sessionsBase = path.join(getAgentDir(), "sessions");
|
|
@@ -2,7 +2,7 @@ import { Buffer } from "node:buffer";
|
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import * as path from "node:path";
|
|
5
|
-
import { resolveModelCandidate } from "../runs/shared/model-resolution.js";
|
|
5
|
+
import { knownModelProviders, resolveModelCandidate } from "../runs/shared/model-resolution.js";
|
|
6
6
|
import { splitKnownThinkingSuffix, toModelInfo } from "./model-info.js";
|
|
7
7
|
import { opencodeSessionHeaders } from "./opencode-session-headers.js";
|
|
8
8
|
const MAX_INHERITED_SESSION_BYTES = 64 * 1024;
|
|
@@ -392,7 +392,7 @@ export async function createPrunedForkSessionWriter(ctx, config, signal) {
|
|
|
392
392
|
if (!config.model?.trim())
|
|
393
393
|
throw new Error("Pruned fork context requires config.forkContext.model.");
|
|
394
394
|
const available = ctx.modelRegistry.getAvailable();
|
|
395
|
-
const resolved = resolveModelCandidate(config.model.trim(), available.map(toModelInfo), ctx.model?.provider);
|
|
395
|
+
const resolved = resolveModelCandidate(config.model.trim(), available.map(toModelInfo), ctx.model?.provider, knownModelProviders(ctx.modelRegistry));
|
|
396
396
|
if (!resolved)
|
|
397
397
|
throw new Error(`Pruned fork model '${config.model}' did not match exactly one available model.`);
|
|
398
398
|
const { baseModel } = splitKnownThinkingSuffix(resolved);
|
package/src/shared/types.d.ts
CHANGED
|
@@ -1457,6 +1457,8 @@ export interface Details {
|
|
|
1457
1457
|
sourceRunId: string;
|
|
1458
1458
|
attempt: number;
|
|
1459
1459
|
};
|
|
1460
|
+
/** When `stop` with `drain` was requested (epoch ms). A drained run is never resumed. */
|
|
1461
|
+
drainRequestedAt?: number;
|
|
1460
1462
|
resource?: WorkflowResourceProvenance;
|
|
1461
1463
|
preflightWarnings?: string[];
|
|
1462
1464
|
trace: Array<{
|
|
@@ -2285,6 +2287,10 @@ export interface WaitSubscriptionRecord {
|
|
|
2285
2287
|
version: 1;
|
|
2286
2288
|
token: string;
|
|
2287
2289
|
sessionId: string;
|
|
2290
|
+
/** Completion owner of the process that armed the record. A record without it stays scoped to the session. */
|
|
2291
|
+
completionOwnerId?: string;
|
|
2292
|
+
/** The Pi process behind `completionOwnerId`. Once it is dead, the next process on the session takes the wake. */
|
|
2293
|
+
completionOwnerProcess?: RecordedPid;
|
|
2288
2294
|
targetKind: "async" | "foreground";
|
|
2289
2295
|
runId: string;
|
|
2290
2296
|
requestedId: string;
|
|
@@ -2374,6 +2380,13 @@ export interface SubagentState {
|
|
|
2374
2380
|
workflowControllers?: Map<string, AbortController>;
|
|
2375
2381
|
/** Live in-process workflow child stoppers keyed by parent workflow run id. */
|
|
2376
2382
|
workflowChildStops?: Map<string, (childId: string, message?: string) => boolean>;
|
|
2383
|
+
/** Live in-process workflow drains keyed by workflow run id; `ok: false` means the drain request could not be saved and nothing was stopped. */
|
|
2384
|
+
workflowDrains?: Map<string, () => {
|
|
2385
|
+
ok: true;
|
|
2386
|
+
started: number;
|
|
2387
|
+
} | {
|
|
2388
|
+
ok: false;
|
|
2389
|
+
}>;
|
|
2377
2390
|
/** Background children awaited by a blocking workflow call: their parent cannot answer supervisor asks. */
|
|
2378
2391
|
blockingWorkflowChildren?: Set<string>;
|
|
2379
2392
|
}
|
|
@@ -2562,6 +2575,7 @@ export interface RunSyncOptions {
|
|
|
2562
2575
|
fullId: string;
|
|
2563
2576
|
contextWindow?: number;
|
|
2564
2577
|
}>;
|
|
2578
|
+
knownProviders?: import("../runs/shared/model-resolution.ts").KnownProviders;
|
|
2565
2579
|
modelResponseAliases?: Record<string, string[]>;
|
|
2566
2580
|
/** Current parent-session provider to prefer for ambiguous bare model ids */
|
|
2567
2581
|
preferredModelProvider?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeModelSegment, resolveModelCandidate } from "../runs/shared/model-resolution.js";
|
|
1
|
+
import { knownModelProviders, normalizeModelSegment, resolveModelCandidate } from "../runs/shared/model-resolution.js";
|
|
2
2
|
import { getSupportedThinkingLevels, splitKnownThinkingSuffix, THINKING_LEVELS, toModelInfo, } from "../shared/model-info.js";
|
|
3
3
|
export const STRONG_WATCHDOG_THINKING = "high";
|
|
4
4
|
const STRONG_WATCHDOG_MODELS = {
|
|
@@ -53,7 +53,7 @@ export function resolveWatchdogModelInput(ctx, rawModel) {
|
|
|
53
53
|
throw new Error("Watchdog model must be a non-empty provider/model value.");
|
|
54
54
|
const availableModels = modelRegistryEntries(ctx);
|
|
55
55
|
const preferredProvider = typeof ctx.model?.provider === "string" ? ctx.model.provider : undefined;
|
|
56
|
-
const resolved = resolveModelCandidate(trimmed, availableModels, preferredProvider) ?? trimmed;
|
|
56
|
+
const resolved = resolveModelCandidate(trimmed, availableModels, preferredProvider, knownModelProviders(ctx.modelRegistry)) ?? trimmed;
|
|
57
57
|
const { baseModel, thinkingSuffix } = splitKnownThinkingSuffix(resolved);
|
|
58
58
|
const named = splitProviderModel(baseModel);
|
|
59
59
|
if (!named)
|