dsh-model-switch 0.4.47 → 0.4.48

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,13 @@
1
+ ## v0.4.48
2
+
3
+ 兼容门限从「逐版本列举」改为「下界 + 区间」:
4
+
5
+ - **新增 `dsh.compatibility.dshRuntime: ">=0.2.0-rc.2"`**:凡 ≥ 该下界的 DSH 运行时都按已验证处理(不再逐个版本写白名单);`blocklist` 仍最优先、加载仍 fail-open——区间只消除「未验证运行时」的警告噪音,不改变任何挂载行为。
6
+ - **实现**:`src/compatibility.ts` 新增 `compareDshVersions()`(含预发布排序:`rc.2 < rc.3 < 正式版`)与 `runtimeFloorOf()`(只认开区间 `>=x.y.z`,有界范围视为另一种承诺、忽略不半执行);`allowDshRuntime()` 把区间透传给判定。
7
+ - **测试**:`tests/compatibility.spec.ts` 增 5 例(预发布排序、区间解析、≥下界不告警、低于下界仍告警、blocklist 仍拦截、清单里确有该键),11 例全绿。
8
+ - **工具**:`tools/route-probe.mjs` 随本版发布 `--map`(按模型分流回复)与 `once`(每模型只回放一次工具调用,避免自激循环)。
9
+ - **尚未取证**:DSH `0.2.1-rc.4` 的运行时验证仍待做(区间已覆盖其语义,但未单独实测,不据此声称已验收);记忆蒸馏路由、Auto review 与 automode 分类器的虚拟实测同样待做。
10
+
1
11
  ## v0.4.47
2
12
 
3
13
  两件用户可见修正(撤卡 + 计划卡换模型),均为热修。
package/README.md CHANGED
@@ -191,7 +191,7 @@ DSH Host peers and development dependencies accept `>=0.1.7-alpha.2`, including
191
191
 
192
192
  Verified releases: `0.1.7-alpha.2`, `0.1.7-rc.1`, `0.1.7-rc.2`, `0.2.0-rc.2`. The 0.2.0 claim covers the Host's renamed question verbs, its unawaited `session.selectModel` default write, and its returned `ModelDirectory.select` refusal, each verified in the lab and on a live desktop session.
193
193
 
194
- The verified releases in `package.json#dsh.compatibility.dshReleases` are evidence, not an allowlist. Review public API changes and test new Host releases before adding a verification claim.
194
+ DSH compatibility is declared as an open-ended floor (`dsh.compatibility.dshRuntime: ">=0.2.0-rc.2"`): every runtime at or above it mounts without an unverified warning, a `blocklist` still wins, and loading stays fail-open. The releases in `package.json#dsh.compatibility.dshReleases` are evidence, not an allowlist. Review public API changes and test new Host releases before adding a verification claim.
195
195
 
