dsh-model-switch 0.4.62 → 0.4.64

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.
@@ -1,105 +1,22 @@
1
1
  import { o as sessionSubagentRouteOf } from "./session-route-D8izd8Zd.js";
2
+ import { symbols } from "@deepseek-ai/cordis";
2
3
  import { ReasoningEffortId } from "@deepseek-ai/dsh-llm";
3
4
  import OfficialSubagentRuntime from "@deepseek-ai/dsh-subagent";
4
- //#region lib/types/subagent-runtime.js
5
- /** Raised only when an explicit startup check finds an unsupported public surface. */
5
+ //#region lib/types/subagent-runtime-legacy.js
6
+ /** Previously published startup error; retained for consumers of this module. */
6
7
  var StartupIncompatibilityError = class extends Error {
7
8
  name = "StartupIncompatibilityError";
8
9
  surface;
9
- /**
10
- * @param surfaceOrMessage - the incompatible public surface, or the error message.
11
- * @param message - the missing or incompatible requirement.
12
- */
13
10
  constructor(surfaceOrMessage, message) {
14
11
  super(message ?? surfaceOrMessage);
15
12
  this.surface = message === void 0 ? "startup" : surfaceOrMessage;
16
13
  }
17
14
  };
18
- function present(value) {
19
- return typeof value === "string" && value.trim() !== "";
20
- }
21
- function spawnHasAnyRouteField(options) {
22
- return present(options?.provider) || present(options?.model) || options?.reasoningEffort !== void 0;
23
- }
24
- /**
25
- * Inject one resolved route into a spawn that names none.
26
- *
27
- * A spawn that already names a provider, model, or effort keeps it: the caller's
28
- * explicit selection outranks any profile policy. The route itself is derived
29
- * from the DELEGATING session (its provider selects a saved group, else the flat
30
- * Subagent card in `fixed` mode), so two sessions on different providers route
31
- * their own spawns and neither can rewrite the other's policy.
32
- * @param request - the caller's spawn request.
33
- * @param route - the delegating session's resolved route, or undefined for official inherit.
34
- * @returns The request to hand the official runtime.
35
- */
36
- function routeSubagentRequest(request, route) {
37
- if (spawnHasAnyRouteField(request.agentOptions)) return request;
38
- if (route === void 0) return request;
39
- return {
40
- ...request,
41
- agentOptions: {
42
- ...request.agentOptions,
43
- provider: route.provider,
44
- model: route.model,
45
- ...route.reasoningEffort === void 0 ? {} : { reasoningEffort: ReasoningEffortId(route.reasoningEffort) }
46
- }
47
- };
48
- }
49
- function assertPublicMethod(value, surface, method) {
50
- if (value === null || typeof value !== "object" && typeof value !== "function" || typeof Reflect.get(value, method) !== "function") throw new StartupIncompatibilityError(surface, surface + " must expose public " + method + "()");
51
- }
52
- /**
53
- * Classify the runtime surface this Host publishes.
54
- *
55
- * DSH 0.2.1 replaced `start()` / `startContinuable()` with the activation API
56
- * (`startActivation`), so a version-agnostic adapter has to recognize both
57
- * lines instead of hard-coding one.
58
- *
59
- * @param value - a runtime class's prototype or a mounted runtime instance.
60
- * @returns `activation` (0.2.1+), `start` (0.1.7/0.2.0), or undefined when neither is published.
61
- */
15
+ /** Classify the two published start API generations without version guessing. */
62
16
  function subagentSurfaceOf(value) {
63
17
  if (value === null || typeof value !== "object" && typeof value !== "function") return void 0;
64
18
  if (typeof Reflect.get(value, "startActivation") === "function") return "activation";
65
- const hasStart = typeof Reflect.get(value, "start") === "function";
66
- const hasContinuable = typeof Reflect.get(value, "startContinuable") === "function";
67
- return hasStart && hasContinuable ? "start" : void 0;
68
- }
69
- /** Read one public method, failing with the typed startup error when it is absent. */
70
- function publicMethod(prototype, surface, method) {
71
- if (prototype === null || typeof prototype !== "object" && typeof prototype !== "function") throw new StartupIncompatibilityError(surface, surface + " must expose public " + method + "()");
72
- const value = Reflect.get(prototype, method);
73
- if (typeof value !== "function") throw new StartupIncompatibilityError(surface, surface + " must expose public " + method + "()");
74
- return value;
75
- }
76
- function constructible(value) {
77
- if (typeof value !== "function") return false;
78
- try {
79
- Reflect.construct(Object, [], value);
80
- return true;
81
- } catch (error) {
82
- if (error instanceof TypeError) return false;
83
- throw error;
84
- }
85
- }
86
- function assertOfficialRuntimeSurface() {
87
- const runtime = OfficialSubagentRuntime;
88
- if (!constructible(runtime)) throw new StartupIncompatibilityError("OfficialSubagentRuntime", "OfficialSubagentRuntime must be constructible");
89
- const line = subagentSurfaceOf(Reflect.get(runtime, "prototype"));
90
- if (line === void 0) throw new StartupIncompatibilityError("OfficialSubagentRuntime", "OfficialSubagentRuntime must expose public startActivation() (0.2.1+) or start()/startContinuable()");
91
- return line;
92
- }
93
- function assertRoutingSurface(ctx) {
94
- assertPublicMethod(ctx.get("modelSwitch", false), "Model Switch runtime", "currentSettings");
95
- }
96
- function routingSurface(ctx) {
97
- return ctx.modelSwitch;
98
- }
99
- function assertMountedSurface(ctx) {
100
- const service = ctx.subagents;
101
- assertPublicMethod(service, "mounted Subagent runtime", "resolveMaxDepth");
102
- if (subagentSurfaceOf(service) === void 0) throw new StartupIncompatibilityError("mounted Subagent runtime", "mounted Subagent runtime must expose public startActivation() (0.2.1+) or start()/startContinuable()");
19
+ return typeof Reflect.get(value, "start") === "function" && typeof Reflect.get(value, "startContinuable") === "function" ? "start" : void 0;
103
20
  }
