dsh-model-switch 0.4.46 → 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 +20 -0
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/lib/client.js +52 -120
- package/lib/index.js +100 -5
- package/lib/types/client/locales.d.ts +2 -2
- package/lib/types/compatibility.d.ts +28 -2
- package/lib/types/picker/plan-review.d.ts +15 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
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
|
+
|
|
11
|
+
## v0.4.47
|
|
12
|
+
|
|
13
|
+
两件用户可见修正(撤卡 + 计划卡换模型),均为热修。
|
|
14
|
+
|
|
15
|
+
- **设置页撤下「记忆蒸馏模型」卡片与供应商分组第五行**:该能力此前只有界面,路由未证实会改变 `dsh-prime-memory` 的实际蒸馏调用(见 `docs/route-verification.md` 的 memory 行与 `docs/prime-memory.md` 的负结果)。适配层 `src/prime-memory-compat.ts` 与 `memoryProvider` / `memoryModel` 设置字段**保留休眠**,等虚拟探针记录到 L1/L2/L3 命中配置路由后再恢复 UI(开关 `MEMORY_CAPABILITY_UI`);分组说明文案同步收回到「压缩、自动审查、会话命名、子代理」四项。
|
|
16
|
+
- **计划审阅卡换模型后点「拒绝」/「讨论」,会话仍用旧模型**:卡片内的执行模型选择器只写草稿,唯一提交点原本只在「接受」路径。现在四个出口(接受 / 拒绝 / 讨论 / 作为目标执行)统一先提交草稿再执行 —— `commitThen()` 复用 `approvePlanReview` 的「未变更短路、提交被拒则不答复」;提交被拒时卡片保持打开并显示原因,不再静默回退旧模型。
|
|
17
|
+
- **测试**:计划卡新增 3 例(拒绝时提交、提交被拒保持打开且不答复、讨论前提交),`tests/picker/plan-review-card.spec.tsx` 32 例全绿;`pnpm run check` 全绿。
|
|
18
|
+
- **规则固化**:`AGENTS.md` 新增「Lab 验证:全程虚拟请求/虚拟答复,零真实额度」;`tools/route-probe.mjs` 增加 `--preset`(`classifier-allow` / `classifier-deny` / `title` / `memory` / `plan`)与 `--tool` 工具调用回放;每日巡检 prompt 同步该约束。
|
|
19
|
+
- **未在本次完成**(按计划随后续版本走):记忆蒸馏路由落地与虚拟实测、DSH `0.2.1-rc.4` 的验证与声明、Auto review 与 automode 分类器的虚拟实测。
|
|
20
|
+
|
|
1
21
|
## v0.4.46
|
|
2
22
|
|
|
3
23
|
设置页「记忆蒸馏模型」的说明补上生效条件:**改完需重启一次 DSH**(该插件在启动时读取路由)。文案与实际行为对齐,避免再次出现"界面显示已改、实际调用没变"的误解。
|
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
|
|
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`
|
|
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/client.js
CHANGED
|
@@ -1743,7 +1743,7 @@ window.__ModuleLoader__.load({
|
|
|
1743
1743
|
const compactionChoices = deriveRouteChoices(groups, compactionDraft);
|
|
1744
1744
|
const compactionOn = routePairConfigured(compaction.value);
|
|
1745
1745
|
const titleChoices = deriveRouteChoices(groups, titleDraft);
|
|
1746
|
-
|
|
1746
|
+
deriveRouteChoices(groups, memoryDraft);
|
|
1747
1747
|
const titleOn = routePairConfigured(sessionTitle.value);
|
|
1748
1748
|
const catalogSeed = firstCatalogRoute(groups);
|
|
1749
1749
|
const synced = [
|
|
@@ -2030,7 +2030,7 @@ window.__ModuleLoader__.load({
|
|
|
2030
2030
|
const groupCompactionChoices = deriveRouteChoices(groups, groupCompaction);
|
|
2031
2031
|
const groupAutoReviewChoices = deriveRouteChoices(groups, groupAutoReview);
|
|
2032
2032
|
const groupTitleChoices = deriveRouteChoices(groups, groupTitle);
|
|
2033
|
-
|
|
2033
|
+
deriveRouteChoices(groups, groupMemory);
|
|
2034
2034
|
const groupSubagentChoices = deriveRouteChoices(groups, groupSubagent);
|
|
2035
2035
|
const groupSubMatched = matchCatalogModel(groups.find((group) => group.id === (groupDraft?.subagentProvider ?? ""))?.models ?? [], groupDraft?.subagentModel ?? "");
|
|
2036
2036
|
const groupSubEfforts = (() => {
|
|
@@ -2597,66 +2597,7 @@ window.__ModuleLoader__.load({
|
|
|
2597
2597
|
})
|
|
2598
2598
|
] })
|
|
2599
2599
|
}),
|
|
2600
|
-
|
|
2601
|
-
title: props.t("memory"),
|
|
2602
|
-
summary: memoryDraft === void 0 ? props.t("loading") : routePairConfigured(memoryDraft) ? routeName(groups, memoryDraft) : props.t("memoryFollow"),
|
|
2603
|
-
hint: props.t("memoryHelp"),
|
|
2604
|
-
note: groupNote(props.t, groupPins.memory),
|
|
2605
|
-
icon: "memory",
|
|
2606
|
-
open: open === "memory",
|
|
2607
|
-
onToggle: () => {
|
|
2608
|
-
toggle("memory");
|
|
2609
|
-
},
|
|
2610
|
-
children: memoryDraft === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2611
|
-
className: ModelSwitchSettings_module_css_default.hint,
|
|
2612
|
-
children: props.t("loading")
|
|
2613
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
2614
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2615
|
-
className: ModelSwitchSettings_module_css_default.hint,
|
|
2616
|
-
children: props.t("memoryRouteHelp")
|
|
2617
|
-
}),
|
|
2618
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2619
|
-
className: ModelSwitchSettings_module_css_default.formGrid,
|
|
2620
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2621
|
-
label: props.t("provider"),
|
|
2622
|
-
value: memoryDraft.provider ?? "",
|
|
2623
|
-
disabled: busy !== void 0 || !memory.writable,
|
|
2624
|
-
choices: memoryChoices.providers,
|
|
2625
|
-
onChange: (provider) => {
|
|
2626
|
-
const first = groups.find((group) => group.id === provider)?.models[0];
|
|
2627
|
-
setMemoryDraft({
|
|
2628
|
-
provider,
|
|
2629
|
-
...first === void 0 ? {} : { model: first.id }
|
|
2630
|
-
});
|
|
2631
|
-
}
|
|
2632
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2633
|
-
label: props.t("model"),
|
|
2634
|
-
value: memoryDraft.model ?? "",
|
|
2635
|
-
disabled: busy !== void 0 || !memory.writable,
|
|
2636
|
-
choices: memoryChoices.models,
|
|
2637
|
-
onChange: (model) => {
|
|
2638
|
-
setMemoryDraft({
|
|
2639
|
-
...memoryDraft,
|
|
2640
|
-
model
|
|
2641
|
-
});
|
|
2642
|
-
}
|
|
2643
|
-
})]
|
|
2644
|
-
}),
|
|
2645
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Actions, {
|
|
2646
|
-
t: props.t,
|
|
2647
|
-
busy: busy === "memory",
|
|
2648
|
-
disabled: busy !== void 0 || !memory.writable,
|
|
2649
|
-
...message?.route === "memory" ? { message: message.text } : {},
|
|
2650
|
-
onCancel: () => {
|
|
2651
|
-
resetMemory();
|
|
2652
|
-
setMessage(void 0);
|
|
2653
|
-
},
|
|
2654
|
-
onSave: () => {
|
|
2655
|
-
run("memory", () => props.saveCapability("memory", pairOps(memoryDraft)));
|
|
2656
|
-
}
|
|
2657
|
-
})
|
|
2658
|
-
] })
|
|
2659
|
-
})
|
|
2600
|
+
null
|
|
2660
2601
|
]
|
|
2661
2602
|
}),
|
|
2662
2603
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
@@ -3012,55 +2953,7 @@ window.__ModuleLoader__.load({
|
|
|
3012
2953
|
}
|
|
3013
2954
|
})]
|
|
3014
2955
|
}),
|
|
3015
|
-
|
|
3016
|
-
className: ModelSwitchSettings_module_css_default.rowCard,
|
|
3017
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3018
|
-
className: ModelSwitchSettings_module_css_default.rowCopy,
|
|
3019
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3020
|
-
className: ModelSwitchSettings_module_css_default.rowTitle,
|
|
3021
|
-
children: props.t("memory")
|
|
3022
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3023
|
-
className: ModelSwitchSettings_module_css_default.hint,
|
|
3024
|
-
children: groupMemory === void 0 ? props.t("memoryFollow") : routeName(groups, groupMemory)
|
|
3025
|
-
})]
|
|
3026
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InstantSwitch, {
|
|
3027
|
-
checked: groupMemory !== void 0,
|
|
3028
|
-
disabled: groupControlsDisabled || groupMemory === void 0 && catalogSeed === void 0,
|
|
3029
|
-
label: props.t("memory"),
|
|
3030
|
-
onChange: (value) => {
|
|
3031
|
-
if (value) enableGroupCapability("memory");
|
|
3032
|
-
else disableGroupCapability("memory");
|
|
3033
|
-
}
|
|
3034
|
-
})]
|
|
3035
|
-
}),
|
|
3036
|
-
groupMemory === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3037
|
-
className: ModelSwitchSettings_module_css_default.formGrid,
|
|
3038
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
3039
|
-
label: props.t("provider"),
|
|
3040
|
-
value: groupMemory.provider,
|
|
3041
|
-
disabled: groupControlsDisabled,
|
|
3042
|
-
choices: groupMemoryChoices.providers,
|
|
3043
|
-
onChange: (provider) => {
|
|
3044
|
-
const first = groups.find((item) => item.id === provider)?.models[0];
|
|
3045
|
-
setGroupDraft((draft) => draft === void 0 ? draft : {
|
|
3046
|
-
...draft,
|
|
3047
|
-
memoryProvider: provider,
|
|
3048
|
-
memoryModel: first?.id ?? ""
|
|
3049
|
-
});
|
|
3050
|
-
}
|
|
3051
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
3052
|
-
label: props.t("model"),
|
|
3053
|
-
value: groupMemory.model,
|
|
3054
|
-
disabled: groupControlsDisabled,
|
|
3055
|
-
choices: groupMemoryChoices.models,
|
|
3056
|
-
onChange: (model) => {
|
|
3057
|
-
setGroupDraft((draft) => draft === void 0 ? draft : {
|
|
3058
|
-
...draft,
|
|
3059
|
-
memoryModel: model
|
|
3060
|
-
});
|
|
3061
|
-
}
|
|
3062
|
-
})]
|
|
3063
|
-
}),
|
|
2956
|
+
null,
|
|
3064
2957
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3065
2958
|
className: ModelSwitchSettings_module_css_default.rowCard,
|
|
3066
2959
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -3208,8 +3101,8 @@ window.__ModuleLoader__.load({
|
|
|
3208
3101
|
providerGroups: "供应商配置组",
|
|
3209
3102
|
providerGroupsCard: "按供应商预设路由",
|
|
3210
3103
|
providerGroupsSummary: "使用该供应商的会话自动采用对应组",
|
|
3211
|
-
providerGroupsHelp: "
|
|
3212
|
-
providerGroupsBodyHelp: "
|
|
3104
|
+
providerGroupsHelp: "为压缩、自动审查、会话命名与子代理按供应商分别保存路由。",
|
|
3105
|
+
providerGroupsBodyHelp: "每个供应商保存一组压缩、自动审查、会话命名与子代理路由。会话自身的供应商与该组一致时,这四项能力按组实时解析,未固定项回落到上方卡片里的全局设置。切换某个会话的模型不会写入任何全局设置,因此不同供应商的多个会话并行时互不影响,会话中切换供应商后下一次调用也会立即跟随新供应商的配置组。",
|
|
3213
3106
|
providerGroupPick: "选择供应商以编辑其配置组。",
|
|
3214
3107
|
providerGroupDelete: "删除该组",
|
|
3215
3108
|
groupOverridesLabel: "组覆盖:{pins};无组时用上方默认值",
|
|
@@ -3295,8 +3188,8 @@ window.__ModuleLoader__.load({
|
|
|
3295
3188
|
providerGroups: "Provider groups",
|
|
3296
3189
|
providerGroupsCard: "Per-provider route presets",
|
|
3297
3190
|
providerGroupsSummary: "Sessions using that provider adopt this group",
|
|
3298
|
-
providerGroupsHelp: "Save compaction, auto-review, session-naming,
|
|
3299
|
-
providerGroupsBodyHelp: "Each provider stores one route group for compaction, auto review, session naming, and subagents. A session running on that provider resolves all
|
|
3191
|
+
providerGroupsHelp: "Save compaction, auto-review, session-naming, and subagent routes per provider.",
|
|
3192
|
+
providerGroupsBodyHelp: "Each provider stores one route group for compaction, auto review, session naming, and subagents. A session running on that provider resolves all four capabilities from the group and falls back to the cards above when a row is off. Switching a session’s model writes no global setting, so parallel sessions on different providers never affect each other, and mid-session provider switches take effect on the very next call.",
|
|
3300
3193
|
providerGroupPick: "Pick a provider to edit its group.",
|
|
3301
3194
|
providerGroupDelete: "Delete group",
|
|
3302
3195
|
groupOverridesLabel: "Group overrides: {pins}; without a group the default above applies",
|
|
@@ -3382,6 +3275,21 @@ window.__ModuleLoader__.load({
|
|
|
3382
3275
|
const code = codeOf(cause) ?? (cause instanceof Error ? codeOf(cause.cause) : void 0);
|
|
3383
3276
|
return code === void 0 ? message : `${code}: ${message}`;
|
|
3384
3277
|
}
|
|
3278
|
+
/**
|
|
3279
|
+
* Commit the execution model a Plan card holds, then run its exit.
|
|
3280
|
+
*
|
|
3281
|
+
* Shared by every exit (approve, keep, discuss, run-as-goal): the card's picker
|
|
3282
|
+
* is a draft, so an exit that skipped this call left the session on the model
|
|
3283
|
+
* the review opened with. An unchanged selection short-circuits without a
|
|
3284
|
+
* second commit, and a refused commit returns `false` **without** running the
|
|
3285
|
+
* exit, so the caller can keep the card open and show the error.
|
|
3286
|
+
*
|
|
3287
|
+
* @param args.select - commits one selection onto the session.
|
|
3288
|
+
* @param args.selection - the execution model the card currently holds.
|
|
3289
|
+
* @param args.current - the session's committed selection, for the short-circuit.
|
|
3290
|
+
* @param args.answer - the exit to run once the commit landed.
|
|
3291
|
+
* @returns whether the exit ran.
|
|
3292
|
+
*/
|
|
3385
3293
|
async function approvePlanReview(args) {
|
|
3386
3294
|
const current = args.current;
|
|
3387
3295
|
if (!(current !== void 0 && current !== null && current.provider === args.selection.provider && current.model === args.selection.model && current.reasoningEffort === args.selection.reasoningEffort ? { committed: true } : await args.select(args.selection)).committed) return false;
|
|
@@ -5229,18 +5137,40 @@ window.__ModuleLoader__.load({
|
|
|
5229
5137
|
blocked,
|
|
5230
5138
|
error
|
|
5231
5139
|
}, available, executionAllowed);
|
|
5232
|
-
/**
|
|
5233
|
-
|
|
5140
|
+
/**
|
|
5141
|
+
* Commit one execution model, then run the card exit.
|
|
5142
|
+
*
|
|
5143
|
+
* The picker on this card only holds a **draft** (`onDraftChange`), so a
|
|
5144
|
+
* model chosen here reaches the session only when something commits it. That
|
|
5145
|
+
* used to be Approve alone: keeping the plan or withdrawing to the composer
|
|
5146
|
+
* silently discarded the change and the conversation continued on the
|
|
5147
|
+
* previous model. Every exit now runs through this helper instead.
|
|
5148
|
+
*
|
|
5149
|
+
* @param model - the execution model to commit; `undefined` means the card
|
|
5150
|
+
* has not resolved a picker yet, so the exit runs uncommitted.
|
|
5151
|
+
* @param act - the exit to perform once the commit landed.
|
|
5152
|
+
* @returns nothing; a refused commit throws so the card stays open with the
|
|
5153
|
+
* error, exactly like a refused approval, instead of dropping the choice.
|
|
5154
|
+
*/
|
|
5155
|
+
const commitThen = async (model, act) => {
|
|
5156
|
+
if (model === void 0) {
|
|
5157
|
+
await act();
|
|
5158
|
+
return;
|
|
5159
|
+
}
|
|
5234
5160
|
if (!await approvePlanReview({
|
|
5235
5161
|
select,
|
|
5236
5162
|
selection: model,
|
|
5237
5163
|
current: snapshot.current,
|
|
5238
|
-
answer:
|
|
5164
|
+
answer: act
|
|
5239
5165
|
})) {
|
|
5240
5166
|
const message = getDirectorySnapshot().error;
|
|
5241
5167
|
throw new Error(message === null ? t("plan.modelFailed") : t("error.action", { message }));
|
|
5242
5168
|
}
|
|
5243
5169
|
};
|
|
5170
|
+
/** Commit whatever the picker currently holds, then run the exit. */
|
|
5171
|
+
const commitDraftThen = (act) => commitThen(execution, act);
|
|
5172
|
+
/** Approve this review after committing its execution model; a refused commit keeps the Plan pending. */
|
|
5173
|
+
const approveWith = (model) => commitThen(model, () => respondAnswer(matched, review.id, review.approve.label, t("plan.responseRejected"), true));
|
|
5244
5174
|
const onApprove = () => {
|
|
5245
5175
|
if (execution === void 0 || !executionAllowed || !available || busy || blocked) return;
|
|
5246
5176
|
settle(async () => {
|
|
@@ -5382,7 +5312,9 @@ window.__ModuleLoader__.load({
|
|
|
5382
5312
|
disabled: busy,
|
|
5383
5313
|
onClick: () => {
|
|
5384
5314
|
settle(async () => {
|
|
5385
|
-
await
|
|
5315
|
+
await commitDraftThen(async () => {
|
|
5316
|
+
await discussPlan(cancelTurn, matched.sessionId, () => respondDismiss(matched, t("plan.cancelRejected"), t("plan.dismissUnsupported")));
|
|
5317
|
+
});
|
|
5386
5318
|
}, true);
|
|
5387
5319
|
},
|
|
5388
5320
|
children: t("plan.discuss")
|
|
@@ -5393,7 +5325,7 @@ window.__ModuleLoader__.load({
|
|
|
5393
5325
|
disabled: busy || blocked,
|
|
5394
5326
|
title: decline.description ?? t("plan.keep"),
|
|
5395
5327
|
onClick: () => {
|
|
5396
|
-
settle(() => respondAnswer(matched, review.id, decline.label, t("plan.responseRejected"), false, feedback.trim()));
|
|
5328
|
+
settle(() => commitDraftThen(() => respondAnswer(matched, review.id, decline.label, t("plan.responseRejected"), false, feedback.trim())));
|
|
5397
5329
|
},
|
|
5398
5330
|
children: t("plan.keep")
|
|
5399
5331
|
}),
|
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
|
-
|
|
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
|
|
@@ -999,6 +1079,21 @@ function selectPlanReview(owner) {
|
|
|
999
1079
|
if (interaction === void 0 || interaction.kind !== "question" && interaction.kind !== "plan-review") return null;
|
|
1000
1080
|
return planReviewOf(interaction.questions) === void 0 ? null : interaction;
|
|
1001
1081
|
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Commit the execution model a Plan card holds, then run its exit.
|
|
1084
|
+
*
|
|
1085
|
+
* Shared by every exit (approve, keep, discuss, run-as-goal): the card's picker
|
|
1086
|
+
* is a draft, so an exit that skipped this call left the session on the model
|
|
1087
|
+
* the review opened with. An unchanged selection short-circuits without a
|
|
1088
|
+
* second commit, and a refused commit returns `false` **without** running the
|
|
1089
|
+
* exit, so the caller can keep the card open and show the error.
|
|
1090
|
+
*
|
|
1091
|
+
* @param args.select - commits one selection onto the session.
|
|
1092
|
+
* @param args.selection - the execution model the card currently holds.
|
|
1093
|
+
* @param args.current - the session's committed selection, for the short-circuit.
|
|
1094
|
+
* @param args.answer - the exit to run once the commit landed.
|
|
1095
|
+
* @returns whether the exit ran.
|
|
1096
|
+
*/
|
|
1002
1097
|
async function approvePlanReview(args) {
|
|
1003
1098
|
const current = args.current;
|
|
1004
1099
|
if (!(current !== void 0 && current !== null && current.provider === args.selection.provider && current.model === args.selection.model && current.reasoningEffort === args.selection.reasoningEffort ? { committed: true } : await args.select(args.selection)).committed) return false;
|
|
@@ -49,8 +49,8 @@ export declare const zh: {
|
|
|
49
49
|
readonly providerGroups: "供应商配置组";
|
|
50
50
|
readonly providerGroupsCard: "按供应商预设路由";
|
|
51
51
|
readonly providerGroupsSummary: "使用该供应商的会话自动采用对应组";
|
|
52
|
-
readonly providerGroupsHelp: "
|
|
53
|
-
readonly providerGroupsBodyHelp: "
|
|
52
|
+
readonly providerGroupsHelp: "为压缩、自动审查、会话命名与子代理按供应商分别保存路由。";
|
|
53
|
+
readonly providerGroupsBodyHelp: "每个供应商保存一组压缩、自动审查、会话命名与子代理路由。会话自身的供应商与该组一致时,这四项能力按组实时解析,未固定项回落到上方卡片里的全局设置。切换某个会话的模型不会写入任何全局设置,因此不同供应商的多个会话并行时互不影响,会话中切换供应商后下一次调用也会立即跟随新供应商的配置组。";
|
|
54
54
|
readonly providerGroupPick: "选择供应商以编辑其配置组。";
|
|
55
55
|
readonly providerGroupDelete: "删除该组";
|
|
56
56
|
readonly groupOverridesLabel: "组覆盖:{pins};无组时用上方默认值";
|
|
@@ -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
|
|
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
|
|
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.
|
|
@@ -30,6 +30,21 @@ export interface PlanCommitOutcome {
|
|
|
30
30
|
* @returns The message, prefixed with the nearest available code.
|
|
31
31
|
*/
|
|
32
32
|
export declare function planErrorText(cause: unknown): string;
|
|
33
|
+
/**
|
|
34
|
+
* Commit the execution model a Plan card holds, then run its exit.
|
|
35
|
+
*
|
|
36
|
+
* Shared by every exit (approve, keep, discuss, run-as-goal): the card's picker
|
|
37
|
+
* is a draft, so an exit that skipped this call left the session on the model
|
|
38
|
+
* the review opened with. An unchanged selection short-circuits without a
|
|
39
|
+
* second commit, and a refused commit returns `false` **without** running the
|
|
40
|
+
* exit, so the caller can keep the card open and show the error.
|
|
41
|
+
*
|
|
42
|
+
* @param args.select - commits one selection onto the session.
|
|
43
|
+
* @param args.selection - the execution model the card currently holds.
|
|
44
|
+
* @param args.current - the session's committed selection, for the short-circuit.
|
|
45
|
+
* @param args.answer - the exit to run once the commit landed.
|
|
46
|
+
* @returns whether the exit ran.
|
|
47
|
+
*/
|
|
33
48
|
export declare function approvePlanReview(args: {
|
|
34
49
|
select: (selection: ModelSelection) => Promise<PlanCommitOutcome>;
|
|
35
50
|
selection: ModelSelection;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-model-switch",
|
|
3
|
-
"version": "0.4.
|
|
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",
|