dsh-model-switch 0.4.69 → 0.4.71

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,27 @@
1
+ ## v0.4.71
2
+
3
+ 修复设置页供应商下拉中 DVR 孪生路由仍与基座成对出现的问题(桌面 0.4.70 实测截图报告)。
4
+
5
+ - **根因**:0.4.69 的孪生去重只加在分组编辑器**顶层**的供应商下拉(`groupProviderChoices`),而设置页其余全部供应商下拉——识图/记忆/压缩/命名/审查各能力卡的提供商下拉,以及**分组编辑器内每一行**(压缩/审查/命名/记忆/识图/子代理)的提供商下拉——都直接走共享构建器 `deriveRouteChoices`,原样列出目录中的 DVR 孪生(显示名「某某 + 自动识图」,id `<base>-vision`)。
6
+ - **修复(`src/client/main-row-controller.ts`)**:去重下沉到 `deriveRouteChoices`——构建列表后隐藏「id 以 `-vision` 结尾、基座 id 也在列表中、且不是当前选中值」的条目,一次覆盖所有下拉。三条保护:孤儿孪生(基座不在列表)仍显示,存量配置可达;当前选中值永不隐藏,已存孪生 id 的路由保持可见可改;models 列表与 unavailable 回退不变。`groupProviderChoices` 的列表级过滤随之移除(已继承),保留「存储孪生键且基座也已配置则跳过」的兜底。
7
+ - **测试**:`tests/client-controller.spec.ts` 新增 `deriveRouteChoices` 孪生去重组(基座在列表时隐藏 / 孤儿与当前选中保留 / 存量孪生路由的 models 不丢);既有 `groupProviderChoices` 三例回归不变。注:`settings-ui` 规格对 `main-row-controller` 有 vi.mock,下拉内容以 client-controller 单测为准。
8
+ - **验证**:`pnpm run check` 全绿。本改动为客户端纯函数投影,不触运行面;0.4.70 的 lab 矩阵(适配行行为)不受影响。桌面升级 0.4.71 后,设置页全部供应商下拉不再出现「+ 自动识图」孪生条目。
9
+
10
+ ## v0.4.70
11
+
12
+ 0.4.69 lab 实测两条遗留观察的插件侧改进(维护版):
13
+
14
+ - **适配行慢启动韧性**:记忆/识图适配行的重试预算从 8 次/约 18 秒扩到 **16 次/约 2.5–3 分钟**(`attempt >= 16`、间隔上限 10s)。慢启动宿主上目标 RPC/行可能在本行激活数分钟后才就绪——0.4.69 lab 实测 DVR 的网络探测把组合拖到分钟级,旧预算耗尽后适配行静默到下一次设置变更。静态 pin 门槛 `PIN_AFTER_ATTEMPTS` 4 → 8(保持预算一半,pin 不再过早压制 live 形态)。
15
+ - **skip 语义细分**:记忆适配行新增 `live-unavailable`(live 接口不可达/重试耗尽),`no-route` 仅表示路由未配置;表单写失败归入 `live-rejected`。
16
+ - **记忆卡状态行**:设置页记忆卡显示适配状态(已接管/未配置/让位/未装/live-unavailable/被拒),慢启动场景在页面直接可见,不再需要翻日志(镜像识图卡 0.4.69 的状态行模式)。
17
+ - **命名槽位冲突检测与指引**:session-titles bundle 排在 dsh-model-switch 之后时,本插件对 `optional-session-title-all-prompts` 的禁用无法命中后置层插入的行(Include 语义限制),官方命名行与接管行撞单注册位,并连带 prime-memory settings-set 把组合告警当内部错误回滚。0.4.70 起接管行检测到组合树中存在已启用的官方命名行时输出 `NAMING_CONFLICT_GUIDANCE`(两个修法:调整 bundles 顺序 / profile 补丁显式禁用);README(zh/en)新增同款故障排查小节;`docs/seam-gap.md` 归档两条上游观察(跨层 disable 缺失;settings-set 对无关组合告警的严格回滚)。
18
+ - **打包卫生**:`package.json` 增加 `prepack: pnpm run build`——`pnpm pack` 此前不触发任何构建,直接打包现存 lib/(0.4.69 lab 首轮因此装到修复前的旧构建,浪费一整轮排查)。
19
+ - **测试**:新增 `live-unavailable` 用例、`NAMING_CONFLICT_GUIDANCE` 内容用例、记忆状态行交互用例。
20
+ - **验证(virtual / 零真实额度)**:DSH `0.2.1-rc.5` lab(`D:\dsh-lab`,3082/4731,本地 0.4.70 构建 + `dsh-vision-router@3.4.0` + `dsh-prime-memory@0.26.24`):
21
+ - **慢启动零触碰收敛(本轮核心主张)**:lab 预置与 0.4.69 相同的实验配置(apigoto 组 memory/vision pin + effort、孪生默认供应商、DVR 种子链),并预先禁用 `optional-session-title-all-prompts` 保持组合干净。启动后**不做任何设置变更**等待慢启动完成:`status.primeMemory = {installed:true, route apigoto/mimo-v2.6-flash, replays:0}`、`status.visionRouter = {installed:true, replays:0}`——0.4.69 同场景记忆适配行需要手动触发一次设置变更(replays 1-2)才收敛,扩展预算(16 次/约 2.5–3 分钟)覆盖了 DVR 网络探测拖慢的组合窗口。记忆 live 读回 effort=high(全局 + l1 逐层);DVR 行 providers 首行写入 `apigoto/mimo-v2.6-flash`、种子链保留(0.4.70 回归无退化)。
22
+ - **组合冲突与告警**:热重载移除 optional 行禁用后,组合回到冲突态(settings-set 再次以 "1 entry did not activate" 回滚——复证 0.4.69 的观察)。该宿主的插件 warn 不落 stdout/文件日志(仅 DVR 自带文件日志可见),告警的发出改由单元测试直接断言:`tests/session-title.spec.ts` 新增聚焦用例(启用官方行的 bench 装置 → apply 后 warns 含 "official naming row is enabled" 与 "optional-session-title-all-prompts"),既有两例精确断言同步滤除这条一次性启动诊断。50/50 通过。
23
+ - 证据:`D:\dsh-artifacts\lab-0470-final-patch.yml`(终态补丁快照,含 DVR 首行写入与 effort 推送持久化)、`lab-0470-host.log`、`probe-0470.jsonl`(零模型调用,全部为配置面验证)。宿主与探针已停止,3082/4731 已释放,lab 恢复为 npm 0.4.62(DVR 卸载、补丁还原)。
24
+
1
25
  ## v0.4.69
