dsh-session-guard 4.4.2 → 4.4.3

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/CHANGELOG.pt.md +196 -196
  3. package/INSTALL.pt.md +120 -120
  4. package/README.pt.md +377 -377
  5. package/dsh.plugin.json +1 -1
  6. package/lib/client.js +397 -181
  7. package/lib/client.js.map +1 -1
  8. package/locale/de.json +6 -6
  9. package/locale/en.json +6 -6
  10. package/locale/es.json +6 -6
  11. package/locale/fr.json +6 -6
  12. package/locale/it.json +6 -6
  13. package/locale/ja.json +6 -6
  14. package/locale/ko.json +6 -6
  15. package/locale/pt.json +6 -6
  16. package/locale/ru.json +6 -6
  17. package/locale/zh.json +6 -6
  18. package/package.json +129 -129
  19. package/src/bridge.js +190 -190
  20. package/src/client/badge-text.ts +49 -49
  21. package/src/client/family-section.tsx +79 -79
  22. package/src/client/locales.ts +400 -400
  23. package/src/client/pause-button-text.ts +76 -76
  24. package/src/client/pause-button.tsx +129 -129
  25. package/src/client/scope-face.ts +20 -20
  26. package/src/client/settings-bridge.ts +202 -202
  27. package/src/client/settings-card.tsx +4 -0
  28. package/src/client/star-row-copy.ts +256 -0
  29. package/src/client/status-badge.tsx +76 -76
  30. package/src/client/styles.ts +30 -30
  31. package/src/deferrals.js +197 -197
  32. package/src/holiday-store.js +196 -196
  33. package/src/holidays.js +215 -215
  34. package/src/pause-gate.js +544 -544
  35. package/src/provider-directory.js +101 -101
  36. package/src/provider.js +139 -139
  37. package/src/retry.js +227 -227
  38. package/src/settings-bridge.js +141 -141
  39. package/src/settings.js +98 -98
  40. package/src/step-gate.js +411 -411
  41. package/src/targets.js +70 -70
  42. package/src/time.js +216 -216
  43. package/src/tool-call-id.js +48 -48
  44. package/src/wiring.js +308 -308
package/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-session-guard",
3
- "version": "4.4.2",
3
+ "version": "4.4.3",
4
4
  "main": "./src/index.js",
5
5
  "description": "高峰自动会话门:step 级门控 + 周末模式 + 高峰自动暂停 + 官方源二维判定 + 会话级冻结 + 后端自动重试。",
6
6
  "engines": {
package/lib/client.js CHANGED
@@ -594,6 +594,216 @@ window.__ModuleLoader__.load({
594
594
  });
595
595
  }
596
596
  //#endregion
