dsh-model-switch 0.4.66 → 0.4.68
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 +24 -0
- package/README.en.md +243 -0
- package/README.md +108 -116
- package/cordis.patch.yml +3 -6
- package/docs/screenshots/composer-picker.png +0 -0
- package/docs/screenshots/plan-review.png +0 -0
- package/docs/screenshots/settings-subagent.png +0 -0
- package/lib/client.js +153 -289
- package/lib/index.js +5 -0
- package/lib/subagent-runtime-BgLqMl2z.js +424 -0
- package/lib/subagent-runtime-CluWLZio.js +412 -0
- package/lib/subagent-runtime.js +2 -289
- package/lib/types/client/ModelSwitchSettings.d.ts +0 -2
- package/lib/types/client/locales.d.ts +0 -10
- package/lib/types/client-contract.d.ts +0 -9
- package/lib/types/review-timeout.d.ts +4 -0
- package/lib/types/subagent-runtime.d.ts +34 -0
- package/package.json +2 -2
- package/README.zh.md +0 -247
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
import { a as sessionProviderOf, n as groupRoute, o as sessionSubagentRouteOf } from "./session-route-D8izd8Zd.js";
|
|
2
|
+
import { symbols } from "@deepseek-ai/cordis";
|
|
3
|
+
import { ReasoningEffortId } from "@deepseek-ai/dsh-llm";
|
|
4
|
+
import OfficialSubagentRuntime from "@deepseek-ai/dsh-subagent";
|
|
5
|
+
//#region lib/types/subagent-runtime-legacy.js
|
|
6
|
+
/** Previously published startup error; retained for consumers of this module. */
|
|
7
|
+
var StartupIncompatibilityError = class extends Error {
|
|
8
|
+
name = "StartupIncompatibilityError";
|
|
9
|
+
surface;
|
|
10
|
+
constructor(surfaceOrMessage, message) {
|
|
11
|
+
super(message ?? surfaceOrMessage);
|
|
12
|
+
this.surface = message === void 0 ? "startup" : surfaceOrMessage;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
/** Classify the two published start API generations without version guessing. */
|
|
16
|
+
function subagentSurfaceOf(value) {
|
|
17
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") return void 0;
|
|
18
|
+
if (typeof Reflect.get(value, "startActivation") === "function") return "activation";
|
|
19
|
+
return typeof Reflect.get(value, "start") === "function" && typeof Reflect.get(value, "startContinuable") === "function" ? "start" : void 0;
|
|
20
|
+
}
|
|
21
|
+
function once(dispose) {
|
|
22
|
+
let pending;
|
|
23
|
+
return () => {
|
|
24
|
+
pending ??= Promise.resolve().then(() => dispose()).then(() => void 0);
|
|
25
|
+
return pending;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
var CleanupLedger = class {
|
|
29
|
+
attempts = [];
|
|
30
|
+
add(dispose) {
|
|
31
|
+
this.attempts.push(once(dispose));
|
|
32
|
+
}
|
|
33
|
+
async disposeAll() {
|
|
34
|
+
const failures = [];
|
|
35
|
+
for (const dispose of [...this.attempts].reverse()) try {
|
|
36
|
+
await dispose();
|
|
37
|
+
} catch (error) {
|
|
38
|
+
failures.push(error);
|
|
39
|
+
}
|
|
40
|
+
return failures;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
function startupFailure(error, failures) {
|
|
44
|
+
if (failures.length === 0) throw error;
|
|
45
|
+
throw new AggregateError([error, ...failures], "Subagent runtime startup and cleanup failed", { cause: error });
|
|
46
|
+
}
|
|
47
|
+
function cleanupDisposer(ledger) {
|
|
48
|
+
return async () => {
|
|
49
|
+
const failures = await ledger.disposeAll();
|
|
50
|
+
if (failures.length > 0) throw new AggregateError(failures, "Subagent runtime cleanup failed");
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Retain the typed-only startup fallback and reverse, idempotent cleanup contract. */
|
|
54
|
+
async function mountWithStartupFallback(candidate, fallback) {
|
|
55
|
+
const ledger = new CleanupLedger();
|
|
56
|
+
try {
|
|
57
|
+
return {
|
|
58
|
+
value: await candidate((dispose) => ledger.add(dispose)),
|
|
59
|
+
dispose: cleanupDisposer(ledger)
|
|
60
|
+
};
|
|
61
|
+
} catch (error) {
|
|
62
|
+
const failures = await ledger.disposeAll();
|
|
63
|
+
if (!(error instanceof StartupIncompatibilityError) || failures.length > 0) startupFailure(error, failures);
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
return {
|
|
67
|
+
value: await fallback((dispose) => ledger.add(dispose)),
|
|
68
|
+
dispose: cleanupDisposer(ledger)
|
|
69
|
+
};
|
|
70
|
+
} catch (error) {
|
|
71
|
+
startupFailure(error, await ledger.disposeAll());
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function routedRuntimeUnavailableNotice(error) {
|
|
75
|
+
return `model-switch: the routed Subagent runtime is unavailable on this DSH Host (${error.message}); delegation follows the official route instead`;
|
|
76
|
+
}
|
|
77
|
+
/** @deprecated Only the legacy subclass needs a mirrored dependency list. */
|
|
78
|
+
function subagentRuntimeInject(officialInject) {
|
|
79
|
+
return [.../* @__PURE__ */ new Set([...officialInject ?? [], "modelSwitch"])];
|
|
80
|
+
}
|
|
81
|
+
function publicMethod(method) {
|
|
82
|
+
const value = Reflect.get(OfficialSubagentRuntime.prototype, method);
|
|
83
|
+
if (typeof value !== "function") throw new StartupIncompatibilityError("OfficialSubagentRuntime", `OfficialSubagentRuntime must expose public ${method}()`);
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated Kept importable for existing consumers, not mounted by the bundle.
|
|
88
|
+
* Install profileSubagentRuntime around the official service instead: the
|
|
89
|
+
* official Loader row must remain enabled to own its strict Typert definitions.
|
|
90
|
+
*/
|
|
91
|
+
var ModelSwitchSubagentRuntime = class extends OfficialSubagentRuntime {
|
|
92
|
+
static inject = subagentRuntimeInject(OfficialSubagentRuntime.inject);
|
|
93
|
+
routed(name, request) {
|
|
94
|
+
const provider = this.ctx.subagents.getProvider(name);
|
|
95
|
+
if (provider !== void 0 && provider.capabilities.agentOptions !== true) return request;
|
|
96
|
+
return routeSubagentRequest(request, sessionSubagentRouteOf(this.ctx, request.parent.session, this.ctx.modelSwitch.currentSettings()));
|
|
97
|
+
}
|
|
98
|
+
start(name, request) {
|
|
99
|
+
return Reflect.apply(publicMethod("start"), this, [name, this.routed(name, request)]);
|
|
100
|
+
}
|
|
101
|
+
startContinuable(spec) {
|
|
102
|
+
return Reflect.apply(publicMethod("startContinuable"), this, [{
|
|
103
|
+
...spec,
|
|
104
|
+
request: this.routed(spec.provider, spec.request)
|
|
105
|
+
}]);
|
|
106
|
+
}
|
|
107
|
+
startActivation(spec) {
|
|
108
|
+
const request = spec.request ?? spec;
|
|
109
|
+
return Reflect.apply(publicMethod("startActivation"), this, [{
|
|
110
|
+
...spec,
|
|
111
|
+
request: this.routed(spec.provider, request)
|
|
112
|
+
}]);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region lib/types/subagent-runtime.js
|
|
117
|
+
function present(value) {
|
|
118
|
+
return typeof value === "string" && value.trim() !== "";
|
|
119
|
+
}
|
|
120
|
+
function spawnHasAnyRouteField(options) {
|
|
121
|
+
return present(options?.provider) || present(options?.model) || options?.reasoningEffort !== void 0;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Inject a parent-session route only when the caller named no provider, model,
|
|
125
|
+
* or reasoning effort. All other request and Agent options pass through.
|
|
126
|
+
*/
|
|
127
|
+
function routeSubagentRequest(request, route) {
|
|
128
|
+
if (spawnHasAnyRouteField(request.agentOptions) || route === void 0) return request;
|
|
129
|
+
return {
|
|
130
|
+
...request,
|
|
131
|
+
agentOptions: {
|
|
132
|
+
...request.agentOptions,
|
|
133
|
+
provider: route.provider,
|
|
134
|
+
model: route.model,
|
|
135
|
+
...route.reasoningEffort === void 0 ? {} : { reasoningEffort: ReasoningEffortId(route.reasoningEffort) }
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/** Resolve the current public route surface, never retaining a disposed service. */
|
|
140
|
+
function routedSubagentRequest(ctx, runtime, providerName, request) {
|
|
141
|
+
if (spawnHasAnyRouteField(request.agentOptions)) return request;
|
|
142
|
+
const provider = runtime.getProvider?.(providerName);
|
|
143
|
+
if (provider !== void 0 && provider.capabilities?.agentOptions !== true) return request;
|
|
144
|
+
let modelSwitch;
|
|
145
|
+
try {
|
|
146
|
+
modelSwitch = ctx.get("modelSwitch");
|
|
147
|
+
} catch {
|
|
148
|
+
return request;
|
|
149
|
+
}
|
|
150
|
+
if (typeof modelSwitch?.currentSettings !== "function") return request;
|
|
151
|
+
return routeSubagentRequest(request, sessionSubagentRouteOf(ctx, request.parent.session, modelSwitch.currentSettings()));
|
|
152
|
+
}
|
|
153
|
+
/** A tracing proxy is for calls, not method ownership or descriptor restoration. */
|
|
154
|
+
function originalService(value) {
|
|
155
|
+
const original = Reflect.get(value, symbols.original);
|
|
156
|
+
return original !== null && (typeof original === "object" || typeof original === "function") ? original : value;
|
|
157
|
+
}
|
|
158
|
+
function isRequest(value) {
|
|
159
|
+
if (typeof value !== "object" || value === null) return false;
|
|
160
|
+
const parent = Reflect.get(value, "parent");
|
|
161
|
+
return typeof parent === "object" && parent !== null && Reflect.get(parent, "session") !== void 0;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Route one activation spec under either released shape. 0.2.1 through
|
|
165
|
+
* 0.2.2-rc.1 nest the SubagentStartRequest under spec.request; 0.2.2-rc.2
|
|
166
|
+
* flattens those fields onto the spec itself. Unknown shapes pass through
|
|
167
|
+
* untouched, so an unanticipated future shape keeps the official route.
|
|
168
|
+
*/
|
|
169
|
+
function routedSpecOf(spec, provider, state) {
|
|
170
|
+
const nested = Reflect.get(spec, "request");
|
|
171
|
+
if (typeof nested === "object" && nested !== null && isRequest(nested)) {
|
|
172
|
+
const request = routeFor(state, provider, nested);
|
|
173
|
+
return request === nested ? spec : {
|
|
174
|
+
...spec,
|
|
175
|
+
request
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
if (isRequest(spec)) {
|
|
179
|
+
const request = routeFor(state, provider, spec);
|
|
180
|
+
if (request === spec) return spec;
|
|
181
|
+
return {
|
|
182
|
+
...spec,
|
|
183
|
+
agentOptions: request.agentOptions
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
return spec;
|
|
187
|
+
}
|
|
188
|
+
function warn(ctx, message) {
|
|
189
|
+
try {
|
|
190
|
+
ctx.logger.warn(message);
|
|
191
|
+
} catch {}
|
|
192
|
+
}
|
|
193
|
+
const wrappers = /* @__PURE__ */ new WeakMap();
|
|
194
|
+
function routeFor(state, provider, request) {
|
|
195
|
+
const ctx = [...state.leases].at(-1)?.ctx;
|
|
196
|
+
return ctx === void 0 ? request : routedSubagentRequest(ctx, state.runtime, provider, request);
|
|
197
|
+
}
|
|
198
|
+
function wrapMethod(target, key, factory) {
|
|
199
|
+
const original = Reflect.get(target, key);
|
|
200
|
+
if (typeof original !== "function") return void 0;
|
|
201
|
+
const previous = Object.getOwnPropertyDescriptor(target, key);
|
|
202
|
+
const wrapped = factory(original);
|
|
203
|
+
Object.defineProperty(target, key, {
|
|
204
|
+
configurable: true,
|
|
205
|
+
enumerable: previous?.enumerable ?? false,
|
|
206
|
+
writable: true,
|
|
207
|
+
value: wrapped
|
|
208
|
+
});
|
|
209
|
+
return () => {
|
|
210
|
+
if (Object.getOwnPropertyDescriptor(target, key)?.value !== wrapped) return;
|
|
211
|
+
if (previous === void 0) Reflect.deleteProperty(target, key);
|
|
212
|
+
else Object.defineProperty(target, key, previous);
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Wrap the official service's start entries only. Its identity, prototype,
|
|
217
|
+
* registry, manager, Typert binding and prompt/interrupt methods are untouched.
|
|
218
|
+
* Disposers are idempotent and safe when overlapping adapter fibers unload in
|
|
219
|
+
* either order. Unsupported or sealed surfaces leave the official route usable.
|
|
220
|
+
*/
|
|
221
|
+
function installSubagentRouteWrappers(ctx) {
|
|
222
|
+
const service = ctx.get("subagents");
|
|
223
|
+
if (service === void 0) {
|
|
224
|
+
warn(ctx, "model-switch: subagents service is unavailable; delegation keeps the official route");
|
|
225
|
+
return () => {};
|
|
226
|
+
}
|
|
227
|
+
const runtime = originalService(service);
|
|
228
|
+
let state = wrappers.get(runtime);
|
|
229
|
+
if (state === void 0) {
|
|
230
|
+
state = {
|
|
231
|
+
runtime,
|
|
232
|
+
leases: /* @__PURE__ */ new Set(),
|
|
233
|
+
restores: []
|
|
234
|
+
};
|
|
235
|
+
const current = state;
|
|
236
|
+
const wrap = (key, factory) => {
|
|
237
|
+
const restore = wrapMethod(runtime, key, factory);
|
|
238
|
+
if (restore !== void 0) current.restores.push(restore);
|
|
239
|
+
};
|
|
240
|
+
try {
|
|
241
|
+
for (const key of ["startActivation", "startContinuable"]) wrap(key, (original) => function(...args) {
|
|
242
|
+
const rawSpec = args[0];
|
|
243
|
+
if (typeof rawSpec !== "object" || rawSpec === null) return Reflect.apply(original, this, args);
|
|
244
|
+
const spec = rawSpec;
|
|
245
|
+
if (typeof spec.provider !== "string") return Reflect.apply(original, this, args);
|
|
246
|
+
return Reflect.apply(original, this, [routedSpecOf(spec, spec.provider, current), ...args.slice(1)]);
|
|
247
|
+
});
|
|
248
|
+
wrap("start", (original) => function(...args) {
|
|
249
|
+
const [provider, request] = args;
|
|
250
|
+
if (typeof provider !== "string" || !isRequest(request)) return Reflect.apply(original, this, args);
|
|
251
|
+
return Reflect.apply(original, this, [
|
|
252
|
+
provider,
|
|
253
|
+
routeFor(current, provider, request),
|
|
254
|
+
...args.slice(2)
|
|
255
|
+
]);
|
|
256
|
+
});
|
|
257
|
+
} catch (error) {
|
|
258
|
+
for (const restore of current.restores.reverse()) restore();
|
|
259
|
+
warn(ctx, `model-switch: Subagent starts cannot be wrapped (${String(error)}); delegation keeps the official route`);
|
|
260
|
+
return () => {};
|
|
261
|
+
}
|
|
262
|
+
if (current.restores.length === 0) {
|
|
263
|
+
warn(ctx, "model-switch: no supported public Subagent start entry; delegation keeps the official route");
|
|
264
|
+
return () => {};
|
|
265
|
+
}
|
|
266
|
+
wrappers.set(runtime, state);
|
|
267
|
+
}
|
|
268
|
+
const lease = { ctx };
|
|
269
|
+
state.leases.add(lease);
|
|
270
|
+
const owned = state;
|
|
271
|
+
return () => {
|
|
272
|
+
if (!owned.leases.delete(lease) || owned.leases.size > 0) return;
|
|
273
|
+
for (const restore of [...owned.restores].reverse()) restore();
|
|
274
|
+
wrappers.delete(runtime);
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
/** The official tool that lists routes available for explicit child selection. */
|
|
278
|
+
const SUBAGENT_MODEL_DISCOVERY_TOOL = "list_subagent_models";
|
|
279
|
+
/**
|
|
280
|
+
* Live state of the discovery-hint adapter, surfaced through the capabilities
|
|
281
|
+
* RPC next to the other adapter states.
|
|
282
|
+
*/
|
|
283
|
+
const subagentDiscoveryHintStatus = {
|
|
284
|
+
/** The tools registry was reachable and the adapter installed. */
|
|
285
|
+
installed: false,
|
|
286
|
+
/** The discovery tool was found and its execute wrapped. */
|
|
287
|
+
toolWrapped: false
|
|
288
|
+
};
|
|
289
|
+
/** Marker so a re-sweep never wraps a wrapper. */
|
|
290
|
+
const discoveryHintMarker = Symbol("modelSwitchSubagentDiscoveryHint");
|
|
291
|
+
/** The calling agent's session handle, as discovery executions carry it. */
|
|
292
|
+
function sessionOfExec(exec) {
|
|
293
|
+
const agent = exec?.agent;
|
|
294
|
+
const session = agent === null || typeof agent !== "object" ? void 0 : agent.session;
|
|
295
|
+
return session === null || typeof session !== "object" ? void 0 : session;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Compose the route footer appended to the discovery tool's text output.
|
|
299
|
+
*
|
|
300
|
+
* Pure so the copy and the source attribution stay unit-testable.
|
|
301
|
+
*
|
|
302
|
+
* @param route - the route an unnamed spawn from this session would use.
|
|
303
|
+
* @param pinnedByGroup - whether a provider group (not the flat card) pinned it.
|
|
304
|
+
* @returns the footer line; undefined routes are stated as official inherit.
|
|
305
|
+
*/
|
|
306
|
+
function subagentDiscoveryFooter(route, pinnedByGroup) {
|
|
307
|
+
if (route === void 0) return "Default route for spawns that name no provider/model (Model Switch): official inherit (nothing pinned).";
|
|
308
|
+
const source = pinnedByGroup ? "provider group pin" : "fixed card";
|
|
309
|
+
const effort = route.reasoningEffort === void 0 ? "" : `, effort ${route.reasoningEffort}`;
|
|
310
|
+
return `Default route for spawns that name no provider/model (Model Switch, ${source}): ${route.provider}/${route.model}${effort}`;
|
|
311
|
+
}
|
|
312
|
+
/** Read the effective route and its source for one discovery execution. */
|
|
313
|
+
function discoveryRouteOf(ctx, exec) {
|
|
314
|
+
const session = sessionOfExec(exec);
|
|
315
|
+
let settings;
|
|
316
|
+
try {
|
|
317
|
+
const modelSwitch = ctx.get("modelSwitch");
|
|
318
|
+
settings = typeof modelSwitch?.currentSettings === "function" ? modelSwitch.currentSettings() : void 0;
|
|
319
|
+
} catch {
|
|
320
|
+
settings = void 0;
|
|
321
|
+
}
|
|
322
|
+
const route = sessionSubagentRouteOf(ctx, session, settings);
|
|
323
|
+
return {
|
|
324
|
+
route,
|
|
325
|
+
pinnedByGroup: route !== void 0 && groupRoute(settings, sessionProviderOf(ctx, session), "subagent") !== void 0
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Wrap the official discovery tool's execute so its text output also states the
|
|
330
|
+
* route an unnamed spawn would actually take — the one piece the
|
|
331
|
+
* authorized-route listing cannot know.
|
|
332
|
+
*
|
|
333
|
+
* The wrap is in place on the registered definition (the registry resolves
|
|
334
|
+
* tools per call), idempotent across re-sweeps, and re-applied when the
|
|
335
|
+
* registry changes so a re-registered tool is covered too. Unknown result
|
|
336
|
+
* shapes pass through untouched; unload restores the official execute.
|
|
337
|
+
*
|
|
338
|
+
* @param ctx - this row's context.
|
|
339
|
+
* @returns a disposer that detaches the listener and restores the execute.
|
|
340
|
+
*/
|
|
341
|
+
function installSubagentDiscoveryHint(ctx) {
|
|
342
|
+
const tools = ctx.get("tools", false);
|
|
343
|
+
if (tools === void 0 || typeof tools.get !== "function") {
|
|
344
|
+
warn(ctx, "model-switch: the tools registry is unavailable; list_subagent_models keeps its official output");
|
|
345
|
+
return () => {};
|
|
346
|
+
}
|
|
347
|
+
subagentDiscoveryHintStatus.installed = true;
|
|
348
|
+
const restores = [];
|
|
349
|
+
let wrappedOnce = false;
|
|
350
|
+
const sweep = () => {
|
|
351
|
+
const definition = tools.get(SUBAGENT_MODEL_DISCOVERY_TOOL);
|
|
352
|
+
if (definition === void 0) return;
|
|
353
|
+
const current = definition.execute;
|
|
354
|
+
if (typeof current !== "function" || Reflect.get(current, discoveryHintMarker) === true) return;
|
|
355
|
+
const restore = wrapMethod(definition, "execute", (original) => {
|
|
356
|
+
const wrapped = function(...args) {
|
|
357
|
+
const returned = Reflect.apply(original, this, args);
|
|
358
|
+
const append = (value) => {
|
|
359
|
+
if (typeof value !== "string") return value;
|
|
360
|
+
const { route, pinnedByGroup } = discoveryRouteOf(ctx, args[1]);
|
|
361
|
+
return `${value}\n${subagentDiscoveryFooter(route, pinnedByGroup)}`;
|
|
362
|
+
};
|
|
363
|
+
if (returned !== null && (typeof returned === "object" || typeof returned === "function") && typeof returned.then === "function") return returned.then(append);
|
|
364
|
+
return append(returned);
|
|
365
|
+
};
|
|
366
|
+
Object.defineProperty(wrapped, discoveryHintMarker, { value: true });
|
|
367
|
+
return wrapped;
|
|
368
|
+
});
|
|
369
|
+
if (restore !== void 0) {
|
|
370
|
+
restores.push(restore);
|
|
371
|
+
subagentDiscoveryHintStatus.toolWrapped = true;
|
|
372
|
+
if (!wrappedOnce) {
|
|
373
|
+
wrappedOnce = true;
|
|
374
|
+
try {
|
|
375
|
+
ctx.logger.info("model-switch: list_subagent_models now states the effective default route for unnamed spawns");
|
|
376
|
+
} catch {}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
sweep();
|
|
381
|
+
let attempts = 0;
|
|
382
|
+
const retry = setInterval(() => {
|
|
383
|
+
attempts += 1;
|
|
384
|
+
sweep();
|
|
385
|
+
if (wrappedOnce || attempts >= 15) clearInterval(retry);
|
|
386
|
+
}, 1e3);
|
|
387
|
+
const off = ctx.on("tools/change", sweep);
|
|
388
|
+
return () => {
|
|
389
|
+
off();
|
|
390
|
+
clearInterval(retry);
|
|
391
|
+
for (const restore of restores.reverse()) restore();
|
|
392
|
+
restores.length = 0;
|
|
393
|
+
subagentDiscoveryHintStatus.installed = false;
|
|
394
|
+
subagentDiscoveryHintStatus.toolWrapped = false;
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Wait for the official service without replacing it or copying its dependency
|
|
399
|
+
* list. Model Switch is read optionally per call, so its absence cannot hold a
|
|
400
|
+
* startup fiber or retain a stale settings service. Cordis rebinds this effect
|
|
401
|
+
* when the official service is recreated.
|
|
402
|
+
*/
|
|
403
|
+
function profileSubagentRuntime(ctx) {
|
|
404
|
+
ctx.inject(["subagents"], (scope) => {
|
|
405
|
+
scope.effect(() => installSubagentRouteWrappers(scope), "Model Switch: route official Subagent starts");
|
|
406
|
+
});
|
|
407
|
+
ctx.inject(["tools"], (scope) => {
|
|
408
|
+
scope.effect(() => installSubagentDiscoveryHint(scope), "Model Switch: annotate the subagent model discovery tool");
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
//#endregion
|
|
412
|
+
export { routedSubagentRequest as a, ModelSwitchSubagentRuntime as c, routedRuntimeUnavailableNotice as d, subagentRuntimeInject as f, routeSubagentRequest as i, StartupIncompatibilityError as l, installSubagentRouteWrappers as n, subagentDiscoveryFooter as o, subagentSurfaceOf as p, profileSubagentRuntime as r, subagentDiscoveryHintStatus as s, installSubagentDiscoveryHint as t, mountWithStartupFallback as u };
|