dsh-model-switch 0.4.71 → 0.4.73
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 +25 -0
- package/PRODUCT.md +1 -1
- package/README.md +2 -0
- package/lib/auto-review-0mh6NLlr.js +1817 -0
- package/lib/auto-review-B4L59yj4.js +1079 -0
- package/lib/auto-review.js +2 -2
- package/lib/automode-compat.js +1 -1
- package/lib/client.js +128 -4
- package/lib/index.js +12 -4
- package/lib/review-timeout-CAlD65wl.js +339 -0
- package/lib/review-timeout.js +1 -1
- package/lib/tool-allowlist-Ddb8jfNx.js +560 -0
- package/lib/types/auto-review-gate.d.ts +186 -0
- package/lib/types/auto-review.d.ts +31 -2
- package/lib/types/capabilities-rpc.d.ts +6 -0
- package/lib/types/client/ModelSwitchSettings.d.ts +2 -0
- package/lib/types/client/locales.d.ts +7 -0
- package/lib/types/client-contract.d.ts +8 -0
- package/lib/types/host-settings.d.ts +11 -0
- package/lib/types/tool-allowlist.d.ts +7 -2
- package/package.json +1 -1
package/lib/auto-review.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as bindAutoReviewSessionCorrelation, c as installToolCallSafetyNet, d as
|
|
2
|
-
export { apply, autoReviewGate, autoReviewRouteOf, autoReviewStatus, bindAutoReviewSessionCorrelation, defensivePermissionPresets, inject, installToolCallSafetyNet, isReviewerInfrastructureFailure, name, resolveSessionAutoReviewRoute, reviewLlm, reviewScope };
|
|
1
|
+
import { a as bindAutoReviewSessionCorrelation, c as installToolCallSafetyNet, d as ownGateEngaged, f as resolveSessionAutoReviewRoute, i as autoReviewStatus, l as isReviewerInfrastructureFailure, m as reviewScope, n as autoReviewGate, o as defensivePermissionPresets, p as reviewLlm, r as autoReviewRouteOf, s as inject, t as apply, u as name } from "./auto-review-0mh6NLlr.js";
|
|
2
|
+
export { apply, autoReviewGate, autoReviewRouteOf, autoReviewStatus, bindAutoReviewSessionCorrelation, defensivePermissionPresets, inject, installToolCallSafetyNet, isReviewerInfrastructureFailure, name, ownGateEngaged, resolveSessionAutoReviewRoute, reviewLlm, reviewScope };
|
package/lib/automode-compat.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as DEFAULT_READ_ONLY_TOOLS } from "./tool-allowlist-
|
|
1
|
+
import { t as DEFAULT_READ_ONLY_TOOLS } from "./tool-allowlist-Ddb8jfNx.js";
|
|
2
2
|
import { t as applyFiberConfig } from "./fiber-hot-update-DrZANcwD.js";
|
|
3
3
|
//#region lib/types/automode-compat.js
|
|
4
4
|
/** Cordis plugin identity; matches the `cordis.patch.yml` insert row id. */
|
package/lib/client.js
CHANGED
|
@@ -64,6 +64,42 @@ window.__ModuleLoader__.load({
|
|
|
64
64
|
label: "插件 · dsh-embedded-browser",
|
|
65
65
|
repo: "https://github.com/imroc/dsh-embedded-browser"
|
|
66
66
|
},
|
|
67
|
+
{
|
|
68
|
+
id: "dsh-bilibili-summary",
|
|
69
|
+
kind: "plugin",
|
|
70
|
+
label: "插件 · dsh-bilibili-summary",
|
|
71
|
+
repo: "https://github.com/Adamaik/dsh-zcode-plugins"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: "dsh-media-lens",
|
|
75
|
+
kind: "plugin",
|
|
76
|
+
label: "插件 · dsh-media-lens",
|
|
77
|
+
repo: "https://github.com/drscrewdriver/dsh-media-lens"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: "dsh-video-storyboard",
|
|
81
|
+
kind: "plugin",
|
|
82
|
+
label: "插件 · dsh-video-storyboard",
|
|
83
|
+
repo: "https://github.com/SAOS-3624/dsh-video-storyboard"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "dsh-video-studio",
|
|
87
|
+
kind: "plugin",
|
|
88
|
+
label: "插件 · dsh-video-studio",
|
|
89
|
+
repo: "https://github.com/vandoor7-droid/dsh-video-studio"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: "dsh-meme-radar",
|
|
93
|
+
kind: "plugin",
|
|
94
|
+
label: "插件 · dsh-meme-radar",
|
|
95
|
+
repo: "https://github.com/vandoor7-droid/dsh-meme-radar"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: "dsh-windows-mcp",
|
|
99
|
+
kind: "plugin",
|
|
100
|
+
label: "插件 · dsh-windows-mcp",
|
|
101
|
+
repo: "https://github.com/helloHub1212/dsh-windows-mcp"
|
|
102
|
+
},
|
|
67
103
|
{
|
|
68
104
|
id: "mcp:wincu",
|
|
69
105
|
kind: "mcp",
|
|
@@ -145,6 +181,8 @@ window.__ModuleLoader__.load({
|
|
|
145
181
|
"terminal_signal",
|
|
146
182
|
"todo_write",
|
|
147
183
|
"update_goal",
|
|
184
|
+
"user_terminal_list",
|
|
185
|
+
"user_terminal_read",
|
|
148
186
|
"wait_agent",
|
|
149
187
|
"web_fetch",
|
|
150
188
|
"web_search",
|
|
@@ -162,7 +200,12 @@ window.__ModuleLoader__.load({
|
|
|
162
200
|
["browser_embedded_", "dsh-embedded-browser"],
|
|
163
201
|
["ops_", "dsh-ops"],
|
|
164
202
|
["vision_", "dsh-vision-router"],
|
|
165
|
-
["univer_", "dsh-univer-office"]
|
|
203
|
+
["univer_", "dsh-univer-office"],
|
|
204
|
+
["bilibili_", "dsh-bilibili-summary"],
|
|
205
|
+
["media_read_", "dsh-media-lens"],
|
|
206
|
+
["video_", "dsh-video-storyboard"],
|
|
207
|
+
["studio_", "dsh-video-studio"],
|
|
208
|
+
["meme_", "dsh-meme-radar"]
|
|
166
209
|
];
|
|
167
210
|
/**
|
|
168
211
|
* Single plugin tools that carry no usable prefix.
|
|
@@ -203,7 +246,9 @@ window.__ModuleLoader__.load({
|
|
|
203
246
|
["memory_list", "dsh-auto-memory"],
|
|
204
247
|
["memory_prune", "dsh-auto-memory"],
|
|
205
248
|
["memory_read", "dsh-auto-memory"],
|
|
206
|
-
["memory_write", "dsh-auto-memory"]
|
|
249
|
+
["memory_write", "dsh-auto-memory"],
|
|
250
|
+
["hotlist_scan", "dsh-meme-radar"],
|
|
251
|
+
["windows_mcp_doctor", "dsh-windows-mcp"]
|
|
207
252
|
]);
|
|
208
253
|
/** `<base>__<owner>` — the extension-tool naming the QQ bot framework uses. */
|
|
209
254
|
const EXTENSION_TOOL = /^([A-Za-z0-9_-]+)__(.+)$/;
|
|
@@ -227,7 +272,8 @@ window.__ModuleLoader__.load({
|
|
|
227
272
|
* Beyond that rule sit the entries the user explicitly released (2026-10-24:
|
|
228
273
|
* goal/schedule/terminal creation; 2026-11-20: the vision model calls, the
|
|
229
274
|
* mineru document_parse task, todo/goal updates, and the prime-memory write
|
|
230
|
-
* tools
|
|
275
|
+
* tools; 2026-11-22: the media-lens file reads and the video storyboard
|
|
276
|
+
* search/decode tools). These do have side effects — vision calls spend the configured
|
|
231
277
|
* backend's quota and send image content to it, document_parse spawns a parse
|
|
232
278
|
* task, the memory tools mutate the memory store — but everything they enable
|
|
233
279
|
* stays inside the same session and auto preset. Releasing them only skips the
|
|
@@ -236,7 +282,11 @@ window.__ModuleLoader__.load({
|
|
|
236
282
|
* from the parent's in-flight bypass answer, so releasing them would strip the
|
|
237
283
|
* child of the auto preset entirely (see DELEGATION_SPAWNS in the tests).
|
|
238
284
|
* schedule_edit was reviewed on 2026-11-20 and deliberately kept OUT: it can
|
|
239
|
-
* modify or delete tasks other sessions created.
|
|
285
|
+
* modify or delete tasks other sessions created. bilibili_login (writes the
|
|
286
|
+
* stored sign-in session), bilibili_transcribe (its first run builds a private
|
|
287
|
+
* virtualenv, downloads a whisper model and the audio) and meme_add (writes
|
|
288
|
+
* the meme library) were reviewed on 2026-11-22 and stay OUT for the same
|
|
289
|
+
* reason.
|
|
240
290
|
*/
|
|
241
291
|
const DEFAULT_READ_ONLY_TOOLS = [
|
|
242
292
|
"read",
|
|
@@ -337,6 +387,19 @@ window.__ModuleLoader__.load({
|
|
|
337
387
|
"mcp__mineru-mcp__get_task_progress",
|
|
338
388
|
"mcp__mineru-mcp__get_recent_logs",
|
|
339
389
|
"mcp__mineru-mcp__wait_for_task",
|
|
390
|
+
"user_terminal_list",
|
|
391
|
+
"user_terminal_read",
|
|
392
|
+
"windows_mcp_doctor",
|
|
393
|
+
"meme_query",
|
|
394
|
+
"hotlist_scan",
|
|
395
|
+
"bilibili_video_info",
|
|
396
|
+
"bilibili_series",
|
|
397
|
+
"bilibili_subtitles",
|
|
398
|
+
"video_help",
|
|
399
|
+
"video_probe",
|
|
400
|
+
"video_storyboard_settings",
|
|
401
|
+
"studio_status",
|
|
402
|
+
"studio_open",
|
|
340
403
|
"vision_describe",
|
|
341
404
|
"vision_bootstrap",
|
|
342
405
|
"vision_ground",
|
|
@@ -363,6 +426,14 @@ window.__ModuleLoader__.load({
|
|
|
363
426
|
"memory_migrate_relation",
|
|
364
427
|
"memory_reproject",
|
|
365
428
|
"memory_ruminate_cancel",
|
|
429
|
+
"media_read_image",
|
|
430
|
+
"media_read_audio",
|
|
431
|
+
"media_read_pdf",
|
|
432
|
+
"media_read_video",
|
|
433
|
+
"video_locate",
|
|
434
|
+
"video_storyboard",
|
|
435
|
+
"video_subtitles",
|
|
436
|
+
"video_zoom",
|
|
366
437
|
"sessions_list__*",
|
|
367
438
|
"bing_search__*"
|
|
368
439
|
];
|
|
@@ -650,6 +721,9 @@ window.__ModuleLoader__.load({
|
|
|
650
721
|
held: status.held === true,
|
|
651
722
|
allowedCalls: count(status.allowedCalls),
|
|
652
723
|
skippedReadOnly: count(status.skippedReadOnly),
|
|
724
|
+
ownGate: status.ownGate === true,
|
|
725
|
+
purgeInstalled: status.purgeInstalled === true,
|
|
726
|
+
...typeof status.officialGateNeutered === "boolean" ? { officialGateNeutered: status.officialGateNeutered } : {},
|
|
653
727
|
automode,
|
|
654
728
|
primeMemory: adapterRow(status.primeMemory),
|
|
655
729
|
visionRouter: adapterRow(status.visionRouter)
|
|
@@ -2191,6 +2265,8 @@ window.__ModuleLoader__.load({
|
|
|
2191
2265
|
const allowlistView = switchSettings.value === void 0 ? void 0 : deriveAutoReviewAllowlist(switchSettings.value);
|
|
2192
2266
|
const allowlistTools = allowlistView?.tools ?? DEFAULT_READ_ONLY_TOOLS;
|
|
2193
2267
|
const allowlistEnabled = allowlistView?.enabled === true;
|
|
2268
|
+
/** The own-gate switch value: default on; only meaningful on a purge-patched host. */
|
|
2269
|
+
const ownGateSettingOn = switchSettings.value === void 0 ? true : switchSettings.value.autoReviewOwnGate !== false;
|
|
2194
2270
|
const allowlistWritable = switchSettings.status === "ready" && switchSettings.writable;
|
|
2195
2271
|
const persistAllowlist = (next) => {
|
|
2196
2272
|
if (busy !== void 0 || !allowlistWritable) return;
|
|
@@ -3279,6 +3355,33 @@ window.__ModuleLoader__.load({
|
|
|
3279
3355
|
className: ModelSwitchSettings_module_css_default.hint,
|
|
3280
3356
|
children: props.t("reviewAllowlistSkipped").replace("{count}", String(reviewStatus.skippedReadOnly))
|
|
3281
3357
|
}),
|
|
3358
|
+
reviewStatus === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3359
|
+
className: ModelSwitchSettings_module_css_default.rowCard,
|
|
3360
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3361
|
+
className: ModelSwitchSettings_module_css_default.rowCopy,
|
|
3362
|
+
children: [
|
|
3363
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3364
|
+
className: ModelSwitchSettings_module_css_default.rowTitle,
|
|
3365
|
+
children: props.t("reviewOwnGate")
|
|
3366
|
+
}),
|
|
3367
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3368
|
+
className: ModelSwitchSettings_module_css_default.hint,
|
|
3369
|
+
children: props.t("reviewOwnGateHelp")
|
|
3370
|
+
}),
|
|
3371
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3372
|
+
className: ModelSwitchSettings_module_css_default.hint,
|
|
3373
|
+
children: reviewStatus.purgeInstalled === true ? props.t("reviewOwnGatePatched").replace("{neutered}", reviewStatus.officialGateNeutered === void 0 ? props.t("reviewOwnGateUnknown") : reviewStatus.officialGateNeutered ? props.t("reviewOwnGateNeuteredYes") : props.t("reviewOwnGateNeuteredNo")) : props.t("reviewOwnGateUnavailable")
|
|
3374
|
+
})
|
|
3375
|
+
]
|
|
3376
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InstantSwitch, {
|
|
3377
|
+
checked: ownGateSettingOn,
|
|
3378
|
+
disabled: busy !== void 0 || !allowlistWritable || reviewStatus.purgeInstalled !== true,
|
|
3379
|
+
label: props.t("reviewOwnGate"),
|
|
3380
|
+
onChange: (next) => {
|
|
3381
|
+
run("allowlist", () => props.saveReviewOwnGate(next));
|
|
3382
|
+
}
|
|
3383
|
+
})]
|
|
3384
|
+
}),
|
|
3282
3385
|
reviewStatus?.automode === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3283
3386
|
className: ModelSwitchSettings_module_css_default.hint,
|
|
3284
3387
|
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))
|
|
@@ -3864,6 +3967,13 @@ window.__ModuleLoader__.load({
|
|
|
3864
3967
|
reviewAllowlistAvailable: "本机存在但未放行的工具:",
|
|
3865
3968
|
reviewAllowlistRepo: "仓库",
|
|
3866
3969
|
reviewAllowlistSkipped: "本 Host 进程已为纯读调用跳过 {count} 次审查。",
|
|
3970
|
+
reviewOwnGate: "破甲接管:自有审查门",
|
|
3971
|
+
reviewOwnGateHelp: "安装破甲(dsh-purge)后,官方审查门的宿主代码会被其补丁短路;开启后由本插件的自有审查门接管 auto 会话的逐调用审查,路由仍用上方配置的审查模型。",
|
|
3972
|
+
reviewOwnGateUnavailable: "未检测到破甲插件:官方审查门正常服务,此开关不适用。",
|
|
3973
|
+
reviewOwnGatePatched: "官方门补丁状态:{neutered}。",
|
|
3974
|
+
reviewOwnGateNeuteredYes: "已被宿主补丁短路",
|
|
3975
|
+
reviewOwnGateNeuteredNo: "未见补丁标记",
|
|
3976
|
+
reviewOwnGateUnknown: "未知",
|
|
3867
3977
|
reviewAutomodeLinked: "Auto mode 已接入:审查路由 {route},直通 +{added} 个纯读工具({skipped} 条通配未同步)。",
|
|
3868
3978
|
reviewAutomodeRouteOwn: "沿用其自身配置",
|
|
3869
3979
|
reviewAutomodeRouteUnset: "未配置(沿用会话模型)",
|
|
@@ -3970,6 +4080,13 @@ window.__ModuleLoader__.load({
|
|
|
3970
4080
|
reviewAllowlistAvailable: "Present on this machine but not allowed:",
|
|
3971
4081
|
reviewAllowlistRepo: "repo",
|
|
3972
4082
|
reviewAllowlistSkipped: "This Host process has skipped the reviewer {count} times.",
|
|
4083
|
+
reviewOwnGate: "Purge takeover: owned review gate",
|
|
4084
|
+
reviewOwnGateHelp: "Once dsh-purge patches the host, the official review gate’s host code is short-circuited; when on, this plugin’s own gate reviews every call in Auto sessions using the reviewer model configured above.",
|
|
4085
|
+
reviewOwnGateUnavailable: "No purge plugin detected: the official gate serves and this switch does not apply.",
|
|
4086
|
+
reviewOwnGatePatched: "Official gate patch state: {neutered}.",
|
|
4087
|
+
reviewOwnGateNeuteredYes: "short-circuited by a host patch",
|
|
4088
|
+
reviewOwnGateNeuteredNo: "no patch marker seen",
|
|
4089
|
+
reviewOwnGateUnknown: "unknown",
|
|
3973
4090
|
reviewAutomodeLinked: "Auto mode linked: reviewer route {route}, passes +{added} read-only tools ({skipped} pattern entries not synced).",
|
|
3974
4091
|
reviewAutomodeRouteOwn: "its own settings",
|
|
3975
4092
|
reviewAutomodeRouteUnset: "unset (follows the session model)",
|
|
@@ -6728,6 +6845,13 @@ window.__ModuleLoader__.load({
|
|
|
6728
6845
|
value: [...tools]
|
|
6729
6846
|
}])) throw new Error("settings-rejected");
|
|
6730
6847
|
},
|
|
6848
|
+
saveReviewOwnGate: async (ownGate) => {
|
|
6849
|
+
if (!await owned.mutate([{
|
|
6850
|
+
op: "set",
|
|
6851
|
+
path: ["autoReviewOwnGate"],
|
|
6852
|
+
value: ownGate
|
|
6853
|
+
}])) throw new Error("settings-rejected");
|
|
6854
|
+
},
|
|
6731
6855
|
...connectionRpc === void 0 ? {} : { scanTools: async () => {
|
|
6732
6856
|
const response = await callPluginRpc(connectionRpc, "plugin-rpc/model-switch", "tools", {});
|
|
6733
6857
|
if (!response.ok || response.value === void 0) throw new Error(t("reviewAllowlistScanFailed"));
|
package/lib/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { l as normalizeProviderGroups } from "./session-route-CRfpxarI.js";
|
|
2
|
-
import { r as resolveToolSource, t as DEFAULT_READ_ONLY_TOOLS } from "./tool-allowlist-
|
|
3
|
-
import { i as autoReviewStatus } from "./auto-review-
|
|
2
|
+
import { r as resolveToolSource, t as DEFAULT_READ_ONLY_TOOLS } from "./tool-allowlist-Ddb8jfNx.js";
|
|
3
|
+
import { d as ownGateEngaged, i as autoReviewStatus } from "./auto-review-0mh6NLlr.js";
|
|
4
4
|
import { ModelSwitchAdapterRegistry } from "./adapter-registry.js";
|
|
5
5
|
import { automodeCompatView } from "./automode-compat.js";
|
|
6
6
|
import { s as subagentDiscoveryHintStatus } from "./subagent-runtime-eNKrdb2H.js";
|
|
7
|
-
import { u as reviewTimeoutStatus } from "./review-timeout-
|
|
7
|
+
import { u as reviewTimeoutStatus } from "./review-timeout-CAlD65wl.js";
|
|
8
8
|
import { primeMemoryCompatStatus } from "./prime-memory-compat.js";
|
|
9
9
|
import { a as visionRouterCompatStatus } from "./vision-router-compat-DP81VMLW.js";
|
|
10
10
|
import { createRequire } from "node:module";
|
|
@@ -35,6 +35,7 @@ const Config = z.object({
|
|
|
35
35
|
autoReviewProvider: z.string().volatile(),
|
|
36
36
|
autoReviewModel: z.string().volatile(),
|
|
37
37
|
autoReviewSkipReadOnly: z.boolean().default(false).volatile(),
|
|
38
|
+
autoReviewOwnGate: z.boolean().default(true).volatile(),
|
|
38
39
|
autoReviewAllowlist: z.array(z.string()).default([...DEFAULT_READ_ONLY_TOOLS]).volatile(),
|
|
39
40
|
/** Reviewer stream idle timeout in ms; 0 = cancel (upstream ceiling); absent = provider default. */
|
|
40
41
|
autoReviewTimeoutMs: z.number().step(1).min(0).max(2147483647).volatile(),
|
|
@@ -76,6 +77,7 @@ function readConfig(config) {
|
|
|
76
77
|
const autoReviewProvider = config.autoReviewProvider.get();
|
|
77
78
|
const autoReviewModel = config.autoReviewModel.get();
|
|
78
79
|
const autoReviewSkipReadOnly = config.autoReviewSkipReadOnly.get();
|
|
80
|
+
const autoReviewOwnGate = config.autoReviewOwnGate.get();
|
|
79
81
|
const autoReviewAllowlist = config.autoReviewAllowlist.get();
|
|
80
82
|
const autoReviewTimeoutMs = config.autoReviewTimeoutMs.get();
|
|
81
83
|
const compactProvider = config.compactProvider.get();
|
|
@@ -100,6 +102,7 @@ function readConfig(config) {
|
|
|
100
102
|
...autoReviewProvider === void 0 || autoReviewProvider === "" ? {} : { autoReviewProvider },
|
|
101
103
|
...autoReviewModel === void 0 || autoReviewModel === "" ? {} : { autoReviewModel },
|
|
102
104
|
...autoReviewSkipReadOnly ? { autoReviewSkipReadOnly } : {},
|
|
105
|
+
...autoReviewOwnGate === void 0 ? {} : { autoReviewOwnGate },
|
|
103
106
|
...Array.isArray(autoReviewAllowlist) ? { autoReviewAllowlist: [...autoReviewAllowlist] } : {},
|
|
104
107
|
...autoReviewTimeoutMs === void 0 ? {} : { autoReviewTimeoutMs },
|
|
105
108
|
...compactProvider === void 0 || compactProvider === "" ? {} : { compactProvider },
|
|
@@ -463,7 +466,9 @@ function capabilitiesRpc(registry, snapshot, lifetime, catalog = () => ({
|
|
|
463
466
|
}), status = () => ({
|
|
464
467
|
held: false,
|
|
465
468
|
allowedCalls: 0,
|
|
466
|
-
skippedReadOnly: 0
|
|
469
|
+
skippedReadOnly: 0,
|
|
470
|
+
ownGate: false,
|
|
471
|
+
purgeInstalled: false
|
|
467
472
|
})) {
|
|
468
473
|
let revision = 0;
|
|
469
474
|
let previous;
|
|
@@ -557,6 +562,9 @@ function installCapabilitiesRpc(ctx, registry, snapshot) {
|
|
|
557
562
|
held: autoReviewStatus.held,
|
|
558
563
|
allowedCalls: autoReviewStatus.allowedCalls,
|
|
559
564
|
skippedReadOnly: autoReviewStatus.skippedReadOnly,
|
|
565
|
+
ownGate: ownGateEngaged(),
|
|
566
|
+
purgeInstalled: autoReviewStatus.purgeInstalled,
|
|
567
|
+
...autoReviewStatus.officialGateNeutered === void 0 ? {} : { officialGateNeutered: autoReviewStatus.officialGateNeutered },
|
|
560
568
|
automode: automodeCompatView(),
|
|
561
569
|
primeMemory: {
|
|
562
570
|
installed: primeMemoryCompatStatus.installed,
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import "./tool-allowlist-Ddb8jfNx.js";
|
|
2
|
+
import { t as applyFiberConfig } from "./fiber-hot-update-DrZANcwD.js";
|
|
3
|
+
Object.freeze({
|
|
4
|
+
mode: "subagentMode",
|
|
5
|
+
provider: "subagentProvider",
|
|
6
|
+
model: "subagentModel",
|
|
7
|
+
reasoningEffort: "subagentReasoningEffort"
|
|
8
|
+
});
|
|
9
|
+
Object.freeze({
|
|
10
|
+
provider: "searchProvider",
|
|
11
|
+
model: "searchModel"
|
|
12
|
+
});
|
|
13
|
+
Object.freeze({
|
|
14
|
+
provider: "imageProvider",
|
|
15
|
+
model: "imageModel"
|
|
16
|
+
});
|
|
17
|
+
Object.freeze({
|
|
18
|
+
provider: "autoReviewProvider",
|
|
19
|
+
model: "autoReviewModel"
|
|
20
|
+
});
|
|
21
|
+
Object.freeze({
|
|
22
|
+
enabled: "autoReviewSkipReadOnly",
|
|
23
|
+
tools: "autoReviewAllowlist"
|
|
24
|
+
});
|
|
25
|
+
/** Upstream ceiling enforced by `@deepseek-ai/dsh-timeout` (MAX_TIMER_DELAY_MS). */
|
|
26
|
+
const UPSTREAM_MAX_IDLE_TIMEOUT_MS = 2147483647;
|
|
27
|
+
Object.freeze({
|
|
28
|
+
provider: "compactProvider",
|
|
29
|
+
model: "compactModel"
|
|
30
|
+
});
|
|
31
|
+
Object.freeze({
|
|
32
|
+
provider: "titleProvider",
|
|
33
|
+
model: "titleModel"
|
|
34
|
+
});
|
|
35
|
+
Object.freeze({
|
|
36
|
+
provider: "memoryProvider",
|
|
37
|
+
model: "memoryModel",
|
|
38
|
+
reasoningEffort: "memoryReasoningEffort"
|
|
39
|
+
});
|
|
40
|
+
Object.freeze({
|
|
41
|
+
provider: "visionProvider",
|
|
42
|
+
model: "visionModel"
|
|
43
|
+
});
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region lib/types/review-timeout.js
|
|
46
|
+
/** Cordis plugin identity; matches the `cordis.patch.yml` insert row id. */
|
|
47
|
+
const name = "model-switch-review-timeout";
|
|
48
|
+
/** This row needs the Host's settings service (for `documentPath` and our ns). */
|
|
49
|
+
const inject = ["settings"];
|
|
50
|
+
/** The pi-ai row whose provider profiles carry `streamIdleTimeoutMs`. */
|
|
51
|
+
const PI_AI_ROW = "llm-pi-ai";
|
|
52
|
+
/** The package the pi-ai row loads; matching by name survives a profile id rename. */
|
|
53
|
+
const PI_AI_PACKAGE = "@deepseek-ai/dsh-llm-pi-ai";
|
|
54
|
+
/** Live state surfaced next to the reviewer card through the capabilities RPC. */
|
|
55
|
+
const reviewTimeoutStatus = {
|
|
56
|
+
configuredMs: void 0,
|
|
57
|
+
applied: [],
|
|
58
|
+
skipped: [],
|
|
59
|
+
/** Providers whose running row was reloaded with the new timeout. */
|
|
60
|
+
hotApplied: [],
|
|
61
|
+
/** Whether the running row took the value, or the next start has to. */
|
|
62
|
+
hot: void 0,
|
|
63
|
+
/** Why the running row did not take the value, when it did not. */
|
|
64
|
+
hotReason: void 0
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Resolve the stored setting into concrete write values.
|
|
68
|
+
*
|
|
69
|
+
* Stored values are user intent: absent = follow the provider default, `0` =
|
|
70
|
+
* cancelled (written as the upstream ceiling), anything else is clamped into
|
|
71
|
+
* the upstream-legal range so a hand-edited profile cannot produce a rejected
|
|
72
|
+
* value.
|
|
73
|
+
*
|
|
74
|
+
* @param settings - the plugin's current settings.
|
|
75
|
+
* @returns the write value and the reviewer providers to apply it to.
|
|
76
|
+
*/
|
|
77
|
+
function planReviewTimeout(settings) {
|
|
78
|
+
const raw = settings.autoReviewTimeoutMs;
|
|
79
|
+
const timeoutMs = raw === void 0 ? void 0 : raw <= 0 ? UPSTREAM_MAX_IDLE_TIMEOUT_MS : Math.min(Math.floor(raw), UPSTREAM_MAX_IDLE_TIMEOUT_MS);
|
|
80
|
+
const providers = /* @__PURE__ */ new Set();
|
|
81
|
+
const add = (value) => {
|
|
82
|
+
const trimmed = (value ?? "").trim();
|
|
83
|
+
if (trimmed !== "") providers.add(trimmed);
|
|
84
|
+
};
|
|
85
|
+
add(settings.autoReviewProvider);
|
|
86
|
+
for (const group of Object.values(settings.providerGroups ?? {})) add(group.autoReviewProvider);
|
|
87
|
+
return {
|
|
88
|
+
timeoutMs,
|
|
89
|
+
providers: [...providers]
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** Escape a provider id for use inside a regular expression. */
|
|
93
|
+
function escapeRegExp(value) {
|
|
94
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Set or remove one pi-ai provider's `streamIdleTimeoutMs` in the profile
|
|
98
|
+
* document, touching only that provider's block.
|
|
99
|
+
*
|
|
100
|
+
* The pi-ai row's layout is fixed by its schema: the provider sits at six
|
|
101
|
+
* spaces under `providers:`, its fields at eight. The patch inserts the key at
|
|
102
|
+
* the top of the provider block, replaces it in place, or removes it, and never
|
|
103
|
+
* touches another provider or row.
|
|
104
|
+
*
|
|
105
|
+
* @param text - the full profile document.
|
|
106
|
+
* @param provider - the pi-ai provider id.
|
|
107
|
+
* @param timeoutMs - the value to write, or undefined to remove the key.
|
|
108
|
+
* @returns the patched text and what happened.
|
|
109
|
+
*/
|
|
110
|
+
function patchProviderIdleTimeout(text, provider, timeoutMs) {
|
|
111
|
+
const rows = text.split(/(?=^- id: )/m);
|
|
112
|
+
const index = rows.findIndex((row) => new RegExp(`^- id: ${escapeRegExp(PI_AI_ROW)}\\r?$`, "m").test(row.split("\n", 1)[0] ?? ""));
|
|
113
|
+
if (index < 0) return {
|
|
114
|
+
text,
|
|
115
|
+
outcome: "missing-row"
|
|
116
|
+
};
|
|
117
|
+
const row = rows[index];
|
|
118
|
+
const match = new RegExp(`^( {6})(${escapeRegExp(provider)}):(\\r?)$`, "m").exec(row);
|
|
119
|
+
if (match === null) return {
|
|
120
|
+
text,
|
|
121
|
+
outcome: "missing-provider"
|
|
122
|
+
};
|
|
123
|
+
const blockStart = match.index + match[0].length;
|
|
124
|
+
const bodyRe = /\r?\n {0,6}\S/g;
|
|
125
|
+
bodyRe.lastIndex = blockStart;
|
|
126
|
+
const bodyEnd = bodyRe.exec(row)?.index ?? row.length;
|
|
127
|
+
const block = row.slice(blockStart, bodyEnd);
|
|
128
|
+
const idleRe = /^( {8})streamIdleTimeoutMs: *(\d+)(\r?)$/m;
|
|
129
|
+
const idleMatch = idleRe.exec(block);
|
|
130
|
+
if (timeoutMs !== void 0) {
|
|
131
|
+
if (idleMatch !== null) {
|
|
132
|
+
if (Number(idleMatch[2]) === timeoutMs) return {
|
|
133
|
+
text,
|
|
134
|
+
outcome: "unchanged"
|
|
135
|
+
};
|
|
136
|
+
const nextBlock = block.replace(idleRe, `${idleMatch[1]}streamIdleTimeoutMs: ${timeoutMs}${idleMatch[3]}`);
|
|
137
|
+
rows[index] = row.slice(0, blockStart) + nextBlock + row.slice(bodyEnd);
|
|
138
|
+
return {
|
|
139
|
+
text: rows.join(""),
|
|
140
|
+
outcome: "written"
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const nextBlock = `\n streamIdleTimeoutMs: ${timeoutMs}${match[3] === "\r" ? "\r\n" : "\n"}${block.slice(1)}`;
|
|
144
|
+
rows[index] = row.slice(0, blockStart) + nextBlock + row.slice(bodyEnd);
|
|
145
|
+
return {
|
|
146
|
+
text: rows.join(""),
|
|
147
|
+
outcome: "written"
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
if (idleMatch === null) return {
|
|
151
|
+
text,
|
|
152
|
+
outcome: "unchanged"
|
|
153
|
+
};
|
|
154
|
+
const removeRe = /^ {8}streamIdleTimeoutMs: *\d+\r?\n/m;
|
|
155
|
+
const withoutLine = removeRe.test(block) ? block.replace(removeRe, "") : block.replace(idleRe, "");
|
|
156
|
+
rows[index] = row.slice(0, blockStart) + withoutLine + row.slice(bodyEnd);
|
|
157
|
+
return {
|
|
158
|
+
text: rows.join(""),
|
|
159
|
+
outcome: "written"
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Read a provider's current `streamIdleTimeoutMs` from the document.
|
|
164
|
+
*
|
|
165
|
+
* Used to record the pre-overwrite value so a later reset restores it.
|
|
166
|
+
*
|
|
167
|
+
* @param text - the full profile document.
|
|
168
|
+
* @param provider - the pi-ai provider id.
|
|
169
|
+
* @returns the value, or null when the key is absent.
|
|
170
|
+
*/
|
|
171
|
+
function readProviderIdleTimeout(text, provider) {
|
|
172
|
+
const row = text.split(/(?=^- id: )/m).find((candidate) => candidate.startsWith(`- id: llm-pi-ai\n`) || candidate.startsWith(`- id: llm-pi-ai\r\n`));
|
|
173
|
+
if (row === void 0) return null;
|
|
174
|
+
const match = new RegExp(`^ {6}${escapeRegExp(provider)}:\\r?\\n((?: {8}.*\\r?\\n)*)`, "m").exec(row);
|
|
175
|
+
if (match === null) return null;
|
|
176
|
+
const idle = /^ {8}streamIdleTimeoutMs: *(\d+)/m.exec(match[1] ?? "");
|
|
177
|
+
return idle === null ? null : Number(idle[1]);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Build the pi-ai row config with one provider's idle timeout set or removed.
|
|
181
|
+
*
|
|
182
|
+
* Pure: the caller decides whether to hand the result to the loader, and a shape
|
|
183
|
+
* this function does not recognize returns `undefined` instead of a guess.
|
|
184
|
+
*
|
|
185
|
+
* @param config - the row's current config object.
|
|
186
|
+
* @param provider - the pi-ai provider id inside `providers`.
|
|
187
|
+
* @param timeoutMs - the value to set, or undefined to remove the key.
|
|
188
|
+
* @returns the next config, or undefined when the current one is not an object.
|
|
189
|
+
*/
|
|
190
|
+
function planProviderConfig(config, provider, timeoutMs) {
|
|
191
|
+
if (config === null || typeof config !== "object" || Array.isArray(config)) return void 0;
|
|
192
|
+
const base = config;
|
|
193
|
+
const providers = base.providers === null || typeof base.providers !== "object" || Array.isArray(base.providers) ? {} : base.providers;
|
|
194
|
+
const nextProvider = { ...providers[provider] === null || typeof providers[provider] !== "object" || Array.isArray(providers[provider]) ? {} : providers[provider] };
|
|
195
|
+
if (timeoutMs === void 0) delete nextProvider.streamIdleTimeoutMs;
|
|
196
|
+
else nextProvider.streamIdleTimeoutMs = timeoutMs;
|
|
197
|
+
return {
|
|
198
|
+
...base,
|
|
199
|
+
providers: {
|
|
200
|
+
...providers,
|
|
201
|
+
[provider]: nextProvider
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Find the loader row that owns the pi-ai provider profiles.
|
|
207
|
+
*
|
|
208
|
+
* @param loader - the Host loader service, when present.
|
|
209
|
+
* @returns the row entry, or undefined when the profile does not load it.
|
|
210
|
+
*/
|
|
211
|
+
function findPiAiEntry(loader) {
|
|
212
|
+
if (loader === void 0 || typeof loader.entries !== "function") return void 0;
|
|
213
|
+
for (const entry of loader.entries()) if (entry.options?.name === PI_AI_PACKAGE || entry.id === "llm-pi-ai") return entry;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Reload the pi-ai row so a changed timeout applies without a Host restart.
|
|
217
|
+
*
|
|
218
|
+
* The document write already happened; this is the runtime half. One reload
|
|
219
|
+
* carries every provider that changed. A reload aborts the provider's in-flight
|
|
220
|
+
* calls, which is why it only runs on an actual value change.
|
|
221
|
+
*
|
|
222
|
+
* @param loader - the Host loader service.
|
|
223
|
+
* @param log - row logger for the one-line report.
|
|
224
|
+
* @param providers - providers whose `streamIdleTimeoutMs` the document write changed.
|
|
225
|
+
* @param timeoutMs - the value the document now carries, or undefined for a reset.
|
|
226
|
+
*/
|
|
227
|
+
async function pushHotTimeout(loader, log, providers, timeoutMs) {
|
|
228
|
+
const entry = findPiAiEntry(loader);
|
|
229
|
+
if (entry === void 0) {
|
|
230
|
+
reviewTimeoutStatus.hot = "restart-required";
|
|
231
|
+
reviewTimeoutStatus.hotReason = "the pi-ai row is not loaded";
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
let config = entry.options?.config;
|
|
235
|
+
for (const provider of providers) {
|
|
236
|
+
const next = planProviderConfig(config, provider, timeoutMs);
|
|
237
|
+
if (next === void 0) {
|
|
238
|
+
reviewTimeoutStatus.hot = "restart-required";
|
|
239
|
+
reviewTimeoutStatus.hotReason = "the pi-ai row config is not an object";
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
config = next;
|
|
243
|
+
}
|
|
244
|
+
const result = await applyFiberConfig(entry, config);
|
|
245
|
+
const label = timeoutMs === void 0 ? "reset (provider defaults restored)" : `${timeoutMs}ms`;
|
|
246
|
+
if (result.outcome === "updated") {
|
|
247
|
+
reviewTimeoutStatus.hot = "applied";
|
|
248
|
+
reviewTimeoutStatus.hotReason = void 0;
|
|
249
|
+
for (const provider of providers) if (!reviewTimeoutStatus.hotApplied.includes(provider)) reviewTimeoutStatus.hotApplied.push(provider);
|
|
250
|
+
log.info(`model-switch: reloaded ${PI_AI_ROW} so the review timeout (${label}) applies now to [${providers.join(", ")}]; its in-flight calls were dropped`);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
reviewTimeoutStatus.hot = "restart-required";
|
|
254
|
+
reviewTimeoutStatus.hotReason = result.outcome === "failed" ? result.error ?? "reload failed" : result.outcome === "no-fiber" ? "the pi-ai row has no live instance" : "the pi-ai row is mid-transition";
|
|
255
|
+
if (result.outcome === "failed") log.warn(`model-switch: the pi-ai reload for the review timeout failed (${reviewTimeoutStatus.hotReason}); the value applies after a Host restart`);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Row entry point: apply the configured timeout to the reviewer providers'
|
|
259
|
+
* pi-ai profiles in the profile document.
|
|
260
|
+
*
|
|
261
|
+
* Every failure is contained and logged; a broken document must never take the
|
|
262
|
+
* Host down. The write is idempotent: replays find the value already in place
|
|
263
|
+
* and do nothing.
|
|
264
|
+
*
|
|
265
|
+
* @param ctx - this row's context.
|
|
266
|
+
*/
|
|
267
|
+
function apply(outer) {
|
|
268
|
+
outer.inject(["modelSwitch"], (ctx) => {
|
|
269
|
+
const runtime = ctx.modelSwitch;
|
|
270
|
+
const log = ctx.logger;
|
|
271
|
+
const execute = async () => {
|
|
272
|
+
reviewTimeoutStatus.configuredMs = void 0;
|
|
273
|
+
reviewTimeoutStatus.applied = [];
|
|
274
|
+
reviewTimeoutStatus.skipped = [];
|
|
275
|
+
reviewTimeoutStatus.hotApplied = [];
|
|
276
|
+
reviewTimeoutStatus.hot = void 0;
|
|
277
|
+
reviewTimeoutStatus.hotReason = void 0;
|
|
278
|
+
const settings = runtime.currentSettings();
|
|
279
|
+
const plan = planReviewTimeout(settings);
|
|
280
|
+
reviewTimeoutStatus.configuredMs = settings.autoReviewTimeoutMs;
|
|
281
|
+
if (plan.providers.length === 0) return;
|
|
282
|
+
const forms = ctx.get("settings", true);
|
|
283
|
+
const documentPath = forms?.documentPath;
|
|
284
|
+
if (forms === void 0 || typeof documentPath !== "string" || documentPath === "") {
|
|
285
|
+
reviewTimeoutStatus.skipped.push(...plan.providers);
|
|
286
|
+
log.warn("model-switch: no profile document is reachable; the review timeout write is skipped");
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
try {
|
|
290
|
+
const { readFile, writeFile } = await import("node:fs/promises");
|
|
291
|
+
let text = await readFile(documentPath, "utf8");
|
|
292
|
+
let changed = false;
|
|
293
|
+
const changedProviders = [];
|
|
294
|
+
for (const provider of plan.providers) {
|
|
295
|
+
const patched = patchProviderIdleTimeout(text, provider, plan.timeoutMs);
|
|
296
|
+
if (patched.outcome === "written") {
|
|
297
|
+
text = patched.text;
|
|
298
|
+
changed = true;
|
|
299
|
+
changedProviders.push(provider);
|
|
300
|
+
}
|
|
301
|
+
if (patched.outcome === "written" || patched.outcome === "unchanged") reviewTimeoutStatus.applied.push(provider);
|
|
302
|
+
else reviewTimeoutStatus.skipped.push(provider);
|
|
303
|
+
}
|
|
304
|
+
if (changed) await writeFile(documentPath, text, "utf8");
|
|
305
|
+
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(", ")}]`);
|
|
306
|
+
if (changedProviders.length > 0) pushHotTimeout(ctx.get("loader", false), log, changedProviders, plan.timeoutMs);
|
|
307
|
+
} catch (cause) {
|
|
308
|
+
log.warn(`model-switch: the review timeout write failed (${String(cause)})`);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
let pending;
|
|
312
|
+
const run = () => {
|
|
313
|
+
if (pending !== void 0) return pending;
|
|
314
|
+
const next = execute().finally(() => {
|
|
315
|
+
if (pending === next) pending = void 0;
|
|
316
|
+
});
|
|
317
|
+
pending = next;
|
|
318
|
+
return next;
|
|
319
|
+
};
|
|
320
|
+
run();
|
|
321
|
+
const lateSweep = setTimeout(() => {
|
|
322
|
+
run();
|
|
323
|
+
}, 1500);
|
|
324
|
+
const offService = ctx.on("internal/service", (name) => {
|
|
325
|
+
if (name === "settings") run();
|
|
326
|
+
});
|
|
327
|
+
ctx.effect(function* () {
|
|
328
|
+
yield () => {
|
|
329
|
+
offService();
|
|
330
|
+
clearTimeout(lateSweep);
|
|
331
|
+
};
|
|
332
|
+
yield ctx.on("model-switch/settings-update", () => {
|
|
333
|
+
run();
|
|
334
|
+
});
|
|
335
|
+
}, "model-switch: keep the review timeout write aligned with the settings");
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
//#endregion
|
|
339
|
+
export { name as a, planReviewTimeout as c, inject as i, readProviderIdleTimeout as l, apply as n, patchProviderIdleTimeout as o, findPiAiEntry as r, planProviderConfig as s, PI_AI_ROW as t, reviewTimeoutStatus as u };
|
package/lib/review-timeout.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as name, c as planReviewTimeout, i as inject, l as readProviderIdleTimeout, n as apply, o as patchProviderIdleTimeout, r as findPiAiEntry, s as planProviderConfig, t as PI_AI_ROW, u as reviewTimeoutStatus } from "./review-timeout-
|
|
1
|
+
import { a as name, c as planReviewTimeout, i as inject, l as readProviderIdleTimeout, n as apply, o as patchProviderIdleTimeout, r as findPiAiEntry, s as planProviderConfig, t as PI_AI_ROW, u as reviewTimeoutStatus } from "./review-timeout-CAlD65wl.js";
|
|
2
2
|
export { PI_AI_ROW, apply, findPiAiEntry, inject, name, patchProviderIdleTimeout, planProviderConfig, planReviewTimeout, readProviderIdleTimeout, reviewTimeoutStatus };
|