dsh-model-switch 0.4.48 → 0.4.51

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.
@@ -1,2 +1,2 @@
1
- import { a as bindAutoReviewSessionCorrelation, c as installToolCallSafetyNet, d as resolveSessionAutoReviewRoute, f as reviewLlm, i as autoReviewStatus, l as isReviewerInfrastructureFailure, n as autoReviewGate, o as defensivePermissionPresets, p as reviewScope, r as autoReviewRouteOf, s as inject, t as apply, u as name } from "./auto-review-BbfitRtw.js";
1
+ import { a as bindAutoReviewSessionCorrelation, c as installToolCallSafetyNet, d as resolveSessionAutoReviewRoute, f as reviewLlm, i as autoReviewStatus, l as isReviewerInfrastructureFailure, n as autoReviewGate, o as defensivePermissionPresets, p as reviewScope, r as autoReviewRouteOf, s as inject, t as apply, u as name } from "./auto-review-uu9lvAIZ.js";
2
2
  export { apply, autoReviewGate, autoReviewRouteOf, autoReviewStatus, bindAutoReviewSessionCorrelation, defensivePermissionPresets, inject, installToolCallSafetyNet, isReviewerInfrastructureFailure, name, resolveSessionAutoReviewRoute, reviewLlm, reviewScope };
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: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
2606
- className: ModelSwitchSettings_module_css_default.groupLabel,
2607
- children: props.t("reviewAllowlistGroup")
2608
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(RouteCard, {
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
- children: [
2630
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2631
- className: ModelSwitchSettings_module_css_default.hint,
2632
- children: props.t("reviewAllowlistNote")
2633
- }),
2634
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2635
- className: ModelSwitchSettings_module_css_default.allowToolbar,
2636
- children: [
2637
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2638
- className: ModelSwitchSettings_module_css_default.input,
2639
- type: "search",
2640
- value: allowlistQuery,
2641
- placeholder: props.t("reviewAllowlistSearch"),
2642
- onChange: (event) => {
2643
- setAllowlistQuery(event.target.value);
2644
- }
2645
- }),
2646
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2647
- type: "button",
2648
- className: cx(ModelSwitchSettings_module_css_default.button, ModelSwitchSettings_module_css_default.secondaryButton),
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
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
2680
- className: ModelSwitchSettings_module_css_default.allowList,
2681
- children: allowlistIncluded.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
2682
- className: ModelSwitchSettings_module_css_default.allowRow,
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.jsxs)("label", {
2685
- className: ModelSwitchSettings_module_css_default.allowLabel,
2686
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2687
- type: "checkbox",
2688
- checked: true,
2689
- readOnly: true
2690
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
2691
- className: ModelSwitchSettings_module_css_default.allowName,
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 || !allowlistWritable,
2712
- onClick: () => {
2713
- setAllowTool(row.entry, false);
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
- setAllowTool(row.name, true);
2685
+ persistAllowlist({
2686
+ enabled: allowlistEnabled,
2687
+ tools: [...DEFAULT_READ_ONLY_TOOLS]
2688
+ });
2762
2689
  },
2763
- children: props.t("reviewAllowlistAdd")
2690
+ children: props.t("reviewAllowlistReset")
2764
2691
  })
2765
2692
  ]
2766
- }, row.name))
2767
- })] }),
2768
- catalogState === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2769
- className: cx(ModelSwitchSettings_module_css_default.hint, ModelSwitchSettings_module_css_default.message),
2770
- children: props.t("reviewAllowlistScanFailed")
2771
- }) : null
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
@@ -1,6 +1,6 @@
1
1
  import { s as normalizeProviderGroups } from "./session-route-D8izd8Zd.js";
2
2
  import { r as resolveToolSource, t as DEFAULT_READ_ONLY_TOOLS } from "./tool-allowlist-DlzB5GlQ.js";
3
- import { i as autoReviewStatus } from "./auto-review-BbfitRtw.js";
3
+ import { i as autoReviewStatus } from "./auto-review-uu9lvAIZ.js";
4
4
  import { ModelSwitchAdapterRegistry } from "./adapter-registry.js";
5
5
  import { automodeCompatView } from "./automode-compat.js";
6
6
  import { createRequire } from "node:module";