196
196
  **Third-party auto modes.** When [`@log.li/dsh-automode`](https://github.com/log-li/dsh-automode) is installed, the `model-switch-automode-compat` row injects this plugin's Auto-review route and pure-read list into that row's **in-memory** config — no profile write, nothing to configure by hand. Its `auto-mode` preset then reviews with your configured route and passes your allowlisted tools, while the `auto` preset keeps using this plugin's own gate. Explicit `classifier.provider/model` values in that row always win, pattern-shaped allowlist entries cannot transfer (its check is exact-match), and its hard-deny bands still run first.
197
197
 
package/README.zh.md CHANGED
@@ -189,7 +189,7 @@ DSH Host peer 和开发依赖接受 `>=0.1.7-alpha.2`,包括 rc.1 和后续版
189
189
 
190
190
  已验证版本:`0.1.7-alpha.2`、`0.1.7-rc.1`、`0.1.7-rc.2`、`0.2.0-rc.2`、`0.2.1-rc.2`、`0.2.1-rc.3`。0.2.0 的声明覆盖三处差异:Host 改名的提问撤下动词(`cancel()` → `dismiss()`)、`session.selectModel` 不 await 的部署默认值写入、以返回值报出的 `ModelDirectory.select` 拒绝;三者均已在 lab(3082/3085)与真实桌面会话中逐一验证。0.2.1 的声明覆盖两处被替换的 seam:共享命名调用改为 provider 自备提示词与解析的 `executeSessionTitleLlm`(本插件按安装行在运行时适配,并镜像官方 0.2.1 的提示词、取最低 reasoning effort 与 `currentTitle` 锚定);Subagent 运行时以 `startActivation` 取代 `start()`/`startContinuable()`,本插件同时识别两条已发布线,并为激活入口覆写 `spec.request.agentOptions`(显式路由仍优先、非 agentOptions 能力的外部适配器不改写),路由语义与旧线一致(0.4.28,记录于 `docs/seam-gap.md`);0.2.1 还新增了自动审查门禁对 `ctx.workingDirectory` 的读取,旧实现因在自己的 fiber 里直调 `official.apply` 而需要手工镜像门禁的 `inject`,于是每个工具调用都被拒(`cannot get property "workingDirectory" without inject`),0.4.28 改为把官方门禁以插件方式挂载、由官方 `inject` 解析依赖,本行只声明自身需要的服务。0.4.28 的真实包证据:0.2.1 上旧形态精确复现该注入错误、新形态到达 `workingDirectory.ensure` 且成功注册门禁、激活入口的路由改写与 spec 透传通过;0.2.0 上无需 `workingDirectory` 服务即可注册门禁,`start()` 路由改写与父身份保持不变。0.2.1 的 lab 证据为:npm 安装的 0.2.1 运行时 + 打包后的 0.4.26 组合 `exit 0`、命名/压缩/自动审查/子代理四行均来自本插件、Web Host 在 3082 启动并服务需要鉴权的页面;该次未经浏览器调用 3082 能力 RPC,真实桌面的 0.2.1 命名差分在应用升级后复验。0.2.1 还暴露出一处预设层面的差异(0.2.1 校验提示词变量、只有 `provider`/`model`,且把 `time-context`/`tool-schedule` 移进预设):0.4.26 的静态预设副本因此让每一轮都报 `unknown prompt variable "{{cwd}}"`,0.4.27 删除副本改为启动期运行时桥接,并在 lab 的 0.2.1 headless 真实回合中验证通过(展开见 CHANGELOG 0.4.27)。0.2.1-rc.3 是纯客户端改动:本品读到的三个包都是加法——`ui-conversation` 新增 `conversation.session.header.views.actions` 槽位与 header 的 `entryPins`/`entryActions`/`setPinned`(`conversation.composer` 链与 `ComposerChainProps` 一字未改)、`ui-primitives` 新增 `IconAppsAddOutline*` 图标、`ui-user-questions` 只有版本号;`experimental-auto-review`、`dsh-tools`、`dsh-session`、`dsh-subagent` 与 `api/*` 在 rc.3 中源码未变(后者只有版本号)。插件本体零改动,在 rc.3 lab(3083,`@deepseek-ai/dsh@0.2.1-rc.3`)复验:挂载无 unverified 告警、58 条默认名单、纯读跳过计数、写操作仍审查、计划卡「去聊天里说」回合以 `aborted` 结束、草稿跨会话保留;再用同一产物在 rc.2 lab(3082)回归通过(展开见 CHANGELOG 0.4.41)。
191
191
 
192
- `package.json#dsh.compatibility.dshReleases` 中的已验证版本是证据,不是允许列表。新增验证声明前要审查公开 API 变化并测试新 Host 版本。
192
+ DSH 兼容按「下界 + 区间」声明(`dsh.compatibility.dshRuntime: ">=0.2.0-rc.2"`):≥ 该下界一律挂载且不再告警,`blocklist` 仍最优先,加载保持 fail-open。`package.json#dsh.compatibility.dshReleases` 里的逐版本记录是证据,不是允许列表。新增验证声明前要审查公开 API 变化并测试新 Host 版本。
193
193
 
194
194
  **第三方自动模式。** 安装 [`@log.li/dsh-automode`](https://github.com/log-li/dsh-automode) 后,`model-switch-automode-compat` 行会把本插件的自动审查路由与纯读名单注入到该行的**内存配置**里——不写 profile、不需要手工配置。它的 `auto-mode` 档位会用你配置的路由审查、并按你的名单直通纯读工具;`auto` 档位仍然走本插件自己的闸门。该行里显式写过的 `classifier.provider/model` 永远优先,带通配的名单条目无法转过去(它是精确匹配),它的硬 deny 正则也照旧先跑。
195
195
 
package/lib/index.js CHANGED
@@ -639,19 +639,98 @@ function installDeepSeekSearchAdapter(ctx) {
639
639
  //#endregion
640
640
  //#region lib/types/compatibility.js
641
641
  /**
642
+ * Parse a dotted DSH version, tolerating a prerelease suffix.
643
+ * @param version - the raw version text.
644
+ * @returns the parsed parts, or undefined when the shape is unknown.
645
+ */
646
+ function parseVersion(version) {
647
+ const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(version.trim());
648
+ if (match === null) return void 0;
649
+ return {
650
+ base: [
651
+ Number(match[1]),
652
+ Number(match[2]),
653
+ Number(match[3])
654
+ ],
655
+ pre: match[4] === void 0 ? [] : match[4].split(".")
656
+ };
657
+ }
658
+ /** Semver prerelease ordering for one identifier pair. */
659
+ function compareIdentifier(left, right) {
660
+ const leftNumeric = /^\d+$/.test(left);
661
+ const rightNumeric = /^\d+$/.test(right);
662
+ if (leftNumeric && rightNumeric) return Number(left) - Number(right);
663
+ if (leftNumeric) return -1;
664
+ if (rightNumeric) return 1;
665
+ return left < right ? -1 : left > right ? 1 : 0;
666
+ }
667
+ /**
668
+ * Order two DSH versions with prerelease semantics (`rc.2 < rc.3 < release`).
669
+ * @param left - first version.
670
+ * @param right - second version.
671
+ * @returns -1/0/1, or undefined when either side is unparsable.
672
+ */
673
+ function compareDshVersions(left, right) {
674
+ const a = parseVersion(left);
675
+ const b = parseVersion(right);
676
+ if (a === void 0 || b === void 0) return void 0;
677
+ for (let index = 0; index < 3; index += 1) {
678
+ const difference = a.base[index] - b.base[index];
679
+ if (difference !== 0) return difference < 0 ? -1 : 1;
680
+ }
681
+ if (a.pre.length === 0 && b.pre.length === 0) return 0;
682
+ if (a.pre.length === 0) return 1;
683
+ if (b.pre.length === 0) return -1;
684
+ const shared = Math.min(a.pre.length, b.pre.length);
685
+ for (let index = 0; index < shared; index += 1) {
686
+ const difference = compareIdentifier(a.pre[index], b.pre[index]);
687
+ if (difference !== 0) return difference < 0 ? -1 : 1;
688
+ }
689
+ if (a.pre.length === b.pre.length) return 0;
690
+ return a.pre.length < b.pre.length ? -1 : 1;
691
+ }
692
+ /**
693
+ * Read the floor out of a declared runtime range.
694
+ *
695
+ * Only the open-ended `>=x.y.z` form is understood: the declaration promises
696
+ * "this release and everything after it", so a bounded range is a different
697
+ * statement and is ignored rather than half-honoured.
698
+ *
699
+ * @param range - the declared range text.
700
+ * @returns the floor version, or undefined when absent/misunderstood.
701
+ */
702
+ function runtimeFloorOf(range) {
703
+ if (typeof range !== "string") return void 0;
704
+ const match = /^\s*>=\s*([0-9A-Za-z.-]+)\s*$/.exec(range);
705
+ return match === null ? void 0 : match[1];
706
+ }
707
+ /**
642
708
  * Classify one runtime without treating the verified table as an allowlist.
709
+ *
710
+ * Precedence: a blocked version wins over everything; a version named in the
711
+ * evidence table is verified; otherwise a declared `dshRuntime` floor marks every
712
+ * runtime at or above it verified. Anything else stays unverified, and the mount
713
+ * path remains fail-open for it.
714
+ *
643
715
  * @param version - Resolved DSH runtime version.
644
716
  * @param verified - Releases with direct compatibility evidence.
645
717
  * @param blocklist - Versions excluded after reproduced failures.
718
+ * @param runtimeRange - Declared open-ended floor (`>=x.y.z`).
646
719
  * @returns The fail-open mount decision.
647
720
  */
648
- function classifyDshRuntime(version, verified, blocklist = {}) {
721
+ function classifyDshRuntime(version, verified, blocklist = {}, runtimeRange) {
649
722
  const reason = blocklist[version];
650
723
  if (typeof reason === "string" && reason.trim() !== "") return {
651
724
  kind: "blocked",
652
725
  reason
653
726
  };
654
- return verified.has(version) ? { kind: "verified" } : { kind: "unverified" };
727
+ if (verified.has(version)) return { kind: "verified" };
728
+ const floor = runtimeFloorOf(runtimeRange);
729
+ if (floor !== void 0) {
730
+ const order = compareDshVersions(version, floor);
731
+ if (order !== void 0 && order >= 0) return { kind: "verified" };
732
+ }
733
+ return { kind: "unverified" };
655
734
  }
656
735
  /**
657
736
  * Apply the fail-open decision and emit at most one visible warning.
@@ -660,10 +739,11 @@ function classifyDshRuntime(version, verified, blocklist = {}) {
660
739
  * @param version - Resolved DSH runtime version.
661
740
  * @param verified - Releases with direct compatibility evidence.
662
741
  * @param blocklist - Versions excluded after reproduced failures.
742
+ * @param runtimeRange - Declared open-ended floor (`>=x.y.z`).
663
743
  * @returns Whether the host mount should continue.
664
744
  */
665
- function shouldMountDshRuntime(logger, pluginName, version, verified, blocklist = {}) {
666
- const decision = classifyDshRuntime(version, verified, blocklist);
745
+ function shouldMountDshRuntime(logger, pluginName, version, verified, blocklist = {}, runtimeRange) {
746
+ const decision = classifyDshRuntime(version, verified, blocklist, runtimeRange);
667
747
  if (decision.kind === "blocked") {
668
748
  logger.warn(`[${pluginName}] blocked on DSH ${version}: ${decision.reason}; see package.json#dsh.compatibility.blocklist`);
669
749
  return false;
@@ -705,7 +785,7 @@ function packageVersion(packageName) {
705
785
  function allowDshRuntime(logger, pluginName, candidates) {
706
786
  const version = process.env.DSH_VERSION?.trim() || candidates.map(packageVersion).find((value) => value !== void 0) || "unknown";
707
787
  const compatibility = readManifest().dsh?.compatibility;
708
- return shouldMountDshRuntime(logger, pluginName, version, new Set(Object.entries(compatibility?.dshReleases ?? {}).filter(([, status]) => status === "compatible" || status === "verified").map(([release]) => release)), compatibility?.blocklist);
788
+ return shouldMountDshRuntime(logger, pluginName, version, new Set(Object.entries(compatibility?.dshReleases ?? {}).filter(([, status]) => status === "compatible" || status === "verified").map(([release]) => release)), compatibility?.blocklist, compatibility?.dshRuntime);
709
789
  }
710
790
  //#endregion
711
791
  //#region lib/types/preset-sync.js
@@ -1,6 +1,24 @@
1
1
  interface CompatibilityLogger {
2
2
  warn(message: string): void;
3
3
  }
4
+ /**
5
+ * Order two DSH versions with prerelease semantics (`rc.2 < rc.3 < release`).
6
+ * @param left - first version.
7
+ * @param right - second version.
8
+ * @returns -1/0/1, or undefined when either side is unparsable.
9
+ */
10
+ export declare function compareDshVersions(left: string, right: string): number | undefined;
11
+ /**
12
+ * Read the floor out of a declared runtime range.
13
+ *
14
+ * Only the open-ended `>=x.y.z` form is understood: the declaration promises
15
+ * "this release and everything after it", so a bounded range is a different
16
+ * statement and is ignored rather than half-honoured.
17
+ *
18
+ * @param range - the declared range text.
19
+ * @returns the floor version, or undefined when absent/misunderstood.
20
+ */
21
+ export declare function runtimeFloorOf(range: unknown): string | undefined;
4
22
  export type DshRuntimeClassification = {
5
23
  kind: 'verified';
6
24
  } | {
@@ -11,12 +29,19 @@ export type DshRuntimeClassification = {
11
29
  };
12
30
  /**
13
31
  * Classify one runtime without treating the verified table as an allowlist.
32
+ *
33
+ * Precedence: a blocked version wins over everything; a version named in the
34
+ * evidence table is verified; otherwise a declared `dshRuntime` floor marks every
35
+ * runtime at or above it verified. Anything else stays unverified, and the mount
36
+ * path remains fail-open for it.
37
+ *
14
38
  * @param version - Resolved DSH runtime version.
15
39
  * @param verified - Releases with direct compatibility evidence.
16
40
  * @param blocklist - Versions excluded after reproduced failures.
41
+ * @param runtimeRange - Declared open-ended floor (`>=x.y.z`).
17
42
  * @returns The fail-open mount decision.
18
43
  */
19
- export declare function classifyDshRuntime(version: string, verified: ReadonlySet<string>, blocklist?: Readonly<Record<string, unknown>>): DshRuntimeClassification;
44
+ export declare function classifyDshRuntime(version: string, verified: ReadonlySet<string>, blocklist?: Readonly<Record<string, unknown>>, runtimeRange?: unknown): DshRuntimeClassification;
20
45
  /**
21
46
  * Apply the fail-open decision and emit at most one visible warning.
22
47
  * @param logger - Host logger receiving compatibility warnings.
@@ -24,9 +49,10 @@ export declare function classifyDshRuntime(version: string, verified: ReadonlySe
24
49
  * @param version - Resolved DSH runtime version.
25
50
  * @param verified - Releases with direct compatibility evidence.
26
51
  * @param blocklist - Versions excluded after reproduced failures.
52
+ * @param runtimeRange - Declared open-ended floor (`>=x.y.z`).
27
53
  * @returns Whether the host mount should continue.
28
54
  */
29
- export declare function shouldMountDshRuntime(logger: CompatibilityLogger, pluginName: string, version: string, verified: ReadonlySet<string>, blocklist?: Readonly<Record<string, unknown>>): boolean;
55
+ export declare function shouldMountDshRuntime(logger: CompatibilityLogger, pluginName: string, version: string, verified: ReadonlySet<string>, blocklist?: Readonly<Record<string, unknown>>, runtimeRange?: unknown): boolean;
30
56
  /**
31
57
  * Warn once for an unknown runtime while keeping the normal host mount path.
32
58
  * @param logger - Host logger receiving compatibility warnings.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-model-switch",
3
- "version": "0.4.47",
3
+ "version": "0.4.48",
4
4
  "description": "Explicit model routing plus composer/Plan picker for DeepSeek Harness",
5
5
  "repository": {
6
6
  "type": "git",
@@ -110,6 +110,7 @@
110
110
  "platform": "web"
111
111
  },
112
112
  "compatibility": {
113
+ "dshRuntime": ">=0.2.0-rc.2",
113
114
  "dshReleases": {
114
115
  "0.1.7-alpha.2": "compatible",
115
116
  "0.1.7-rc.1": "compatible",