dsh-model-switch 0.4.60 → 0.4.62

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 CHANGED
@@ -1,3 +1,25 @@
1
+ ## v0.4.62
2
+
3
+ 修复设置页「模型目录偶发加载失败后整个页面卡死」的问题:两个会话在不同供应商上并行、后台任务(如记忆蒸馏)恰在加载瞬间占用 Host 时,`session/modelCatalog` 的一次瞬时失败会把设置页永久留在空目录状态——供应商配置组下拉里所有供应商都带 ⚠、模型下拉没有选项、依赖目录的开关全部禁用,只能重开设置页恢复。
4
+
5
+ - **根因**:`useSettingsCatalog` 只在挂载与供应商排序变化时各加载一次,`.catch()` 只设置错误文案、`groups` 保持 `[]`,没有任何重试或刷新入口。空目录时 `groupProviderChoices` 把每个已配置供应商追加为 `unavailable ⚠`,且宿主目录响应里的 `failures`(哪些供应商只是暂时加载失败)被客户端整个丢弃,"暂时不可用"被渲染成"已删除"。
6
+ - **修复(`src/client/main-row-controller.ts`)**:目录加载改为状态机 `loading / ready / failed`——失败后按 400ms / 1200ms 退避重试(共 3 次尝试),重试成功即自愈;**失败时保留最近一次成功的 groups**(不再把可用目录清空);只有最新一次加载可以落地(取消的加载被丢弃)。新增 `withCatalogFailures()` 把宿主 `failures` 合并为无模型的供应商条目:这些供应商保持可选(不再显示 ⚠),但不发明模型行(种子逻辑因 `models[0]` 为空自动跳过)。`src/client/index.tsx` 的 `loadCatalog` 现在把 `failures` 与 `groups` 一起返回。
7
+ - **UI(`src/client/ModelSwitchSettings.tsx`)**:目录失败时显示明确提示与「重试」按钮;从未加载成功时显示原始失败文案,还留着上一次成功目录时显示"目录暂时不可用(已保存的组仍可编辑)";初始加载期显示"正在加载模型目录…"。供应商配置组的「删除该组」与已选组编辑在目录失败期间保持可用;依赖模型种子的能力开关语义不变(目录为空仍禁用,防误点)。
8
+ - **测试**:`tests/client-controller.spec.ts` 新增 8 条(failures 合并去重、空名回退 id、失败供应商在组编辑器可选、重试助手的首试即成/退避重试/预算用尽抛最后错误/取消即停);`tests/settings-ui.client.spec.tsx` 新增 4 条(加载提示、失败重试按钮触发 reload、残留组可编辑可删除、宿主报失败的供应商不带 ⚠ 且可删除)。`pnpm run check` 全绿(tsc + tsdown + 656 测试 + pack 闸门)。
9
+
10
+ ## v0.4.61
11
+
12
+ 修复 DSH 0.2.1 上**子代理与团队通道全部不可用**的 P0:`spawn_teammate` / `subagent` 一律失败,报 `cannot get property "workingDirectory" without inject`。
13
+
14
+ - **根因**:`ModelSwitchSubagentRuntime` 继承官方 `@deepseek-ai/dsh-subagent` 的运行时并覆写路由;cordis 解析插件依赖时读的是**被挂载类自己的** `inject`,子类的 `static inject = ['modelSwitch']` 会**整体替换**而不是合并基类列表。DSH 0.2.1 起官方运行时声明并读取 `workingDirectory`(`ctx.workingDirectory.ensure(...)`),这一依赖被替换掉后,任何一次委派都在 cordis 的注入检查处抛出上述错误。这与 0.4.28 修过的自动审查门禁是同一类缺陷(覆写官方代码却手工镜像 `inject`)。
15
+ - **修复**:`src/subagent-runtime.ts` 新增 `subagentRuntimeInject()`,从**已安装的官方运行时**读取 `inject` 声明并与 `modelSwitch` 去重合并,子类改用该函数生成列表——官方新增依赖会被自动镜像,不再过时;基类在 0.1.7/0.2.0 没有该声明时退回 `['modelSwitch']`。`tests/subagent-runtime.spec.ts` 新增 4 条守卫(镜像基类列表、无声明时保留路由服务、去重、挂载列表与已安装运行时一致)。
16
+ - **验证(virtual / 零真实额度)**:DSH `0.2.1-rc.5` lab 的 headless profile(真实宿主 + 虚拟探针 4731,模型回放一次 `subagent` 工具调用)。发布版 **0.4.60** 复现:工具结果为 `Error: cannot get property "workingDirectory" without inject`(会话 `session-f783b457`);装本修复构建后同一回放得到 `started subagent 4b1d65b1-1b91-4b41-a144-41cc7617e039`(`isError:false`,会话 `session-8ea93988`,探针记录 `D:\dsh-artifacts\probe-subagent.jsonl`)。自动审查/命名/记忆等其它接管行未改动。
17
+ - **残余**:0.4.61 装到桌面 profile 后需实际点一次子代理/团队委派确认(桌面宿主无法在 lab 内复刻)。0.1.7 / 0.2.0 的 `start()` 线依赖列表照旧合并,语义不变。
18
+
19
+ ## Unreleased
20
+
21
+ - **兼容巡检(2026-11-02,仅文档)**:DSH `latest` 仍是 `0.2.1-rc.5`(未移动,10-30/31 的验收结论继续有效);`dsh-prime-memory` 从 **0.26.16 移到 0.26.24**,其 `engines.dsh` 含 rc.5,已在 rc.5 lab + 本插件 0.4.60 下跑完七项接入检查(行激活、适配推送落地、无 `llm:` 静态钉、`settings-set` 读回、`effectiveCfg` 单测 9/9、免重启改路由 `replays:1→2`、蒸馏走新路由)。`docs/compat-watch-state.json` 记录 0.26.24 为已验证版本。**无代码改动,不发版。**
22
+
1
23
  ## v0.4.60
