dsh-model-switch 0.4.47 → 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/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 },
@@ -639,19 +643,98 @@ function installDeepSeekSearchAdapter(ctx) {
639
643
  //#endregion
640
644
  //#region lib/types/compatibility.js
641
645
  /**
646
+ * Parse a dotted DSH version, tolerating a prerelease suffix.
647
+ * @param version - the raw version text.
648
+ * @returns the parsed parts, or undefined when the shape is unknown.
649
+ */
650
+ function parseVersion(version) {
651
+ const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(version.trim());
652
+ if (match === null) return void 0;
653
+ return {
654
+ base: [
655
+ Number(match[1]),
656
+ Number(match[2]),
657
+ Number(match[3])
658
+ ],
659
+ pre: match[4] === void 0 ? [] : match[4].split(".")
660
+ };
661
+ }
662
+ /** Semver prerelease ordering for one identifier pair. */
663
+ function compareIdentifier(left, right) {
664
+ const leftNumeric = /^\d+$/.test(left);
665
+ const rightNumeric = /^\d+$/.test(right);
666
+ if (leftNumeric && rightNumeric) return Number(left) - Number(right);
667
+ if (leftNumeric) return -1;
668
+ if (rightNumeric) return 1;
669
+ return left < right ? -1 : left > right ? 1 : 0;
670
+ }
671
+ /**
672
+ * Order two DSH versions with prerelease semantics (`rc.2 < rc.3 < release`).
673
+ * @param left - first version.
674
+ * @param right - second version.
675
+ * @returns -1/0/1, or undefined when either side is unparsable.
676
+ */
677
+ function compareDshVersions(left, right) {
678
+ const a = parseVersion(left);
679
+ const b = parseVersion(right);
680
+ if (a === void 0 || b === void 0) return void 0;
681
+ for (let index = 0; index < 3; index += 1) {
682
+ const difference = a.base[index] - b.base[index];
683
+ if (difference !== 0) return difference < 0 ? -1 : 1;
684
+ }
685
+ if (a.pre.length === 0 && b.pre.length === 0) return 0;
686
+ if (a.pre.length === 0) return 1;
687
+ if (b.pre.length === 0) return -1;
688
+ const shared = Math.min(a.pre.length, b.pre.length);
689
+ for (let index = 0; index < shared; index += 1) {
690
+ const difference = compareIdentifier(a.pre[index], b.pre[index]);
691
+ if (difference !== 0) return difference < 0 ? -1 : 1;
692
+ }
693
+ if (a.pre.length === b.pre.length) return 0;
694
+ return a.pre.length < b.pre.length ? -1 : 1;
695
+ }
696
+ /**
697
+ * Read the floor out of a declared runtime range.
698
+ *
699
+ * Only the open-ended `>=x.y.z` form is understood: the declaration promises
700
+ * "this release and everything after it", so a bounded range is a different
701
+ * statement and is ignored rather than half-honoured.
702
+ *
703
+ * @param range - the declared range text.
704
+ * @returns the floor version, or undefined when absent/misunderstood.
705
+ */
706
+ function runtimeFloorOf(range) {
707
+ if (typeof range !== "string") return void 0;
708
+ const match = /^\s*>=\s*([0-9A-Za-z.-]+)\s*$/.exec(range);
709
+ return match === null ? void 0 : match[1];
710
+ }
711
+ /**
642
712
  * Classify one runtime without treating the verified table as an allowlist.
713
+ *
714
+ * Precedence: a blocked version wins over everything; a version named in the
715
+ * evidence table is verified; otherwise a declared `dshRuntime` floor marks every
716
+ * runtime at or above it verified. Anything else stays unverified, and the mount
717
+ * path remains fail-open for it.
718
+ *
643
719
  * @param version - Resolved DSH runtime version.
644
720
  * @param verified - Releases with direct compatibility evidence.
645
721
  * @param blocklist - Versions excluded after reproduced failures.
722
+ * @param runtimeRange - Declared open-ended floor (`>=x.y.z`).
646
723
  * @returns The fail-open mount decision.
647
724
  */
648
- function classifyDshRuntime(version, verified, blocklist = {}) {
725
+ function classifyDshRuntime(version, verified, blocklist = {}, runtimeRange) {
649
726
  const reason = blocklist[version];
650
727
  if (typeof reason === "string" && reason.trim() !== "") return {
651
728
  kind: "blocked",
652
729
  reason
653
730
  };
654
- return verified.has(version) ? { kind: "verified" } : { kind: "unverified" };
731
+ if (verified.has(version)) return { kind: "verified" };
732
+ const floor = runtimeFloorOf(runtimeRange);
733
+ if (floor !== void 0) {
734
+ const order = compareDshVersions(version, floor);
735
+ if (order !== void 0 && order >= 0) return { kind: "verified" };
736
+ }
737
+ return { kind: "unverified" };
655
738
  }
656
739
  /**
657
740
  * Apply the fail-open decision and emit at most one visible warning.
@@ -660,10 +743,11 @@ function classifyDshRuntime(version, verified, blocklist = {}) {
660
743
  * @param version - Resolved DSH runtime version.
661
744
  * @param verified - Releases with direct compatibility evidence.
662
745
  * @param blocklist - Versions excluded after reproduced failures.
746
+ * @param runtimeRange - Declared open-ended floor (`>=x.y.z`).
663
747
  * @returns Whether the host mount should continue.
664
748
  */
665
- function shouldMountDshRuntime(logger, pluginName, version, verified, blocklist = {}) {
666
- const decision = classifyDshRuntime(version, verified, blocklist);
749
+ function shouldMountDshRuntime(logger, pluginName, version, verified, blocklist = {}, runtimeRange) {
750
+ const decision = classifyDshRuntime(version, verified, blocklist, runtimeRange);
667
751
  if (decision.kind === "blocked") {
668
752
  logger.warn(`[${pluginName}] blocked on DSH ${version}: ${decision.reason}; see package.json#dsh.compatibility.blocklist`);
669
753
  return false;
@@ -705,7 +789,7 @@ function packageVersion(packageName) {
705
789
  function allowDshRuntime(logger, pluginName, candidates) {
706
790
  const version = process.env.DSH_VERSION?.trim() || candidates.map(packageVersion).find((value) => value !== void 0) || "unknown";
707
791
  const compatibility = readManifest().dsh?.compatibility;
708
- return shouldMountDshRuntime(logger, pluginName, version, new Set(Object.entries(compatibility?.dshReleases ?? {}).filter(([, status]) => status === "compatible" || status === "verified").map(([release]) => release)), compatibility?.blocklist);
792
+ return shouldMountDshRuntime(logger, pluginName, version, new Set(Object.entries(compatibility?.dshReleases ?? {}).filter(([, status]) => status === "compatible" || status === "verified").map(([release]) => release)), compatibility?.blocklist, compatibility?.dshRuntime);
709
793
  }
710
794
  //#endregion
711
795
  //#region lib/types/preset-sync.js
@@ -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;
@@ -1,6 +1,24 @@
1
1
  interface CompatibilityLogger {
2
2
  warn(message: string): void;
3
3
  }
4
+ /**
5
+ * Order two DSH versions with prerelease semantics (`rc.2 < rc.3 < release`).
6
+ * @param left - first version.
7
+ * @param right - second version.
8
+ * @returns -1/0/1, or undefined when either side is unparsable.
9
+ */
10
+ export declare function compareDshVersions(left: string, right: string): number | undefined;
11
+ /**
12
+ * Read the floor out of a declared runtime range.
13
+ *
14
+ * Only the open-ended `>=x.y.z` form is understood: the declaration promises
15
+ * "this release and everything after it", so a bounded range is a different
16
+ * statement and is ignored rather than half-honoured.
17
+ *
18
+ * @param range - the declared range text.
19
+ * @returns the floor version, or undefined when absent/misunderstood.
20
+ */
21
+ export declare function runtimeFloorOf(range: unknown): string | undefined;
4
22
  export type DshRuntimeClassification = {
5
23
  kind: 'verified';
6
24
  } | {
@@ -11,12 +29,19 @@ export type DshRuntimeClassification = {
11
29
  };
12
30
  /**
13
31
  * Classify one runtime without treating the verified table as an allowlist.
32
+ *
33
+ * Precedence: a blocked version wins over everything; a version named in the
34
+ * evidence table is verified; otherwise a declared `dshRuntime` floor marks every
35
+ * runtime at or above it verified. Anything else stays unverified, and the mount
36
+ * path remains fail-open for it.
37
+ *
14
38
  * @param version - Resolved DSH runtime version.
15
39
  * @param verified - Releases with direct compatibility evidence.
16
40
  * @param blocklist - Versions excluded after reproduced failures.
41
+ * @param runtimeRange - Declared open-ended floor (`>=x.y.z`).
17
42
  * @returns The fail-open mount decision.
18
43
  */
19
- export declare function classifyDshRuntime(version: string, verified: ReadonlySet<string>, blocklist?: Readonly<Record<string, unknown>>): DshRuntimeClassification;
44
+ export declare function classifyDshRuntime(version: string, verified: ReadonlySet<string>, blocklist?: Readonly<Record<string, unknown>>, runtimeRange?: unknown): DshRuntimeClassification;
20
45
  /**
21
46
  * Apply the fail-open decision and emit at most one visible warning.
22
47
  * @param logger - Host logger receiving compatibility warnings.
@@ -24,9 +49,10 @@ export declare function classifyDshRuntime(version: string, verified: ReadonlySe
24
49
  * @param version - Resolved DSH runtime version.
25
50
  * @param verified - Releases with direct compatibility evidence.
26
51
  * @param blocklist - Versions excluded after reproduced failures.
52
+ * @param runtimeRange - Declared open-ended floor (`>=x.y.z`).
27
53
  * @returns Whether the host mount should continue.
28
54
  */
29
- export declare function shouldMountDshRuntime(logger: CompatibilityLogger, pluginName: string, version: string, verified: ReadonlySet<string>, blocklist?: Readonly<Record<string, unknown>>): boolean;
55
+ export declare function shouldMountDshRuntime(logger: CompatibilityLogger, pluginName: string, version: string, verified: ReadonlySet<string>, blocklist?: Readonly<Record<string, unknown>>, runtimeRange?: unknown): boolean;
30
56
  /**
31
57
  * Warn once for an unknown runtime while keeping the normal host mount path.
32
58
  * @param logger - Host logger receiving compatibility warnings.
@@ -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
  *