2
26
 
3
27
  四项用户请求的能力一次落地(2026-11-20):**识图路由适配 dsh-vision-router**、**孪生供应商配置组合并**、**记忆蒸馏思考强度**、**纯读免审查白名单校准**。
package/README.en.md CHANGED
@@ -128,6 +128,13 @@ Since 0.4.29 the row also coexists with the experimental "titles that update wit
128
128
  Since 0.4.30 the Auto review row also survives a degraded permission service. DSH's Auto gate reads `permissionPresets.current(session)` before every tool call, and when that service has gone inactive the read throws `cannot get required service "sessionProjections" in inactive context` outside the gate's own reviewer-error handling — so every tool call died before its body ran. The row shadows that service inside its review scope: a failed probe reports "not on Auto", the tool call runs normally, and one log line states that review was skipped. Since 0.4.31 the shadow is **always on** and resolves the service lazily per call (so it protects even while the service is still activating), and its one degradation line carries the exact fiber chain (`uid/state/name/inject` per fiber) that failed resolution — because the upstream cause is a loader lifecycle window: `internal/get` walks the whole caller fiber chain and twenty-four released rows declare `sessionProjections`, so any one of them mid-reload can break an unguarded probe (recorded in `docs/seam-gap.md` with the upstream proposal). The Auto registration itself is brokered — handed over and reclaimed around displacements without unmounting the gate, since unmounting is what flips live `auto` sessions to `danger-full-access` — and a gate re-mounted after a profile reload unloads its previous registration first, so the `auto` preset cannot disappear from the permission picker.
129
129
 
130
130
 
131
+ **Troubleshooting: a naming row "did not activate".** When the session-titles bundle sits **after** dsh-model-switch in the profile's bundles list, this plugin's patch cannot disable `optional-session-title-all-prompts` (an Include disable cannot reach a row a later layer inserts), so the official naming row fights this plugin's takeover row for the single naming slot — the log shows "already registered / 1 entry did not activate", and unrelated profile-persisting writes (prime-memory's settings-set among them) can be blocked by the composition warning. From 0.4.70 the startup log carries the same guidance. Two fixes: move the session-titles bundle before dsh-model-switch, or add an explicit disable to the profile's cordis.patch.yml:
132
+
133
+ ```yaml
134
+ - id: optional-session-title-all-prompts
135
+ disabled: true
136
+ ```
137
+
131
138
  ## Memory distillation & Vision Router
132
139
 