104
21
  function once(dispose) {
105
22
  let pending;
@@ -123,9 +40,9 @@ var CleanupLedger = class {
123
40
  return failures;
124
41
  }
125
42
  };
126
- function startupFailure(error, cleanupFailures) {
127
- if (cleanupFailures.length === 0) throw error;
128
- throw new AggregateError([error, ...cleanupFailures], "Subagent runtime startup and cleanup failed", { cause: error });
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 });
129
46
  }
130
47
  function cleanupDisposer(ledger) {
131
48
  return async () => {
@@ -133,19 +50,7 @@ function cleanupDisposer(ledger) {
133
50
  if (failures.length > 0) throw new AggregateError(failures, "Subagent runtime cleanup failed");
134
51
  };
135
52
  }
136
- /**
137
- * Mount a candidate and use the fallback only for typed startup incompatibility.
138
- *
139
- * Every resource registered by an attempt is disposed in reverse order before a
140
- * fallback starts and again when the mounted result is disposed. Cleanup keeps
141
- * running after failures, and a startup error stays first in any aggregate.
142
- *
143
- * @param candidate - startup callback for the routed candidate.
144
- * @param fallback - startup callback for the untouched official runtime.
145
- * @returns the selected value and an idempotent disposer.
146
- * @throws the candidate error unless it is a StartupIncompatibilityError.
147
- * @throws the fallback startup error when fallback startup fails.
148
- */
53
+ /** Retain the typed-only startup fallback and reverse, idempotent cleanup contract. */
149
54
  async function mountWithStartupFallback(candidate, fallback) {
150
55
  const ledger = new CleanupLedger();
151
56
  try {
@@ -154,9 +59,8 @@ async function mountWithStartupFallback(candidate, fallback) {
154
59
  dispose: cleanupDisposer(ledger)
155
60
  };
156
61
  } catch (error) {
157
- const cleanupFailures = await ledger.disposeAll();
158
- if (!(error instanceof StartupIncompatibilityError)) startupFailure(error, cleanupFailures);
159
- if (cleanupFailures.length > 0) startupFailure(error, cleanupFailures);
62
+ const failures = await ledger.disposeAll();
63
+ if (!(error instanceof StartupIncompatibilityError) || failures.length > 0) startupFailure(error, failures);
160
64
  }
161
65
  try {
162
66
  return {
@@ -167,120 +71,219 @@ async function mountWithStartupFallback(candidate, fallback) {
167
71
  startupFailure(error, await ledger.disposeAll());
168
72
  }
169
73
  }
170
- /**
171
- * Operator-facing notice for a Host whose Subagent runtime cannot be routed.
172
- *
173
- * DSH 0.2.1 replaced `start()`/`startContinuable()` with the activation API, so
174
- * this adapter's override point is gone; the row then mounts the untouched
175
- * official runtime instead of guessing a new seam.
176
- * @param error - the typed startup incompatibility that rejected the candidate.
177
- * @returns The notice logged once at startup.
178
- */
179
74
  function routedRuntimeUnavailableNotice(error) {
180
75
  return `model-switch: the routed Subagent runtime is unavailable on this DSH Host (${error.message}); delegation follows the official route instead`;
181
76
  }
182
- /** Log one notice without letting a missing logger service fail the startup. */
183
- function reportNotice(ctx, message) {
184
- try {
185
- ctx.logger.warn(message);
186
- } catch {}
77
+ /** @deprecated Only the legacy subclass needs a mirrored dependency list. */
78
+ function subagentRuntimeInject(officialInject) {
79
+ return [.../* @__PURE__ */ new Set([...officialInject ?? [], "modelSwitch"])];
187
80
  }
188
- async function mountProfileRuntime(ctx) {
189
- if (ctx.get("modelSwitch", false) === void 0) {
190
- reportNotice(ctx, "model-switch: the subagent runtime row is mounted without the modelSwitch service; subagent calls keep the official route");
191
- const official = ctx.plugin(OfficialSubagentRuntime);
192
- return async () => {
193
- await official.dispose();
194
- };
195
- }
196
- return (await mountWithStartupFallback(async (track) => {
197
- try {
198
- assertOfficialRuntimeSurface();
199
- } catch (error) {
200
- if (error instanceof StartupIncompatibilityError) reportNotice(ctx, routedRuntimeUnavailableNotice(error));
201
- throw error;
202
- }
203
- assertRoutingSurface(ctx);
204
- const candidate = ctx.plugin(ModelSwitchSubagentRuntime);
205
- track(() => candidate.dispose());
206
- await candidate;
207
- const surface = ctx.inject(["subagents"], (surfaceCtx) => {
208
- assertMountedSurface(surfaceCtx);
209
- });
210
- track(() => surface.dispose());
211
- await surface;
212
- return candidate;
213
- }, async (track) => {
214
- const official = ctx.plugin(OfficialSubagentRuntime);
215
- track(() => official.dispose());
216
- await official;
217
- return official;
218
- })).dispose;
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;
219
85
  }
220
- /** Profile replacement that selects the routed runtime or the untouched official runtime. */
221
- const profileSubagentRuntime = Object.assign(async (ctx) => mountProfileRuntime(ctx), {});
222
- /**
223
- * The services the official runtime declares for its own plugin.
224
- *
225
- * Subclassing keeps the official behavior, but cordis resolves a plugin's
226
- * `inject` from the class it mounts — a static list on this subclass *replaces*
227
- * the base class's list instead of adding to it. DSH 0.2.1's runtime declares
228
- * `workingDirectory` and reads it on every activation
229
- * (`ctx.workingDirectory.ensure(...)`); declaring only `modelSwitch` hid that
230
- * dependency, so every delegation failed with
231
- * `cannot get property "workingDirectory" without inject`. The list is read from
232
- * the installed runtime instead of hard-coded so a future Host dependency is
233
- * mirrored too.
234
- */
235
- const OFFICIAL_RUNTIME_INJECT = (() => {
236
- const declared = OfficialSubagentRuntime.inject;
237
- return Array.isArray(declared) ? [...declared] : [];
238
- })();
239
86
  /**
240
- * The plugin dependency list for the mounted runtime.
241
- *
242
- * Static inheritance does not merge `inject`: cordis reads the static list off
243
- * the class it mounts, so the subclass must repeat every service the official
244
- * runtime's own code reads and add the route surface this adapter uses.
245
- * @param officialInject - the installed runtime's declared dependencies (absent on 0.1.7/0.2.0).
246
- * @returns The deduplicated list, official dependencies first.
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.
247
90
  */
248
- function subagentRuntimeInject(officialInject) {
249
- return [.../* @__PURE__ */ new Set([...officialInject ?? [], "modelSwitch"])];
250
- }
251
- /** Official runtime with only a pre-descriptor route-selection adapter. */
252
91
  var ModelSwitchSubagentRuntime = class extends OfficialSubagentRuntime {
253
- static inject = subagentRuntimeInject(OFFICIAL_RUNTIME_INJECT);
92
+ static inject = subagentRuntimeInject(OfficialSubagentRuntime.inject);
254
93
  routed(name, request) {
255
94
  const provider = this.ctx.subagents.getProvider(name);
256
95
  if (provider !== void 0 && provider.capabilities.agentOptions !== true) return request;
257
- const modelSwitch = routingSurface(this.ctx);
258
- return routeSubagentRequest(request, sessionSubagentRouteOf(this.ctx, request.parent.session, modelSwitch.currentSettings()));
96
+ return routeSubagentRequest(request, sessionSubagentRouteOf(this.ctx, request.parent.session, this.ctx.modelSwitch.currentSettings()));
259
97
  }
260
98
  start(name, request) {
261
- return publicMethod(OfficialSubagentRuntime.prototype, "OfficialSubagentRuntime", "start").call(this, name, this.routed(name, request));
99
+ return Reflect.apply(publicMethod("start"), this, [name, this.routed(name, request)]);
262
100
  }
263
101
  startContinuable(spec) {
264
- return publicMethod(OfficialSubagentRuntime.prototype, "OfficialSubagentRuntime", "startContinuable").call(this, {
102
+ return Reflect.apply(publicMethod("startContinuable"), this, [{
265
103
  ...spec,
266
104
  request: this.routed(spec.provider, spec.request)
267
- });
105
+ }]);
268
106
  }
269
- /**
270
- * 0.2.1+ activation entry: delegation tools call this instead of
271
- * `start()`/`startContinuable()`, and its spec carries the same
272
- * `request.agentOptions` this adapter already rewrites. Every other spec
273
- * field (label, childId, signal, delivery) passes through untouched.
274
- *
275
- * @param spec - the activation spec published by the installed Host.
276
- * @returns The official activation result.
277
- */
278
107
  startActivation(spec) {
279
- return publicMethod(OfficialSubagentRuntime.prototype, "OfficialSubagentRuntime", "startActivation").call(this, {
108
+ const request = spec.request ?? spec;
109
+ return Reflect.apply(publicMethod("startActivation"), this, [{
280
110
  ...spec,
281
- request: this.routed(spec.provider, spec.request)
282
- });
111
+ request: this.routed(spec.provider, request)
112
+ }]);
283
113
  }
284
114
  };
285
115
  //#endregion
286
- export { ModelSwitchSubagentRuntime, StartupIncompatibilityError, profileSubagentRuntime as default, profileSubagentRuntime, mountWithStartupFallback, routeSubagentRequest, routedRuntimeUnavailableNotice, subagentRuntimeInject, subagentSurfaceOf };
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
+ /**
278
+ * Wait for the official service without replacing it or copying its dependency
279
+ * list. Model Switch is read optionally per call, so its absence cannot hold a
280
+ * startup fiber or retain a stale settings service. Cordis rebinds this effect
281
+ * when the official service is recreated.
282
+ */
283
+ function profileSubagentRuntime(ctx) {
284
+ ctx.inject(["subagents"], (scope) => {
285
+ scope.effect(() => installSubagentRouteWrappers(scope), "Model Switch: route official Subagent starts");
286
+ });
287
+ }
288
+ //#endregion
289
+ export { ModelSwitchSubagentRuntime, StartupIncompatibilityError, profileSubagentRuntime as default, profileSubagentRuntime, installSubagentRouteWrappers, mountWithStartupFallback, routeSubagentRequest, routedRuntimeUnavailableNotice, routedSubagentRequest, subagentRuntimeInject, subagentSurfaceOf };
@@ -0,0 +1,53 @@
1
+ /** Viewport placement result written imperatively onto the portaled menu. */
2
+ /**
3
+ * Viewport-edge clamps are emitted as CSS custom properties; the stylesheet
4
+ * composes them with the env(safe-area-inset-*) floors (see `.menu` in
5
+ * ComposerPicker.module.css):
6
+ *
7
+ * top: max(var(--dsh-menu-top), calc(env(safe-area-inset-top) + gutter));
8
+ * right: max(var(--dsh-menu-right), calc(env(safe-area-inset-right) + gutter));
9
+ * max-height: min(var(--dsh-menu-max-height), calc(100dvh - env(safe-area-inset-bottom) - env(safe-area-inset-top)));
10
+ *
11
+ * Numbers come from innerWidth/innerHeight, which exclude browser chrome but
12
+ * not display cutouts, so the stylesheet side of the max()/min() keeps the
13
+ * popup inside the safe area on notched phones.
14
+ */
15
+ export interface PopupPlacementStyle {
16
+ readonly '--dsh-menu-top': string;
17
+ readonly '--dsh-menu-right': string;
18
+ readonly '--dsh-menu-max-height': string;
19
+ readonly visibility: 'visible';
20
+ }
21
+ export declare function samePlacement(left: PopupPlacementStyle | undefined, right: PopupPlacementStyle): boolean;
22
+ export interface PopupPlacementInput {
23
+ readonly trigger: {
24
+ readonly left: number;
25
+ readonly right: number;
26
+ readonly top: number;
27
+ readonly bottom: number;
28
+ };
29
+ readonly menu: {
30
+ readonly width: number;
31
+ readonly height: number;
32
+ };
33
+ readonly viewport: {
34
+ readonly width: number;
35
+ readonly height: number;
36
+ };
37
+ readonly gutter?: number;
38
+ }
39
+ /**
40
+ * Position the portaled picker menu in viewport coordinates, right-aligned to
41
+ * its trigger and preferring the space above it, clamped to the viewport.
42
+ */
43
+ /**
44
+ * Position the portaled picker menu in viewport coordinates, right-aligned to
45
+ * its trigger and preferring the space above it, clamped to the viewport.
46
+ *
47
+ * The height clamp is the viewport budget only (never a content measurement):
48
+ * the stylesheet caps the box at that budget, so taller menu panes grow into
49
+ * it naturally and a later ResizeObserver pass only re-reads the rendered box
50
+ * to re-anchor the trigger edge. Capping from the measured box would instead
51
+ * lock the menu at whatever height it first rendered with.
52
+ */
53
+ export declare function placeComposerPopup({ trigger, menu, viewport, gutter }: PopupPlacementInput): PopupPlacementStyle;
@@ -1,4 +1,4 @@
1
- import { type CSSProperties, type MouseEvent as ReactMouseEvent, type PointerEvent as ReactPointerEvent, type RefObject } from 'react';
1
+ import { type MouseEvent as ReactMouseEvent, type PointerEvent as ReactPointerEvent, type RefObject } from 'react';
2
2
  import { type PickerInteractionOperations } from './popup-dismissal.ts';
3
3
  export interface ComposerPickerSurfaceOptions {
4
4
  locked: boolean;
@@ -13,7 +13,6 @@ export interface ComposerPickerSurfaceOptions {
13
13
  export interface ComposerPickerSurface {
14
14
  id: string;
15
15
  open: boolean;
16
- menuStyle: CSSProperties;
17
16
  triggerRef: RefObject<HTMLButtonElement>;
18
17
  menuRef: RefObject<HTMLDivElement>;
19
18
  show: () => void;
@@ -21,5 +20,5 @@ export interface ComposerPickerSurface {
21
20
  onTriggerPointerDown: (event: ReactPointerEvent<HTMLButtonElement>) => void;
22
21
  onTriggerClick: (event?: ReactMouseEvent<HTMLButtonElement>) => void;
23
22
  }
24
- /** Own popup activation, positioning, and dismissal behind one internal seam. */
23
+ /** Own popup activation, viewport placement, and dismissal behind one internal seam. */
25
24
  export declare function useComposerPickerSurface(options: ComposerPickerSurfaceOptions): ComposerPickerSurface;
@@ -0,0 +1,34 @@
1
+ import OfficialSubagentRuntime, { type ContinuableStart, type ContinuableStartSpec, type SubagentRun, type SubagentStartRequest } from '@deepseek-ai/dsh-subagent';
2
+ import { type SubagentActivationSpecLike } from './subagent-runtime.js';
3
+ /** Previously published startup error; retained for consumers of this module. */
4
+ export declare class StartupIncompatibilityError extends Error {
5
+ readonly name = "StartupIncompatibilityError";
6
+ readonly surface: string;
7
+ constructor(surfaceOrMessage: string, message?: string);
8
+ }
9
+ export type StartupDisposer = () => void | PromiseLike<void>;
10
+ export type StartupCleanupTracker = (dispose: StartupDisposer) => void;
11
+ export interface MountedStartup<T> {
12
+ readonly value: T;
13
+ readonly dispose: () => Promise<void>;
14
+ }
15
+ export type SubagentSurfaceLine = 'activation' | 'start';
16
+ /** Classify the two published start API generations without version guessing. */
17
+ export declare function subagentSurfaceOf(value: unknown): SubagentSurfaceLine | undefined;
18
+ /** Retain the typed-only startup fallback and reverse, idempotent cleanup contract. */
19
+ export declare function mountWithStartupFallback<T>(candidate: (track: StartupCleanupTracker) => Promise<T>, fallback: (track: StartupCleanupTracker) => Promise<T>): Promise<MountedStartup<T>>;
20
+ export declare function routedRuntimeUnavailableNotice(error: StartupIncompatibilityError): string;
21
+ /** @deprecated Only the legacy subclass needs a mirrored dependency list. */
22
+ export declare function subagentRuntimeInject(officialInject: readonly string[] | undefined): string[];
23
+ /**
24
+ * @deprecated Kept importable for existing consumers, not mounted by the bundle.
25
+ * Install profileSubagentRuntime around the official service instead: the
26
+ * official Loader row must remain enabled to own its strict Typert definitions.
27
+ */
28
+ export declare class ModelSwitchSubagentRuntime extends OfficialSubagentRuntime {
29
+ static inject: string[];
30
+ private routed;
31
+ start(name: string, request: SubagentStartRequest): Promise<SubagentRun>;
32
+ startContinuable(spec: ContinuableStartSpec): Promise<ContinuableStart>;
33
+ startActivation(spec: SubagentActivationSpecLike): Promise<unknown>;
34
+ }