dsh-model-switch 0.4.48 → 0.4.50
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 +29 -0
- package/cordis.patch.yml +7 -0
- package/lib/client.js +289 -153
- package/lib/index.js +4 -0
- package/lib/prime-memory-compat.js +5 -8
- package/lib/review-timeout.js +238 -0
- package/lib/types/client/ModelSwitchSettings.d.ts +2 -0
- package/lib/types/client/locales.d.ts +10 -0
- package/lib/types/client-contract.d.ts +11 -0
- package/lib/types/host-settings.d.ts +15 -0
- package/lib/types/prime-memory-compat.d.ts +14 -0
- package/lib/types/review-timeout.d.ts +104 -0
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
## Unreleased
|
|
3
|
+
|
|
4
|
+
- **记忆蒸馏路由修复(已提交,未发版)**:`fix(memory): stop the pin and the live push from cancelling each other`(`8e59fda`)。适配层不再"推链 + 清空 legacy 对 + 写静态 pin"三者互相抵消:live RPC 被接受时只发 `distillChain: []` + `distillProvider`/`distillModel` + 分层链,静态 pin 降级为 RPC 不可用时的兜底。`src/`、`lib/` 与测试(586 通过)已更新;**npm 上的 0.4.48 不含此修复**。
|
|
5
|
+
- **发版前置条件**:在隔离 lab(全虚拟探针)里证明 L1/L2/L3 的蒸馏调用确实带着配置路由、且改动即时生效;通过后才恢复「记忆蒸馏模型」卡片(`MEMORY_CAPABILITY_UI`)并随 v0.4.49 发布。未通过则保持撤卡。
|
|
6
|
+
- **其余待做**:DSH `0.2.1-rc.4` 运行时验证;Auto review 与 automode 分类器的虚拟取证;计划审阅卡两张截图(需 answerer)。
|
|
7
|
+
|
|
8
|
+
## v0.4.50
|
|
9
|
+
|
|
10
|
+
设置页新增「审查超时」:自动审查请求的流式空闲超时可自定义、可取消、可恢复默认。
|
|
11
|
+
|
|
12
|
+
- 作用点:写入审查模型所在 provider 的 `streamIdleTimeoutMs`(`@deepseek-ai/dsh-llm-pi-ai` 的 provider profile)。上游没有 per-request 覆盖,这是唯一入口。
|
|
13
|
+
- 「取消超时」写上游硬上限 `2147483647ms`(≈24.8 天)——上游拒绝 0/负数/Infinity,所以它 **不是真正的无限**;死端点会一直等待,UI 文案已如实标注。
|
|
14
|
+
- 作用范围:该 provider 的**全部调用**(审查、主对话、其他路由),不只是审查请求。
|
|
15
|
+
- 生效时机:写入发生在启动过程中,**下一次启动**才读取新值(实测写入当次仍按旧的 300 秒);UI 已写明需重启一次。
|
|
16
|
+
- 恢复默认 = 删除该键(本插件是这条键的管理者);实测删除后回到上游默认行为。
|
|
17
|
+
|
|
18
|
+
修复(本轮实测发现):
|
|
19
|
+
|
|
20
|
+
- `model-switch-review-timeout` 行在激活期 `await` 设置写入会拖死加载器:headless profile 直接起不来,CLI 以 `unsettled top-level await` 退出(exit 13)。改为 fire-and-forget + 延迟重试 + 串行化。
|
|
21
|
+
- 清空超时字段改用 `unset` 而不是 `set null`:字段是数字,null 会被 host schema 拒绝。
|
|
22
|
+
|
|
23
|
+
lab 实测(virtual / 零真实额度;本地虚拟端点 `tools/route-probe.mjs`,DSH 0.2.1-rc.3):
|
|
24
|
+
|
|
25
|
+
- 自定义 5 秒 + 探针挂起 8 秒 → 下次启动报 `TIMEOUT: pi-ai stream idle timeout after 5000ms`(写入当次仍成功,证明需重启);
|
|
26
|
+
- 取消超时 → 键写为 `2147483647`,同样 8 秒挂起后正常完成;
|
|
27
|
+
- 恢复默认 → 键被删除,后续启动正常完成(回到 300 秒语义)。
|
|
28
|
+
- 复现方式:`node tools/route-probe.mjs --preset ok --hang 8000`(挂起 8 秒不回字节),配合上面三种设置重启各一次即可复跑。
|
|
29
|
+
|
|
1
30
|
## v0.4.48
|
|
2
31
|
|
|
3
32
|
兼容门限从「逐版本列举」改为「下界 + 区间」:
|
package/cordis.patch.yml
CHANGED
|
@@ -87,3 +87,10 @@
|
|
|
87
87
|
# "follow the default model" state.
|
|
88
88
|
- id: model-switch-prime-memory-compat
|
|
89
89
|
name: 'dsh-model-switch/prime-memory-compat'
|
|
90
|
+
|
|
91
|
+
# Write the configured reviewer stream idle timeout into the reviewer
|
|
92
|
+
# routes' pi-ai provider profiles (the only place the upstream watchdog
|
|
93
|
+
# reads it). The write lands in the profile document, so it takes effect on
|
|
94
|
+
# the next start — same channel as the memory static pin.
|
|
95
|
+
- id: model-switch-review-timeout
|
|
96
|
+
name: 'dsh-model-switch/review-timeout'
|
package/lib/client.js
CHANGED
|
@@ -369,6 +369,8 @@ window.__ModuleLoader__.load({
|
|
|
369
369
|
enabled: "autoReviewSkipReadOnly",
|
|
370
370
|
tools: "autoReviewAllowlist"
|
|
371
371
|
});
|
|
372
|
+
/** Upstream ceiling enforced by `@deepseek-ai/dsh-timeout` (MAX_TIMER_DELAY_MS). */
|
|
373
|
+
const UPSTREAM_MAX_IDLE_TIMEOUT_MS = 2147483647;
|
|
372
374
|
/**
|
|
373
375
|
* Derive the allowlist editor's value.
|
|
374
376
|
*
|
|
@@ -1844,6 +1846,29 @@ window.__ModuleLoader__.load({
|
|
|
1844
1846
|
})).filter((row) => allowlistQueryText === "" || row.entry.toLowerCase().includes(allowlistQueryText));
|
|
1845
1847
|
const allowlistAvailable = (catalogRows ?? []).filter((row) => !isAllowedByList(row.name, allowlistTools)).filter((row) => allowlistQueryText === "" || row.name.toLowerCase().includes(allowlistQueryText) || row.sourceLabel.toLowerCase().includes(allowlistQueryText));
|
|
1846
1848
|
const allowlistSummaryText = allowlistView === void 0 ? props.t("loading") : allowlistEnabled ? props.t("reviewAllowlistOnSummary").replace("{count}", String(allowlistTools.length)) : props.t("reviewAllowlistOffSummary");
|
|
1849
|
+
/**
|
|
1850
|
+
* The reviewer stream idle timeout, stored in seconds for display; undefined
|
|
1851
|
+
* = follow the provider default. The save path converts to milliseconds and
|
|
1852
|
+
* `0` = cancelled (upstream ceiling) before writing.
|
|
1853
|
+
*/
|
|
1854
|
+
const storedTimeoutMs = switchSettings.value?.autoReviewTimeoutMs;
|
|
1855
|
+
const [timeoutDraft, setTimeoutDraft] = (0, react.useState)(void 0);
|
|
1856
|
+
const timeoutSeconds = timeoutDraft ?? (storedTimeoutMs === void 0 ? void 0 : String(Math.round(storedTimeoutMs / 1e3)));
|
|
1857
|
+
const timeoutCancelled = storedTimeoutMs === 0;
|
|
1858
|
+
const timeoutWritable = switchSettings.status === "ready" && switchSettings.writable;
|
|
1859
|
+
const timeoutSummary = storedTimeoutMs === void 0 ? props.t("reviewTimeoutDefault") : storedTimeoutMs === 0 ? props.t("reviewTimeoutCancelled") : `${Math.round(storedTimeoutMs / 1e3)}s`;
|
|
1860
|
+
const saveTimeout = () => {
|
|
1861
|
+
if (busy !== void 0 || !timeoutWritable) return;
|
|
1862
|
+
const trimmed = (timeoutDraft ?? "").trim();
|
|
1863
|
+
if (trimmed === "") {
|
|
1864
|
+
run("timeout", () => props.saveReviewTimeout(void 0));
|
|
1865
|
+
return;
|
|
1866
|
+
}
|
|
1867
|
+
const seconds = Number(trimmed);
|
|
1868
|
+
if (!Number.isFinite(seconds) || seconds < 1 || !Number.isInteger(seconds)) return;
|
|
1869
|
+
const ms = Math.min(seconds, Math.round(UPSTREAM_MAX_IDLE_TIMEOUT_MS / 1e3)) * 1e3;
|
|
1870
|
+
run("timeout", () => props.saveReviewTimeout(ms));
|
|
1871
|
+
};
|
|
1847
1872
|
const saveSubagent = () => {
|
|
1848
1873
|
if (subagentDraft === void 0 || subagentDraft.mode !== "fixed") return;
|
|
1849
1874
|
const matched = subagentCatalogModel;
|
|
@@ -2602,175 +2627,256 @@ window.__ModuleLoader__.load({
|
|
|
2602
2627
|
}),
|
|
2603
2628
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2604
2629
|
className: ModelSwitchSettings_module_css_default.group,
|
|
2605
|
-
children: [
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
title: props.t("reviewAllowlist"),
|
|
2610
|
-
summary: allowlistSummaryText,
|
|
2611
|
-
hint: props.t("reviewAllowlistHelp"),
|
|
2612
|
-
icon: "autoReview",
|
|
2613
|
-
open: open === "allowlist",
|
|
2614
|
-
onToggle: () => {
|
|
2615
|
-
toggle("allowlist");
|
|
2616
|
-
},
|
|
2617
|
-
...allowlistEnabled ? { badge: props.t("reviewAllowlistBadge") } : {},
|
|
2618
|
-
trailing: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InstantSwitch, {
|
|
2619
|
-
checked: allowlistEnabled,
|
|
2620
|
-
disabled: busy !== void 0 || !allowlistWritable,
|
|
2621
|
-
label: props.t("reviewAllowlist"),
|
|
2622
|
-
onChange: (value) => {
|
|
2623
|
-
persistAllowlist({
|
|
2624
|
-
enabled: value,
|
|
2625
|
-
tools: allowlistTools
|
|
2626
|
-
});
|
|
2627
|
-
}
|
|
2630
|
+
children: [
|
|
2631
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
2632
|
+
className: ModelSwitchSettings_module_css_default.groupLabel,
|
|
2633
|
+
children: props.t("reviewAllowlistGroup")
|
|
2628
2634
|
}),
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
disabled: busy !== void 0 || props.scanTools === void 0 || catalogState === "loading",
|
|
2650
|
-
onClick: scanAllowlistTools,
|
|
2651
|
-
children: catalogState === "loading" ? props.t("reviewAllowlistScanning") : props.t("reviewAllowlistScan")
|
|
2652
|
-
}),
|
|
2653
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2654
|
-
type: "button",
|
|
2655
|
-
className: cx(ModelSwitchSettings_module_css_default.button, ModelSwitchSettings_module_css_default.secondaryButton),
|
|
2656
|
-
disabled: busy !== void 0 || !allowlistWritable,
|
|
2657
|
-
onClick: () => {
|
|
2658
|
-
persistAllowlist({
|
|
2659
|
-
enabled: allowlistEnabled,
|
|
2660
|
-
tools: [...DEFAULT_READ_ONLY_TOOLS]
|
|
2661
|
-
});
|
|
2662
|
-
},
|
|
2663
|
-
children: props.t("reviewAllowlistReset")
|
|
2664
|
-
})
|
|
2665
|
-
]
|
|
2666
|
-
}),
|
|
2667
|
-
message?.route === "allowlist" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2668
|
-
className: cx(ModelSwitchSettings_module_css_default.hint, ModelSwitchSettings_module_css_default.message),
|
|
2669
|
-
children: message.text
|
|
2670
|
-
}) : null,
|
|
2671
|
-
reviewStatus === void 0 || reviewStatus.skippedReadOnly === 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2672
|
-
className: ModelSwitchSettings_module_css_default.hint,
|
|
2673
|
-
children: props.t("reviewAllowlistSkipped").replace("{count}", String(reviewStatus.skippedReadOnly))
|
|
2674
|
-
}),
|
|
2675
|
-
reviewStatus?.automode === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2676
|
-
className: ModelSwitchSettings_module_css_default.hint,
|
|
2677
|
-
children: props.t("reviewAutomodeLinked").replace("{route}", reviewStatus.automode.route ?? (reviewStatus.automode.routeSkipped === "user-set" ? props.t("reviewAutomodeRouteOwn") : props.t("reviewAutomodeRouteUnset"))).replace("{added}", String(reviewStatus.automode.added)).replace("{skipped}", String(reviewStatus.automode.skipped))
|
|
2635
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(RouteCard, {
|
|
2636
|
+
title: props.t("reviewAllowlist"),
|
|
2637
|
+
summary: allowlistSummaryText,
|
|
2638
|
+
hint: props.t("reviewAllowlistHelp"),
|
|
2639
|
+
icon: "autoReview",
|
|
2640
|
+
open: open === "allowlist",
|
|
2641
|
+
onToggle: () => {
|
|
2642
|
+
toggle("allowlist");
|
|
2643
|
+
},
|
|
2644
|
+
...allowlistEnabled ? { badge: props.t("reviewAllowlistBadge") } : {},
|
|
2645
|
+
trailing: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InstantSwitch, {
|
|
2646
|
+
checked: allowlistEnabled,
|
|
2647
|
+
disabled: busy !== void 0 || !allowlistWritable,
|
|
2648
|
+
label: props.t("reviewAllowlist"),
|
|
2649
|
+
onChange: (value) => {
|
|
2650
|
+
persistAllowlist({
|
|
2651
|
+
enabled: value,
|
|
2652
|
+
tools: allowlistTools
|
|
2653
|
+
});
|
|
2654
|
+
}
|
|
2678
2655
|
}),
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2656
|
+
children: [
|
|
2657
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2658
|
+
className: ModelSwitchSettings_module_css_default.hint,
|
|
2659
|
+
children: props.t("reviewAllowlistNote")
|
|
2660
|
+
}),
|
|
2661
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2662
|
+
className: ModelSwitchSettings_module_css_default.allowToolbar,
|
|
2683
2663
|
children: [
|
|
2684
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
2685
|
-
className: ModelSwitchSettings_module_css_default.
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
children: row.entry
|
|
2693
|
-
})]
|
|
2694
|
-
}),
|
|
2695
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2696
|
-
className: ModelSwitchSettings_module_css_default.allowSource,
|
|
2697
|
-
children: [row.source.label, row.source.repo === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2698
|
-
className: ModelSwitchSettings_module_css_default.allowDot,
|
|
2699
|
-
children: "·"
|
|
2700
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
2701
|
-
className: ModelSwitchSettings_module_css_default.allowRepo,
|
|
2702
|
-
href: row.source.repo,
|
|
2703
|
-
target: "_blank",
|
|
2704
|
-
rel: "noreferrer",
|
|
2705
|
-
children: props.t("reviewAllowlistRepo")
|
|
2706
|
-
})] })]
|
|
2664
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2665
|
+
className: ModelSwitchSettings_module_css_default.input,
|
|
2666
|
+
type: "search",
|
|
2667
|
+
value: allowlistQuery,
|
|
2668
|
+
placeholder: props.t("reviewAllowlistSearch"),
|
|
2669
|
+
onChange: (event) => {
|
|
2670
|
+
setAllowlistQuery(event.target.value);
|
|
2671
|
+
}
|
|
2707
2672
|
}),
|
|
2708
2673
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2709
2674
|
type: "button",
|
|
2710
2675
|
className: cx(ModelSwitchSettings_module_css_default.button, ModelSwitchSettings_module_css_default.secondaryButton),
|
|
2711
|
-
disabled: busy !== void 0 ||
|
|
2712
|
-
onClick:
|
|
2713
|
-
|
|
2714
|
-
},
|
|
2715
|
-
children: props.t("reviewAllowlistRemove")
|
|
2716
|
-
})
|
|
2717
|
-
]
|
|
2718
|
-
}, row.entry))
|
|
2719
|
-
}),
|
|
2720
|
-
allowlistIncluded.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2721
|
-
className: ModelSwitchSettings_module_css_default.hint,
|
|
2722
|
-
children: props.t("reviewAllowlistNone")
|
|
2723
|
-
}) : null,
|
|
2724
|
-
allowlistAvailable.length === 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2725
|
-
className: ModelSwitchSettings_module_css_default.hint,
|
|
2726
|
-
children: props.t("reviewAllowlistAvailable")
|
|
2727
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
2728
|
-
className: ModelSwitchSettings_module_css_default.allowList,
|
|
2729
|
-
children: allowlistAvailable.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
2730
|
-
className: ModelSwitchSettings_module_css_default.allowRow,
|
|
2731
|
-
children: [
|
|
2732
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2733
|
-
className: ModelSwitchSettings_module_css_default.allowLabel,
|
|
2734
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2735
|
-
type: "checkbox",
|
|
2736
|
-
checked: false,
|
|
2737
|
-
readOnly: true
|
|
2738
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
2739
|
-
className: ModelSwitchSettings_module_css_default.allowName,
|
|
2740
|
-
children: row.name
|
|
2741
|
-
})]
|
|
2742
|
-
}),
|
|
2743
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2744
|
-
className: ModelSwitchSettings_module_css_default.allowSource,
|
|
2745
|
-
children: [row.sourceLabel, row.repo === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2746
|
-
className: ModelSwitchSettings_module_css_default.allowDot,
|
|
2747
|
-
children: "·"
|
|
2748
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
2749
|
-
className: ModelSwitchSettings_module_css_default.allowRepo,
|
|
2750
|
-
href: row.repo,
|
|
2751
|
-
target: "_blank",
|
|
2752
|
-
rel: "noreferrer",
|
|
2753
|
-
children: props.t("reviewAllowlistRepo")
|
|
2754
|
-
})] })]
|
|
2676
|
+
disabled: busy !== void 0 || props.scanTools === void 0 || catalogState === "loading",
|
|
2677
|
+
onClick: scanAllowlistTools,
|
|
2678
|
+
children: catalogState === "loading" ? props.t("reviewAllowlistScanning") : props.t("reviewAllowlistScan")
|
|
2755
2679
|
}),
|
|
2756
2680
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2757
2681
|
type: "button",
|
|
2758
2682
|
className: cx(ModelSwitchSettings_module_css_default.button, ModelSwitchSettings_module_css_default.secondaryButton),
|
|
2759
2683
|
disabled: busy !== void 0 || !allowlistWritable,
|
|
2760
2684
|
onClick: () => {
|
|
2761
|
-
|
|
2685
|
+
persistAllowlist({
|
|
2686
|
+
enabled: allowlistEnabled,
|
|
2687
|
+
tools: [...DEFAULT_READ_ONLY_TOOLS]
|
|
2688
|
+
});
|
|
2762
2689
|
},
|
|
2763
|
-
children: props.t("
|
|
2690
|
+
children: props.t("reviewAllowlistReset")
|
|
2764
2691
|
})
|
|
2765
2692
|
]
|
|
2766
|
-
},
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2693
|
+
}),
|
|
2694
|
+
message?.route === "allowlist" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2695
|
+
className: cx(ModelSwitchSettings_module_css_default.hint, ModelSwitchSettings_module_css_default.message),
|
|
2696
|
+
children: message.text
|
|
2697
|
+
}) : null,
|
|
2698
|
+
reviewStatus === void 0 || reviewStatus.skippedReadOnly === 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2699
|
+
className: ModelSwitchSettings_module_css_default.hint,
|
|
2700
|
+
children: props.t("reviewAllowlistSkipped").replace("{count}", String(reviewStatus.skippedReadOnly))
|
|
2701
|
+
}),
|
|
2702
|
+
reviewStatus?.automode === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2703
|
+
className: ModelSwitchSettings_module_css_default.hint,
|
|
2704
|
+
children: props.t("reviewAutomodeLinked").replace("{route}", reviewStatus.automode.route ?? (reviewStatus.automode.routeSkipped === "user-set" ? props.t("reviewAutomodeRouteOwn") : props.t("reviewAutomodeRouteUnset"))).replace("{added}", String(reviewStatus.automode.added)).replace("{skipped}", String(reviewStatus.automode.skipped))
|
|
2705
|
+
}),
|
|
2706
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
2707
|
+
className: ModelSwitchSettings_module_css_default.allowList,
|
|
2708
|
+
children: allowlistIncluded.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
2709
|
+
className: ModelSwitchSettings_module_css_default.allowRow,
|
|
2710
|
+
children: [
|
|
2711
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2712
|
+
className: ModelSwitchSettings_module_css_default.allowLabel,
|
|
2713
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2714
|
+
type: "checkbox",
|
|
2715
|
+
checked: true,
|
|
2716
|
+
readOnly: true
|
|
2717
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
2718
|
+
className: ModelSwitchSettings_module_css_default.allowName,
|
|
2719
|
+
children: row.entry
|
|
2720
|
+
})]
|
|
2721
|
+
}),
|
|
2722
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2723
|
+
className: ModelSwitchSettings_module_css_default.allowSource,
|
|
2724
|
+
children: [row.source.label, row.source.repo === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2725
|
+
className: ModelSwitchSettings_module_css_default.allowDot,
|
|
2726
|
+
children: "·"
|
|
2727
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
2728
|
+
className: ModelSwitchSettings_module_css_default.allowRepo,
|
|
2729
|
+
href: row.source.repo,
|
|
2730
|
+
target: "_blank",
|
|
2731
|
+
rel: "noreferrer",
|
|
2732
|
+
children: props.t("reviewAllowlistRepo")
|
|
2733
|
+
})] })]
|
|
2734
|
+
}),
|
|
2735
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2736
|
+
type: "button",
|
|
2737
|
+
className: cx(ModelSwitchSettings_module_css_default.button, ModelSwitchSettings_module_css_default.secondaryButton),
|
|
2738
|
+
disabled: busy !== void 0 || !allowlistWritable,
|
|
2739
|
+
onClick: () => {
|
|
2740
|
+
setAllowTool(row.entry, false);
|
|
2741
|
+
},
|
|
2742
|
+
children: props.t("reviewAllowlistRemove")
|
|
2743
|
+
})
|
|
2744
|
+
]
|
|
2745
|
+
}, row.entry))
|
|
2746
|
+
}),
|
|
2747
|
+
allowlistIncluded.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2748
|
+
className: ModelSwitchSettings_module_css_default.hint,
|
|
2749
|
+
children: props.t("reviewAllowlistNone")
|
|
2750
|
+
}) : null,
|
|
2751
|
+
allowlistAvailable.length === 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2752
|
+
className: ModelSwitchSettings_module_css_default.hint,
|
|
2753
|
+
children: props.t("reviewAllowlistAvailable")
|
|
2754
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
2755
|
+
className: ModelSwitchSettings_module_css_default.allowList,
|
|
2756
|
+
children: allowlistAvailable.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
2757
|
+
className: ModelSwitchSettings_module_css_default.allowRow,
|
|
2758
|
+
children: [
|
|
2759
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2760
|
+
className: ModelSwitchSettings_module_css_default.allowLabel,
|
|
2761
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2762
|
+
type: "checkbox",
|
|
2763
|
+
checked: false,
|
|
2764
|
+
readOnly: true
|
|
2765
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
2766
|
+
className: ModelSwitchSettings_module_css_default.allowName,
|
|
2767
|
+
children: row.name
|
|
2768
|
+
})]
|
|
2769
|
+
}),
|
|
2770
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2771
|
+
className: ModelSwitchSettings_module_css_default.allowSource,
|
|
2772
|
+
children: [row.sourceLabel, row.repo === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2773
|
+
className: ModelSwitchSettings_module_css_default.allowDot,
|
|
2774
|
+
children: "·"
|
|
2775
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
2776
|
+
className: ModelSwitchSettings_module_css_default.allowRepo,
|
|
2777
|
+
href: row.repo,
|
|
2778
|
+
target: "_blank",
|
|
2779
|
+
rel: "noreferrer",
|
|
2780
|
+
children: props.t("reviewAllowlistRepo")
|
|
2781
|
+
})] })]
|
|
2782
|
+
}),
|
|
2783
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2784
|
+
type: "button",
|
|
2785
|
+
className: cx(ModelSwitchSettings_module_css_default.button, ModelSwitchSettings_module_css_default.secondaryButton),
|
|
2786
|
+
disabled: busy !== void 0 || !allowlistWritable,
|
|
2787
|
+
onClick: () => {
|
|
2788
|
+
setAllowTool(row.name, true);
|
|
2789
|
+
},
|
|
2790
|
+
children: props.t("reviewAllowlistAdd")
|
|
2791
|
+
})
|
|
2792
|
+
]
|
|
2793
|
+
}, row.name))
|
|
2794
|
+
})] }),
|
|
2795
|
+
catalogState === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2796
|
+
className: cx(ModelSwitchSettings_module_css_default.hint, ModelSwitchSettings_module_css_default.message),
|
|
2797
|
+
children: props.t("reviewAllowlistScanFailed")
|
|
2798
|
+
}) : null
|
|
2799
|
+
]
|
|
2800
|
+
}),
|
|
2801
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(RouteCard, {
|
|
2802
|
+
title: props.t("reviewTimeout"),
|
|
2803
|
+
summary: timeoutSummary,
|
|
2804
|
+
hint: props.t("reviewTimeoutHelp"),
|
|
2805
|
+
icon: "autoReview",
|
|
2806
|
+
open: open === "timeout",
|
|
2807
|
+
onToggle: () => {
|
|
2808
|
+
toggle("timeout");
|
|
2809
|
+
},
|
|
2810
|
+
children: [
|
|
2811
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2812
|
+
className: ModelSwitchSettings_module_css_default.hint,
|
|
2813
|
+
children: props.t("reviewTimeoutScope")
|
|
2814
|
+
}),
|
|
2815
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2816
|
+
className: ModelSwitchSettings_module_css_default.formGrid,
|
|
2817
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2818
|
+
className: ModelSwitchSettings_module_css_default.field,
|
|
2819
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2820
|
+
className: ModelSwitchSettings_module_css_default.fieldLabel,
|
|
2821
|
+
children: props.t("reviewTimeoutSeconds")
|
|
2822
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2823
|
+
className: ModelSwitchSettings_module_css_default.input,
|
|
2824
|
+
type: "number",
|
|
2825
|
+
min: 1,
|
|
2826
|
+
max: Math.round(UPSTREAM_MAX_IDLE_TIMEOUT_MS / 1e3),
|
|
2827
|
+
step: 1,
|
|
2828
|
+
disabled: busy !== void 0 || !timeoutWritable || timeoutCancelled,
|
|
2829
|
+
value: timeoutSeconds ?? "",
|
|
2830
|
+
placeholder: props.t("reviewTimeoutPlaceholder"),
|
|
2831
|
+
onChange: (event) => {
|
|
2832
|
+
setTimeoutDraft(event.target.value);
|
|
2833
|
+
}
|
|
2834
|
+
})]
|
|
2835
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2836
|
+
className: ModelSwitchSettings_module_css_default.field,
|
|
2837
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2838
|
+
className: ModelSwitchSettings_module_css_default.fieldLabel,
|
|
2839
|
+
children: props.t("reviewTimeoutCancelLabel")
|
|
2840
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2841
|
+
style: {
|
|
2842
|
+
display: "flex",
|
|
2843
|
+
alignItems: "center",
|
|
2844
|
+
gap: 6
|
|
2845
|
+
},
|
|
2846
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2847
|
+
type: "checkbox",
|
|
2848
|
+
checked: timeoutCancelled,
|
|
2849
|
+
disabled: busy !== void 0 || !timeoutWritable,
|
|
2850
|
+
onChange: (event) => {
|
|
2851
|
+
if (event.target.checked) {
|
|
2852
|
+
setTimeoutDraft(void 0);
|
|
2853
|
+
run("timeout", () => props.saveReviewTimeout(0));
|
|
2854
|
+
} else run("timeout", () => props.saveReviewTimeout(void 0));
|
|
2855
|
+
}
|
|
2856
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2857
|
+
className: ModelSwitchSettings_module_css_default.hint,
|
|
2858
|
+
children: props.t("reviewTimeoutCancelHint")
|
|
2859
|
+
})]
|
|
2860
|
+
})]
|
|
2861
|
+
})]
|
|
2862
|
+
}),
|
|
2863
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2864
|
+
className: ModelSwitchSettings_module_css_default.formGrid,
|
|
2865
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2866
|
+
type: "button",
|
|
2867
|
+
className: cx(ModelSwitchSettings_module_css_default.button, ModelSwitchSettings_module_css_default.secondaryButton),
|
|
2868
|
+
disabled: busy !== void 0 || !timeoutWritable,
|
|
2869
|
+
onClick: saveTimeout,
|
|
2870
|
+
children: props.t("reviewTimeoutSave")
|
|
2871
|
+
})
|
|
2872
|
+
}),
|
|
2873
|
+
message?.route === "timeout" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2874
|
+
className: cx(ModelSwitchSettings_module_css_default.hint, ModelSwitchSettings_module_css_default.message),
|
|
2875
|
+
children: message.text
|
|
2876
|
+
}) : null
|
|
2877
|
+
]
|
|
2878
|
+
})
|
|
2879
|
+
]
|
|
2774
2880
|
}),
|
|
2775
2881
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2776
2882
|
className: ModelSwitchSettings_module_css_default.group,
|
|
@@ -3127,6 +3233,16 @@ window.__ModuleLoader__.load({
|
|
|
3127
3233
|
reviewAllowlistAvailable: "本机存在但未放行的工具:",
|
|
3128
3234
|
reviewAllowlistRepo: "仓库",
|
|
3129
3235
|
reviewAllowlistSkipped: "本 Host 进程已为纯读调用跳过 {count} 次审查。",
|
|
3236
|
+
reviewTimeout: "审查超时",
|
|
3237
|
+
reviewTimeoutDefault: "跟随 Provider 默认(300 秒)",
|
|
3238
|
+
reviewTimeoutHelp: "设置自动审查请求的流式空闲超时。留空恢复 Provider 默认值;勾选「取消超时」写入上游上限(约 24.8 天),审查将不会因空闲而超时。该值写在 Provider 配置里,改完需重启一次 DSH 才生效。",
|
|
3239
|
+
reviewTimeoutScope: "注意:该值写入审查模型所在 Provider 的 streamIdleTimeoutMs,对该 Provider 的所有调用(含主对话)生效,不只影响审查请求。",
|
|
3240
|
+
reviewTimeoutSeconds: "超时秒数",
|
|
3241
|
+
reviewTimeoutPlaceholder: "300(默认)",
|
|
3242
|
+
reviewTimeoutCancelLabel: "取消超时",
|
|
3243
|
+
reviewTimeoutCancelHint: "审查调用不再因空闲超时(写入约 24.8 天上限)",
|
|
3244
|
+
reviewTimeoutSave: "保存超时设置",
|
|
3245
|
+
reviewTimeoutCancelled: "已取消超时",
|
|
3130
3246
|
reviewAutomodeLinked: "Auto mode 已接入:审查路由 {route},直通 +{added} 个纯读工具({skipped} 条通配未同步)。",
|
|
3131
3247
|
reviewAutomodeRouteOwn: "沿用其自身配置",
|
|
3132
3248
|
reviewAutomodeRouteUnset: "未配置(沿用会话模型)",
|
|
@@ -3214,6 +3330,16 @@ window.__ModuleLoader__.load({
|
|
|
3214
3330
|
reviewAllowlistAvailable: "Present on this machine but not allowed:",
|
|
3215
3331
|
reviewAllowlistRepo: "repo",
|
|
3216
3332
|
reviewAllowlistSkipped: "This Host process has skipped the reviewer {count} times.",
|
|
3333
|
+
reviewTimeout: "Review timeout",
|
|
3334
|
+
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. The value is written into the Provider profile, so it applies after one DSH restart.",
|
|
3336
|
+
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
|
+
reviewTimeoutSeconds: "Timeout (seconds)",
|
|
3338
|
+
reviewTimeoutPlaceholder: "300 (default)",
|
|
3339
|
+
reviewTimeoutCancelLabel: "Cancel timeout",
|
|
3340
|
+
reviewTimeoutCancelHint: "Reviews never time out on idle (writes ~24.8-day ceiling)",
|
|
3341
|
+
reviewTimeoutSave: "Save timeout",
|
|
3342
|
+
reviewTimeoutCancelled: "Timeout cancelled",
|
|
3217
3343
|
reviewAutomodeLinked: "Auto mode linked: reviewer route {route}, passes +{added} read-only tools ({skipped} pattern entries not synced).",
|
|
3218
3344
|
reviewAutomodeRouteOwn: "its own settings",
|
|
3219
3345
|
reviewAutomodeRouteUnset: "unset (follows the session model)",
|
|
@@ -5892,6 +6018,16 @@ window.__ModuleLoader__.load({
|
|
|
5892
6018
|
value: [...tools]
|
|
5893
6019
|
}])) throw new Error("settings-rejected");
|
|
5894
6020
|
},
|
|
6021
|
+
saveReviewTimeout: async (value) => {
|
|
6022
|
+
if (!await owned.mutate([value === void 0 ? {
|
|
6023
|
+
op: "unset",
|
|
6024
|
+
path: ["autoReviewTimeoutMs"]
|
|
6025
|
+
} : {
|
|
6026
|
+
op: "set",
|
|
6027
|
+
path: ["autoReviewTimeoutMs"],
|
|
6028
|
+
value
|
|
6029
|
+
}])) throw new Error("settings-rejected");
|
|
6030
|
+
},
|
|
5895
6031
|
...connectionRpc === void 0 ? {} : { scanTools: async () => {
|
|
5896
6032
|
const response = await callPluginRpc(connectionRpc, "plugin-rpc/model-switch", "tools", {});
|
|
5897
6033
|
if (!response.ok || response.value === void 0) throw new Error(t("reviewAllowlistScanFailed"));
|
package/lib/index.js
CHANGED
|
@@ -32,6 +32,8 @@ const Config = z.object({
|
|
|
32
32
|
autoReviewModel: z.string().volatile(),
|
|
33
33
|
autoReviewSkipReadOnly: z.boolean().default(false).volatile(),
|
|
34
34
|
autoReviewAllowlist: z.array(z.string()).default([...DEFAULT_READ_ONLY_TOOLS]).volatile(),
|
|
35
|
+
/** Reviewer stream idle timeout in ms; 0 = cancel (upstream ceiling); absent = provider default. */
|
|
36
|
+
autoReviewTimeoutMs: z.number().step(1).min(0).max(2147483647).volatile(),
|
|
35
37
|
compactProvider: z.string().volatile(),
|
|
36
38
|
compactModel: z.string().volatile(),
|
|
37
39
|
titleProvider: z.string().volatile(),
|
|
@@ -65,6 +67,7 @@ function readConfig(config) {
|
|
|
65
67
|
const autoReviewModel = config.autoReviewModel.get();
|
|
66
68
|
const autoReviewSkipReadOnly = config.autoReviewSkipReadOnly.get();
|
|
67
69
|
const autoReviewAllowlist = config.autoReviewAllowlist.get();
|
|
70
|
+
const autoReviewTimeoutMs = config.autoReviewTimeoutMs.get();
|
|
68
71
|
const compactProvider = config.compactProvider.get();
|
|
69
72
|
const compactModel = config.compactModel.get();
|
|
70
73
|
const titleProvider = config.titleProvider.get();
|
|
@@ -85,6 +88,7 @@ function readConfig(config) {
|
|
|
85
88
|
...autoReviewModel === void 0 || autoReviewModel === "" ? {} : { autoReviewModel },
|
|
86
89
|
...autoReviewSkipReadOnly ? { autoReviewSkipReadOnly } : {},
|
|
87
90
|
...Array.isArray(autoReviewAllowlist) ? { autoReviewAllowlist: [...autoReviewAllowlist] } : {},
|
|
91
|
+
...autoReviewTimeoutMs === void 0 ? {} : { autoReviewTimeoutMs },
|
|
88
92
|
...compactProvider === void 0 || compactProvider === "" ? {} : { compactProvider },
|
|
89
93
|
...compactModel === void 0 || compactModel === "" ? {} : { compactModel },
|
|
90
94
|
...titleProvider === void 0 || titleProvider === "" ? {} : { titleProvider },
|
|
@@ -280,10 +280,7 @@ async function pushMemoryRoute(ctx, route) {
|
|
|
280
280
|
method: "POST",
|
|
281
281
|
headers: { "content-type": "application/json" },
|
|
282
282
|
body: JSON.stringify({
|
|
283
|
-
distillChain: [
|
|
284
|
-
provider: route.provider,
|
|
285
|
-
model: route.model
|
|
286
|
-
}],
|
|
283
|
+
distillChain: [],
|
|
287
284
|
distillLayerChains: {
|
|
288
285
|
l1: [{
|
|
289
286
|
provider: route.provider,
|
|
@@ -298,8 +295,8 @@ async function pushMemoryRoute(ctx, route) {
|
|
|
298
295
|
model: route.model
|
|
299
296
|
}]
|
|
300
297
|
},
|
|
301
|
-
distillProvider:
|
|
302
|
-
distillModel:
|
|
298
|
+
distillProvider: route.provider,
|
|
299
|
+
distillModel: route.model,
|
|
303
300
|
reasoningEffort: ""
|
|
304
301
|
})
|
|
305
302
|
});
|
|
@@ -402,13 +399,13 @@ function installPrimeMemoryCompat(ctx, loader, routeOf) {
|
|
|
402
399
|
primeMemoryCompatStatus.route = wanted;
|
|
403
400
|
delete primeMemoryCompatStatus.routeSkipped;
|
|
404
401
|
}
|
|
402
|
+
if (pushed === "pushed") return;
|
|
405
403
|
const documentPath = forms.documentPath;
|
|
406
404
|
if (typeof documentPath === "string" && documentPath !== "") try {
|
|
407
405
|
if (await writeStaticPin(documentPath, provider, model) === "written") ctx.logger.info(`model-switch: pinned the dsh-prime-memory distillation route to ${wanted} (applies from the next start)`);
|
|
408
406
|
} catch (cause) {
|
|
409
407
|
ctx.logger.warn(`model-switch: could not pin the dsh-prime-memory route (${String(cause)})`);
|
|
410
408
|
}
|
|
411
|
-
if (pushed === "pushed") return;
|
|
412
409
|
const section = sectionOf(forms);
|
|
413
410
|
if (section === void 0 || asRecord(section.value) === void 0) {
|
|
414
411
|
scheduleRetry();
|
|
@@ -492,4 +489,4 @@ function apply(ctx) {
|
|
|
492
489
|
}, "model-switch: keep the dsh-prime-memory route aligned with the settings");
|
|
493
490
|
}
|
|
494
491
|
//#endregion
|
|
495
|
-
export { apply, chainOf, inject, installPrimeMemoryCompat, name, planPrimeMemoryRoute, primeMemoryCompatStatus };
|
|
492
|
+
export { apply, chainOf, inject, installPrimeMemoryCompat, name, planPrimeMemoryRoute, primeMemoryCompatStatus, pushMemoryRoute };
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import "./tool-allowlist-DlzB5GlQ.js";
|
|
2
|
+
Object.freeze({
|
|
3
|
+
mode: "subagentMode",
|
|
4
|
+
provider: "subagentProvider",
|
|
5
|
+
model: "subagentModel",
|
|
6
|
+
reasoningEffort: "subagentReasoningEffort"
|
|
7
|
+
});
|
|
8
|
+
Object.freeze({
|
|
9
|
+
provider: "searchProvider",
|
|
10
|
+
model: "searchModel"
|
|
11
|
+
});
|
|
12
|
+
Object.freeze({
|
|
13
|
+
provider: "imageProvider",
|
|
14
|
+
model: "imageModel"
|
|
15
|
+
});
|
|
16
|
+
Object.freeze({
|
|
17
|
+
provider: "autoReviewProvider",
|
|
18
|
+
model: "autoReviewModel"
|
|
19
|
+
});
|
|
20
|
+
Object.freeze({
|
|
21
|
+
enabled: "autoReviewSkipReadOnly",
|
|
22
|
+
tools: "autoReviewAllowlist"
|
|
23
|
+
});
|
|
24
|
+
/** Upstream ceiling enforced by `@deepseek-ai/dsh-timeout` (MAX_TIMER_DELAY_MS). */
|
|
25
|
+
const UPSTREAM_MAX_IDLE_TIMEOUT_MS = 2147483647;
|
|
26
|
+
Object.freeze({
|
|
27
|
+
provider: "compactProvider",
|
|
28
|
+
model: "compactModel"
|
|
29
|
+
});
|
|
30
|
+
Object.freeze({
|
|
31
|
+
provider: "titleProvider",
|
|
32
|
+
model: "titleModel"
|
|
33
|
+
});
|
|
34
|
+
Object.freeze({
|
|
35
|
+
provider: "memoryProvider",
|
|
36
|
+
model: "memoryModel"
|
|
37
|
+
});
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region lib/types/review-timeout.js
|
|
40
|
+
/** Cordis plugin identity; matches the `cordis.patch.yml` insert row id. */
|
|
41
|
+
const name = "model-switch-review-timeout";
|
|
42
|
+
/** This row needs the Host's settings service (for `documentPath` and our ns). */
|
|
43
|
+
const inject = ["settings", "modelSwitch"];
|
|
44
|
+
/** The pi-ai row whose provider profiles carry `streamIdleTimeoutMs`. */
|
|
45
|
+
const PI_AI_ROW = "llm-pi-ai";
|
|
46
|
+
/** Live state surfaced next to the reviewer card through the capabilities RPC. */
|
|
47
|
+
const reviewTimeoutStatus = {
|
|
48
|
+
configuredMs: void 0,
|
|
49
|
+
applied: [],
|
|
50
|
+
skipped: []
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Resolve the stored setting into concrete write values.
|
|
54
|
+
*
|
|
55
|
+
* Stored values are user intent: absent = follow the provider default, `0` =
|
|
56
|
+
* cancelled (written as the upstream ceiling), anything else is clamped into
|
|
57
|
+
* the upstream-legal range so a hand-edited profile cannot produce a rejected
|
|
58
|
+
* value.
|
|
59
|
+
*
|
|
60
|
+
* @param settings - the plugin's current settings.
|
|
61
|
+
* @returns the write value and the reviewer providers to apply it to.
|
|
62
|
+
*/
|
|
63
|
+
function planReviewTimeout(settings) {
|
|
64
|
+
const raw = settings.autoReviewTimeoutMs;
|
|
65
|
+
const timeoutMs = raw === void 0 ? void 0 : raw <= 0 ? UPSTREAM_MAX_IDLE_TIMEOUT_MS : Math.min(Math.floor(raw), UPSTREAM_MAX_IDLE_TIMEOUT_MS);
|
|
66
|
+
const providers = /* @__PURE__ */ new Set();
|
|
67
|
+
const add = (value) => {
|
|
68
|
+
const trimmed = (value ?? "").trim();
|
|
69
|
+
if (trimmed !== "") providers.add(trimmed);
|
|
70
|
+
};
|
|
71
|
+
add(settings.autoReviewProvider);
|
|
72
|
+
for (const group of Object.values(settings.providerGroups ?? {})) add(group.autoReviewProvider);
|
|
73
|
+
return {
|
|
74
|
+
timeoutMs,
|
|
75
|
+
providers: [...providers]
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Escape a provider id for use inside a regular expression. */
|
|
79
|
+
function escapeRegExp(value) {
|
|
80
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Set or remove one pi-ai provider's `streamIdleTimeoutMs` in the profile
|
|
84
|
+
* document, touching only that provider's block.
|
|
85
|
+
*
|
|
86
|
+
* The pi-ai row's layout is fixed by its schema: the provider sits at six
|
|
87
|
+
* spaces under `providers:`, its fields at eight. The patch inserts the key at
|
|
88
|
+
* the top of the provider block, replaces it in place, or removes it, and never
|
|
89
|
+
* touches another provider or row.
|
|
90
|
+
*
|
|
91
|
+
* @param text - the full profile document.
|
|
92
|
+
* @param provider - the pi-ai provider id.
|
|
93
|
+
* @param timeoutMs - the value to write, or undefined to remove the key.
|
|
94
|
+
* @returns the patched text and what happened.
|
|
95
|
+
*/
|
|
96
|
+
function patchProviderIdleTimeout(text, provider, timeoutMs) {
|
|
97
|
+
const rows = text.split(/(?=^- id: )/m);
|
|
98
|
+
const index = rows.findIndex((row) => new RegExp(`^- id: ${escapeRegExp(PI_AI_ROW)}\\r?$`, "m").test(row.split("\n", 1)[0] ?? ""));
|
|
99
|
+
if (index < 0) return {
|
|
100
|
+
text,
|
|
101
|
+
outcome: "missing-row"
|
|
102
|
+
};
|
|
103
|
+
const row = rows[index];
|
|
104
|
+
const match = new RegExp(`^( {6})(${escapeRegExp(provider)}):(\\r?)$`, "m").exec(row);
|
|
105
|
+
if (match === null) return {
|
|
106
|
+
text,
|
|
107
|
+
outcome: "missing-provider"
|
|
108
|
+
};
|
|
109
|
+
const blockStart = match.index + match[0].length;
|
|
110
|
+
const bodyRe = /\r?\n {0,6}\S/g;
|
|
111
|
+
bodyRe.lastIndex = blockStart;
|
|
112
|
+
const bodyEnd = bodyRe.exec(row)?.index ?? row.length;
|
|
113
|
+
const block = row.slice(blockStart, bodyEnd);
|
|
114
|
+
const idleRe = /^( {8})streamIdleTimeoutMs: *(\d+)(\r?)$/m;
|
|
115
|
+
const idleMatch = idleRe.exec(block);
|
|
116
|
+
if (timeoutMs !== void 0) {
|
|
117
|
+
if (idleMatch !== null) {
|
|
118
|
+
if (Number(idleMatch[2]) === timeoutMs) return {
|
|
119
|
+
text,
|
|
120
|
+
outcome: "unchanged"
|
|
121
|
+
};
|
|
122
|
+
const nextBlock = block.replace(idleRe, `${idleMatch[1]}streamIdleTimeoutMs: ${timeoutMs}${idleMatch[3]}`);
|
|
123
|
+
rows[index] = row.slice(0, blockStart) + nextBlock + row.slice(bodyEnd);
|
|
124
|
+
return {
|
|
125
|
+
text: rows.join(""),
|
|
126
|
+
outcome: "written"
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
const nextBlock = `\n streamIdleTimeoutMs: ${timeoutMs}${match[3] === "\r" ? "\r\n" : "\n"}${block.slice(1)}`;
|
|
130
|
+
rows[index] = row.slice(0, blockStart) + nextBlock + row.slice(bodyEnd);
|
|
131
|
+
return {
|
|
132
|
+
text: rows.join(""),
|
|
133
|
+
outcome: "written"
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (idleMatch === null) return {
|
|
137
|
+
text,
|
|
138
|
+
outcome: "unchanged"
|
|
139
|
+
};
|
|
140
|
+
const removeRe = /^ {8}streamIdleTimeoutMs: *\d+\r?\n/m;
|
|
141
|
+
const withoutLine = removeRe.test(block) ? block.replace(removeRe, "") : block.replace(idleRe, "");
|
|
142
|
+
rows[index] = row.slice(0, blockStart) + withoutLine + row.slice(bodyEnd);
|
|
143
|
+
return {
|
|
144
|
+
text: rows.join(""),
|
|
145
|
+
outcome: "written"
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Read a provider's current `streamIdleTimeoutMs` from the document.
|
|
150
|
+
*
|
|
151
|
+
* Used to record the pre-overwrite value so a later reset restores it.
|
|
152
|
+
*
|
|
153
|
+
* @param text - the full profile document.
|
|
154
|
+
* @param provider - the pi-ai provider id.
|
|
155
|
+
* @returns the value, or null when the key is absent.
|
|
156
|
+
*/
|
|
157
|
+
function readProviderIdleTimeout(text, provider) {
|
|
158
|
+
const row = text.split(/(?=^- id: )/m).find((candidate) => candidate.startsWith(`- id: llm-pi-ai\n`) || candidate.startsWith(`- id: llm-pi-ai\r\n`));
|
|
159
|
+
if (row === void 0) return null;
|
|
160
|
+
const match = new RegExp(`^ {6}${escapeRegExp(provider)}:\\r?\\n((?: {8}.*\\r?\\n)*)`, "m").exec(row);
|
|
161
|
+
if (match === null) return null;
|
|
162
|
+
const idle = /^ {8}streamIdleTimeoutMs: *(\d+)/m.exec(match[1] ?? "");
|
|
163
|
+
return idle === null ? null : Number(idle[1]);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Row entry point: apply the configured timeout to the reviewer providers'
|
|
167
|
+
* pi-ai profiles in the profile document.
|
|
168
|
+
*
|
|
169
|
+
* Every failure is contained and logged; a broken document must never take the
|
|
170
|
+
* Host down. The write is idempotent: replays find the value already in place
|
|
171
|
+
* and do nothing.
|
|
172
|
+
*
|
|
173
|
+
* @param ctx - this row's context.
|
|
174
|
+
*/
|
|
175
|
+
function apply(ctx) {
|
|
176
|
+
const log = ctx.logger;
|
|
177
|
+
const execute = async () => {
|
|
178
|
+
reviewTimeoutStatus.configuredMs = void 0;
|
|
179
|
+
reviewTimeoutStatus.applied = [];
|
|
180
|
+
reviewTimeoutStatus.skipped = [];
|
|
181
|
+
const settings = ctx.modelSwitch.currentSettings();
|
|
182
|
+
const plan = planReviewTimeout(settings);
|
|
183
|
+
reviewTimeoutStatus.configuredMs = settings.autoReviewTimeoutMs;
|
|
184
|
+
if (plan.providers.length === 0) return;
|
|
185
|
+
const forms = ctx.get("settings", true);
|
|
186
|
+
const documentPath = forms?.documentPath;
|
|
187
|
+
if (forms === void 0 || typeof documentPath !== "string" || documentPath === "") {
|
|
188
|
+
reviewTimeoutStatus.skipped.push(...plan.providers);
|
|
189
|
+
log.warn("model-switch: no profile document is reachable; the review timeout write is skipped");
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
const { readFile, writeFile } = await import("node:fs/promises");
|
|
194
|
+
let text = await readFile(documentPath, "utf8");
|
|
195
|
+
let changed = false;
|
|
196
|
+
for (const provider of plan.providers) {
|
|
197
|
+
const patched = patchProviderIdleTimeout(text, provider, plan.timeoutMs);
|
|
198
|
+
if (patched.outcome === "written") {
|
|
199
|
+
text = patched.text;
|
|
200
|
+
changed = true;
|
|
201
|
+
}
|
|
202
|
+
if (patched.outcome === "written" || patched.outcome === "unchanged") reviewTimeoutStatus.applied.push(provider);
|
|
203
|
+
else reviewTimeoutStatus.skipped.push(provider);
|
|
204
|
+
}
|
|
205
|
+
if (changed) await writeFile(documentPath, text, "utf8");
|
|
206
|
+
log.info(`model-switch: review timeout ${plan.timeoutMs === void 0 ? "reset (provider defaults restored)" : `${plan.timeoutMs}ms`} applied to [${reviewTimeoutStatus.applied.join(", ")}]; skipped [${reviewTimeoutStatus.skipped.join(", ")}]; effective after restart`);
|
|
207
|
+
} catch (cause) {
|
|
208
|
+
log.warn(`model-switch: the review timeout write failed (${String(cause)})`);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
let pending;
|
|
212
|
+
const run = () => {
|
|
213
|
+
if (pending !== void 0) return pending;
|
|
214
|
+
const next = execute().finally(() => {
|
|
215
|
+
if (pending === next) pending = void 0;
|
|
216
|
+
});
|
|
217
|
+
pending = next;
|
|
218
|
+
return next;
|
|
219
|
+
};
|
|
220
|
+
run();
|
|
221
|
+
const lateSweep = setTimeout(() => {
|
|
222
|
+
run();
|
|
223
|
+
}, 1500);
|
|
224
|
+
const offService = ctx.on("internal/service", (name) => {
|
|
225
|
+
if (name === "settings") run();
|
|
226
|
+
});
|
|
227
|
+
ctx.effect(function* () {
|
|
228
|
+
yield () => {
|
|
229
|
+
offService();
|
|
230
|
+
clearTimeout(lateSweep);
|
|
231
|
+
};
|
|
232
|
+
yield ctx.on("model-switch/settings-update", () => {
|
|
233
|
+
run();
|
|
234
|
+
});
|
|
235
|
+
}, "model-switch: keep the review timeout write aligned with the settings");
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
export { PI_AI_ROW, apply, inject, name, patchProviderIdleTimeout, planReviewTimeout, readProviderIdleTimeout, reviewTimeoutStatus };
|
|
@@ -32,6 +32,8 @@ export interface ModelSwitchSettingsFace {
|
|
|
32
32
|
enabled: boolean;
|
|
33
33
|
tools: readonly string[];
|
|
34
34
|
}) => Promise<void>;
|
|
35
|
+
/** Persist the reviewer stream idle timeout; undefined restores provider default. */
|
|
36
|
+
saveReviewTimeout: (value: number | undefined) => Promise<void>;
|
|
35
37
|
/** The Host's live tool catalog; absent on a Host without the `tools` RPC endpoint. */
|
|
36
38
|
scanTools?: () => Promise<{
|
|
37
39
|
rows: readonly ToolCatalogRow[];
|
|
@@ -75,6 +75,16 @@ export declare const zh: {
|
|
|
75
75
|
readonly reviewAllowlistAvailable: "本机存在但未放行的工具:";
|
|
76
76
|
readonly reviewAllowlistRepo: "仓库";
|
|
77
77
|
readonly reviewAllowlistSkipped: "本 Host 进程已为纯读调用跳过 {count} 次审查。";
|
|
78
|
+
readonly reviewTimeout: "审查超时";
|
|
79
|
+
readonly reviewTimeoutDefault: "跟随 Provider 默认(300 秒)";
|
|
80
|
+
readonly reviewTimeoutHelp: "设置自动审查请求的流式空闲超时。留空恢复 Provider 默认值;勾选「取消超时」写入上游上限(约 24.8 天),审查将不会因空闲而超时。该值写在 Provider 配置里,改完需重启一次 DSH 才生效。";
|
|
81
|
+
readonly reviewTimeoutScope: "注意:该值写入审查模型所在 Provider 的 streamIdleTimeoutMs,对该 Provider 的所有调用(含主对话)生效,不只影响审查请求。";
|
|
82
|
+
readonly reviewTimeoutSeconds: "超时秒数";
|
|
83
|
+
readonly reviewTimeoutPlaceholder: "300(默认)";
|
|
84
|
+
readonly reviewTimeoutCancelLabel: "取消超时";
|
|
85
|
+
readonly reviewTimeoutCancelHint: "审查调用不再因空闲超时(写入约 24.8 天上限)";
|
|
86
|
+
readonly reviewTimeoutSave: "保存超时设置";
|
|
87
|
+
readonly reviewTimeoutCancelled: "已取消超时";
|
|
78
88
|
readonly reviewAutomodeLinked: "Auto mode 已接入:审查路由 {route},直通 +{added} 个纯读工具({skipped} 条通配未同步)。";
|
|
79
89
|
readonly reviewAutomodeRouteOwn: "沿用其自身配置";
|
|
80
90
|
readonly reviewAutomodeRouteUnset: "未配置(沿用会话模型)";
|
|
@@ -16,6 +16,11 @@ export interface ModelSwitchSettingsView {
|
|
|
16
16
|
autoReviewSkipReadOnly?: boolean;
|
|
17
17
|
/** Exact tool names, or trailing-`*` patterns, that skip the reviewer when enabled. */
|
|
18
18
|
autoReviewAllowlist?: readonly string[];
|
|
19
|
+
/**
|
|
20
|
+
* Reviewer stream idle timeout in ms; `0` = cancelled (written as the upstream
|
|
21
|
+
* ceiling); absent = follow the provider default.
|
|
22
|
+
*/
|
|
23
|
+
autoReviewTimeoutMs?: number;
|
|
19
24
|
compactProvider?: string;
|
|
20
25
|
compactModel?: string;
|
|
21
26
|
titleProvider?: string;
|
|
@@ -62,6 +67,12 @@ export declare const AUTO_REVIEW_ALLOWLIST_FIELDS: Readonly<{
|
|
|
62
67
|
readonly enabled: "autoReviewSkipReadOnly";
|
|
63
68
|
readonly tools: "autoReviewAllowlist";
|
|
64
69
|
}>;
|
|
70
|
+
/** Auto-reviewer stream idle timeout: one stored value; absent keeps the provider default. */
|
|
71
|
+
export declare const AUTO_REVIEW_TIMEOUT_FIELD: "autoReviewTimeoutMs";
|
|
72
|
+
/** Upstream ceiling enforced by `@deepseek-ai/dsh-timeout` (MAX_TIMER_DELAY_MS). */
|
|
73
|
+
export declare const UPSTREAM_MAX_IDLE_TIMEOUT_MS = 2147483647;
|
|
74
|
+
/** Upstream default (300 s) when the provider profile leaves the field unset. */
|
|
75
|
+
export declare const UPSTREAM_DEFAULT_IDLE_TIMEOUT_MS = 300000;
|
|
65
76
|
/** One allowlist editor snapshot (switch + entries). */
|
|
66
77
|
export interface AutoReviewAllowlistView {
|
|
67
78
|
enabled: boolean;
|
|
@@ -29,6 +29,19 @@ export interface ModelSwitchSettings {
|
|
|
29
29
|
* name). A bare `*` is rejected by the settings editor and never matches.
|
|
30
30
|
*/
|
|
31
31
|
autoReviewAllowlist?: readonly string[];
|
|
32
|
+
/**
|
|
33
|
+
* Reviewer stream idle timeout, in milliseconds, written to the reviewer
|
|
34
|
+
* routes' pi-ai provider profiles (`streamIdleTimeoutMs`).
|
|
35
|
+
*
|
|
36
|
+
* - absent: follow the provider default (300 s) — the upstream behaviour.
|
|
37
|
+
* - `0`: "cancel the timeout" — written as the upstream hard maximum
|
|
38
|
+
* (2147483647 ms ≈ 24.86 days), the closest legal value to "no timeout".
|
|
39
|
+
* - otherwise: a positive finite integer, clamped to the upstream ceiling.
|
|
40
|
+
*
|
|
41
|
+
* The key lives on the provider profile, so it applies to every call through
|
|
42
|
+
* that provider (reviewer, main chat, …), not only the reviewer.
|
|
43
|
+
*/
|
|
44
|
+
autoReviewTimeoutMs?: number;
|
|
32
45
|
/** Summarization provider for `/compact` and automatic compaction; both fields unset = official default (the conversation target). */
|
|
33
46
|
compactProvider?: string;
|
|
34
47
|
/** Summarization model for `/compact` and automatic compaction; set together with `compactProvider`. */
|
|
@@ -60,6 +73,8 @@ export interface Config {
|
|
|
60
73
|
autoReviewSkipReadOnly: Volatile<boolean>;
|
|
61
74
|
/** Tool names (exact, or a trailing `*` pattern) that skip the Auto reviewer. */
|
|
62
75
|
autoReviewAllowlist: Volatile<readonly string[]>;
|
|
76
|
+
/** Reviewer stream idle timeout in ms; 0 = cancel (upstream ceiling); absent = provider default. */
|
|
77
|
+
autoReviewTimeoutMs: Volatile<number | undefined>;
|
|
63
78
|
compactProvider: Volatile<string | undefined>;
|
|
64
79
|
compactModel: Volatile<string | undefined>;
|
|
65
80
|
titleProvider: Volatile<string | undefined>;
|
|
@@ -79,6 +79,20 @@ export declare function planPrimeMemoryRoute(config: unknown, route: CapabilityR
|
|
|
79
79
|
interface Loader {
|
|
80
80
|
entries?(): Iterable<Entry>;
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Hand the route to the memory plugin through the RPC it registers for its own
|
|
84
|
+
* settings page.
|
|
85
|
+
*
|
|
86
|
+
* Writing the config document (what `settings.update` does) only changes what the
|
|
87
|
+
* next start reads; the plugin resolves its route from the runtime settings object
|
|
88
|
+
* it built at `apply`. This endpoint is the documented runtime write path — the
|
|
89
|
+
* same one its own "distillation parameters" panel posts to — so it takes effect
|
|
90
|
+
* without a restart, which is exactly what a provider switch needs.
|
|
91
|
+
*/
|
|
92
|
+
export declare function pushMemoryRoute(ctx: Context, route: {
|
|
93
|
+
provider: string;
|
|
94
|
+
model: string;
|
|
95
|
+
}): Promise<'pushed' | 'absent' | 'rejected'>;
|
|
82
96
|
/**
|
|
83
97
|
* Install the adapter for the whole profile.
|
|
84
98
|
*
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configurable Auto-reviewer stream idle timeout.
|
|
3
|
+
*
|
|
4
|
+
* The reviewer call is a normal llm stream, so its idle watchdog is the one
|
|
5
|
+
* `@deepseek-ai/dsh-llm-pi-ai` puts on the **provider profile**:
|
|
6
|
+
* `providers.<id>.streamIdleTimeoutMs` (default 300 000 ms). There is no
|
|
7
|
+
* per-request override — `GenerateOptions` carries no timeout fields and the
|
|
8
|
+
* adapter reads the profile per call — so the only way to change the reviewer's
|
|
9
|
+
* timeout is to write that provider-profile key.
|
|
10
|
+
*
|
|
11
|
+
* Consequences, all surfaced in the UI copy:
|
|
12
|
+
*
|
|
13
|
+
* - The key lives on the provider, so it applies to **every** call through that
|
|
14
|
+
* provider (reviewer, main chat, other routes), not only the reviewer.
|
|
15
|
+
* - "Cancel the timeout" is legal only as the upstream ceiling
|
|
16
|
+
* (`MAX_TIMER_DELAY_MS` = 2147483647 ms ≈ 24.86 days); upstream rejects 0,
|
|
17
|
+
* negatives and Infinity, so the UI writes the ceiling and says so.
|
|
18
|
+
* - The profile document is read at Host start (same channel as the memory
|
|
19
|
+
* static pin), so a written value takes effect **after a restart**.
|
|
20
|
+
*
|
|
21
|
+
* Restoring is symmetric: the value a provider carried before the first
|
|
22
|
+
* overwrite is recorded in this plugin's own settings
|
|
23
|
+
* (`autoReviewTimeoutPrevious`) and written back when the setting returns to
|
|
24
|
+
* "follow the provider default", so clearing the setting never leaves an
|
|
25
|
+
* adapter-written value behind.
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
30
|
+
import type { ModelSwitchSettings } from './host-settings.js';
|
|
31
|
+
/** Cordis plugin identity; matches the `cordis.patch.yml` insert row id. */
|
|
32
|
+
export declare const name = "model-switch-review-timeout";
|
|
33
|
+
/** This row needs the Host's settings service (for `documentPath` and our ns). */
|
|
34
|
+
export declare const inject: string[];
|
|
35
|
+
/** The pi-ai row whose provider profiles carry `streamIdleTimeoutMs`. */
|
|
36
|
+
export declare const PI_AI_ROW = "llm-pi-ai";
|
|
37
|
+
/** Live state surfaced next to the reviewer card through the capabilities RPC. */
|
|
38
|
+
export declare const reviewTimeoutStatus: {
|
|
39
|
+
configuredMs: number | undefined;
|
|
40
|
+
applied: string[];
|
|
41
|
+
skipped: string[];
|
|
42
|
+
};
|
|
43
|
+
/** One resolved write decision. */
|
|
44
|
+
export interface ReviewTimeoutPlan {
|
|
45
|
+
/** Milliseconds to write per provider; undefined means "restore / follow default". */
|
|
46
|
+
readonly timeoutMs: number | undefined;
|
|
47
|
+
/** Reviewer provider ids collected from the global route and every group. */
|
|
48
|
+
readonly providers: readonly string[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Resolve the stored setting into concrete write values.
|
|
52
|
+
*
|
|
53
|
+
* Stored values are user intent: absent = follow the provider default, `0` =
|
|
54
|
+
* cancelled (written as the upstream ceiling), anything else is clamped into
|
|
55
|
+
* the upstream-legal range so a hand-edited profile cannot produce a rejected
|
|
56
|
+
* value.
|
|
57
|
+
*
|
|
58
|
+
* @param settings - the plugin's current settings.
|
|
59
|
+
* @returns the write value and the reviewer providers to apply it to.
|
|
60
|
+
*/
|
|
61
|
+
export declare function planReviewTimeout(settings: ModelSwitchSettings): ReviewTimeoutPlan;
|
|
62
|
+
/** Why a provider was left untouched. */
|
|
63
|
+
export type ReviewTimeoutSkip = 'missing-row' | 'missing-provider' | 'unrecorded';
|
|
64
|
+
/** Result of one document patch attempt. */
|
|
65
|
+
export interface ReviewTimeoutPatch {
|
|
66
|
+
readonly text: string;
|
|
67
|
+
readonly outcome: 'written' | 'unchanged' | ReviewTimeoutSkip;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Set or remove one pi-ai provider's `streamIdleTimeoutMs` in the profile
|
|
71
|
+
* document, touching only that provider's block.
|
|
72
|
+
*
|
|
73
|
+
* The pi-ai row's layout is fixed by its schema: the provider sits at six
|
|
74
|
+
* spaces under `providers:`, its fields at eight. The patch inserts the key at
|
|
75
|
+
* the top of the provider block, replaces it in place, or removes it, and never
|
|
76
|
+
* touches another provider or row.
|
|
77
|
+
*
|
|
78
|
+
* @param text - the full profile document.
|
|
79
|
+
* @param provider - the pi-ai provider id.
|
|
80
|
+
* @param timeoutMs - the value to write, or undefined to remove the key.
|
|
81
|
+
* @returns the patched text and what happened.
|
|
82
|
+
*/
|
|
83
|
+
export declare function patchProviderIdleTimeout(text: string, provider: string, timeoutMs: number | undefined): ReviewTimeoutPatch;
|
|
84
|
+
/**
|
|
85
|
+
* Read a provider's current `streamIdleTimeoutMs` from the document.
|
|
86
|
+
*
|
|
87
|
+
* Used to record the pre-overwrite value so a later reset restores it.
|
|
88
|
+
*
|
|
89
|
+
* @param text - the full profile document.
|
|
90
|
+
* @param provider - the pi-ai provider id.
|
|
91
|
+
* @returns the value, or null when the key is absent.
|
|
92
|
+
*/
|
|
93
|
+
export declare function readProviderIdleTimeout(text: string, provider: string): number | null;
|
|
94
|
+
/**
|
|
95
|
+
* Row entry point: apply the configured timeout to the reviewer providers'
|
|
96
|
+
* pi-ai profiles in the profile document.
|
|
97
|
+
*
|
|
98
|
+
* Every failure is contained and logged; a broken document must never take the
|
|
99
|
+
* Host down. The write is idempotent: replays find the value already in place
|
|
100
|
+
* and do nothing.
|
|
101
|
+
*
|
|
102
|
+
* @param ctx - this row's context.
|
|
103
|
+
*/
|
|
104
|
+
export declare function apply(ctx: Context): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-model-switch",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.50",
|
|
4
4
|
"description": "Explicit model routing plus composer/Plan picker for DeepSeek Harness",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -66,6 +66,10 @@
|
|
|
66
66
|
"types": "./lib/types/prime-memory-compat.d.ts",
|
|
67
67
|
"default": "./lib/prime-memory-compat.js"
|
|
68
68
|
},
|
|
69
|
+
"./review-timeout": {
|
|
70
|
+
"types": "./lib/types/review-timeout.d.ts",
|
|
71
|
+
"default": "./lib/review-timeout.js"
|
|
72
|
+
},
|
|
69
73
|
"./package.json": "./package.json"
|
|
70
74
|
},
|
|
71
75
|
"files": [
|