133
140
  The "Memory distillation model" card pins the distillation route for the third-party `dsh-prime-memory` plugin and may carry a **reasoning effort** (empty = the plugin's auto resolution from model capability). Saving writes that plugin's own live settings immediately — the per-layer chains and the global field both carry the effort — with no restart; only when the live attempts keep failing does the static route fall back to the next start. The route resolves from the deployment default provider's group, else the flat pair.
package/README.md CHANGED
@@ -126,6 +126,13 @@ DSH 会自动为新会话起名;命名的触发节奏由 profile 的官方命
126
126
  0.4.30 起 Auto 审查行还能在许可服务降级时保住工具调用:DSH 的 Auto gate 在每次工具调用前读取 `permissionPresets.current(session)`,一旦该服务失活,这次读取会在 gate 自己的审查错误包装之外抛出 `cannot get required service "sessionProjections" in inactive context`,导致每个工具调用都在执行前失败。本行在审查作用域内遮蔽该服务:探测失败即按「不在 Auto」处理,工具调用照常执行,并只记一行日志说明审查被跳过。0.4.31 起该遮蔽**常开**且按调用惰性解析服务(服务尚未激活时也受保护),并把失败的解析链(每级 fiber 的 `uid/state/name/inject`)记进唯一那行降级日志——因为上游成因是 loader 生命周期窗口:`internal/get` 会沿调用方 fiber 链整链查找,而有 24 个已发布行在 `inject` 里声明了 `sessionProjections`,其中任何一行处于重载中都可能打断无防护的探测(连同上游建议一并记录在 `docs/seam-gap.md`)。Auto 注册本身改为**托管**:位移时同步交出、事后收回而不卸载 gate(卸载会把在用 `auto` 的会话翻成 `danger-full-access`);配置重载后重新挂载的 gate 会先卸载上一个注册,因此 `auto` 预设不会再从许可选择器里消失。
127
127
 
128
128
 
129
+ **故障排查:命名行「did not activate」。** 当 profile 的 bundles 里 session-titles bundle 排在 dsh-model-switch **之后**时,本插件补丁对 `optional-session-title-all-prompts` 的禁用无法命中后置层新插入的行(Include 语义限制),官方命名行会与本插件的接管行争夺唯一的命名槽位——日志出现「already registered / 1 entry did not activate」,并可能连带阻断 prime-memory 等插件的 settings-set 持久化写入。0.4.70 起启动日志会给出同样指引。两种修法:把 session-titles bundle 移到 dsh-model-switch 之前;或在 profile 的 cordis.patch.yml 显式加一行禁用:
130
+
131
+ ```yaml
132
+ - id: optional-session-title-all-prompts
133
+ disabled: true
134
+ ```
135
+
129
136
  ## 记忆蒸馏与识图模型(Memory distillation & Vision Router)
130
137
 
131
138
  「记忆蒸馏模型」卡片为第三方 `dsh-prime-memory` 指定蒸馏路由,并可附带**思考强度**(留空 = 该插件按模型能力自动解析)。保存后立即写入该插件自己的 live 设置(逐层链与全局字段同时携带强度),无需重启;仅当反复写不进去时才回落静态路由(下次启动生效)。路由按部署默认供应商的配置组解析,无组时用平铺对。
package/lib/client.js CHANGED
@@ -1259,15 +1259,21 @@ window.__ModuleLoader__.load({
1259
1259
  }
1260
1260
  function deriveRouteChoices(groups, route, allowedProviders) {
1261
1261
  const allowed = allowedProviders === void 0 ? void 0 : new Set(allowedProviders);
1262
- const providers = groups.filter((group) => allowed === void 0 || allowed.has(group.id)).map((group) => ({
1262
+ const listed = groups.filter((group) => allowed === void 0 || allowed.has(group.id)).map((group) => ({
1263
1263
  id: group.id,
1264
1264
  name: group.name
1265
1265
  }));
1266
- if (route?.provider !== void 0 && !providers.some((option) => option.id === route.provider)) providers.push({
1266
+ if (route?.provider !== void 0 && !listed.some((option) => option.id === route.provider)) listed.push({
1267
1267
  id: route.provider,
1268
1268
  name: route.provider,
1269
1269
  unavailable: true
1270
1270
  });
1271
+ const ids = new Set(listed.map((choice) => choice.id));
1272
+ const providers = listed.filter((choice) => {
1273
+ if (choice.id === route?.provider) return true;
1274
+ const base = canonicalGroupProvider(choice.id);
1275
+ return base === choice.id || !ids.has(base);
1276
+ });
1271
1277
  const models = (groups.find((item) => item.id === route?.provider)?.models ?? []).map((model) => ({
1272
1278
  id: model.id,
1273
1279
  name: model.name
@@ -1298,13 +1304,7 @@ window.__ModuleLoader__.load({
1298
1304
  * @returns catalog choices first (original order), then the missing providers.
1299
1305
  */
1300
1306
  function groupProviderChoices(groups, configured, current) {
1301
- const listed = deriveRouteChoices(groups, current === void 0 || current.trim() === "" ? void 0 : { provider: current }).providers;
1302
- const ids = new Set(listed.map((choice) => choice.id));
1303
- const choices = listed.filter((choice) => {
1304
- if (choice.id === current) return true;
1305
- const base = canonicalGroupProvider(choice.id);
1306
- return base === choice.id || !ids.has(base);
1307
- });
1307
+ const choices = deriveRouteChoices(groups, current === void 0 || current.trim() === "" ? void 0 : { provider: current }).providers;
1308
1308
  const seen = new Set(choices.map((choice) => choice.id));
1309
1309
  for (const provider of configured) {
1310
1310
  if (provider.trim() === "" || seen.has(provider)) continue;
@@ -2567,6 +2567,20 @@ window.__ModuleLoader__.load({
2567
2567
  run("providerGroups", () => props.saveProviderGroup(groupProvider, void 0));
2568
2568
  };
2569
2569
  /**
2570
+ * The memory adapter status line, from the same scan as the vision one: the
2571
+ * slow-boot case (live seam unreachable) is now visible without log diving.
2572
+ */
2573
+ const memoryStatusRow = reviewStatus?.primeMemory;
2574
+ const memoryAdapterStatus = () => {
2575
+ if (memoryStatusRow === void 0) return "";
2576
+ if (memoryStatusRow.installed && memoryStatusRow.route !== void 0) return props.t("memoryLinked").replace("{route}", memoryStatusRow.route);
2577
+ if (memoryStatusRow.routeSkipped === "live-unavailable") return props.t("memoryLinkedUnavailable");
2578
+ if (memoryStatusRow.routeSkipped === "live-rejected" || memoryStatusRow.routeSkipped === "no-seam" || memoryStatusRow.routeSkipped === "no-service") return props.t("memoryLinkedRejected");
2579
+ if (memoryStatusRow.routeSkipped === "user-set") return props.t("memoryLinkedUserSet");
2580
+ if (memoryStatusRow.routeSkipped === "no-row") return props.t("memoryLinkedMissing");
2581
+ return props.t("memoryLinkedUnset");
2582
+ };
2583
+ /**
2570
2584
  * The vision adapter status line: what the host-side compat row last did.
2571
2585
  * Rendered only when a tool scan has delivered the live adapter state.
2572
2586
  */
@@ -3061,6 +3075,10 @@ window.__ModuleLoader__.load({
3061
3075
  className: ModelSwitchSettings_module_css_default.hint,
3062
3076
  children: props.t("memoryRouteHelp")
3063
3077
  }),
3078
+ reviewStatus?.primeMemory === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3079
+ className: ModelSwitchSettings_module_css_default.hint,
3080
+ children: memoryAdapterStatus()
3081
+ }),
3064
3082
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3065
3083
  className: ModelSwitchSettings_module_css_default.formGrid,
3066
3084
  children: [
@@ -3803,6 +3821,12 @@ window.__ModuleLoader__.load({
3803
3821
  memoryRouteHelp: "按部署默认供应商的配置组解析;该供应商没有组时使用这里填写的平面默认。优先写该行的 live 设置(立即生效),不可用时写静态路由(llm.provider/llm.model),启动时生效。",
3804
3822
  memoryEffort: "思考强度",
3805
3823
  effortAuto: "自动(跟随模型)",
3824
+ memoryLinked: "已接管蒸馏路由:{route}。",
3825
+ memoryLinkedUnavailable: "记忆插件 live 接口尚未就绪(慢启动;重试预算已加长,改动任意设置可立即触发推送)。",
3826
+ memoryLinkedRejected: "蒸馏路由写入被拒绝,详见宿主日志。",
3827
+ memoryLinkedUserSet: "检测到记忆插件内自行配置的蒸馏路由,本插件让位。",
3828
+ memoryLinkedMissing: "未检测到 dsh-prime-memory 插件。",
3829
+ memoryLinkedUnset: "蒸馏路由未配置,记忆插件使用自身默认。",
3806
3830
  vision: "识图模型",
3807
3831
  visionFollow: "跟随 Vision Router 默认",
3808
3832
  visionHelp: "为 dsh-vision-router 的识图后端链指定首选路由;两个字段都留空时该插件使用自己的后端链。配置后作为链首行写入(其余行保留为降级后备),经官方 ConfigEditor 热生效、无需重启。应选择支持图片输入的模型。",
@@ -3903,6 +3927,12 @@ window.__ModuleLoader__.load({
3903
3927
  memoryRouteHelp: "Resolved from the deployment default provider group; without a group the flat pair here applies. The live settings are preferred (immediate); the static route (llm.provider/llm.model) is the fallback that applies at start.",
3904
3928
  memoryEffort: "Reasoning effort",
3905
3929
  effortAuto: "Auto (follow the model)",
3930
+ memoryLinked: "Memory distillation route held: {route}.",
3931
+ memoryLinkedUnavailable: "The memory plugin’s live seam is not up yet (slow boot; the retry budget is now longer, and changing any setting triggers the push immediately).",
3932
+ memoryLinkedRejected: "The distillation-route write was rejected; see the host log.",
3933
+ memoryLinkedUserSet: "A distillation route set inside the memory plugin itself wins; this plugin stands down.",
3934
+ memoryLinkedMissing: "dsh-prime-memory is not installed.",
3935
+ memoryLinkedUnset: "No distillation route configured; the memory plugin keeps its own default.",
3906
3936
  vision: "Vision model",
3907
3937
  visionFollow: "Follows the Vision Router default",
3908
3938
  visionHelp: "Pin the preferred backend for dsh-vision-router’s vision chain; both fields empty keeps that plugin on its own chain. A configured route becomes the chain’s first row (the remaining rows stay as fallbacks), written through the official ConfigEditor and hot-applied without a restart. Pick a model that accepts image input.",
package/lib/index.js CHANGED
@@ -6,7 +6,7 @@ import { automodeCompatView } from "./automode-compat.js";
6
6
  import { s as subagentDiscoveryHintStatus } from "./subagent-runtime-eNKrdb2H.js";
7
7
  import { u as reviewTimeoutStatus } from "./review-timeout-FB32BcnO.js";
8
8
  import { primeMemoryCompatStatus } from "./prime-memory-compat.js";
9
- import { a as visionRouterCompatStatus } from "./vision-router-compat-B9bkgJmh.js";
9
+ import { a as visionRouterCompatStatus } from "./vision-router-compat-DP81VMLW.js";
10
10
  import { createRequire } from "node:module";
11
11
  import z from "@deepseek-ai/schemastery";
12
12
  import { Service } from "@deepseek-ai/cordis";
@@ -330,8 +330,13 @@ function formsOf(ctx) {
330
330
  return;
331
331
  }
332
332
  }
333
- /** Live attempts to spend before falling back to the static pin. */
334
- const PIN_AFTER_ATTEMPTS = 4;
333
+ /**
334
+ * Live attempts to spend before falling back to the static pin.
335
+ *
336
+ * Kept at half the retry budget: the pin suppresses every live form, so it must
337
+ * not fire while the extended live window still has a realistic chance.
338
+ */
339
+ const PIN_AFTER_ATTEMPTS = 8;
335
340
  /**
336
341
  * Install the adapter for the whole profile.
337
342
  *
@@ -363,8 +368,8 @@ function installPrimeMemoryCompat(ctx, loader, routeOf) {
363
368
  }
364
369
  };
365
370
  const scheduleRetry = () => {
366
- if (attempt >= 8) return;
367
- const delay = Math.min(4e3, 200 * 2 ** attempt);
371
+ if (attempt >= 16) return;
372
+ const delay = Math.min(1e4, 200 * 2 ** attempt);
368
373
  attempt += 1;
369
374
  const timer = setTimeout(() => {
370
375
  run();
@@ -440,7 +445,7 @@ function installPrimeMemoryCompat(ctx, loader, routeOf) {
440
445
  const forms = formsOf(ctx);
441
446
  const live = await readMemoryLive(ctx);
442
447
  if (live === void 0) {
443
- primeMemoryCompatStatus.routeSkipped = "no-route";
448
+ primeMemoryCompatStatus.routeSkipped = "live-unavailable";
444
449
  scheduleRetry();
445
450
  return;
446
451
  }
@@ -477,7 +482,7 @@ function installPrimeMemoryCompat(ctx, loader, routeOf) {
477
482
  primeMemoryCompatStatus.routeSkipped = "live-rejected";
478
483
  }
479
484
  if (forms === void 0 || forms.update === void 0 || forms.describe === void 0) {
480
- primeMemoryCompatStatus.routeSkipped = "no-route";
485
+ primeMemoryCompatStatus.routeSkipped = "live-unavailable";
481
486
  scheduleRetry();
482
487
  return;
483
488
  }
@@ -503,7 +508,7 @@ function installPrimeMemoryCompat(ctx, loader, routeOf) {
503
508
  primeMemoryCompatStatus.route = wanted;
504
509
  delete primeMemoryCompatStatus.routeSkipped;
505
510
  }).catch(async (cause) => {
506
- primeMemoryCompatStatus.routeSkipped = "no-route";
511
+ primeMemoryCompatStatus.routeSkipped = "live-rejected";
507
512
  ctx.logger.warn(`model-switch: could not write the dsh-prime-memory distillation route (${String(cause)})`);
508
513
  await pinAsFallback(forms, provider, model, wanted);
509
514
  }).finally(() => {
@@ -698,6 +698,18 @@ function leafId(entry) {
698
698
  return typeof raw === "string" ? raw : void 0;
699
699
  }
700
700
  /**
701
+ * The one-shot guidance for the layer-order naming conflict.
702
+ *
703
+ * An id-disable in this plugin's bundle patch cannot reach a row the
704
+ * session-titles bundle inserts in a LATER layer, so the profile's bundle
705
+ * order decides whether the official naming row arrives disabled. The runtime
706
+ * takeover still displaces it, but that order leaves the composition one
707
+ * "did not activate" warning away from blocking unrelated profile-persisting
708
+ * writes (observed in the lab: prime-memory settings-set rolling back on the
709
+ * composition warning). Names the two durable profile-side fixes.
710
+ */
711
+ const NAMING_CONFLICT_GUIDANCE = "an official naming row is enabled in the composed tree (the session-titles bundle composes after dsh-model-switch, so this plugin id-disable cannot reach it). The takeover displaces it at runtime; to also keep the composition clean, either move the session-titles bundle before dsh-model-switch in the profile bundles list, or add a profile-patch row with id optional-session-title-all-prompts and disabled: true";
712
+ /**
701
713
  * Every official naming row the loader currently has instantiated and enabled.
702
714
  *
703
715
  * A row that is enabled here may be about to run its own `register()`, so this
@@ -860,8 +872,10 @@ async function apply(ctx) {
860
872
  const plan = planFor(ctx, module, entry);
861
873
  if (plan === void 0) return;
862
874
  const seam = new NamingSeam(ctx, module, settingsReader, plan);
863
- if (!(enabledOfficialRows(ctx).length > 0) && !seam.claim()) ctx.logger.info("model-switch: another session-title provider already owns the seam; naming follows it while it is active");
875
+ const pendingOfficial = enabledOfficialRows(ctx).length > 0;
876
+ if (pendingOfficial) ctx.logger.warn("model-switch: an official naming row is enabled in the composed tree (the session-titles bundle composes after dsh-model-switch, so this plugin id-disable cannot reach it). The takeover displaces it at runtime; to also keep the composition clean, either move the session-titles bundle before dsh-model-switch in the profile bundles list, or add a profile-patch row with id optional-session-title-all-prompts and disabled: true");
877
+ if (!pendingOfficial && !seam.claim()) ctx.logger.info("model-switch: another session-title provider already owns the seam; naming follows it while it is active");
864
878
  installTakeover(ctx, module, seam);
865
879
  }
866
880
  //#endregion
867
- export { TAKEOVER_MAX_ATTEMPTS, TAKEOVER_RETRY_DELAY_MS, TITLE_CADENCES, apply, composeTitleRoute, forwardedConfig, frameTitleInput, inject, isMaxTokensFailure, isModernTitleModule, isOfficialTitleRow, name, normalizeTitleText, officialTitleEntry, officialTitlePackage, resolveNamingPolicy, selectTitleMessages, selectTitleReasoningEffort, shouldTryNextCandidate, splitTitlePolicy, titleCadence, titleFromOutput, titleFromResponse, titleRouteCandidates, titleSystemPrompt, widerTitleBudget };
881
+ export { NAMING_CONFLICT_GUIDANCE, TAKEOVER_MAX_ATTEMPTS, TAKEOVER_RETRY_DELAY_MS, TITLE_CADENCES, apply, composeTitleRoute, forwardedConfig, frameTitleInput, inject, isMaxTokensFailure, isModernTitleModule, isOfficialTitleRow, name, normalizeTitleText, officialTitleEntry, officialTitlePackage, resolveNamingPolicy, selectTitleMessages, selectTitleReasoningEffort, shouldTryNextCandidate, splitTitlePolicy, titleCadence, titleFromOutput, titleFromResponse, titleRouteCandidates, titleSystemPrompt, widerTitleBudget };
@@ -51,6 +51,12 @@ export declare const zh: {
51
51
  readonly memoryRouteHelp: "按部署默认供应商的配置组解析;该供应商没有组时使用这里填写的平面默认。优先写该行的 live 设置(立即生效),不可用时写静态路由(llm.provider/llm.model),启动时生效。";
52
52
  readonly memoryEffort: "思考强度";
53
53
  readonly effortAuto: "自动(跟随模型)";
54
+ readonly memoryLinked: "已接管蒸馏路由:{route}。";
55
+ readonly memoryLinkedUnavailable: "记忆插件 live 接口尚未就绪(慢启动;重试预算已加长,改动任意设置可立即触发推送)。";
56
+ readonly memoryLinkedRejected: "蒸馏路由写入被拒绝,详见宿主日志。";
57
+ readonly memoryLinkedUserSet: "检测到记忆插件内自行配置的蒸馏路由,本插件让位。";
58
+ readonly memoryLinkedMissing: "未检测到 dsh-prime-memory 插件。";
59
+ readonly memoryLinkedUnset: "蒸馏路由未配置,记忆插件使用自身默认。";
54
60
  readonly vision: "识图模型";
55
61
  readonly visionFollow: "跟随 Vision Router 默认";
56
62
  readonly visionHelp: "为 dsh-vision-router 的识图后端链指定首选路由;两个字段都留空时该插件使用自己的后端链。配置后作为链首行写入(其余行保留为降级后备),经官方 ConfigEditor 热生效、无需重启。应选择支持图片输入的模型。";
@@ -30,8 +30,13 @@ import { type DistillChainEntry } from './prime-memory-route.js';
30
30
  /** Row name and dependencies, mirroring the sibling adapter row. */
31
31
  export declare const name = "model-switch-prime-memory-compat";
32
32
  export declare const inject: string[];
33
- /** Why the adapter stayed out of the way. */
34
- export type PrimeMemoryRouteSkip = 'user-set' | 'no-route' | 'no-row' | 'no-service' | 'no-seam' | 'live-rejected';
33
+ /**
34
+ * Why the adapter stayed out of the way.
35
+ *
36
+ * `no-route` means the route itself is unset; `live-unavailable` means the
37
+ * memory plugin's live seam was unreachable (slow boot, retries exhausted).
38
+ */
39
+ export type PrimeMemoryRouteSkip = 'user-set' | 'no-route' | 'live-unavailable' | 'no-row' | 'no-service' | 'no-seam' | 'live-rejected';
35
40
  /** Live adapter state, surfaced next to the settings card. */
36
41
  export interface PrimeMemoryCompatStatus {
37
42
  /** Whether at least one write reached the memory plugin's settings. */
@@ -287,6 +287,18 @@ export declare const TAKEOVER_MAX_ATTEMPTS = 20;
287
287
  * group or an unrelated plugin's row with a recycled id.
288
288
  */
289
289
  export declare function isOfficialTitleRow(entry: Entry | undefined): boolean;
290
+ /**
291
+ * The one-shot guidance for the layer-order naming conflict.
292
+ *
293
+ * An id-disable in this plugin's bundle patch cannot reach a row the
294
+ * session-titles bundle inserts in a LATER layer, so the profile's bundle
295
+ * order decides whether the official naming row arrives disabled. The runtime
296
+ * takeover still displaces it, but that order leaves the composition one
297
+ * "did not activate" warning away from blocking unrelated profile-persisting
298
+ * writes (observed in the lab: prime-memory settings-set rolling back on the
299
+ * composition warning). Names the two durable profile-side fixes.
300
+ */
301
+ export declare const NAMING_CONFLICT_GUIDANCE = "an official naming row is enabled in the composed tree (the session-titles bundle composes after dsh-model-switch, so this plugin id-disable cannot reach it). The takeover displaces it at runtime; to also keep the composition clean, either move the session-titles bundle before dsh-model-switch in the profile bundles list, or add a profile-patch row with id optional-session-title-all-prompts and disabled: true";
290
302
  /**
291
303
  * Mount the Model Switch session-naming row for this profile.
292
304
  *
@@ -0,0 +1,312 @@
1
+ import { s as visionRouteOf } from "./session-route-CRfpxarI.js";
2
+ import { t as deploymentDefaultProviderOf } from "./prime-memory-route-DGUVfogE.js";
3
+ //#region lib/types/vision-router-route.js
4
+ /**
5
+ * Model Switch's adapter to `dsh-vision-router`'s backend chain.
6
+ *
7
+ * dsh-vision-router owns the vision backend chain: an ordered `providers` list
8
+ * of `{ provider, model, fallbacks }` rows in its `vision-router` row config,
9
+ * each row a host llm provider/model the chain tries in order. This module only
10
+ * builds the chain Model Switch offers; it never runs a vision call, never
11
+ * rewrites another row, and never touches a route the user did not ask to
12
+ * change.
13
+ *
14
+ * Managed-head semantics: a configured route owns the chain's FIRST row (the
15
+ * primary backend); the rows the user already had stay below in their own order
16
+ * as fallbacks. Unlike the memory adapter there is no `user-set` skip: the
17
+ * chain is an ordered fallback table that is never empty (the built-in free
18
+ * endpoint is the runtime's last resort), so the head is the routing decision
19
+ * and a user-set head is exactly what a configured route replaces.
20
+ *
21
+ * All functions here are pure.
22
+ */
23
+ /** The loader row id dsh-vision-router is composed under (fixed by its bundle patch). */
24
+ const VISION_ROUTER_ENTRY_ID = "vision-router";
25
+ /** The package name that identifies the row; the authoritative identity. */
26
+ const VISION_ROUTER_PACKAGE = "dsh-vision-router";
27
+ /** A non-blank string within dsh-vision-router's identifier budget. */
28
+ function validIdentifier(value) {
29
+ return typeof value === "string" && value.length > 0 && value.length <= 512;
30
+ }
31
+ /**
32
+ * Whether one loader entry is dsh-vision-router.
33
+ *
34
+ * The package name wins over the row id: a profile layer may rename the row,
35
+ * while an unrelated row could recycle the id.
36
+ * @param entry - the loader entry to test.
37
+ * @returns True for dsh-vision-router's row.
38
+ */
39
+ function isVisionRouterRow(entry) {
40
+ const name = entry?.options?.name;
41
+ if (typeof name === "string" && name.trim() !== "") return name === VISION_ROUTER_PACKAGE;
42
+ return entry?.options?.id === VISION_ROUTER_ENTRY_ID;
43
+ }
44
+ /**
45
+ * Strip a raw providers value to well-formed chain rows.
46
+ *
47
+ * Mirrors dsh-vision-router's own runtime normalization: entries without a
48
+ * valid provider and model are dropped, fallbacks are kept as strings, and the
49
+ * chain is capped at the plugin's row limit.
50
+ * @param value - the raw `providers` config value, when present.
51
+ * @returns The valid rows, in stored order.
52
+ */
53
+ function normalizeVisionProviderEntries(value) {
54
+ if (!Array.isArray(value)) return [];
55
+ const rows = [];
56
+ for (const entry of value) {
57
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry)) continue;
58
+ const source = entry;
59
+ if (!validIdentifier(source.provider) || !validIdentifier(source.model)) continue;
60
+ const fallbacks = Array.isArray(source.fallbacks) ? source.fallbacks.filter((item) => validIdentifier(item)) : [];
61
+ rows.push({
62
+ provider: source.provider,
63
+ model: source.model,
64
+ fallbacks
65
+ });
66
+ if (rows.length >= 32) break;
67
+ }
68
+ return rows;
69
+ }
70
+ /**
71
+ * The backend chain dsh-vision-router should run, given the route Model Switch wants.
72
+ *
73
+ * The chosen route goes first; the entries the plugin already had follow in
74
+ * their own order, minus any duplicate of the chosen pair (a duplicate is a
75
+ * guaranteed second failure, not a fallback) and minus the entry this adapter
76
+ * wrote on an earlier pass (identified by `adopted`, so a route change
77
+ * replaces in place instead of accumulating). An empty chosen route leaves the
78
+ * existing chain untouched.
79
+ * @param existing - the raw `providers` config value as currently stored.
80
+ * @param route - the route Model Switch wants first, if any.
81
+ * @param adopted - the `provider/model` this adapter wrote on an earlier pass.
82
+ * @returns The chain to write, whether it changed, and what was applied.
83
+ */
84
+ function planVisionProviders(existing, route, adopted) {
85
+ const chain = normalizeVisionProviderEntries(existing);
86
+ const provider = typeof route?.provider === "string" ? route.provider.trim() : "";
87
+ const model = typeof route?.model === "string" ? route.model.trim() : "";
88
+ if (provider === "" || model === "") return {
89
+ providers: chain,
90
+ changed: false,
91
+ skipped: "no-route"
92
+ };
93
+ const head = chain[0];
94
+ if (head !== void 0 && head.provider === provider && head.model === model) return {
95
+ providers: chain,
96
+ changed: false,
97
+ route: `${provider}/${model}`
98
+ };
99
+ const rest = chain.filter((entry) => {
100
+ if (entry.provider === provider && entry.model === model) return false;
101
+ if (adopted !== void 0 && `${entry.provider}/${entry.model}` === adopted) return false;
102
+ return true;
103
+ });
104
+ return {
105
+ providers: [{
106
+ provider,
107
+ model,
108
+ fallbacks: []
109
+ }, ...rest].slice(0, 32),
110
+ changed: true,
111
+ route: `${provider}/${model}`
112
+ };
113
+ }
114
+ //#endregion
115
+ //#region lib/types/vision-router-compat.js
116
+ /**
117
+ * Adapt `dsh-vision-router`'s backend chain to this plugin's vision route.
118
+ *
119
+ * The vision plugin owns an ordered `providers` chain in its `vision-router`
120
+ * row config and reads it live. The write crosses the same boundary the
121
+ * plugin's own settings facade uses: `ctx.configEditor.edit(entry, change)` —
122
+ * the released core ConfigEditor seam. The edit validates through the plugin's
123
+ * own Config schema (`providers` is declared there), persists into the profile
124
+ * patch row, and hot-reloads just that entry, so a provider switch applies
125
+ * without a Host restart. The plugin's HTTP local-settings transport stays
126
+ * unused: its BrowserAuth fence only admits an authenticated local browser,
127
+ * not a plugin fiber.
128
+ *
129
+ * The route itself is provider-group based: the group of the deployment
130
+ * default provider (canonicalized — a twin `${provider}-vision` default keys
131
+ * its base), falling back to the flat vision pair. Chain semantics are the
132
+ * managed head documented in `./vision-router-route.ts`: a configured route
133
+ * owns the first row, the user's own rows stay below as fallbacks, and an
134
+ * empty route leaves the chain untouched.
135
+ */
136
+ /** Row name and dependencies, mirroring the sibling adapter rows. */
137
+ const name = "model-switch-vision-router-compat";
138
+ const inject = ["loader"];
139
+ /** The state the settings page reads. */
140
+ const visionRouterCompatStatus = {
141
+ installed: false,
142
+ replays: 0
143
+ };
144
+ /** A non-blank string. */
145
+ function text(value) {
146
+ return typeof value === "string" ? value.trim() : "";
147
+ }
148
+ /** Read a value as a plain record. */
149
+ function asRecord(value) {
150
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
151
+ }
152
+ /** The config one loader entry currently runs with. */
153
+ function configOf(entry) {
154
+ return asRecord(entry?.options?.config);
155
+ }
156
+ /** The ConfigEditor service, when this Host exposes the released seam. */
157
+ function editorOf(ctx) {
158
+ try {
159
+ return ctx.get("configEditor", false);
160
+ } catch {
161
+ return;
162
+ }
163
+ }
164
+ /** The vision plugin's addressable row, as currently composed. */
165
+ function visionRouterEntryOf(editor) {
166
+ for (const candidate of editor.entries?.() ?? []) if (isVisionRouterRow(candidate)) return candidate;
167
+ }
168
+ /**
169
+ * Install the adapter for the whole profile.
170
+ *
171
+ * Runs on activation, on every `loader/patch-context` and `loader/entry-init`
172
+ * that concerns the vision plugin's row, once more after a short delay (the
173
+ * row is often composed after this one), when the `configEditor` service
174
+ * appears, and whenever this plugin's settings change. Every pass compares
175
+ * before writing: a ConfigEditor edit reconciles the profile and re-enters
176
+ * this adapter, so an unchanged head must not produce another write.
177
+ * @param ctx - this row's context.
178
+ * @param routeOf - resolves this plugin's vision route for one settings snapshot.
179
+ * @returns The disposer and a replay hook.
180
+ */
181
+ function installVisionRouterCompat(ctx, routeOf) {
182
+ /** The route this adapter wrote last, so it may replace its own value only. */
183
+ let adoptedRoute;
184
+ let pending;
185
+ let attempt = 0;
186
+ const timers = [];
187
+ const scheduleRetry = () => {
188
+ if (attempt >= 16) return;
189
+ const delay = Math.min(1e4, 200 * 2 ** attempt);
190
+ attempt += 1;
191
+ const timer = setTimeout(() => {
192
+ run();
193
+ }, delay);
194
+ timer.unref?.();
195
+ timers.push(timer);
196
+ };
197
+ const run = async () => {
198
+ if (pending !== void 0) return pending;
199
+ const editor = editorOf(ctx);
200
+ if (editor === void 0 || typeof editor.entries !== "function" || typeof editor.edit !== "function") {
201
+ visionRouterCompatStatus.routeSkipped = "no-seam";
202
+ return;
203
+ }
204
+ const entry = visionRouterEntryOf(editor);
205
+ if (entry === void 0) {
206
+ visionRouterCompatStatus.routeSkipped = "no-row";
207
+ scheduleRetry();
208
+ return;
209
+ }
210
+ const editRow = editor.edit.bind(editor);
211
+ const route = routeOf();
212
+ const provider = text(route?.provider);
213
+ const model = text(route?.model);
214
+ if (provider === "" || model === "") {
215
+ visionRouterCompatStatus.routeSkipped = "no-route";
216
+ return;
217
+ }
218
+ const preview = planVisionProviders(configOf(entry)?.providers, route, adoptedRoute);
219
+ if (!preview.changed) {
220
+ adoptedRoute = preview.route ?? adoptedRoute;
221
+ if (preview.route !== void 0) {
222
+ visionRouterCompatStatus.installed = true;
223
+ visionRouterCompatStatus.route = preview.route;
224
+ delete visionRouterCompatStatus.routeSkipped;
225
+ }
226
+ return;
227
+ }
228
+ const wanted = `${provider}/${model}`;
229
+ pending = (async () => {
230
+ try {
231
+ await editRow(entry, (current) => {
232
+ const base = asRecord(current) ?? {};
233
+ const plan = planVisionProviders(base.providers, route, adoptedRoute);
234
+ return {
235
+ ...base,
236
+ providers: plan.providers
237
+ };
238
+ });
239
+ const verify = planVisionProviders(configOf(visionRouterEntryOf(editor))?.providers, route, adoptedRoute);
240
+ if (!verify.changed) {
241
+ adoptedRoute = verify.route ?? wanted;
242
+ attempt = 0;
243
+ visionRouterCompatStatus.installed = true;
244
+ visionRouterCompatStatus.route = wanted;
245
+ delete visionRouterCompatStatus.routeSkipped;
246
+ } else visionRouterCompatStatus.routeSkipped = "rejected";
247
+ } catch (cause) {
248
+ visionRouterCompatStatus.routeSkipped = "rejected";
249
+ ctx.logger.warn(`model-switch: could not write the dsh-vision-router backend chain (${String(cause)})`);
250
+ scheduleRetry();
251
+ } finally {
252
+ pending = void 0;
253
+ }
254
+ })();
255
+ return pending;
256
+ };
257
+ const replay = () => {
258
+ visionRouterCompatStatus.replays += 1;
259
+ run();
260
+ return true;
261
+ };
262
+ run();
263
+ const offPatch = ctx.on("loader/patch-context", function(first, second) {
264
+ const nextFn = typeof first === "function" ? first : second;
265
+ if (isVisionRouterRow(typeof first === "function" ? this : first)) run();
266
+ return nextFn === void 0 ? void 0 : nextFn();
267
+ });
268
+ const offInit = ctx.on("loader/entry-init", function(first) {
269
+ const candidate = this ?? first;
270
+ if (candidate !== void 0 && isVisionRouterRow(candidate)) run();
271
+ });
272
+ const offService = ctx.on("internal/service", (name) => {
273
+ if (name === "configEditor") run();
274
+ });
275
+ const lateSweep = setTimeout(() => {
276
+ run();
277
+ }, 1500);
278
+ lateSweep.unref?.();
279
+ return {
280
+ dispose: () => {
281
+ offPatch();
282
+ offInit();
283
+ offService();
284
+ clearTimeout(lateSweep);
285
+ for (const timer of timers) clearTimeout(timer);
286
+ },
287
+ replay
288
+ };
289
+ }
290
+ /**
291
+ * Row entry point: adapt the vision plugin on activation and on remount.
292
+ * @param ctx - this row's context.
293
+ */
294
+ function apply(ctx) {
295
+ ctx.inject(["modelSwitch"], (withProvider) => {
296
+ withProvider.inject(["configEditor"], (scope) => scope.effect(() => {
297
+ const runtime = scope.modelSwitch;
298
+ const loader = scope.get("loader", false);
299
+ const routeOf = () => visionRouteOf(runtime.currentSettings(), deploymentDefaultProviderOf(loader));
300
+ const adapter = installVisionRouterCompat(scope, routeOf);
301
+ const off = scope.on("model-switch/settings-update", () => {
302
+ if (adapter.replay()) scope.logger.info("model-switch: re-applied the dsh-vision-router backend chain after a settings change");
303
+ });
304
+ return () => {
305
+ off();
306
+ adapter.dispose();
307
+ };
308
+ }, "model-switch: keep the dsh-vision-router route aligned with the settings"));
309
+ });
310
+ }
311
+ //#endregion
312
+ export { visionRouterCompatStatus as a, name as i, inject as n, installVisionRouterCompat as r, apply as t };
@@ -1,2 +1,2 @@
1
- import { a as visionRouterCompatStatus, i as name, n as inject, r as installVisionRouterCompat, t as apply } from "./vision-router-compat-B9bkgJmh.js";
1
+ import { a as visionRouterCompatStatus, i as name, n as inject, r as installVisionRouterCompat, t as apply } from "./vision-router-compat-DP81VMLW.js";
2
2
  export { apply, inject, installVisionRouterCompat, name, visionRouterCompatStatus };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-model-switch",
3
- "version": "0.4.69",
3
+ "version": "0.4.71",
4
4
  "description": "Explicit model routing plus composer/Plan picker for DeepSeek Harness",
5
5
  "repository": {
6
6
  "type": "git",
@@ -91,6 +91,7 @@
91
91
  "bundle": "tsdown",
92
92
  "build": "tsc -p tsconfig.json && tsdown",
93
93
  "prepublishOnly": "pnpm run build",
94
+ "prepack": "pnpm run build",
94
95
  "test": "vitest run",
95
96
  "typecheck": "tsc -p tsconfig.json --noEmit",
96
97
  "pack:check": "node scripts/check-rc1-pack.mjs",