dsh-session-guard 4.3.0 → 4.4.1
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 +415 -402
- package/CHANGELOG.pt.md +196 -196
- package/INSTALL.pt.md +120 -120
- package/README.pt.md +377 -377
- package/dsh.plugin.json +16 -16
- package/lib/client.js +526 -136
- package/lib/client.js.map +1 -1
- package/locale/de.json +6 -6
- package/locale/en.json +6 -6
- package/locale/es.json +6 -6
- package/locale/fr.json +6 -6
- package/locale/it.json +6 -6
- package/locale/ja.json +6 -6
- package/locale/ko.json +6 -6
- package/locale/pt.json +6 -6
- package/locale/ru.json +6 -6
- package/locale/zh.json +6 -6
- package/package.json +129 -129
- package/src/bridge.js +190 -190
- package/src/client/guide.tsx +368 -0
- package/src/client/locales.ts +400 -400
- package/src/client/pause-button-text.ts +76 -76
- package/src/client/pause-button.tsx +129 -129
- package/src/client/scope-face.ts +20 -20
- package/src/client/settings-card.tsx +46 -0
- package/src/client/styles.ts +30 -30
- package/src/holidays.js +215 -215
- package/src/pause-gate.js +544 -544
- package/src/retry.js +227 -227
- package/src/step-gate.js +411 -411
- package/src/wiring.js +308 -308
package/lib/client.js
CHANGED
|
@@ -250,6 +250,349 @@ window.__ModuleLoader__.load({
|
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
252
|
//#endregion
|
|
253
|
+
//#region src/client/guide.tsx
|
|
254
|
+
/**
|
|
255
|
+
* ⚠️ 生成副本 —— 请勿手改。真源:mine-dsh-plugins/_tools/guide-kit/guide.tsx
|
|
256
|
+
* 重新同步:node _tools/guide-kit/sync.mjs
|
|
257
|
+
*/
|
|
258
|
+
/**
|
|
259
|
+
* guide-kit —— 九插件共用的「首次使用引导」件(**生成副本,勿手改**)。
|
|
260
|
+
*
|
|
261
|
+
* 唯一真源:`mine-dsh-plugins/_tools/guide-kit/guide.tsx`
|
|
262
|
+
* 同步命令:`node _tools/guide-kit/sync.mjs`(会覆盖本文件;改这里等于白改)
|
|
263
|
+
*
|
|
264
|
+
* 六条契约(见 .agents/plans/unified-i18n-onboarding/spec.md §2):
|
|
265
|
+
* 1. Skip 恒定可见,任何步骤都能退;
|
|
266
|
+
* 2. 永远有字:引导外壳(标题/按钮/步进)自带 10 语词表,按 <html lang> 取词,
|
|
267
|
+
* 认不出的一律落 en;步骤正文按「本语 → en → zh → 任意可用」逐级回退,绝不留空白;
|
|
268
|
+
* 3. 重启入口:`GuideRestartButton`(或自己调 `resetGuide(ns)` + setOpen(true))就地重开;
|
|
269
|
+
* 4. 零依赖:只 react + localStorage,不 import 平台包,不抢宿主设置表单;
|
|
270
|
+
* 5. 引导自己绝不能成为卡面渲染的失败点:样式注入与存储访问全部 try/catch + 能力探测;
|
|
271
|
+
* 6. 外壳词表与步骤正文分离:外壳跨插件统一(本文件),正文每插件一份 `guide-steps.ts`。
|
|
272
|
+
*/
|
|
273
|
+
/** 生态通用的十个语言码(与各插件 `locale/*.json`、README 的十语镜像同口径)。 */
|
|
274
|
+
const GUIDE_LOCALES = [
|
|
275
|
+
"zh",
|
|
276
|
+
"en",
|
|
277
|
+
"ja",
|
|
278
|
+
"ko",
|
|
279
|
+
"fr",
|
|
280
|
+
"de",
|
|
281
|
+
"it",
|
|
282
|
+
"ru",
|
|
283
|
+
"es",
|
|
284
|
+
"pt"
|
|
285
|
+
];
|
|
286
|
+
/**
|
|
287
|
+
* 引导外壳词表(10 语)。
|
|
288
|
+
*
|
|
289
|
+
* 为什么不塞进各插件 locales:这七个词是**跨插件同一套**,塞进九个字典要重复翻译
|
|
290
|
+
* 9×10 次,且一旦措辞调整就得动九个仓。外壳留在本文件,正文留各插件。
|
|
291
|
+
*/
|
|
292
|
+
const GUIDE_COPY = {
|
|
293
|
+
zh: {
|
|
294
|
+
title: "快速上手",
|
|
295
|
+
skip: "跳过引导",
|
|
296
|
+
next: "下一步",
|
|
297
|
+
prev: "上一步",
|
|
298
|
+
done: "开始使用",
|
|
299
|
+
restart: "重新查看引导",
|
|
300
|
+
stepOf: (current, total) => `第 ${current} / ${total} 步`
|
|
301
|
+
},
|
|
302
|
+
en: {
|
|
303
|
+
title: "Quick start",
|
|
304
|
+
skip: "Skip guide",
|
|
305
|
+
next: "Next",
|
|
306
|
+
prev: "Back",
|
|
307
|
+
done: "Get started",
|
|
308
|
+
restart: "Show guide again",
|
|
309
|
+
stepOf: (current, total) => `Step ${current} of ${total}`
|
|
310
|
+
},
|
|
311
|
+
ja: {
|
|
312
|
+
title: "クイックスタート",
|
|
313
|
+
skip: "ガイドをスキップ",
|
|
314
|
+
next: "次へ",
|
|
315
|
+
prev: "戻る",
|
|
316
|
+
done: "はじめる",
|
|
317
|
+
restart: "ガイドをもう一度表示",
|
|
318
|
+
stepOf: (current, total) => `ステップ ${current} / ${total}`
|
|
319
|
+
},
|
|
320
|
+
ko: {
|
|
321
|
+
title: "빠른 시작",
|
|
322
|
+
skip: "가이드 건너뛰기",
|
|
323
|
+
next: "다음",
|
|
324
|
+
prev: "이전",
|
|
325
|
+
done: "시작하기",
|
|
326
|
+
restart: "가이드 다시 보기",
|
|
327
|
+
stepOf: (current, total) => `${current} / ${total} 단계`
|
|
328
|
+
},
|
|
329
|
+
fr: {
|
|
330
|
+
title: "Démarrage rapide",
|
|
331
|
+
skip: "Ignorer le guide",
|
|
332
|
+
next: "Suivant",
|
|
333
|
+
prev: "Retour",
|
|
334
|
+
done: "Commencer",
|
|
335
|
+
restart: "Revoir le guide",
|
|
336
|
+
stepOf: (current, total) => `Étape ${current} sur ${total}`
|
|
337
|
+
},
|
|
338
|
+
de: {
|
|
339
|
+
title: "Schnellstart",
|
|
340
|
+
skip: "Anleitung überspringen",
|
|
341
|
+
next: "Weiter",
|
|
342
|
+
prev: "Zurück",
|
|
343
|
+
done: "Loslegen",
|
|
344
|
+
restart: "Anleitung erneut anzeigen",
|
|
345
|
+
stepOf: (current, total) => `Schritt ${current} von ${total}`
|
|
346
|
+
},
|
|
347
|
+
it: {
|
|
348
|
+
title: "Avvio rapido",
|
|
349
|
+
skip: "Salta la guida",
|
|
350
|
+
next: "Avanti",
|
|
351
|
+
prev: "Indietro",
|
|
352
|
+
done: "Inizia",
|
|
353
|
+
restart: "Rivedi la guida",
|
|
354
|
+
stepOf: (current, total) => `Passo ${current} di ${total}`
|
|
355
|
+
},
|
|
356
|
+
ru: {
|
|
357
|
+
title: "Быстрый старт",
|
|
358
|
+
skip: "Пропустить руководство",
|
|
359
|
+
next: "Далее",
|
|
360
|
+
prev: "Назад",
|
|
361
|
+
done: "Начать",
|
|
362
|
+
restart: "Показать руководство снова",
|
|
363
|
+
stepOf: (current, total) => `Шаг ${current} из ${total}`
|
|
364
|
+
},
|
|
365
|
+
es: {
|
|
366
|
+
title: "Inicio rápido",
|
|
367
|
+
skip: "Omitir la guía",
|
|
368
|
+
next: "Siguiente",
|
|
369
|
+
prev: "Atrás",
|
|
370
|
+
done: "Empezar",
|
|
371
|
+
restart: "Ver la guía de nuevo",
|
|
372
|
+
stepOf: (current, total) => `Paso ${current} de ${total}`
|
|
373
|
+
},
|
|
374
|
+
pt: {
|
|
375
|
+
title: "Início rápido",
|
|
376
|
+
skip: "Ignorar o guia",
|
|
377
|
+
next: "Próximo",
|
|
378
|
+
prev: "Voltar",
|
|
379
|
+
done: "Começar",
|
|
380
|
+
restart: "Ver o guia novamente",
|
|
381
|
+
stepOf: (current, total) => `Passo ${current} de ${total}`
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
/** 语言标签 → 语言码:只认主标签,认不出的落 null(由调用方回退 en)。 */
|
|
385
|
+
function normalizeGuideLocale(tag) {
|
|
386
|
+
const primary = tag.toLowerCase().trim().split(/[-_]/)[0] ?? "";
|
|
387
|
+
return GUIDE_LOCALES.includes(primary) ? primary : null;
|
|
388
|
+
}
|
|
389
|
+
function htmlLang() {
|
|
390
|
+
try {
|
|
391
|
+
return typeof document === "undefined" ? "" : document.documentElement?.lang ?? "";
|
|
392
|
+
} catch {
|
|
393
|
+
return "";
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* 当前引导语言:以宿主 `<html lang>` 为准(语言切换会改写这个属性)。
|
|
398
|
+
*
|
|
399
|
+
* 认不出 → en:引导是「帮助」面,宁可给英文也不能给空白或中文硬串。
|
|
400
|
+
*/
|
|
401
|
+
function currentGuideLocale() {
|
|
402
|
+
return normalizeGuideLocale(htmlLang()) ?? "en";
|
|
403
|
+
}
|
|
404
|
+
/** 引导外壳取词。 */
|
|
405
|
+
function guideLabels(locale = currentGuideLocale()) {
|
|
406
|
+
return GUIDE_COPY[locale] ?? GUIDE_COPY.en;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* 步骤正文取词:本语 → en → zh → 表里第一个可用。
|
|
410
|
+
*
|
|
411
|
+
* 为什么需要回退链:九插件分批补语种,某个插件可能只有 zh/en 而宿主是 ru;
|
|
412
|
+
* 这时给英文是可用的,给空白等于「引导坏了」。`undefined` 步骤表按空表处理。
|
|
413
|
+
*/
|
|
414
|
+
function guideSteps(map) {
|
|
415
|
+
if (map === void 0) return [];
|
|
416
|
+
const order = [
|
|
417
|
+
currentGuideLocale(),
|
|
418
|
+
"en",
|
|
419
|
+
"zh"
|
|
420
|
+
];
|
|
421
|
+
for (const key of order) {
|
|
422
|
+
const hit = key === void 0 ? void 0 : map[key];
|
|
423
|
+
if (hit !== void 0 && hit.length > 0) return hit;
|
|
424
|
+
}
|
|
425
|
+
for (const key of GUIDE_LOCALES) {
|
|
426
|
+
const hit = map[key];
|
|
427
|
+
if (hit !== void 0 && hit.length > 0) return hit;
|
|
428
|
+
}
|
|
429
|
+
return [];
|
|
430
|
+
}
|
|
431
|
+
function guideStorageKey(ns) {
|
|
432
|
+
return `dsh.guide.${ns}.skipped`;
|
|
433
|
+
}
|
|
434
|
+
/** 是否已跳过(存储不可用时按「未跳过」处理:宁可多教一次,不要静默不教)。 */
|
|
435
|
+
function isGuideSkipped(ns) {
|
|
436
|
+
try {
|
|
437
|
+
return typeof localStorage !== "undefined" && localStorage.getItem(guideStorageKey(ns)) === "1";
|
|
438
|
+
} catch {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
/** 记下跳过;写失败不抛(隐私模式 / 存储禁用)。 */
|
|
443
|
+
function skipGuide(ns) {
|
|
444
|
+
try {
|
|
445
|
+
localStorage?.setItem(guideStorageKey(ns), "1");
|
|
446
|
+
} catch {}
|
|
447
|
+
}
|
|
448
|
+
/** 清标记 = 允许重新教学。 */
|
|
449
|
+
function resetGuide(ns) {
|
|
450
|
+
try {
|
|
451
|
+
localStorage?.removeItem(guideStorageKey(ns));
|
|
452
|
+
} catch {}
|
|
453
|
+
}
|
|
454
|
+
const GUIDE_CSS = `
|
|
455
|
+
.sgGuide{border:1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.28));background:var(--dsw-alias-bg-layer-2, rgba(127,127,127,.06));border-radius:12px;padding:14px 16px;margin:0 0 12px}
|
|
456
|
+
.sgGuideHead{display:flex;align-items:center;gap:8px;margin:0 0 10px}
|
|
457
|
+
.sgGuideTitle{font-size:14px;font-weight:600;color:var(--dsw-alias-label-primary, currentColor)}
|
|
458
|
+
.sgGuideStep{font-size:12px;color:var(--dsw-alias-label-tertiary, rgba(127,127,127,.9));margin-left:auto}
|
|
459
|
+
.sgGuideBody{font-size:13px;line-height:1.6;color:var(--dsw-alias-label-secondary, currentColor);min-height:52px}
|
|
460
|
+
.sgGuideBody b{color:var(--dsw-alias-label-primary, currentColor);font-weight:600}
|
|
461
|
+
.sgGuideDots{display:flex;gap:6px;margin:10px 0 0}
|
|
462
|
+
.sgGuideDot{width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-border-l2, rgba(127,127,127,.3))}
|
|
463
|
+
.sgGuideDot-on{background:var(--dsw-alias-button-primary-fill, #4d6bfe)}
|
|
464
|
+
.sgGuideFoot{display:flex;align-items:center;gap:8px;margin:12px 0 0}
|
|
465
|
+
.sgGuideBtn{appearance:none;font:inherit;font-size:12px;padding:5px 12px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.3));background:transparent;color:var(--dsw-alias-label-primary, currentColor);cursor:pointer}
|
|
466
|
+
.sgGuideBtn-primary{background:var(--dsw-alias-button-primary-fill, #4d6bfe);border-color:transparent;color:#fff}
|
|
467
|
+
.sgGuideBtn-skip{margin-right:auto;color:var(--dsw-alias-label-tertiary, rgba(127,127,127,.9));border-color:transparent;text-decoration:underline}
|
|
468
|
+
.sgGuideRestart{appearance:none;font:inherit;font-size:12px;padding:0;border:0;background:transparent;color:var(--dsw-alias-link-primary, #4d6bfe);cursor:pointer;text-decoration:underline}
|
|
469
|
+
`;
|
|
470
|
+
function injectGuideCss() {
|
|
471
|
+
try {
|
|
472
|
+
if (typeof document === "undefined") return;
|
|
473
|
+
if (typeof document.querySelector !== "function") return;
|
|
474
|
+
if (typeof document.createElement !== "function") return;
|
|
475
|
+
if (!document.head) return;
|
|
476
|
+
if (document.querySelector("style[data-plugin-css=\"guide-kit\"]") !== null) return;
|
|
477
|
+
const tag = document.createElement("style");
|
|
478
|
+
tag.dataset.pluginCss = "guide-kit";
|
|
479
|
+
tag.textContent = GUIDE_CSS;
|
|
480
|
+
document.head.appendChild(tag);
|
|
481
|
+
} catch {}
|
|
482
|
+
}
|
|
483
|
+
/** 语言变更订阅:语言切换后重渲染词表(引导是短生命周期,直接跟随 <html lang>)。 */
|
|
484
|
+
function useLangTick() {
|
|
485
|
+
const [, setTick] = (0, react.useState)(0);
|
|
486
|
+
(0, react.useEffect)(() => {
|
|
487
|
+
try {
|
|
488
|
+
if (typeof MutationObserver === "undefined" || typeof document === "undefined") return;
|
|
489
|
+
if (!document.documentElement) return;
|
|
490
|
+
const observer = new MutationObserver(() => setTick((n) => n + 1));
|
|
491
|
+
observer.observe(document.documentElement, {
|
|
492
|
+
attributes: true,
|
|
493
|
+
attributeFilter: ["lang"]
|
|
494
|
+
});
|
|
495
|
+
return () => observer.disconnect();
|
|
496
|
+
} catch {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
}, []);
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* 引导主体:≤10 步的小教学(惯例:末条讲「用量端点」贴士)+ 恒定可见的 Skip。
|
|
503
|
+
*
|
|
504
|
+
* `onClose` 由宿主卡面传:Skip/Done 都会调用它(Skip 同时写标记)。
|
|
505
|
+
*/
|
|
506
|
+
function GuidePanel(props) {
|
|
507
|
+
const { ns, steps, onClose } = props;
|
|
508
|
+
const [index, setIndex] = (0, react.useState)(0);
|
|
509
|
+
useLangTick();
|
|
510
|
+
const labels = guideLabels();
|
|
511
|
+
(0, react.useEffect)(() => {
|
|
512
|
+
injectGuideCss();
|
|
513
|
+
}, []);
|
|
514
|
+
if (steps.length === 0) return null;
|
|
515
|
+
const current = steps[Math.min(index, steps.length - 1)];
|
|
516
|
+
const last = index >= steps.length - 1;
|
|
517
|
+
const finish = () => {
|
|
518
|
+
skipGuide(ns);
|
|
519
|
+
onClose();
|
|
520
|
+
};
|
|
521
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
522
|
+
className: "sgGuide",
|
|
523
|
+
"aria-label": labels.title,
|
|
524
|
+
children: [
|
|
525
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
526
|
+
className: "sgGuideHead",
|
|
527
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
528
|
+
className: "sgGuideTitle",
|
|
529
|
+
children: labels.title
|
|
530
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
531
|
+
className: "sgGuideStep",
|
|
532
|
+
children: labels.stepOf(index + 1, steps.length)
|
|
533
|
+
})]
|
|
534
|
+
}),
|
|
535
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
536
|
+
className: "sgGuideBody",
|
|
537
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: current.title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: current.body })]
|
|
538
|
+
}),
|
|
539
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
540
|
+
className: "sgGuideDots",
|
|
541
|
+
"aria-hidden": "true",
|
|
542
|
+
children: steps.map((step, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "sgGuideDot" + (i === index ? " sgGuideDot-on" : "") }, step.title))
|
|
543
|
+
}),
|
|
544
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", {
|
|
545
|
+
className: "sgGuideFoot",
|
|
546
|
+
children: [
|
|
547
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
548
|
+
type: "button",
|
|
549
|
+
className: "sgGuideBtn sgGuideBtn-skip",
|
|
550
|
+
onClick: () => finish(),
|
|
551
|
+
children: labels.skip
|
|
552
|
+
}),
|
|
553
|
+
index > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
554
|
+
type: "button",
|
|
555
|
+
className: "sgGuideBtn",
|
|
556
|
+
onClick: () => setIndex(index - 1),
|
|
557
|
+
children: labels.prev
|
|
558
|
+
}),
|
|
559
|
+
last ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
560
|
+
type: "button",
|
|
561
|
+
className: "sgGuideBtn sgGuideBtn-primary",
|
|
562
|
+
onClick: () => finish(),
|
|
563
|
+
children: labels.done
|
|
564
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
565
|
+
type: "button",
|
|
566
|
+
className: "sgGuideBtn sgGuideBtn-primary",
|
|
567
|
+
onClick: () => setIndex(index + 1),
|
|
568
|
+
children: labels.next
|
|
569
|
+
})
|
|
570
|
+
]
|
|
571
|
+
})
|
|
572
|
+
]
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* 重启入口:清标记 + 就地重开引导。
|
|
577
|
+
*
|
|
578
|
+
* 统一件,避免九插件各写一份(措辞/样式/清标记时机容易走样)。跳过之后
|
|
579
|
+
* 用户想再看一次,不需要去清浏览器存储。
|
|
580
|
+
*/
|
|
581
|
+
function GuideRestartButton(props) {
|
|
582
|
+
const { ns, onOpen, style } = props;
|
|
583
|
+
useLangTick();
|
|
584
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
585
|
+
type: "button",
|
|
586
|
+
className: "sgGuideRestart",
|
|
587
|
+
style,
|
|
588
|
+
onClick: () => {
|
|
589
|
+
resetGuide(ns);
|
|
590
|
+
onOpen();
|
|
591
|
+
},
|
|
592
|
+
children: guideLabels().restart
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
//#endregion
|
|
253
596
|
//#region src/client/settings-card.tsx
|
|
254
597
|
/**
|
|
255
598
|
* dsh-session-guard — 插件配置卡片(dsh-family.tab 共用设置节,抽屉默认展开)。
|
|
@@ -263,6 +606,37 @@ window.__ModuleLoader__.load({
|
|
|
263
606
|
* 仅依赖 react;CSS 经 `<style data-plugin-css>` 注入一次,控件为原生 HTML,
|
|
264
607
|
* 客户端 bundle 无 value-import @deepseek-ai/* 平台包(类型导入被构建擦除)。
|
|
265
608
|
*/
|
|
609
|
+
/** 首次使用引导文案(zh/en 为一等公民;其余语种由 guide-kit 的回退链落到 en)。 */
|
|
610
|
+
const GUIDE_STEPS = {
|
|
611
|
+
zh: [
|
|
612
|
+
{
|
|
613
|
+
title: "它会替你踩刹车",
|
|
614
|
+
body: "高峰时段自动暂停运行中的会话,退峰后自动续跑;周末模式让你无视峰谷畅快跑。"
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
title: "判定口径按「官方源」",
|
|
618
|
+
body: "默认只拦 DeepSeek 官方源,本地/第三方 provider 照常跑;需要更严时再打开「官方源二维判定」下的名单。"
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
title: "状态永远可见",
|
|
622
|
+
body: "输入框右侧的徽标显示当前状态(正常 / 峰值暂停中);停不下来时用旁边的暂停按钮手动接管。"
|
|
623
|
+
}
|
|
624
|
+
],
|
|
625
|
+
en: [
|
|
626
|
+
{
|
|
627
|
+
title: "It pumps the brakes for you",
|
|
628
|
+
body: "Running sessions auto-pause during peak hours and resume off-peak. Weekend mode ignores peaks entirely."
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
title: "Official-source scoping",
|
|
632
|
+
body: "By default only the DeepSeek official source is gated; local/third-party providers keep running. Tighten it via the official-source allowlists when needed."
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
title: "Status stays visible",
|
|
636
|
+
body: "The badge right of the composer shows the current state (Normal / Peak paused). Use the pause button beside it to take over manually."
|
|
637
|
+
}
|
|
638
|
+
]
|
|
639
|
+
};
|
|
266
640
|
/** 卡片样式,注入一次(保持 bundle CSS-free)。 */
|
|
267
641
|
const CARD_CSS = `
|
|
268
642
|
.sgCard{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}
|
|
@@ -442,6 +816,7 @@ window.__ModuleLoader__.load({
|
|
|
442
816
|
const readonly = unavailable || !snapshot.writable;
|
|
443
817
|
const value = snapshot.value ?? {};
|
|
444
818
|
const [open, setOpen] = (0, react.useState)(true);
|
|
819
|
+
const [guideOpen, setGuideOpen] = (0, react.useState)(() => !isGuideSkipped("session-guard"));
|
|
445
820
|
injectCss();
|
|
446
821
|
const toggle = (field, next) => {
|
|
447
822
|
scope.set(field, next);
|
|
@@ -477,146 +852,161 @@ window.__ModuleLoader__.load({
|
|
|
477
852
|
strokeLinejoin: "round"
|
|
478
853
|
})
|
|
479
854
|
})]
|
|
480
|
-
}), open && /* @__PURE__ */ (0, react_jsx_runtime.
|
|
855
|
+
}), open && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
481
856
|
className: "sgCardBody",
|
|
482
|
-
children:
|
|
483
|
-
style: {
|
|
484
|
-
margin: "0",
|
|
485
|
-
padding: "12px 0",
|
|
486
|
-
fontSize: "13px",
|
|
487
|
-
color: "var(--dsw-alias-label-tertiary)"
|
|
488
|
-
},
|
|
489
|
-
children: "设置命名空间不可用:请确认 dsh-session-guard 已装配进此 profile。"
|
|
490
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
491
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
492
|
-
label: "高峰自动暂停冻结会话",
|
|
493
|
-
description: "高峰时段自动暂停运行会话",
|
|
494
|
-
checked: value.enabled ?? true,
|
|
495
|
-
disabled: readonly,
|
|
496
|
-
onChange: (next) => toggle("enabled", next)
|
|
497
|
-
}),
|
|
498
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
499
|
-
label: "step 级门控",
|
|
500
|
-
description: "高峰在下一个 step 的模型请求前拉门(省 token 更彻底);关闭则回退为回合级暂停",
|
|
501
|
-
checked: value.stepLevelPause ?? true,
|
|
502
|
-
disabled: readonly,
|
|
503
|
-
onChange: (next) => toggle("stepLevelPause", next)
|
|
504
|
-
}),
|
|
505
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextRow, {
|
|
506
|
-
label: "step 门控超时(毫秒)",
|
|
507
|
-
description: "到期释放 step 门并升级为回合级暂停(防死锁);0 或非法值用默认 300000",
|
|
508
|
-
value: String(value.stepGateTimeoutMs ?? 3e5),
|
|
509
|
-
placeholder: "300000",
|
|
510
|
-
disabled: readonly,
|
|
511
|
-
onCommit: (next) => {
|
|
512
|
-
const n = Number(String(next).trim());
|
|
513
|
-
scope.set("stepGateTimeoutMs", Number.isFinite(n) && n > 0 ? n : 3e5);
|
|
514
|
-
}
|
|
515
|
-
}),
|
|
516
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
517
|
-
label: "官方源二维判定",
|
|
518
|
-
description: "高峰期只拦 DeepSeek 官方源;本地/第三方 provider 照常跑",
|
|
519
|
-
checked: value.providerGuard ?? true,
|
|
520
|
-
disabled: readonly,
|
|
521
|
-
onChange: (next) => toggle("providerGuard", next)
|
|
522
|
-
}),
|
|
523
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ListRow, {
|
|
524
|
-
label: "追加官方 provider id",
|
|
525
|
-
description: "精确匹配,优先级最高(逗号分隔)",
|
|
526
|
-
values: toList(value.officialProviders),
|
|
527
|
-
placeholder: "deepseek-official",
|
|
528
|
-
disabled: readonly,
|
|
529
|
-
onCommit: (next) => {
|
|
530
|
-
scope.set("officialProviders", next);
|
|
531
|
-
}
|
|
532
|
-
}),
|
|
533
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ListRow, {
|
|
534
|
-
label: "官方端点名单",
|
|
535
|
-
description: "baseURL 归一化后的 host(逗号分隔)",
|
|
536
|
-
values: toList(value.officialBaseURLs),
|
|
537
|
-
placeholder: "api.deepseek.com",
|
|
538
|
-
disabled: readonly,
|
|
539
|
-
onCommit: (next) => {
|
|
540
|
-
scope.set("officialBaseURLs", next);
|
|
541
|
-
}
|
|
542
|
-
}),
|
|
543
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectRow, {
|
|
544
|
-
label: "拦截方式",
|
|
545
|
-
description: "挂起等待不报错;或报错并记入延后队列",
|
|
546
|
-
value: value.deferredMode === "error" ? "error" : "hold",
|
|
547
|
-
options: [{
|
|
548
|
-
value: "hold",
|
|
549
|
-
label: "挂起等待(退峰自动放行)"
|
|
550
|
-
}, {
|
|
551
|
-
value: "error",
|
|
552
|
-
label: "报错并延后(退峰续跑)"
|
|
553
|
-
}],
|
|
554
|
-
disabled: readonly,
|
|
555
|
-
onChange: (next) => {
|
|
556
|
-
scope.set("deferredMode", next);
|
|
557
|
-
}
|
|
558
|
-
}),
|
|
559
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
560
|
-
label: "退峰自动继续",
|
|
561
|
-
description: "关闭后延后的请求/会话不自动续跑,需手动 /resume",
|
|
562
|
-
checked: value.deferredResume ?? true,
|
|
563
|
-
disabled: readonly,
|
|
564
|
-
onChange: (next) => toggle("deferredResume", next)
|
|
565
|
-
}),
|
|
566
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextRow, {
|
|
567
|
-
label: "退峰续跑文案",
|
|
568
|
-
description: "error 模式退峰时发送的消息内容",
|
|
569
|
-
value: value.deferredResumeText ?? "",
|
|
570
|
-
placeholder: "继续(高峰已过,自动继续)",
|
|
571
|
-
disabled: readonly,
|
|
572
|
-
onCommit: (next) => {
|
|
573
|
-
scope.set("deferredResumeText", next);
|
|
574
|
-
}
|
|
575
|
-
}),
|
|
576
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
577
|
-
label: "纳入子代理请求",
|
|
578
|
-
description: "子代理请求同样计费,默认一并拦截",
|
|
579
|
-
checked: value.guardSubagents ?? true,
|
|
580
|
-
disabled: readonly,
|
|
581
|
-
onChange: (next) => toggle("guardSubagents", next)
|
|
582
|
-
}),
|
|
583
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
584
|
-
label: "低谷自动恢复",
|
|
585
|
-
description: "低峰时段自动恢复被暂停的会话",
|
|
586
|
-
checked: value.offPeakAutoResume ?? true,
|
|
587
|
-
disabled: readonly,
|
|
588
|
-
onChange: (next) => toggle("offPeakAutoResume", next)
|
|
589
|
-
}),
|
|
590
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
591
|
-
label: "周末模式",
|
|
592
|
-
description: "识别周末,无视峰谷畅快跑",
|
|
593
|
-
checked: value.weekendMode ?? true,
|
|
594
|
-
disabled: readonly,
|
|
595
|
-
onChange: (next) => toggle("weekendMode", next)
|
|
596
|
-
}),
|
|
597
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
598
|
-
label: "回退锁队列",
|
|
599
|
-
description: "无会话门时锁等待队列",
|
|
600
|
-
checked: value.queueFallback ?? true,
|
|
601
|
-
disabled: readonly,
|
|
602
|
-
onChange: (next) => toggle("queueFallback", next)
|
|
603
|
-
}),
|
|
604
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
605
|
-
label: "自动重试",
|
|
606
|
-
description: "后端重试,默认关(保守)",
|
|
607
|
-
checked: value.retryEnabled ?? false,
|
|
608
|
-
disabled: readonly,
|
|
609
|
-
onChange: (next) => toggle("retryEnabled", next)
|
|
610
|
-
}),
|
|
857
|
+
children: [
|
|
611
858
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
612
859
|
className: "sgHint",
|
|
613
|
-
|
|
860
|
+
style: { marginBottom: 12 },
|
|
861
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GuideRestartButton, {
|
|
862
|
+
ns: "session-guard",
|
|
863
|
+
onOpen: () => setGuideOpen(true)
|
|
864
|
+
})
|
|
614
865
|
}),
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
866
|
+
guideOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GuidePanel, {
|
|
867
|
+
ns: "session-guard",
|
|
868
|
+
steps: guideSteps(GUIDE_STEPS),
|
|
869
|
+
onClose: () => setGuideOpen(false)
|
|
870
|
+
}),
|
|
871
|
+
unavailable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
872
|
+
style: {
|
|
873
|
+
margin: "0",
|
|
874
|
+
padding: "12px 0",
|
|
875
|
+
fontSize: "13px",
|
|
876
|
+
color: "var(--dsw-alias-label-tertiary)"
|
|
877
|
+
},
|
|
878
|
+
children: "设置命名空间不可用:请确认 dsh-session-guard 已装配进此 profile。"
|
|
879
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
880
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
881
|
+
label: "高峰自动暂停冻结会话",
|
|
882
|
+
description: "高峰时段自动暂停运行会话",
|
|
883
|
+
checked: value.enabled ?? true,
|
|
884
|
+
disabled: readonly,
|
|
885
|
+
onChange: (next) => toggle("enabled", next)
|
|
886
|
+
}),
|
|
887
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
888
|
+
label: "step 级门控",
|
|
889
|
+
description: "高峰在下一个 step 的模型请求前拉门(省 token 更彻底);关闭则回退为回合级暂停",
|
|
890
|
+
checked: value.stepLevelPause ?? true,
|
|
891
|
+
disabled: readonly,
|
|
892
|
+
onChange: (next) => toggle("stepLevelPause", next)
|
|
893
|
+
}),
|
|
894
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextRow, {
|
|
895
|
+
label: "step 门控超时(毫秒)",
|
|
896
|
+
description: "到期释放 step 门并升级为回合级暂停(防死锁);0 或非法值用默认 300000",
|
|
897
|
+
value: String(value.stepGateTimeoutMs ?? 3e5),
|
|
898
|
+
placeholder: "300000",
|
|
899
|
+
disabled: readonly,
|
|
900
|
+
onCommit: (next) => {
|
|
901
|
+
const n = Number(String(next).trim());
|
|
902
|
+
scope.set("stepGateTimeoutMs", Number.isFinite(n) && n > 0 ? n : 3e5);
|
|
903
|
+
}
|
|
904
|
+
}),
|
|
905
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
906
|
+
label: "官方源二维判定",
|
|
907
|
+
description: "高峰期只拦 DeepSeek 官方源;本地/第三方 provider 照常跑",
|
|
908
|
+
checked: value.providerGuard ?? true,
|
|
909
|
+
disabled: readonly,
|
|
910
|
+
onChange: (next) => toggle("providerGuard", next)
|
|
911
|
+
}),
|
|
912
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ListRow, {
|
|
913
|
+
label: "追加官方 provider id",
|
|
914
|
+
description: "精确匹配,优先级最高(逗号分隔)",
|
|
915
|
+
values: toList(value.officialProviders),
|
|
916
|
+
placeholder: "deepseek-official",
|
|
917
|
+
disabled: readonly,
|
|
918
|
+
onCommit: (next) => {
|
|
919
|
+
scope.set("officialProviders", next);
|
|
920
|
+
}
|
|
921
|
+
}),
|
|
922
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ListRow, {
|
|
923
|
+
label: "官方端点名单",
|
|
924
|
+
description: "baseURL 归一化后的 host(逗号分隔)",
|
|
925
|
+
values: toList(value.officialBaseURLs),
|
|
926
|
+
placeholder: "api.deepseek.com",
|
|
927
|
+
disabled: readonly,
|
|
928
|
+
onCommit: (next) => {
|
|
929
|
+
scope.set("officialBaseURLs", next);
|
|
930
|
+
}
|
|
931
|
+
}),
|
|
932
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectRow, {
|
|
933
|
+
label: "拦截方式",
|
|
934
|
+
description: "挂起等待不报错;或报错并记入延后队列",
|
|
935
|
+
value: value.deferredMode === "error" ? "error" : "hold",
|
|
936
|
+
options: [{
|
|
937
|
+
value: "hold",
|
|
938
|
+
label: "挂起等待(退峰自动放行)"
|
|
939
|
+
}, {
|
|
940
|
+
value: "error",
|
|
941
|
+
label: "报错并延后(退峰续跑)"
|
|
942
|
+
}],
|
|
943
|
+
disabled: readonly,
|
|
944
|
+
onChange: (next) => {
|
|
945
|
+
scope.set("deferredMode", next);
|
|
946
|
+
}
|
|
947
|
+
}),
|
|
948
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
949
|
+
label: "退峰自动继续",
|
|
950
|
+
description: "关闭后延后的请求/会话不自动续跑,需手动 /resume",
|
|
951
|
+
checked: value.deferredResume ?? true,
|
|
952
|
+
disabled: readonly,
|
|
953
|
+
onChange: (next) => toggle("deferredResume", next)
|
|
954
|
+
}),
|
|
955
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextRow, {
|
|
956
|
+
label: "退峰续跑文案",
|
|
957
|
+
description: "error 模式退峰时发送的消息内容",
|
|
958
|
+
value: value.deferredResumeText ?? "",
|
|
959
|
+
placeholder: "继续(高峰已过,自动继续)",
|
|
960
|
+
disabled: readonly,
|
|
961
|
+
onCommit: (next) => {
|
|
962
|
+
scope.set("deferredResumeText", next);
|
|
963
|
+
}
|
|
964
|
+
}),
|
|
965
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
966
|
+
label: "纳入子代理请求",
|
|
967
|
+
description: "子代理请求同样计费,默认一并拦截",
|
|
968
|
+
checked: value.guardSubagents ?? true,
|
|
969
|
+
disabled: readonly,
|
|
970
|
+
onChange: (next) => toggle("guardSubagents", next)
|
|
971
|
+
}),
|
|
972
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
973
|
+
label: "低谷自动恢复",
|
|
974
|
+
description: "低峰时段自动恢复被暂停的会话",
|
|
975
|
+
checked: value.offPeakAutoResume ?? true,
|
|
976
|
+
disabled: readonly,
|
|
977
|
+
onChange: (next) => toggle("offPeakAutoResume", next)
|
|
978
|
+
}),
|
|
979
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
980
|
+
label: "周末模式",
|
|
981
|
+
description: "识别周末,无视峰谷畅快跑",
|
|
982
|
+
checked: value.weekendMode ?? true,
|
|
983
|
+
disabled: readonly,
|
|
984
|
+
onChange: (next) => toggle("weekendMode", next)
|
|
985
|
+
}),
|
|
986
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
987
|
+
label: "回退锁队列",
|
|
988
|
+
description: "无会话门时锁等待队列",
|
|
989
|
+
checked: value.queueFallback ?? true,
|
|
990
|
+
disabled: readonly,
|
|
991
|
+
onChange: (next) => toggle("queueFallback", next)
|
|
992
|
+
}),
|
|
993
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SwitchRow, {
|
|
994
|
+
label: "自动重试",
|
|
995
|
+
description: "后端重试,默认关(保守)",
|
|
996
|
+
checked: value.retryEnabled ?? false,
|
|
997
|
+
disabled: readonly,
|
|
998
|
+
onChange: (next) => toggle("retryEnabled", next)
|
|
999
|
+
}),
|
|
1000
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1001
|
+
className: "sgHint",
|
|
1002
|
+
children: "判定口径:显式 id 名单 → baseURL 端点 → catalog 默认端点 → 内置 id。 排查误判访问 /session-guard/provider?provider=<id> 看 matchedBy。"
|
|
1003
|
+
}),
|
|
1004
|
+
!snapshot.writable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1005
|
+
className: "sgReadonly",
|
|
1006
|
+
children: "当前只读,无法修改。"
|
|
1007
|
+
})
|
|
1008
|
+
] })
|
|
1009
|
+
]
|
|
620
1010
|
})]
|
|
621
1011
|
});
|
|
622
1012
|
}
|