597
+ //#region src/client/star-row-copy.ts
598
+ /**
599
+ * star-row 真源(面板 star 快车道行,v1)——纯 DOM 实现,零依赖。
600
+ *
601
+ * 副本约束:生成文件名 star-row-copy.ts,头部须保留 /** 块注释,单行 ≤140
602
+ * 字宽(sidebar-fold 仓 lint 门禁:max-line + file-header)。
603
+ *
604
+ * 契约(对齐 panel-star-row spec):
605
+ * - 渲染一行 <a>:GitHub 单色 SVG + `owner/name`;variant A 追加一句工程话术;
606
+ * - 整行即链接(A/L 档),新标签页打开;不做弹窗、不做按钮交互;
607
+ * - 文案内嵌 10 语,按 `document.documentElement.lang` 前缀自选
608
+ * (同 sidebar-fold `pickDictionary` 口径),不依赖宿主 locale 服务,
609
+ * 避免逐仓动字典文件;
610
+ * - 样式一次性注入 <style data-dsh-star-row>,色随 currentColor,深浅主题自适应;
611
+ * - 副本由 _tools/star-row/sync.mjs 生成到各仓 `src/client/star-row-copy.ts`
612
+ * (文件名含 copy,locale 守卫豁免规则命中),改副本无效,改真源后重跑 sync。
613
+ *
614
+ * 每仓生成时在文件头部烘焙 REPO_URL / STAR_NS / STAR_VARIANT 三个常量。
615
+ */
616
+ /** 生成段:REPO_URL / STAR_NS / STAR_VARIANT 由 sync 注入。 */
617
+ const REPO_URL = "https://github.com/drscrewdriver/dsh-session-guard";
618
+ const STAR_NS = "session-guard";
619
+ /** zh 为键集真理源;10 语与 sidebar-fold/manage-session 同集合。 */
620
+ const STAR_COPY = {
621
+ zh: { ask: "觉得省事了?一颗 Star 让工具被更多人看见" },
622
+ en: { ask: "Finding it handy? A star helps more people discover this tool" },
623
+ ja: { ask: "便利でしたら⭐で、このツールがもっと届きます" },
624
+ ko: { ask: "유용했다면 ⭐ 하나로 더 많은 사용자에게 닿습니다" },
625
+ fr: { ask: "Utile ? Une étoile aide cet outil à être découvert" },
626
+ de: { ask: "Nützlich? Ein Stern hilft dem Tool, gesehen zu werden" },
627
+ it: { ask: "Ti è utile? Una stella aiuta questo tool a farsi scoprire" },
628
+ ru: { ask: "Пригодилось? Звезда поможет большему числу людей узнать о tool" },
629
+ es: { ask: "¿Te resulta útil? Una estrella ayuda a que más gente lo descubra" },
630
+ pt: { ask: "Achou útil? Uma estrela ajuda mais pessoas a descobrir a ferramenta" }
631
+ };
632
+ const STAR_LANGS = [
633
+ "zh",
634
+ "en",
635
+ "ja",
636
+ "ko",
637
+ "fr",
638
+ "de",
639
+ "it",
640
+ "ru",
641
+ "es",
642
+ "pt"
643
+ ];
644
+ /** GitHub mark(Simple Icons / octicon 轮廓,24 视口),fill 随 currentColor。 */
645
+ const GITHUB_MARK_PATH = "M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332 -5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12";
646
+ const STYLE_ID = "dsh-star-row-style";
647
+ const STYLE_CSS = [
648
+ ".dsh-star-row{display:flex;align-items:center;gap:7px;font-size:12px;",
649
+ "line-height:1.5;color:inherit;text-decoration:none;opacity:.72;padding:3px 0;",
650
+ "margin-top:6px;min-width:0;flex-wrap:wrap}",
651
+ ".dsh-star-row:hover{opacity:1;text-decoration:underline}",
652
+ ".dsh-star-row svg{width:14px;height:14px;flex:none;display:block}",
653
+ ".dsh-star-row .dsh-star-ask{opacity:.85;font-weight:400}"
654
+ ].join("");
655
+ const STAR_CTA = {
656
+ zh: "留颗 Star",
657
+ en: "Star",
658
+ ja: "スター",
659
+ ko: "스타",
660
+ fr: "Star",
661
+ de: "Stern",
662
+ it: "Stella",
663
+ ru: "Звезда",
664
+ es: "Estrella",
665
+ pt: "Estrela"
666
+ };
667
+ /** 隐藏钮的可读名(★ 之外的独立动作,10 语同集)。 */
668
+ const STAR_HIDE = {
669
+ zh: "不再提示",
670
+ en: "Dismiss",
671
+ ja: "今後表示しない",
672
+ ko: "다시 보지 않기",
673
+ fr: "Masquer",
674
+ de: "Ausblenden",
675
+ it: "Nascondi",
676
+ ru: "Скрыть",
677
+ es: "Ocultar",
678
+ pt: "Ocultar"
679
+ };
680
+ const STAR_S_STYLE_ID = "dsh-star-row-s-style";
681
+ const STAR_S_STYLE = [
682
+ ".dsh-star-row-s{display:flex;align-items:center;gap:8px;flex-wrap:wrap;",
683
+ "font-size:12px;line-height:1.5;color:inherit;opacity:.75;margin-top:10px;",
684
+ "padding-top:8px;border-top:1px solid var(--dsw-alias-border-l2,currentColor)}",
685
+ ".dsh-star-row-s:hover{opacity:1}",
686
+ ".dsh-star-link{display:inline-flex;align-items:center;gap:6px;",
687
+ "color:inherit;text-decoration:none}",
688
+ ".dsh-star-link:hover{text-decoration:underline}",
689
+ ".dsh-star-link svg{width:14px;height:14px;flex:none;display:block}",
690
+ ".dsh-star-row-s .dsh-star-ask{opacity:.85;font-weight:400}",
691
+ ".dsh-star-cta,.dsh-star-hide{font:inherit;font-size:11px;line-height:1;",
692
+ "padding:4px 9px;border-radius:999px;border:1px solid currentColor;",
693
+ "background:transparent;color:inherit;cursor:pointer;flex:none;opacity:.7}",
694
+ ".dsh-star-hide{padding:4px 7px}",
695
+ ".dsh-star-cta:hover,.dsh-star-hide:hover{opacity:1}"
696
+ ].join("");
697
+ /** 宿主语言标签归一:取 `documentElement.lang` 的前缀,命中 STAR_LANGS 即用。 */
698
+ function starLang() {
699
+ const low = (typeof document !== "undefined" && document.documentElement.lang || "").toLowerCase();
700
+ for (const cand of STAR_LANGS) if (low.startsWith(cand)) return cand;
701
+ return "en";
702
+ }
703
+ /** 是否已被用户点掉话术(隐私模式下读失败按未关闭处理,只影响本次会话)。 */
704
+ function starDismissed() {
705
+ try {
706
+ return localStorage.getItem("dsh.star." + STAR_NS + ".dismissed") === "1";
707
+ } catch {
708
+ return false;
709
+ }
710
+ }
711
+ /** 记住关闭态(隐私模式写失败不报错,话术本次隐藏、刷新复活)。 */
712
+ function starDismiss() {
713
+ try {
714
+ localStorage.setItem("dsh.star." + STAR_NS + ".dismissed", "1");
715
+ } catch {}
716
+ }
717
+ /** 一次性注入 S 档样式。 */
718
+ function injectStarSStyle(d) {
719
+ if (d.getElementById(STAR_S_STYLE_ID)) return;
720
+ const style = d.createElement("style");
721
+ style.id = STAR_S_STYLE_ID;
722
+ style.textContent = STAR_S_STYLE;
723
+ d.head.appendChild(style);
724
+ }
725
+ /** 打开仓库页:桌面壳里 window.open 可能被拦,锚点 click 才是两条路径都通的写法。 */
726
+ function openRepo(d) {
727
+ const a = d.createElement("a");
728
+ a.href = REPO_URL;
729
+ a.target = "_blank";
730
+ a.rel = "noopener noreferrer";
731
+ a.click();
732
+ }
733
+ /** S 档扩充:把裸链接行升级成「链接 | 话术 | ★ CTA | × 隐藏」,非 S 档返回 null 走原路径。 */
734
+ function extendedStarRow(link, d) {
735
+ if (starDismissed()) return link;
736
+ injectStarSStyle(d);
737
+ link.className = "dsh-star-link";
738
+ const lang = starLang();
739
+ const row = d.createElement("div");
740
+ row.className = "dsh-star-row-s";
741
+ row.appendChild(link);
742
+ const ask = d.createElement("span");
743
+ ask.className = "dsh-star-ask";
744
+ ask.textContent = STAR_COPY[lang].ask;
745
+ row.appendChild(ask);
746
+ const cta = d.createElement("button");
747
+ cta.type = "button";
748
+ cta.className = "dsh-star-cta";
749
+ cta.textContent = "★ " + STAR_CTA[lang];
750
+ cta.addEventListener("click", (event) => {
751
+ event.preventDefault();
752
+ event.stopPropagation();
753
+ openRepo(d);
754
+ });
755
+ row.appendChild(cta);
756
+ const hide = d.createElement("button");
757
+ hide.type = "button";
758
+ hide.className = "dsh-star-hide";
759
+ hide.textContent = "×";
760
+ hide.title = STAR_HIDE[lang];
761
+ hide.setAttribute("aria-label", STAR_HIDE[lang]);
762
+ hide.addEventListener("click", (event) => {
763
+ event.preventDefault();
764
+ event.stopPropagation();
765
+ starDismiss();
766
+ if (row.parentNode) {
767
+ row.parentNode.replaceChild(link, row);
768
+ link.className = "dsh-star-row";
769
+ }
770
+ });
771
+ row.appendChild(hide);
772
+ return row;
773
+ }
774
+ /** 在目标文档上建出快车道行(一次性注入样式)。纯 DOM,React 仓经 ref 回调挂载。 */
775
+ function mountStarRow(doc) {
776
+ const d = doc ?? document;
777
+ if (!d.getElementById(STYLE_ID)) {
778
+ const tag = d.createElement("style");
779
+ tag.id = STYLE_ID;
780
+ tag.textContent = STYLE_CSS;
781
+ d.head.appendChild(tag);
782
+ }
783
+ const match = REPO_URL.match(/github\.com\/([^/]+\/[^/#?]+)/);
784
+ const repo = match ? match[1] : "drscrewdriver";
785
+ const a = d.createElement("a");
786
+ a.className = "dsh-star-row";
787
+ a.href = REPO_URL;
788
+ a.target = "_blank";
789
+ a.rel = "noreferrer";
790
+ a.dataset.starNs = STAR_NS;
791
+ const svg = d.createElementNS("http://www.w3.org/2000/svg", "svg");
792
+ svg.setAttribute("viewBox", "0 0 24 24");
793
+ svg.setAttribute("aria-hidden", "true");
794
+ const path = d.createElementNS("http://www.w3.org/2000/svg", "path");
795
+ path.setAttribute("fill", "currentColor");
796
+ path.setAttribute("d", GITHUB_MARK_PATH);
797
+ svg.appendChild(path);
798
+ a.appendChild(svg);
799
+ const label = d.createElement("span");
800
+ label.textContent = repo;
801
+ a.appendChild(label);
802
+ const row = extendedStarRow(a, d);
803
+ if (row) return row;
804
+ return a;
805
+ }
806
+ //#endregion
597
807
  //#region src/client/settings-card.tsx
598
808
  /**
599
809
  * dsh-session-guard — 插件配置卡片(dsh-family.tab 共用设置节,抽屉默认展开)。
@@ -824,191 +1034,197 @@ window.__ModuleLoader__.load({
824
1034
  };
825
1035
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
826
1036
  className: "sgCard" + (open ? " sgCard-open" : ""),
827
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
828
- type: "button",
829
- className: "sgCardHeader",
830
- "aria-expanded": open,
831
- onClick: () => setOpen(!open),
832
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
833
- className: "sgCardHeadtext",
834
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
835
- className: "sgCardName",
836
- children: "会话守护门禁"
837
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
838
- className: "sgCardDesc",
839
- children: "高峰自动暂停运行会话,周末模式无视峰谷畅快跑"
840
- })]
841
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
842
- className: "sgCardChevron" + (open ? " sgCardChevron-open" : ""),
843
- viewBox: "0 0 14 14",
844
- width: 14,
845
- height: 14,
846
- fill: "none",
847
- "aria-hidden": "true",
848
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
849
- d: "M3.5 5.5L7 9l3.5-3.5",
850
- stroke: "currentColor",
851
- strokeWidth: 1.5,
852
- strokeLinecap: "round",
853
- strokeLinejoin: "round"
854
- })
855
- })]
856
- }), open && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
857
- className: "sgCardBody",
858
- children: [
859
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
860
- className: "sgHint",
861
- style: { marginBottom: 12 },
862
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GuideRestartButton, {
863
- ns: "session-guard",
864
- onOpen: () => setGuideOpen(true)
1037
+ children: [
1038
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1039
+ type: "button",
1040
+ className: "sgCardHeader",
1041
+ "aria-expanded": open,
1042
+ onClick: () => setOpen(!open),
1043
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1044
+ className: "sgCardHeadtext",
1045
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1046
+ className: "sgCardName",
1047
+ children: "会话守护门禁"
1048
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1049
+ className: "sgCardDesc",
1050
+ children: "高峰自动暂停运行会话,周末模式无视峰谷畅快跑"
1051
+ })]
1052
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
1053
+ className: "sgCardChevron" + (open ? " sgCardChevron-open" : ""),
1054
+ viewBox: "0 0 14 14",
1055
+ width: 14,
1056
+ height: 14,
1057
+ fill: "none",
1058
+ "aria-hidden": "true",
1059
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1060
+ d: "M3.5 5.5L7 9l3.5-3.5",
1061
+ stroke: "currentColor",
1062
+ strokeWidth: 1.5,
1063
+ strokeLinecap: "round",
1064
+ strokeLinejoin: "round"
865
1065
  })
866
- }),
867
- guideOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GuidePanel, {
868
- ns: "session-guard",
869
- steps: guideSteps(GUIDE_STEPS),
870
- onClose: () => setGuideOpen(false)
871
- }),
872
- unavailable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
873
- style: {
874
- margin: "0",
875
- padding: "12px 0",
876
- fontSize: "13px",
877
- color: "var(--dsw-alias-label-tertiary)"
878
- },
879
- children: "设置命名空间不可用:请确认 dsh-session-guard 已装配进此 profile。"
880
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
881
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
882
- label: "高峰自动暂停冻结会话",
883
- description: "高峰时段自动暂停运行会话",
884
- checked: value.enabled ?? true,
885
- disabled: readonly,
886
- onChange: (next) => toggle("enabled", next)
887
- }),
888
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
889
- label: "step 级门控",
890
- description: "高峰在下一个 step 的模型请求前拉门(省 token 更彻底);关闭则回退为回合级暂停",
891
- checked: value.stepLevelPause ?? true,
892
- disabled: readonly,
893
- onChange: (next) => toggle("stepLevelPause", next)
894
- }),
895
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextRow, {
896
- label: "step 门控超时(毫秒)",
897
- description: "到期释放 step 门并升级为回合级暂停(防死锁);0 或非法值用默认 300000",
898
- value: String(value.stepGateTimeoutMs ?? 3e5),
899
- placeholder: "300000",
900
- disabled: readonly,
901
- onCommit: (next) => {
902
- const n = Number(String(next).trim());
903
- scope.set("stepGateTimeoutMs", Number.isFinite(n) && n > 0 ? n : 3e5);
904
- }
905
- }),
906
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
907
- label: "官方源二维判定",
908
- description: "高峰期只拦 DeepSeek 官方源;本地/第三方 provider 照常跑",
909
- checked: value.providerGuard ?? true,
910
- disabled: readonly,
911
- onChange: (next) => toggle("providerGuard", next)
912
- }),
913
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ListRow, {
914
- label: "追加官方 provider id",
915
- description: "精确匹配,优先级最高(逗号分隔)",
916
- values: toList(value.officialProviders),
917
- placeholder: "deepseek-official",
918
- disabled: readonly,
919
- onCommit: (next) => {
920
- scope.set("officialProviders", next);
921
- }
922
- }),
923
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ListRow, {
924
- label: "官方端点名单",
925
- description: "baseURL 归一化后的 host(逗号分隔)",
926
- values: toList(value.officialBaseURLs),
927
- placeholder: "api.deepseek.com",
928
- disabled: readonly,
929
- onCommit: (next) => {
930
- scope.set("officialBaseURLs", next);
931
- }
932
- }),
933
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectRow, {
934
- label: "拦截方式",
935
- description: "挂起等待不报错;或报错并记入延后队列",
936
- value: value.deferredMode === "error" ? "error" : "hold",
937
- options: [{
938
- value: "hold",
939
- label: "挂起等待(退峰自动放行)"
940
- }, {
941
- value: "error",
942
- label: "报错并延后(退峰续跑)"
943
- }],
944
- disabled: readonly,
945
- onChange: (next) => {
946
- scope.set("deferredMode", next);
947
- }
948
- }),
949
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
950
- label: "退峰自动继续",
951
- description: "关闭后延后的请求/会话不自动续跑,需手动 /resume",
952
- checked: value.deferredResume ?? true,
953
- disabled: readonly,
954
- onChange: (next) => toggle("deferredResume", next)
955
- }),
956
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextRow, {
957
- label: "退峰续跑文案",
958
- description: "error 模式退峰时发送的消息内容",
959
- value: value.deferredResumeText ?? "",
960
- placeholder: "继续(高峰已过,自动继续)",
961
- disabled: readonly,
962
- onCommit: (next) => {
963
- scope.set("deferredResumeText", next);
964
- }
965
- }),
966
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
967
- label: "纳入子代理请求",
968
- description: "子代理请求同样计费,默认一并拦截",
969
- checked: value.guardSubagents ?? true,
970
- disabled: readonly,
971
- onChange: (next) => toggle("guardSubagents", next)
972
- }),
973
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
974
- label: "低谷自动恢复",
975
- description: "低峰时段自动恢复被暂停的会话",
976
- checked: value.offPeakAutoResume ?? true,
977
- disabled: readonly,
978
- onChange: (next) => toggle("offPeakAutoResume", next)
979
- }),
980
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
981
- label: "周末模式",
982
- description: "识别周末,无视峰谷畅快跑",
983
- checked: value.weekendMode ?? true,
984
- disabled: readonly,
985
- onChange: (next) => toggle("weekendMode", next)
986
- }),
987
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
988
- label: "回退锁队列",
989
- description: "无会话门时锁等待队列",
990
- checked: value.queueFallback ?? true,
991
- disabled: readonly,
992
- onChange: (next) => toggle("queueFallback", next)
993
- }),
994
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
995
- label: "自动重试",
996
- description: "后端重试,默认关(保守)",
997
- checked: value.retryEnabled ?? false,
998
- disabled: readonly,
999
- onChange: (next) => toggle("retryEnabled", next)
1000
- }),
1066
+ })]
1067
+ }),
1068
+ open && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1069
+ className: "sgCardBody",
1070
+ children: [
1001
1071
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1002
1072
  className: "sgHint",
1003
- children: "判定口径:显式 id 名单 → baseURL 端点 → catalog 默认端点 → 内置 id。 排查误判访问 /session-guard/provider?provider=<id> 看 matchedBy。"
1073
+ style: { marginBottom: 12 },
1074
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GuideRestartButton, {
1075
+ ns: "session-guard",
1076
+ onOpen: () => setGuideOpen(true)
1077
+ })
1004
1078
  }),
1005
- !snapshot.writable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1006
- className: "sgReadonly",
1007
- children: "当前只读,无法修改。"
1008
- })
1009
- ] })
1010
- ]
1011
- })]
1079
+ guideOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GuidePanel, {
1080
+ ns: "session-guard",
1081
+ steps: guideSteps(GUIDE_STEPS),
1082
+ onClose: () => setGuideOpen(false)
1083
+ }),
1084
+ unavailable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1085
+ style: {
1086
+ margin: "0",
1087
+ padding: "12px 0",
1088
+ fontSize: "13px",
1089
+ color: "var(--dsw-alias-label-tertiary)"
1090
+ },
1091
+ children: "设置命名空间不可用:请确认 dsh-session-guard 已装配进此 profile。"
1092
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1093
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
1094
+ label: "高峰自动暂停冻结会话",
1095
+ description: "高峰时段自动暂停运行会话",
1096
+ checked: value.enabled ?? true,
1097
+ disabled: readonly,
1098
+ onChange: (next) => toggle("enabled", next)
1099
+ }),
1100
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
1101
+ label: "step 级门控",
1102
+ description: "高峰在下一个 step 的模型请求前拉门(省 token 更彻底);关闭则回退为回合级暂停",
1103
+ checked: value.stepLevelPause ?? true,
1104
+ disabled: readonly,
1105
+ onChange: (next) => toggle("stepLevelPause", next)
1106
+ }),
1107
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextRow, {
1108
+ label: "step 门控超时(毫秒)",
1109
+ description: "到期释放 step 门并升级为回合级暂停(防死锁);0 或非法值用默认 300000",
1110
+ value: String(value.stepGateTimeoutMs ?? 3e5),
1111
+ placeholder: "300000",
1112
+ disabled: readonly,
1113
+ onCommit: (next) => {
1114
+ const n = Number(String(next).trim());
1115
+ scope.set("stepGateTimeoutMs", Number.isFinite(n) && n > 0 ? n : 3e5);
1116
+ }
1117
+ }),
1118
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
1119
+ label: "官方源二维判定",
1120
+ description: "高峰期只拦 DeepSeek 官方源;本地/第三方 provider 照常跑",
1121
+ checked: value.providerGuard ?? true,
1122
+ disabled: readonly,
1123
+ onChange: (next) => toggle("providerGuard", next)
1124
+ }),
1125
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ListRow, {
1126
+ label: "追加官方 provider id",
1127
+ description: "精确匹配,优先级最高(逗号分隔)",
1128
+ values: toList(value.officialProviders),
1129
+ placeholder: "deepseek-official",
1130
+ disabled: readonly,
1131
+ onCommit: (next) => {
1132
+ scope.set("officialProviders", next);
1133
+ }
1134
+ }),
1135
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ListRow, {
1136
+ label: "官方端点名单",
1137
+ description: "baseURL 归一化后的 host(逗号分隔)",
1138
+ values: toList(value.officialBaseURLs),
1139
+ placeholder: "api.deepseek.com",
1140
+ disabled: readonly,
1141
+ onCommit: (next) => {
1142
+ scope.set("officialBaseURLs", next);
1143
+ }
1144
+ }),
1145
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectRow, {
1146
+ label: "拦截方式",
1147
+ description: "挂起等待不报错;或报错并记入延后队列",
1148
+ value: value.deferredMode === "error" ? "error" : "hold",
1149
+ options: [{
1150
+ value: "hold",
1151
+ label: "挂起等待(退峰自动放行)"
1152
+ }, {
1153
+ value: "error",
1154
+ label: "报错并延后(退峰续跑)"
1155
+ }],
1156
+ disabled: readonly,
1157
+ onChange: (next) => {
1158
+ scope.set("deferredMode", next);
1159
+ }
1160
+ }),
1161
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
1162
+ label: "退峰自动继续",
1163
+ description: "关闭后延后的请求/会话不自动续跑,需手动 /resume",
1164
+ checked: value.deferredResume ?? true,
1165
+ disabled: readonly,
1166
+ onChange: (next) => toggle("deferredResume", next)
1167
+ }),
1168
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextRow, {
1169
+ label: "退峰续跑文案",
1170
+ description: "error 模式退峰时发送的消息内容",
1171
+ value: value.deferredResumeText ?? "",
1172
+ placeholder: "继续(高峰已过,自动继续)",
1173
+ disabled: readonly,
1174
+ onCommit: (next) => {
1175
+ scope.set("deferredResumeText", next);
1176
+ }
1177
+ }),
1178
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
1179
+ label: "纳入子代理请求",
1180
+ description: "子代理请求同样计费,默认一并拦截",
1181
+ checked: value.guardSubagents ?? true,
1182
+ disabled: readonly,
1183
+ onChange: (next) => toggle("guardSubagents", next)
1184
+ }),
1185
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
1186
+ label: "低谷自动恢复",
1187
+ description: "低峰时段自动恢复被暂停的会话",
1188
+ checked: value.offPeakAutoResume ?? true,
1189
+ disabled: readonly,
1190
+ onChange: (next) => toggle("offPeakAutoResume", next)
1191
+ }),
1192
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
1193
+ label: "周末模式",
1194
+ description: "识别周末,无视峰谷畅快跑",
1195
+ checked: value.weekendMode ?? true,
1196
+ disabled: readonly,
1197
+ onChange: (next) => toggle("weekendMode", next)
1198
+ }),
1199
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
1200
+ label: "回退锁队列",
1201
+ description: "无会话门时锁等待队列",
1202
+ checked: value.queueFallback ?? true,
1203
+ disabled: readonly,
1204
+ onChange: (next) => toggle("queueFallback", next)
1205
+ }),
1206
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
1207
+ label: "自动重试",
1208
+ description: "后端重试,默认关(保守)",
1209
+ checked: value.retryEnabled ?? false,
1210
+ disabled: readonly,
1211
+ onChange: (next) => toggle("retryEnabled", next)
1212
+ }),
1213
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1214
+ className: "sgHint",
1215
+ children: "判定口径:显式 id 名单 → baseURL 端点 → catalog 默认端点 → 内置 id。 排查误判访问 /session-guard/provider?provider=<id> 看 matchedBy。"
1216
+ }),
1217
+ !snapshot.writable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1218
+ className: "sgReadonly",
1219
+ children: "当前只读,无法修改。"
1220
+ })
1221
+ ] })
1222
+ ]
1223
+ }),
1224
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { ref: (node) => {
1225
+ if (node && !node.firstChild) node.appendChild(mountStarRow());
1226
+ } })
1227
+ ]
1012
1228
  });
1013
1229
  }
1014
1230
  //#endregion