2
24
 
3
25
  纯读免审查默认名单扩展到 **84 条**(2026-11-01,按桌面端实际安装的插件重新校准)。
package/lib/client.js CHANGED
@@ -1141,8 +1141,10 @@ window.__ModuleLoader__.load({
1141
1141
  * catalog-only list makes that group unreachable: the row stays stored, no
1142
1142
  * selection can open it, and nothing can delete it. Union in every configured
1143
1143
  * group's provider and mark the missing ones unavailable so the editor can still
1144
- * open and remove them.
1145
- * @param groups - the live model catalog.
1144
+ * open and remove them. Feed this the merged list from `withCatalogFailures` so
1145
+ * a provider that merely failed to load stays selectable instead of looking
1146
+ * deleted.
1147
+ * @param groups - the live model catalog merged with the host's load failures.
1146
1148
  * @param configured - provider ids that still have a stored group.
1147
1149
  * @param current - the group being edited, kept listed even when it is unknown.
1148
1150
  * @returns catalog choices first (original order), then the missing providers.
@@ -1161,38 +1163,110 @@ window.__ModuleLoader__.load({
1161
1163
  }
1162
1164
  return choices;
1163
1165
  }
1164
- /** Load the model catalog backing every route editor, reloading on provider-order changes. */
1166
+ /** Backoff between catalog retries: a busy Host clears within seconds, not minutes. */
1167
+ const CATALOG_RETRY_DELAYS_MS = [400, 1200];
1168
+ /**
1169
+ * Load the model catalog with bounded backoff.
1170
+ *
1171
+ * The catalog RPC is one read against a live Host; a transient failure (a busy
1172
+ * Host, a reconnecting remote, a background task saturating the provider
1173
+ * lookups) must recover on its own instead of leaving the settings page stuck
1174
+ * on an empty catalog. Each attempt re-runs `load`; a cancelled load rethrows
1175
+ * the last error without further attempts.
1176
+ */
1177
+ async function loadCatalogWithRetry(load, options = {}) {
1178
+ const attempts = options.attempts ?? 3;
1179
+ const delaysMs = options.delaysMs ?? CATALOG_RETRY_DELAYS_MS;
1180
+ const sleep = options.sleep ?? ((ms) => new Promise((resolve) => {
1181
+ setTimeout(resolve, ms);
1182
+ }));
1183
+ let lastError;
1184
+ for (let attempt = 0; attempt < attempts; attempt += 1) {
1185
+ if (attempt > 0) await sleep(delaysMs[Math.min(attempt - 1, delaysMs.length - 1)] ?? 0);
1186
+ if (options.cancelled?.() === true) break;
1187
+ try {
1188
+ return await load();
1189
+ } catch (error) {
1190
+ lastError = error;
1191
+ }
1192
+ }
1193
+ throw lastError instanceof Error ? lastError : /* @__PURE__ */ new Error("catalog load failed");
1194
+ }
1195
+ /**
1196
+ * Merge the host's load failures into the catalog as model-less groups.
1197
+ *
1198
+ * A failed provider is KNOWN (the Host listed it) but temporarily unavailable.
1199
+ * Rendering it as absent would mark every stored route for it "unavailable ⚠"
1200
+ * and lock the provider-group editor while a background task hiccups. A
1201
+ * model-less group keeps the provider selectable without inventing model rows;
1202
+ * seeding logic skips it because `models[0]` is undefined.
1203
+ */
1204
+ function withCatalogFailures(groups, failures) {
1205
+ const known = new Set(groups.map((group) => group.id));
1206
+ const extra = failures.filter((failure) => failure.id.trim() !== "" && !known.has(failure.id)).map((failure) => ({
1207
+ id: failure.id,
1208
+ name: failure.name.trim() === "" ? failure.id : failure.name,
1209
+ models: []
1210
+ }));
1211
+ return [...groups, ...extra];
1212
+ }
1213
+ /**
1214
+ * Load the model catalog backing every route editor, with bounded retries.
1215
+ *
1216
+ * A failed load keeps the last successful groups (the editor stays usable and
1217
+ * honest via the error hint) instead of collapsing to an empty catalog; a
1218
+ * provider-order change or `reload()` starts a fresh attempt, and only the
1219
+ * newest attempt may land.
1220
+ */
1165
1221
  function useSettingsCatalog(input) {
1166
- const [groups, setGroups] = (0, react.useState)([]);
1167
- const [catalogError, setCatalogError] = (0, react.useState)();
1168
- (0, react.useEffect)(() => {
1169
- let live = true;
1170
- const load = () => {
1171
- input.loadCatalog().then((value) => {
1172
- if (live) {
1173
- setGroups(value);
1174
- setCatalogError(void 0);
1175
- }
1176
- }).catch(() => {
1177
- if (live) setCatalogError(input.t("catalogFailed"));
1222
+ const [state, setState] = (0, react.useState)({
1223
+ status: "loading",
1224
+ groups: [],
1225
+ failures: [],
1226
+ error: void 0
1227
+ });
1228
+ const latest = (0, react.useRef)(input);
1229
+ latest.current = input;
1230
+ const runRef = (0, react.useRef)(0);
1231
+ const run = (0, react.useCallback)(() => {
1232
+ const runId = runRef.current + 1;
1233
+ runRef.current = runId;
1234
+ setState((previous) => ({
1235
+ ...previous,
1236
+ status: "loading"
1237
+ }));
1238
+ loadCatalogWithRetry(() => latest.current.loadCatalog(), { cancelled: () => runId !== runRef.current }).then((payload) => {
1239
+ if (runId !== runRef.current) return;
1240
+ setState({
1241
+ status: "ready",
1242
+ groups: withCatalogFailures(payload.groups, payload.failures),
1243
+ failures: payload.failures,
1244
+ error: void 0
1178
1245
  });
1179
- };
1180
- load();
1181
- const stop = input.subscribeProviderOrder?.(() => {
1182
- if (live) load();
1246
+ }).catch(() => {
1247
+ if (runId !== runRef.current) return;
1248
+ setState((previous) => ({
1249
+ ...previous,
1250
+ status: "failed",
1251
+ error: latest.current.t("catalogFailed")
1252
+ }));
1253
+ });
1254
+ }, []);
1255
+ const subscribeRef = (0, react.useRef)(input.subscribeProviderOrder);
1256
+ subscribeRef.current = input.subscribeProviderOrder;
1257
+ (0, react.useEffect)(() => {
1258
+ run();
1259
+ const stop = subscribeRef.current?.(() => {
1260
+ run();
1183
1261
  });
1184
1262
  return () => {
1185
- live = false;
1263
+ runRef.current += 1;
1186
1264
  stop?.();
1187
1265
  };
1188
- }, [
1189
- input.loadCatalog,
1190
- input.subscribeProviderOrder,
1191
- input.t
1192
- ]);
1266
+ }, [run]);
1193
1267
  return {
1194
- groups,
1195
- catalogError
1268
+ ...state,
1269
+ reload: run
1196
1270
  };
1197
1271
  }
1198
1272
  //#endregion
@@ -1650,7 +1724,7 @@ window.__ModuleLoader__.load({
1650
1724
  return choices;
1651
1725
  }
1652
1726
  function ModelSwitchSettings(props) {
1653
- const { groups, catalogError } = useSettingsCatalog(props);
1727
+ const { groups, status: catalogStatus, error: catalogError, reload: reloadCatalog } = useSettingsCatalog(props);
1654
1728
  const subagent = props.useSubagentSettings((value) => value);
1655
1729
  const search = props.useSearchSettings((value) => value);
1656
1730
  const image = props.useImageSettings((value) => value);
@@ -2289,9 +2363,21 @@ window.__ModuleLoader__.load({
2289
2363
  className: ModelSwitchSettings_module_css_default.saved,
2290
2364
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", { className: ModelSwitchSettings_module_css_default.savedDot }), synced ? props.t("settingsSynced") : props.t("loading")]
2291
2365
  }),
2292
- catalogError === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2366
+ catalogError === void 0 ? catalogStatus === "loading" && groups.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2367
+ className: ModelSwitchSettings_module_css_default.hint,
2368
+ children: props.t("catalogLoading")
2369
+ }) : null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
2293
2370
  className: cx(ModelSwitchSettings_module_css_default.hint, ModelSwitchSettings_module_css_default.message),
2294
- children: catalogError
2371
+ children: [
2372
+ groups.length === 0 ? catalogError : props.t("catalogUnavailableHint"),
2373
+ " ",
2374
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2375
+ type: "button",
2376
+ className: cx(ModelSwitchSettings_module_css_default.button, ModelSwitchSettings_module_css_default.secondaryButton),
2377
+ onClick: reloadCatalog,
2378
+ children: props.t("catalogRetry")
2379
+ })
2380
+ ]
2295
2381
  }),
2296
2382
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2297
2383
  className: ModelSwitchSettings_module_css_default.group,
@@ -3397,6 +3483,9 @@ window.__ModuleLoader__.load({
3397
3483
  loading: "正在加载设置…",
3398
3484
  requestFailed: "保存失败",
3399
3485
  catalogFailed: "无法加载模型目录。",
3486
+ catalogLoading: "正在加载模型目录…",
3487
+ catalogRetry: "重试",
3488
+ catalogUnavailableHint: "模型目录暂时不可用(后台任务繁忙或 Host 忙碌时会偶发);已显示的供应商与已保存的组仍可编辑,也可点击重试。",
3400
3489
  autoReview: "自动审查模型",
3401
3490
  autoReviewFollow: "跟随会话模型",
3402
3491
  autoReviewHelp: "为官方 auto-review(Auto 权限预设的逐调用审查)指定审查模型;需启用官方 auto-review 能力包。关闭时审查跟随当前会话模型。本插件启用时,官方「自动审查」组件由本插件接管。",
@@ -3494,6 +3583,9 @@ window.__ModuleLoader__.load({
3494
3583
  loading: "Loading settings…",
3495
3584
  requestFailed: "Save failed",
3496
3585
  catalogFailed: "Could not load the model catalog.",
3586
+ catalogLoading: "Loading the model catalog…",
3587
+ catalogRetry: "Retry",
3588
+ catalogUnavailableHint: "The model catalog is temporarily unavailable (it can hiccup while a background task or the Host is busy); the providers shown and saved groups stay editable, or retry now.",
3497
3589
  autoReview: "Auto review model",
3498
3590
  autoReviewFollow: "Follows the session model",
3499
3591
  autoReviewHelp: "Pin the reviewer model for the official auto-review gate (per-call review under the Auto permission preset). Requires the official auto-review bundle. When off, reviews follow the session model. With this plugin enabled the official auto-review component is taken over.",
@@ -6259,7 +6351,10 @@ window.__ModuleLoader__.load({
6259
6351
  if (!response.ok || response.value === void 0) throw new Error(t("catalogFailed"));
6260
6352
  const enabled = await fetchAntigravityCatalogGroups(connectionRpc);
6261
6353
  const order = orderStore.getSnapshot();
6262
- return sortCatalogGroupsWithRoutes(withAntigravityCatalog(response.value.groups, enabled), order, readCatalogRoutes(directory));
6354
+ return {
6355
+ groups: sortCatalogGroupsWithRoutes(withAntigravityCatalog(response.value.groups, enabled), order, readCatalogRoutes(directory)),
6356
+ failures: response.value.failures
6357
+ };
6263
6358
  },
6264
6359
  ...connectionRpc === void 0 ? {} : { loadCapabilities: async (revision, signal) => {
6265
6360
  const rpc = connectionRpc;
@@ -219,9 +219,38 @@ async function mountProfileRuntime(ctx) {
219
219
  }
220
220
  /** Profile replacement that selects the routed runtime or the untouched official runtime. */
221
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
+ /**
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.
247
+ */
248
+ function subagentRuntimeInject(officialInject) {
249
+ return [.../* @__PURE__ */ new Set([...officialInject ?? [], "modelSwitch"])];
250
+ }
222
251
  /** Official runtime with only a pre-descriptor route-selection adapter. */
223
252
  var ModelSwitchSubagentRuntime = class extends OfficialSubagentRuntime {
224
- static inject = ["modelSwitch"];
253
+ static inject = subagentRuntimeInject(OFFICIAL_RUNTIME_INJECT);
225
254
  routed(name, request) {
226
255
  const provider = this.ctx.subagents.getProvider(name);
227
256
  if (provider !== void 0 && provider.capabilities.agentOptions !== true) return request;
@@ -254,4 +283,4 @@ var ModelSwitchSubagentRuntime = class extends OfficialSubagentRuntime {
254
283
  }
255
284
  };
256
285
  //#endregion
257
- export { ModelSwitchSubagentRuntime, StartupIncompatibilityError, profileSubagentRuntime as default, profileSubagentRuntime, mountWithStartupFallback, routeSubagentRequest, routedRuntimeUnavailableNotice, subagentSurfaceOf };
286
+ export { ModelSwitchSubagentRuntime, StartupIncompatibilityError, profileSubagentRuntime as default, profileSubagentRuntime, mountWithStartupFallback, routeSubagentRequest, routedRuntimeUnavailableNotice, subagentRuntimeInject, subagentSurfaceOf };
@@ -1,5 +1,4 @@
1
1
  import { type ReactNode } from 'react';
2
- import type { ModelProviderGroup } from '@deepseek-ai/dsh-api-session-controller/types';
3
2
  import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client';
4
3
  import type { InjectFace, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
5
4
  import { type CapabilityRouteView, type ModelSwitchSettingsView, type ReviewStatusView, type SubagentSettingsView, type ToolCatalogRow } from '../client-contract.js';
@@ -7,6 +6,7 @@ import { type ProviderGroupConfig } from '../provider-group.js';
7
6
  import type { RuntimeCapabilities } from '../runtime-capabilities.js';
8
7
  import { type CapabilitiesSnapshot } from './search-capabilities.js';
9
8
  import type { ModelSwitchLocaleKey } from './locales.js';
9
+ import { type SettingsCatalogPayload } from './main-row-controller.js';
10
10
  import type { ConfigViewForm, ConfigViewOp } from './derived-config-form.js';
11
11
  export interface ModelSwitchSettingsFace {
12
12
  t: (key: ModelSwitchLocaleKey) => string;
@@ -41,7 +41,7 @@ export interface ModelSwitchSettingsFace {
41
41
  }>;
42
42
  /** Replace or remove (undefined) one provider's saved capability group. */
43
43
  saveProviderGroup: (provider: string, group: ProviderGroupConfig | undefined) => Promise<void>;
44
- loadCatalog: () => Promise<readonly ModelProviderGroup[]>;
44
+ loadCatalog: () => Promise<SettingsCatalogPayload>;
45
45
  /** Host capabilities long-poll; absent in legacy faces, which keep the static-capabilities path. */
46
46
  loadCapabilities?: (revision?: number, signal?: AbortSignal) => Promise<CapabilitiesSnapshot>;
47
47
  subscribeProviderOrder?: (listener: () => void) => () => void;
@@ -28,6 +28,9 @@ export declare const zh: {
28
28
  readonly loading: "正在加载设置…";
29
29
  readonly requestFailed: "保存失败";
30
30
  readonly catalogFailed: "无法加载模型目录。";
31
+ readonly catalogLoading: "正在加载模型目录…";
32
+ readonly catalogRetry: "重试";
33
+ readonly catalogUnavailableHint: "模型目录暂时不可用(后台任务繁忙或 Host 忙碌时会偶发);已显示的供应商与已保存的组仍可编辑,也可点击重试。";
31
34
  readonly autoReview: "自动审查模型";
32
35
  readonly autoReviewFollow: "跟随会话模型";
33
36
  readonly autoReviewHelp: "为官方 auto-review(Auto 权限预设的逐调用审查)指定审查模型;需启用官方 auto-review 能力包。关闭时审查跟随当前会话模型。本插件启用时,官方「自动审查」组件由本插件接管。";
@@ -1,4 +1,4 @@
1
- import type { ModelProviderGroup } from '@deepseek-ai/dsh-api-session-controller/types';
1
+ import type { ModelCatalogFailure, ModelProviderGroup } from '@deepseek-ai/dsh-api-session-controller/types';
2
2
  import type { CapabilityRouteView } from '../client-contract.js';
3
3
  import type { ModelSwitchLocaleKey } from './locales.js';
4
4
  export interface Choice {
@@ -25,20 +25,74 @@ export declare function deriveRouteChoices(groups: readonly ModelProviderGroup[]
25
25
  * catalog-only list makes that group unreachable: the row stays stored, no
26
26
  * selection can open it, and nothing can delete it. Union in every configured
27
27
  * group's provider and mark the missing ones unavailable so the editor can still
28
- * open and remove them.
29
- * @param groups - the live model catalog.
28
+ * open and remove them. Feed this the merged list from `withCatalogFailures` so
29
+ * a provider that merely failed to load stays selectable instead of looking
30
+ * deleted.
31
+ * @param groups - the live model catalog merged with the host's load failures.
30
32
  * @param configured - provider ids that still have a stored group.
31
33
  * @param current - the group being edited, kept listed even when it is unknown.
32
34
  * @returns catalog choices first (original order), then the missing providers.
33
35
  */
34
36
  export declare function groupProviderChoices(groups: readonly ModelProviderGroup[], configured: readonly string[], current: string | undefined): Choice[];
37
+ /** One provider whose model catalog lookup failed on the Host (`ModelCatalogFailure`). */
38
+ export type CatalogFailure = ModelCatalogFailure;
39
+ /** What one catalog load resolves with: successful groups plus the host's isolated failures. */
40
+ export interface SettingsCatalogPayload {
41
+ readonly groups: readonly ModelProviderGroup[];
42
+ readonly failures: readonly CatalogFailure[];
43
+ }
44
+ /** How many attempts one catalog load makes before the settings page gives up. */
45
+ export declare const CATALOG_LOAD_ATTEMPTS = 3;
46
+ /** Backoff between catalog retries: a busy Host clears within seconds, not minutes. */
47
+ export declare const CATALOG_RETRY_DELAYS_MS: readonly number[];
48
+ export interface CatalogRetryOptions {
49
+ attempts?: number;
50
+ delaysMs?: readonly number[];
51
+ sleep?: (ms: number) => Promise<void>;
52
+ cancelled?: () => boolean;
53
+ }
54
+ /**
55
+ * Load the model catalog with bounded backoff.
56
+ *
57
+ * The catalog RPC is one read against a live Host; a transient failure (a busy
58
+ * Host, a reconnecting remote, a background task saturating the provider
59
+ * lookups) must recover on its own instead of leaving the settings page stuck
60
+ * on an empty catalog. Each attempt re-runs `load`; a cancelled load rethrows
61
+ * the last error without further attempts.
62
+ */
63
+ export declare function loadCatalogWithRetry(load: () => Promise<SettingsCatalogPayload>, options?: CatalogRetryOptions): Promise<SettingsCatalogPayload>;
64
+ /**
65
+ * Merge the host's load failures into the catalog as model-less groups.
66
+ *
67
+ * A failed provider is KNOWN (the Host listed it) but temporarily unavailable.
68
+ * Rendering it as absent would mark every stored route for it "unavailable ⚠"
69
+ * and lock the provider-group editor while a background task hiccups. A
70
+ * model-less group keeps the provider selectable without inventing model rows;
71
+ * seeding logic skips it because `models[0]` is undefined.
72
+ */
73
+ export declare function withCatalogFailures(groups: readonly ModelProviderGroup[], failures: readonly CatalogFailure[]): ModelProviderGroup[];
74
+ export type SettingsCatalogStatus = 'loading' | 'ready' | 'failed';
75
+ export interface SettingsCatalogState {
76
+ status: SettingsCatalogStatus;
77
+ /** Live groups merged with the host's load failures; the last good list survives a later failure. */
78
+ groups: readonly ModelProviderGroup[];
79
+ failures: readonly CatalogFailure[];
80
+ /** Localized failure message; undefined while loading or ready. */
81
+ error: string | undefined;
82
+ /** Reload now (used by the retry button and provider-order changes). */
83
+ reload(): void;
84
+ }
35
85
  export interface SettingsCatalogInputs {
36
- loadCatalog(): Promise<readonly ModelProviderGroup[]>;
86
+ loadCatalog(): Promise<SettingsCatalogPayload>;
37
87
  subscribeProviderOrder?: (listener: () => void) => () => void;
38
88
  t(key: ModelSwitchLocaleKey): string;
39
89
  }
40
- /** Load the model catalog backing every route editor, reloading on provider-order changes. */
41
- export declare function useSettingsCatalog(input: SettingsCatalogInputs): {
42
- groups: readonly ModelProviderGroup[];
43
- catalogError: string | undefined;
44
- };
90
+ /**
91
+ * Load the model catalog backing every route editor, with bounded retries.
92
+ *
93
+ * A failed load keeps the last successful groups (the editor stays usable and
94
+ * honest via the error hint) instead of collapsing to an empty catalog; a
95
+ * provider-order change or `reload()` starts a fresh attempt, and only the
96
+ * newest attempt may land.
97
+ */
98
+ export declare function useSettingsCatalog(input: SettingsCatalogInputs): SettingsCatalogState;
@@ -86,6 +86,16 @@ export declare function mountWithStartupFallback<T>(candidate: (track: StartupCl
86
86
  export declare function routedRuntimeUnavailableNotice(error: StartupIncompatibilityError): string;
87
87
  /** Profile replacement that selects the routed runtime or the untouched official runtime. */
88
88
  export declare const profileSubagentRuntime: (ctx: Context) => Promise<() => Promise<void>>;
89
+ /**
90
+ * The plugin dependency list for the mounted runtime.
91
+ *
92
+ * Static inheritance does not merge `inject`: cordis reads the static list off
93
+ * the class it mounts, so the subclass must repeat every service the official
94
+ * runtime's own code reads and add the route surface this adapter uses.
95
+ * @param officialInject - the installed runtime's declared dependencies (absent on 0.1.7/0.2.0).
96
+ * @returns The deduplicated list, official dependencies first.
97
+ */
98
+ export declare function subagentRuntimeInject(officialInject: readonly string[] | undefined): string[];
89
99
  /** Official runtime with only a pre-descriptor route-selection adapter. */
90
100
  export declare class ModelSwitchSubagentRuntime extends OfficialSubagentRuntime {
91
101
  static inject: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-model-switch",
3
- "version": "0.4.60",
3
+ "version": "0.4.62",
4
4
  "description": "Explicit model routing plus composer/Plan picker for DeepSeek Harness",
5
5
  "repository": {
6
6
  "type": "git",