@@ -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 },
@@ -262,6 +262,40 @@ function planPrimeMemoryRoute(config, route, adoptedRoute) {
262
262
  /** The endpoint the memory plugin registers for its own runtime settings writes. */
263
263
  const MEMORY_RPC_PATH = "/dsh-memory/rpc/settings-set";
264
264
  /**
265
+ * Whether the memory row's live section already carries exactly our route.
266
+ *
267
+ * The RPC write path persists the live section to the profile document on every
268
+ * call, and a document change reloads the composition — so pushing an unchanged
269
+ * route re-triggers this adapter forever (a ~6 s recompose loop, observed with
270
+ * `dsh-prime-memory@0.26.10`). Comparing first is what makes the push idempotent
271
+ * across reloads.
272
+ *
273
+ * @param value - the memory row's live settings object, as the forms describe it.
274
+ * @param provider - route provider to compare against.
275
+ * @param model - route model to compare against.
276
+ * @returns true when a push would change nothing.
277
+ */
278
+ function memoryLiveMatchesRoute(value, provider, model) {
279
+ if (value === null || typeof value !== "object") return false;
280
+ const live = value;
281
+ if (live.distillProvider !== provider || live.distillModel !== model) return false;
282
+ const chain = live.distillChain;
283
+ if (Array.isArray(chain) && chain.length !== 0) return false;
284
+ const layers = live.distillLayerChains;
285
+ if (layers === null || typeof layers !== "object") return false;
286
+ for (const key of [
287
+ "l1",
288
+ "l2",
289
+ "l3"
290
+ ]) {
291
+ const layer = layers[key];
292
+ if (!Array.isArray(layer) || layer.length !== 1) return false;
293
+ const first = layer[0];
294
+ if (first === void 0 || first.provider !== provider || first.model !== model) return false;
295
+ }
296
+ return true;
297
+ }
298
+ /**
265
299
  * Hand the route to the memory plugin through the RPC it registers for its own
266
300
  * settings page.
267
301
  *
@@ -280,10 +314,7 @@ async function pushMemoryRoute(ctx, route) {
280
314
  method: "POST",
281
315
  headers: { "content-type": "application/json" },
282
316
  body: JSON.stringify({
283
- distillChain: [{
284
- provider: route.provider,
285
- model: route.model
286
- }],
317
+ distillChain: [],
287
318
  distillLayerChains: {
288
319
  l1: [{
289
320
  provider: route.provider,
@@ -298,8 +329,8 @@ async function pushMemoryRoute(ctx, route) {
298
329
  model: route.model
299
330
  }]
300
331
  },
301
- distillProvider: "",
302
- distillModel: "",
332
+ distillProvider: route.provider,
333
+ distillModel: route.model,
303
334
  reasoningEffort: ""
304
335
  })
305
336
  });
@@ -392,6 +423,13 @@ function installPrimeMemoryCompat(ctx, loader, routeOf) {
392
423
  return;
393
424
  }
394
425
  const wanted = `${provider}/${model}`;
426
+ if (memoryLiveMatchesRoute(sectionOf(forms)?.value, provider, model)) {
427
+ adoptedRoute = wanted;
428
+ primeMemoryCompatStatus.installed = true;
429
+ primeMemoryCompatStatus.route = wanted;
430
+ delete primeMemoryCompatStatus.routeSkipped;
431
+ return;
432
+ }
395
433
  const pushed = await pushMemoryRoute(ctx, {
396
434
  provider,
397
435
  model
@@ -402,13 +440,13 @@ function installPrimeMemoryCompat(ctx, loader, routeOf) {
402
440
  primeMemoryCompatStatus.route = wanted;
403
441
  delete primeMemoryCompatStatus.routeSkipped;
404
442
  }
443
+ if (pushed === "pushed") return;
405
444
  const documentPath = forms.documentPath;
406
445
  if (typeof documentPath === "string" && documentPath !== "") try {
407
446
  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
447
  } catch (cause) {
409
448
  ctx.logger.warn(`model-switch: could not pin the dsh-prime-memory route (${String(cause)})`);
410
449
  }
411
- if (pushed === "pushed") return;
412
450
  const section = sectionOf(forms);
413
451
  if (section === void 0 || asRecord(section.value) === void 0) {
414
452
  scheduleRetry();
@@ -492,4 +530,4 @@ function apply(ctx) {
492
530
  }, "model-switch: keep the dsh-prime-memory route aligned with the settings");
493
531
  }
494
532
  //#endregion
495
- export { apply, chainOf, inject, installPrimeMemoryCompat, name, planPrimeMemoryRoute, primeMemoryCompatStatus };
533
+ export { apply, chainOf, inject, installPrimeMemoryCompat, memoryLiveMatchesRoute, name, planPrimeMemoryRoute, primeMemoryCompatStatus, pushMemoryRoute };