dsh-model-switch 0.4.52 → 0.4.54
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 +22 -0
- package/lib/automode-compat.js +49 -8
- package/lib/client.js +116 -10
- package/lib/fiber-hot-update-DrZANcwD.js +74 -0
- package/lib/index.js +9 -1
- package/lib/prime-memory-compat.js +76 -12
- package/lib/review-timeout-DXRFybFp.js +331 -0
- package/lib/review-timeout.js +2 -238
- package/lib/types/automode-compat.d.ts +8 -0
- package/lib/types/capabilities-rpc.d.ts +10 -0
- package/lib/types/client/locales.d.ts +3 -3
- package/lib/types/fiber-hot-update.d.ts +58 -0
- package/lib/types/prime-memory-compat.d.ts +27 -0
- package/lib/types/review-timeout.d.ts +31 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## v0.4.54
|
|
2
|
+
|
|
3
|
+
记忆蒸馏路由**做通了并重新上线**(此前因未证实而撤卡)。
|
|
4
|
+
|
|
5
|
+
- **根因(lab 实测定位)**:`dsh-prime-memory` 的 `effectiveCfg` 只要 `cfg.llm.provider+model` 非空就视为 pinned,**同时忽略运行时链与 `distillProvider/distillModel` 对**。本插件早期写入的静态 pin 因此一直压过后续所有 live 写入——表现为「卡片改了、实际调用没变」。
|
|
6
|
+
- **修复**:①live 推送被确认成功后,主动删除自己写过的 `llm:` 块(`clearStaticPin`),让 live 对真正生效;②静态 pin 不再抢先写入,改为 **live 尝试耗尽后**的最后手段(`pinAsFallback`,4 次重试后)。
|
|
7
|
+
- **证据(virtual / 零真实额度,记录器 `D:\dsh-artifacts\probe-hot.jsonl`)**:删 pin 后启动不再回写 pin;把本插件的记忆路由改成 `apigoto/gpt-6.1-sol` 重启 → 插件日志 `蒸馏模型路由: apigoto/gpt-6.1-sol`;`rebuild-start` 对 6 条合成 L0 触发真实蒸馏 → 探针记录 `gpt-6.1-sol: 3`、插件日志 `LLM 调用 apigoto/gpt-6.1-sol`。
|
|
8
|
+
- **卡恢复**:`MEMORY_CAPABILITY_UI = true`,「记忆蒸馏模型」卡片与分组行重新上线;文案改为「反复重试仍写不进去时才回落静态路由」。
|
|
9
|
+
- **已知限制(如实记录)**:新的路由要等本插件该行重跑才会被推送(重启,或经我们设置服务的改动);`dsh-prime-memory` 自身 `engines.dsh` 只声明到 `0.2.1-rc.4`,在 rc.5 上宿主会跳过该 bundle,与本插件无关。
|
|
10
|
+
- **新增测试**:`tests/prime-memory-pin.spec.ts` 3 例(写入 → 清除 → 幂等清除 / 无该行 / 文档缺失)。
|
|
11
|
+
|
|
12
|
+
## v0.4.53
|
|
13
|
+
|
|
14
|
+
「自动审查模型」与「审查超时」两项设置改为**热生效**,不再需要重启 DSH。
|
|
15
|
+
|
|
16
|
+
- **机制**:用 Cordis 已发布的 `Fiber.update(config, noSave)`(`cordis/lib/types/fiber.d.ts:187-199`:校验→`internal/update` 瀑布→重挂该行,`noSave` 提示不写回持久化)把新配置推给正在运行的行。新增 `src/fiber-hot-update.ts`:只对 `ACTIVE` 的 fiber 动作,返回 `updated` / `no-fiber` / `not-active` / `failed`,异常全部包住,自身不持久化任何东西。
|
|
17
|
+
- **automode 分类器路由**:设置变化且路由相对上次写入发生变化时才重挂。必须走重挂——该行的 `apply(ctx, rawConfig)` 用 zod `Config()` 解析出闭包副本,只替换 `entry.options.config` 触达不到运行中的实例。**副作用**:重挂会清空该行的判定缓存与每会话断路器计数。
|
|
18
|
+
- **审查超时**:文档写入成功后重挂 `llm-pi-ai` 行使新值立即生效;文档仍是持久副本,重挂不可用(无活实例 / 校验失败 / 被瀑布否决)时回落到下次启动,状态里标注 `restart-required`。**副作用**:重挂会中断该 provider 的在途调用,因此只在值真正变化时触发。
|
|
19
|
+
- **状态面**:capabilities RPC 的 `status` 新增 `automode.hot/hotReason` 与 `reviewTimeout{configuredMs,applied,hotApplied,hot,hotReason}`;设置页文案改为“立即生效 + 副作用 + 回落说明”。
|
|
20
|
+
- **lab 证据(virtual / 零真实额度,`D:\dsh-lab`)**:编辑 profile 触发 loader volatile-update 后**未重启**——automode 路由 `probe/gpt-6-luna` → `probe/deepseek-flash` 且 `hot: applied`;`autoReviewTimeoutMs` 设为 5 → 文档写入 `streamIdleTimeoutMs: 5`、`hotApplied: ["probe"]`、`hot: applied`;随后 30 秒 profile 哈希稳定(无重挂循环),profile 里没有 `classifier`(内存态未持久化)。
|
|
21
|
+
- **未验证(如实记录)**:热生效之后「下一次审查请求确实使用新路由/新超时」的请求级行为没有单独取证;重挂被上游否决时的回落只有单测覆盖。
|
|
22
|
+
|
|
1
23
|
## v0.4.52
|
|
2
24
|
|
|
3
25
|
修复一个自维持的 recompose 循环(lab 实测定位,DSH 0.2.1-rc.3 + dsh-prime-memory 0.26.10):
|
package/lib/automode-compat.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as DEFAULT_READ_ONLY_TOOLS } from "./tool-allowlist-DlzB5GlQ.js";
|
|
2
|
+
import { t as applyFiberConfig } from "./fiber-hot-update-DrZANcwD.js";
|
|
2
3
|
//#region lib/types/automode-compat.js
|
|
3
4
|
/** Cordis plugin identity; matches the `cordis.patch.yml` insert row id. */
|
|
4
5
|
const name = "model-switch-automode-compat";
|
|
@@ -19,7 +20,11 @@ const automodeCompatStatus = {
|
|
|
19
20
|
/** Pattern-shaped entries that cannot transfer. */
|
|
20
21
|
skipped: [],
|
|
21
22
|
/** How many rows were rewritten (remounts included). */
|
|
22
|
-
applied: 0
|
|
23
|
+
applied: 0,
|
|
24
|
+
/** Last hot-reload outcome, once a changed route was pushed into the live row. */
|
|
25
|
+
hot: void 0,
|
|
26
|
+
/** Why the last hot reload did not take, when it did not. */
|
|
27
|
+
hotReason: void 0
|
|
23
28
|
};
|
|
24
29
|
/** Plain-object guard: arrays and `null` are not config objects. */
|
|
25
30
|
function asRecord(value) {
|
|
@@ -189,7 +194,9 @@ function automodeCompatView() {
|
|
|
189
194
|
route: automodeCompatStatus.route,
|
|
190
195
|
routeSkipped: automodeCompatStatus.routeSkipped,
|
|
191
196
|
added: automodeCompatStatus.added.length,
|
|
192
|
-
skipped: automodeCompatStatus.skipped.length
|
|
197
|
+
skipped: automodeCompatStatus.skipped.length,
|
|
198
|
+
hot: automodeCompatStatus.hot,
|
|
199
|
+
hotReason: automodeCompatStatus.hotReason
|
|
193
200
|
};
|
|
194
201
|
}
|
|
195
202
|
/**
|
|
@@ -211,11 +218,45 @@ function installAutomodeCompat(ctx, loader, settings) {
|
|
|
211
218
|
const applied = /* @__PURE__ */ new Map();
|
|
212
219
|
/** Entry → the route this adapter wrote, so a replay may rewrite its own value. */
|
|
213
220
|
const adopted = /* @__PURE__ */ new Map();
|
|
214
|
-
|
|
215
|
-
|
|
221
|
+
/** Entries whose fiber reload is in flight, so one change cannot restart twice. */
|
|
222
|
+
const reloading = /* @__PURE__ */ new Set();
|
|
223
|
+
/**
|
|
224
|
+
* Push a changed route into the row that is already running.
|
|
225
|
+
*
|
|
226
|
+
* `dsh-automode` passes its raw config through `Config(rawConfig)` (a zod
|
|
227
|
+
* schema) at activation, so the running instance holds a parsed copy: rewriting
|
|
228
|
+
* `entry.options.config` cannot reach it. Only a fiber reload re-runs `apply`
|
|
229
|
+
* with the adapted config. The reload disposes that instance, so its verdict
|
|
230
|
+
* cache and per-session breaker counters are gone afterwards.
|
|
231
|
+
*
|
|
232
|
+
* A reload that cannot run (`no-fiber` / `not-active`) is not an error: nothing
|
|
233
|
+
* is running that could be stale, and the next mount reads the adapted config.
|
|
234
|
+
*/
|
|
235
|
+
const hotApply = (entry, plan, previous) => {
|
|
236
|
+
const route = plan.applied.route;
|
|
237
|
+
if (route === void 0 || route === previous || reloading.has(entry)) return;
|
|
238
|
+
reloading.add(entry);
|
|
239
|
+
applyFiberConfig(entry, plan.config).then((result) => {
|
|
240
|
+
reloading.delete(entry);
|
|
241
|
+
if (result.outcome === "updated") {
|
|
242
|
+
automodeCompatStatus.hot = "applied";
|
|
243
|
+
automodeCompatStatus.hotReason = void 0;
|
|
244
|
+
log.info(`model-switch: reloaded dsh-automode with ${route} (verdict cache and breaker counters were reset)`);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (result.outcome !== "failed") return;
|
|
248
|
+
automodeCompatStatus.hot = "restart-required";
|
|
249
|
+
automodeCompatStatus.hotReason = result.error ?? "reload failed";
|
|
250
|
+
log.warn(`model-switch: the dsh-automode reload with ${route} failed (${result.error ?? "unknown error"}); the new route applies after a Host restart`);
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
const applying = (entry, hot) => {
|
|
254
|
+
const previous = adopted.get(entry);
|
|
255
|
+
const plan = adaptEntry(entry, settings, log, previous);
|
|
216
256
|
if (plan === void 0) return;
|
|
217
257
|
if (plan.applied.route !== void 0) adopted.set(entry, plan.applied.route);
|
|
218
258
|
else if (plan.applied.routeSkipped === "user-set") adopted.delete(entry);
|
|
259
|
+
if (hot) hotApply(entry, plan, previous);
|
|
219
260
|
const summary = describeAutomodePlan(plan);
|
|
220
261
|
lastSummary = summary;
|
|
221
262
|
if (!plan.changed) return;
|
|
@@ -224,21 +265,21 @@ function installAutomodeCompat(ctx, loader, settings) {
|
|
|
224
265
|
log.info(`model-switch: adapted dsh-automode (${summary})`);
|
|
225
266
|
};
|
|
226
267
|
if (loader !== void 0 && typeof loader.entries === "function") {
|
|
227
|
-
for (const entry of loader.entries()) if (isAutomodeEntry(entry)) applying(entry);
|
|
268
|
+
for (const entry of loader.entries()) if (isAutomodeEntry(entry)) applying(entry, false);
|
|
228
269
|
}
|
|
229
270
|
const dispose = ctx.on("loader/patch-context", function(first, second) {
|
|
230
271
|
const nextFn = typeof first === "function" ? first : second;
|
|
231
272
|
const candidate = typeof first === "function" ? this : first;
|
|
232
|
-
if (isAutomodeEntry(candidate)) applying(candidate);
|
|
273
|
+
if (isAutomodeEntry(candidate)) applying(candidate, false);
|
|
233
274
|
return nextFn === void 0 ? void 0 : nextFn();
|
|
234
275
|
});
|
|
235
|
-
/** Re-adapt every live row (settings changed under us). */
|
|
276
|
+
/** Re-adapt every live row (settings changed under us) and reload the ones whose route moved. */
|
|
236
277
|
const replay = () => {
|
|
237
278
|
let any = false;
|
|
238
279
|
for (const entry of loader?.entries?.() ?? []) {
|
|
239
280
|
if (!isAutomodeEntry(entry)) continue;
|
|
240
281
|
any = true;
|
|
241
|
-
applying(entry);
|
|
282
|
+
applying(entry, true);
|
|
242
283
|
}
|
|
243
284
|
return any;
|
|
244
285
|
};
|
package/lib/client.js
CHANGED
|
@@ -1745,7 +1745,7 @@ window.__ModuleLoader__.load({
|
|
|
1745
1745
|
const compactionChoices = deriveRouteChoices(groups, compactionDraft);
|
|
1746
1746
|
const compactionOn = routePairConfigured(compaction.value);
|
|
1747
1747
|
const titleChoices = deriveRouteChoices(groups, titleDraft);
|
|
1748
|
-
deriveRouteChoices(groups, memoryDraft);
|
|
1748
|
+
const memoryChoices = deriveRouteChoices(groups, memoryDraft);
|
|
1749
1749
|
const titleOn = routePairConfigured(sessionTitle.value);
|
|
1750
1750
|
const catalogSeed = firstCatalogRoute(groups);
|
|
1751
1751
|
const synced = [
|
|
@@ -2055,7 +2055,7 @@ window.__ModuleLoader__.load({
|
|
|
2055
2055
|
const groupCompactionChoices = deriveRouteChoices(groups, groupCompaction);
|
|
2056
2056
|
const groupAutoReviewChoices = deriveRouteChoices(groups, groupAutoReview);
|
|
2057
2057
|
const groupTitleChoices = deriveRouteChoices(groups, groupTitle);
|
|
2058
|
-
deriveRouteChoices(groups, groupMemory);
|
|
2058
|
+
const groupMemoryChoices = deriveRouteChoices(groups, groupMemory);
|
|
2059
2059
|
const groupSubagentChoices = deriveRouteChoices(groups, groupSubagent);
|
|
2060
2060
|
const groupSubMatched = matchCatalogModel(groups.find((group) => group.id === (groupDraft?.subagentProvider ?? ""))?.models ?? [], groupDraft?.subagentModel ?? "");
|
|
2061
2061
|
const groupSubEfforts = (() => {
|
|
@@ -2622,7 +2622,66 @@ window.__ModuleLoader__.load({
|
|
|
2622
2622
|
})
|
|
2623
2623
|
] })
|
|
2624
2624
|
}),
|
|
2625
|
-
|
|
2625
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteCard, {
|
|
2626
|
+
title: props.t("memory"),
|
|
2627
|
+
summary: memoryDraft === void 0 ? props.t("loading") : routePairConfigured(memoryDraft) ? routeName(groups, memoryDraft) : props.t("memoryFollow"),
|
|
2628
|
+
hint: props.t("memoryHelp"),
|
|
2629
|
+
note: groupNote(props.t, groupPins.memory),
|
|
2630
|
+
icon: "memory",
|
|
2631
|
+
open: open === "memory",
|
|
2632
|
+
onToggle: () => {
|
|
2633
|
+
toggle("memory");
|
|
2634
|
+
},
|
|
2635
|
+
children: memoryDraft === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2636
|
+
className: ModelSwitchSettings_module_css_default.hint,
|
|
2637
|
+
children: props.t("loading")
|
|
2638
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
2639
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2640
|
+
className: ModelSwitchSettings_module_css_default.hint,
|
|
2641
|
+
children: props.t("memoryRouteHelp")
|
|
2642
|
+
}),
|
|
2643
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2644
|
+
className: ModelSwitchSettings_module_css_default.formGrid,
|
|
2645
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2646
|
+
label: props.t("provider"),
|
|
2647
|
+
value: memoryDraft.provider ?? "",
|
|
2648
|
+
disabled: busy !== void 0 || !memory.writable,
|
|
2649
|
+
choices: memoryChoices.providers,
|
|
2650
|
+
onChange: (provider) => {
|
|
2651
|
+
const first = groups.find((group) => group.id === provider)?.models[0];
|
|
2652
|
+
setMemoryDraft({
|
|
2653
|
+
provider,
|
|
2654
|
+
...first === void 0 ? {} : { model: first.id }
|
|
2655
|
+
});
|
|
2656
|
+
}
|
|
2657
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2658
|
+
label: props.t("model"),
|
|
2659
|
+
value: memoryDraft.model ?? "",
|
|
2660
|
+
disabled: busy !== void 0 || !memory.writable,
|
|
2661
|
+
choices: memoryChoices.models,
|
|
2662
|
+
onChange: (model) => {
|
|
2663
|
+
setMemoryDraft({
|
|
2664
|
+
...memoryDraft,
|
|
2665
|
+
model
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
2668
|
+
})]
|
|
2669
|
+
}),
|
|
2670
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Actions, {
|
|
2671
|
+
t: props.t,
|
|
2672
|
+
busy: busy === "memory",
|
|
2673
|
+
disabled: busy !== void 0 || !memory.writable,
|
|
2674
|
+
...message?.route === "memory" ? { message: message.text } : {},
|
|
2675
|
+
onCancel: () => {
|
|
2676
|
+
resetMemory();
|
|
2677
|
+
setMessage(void 0);
|
|
2678
|
+
},
|
|
2679
|
+
onSave: () => {
|
|
2680
|
+
run("memory", () => props.saveCapability("memory", pairOps(memoryDraft)));
|
|
2681
|
+
}
|
|
2682
|
+
})
|
|
2683
|
+
] })
|
|
2684
|
+
})
|
|
2626
2685
|
]
|
|
2627
2686
|
}),
|
|
2628
2687
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
@@ -3059,7 +3118,54 @@ window.__ModuleLoader__.load({
|
|
|
3059
3118
|
}
|
|
3060
3119
|
})]
|
|
3061
3120
|
}),
|
|
3062
|
-
|
|
3121
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3122
|
+
className: ModelSwitchSettings_module_css_default.rowCard,
|
|
3123
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3124
|
+
className: ModelSwitchSettings_module_css_default.rowCopy,
|
|
3125
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3126
|
+
className: ModelSwitchSettings_module_css_default.rowTitle,
|
|
3127
|
+
children: props.t("memory")
|
|
3128
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3129
|
+
className: ModelSwitchSettings_module_css_default.hint,
|
|
3130
|
+
children: groupMemory === void 0 ? props.t("memoryFollow") : routeName(groups, groupMemory)
|
|
3131
|
+
})]
|
|
3132
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InstantSwitch, {
|
|
3133
|
+
checked: groupMemory !== void 0,
|
|
3134
|
+
disabled: groupControlsDisabled || groupMemory === void 0 && catalogSeed === void 0,
|
|
3135
|
+
label: props.t("memory"),
|
|
3136
|
+
onChange: (value) => {
|
|
3137
|
+
if (value) enableGroupCapability("memory");
|
|
3138
|
+
else disableGroupCapability("memory");
|
|
3139
|
+
}
|
|
3140
|
+
})]
|
|
3141
|
+
}), groupMemory === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3142
|
+
className: ModelSwitchSettings_module_css_default.formGrid,
|
|
3143
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
3144
|
+
label: props.t("provider"),
|
|
3145
|
+
value: groupMemory.provider,
|
|
3146
|
+
disabled: groupControlsDisabled,
|
|
3147
|
+
choices: groupMemoryChoices.providers,
|
|
3148
|
+
onChange: (provider) => {
|
|
3149
|
+
const first = groups.find((item) => item.id === provider)?.models[0];
|
|
3150
|
+
setGroupDraft((draft) => draft === void 0 ? draft : {
|
|
3151
|
+
...draft,
|
|
3152
|
+
memoryProvider: provider,
|
|
3153
|
+
memoryModel: first?.id ?? ""
|
|
3154
|
+
});
|
|
3155
|
+
}
|
|
3156
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
3157
|
+
label: props.t("model"),
|
|
3158
|
+
value: groupMemory.model,
|
|
3159
|
+
disabled: groupControlsDisabled,
|
|
3160
|
+
choices: groupMemoryChoices.models,
|
|
3161
|
+
onChange: (model) => {
|
|
3162
|
+
setGroupDraft((draft) => draft === void 0 ? draft : {
|
|
3163
|
+
...draft,
|
|
3164
|
+
memoryModel: model
|
|
3165
|
+
});
|
|
3166
|
+
}
|
|
3167
|
+
})]
|
|
3168
|
+
})] }),
|
|
3063
3169
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3064
3170
|
className: ModelSwitchSettings_module_css_default.rowCard,
|
|
3065
3171
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -3202,8 +3308,8 @@ window.__ModuleLoader__.load({
|
|
|
3202
3308
|
titleRouteHelp: "命名请求固定使用这里的 Provider/模型(不带推理强度);关闭时跟随会话模型。保存后立即对下一次命名生效,不会中断正在进行的命名,会话日志记录的也是实际使用的模型。",
|
|
3203
3309
|
memory: "记忆蒸馏模型",
|
|
3204
3310
|
memoryFollow: "跟随记忆插件默认",
|
|
3205
|
-
memoryHelp: "为 dsh-prime-memory
|
|
3206
|
-
memoryRouteHelp: "
|
|
3311
|
+
memoryHelp: "为 dsh-prime-memory 的记忆蒸馏指定路由;两个字段都留空时跟随该插件自己的默认模型。保存后立即生效(写入该插件自己的 live 设置,运行中的实例会读到);只有反复重试仍写不进去时才回落到静态路由(下次启动生效)。",
|
|
3312
|
+
memoryRouteHelp: "按部署默认供应商的配置组解析;该供应商没有组时使用这里填写的平面默认。优先写该行的 live 设置(立即生效),不可用时写静态路由(llm.provider/llm.model),启动时生效。",
|
|
3207
3313
|
providerGroups: "供应商配置组",
|
|
3208
3314
|
providerGroupsCard: "按供应商预设路由",
|
|
3209
3315
|
providerGroupsSummary: "使用该供应商的会话自动采用对应组",
|
|
@@ -3235,7 +3341,7 @@ window.__ModuleLoader__.load({
|
|
|
3235
3341
|
reviewAllowlistSkipped: "本 Host 进程已为纯读调用跳过 {count} 次审查。",
|
|
3236
3342
|
reviewTimeout: "审查超时",
|
|
3237
3343
|
reviewTimeoutDefault: "跟随 Provider 默认(300 秒)",
|
|
3238
|
-
reviewTimeoutHelp: "设置自动审查请求的流式空闲超时。留空恢复 Provider 默认值;勾选「取消超时」写入上游上限(约 24.8
|
|
3344
|
+
reviewTimeoutHelp: "设置自动审查请求的流式空闲超时。留空恢复 Provider 默认值;勾选「取消超时」写入上游上限(约 24.8 天),审查将不会因空闲而超时。保存后会立即重挂审查模型所在的 Provider 使其生效,重挂会中断该 Provider 的在途调用;重挂不了时回落到下次启动生效。",
|
|
3239
3345
|
reviewTimeoutScope: "注意:该值写入审查模型所在 Provider 的 streamIdleTimeoutMs,对该 Provider 的所有调用(含主对话)生效,不只影响审查请求。",
|
|
3240
3346
|
reviewTimeoutSeconds: "超时秒数",
|
|
3241
3347
|
reviewTimeoutPlaceholder: "300(默认)",
|
|
@@ -3299,8 +3405,8 @@ window.__ModuleLoader__.load({
|
|
|
3299
3405
|
titleRouteHelp: "Naming requests use exactly this provider/model (no reasoning effort); when off they follow the session model. A saved change applies to the very next title, never interrupts a running one, and the session log records the route actually used.",
|
|
3300
3406
|
memory: "Memory distillation model",
|
|
3301
3407
|
memoryFollow: "Follows the memory plugin default",
|
|
3302
|
-
memoryHelp: "Pin the distillation route for dsh-prime-memory. Both fields empty keeps that plugin on its own default model.
|
|
3303
|
-
memoryRouteHelp: "Resolved from the deployment default provider group; without a group the flat pair here applies.
|
|
3408
|
+
memoryHelp: "Pin the distillation route for dsh-prime-memory. Both fields empty keeps that plugin on its own default model. Saved changes apply immediately through that plugin’s own live settings; only after the live attempts keep failing does the static route fall back to the next start.",
|
|
3409
|
+
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.",
|
|
3304
3410
|
providerGroups: "Provider groups",
|
|
3305
3411
|
providerGroupsCard: "Per-provider route presets",
|
|
3306
3412
|
providerGroupsSummary: "Sessions using that provider adopt this group",
|
|
@@ -3332,7 +3438,7 @@ window.__ModuleLoader__.load({
|
|
|
3332
3438
|
reviewAllowlistSkipped: "This Host process has skipped the reviewer {count} times.",
|
|
3333
3439
|
reviewTimeout: "Review timeout",
|
|
3334
3440
|
reviewTimeoutDefault: "Follows Provider default (300 s)",
|
|
3335
|
-
reviewTimeoutHelp: "Set the streaming idle timeout for auto-review requests. Leave empty to restore the Provider default. Check \"Cancel timeout\" to write the upstream ceiling (~24.8 days) so reviews never time out on idle.
|
|
3441
|
+
reviewTimeoutHelp: "Set the streaming idle timeout for auto-review requests. Leave empty to restore the Provider default. Check \"Cancel timeout\" to write the upstream ceiling (~24.8 days) so reviews never time out on idle. Saving reloads the Provider hosting the reviewer model so the value applies at once; that reload drops the Provider’s in-flight calls. When the reload cannot run, the value applies at the next start.",
|
|
3336
3442
|
reviewTimeoutScope: "Note: this value is written to the streamIdleTimeoutMs of the Provider hosting the reviewer model and applies to every call through that Provider (main chat included), not only review requests.",
|
|
3337
3443
|
reviewTimeoutSeconds: "Timeout (seconds)",
|
|
3338
3444
|
reviewTimeoutPlaceholder: "300 (default)",
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//#region lib/types/fiber-hot-update.js
|
|
2
|
+
/**
|
|
3
|
+
* Re-apply a plugin row's config in the running Host, without a Host restart.
|
|
4
|
+
*
|
|
5
|
+
* Cordis exposes this seam on the fiber that owns one loader row
|
|
6
|
+
* (`@deepseek-ai/cordis` `lib/types/fiber.d.ts`):
|
|
7
|
+
*
|
|
8
|
+
* update(config: any, noSave?: boolean): void
|
|
9
|
+
* // Validate and apply new config, then restart the plugin. Runs the
|
|
10
|
+
* // `internal/update` waterfall first, so update hooks (and HMR) can veto or
|
|
11
|
+
* // replace the restart. `noSave` — hint for persistence hooks not to write
|
|
12
|
+
* // the change back.
|
|
13
|
+
*
|
|
14
|
+
* So a row can be "remounted" with a config this plugin computed, while the
|
|
15
|
+
* profile document stays ours to write (or untouched, for rows this plugin only
|
|
16
|
+
* adapts in memory). Two consequences are deliberately the caller's business:
|
|
17
|
+
*
|
|
18
|
+
* - the remount disposes the running plugin instance, so whatever runtime state
|
|
19
|
+
* that instance held (a verdict cache, breaker counters, open streams) is
|
|
20
|
+
* gone afterwards;
|
|
21
|
+
* - `noSave` is a *hint*, not a guarantee — a loader with a persistence hook may
|
|
22
|
+
* still write the merged config back.
|
|
23
|
+
*
|
|
24
|
+
* This module only owns the mechanics: pick the fiber, refuse to touch a row
|
|
25
|
+
* that is not settled, contain every failure, and report what happened. It never
|
|
26
|
+
* throws and never persists anything itself.
|
|
27
|
+
*
|
|
28
|
+
* @module
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* `FiberState.ACTIVE`. The enum is a `const enum`, so the numeric value is what
|
|
32
|
+
* the running build carries; comparing it here keeps the check independent of
|
|
33
|
+
* an import that may be erased by the compiler.
|
|
34
|
+
*/
|
|
35
|
+
const FIBER_ACTIVE = 2;
|
|
36
|
+
/** Render an unknown throwable for a log line. */
|
|
37
|
+
function messageOf(cause) {
|
|
38
|
+
return cause instanceof Error ? cause.message : String(cause);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Apply `config` to one live row by restarting its fiber with that config.
|
|
42
|
+
*
|
|
43
|
+
* The caller keeps responsibility for *when* this is safe (for example: only
|
|
44
|
+
* when the value actually changed, and only for rows whose restart cannot cut a
|
|
45
|
+
* call the user is waiting on). This function does not validate that policy.
|
|
46
|
+
*
|
|
47
|
+
* @param entry - the loader row to reload; `undefined` is reported, not thrown.
|
|
48
|
+
* @param config - the complete raw config the row should run with.
|
|
49
|
+
* @returns the outcome; never throws.
|
|
50
|
+
*/
|
|
51
|
+
async function applyFiberConfig(entry, config) {
|
|
52
|
+
const fiber = entry?.fiber;
|
|
53
|
+
if (entry === void 0 || fiber === void 0) return { outcome: "no-fiber" };
|
|
54
|
+
if (fiber.state !== FIBER_ACTIVE) return { outcome: "not-active" };
|
|
55
|
+
try {
|
|
56
|
+
fiber.update(config, true);
|
|
57
|
+
} catch (cause) {
|
|
58
|
+
return {
|
|
59
|
+
outcome: "failed",
|
|
60
|
+
error: messageOf(cause)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
await fiber.await();
|
|
65
|
+
} catch (cause) {
|
|
66
|
+
return {
|
|
67
|
+
outcome: "failed",
|
|
68
|
+
error: messageOf(cause)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return { outcome: "updated" };
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
export { applyFiberConfig as t };
|
package/lib/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { r as resolveToolSource, t as DEFAULT_READ_ONLY_TOOLS } from "./tool-all
|
|
|
3
3
|
import { i as autoReviewStatus } from "./auto-review-uu9lvAIZ.js";
|
|
4
4
|
import { ModelSwitchAdapterRegistry } from "./adapter-registry.js";
|
|
5
5
|
import { automodeCompatView } from "./automode-compat.js";
|
|
6
|
+
import { u as reviewTimeoutStatus } from "./review-timeout-DXRFybFp.js";
|
|
6
7
|
import { createRequire } from "node:module";
|
|
7
8
|
import z from "@deepseek-ai/schemastery";
|
|
8
9
|
import { Service } from "@deepseek-ai/cordis";
|
|
@@ -541,7 +542,14 @@ function installCapabilitiesRpc(ctx, registry, snapshot) {
|
|
|
541
542
|
held: autoReviewStatus.held,
|
|
542
543
|
allowedCalls: autoReviewStatus.allowedCalls,
|
|
543
544
|
skippedReadOnly: autoReviewStatus.skippedReadOnly,
|
|
544
|
-
automode: automodeCompatView()
|
|
545
|
+
automode: automodeCompatView(),
|
|
546
|
+
reviewTimeout: {
|
|
547
|
+
configuredMs: reviewTimeoutStatus.configuredMs,
|
|
548
|
+
applied: reviewTimeoutStatus.applied,
|
|
549
|
+
hotApplied: reviewTimeoutStatus.hotApplied,
|
|
550
|
+
hot: reviewTimeoutStatus.hot,
|
|
551
|
+
hotReason: reviewTimeoutStatus.hotReason
|
|
552
|
+
}
|
|
545
553
|
}));
|
|
546
554
|
const dispose = scope.connection.fetch.register({
|
|
547
555
|
path: "/api/plugin-rpc/model-switch",
|
|
@@ -140,6 +140,41 @@ const primeMemoryCompatStatus = { installed: false };
|
|
|
140
140
|
* @param model - route model to pin.
|
|
141
141
|
* @returns whether the document changed.
|
|
142
142
|
*/
|
|
143
|
+
/**
|
|
144
|
+
* Remove this plugin's own static pin from the memory row.
|
|
145
|
+
*
|
|
146
|
+
* `effectiveCfg` (dsh-prime-memory `pipeline/runner.js`) treats a non-empty
|
|
147
|
+
* `cfg.llm.provider + cfg.llm.model` pair as "pinned" and then ignores *both* the runtime
|
|
148
|
+
* chain and the legacy `distillProvider`/`distillModel` pair. A pin written earlier — for a
|
|
149
|
+
* host whose live RPC was not ready yet — is therefore not harmless: it keeps winning over
|
|
150
|
+
* every later live push, which is exactly the "the card changed, the calls did not" report.
|
|
151
|
+
* Once a live push is confirmed, the pin has to go.
|
|
152
|
+
*
|
|
153
|
+
* @param documentPath - the profile patch document that holds the memory row.
|
|
154
|
+
* @returns what happened, so the caller can log it without guessing.
|
|
155
|
+
*/
|
|
156
|
+
async function clearStaticPin(documentPath) {
|
|
157
|
+
const { readFile, writeFile } = await import("node:fs/promises");
|
|
158
|
+
let text;
|
|
159
|
+
try {
|
|
160
|
+
text = await readFile(documentPath, "utf8");
|
|
161
|
+
} catch {
|
|
162
|
+
return "missing";
|
|
163
|
+
}
|
|
164
|
+
const rows = text.split(/(?=^- id: )/m);
|
|
165
|
+
const index = rows.findIndex((row) => /^- id: dsh-memory\r?\n/.test(row));
|
|
166
|
+
if (index < 0) return "missing";
|
|
167
|
+
const row = rows[index];
|
|
168
|
+
const trimmed = row.replace(/^ {4}llm:\r?\n(?: {6}.*\r?\n)*/m, "");
|
|
169
|
+
if (trimmed === row) return "absent";
|
|
170
|
+
rows[index] = trimmed;
|
|
171
|
+
try {
|
|
172
|
+
await writeFile(documentPath, rows.join(""), "utf8");
|
|
173
|
+
} catch {
|
|
174
|
+
return "missing";
|
|
175
|
+
}
|
|
176
|
+
return "cleared";
|
|
177
|
+
}
|
|
143
178
|
async function writeStaticPin(documentPath, provider, model) {
|
|
144
179
|
const { readFile, writeFile } = await import("node:fs/promises");
|
|
145
180
|
let text;
|
|
@@ -359,6 +394,8 @@ function formsOf(ctx) {
|
|
|
359
394
|
return;
|
|
360
395
|
}
|
|
361
396
|
}
|
|
397
|
+
/** Live attempts to spend before falling back to the static pin. */
|
|
398
|
+
const PIN_AFTER_ATTEMPTS = 4;
|
|
362
399
|
/**
|
|
363
400
|
* Install the adapter for the whole profile.
|
|
364
401
|
*
|
|
@@ -400,6 +437,31 @@ function installPrimeMemoryCompat(ctx, loader, routeOf) {
|
|
|
400
437
|
timers.push(timer);
|
|
401
438
|
};
|
|
402
439
|
/**
|
|
440
|
+
* Last resort for a host whose live seams never accept the route.
|
|
441
|
+
*
|
|
442
|
+
* Writing the static pin disables every live form (`pinned` in `effectiveCfg`), so it must
|
|
443
|
+
* not happen while the live attempts still have a chance: a pin written on a slow start is
|
|
444
|
+
* what kept overriding later pushes. It therefore waits for the retry budget to run out.
|
|
445
|
+
*
|
|
446
|
+
* @param forms - the settings service describing the memory row.
|
|
447
|
+
* @param provider - route provider to pin.
|
|
448
|
+
* @param model - route model to pin.
|
|
449
|
+
* @param wanted - `provider/model`, for the log line.
|
|
450
|
+
*/
|
|
451
|
+
const pinAsFallback = async (forms, provider, model, wanted) => {
|
|
452
|
+
if (attempt < PIN_AFTER_ATTEMPTS) {
|
|
453
|
+
scheduleRetry();
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
const documentPath = forms.documentPath;
|
|
457
|
+
if (typeof documentPath !== "string" || documentPath === "") return;
|
|
458
|
+
try {
|
|
459
|
+
if (await writeStaticPin(documentPath, provider, model) === "written") ctx.logger.info(`model-switch: pinned the dsh-prime-memory distillation route to ${wanted} after ${attempt} live attempts (applies from the next start)`);
|
|
460
|
+
} catch (cause) {
|
|
461
|
+
ctx.logger.warn(`model-switch: could not pin the dsh-prime-memory route (${String(cause)})`);
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
/**
|
|
403
465
|
* Write our route into the section the plugin itself reads, then read it back.
|
|
404
466
|
*
|
|
405
467
|
* The plugin builds that section inside its own `apply` (`settings.register`), so
|
|
@@ -442,16 +504,18 @@ function installPrimeMemoryCompat(ctx, loader, routeOf) {
|
|
|
442
504
|
primeMemoryCompatStatus.route = wanted;
|
|
443
505
|
delete primeMemoryCompatStatus.routeSkipped;
|
|
444
506
|
}
|
|
445
|
-
if (pushed === "pushed")
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
507
|
+
if (pushed === "pushed") {
|
|
508
|
+
const pinnedDocument = forms.documentPath;
|
|
509
|
+
if (typeof pinnedDocument === "string" && pinnedDocument !== "") try {
|
|
510
|
+
if (await clearStaticPin(pinnedDocument) === "cleared") ctx.logger.info("model-switch: removed the stale dsh-prime-memory static pin; the live route decides now");
|
|
511
|
+
} catch (cause) {
|
|
512
|
+
ctx.logger.warn(`model-switch: could not clear the dsh-prime-memory static pin (${String(cause)})`);
|
|
513
|
+
}
|
|
514
|
+
return;
|
|
451
515
|
}
|
|
452
516
|
const section = sectionOf(forms);
|
|
453
517
|
if (section === void 0 || asRecord(section.value) === void 0) {
|
|
454
|
-
|
|
518
|
+
await pinAsFallback(forms, provider, model, wanted);
|
|
455
519
|
return;
|
|
456
520
|
}
|
|
457
521
|
const current = chainOf(section.value);
|
|
@@ -465,10 +529,10 @@ function installPrimeMemoryCompat(ctx, loader, routeOf) {
|
|
|
465
529
|
provider,
|
|
466
530
|
model
|
|
467
531
|
}, current);
|
|
468
|
-
pending = forms.update(MEMORY_ENTRY_ID, distillChainPatch(chain), section.revision).then(() => {
|
|
532
|
+
pending = forms.update(MEMORY_ENTRY_ID, distillChainPatch(chain), section.revision).then(async () => {
|
|
469
533
|
const applied = chainOf(sectionOf(forms)?.value);
|
|
470
534
|
if ((applied.length > 0 ? `${text(applied[0]?.provider)}/${text(applied[0]?.model)}` : "") !== wanted) {
|
|
471
|
-
|
|
535
|
+
await pinAsFallback(forms, provider, model, wanted);
|
|
472
536
|
return;
|
|
473
537
|
}
|
|
474
538
|
adoptedRoute = wanted;
|
|
@@ -476,10 +540,10 @@ function installPrimeMemoryCompat(ctx, loader, routeOf) {
|
|
|
476
540
|
primeMemoryCompatStatus.installed = true;
|
|
477
541
|
primeMemoryCompatStatus.route = wanted;
|
|
478
542
|
delete primeMemoryCompatStatus.routeSkipped;
|
|
479
|
-
}).catch((cause) => {
|
|
543
|
+
}).catch(async (cause) => {
|
|
480
544
|
primeMemoryCompatStatus.routeSkipped = "no-route";
|
|
481
545
|
ctx.logger.warn(`model-switch: could not write the dsh-prime-memory distillation route (${String(cause)})`);
|
|
482
|
-
|
|
546
|
+
await pinAsFallback(forms, provider, model, wanted);
|
|
483
547
|
}).finally(() => {
|
|
484
548
|
pending = void 0;
|
|
485
549
|
});
|
|
@@ -532,4 +596,4 @@ function apply(ctx) {
|
|
|
532
596
|
}, "model-switch: keep the dsh-prime-memory route aligned with the settings");
|
|
533
597
|
}
|
|
534
598
|
//#endregion
|
|
535
|
-
export { apply, chainOf, inject, installPrimeMemoryCompat, memoryLiveMatchesRoute, name, planPrimeMemoryRoute, primeMemoryCompatStatus, pushMemoryRoute };
|
|
599
|
+
export { apply, chainOf, clearStaticPin, inject, installPrimeMemoryCompat, memoryLiveMatchesRoute, name, planPrimeMemoryRoute, primeMemoryCompatStatus, pushMemoryRoute, writeStaticPin };
|