@kangyishuai/dsh-advisor 0.2.0 → 0.4.0
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/README.md +53 -29
- package/README.zh-CN.md +56 -30
- package/lib/budget.js +10 -4
- package/lib/catalog.js +14 -3
- package/lib/client.js +1543 -462
- package/lib/guard.js +6 -5
- package/lib/money.js +74 -0
- package/lib/service.js +81 -7
- package/lib/settings.js +85 -13
- package/lib/trace.js +31 -0
- package/locale/en.json +111 -34
- package/locale/zh.json +117 -40
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -108,7 +108,6 @@ window.__ModuleLoader__.load({
|
|
|
108
108
|
"settings.budget.maxCallsPerTurn": "每回合最多调用",
|
|
109
109
|
"settings.budget.maxCallsPerSession": "每会话最多调用",
|
|
110
110
|
"settings.budget.maxCallsPerHour": "每小时最多调用",
|
|
111
|
-
"settings.budget.maxCostPerDayUsd": "每日预算(USD)",
|
|
112
111
|
"settings.budget.priceInputPerMTok": "输入单价(USD / 百万 token)",
|
|
113
112
|
"settings.budget.priceOutputPerMTok": "输出单价(USD / 百万 token)",
|
|
114
113
|
"settings.budget.range": "默认 {default} · 范围 {min}–{max}",
|
|
@@ -161,6 +160,14 @@ window.__ModuleLoader__.load({
|
|
|
161
160
|
"tail.anchors": "证据锚点未对上({checked} 条)",
|
|
162
161
|
"tail.downgraded": "严重度已降级",
|
|
163
162
|
"tail.aria": "顾问建议(点击展开或收起)",
|
|
163
|
+
"tail.trace.label": "本次徵询",
|
|
164
|
+
"tail.trace.sep": ":",
|
|
165
|
+
"tail.trace.chars": "{chars} 字符",
|
|
166
|
+
"tail.trigger.tool": "模型发起",
|
|
167
|
+
"tail.trigger.shadow": "影子",
|
|
168
|
+
"tail.trigger.manual": "手动",
|
|
169
|
+
"tail.trigger.postAnswer": "答后复查",
|
|
170
|
+
"tail.trigger.other": "其他",
|
|
164
171
|
};
|
|
165
172
|
|
|
166
173
|
/** 英文字典(键集必须与 zh 完全一致,locale/*.json 同步)。 */
|
|
@@ -239,7 +246,6 @@ window.__ModuleLoader__.load({
|
|
|
239
246
|
"settings.budget.maxCallsPerTurn": "Max calls per turn",
|
|
240
247
|
"settings.budget.maxCallsPerSession": "Max calls per session",
|
|
241
248
|
"settings.budget.maxCallsPerHour": "Max calls per hour",
|
|
242
|
-
"settings.budget.maxCostPerDayUsd": "Daily budget (USD)",
|
|
243
249
|
"settings.budget.priceInputPerMTok": "Input price (USD / 1M tokens)",
|
|
244
250
|
"settings.budget.priceOutputPerMTok": "Output price (USD / 1M tokens)",
|
|
245
251
|
"settings.budget.range": "default {default} · range {min}–{max}",
|
|
@@ -295,6 +301,14 @@ window.__ModuleLoader__.load({
|
|
|
295
301
|
"tail.anchors": "Evidence anchors did not match ({checked} checked)",
|
|
296
302
|
"tail.downgraded": "Severity downgraded",
|
|
297
303
|
"tail.aria": "Advisor advice (click to expand or collapse)",
|
|
304
|
+
"tail.trace.label": "Consultation",
|
|
305
|
+
"tail.trace.sep": ": ",
|
|
306
|
+
"tail.trace.chars": "{chars} chars",
|
|
307
|
+
"tail.trigger.tool": "model",
|
|
308
|
+
"tail.trigger.shadow": "shadow",
|
|
309
|
+
"tail.trigger.manual": "manual",
|
|
310
|
+
"tail.trigger.postAnswer": "post-answer",
|
|
311
|
+
"tail.trigger.other": "other",
|
|
298
312
|
};
|
|
299
313
|
|
|
300
314
|
/** 提示条样式:只用宿主 CSS 变量,深浅色自动跟随;同时充当「client 半已加载」的标记。 */
|
|
@@ -306,16 +320,43 @@ window.__ModuleLoader__.load({
|
|
|
306
320
|
".dsh-advisor-head{display:flex;flex-direction:column;gap:2px;}",
|
|
307
321
|
".dsh-advisor-title{font-size:14px;font-weight:600;}",
|
|
308
322
|
".dsh-advisor-desc{font-size:12px;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
309
|
-
".dsh-advisor-group{display:flex;flex-direction:column;gap:8px;
|
|
323
|
+
".dsh-advisor-group{display:flex;flex-direction:column;gap:8px;}",
|
|
324
|
+
".dsh-advisor-group + .dsh-advisor-group{margin-top:2px;padding-top:10px;border-top:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));}",
|
|
310
325
|
".dsh-advisor-group-title{font-size:12px;font-weight:600;letter-spacing:.04em;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
326
|
+
".dsh-advisor-subgroup{display:flex;flex-direction:column;gap:6px;}",
|
|
327
|
+
".dsh-advisor-subgroup-title{font-size:11.5px;font-weight:600;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
311
328
|
".dsh-advisor-row{display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;}",
|
|
312
329
|
".dsh-advisor-row--stack{flex-direction:column;align-items:flex-start;gap:4px;}",
|
|
330
|
+
".dsh-advisor-field{display:flex;flex-direction:column;gap:2px;}",
|
|
331
|
+
".dsh-advisor-label-wrap{display:flex;align-items:center;gap:6px;flex:0 0 auto;}",
|
|
313
332
|
".dsh-advisor-label{flex:0 0 auto;min-width:120px;color:var(--dsw-alias-label-primary,CanvasText);}",
|
|
333
|
+
".dsh-advisor-help-btn{flex:0 0 auto;width:16px;height:16px;padding:0;border-radius:50%;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.45));background:transparent;color:var(--dsw-alias-label-secondary,GrayText);font-size:11px;line-height:14px;text-align:center;cursor:pointer;}",
|
|
334
|
+
".dsh-advisor-help-btn:hover{background:var(--dsw-alias-bg-layer-2,rgba(128,128,128,.12));color:var(--dsw-alias-label-primary,CanvasText);}",
|
|
335
|
+
".dsh-advisor-help-btn:focus-visible{outline:2px solid var(--dsw-alias-label-primary,CanvasText);outline-offset:1px;}",
|
|
336
|
+
".dsh-advisor-help-body{padding:6px 10px;border-left:2px solid var(--dsw-alias-border-l2,rgba(128,128,128,.35));font-size:11.5px;line-height:1.55;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
337
|
+
".dsh-advisor-help-body p{margin:0;}",
|
|
338
|
+
".dsh-advisor-help-body .dsh-advisor-help-meta{margin-top:2px;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
339
|
+
".dsh-advisor-help-body .dsh-advisor-help-tech{margin-top:2px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10.5px;opacity:.85;}",
|
|
314
340
|
".dsh-advisor-controls{display:flex;flex:1 1 220px;flex-wrap:wrap;gap:6px;min-width:0;}",
|
|
315
341
|
".dsh-advisor-input,.dsh-advisor-select{flex:1 1 140px;min-width:0;padding:4px 8px;border-radius:6px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.4));background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base,Canvas));color:inherit;font:inherit;}",
|
|
316
342
|
".dsh-advisor-input[type=number]{flex:0 0 120px;}",
|
|
317
343
|
".dsh-advisor-input[type=checkbox]{flex:0 0 auto;width:16px;height:16px;}",
|
|
318
344
|
".dsh-advisor-hint{flex:1 1 100%;font-size:11.5px;color:var(--dsw-alias-label-secondary,GrayText);word-break:break-word;}",
|
|
345
|
+
".dsh-advisor-unit{flex:0 0 auto;font-size:11.5px;color:var(--dsw-alias-label-secondary,GrayText);white-space:nowrap;}",
|
|
346
|
+
".dsh-advisor-off{display:flex;flex-direction:column;gap:4px;padding:8px 10px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));border-radius:8px;background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base,Canvas));}",
|
|
347
|
+
".dsh-advisor-off-title{font-weight:600;}",
|
|
348
|
+
".dsh-advisor-dirty{font-size:12px;color:var(--dsw-alias-state-warning-primary,#b7791f);}",
|
|
349
|
+
".dsh-advisor-disclosure{display:flex;flex-direction:column;gap:4px;}",
|
|
350
|
+
".dsh-advisor-disclosure-toggle{display:flex;align-items:center;gap:6px;width:100%;padding:4px 0;border:0;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer;}",
|
|
351
|
+
".dsh-advisor-disclosure-toggle:hover{color:var(--dsw-alias-label-primary,CanvasText);}",
|
|
352
|
+
".dsh-advisor-caret{flex:0 0 auto;width:12px;font-size:11px;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
353
|
+
".dsh-advisor-disclosure-title{font-size:12px;font-weight:600;letter-spacing:.04em;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
354
|
+
".dsh-advisor-badge{flex:0 0 auto;padding:0 6px;border-radius:999px;background:var(--dsw-alias-bg-layer-2,rgba(128,128,128,.14));color:var(--dsw-alias-label-secondary,GrayText);font-size:10.5px;line-height:16px;font-weight:400;}",
|
|
355
|
+
".dsh-advisor-disclosure-body{display:flex;flex-direction:column;gap:10px;padding:4px 0 2px 16px;border-left:2px solid var(--dsw-alias-border-l2,rgba(128,128,128,.22));}",
|
|
356
|
+
".dsh-advisor-paths{display:flex;flex-direction:column;gap:2px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10.5px;color:var(--dsw-alias-label-secondary,GrayText);word-break:break-all;}",
|
|
357
|
+
".dsh-advisor-more{display:flex;flex-direction:column;gap:4px;font-size:11.5px;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
358
|
+
".dsh-advisor-more p{margin:0;}",
|
|
359
|
+
".dsh-advisor-path{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10.5px;word-break:break-all;}",
|
|
319
360
|
".dsh-advisor-choices{display:flex;flex:1 1 100%;flex-direction:column;gap:6px;}",
|
|
320
361
|
".dsh-advisor-choice{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 8px;cursor:pointer;}",
|
|
321
362
|
".dsh-advisor-choice-label{font-weight:500;}",
|
|
@@ -341,9 +382,13 @@ window.__ModuleLoader__.load({
|
|
|
341
382
|
".dsh-advisor-turn-head:hover{background:var(--dsw-alias-bg-layer-2,rgba(128,128,128,.12));}",
|
|
342
383
|
".dsh-advisor-turn-sev{flex:0 0 auto;font-weight:600;color:var(--dsw-alias-label-primary,CanvasText);}",
|
|
343
384
|
".dsh-advisor-turn-sum{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}",
|
|
385
|
+
".dsh-advisor-turn-time{flex:0 0 auto;font-size:11px;color:var(--dsw-alias-label-secondary,GrayText);opacity:.75;}",
|
|
344
386
|
".dsh-advisor-turn-body{display:flex;flex-direction:column;gap:3px;padding:4px 8px;border-left:2px solid var(--dsw-alias-border-l2,rgba(128,128,128,.35));}",
|
|
345
387
|
".dsh-advisor-turn-advice{white-space:pre-wrap;word-break:break-word;color:var(--dsw-alias-label-primary,CanvasText);}",
|
|
346
388
|
".dsh-advisor-turn-meta{font-size:11.5px;color:var(--dsw-alias-label-secondary,GrayText);word-break:break-word;}",
|
|
389
|
+
".dsh-advisor-turn-preview{display:flex;flex-direction:column;gap:4px;}",
|
|
390
|
+
".dsh-advisor-turn-preview-row{display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;}",
|
|
391
|
+
".dsh-advisor-turn-pre{margin:0;padding:8px 10px;max-height:260px;overflow:auto;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));border-radius:6px;background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base,Canvas));font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;line-height:1.5;white-space:pre-wrap;word-break:break-word;}",
|
|
347
392
|
".dsh-advisor-turn-warn{font-size:11.5px;color:var(--dsw-alias-state-warning-primary,#b7791f);word-break:break-word;}",
|
|
348
393
|
].join("\n");
|
|
349
394
|
|
|
@@ -545,47 +590,94 @@ window.__ModuleLoader__.load({
|
|
|
545
590
|
// 真正的校验仍在宿主(不复制宿主写入逻辑)。
|
|
546
591
|
// ------------------------------------------------------------------
|
|
547
592
|
|
|
548
|
-
/** @type {Record<string,
|
|
593
|
+
/** 与 host 的 DEFAULT_SETTINGS 对齐;数值字段缺失时用它回落。 @type {Record<string, any>} */
|
|
549
594
|
let SETTINGS_DEFAULTS = {
|
|
595
|
+
mode: "off",
|
|
596
|
+
provider: "",
|
|
597
|
+
model: "",
|
|
598
|
+
reasoningEffort: "",
|
|
550
599
|
maxTokens: 4096,
|
|
600
|
+
temperature: null,
|
|
551
601
|
maxCallsPerTurn: 1,
|
|
552
602
|
maxCallsPerSession: 32,
|
|
553
603
|
maxCallsPerHour: 12,
|
|
554
|
-
|
|
604
|
+
currency: "USD",
|
|
605
|
+
usdToCny: 7.2,
|
|
606
|
+
maxCostPerDay: 0,
|
|
555
607
|
priceInputPerMTok: 0,
|
|
556
608
|
priceOutputPerMTok: 0,
|
|
557
|
-
|
|
558
|
-
|
|
609
|
+
privacyScope: "summary",
|
|
610
|
+
redact: true,
|
|
611
|
+
dedupe: true,
|
|
559
612
|
sessionCap: 24,
|
|
613
|
+
allowedModels: [],
|
|
614
|
+
workspaceMaxCallsPerDay: 200,
|
|
615
|
+
workspaceMaxCostPerDay: 0,
|
|
616
|
+
postAnswer: "off",
|
|
617
|
+
advisorTools: false,
|
|
618
|
+
tracePrompt: "preview",
|
|
560
619
|
maxInputChars: 60000,
|
|
561
620
|
};
|
|
562
621
|
|
|
563
|
-
/** 与 settings.js 的
|
|
622
|
+
/** 与 settings.js 的 INT_LIMITS / MONEY_LIMITS 逐项一致;越界在前端先夹一次。 @type {Record<string, number[]>} */
|
|
564
623
|
let SETTINGS_LIMITS = {
|
|
565
624
|
maxTokens: [256, 32000],
|
|
566
625
|
maxCallsPerTurn: [0, 8],
|
|
567
626
|
maxCallsPerSession: [0, 1000],
|
|
568
627
|
maxCallsPerHour: [0, 500],
|
|
569
|
-
|
|
628
|
+
maxCostPerDay: [0, 10000],
|
|
570
629
|
priceInputPerMTok: [0, 1000],
|
|
571
630
|
priceOutputPerMTok: [0, 1000],
|
|
572
631
|
workspaceMaxCallsPerDay: [0, 100000],
|
|
573
|
-
|
|
632
|
+
workspaceMaxCostPerDay: [0, 10000],
|
|
633
|
+
usdToCny: [0.1, 100],
|
|
574
634
|
sessionCap: [0, 200],
|
|
575
635
|
maxInputChars: [4000, 400000],
|
|
576
636
|
};
|
|
577
637
|
|
|
638
|
+
/** 金额字段的小数位;与 settings.js 的 MONEY_LIMITS 一致。 @type {Record<string, number>} */
|
|
639
|
+
let SETTINGS_MONEY_FIELDS = {
|
|
640
|
+
maxCostPerDay: 2,
|
|
641
|
+
workspaceMaxCostPerDay: 2,
|
|
642
|
+
priceInputPerMTok: 4,
|
|
643
|
+
priceOutputPerMTok: 4,
|
|
644
|
+
usdToCny: 4,
|
|
645
|
+
};
|
|
646
|
+
|
|
578
647
|
/** 所有整数输入字段(temperature 单独处理:可为空、可小数)。 */
|
|
579
|
-
let SETTINGS_INT_FIELDS = Object.keys(SETTINGS_LIMITS)
|
|
648
|
+
let SETTINGS_INT_FIELDS = Object.keys(SETTINGS_LIMITS).filter(function isIntField(key) {
|
|
649
|
+
return Object.hasOwn(SETTINGS_MONEY_FIELDS, key) === false;
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
/** 高级区字段:用于「N 项已修改」徽标与「恢复默认」。 */
|
|
653
|
+
let SETTINGS_ADVANCED_FIELDS = [
|
|
654
|
+
"maxCallsPerTurn",
|
|
655
|
+
"maxCallsPerSession",
|
|
656
|
+
"maxCallsPerHour",
|
|
657
|
+
"workspaceMaxCallsPerDay",
|
|
658
|
+
"workspaceMaxCostPerDay",
|
|
659
|
+
"priceInputPerMTok",
|
|
660
|
+
"priceOutputPerMTok",
|
|
661
|
+
"usdToCny",
|
|
662
|
+
"maxTokens",
|
|
663
|
+
"temperature",
|
|
664
|
+
"maxInputChars",
|
|
665
|
+
"sessionCap",
|
|
666
|
+
"allowedModels",
|
|
667
|
+
"postAnswer",
|
|
668
|
+
"advisorTools",
|
|
669
|
+
"tracePrompt",
|
|
670
|
+
"dedupe",
|
|
671
|
+
];
|
|
580
672
|
|
|
581
673
|
/** 0 表示「不限」的预算字段;只影响提示文案。 */
|
|
582
674
|
let SETTINGS_UNLIMITED_FIELDS = [
|
|
583
675
|
"maxCallsPerTurn",
|
|
584
676
|
"maxCallsPerSession",
|
|
585
677
|
"maxCallsPerHour",
|
|
586
|
-
"
|
|
678
|
+
"maxCostPerDay",
|
|
587
679
|
"workspaceMaxCallsPerDay",
|
|
588
|
-
"
|
|
680
|
+
"workspaceMaxCostPerDay",
|
|
589
681
|
];
|
|
590
682
|
|
|
591
683
|
/** 模式与发送范围的白名单,与 settings.js 一致。 */
|
|
@@ -595,6 +687,9 @@ window.__ModuleLoader__.load({
|
|
|
595
687
|
/** 回合结束后的自动徵询方式,与 settings.js 一致。 */
|
|
596
688
|
let SETTINGS_POST_ANSWER = ["off", "card"];
|
|
597
689
|
|
|
690
|
+
/** 「记录发送内容」的取值,与 settings.js 一致。 */
|
|
691
|
+
let SETTINGS_TRACE_PROMPT = ["preview", "off"];
|
|
692
|
+
|
|
598
693
|
/** 卡片读写的字段:保存时只 diff 这些键,绝不把整个设置对象发回去。 */
|
|
599
694
|
let SETTINGS_EDITABLE_FIELDS = [
|
|
600
695
|
"mode",
|
|
@@ -606,11 +701,13 @@ window.__ModuleLoader__.load({
|
|
|
606
701
|
"maxCallsPerTurn",
|
|
607
702
|
"maxCallsPerSession",
|
|
608
703
|
"maxCallsPerHour",
|
|
609
|
-
"
|
|
704
|
+
"currency",
|
|
705
|
+
"usdToCny",
|
|
706
|
+
"maxCostPerDay",
|
|
610
707
|
"priceInputPerMTok",
|
|
611
708
|
"priceOutputPerMTok",
|
|
612
709
|
"workspaceMaxCallsPerDay",
|
|
613
|
-
"
|
|
710
|
+
"workspaceMaxCostPerDay",
|
|
614
711
|
"privacyScope",
|
|
615
712
|
"redact",
|
|
616
713
|
"dedupe",
|
|
@@ -618,11 +715,12 @@ window.__ModuleLoader__.load({
|
|
|
618
715
|
"maxInputChars",
|
|
619
716
|
"postAnswer",
|
|
620
717
|
"advisorTools",
|
|
718
|
+
"tracePrompt",
|
|
621
719
|
"allowedModels",
|
|
622
720
|
];
|
|
623
721
|
|
|
624
722
|
/**
|
|
625
|
-
* 整数夹紧:与 settings.js 的
|
|
723
|
+
* 整数夹紧:与 settings.js 的 clampInt 同语义(取整、非有限值回落)。
|
|
626
724
|
* @param {any} value
|
|
627
725
|
* @param {number} fallback
|
|
628
726
|
* @param {number} min
|
|
@@ -635,6 +733,23 @@ window.__ModuleLoader__.load({
|
|
|
635
733
|
return Math.min(max, Math.max(min, Math.round(n)));
|
|
636
734
|
}
|
|
637
735
|
|
|
736
|
+
/**
|
|
737
|
+
* 金额夹紧:与 settings.js 的 clampMoney 同语义(按固定小数位收口)。
|
|
738
|
+
* @param {any} value
|
|
739
|
+
* @param {number} fallback
|
|
740
|
+
* @param {number} min
|
|
741
|
+
* @param {number} max
|
|
742
|
+
* @param {number} digits
|
|
743
|
+
* @returns {number}
|
|
744
|
+
*/
|
|
745
|
+
function clampMoney(value, fallback, min, max, digits) {
|
|
746
|
+
let n = typeof value === "number" ? value : Number(value);
|
|
747
|
+
if (!Number.isFinite(n)) return fallback;
|
|
748
|
+
let bounded = Math.min(max, Math.max(min, n));
|
|
749
|
+
let factor = 10 ** digits;
|
|
750
|
+
return Math.round(bounded * factor) / factor;
|
|
751
|
+
}
|
|
752
|
+
|
|
638
753
|
/**
|
|
639
754
|
* 可空小数夹紧(temperature):空 / 非数字 → null。
|
|
640
755
|
* @param {any} value
|
|
@@ -650,6 +765,20 @@ window.__ModuleLoader__.load({
|
|
|
650
765
|
return Math.min(max, Math.max(min, n));
|
|
651
766
|
}
|
|
652
767
|
|
|
768
|
+
/**
|
|
769
|
+
* 金额输入框的规范文本:去掉多余的尾零,0 显示成 "0"。
|
|
770
|
+
* @param {any} value
|
|
771
|
+
* @param {number} digits
|
|
772
|
+
* @returns {string}
|
|
773
|
+
*/
|
|
774
|
+
function formatMoneyInput(value, digits) {
|
|
775
|
+
let n = Number(value);
|
|
776
|
+
if (!Number.isFinite(n)) return "0";
|
|
777
|
+
let text = n.toFixed(digits);
|
|
778
|
+
if (text.indexOf(".") >= 0) text = text.replace(/0+$/, "").replace(/\.$/, "");
|
|
779
|
+
return text === "" || text === "-0" ? "0" : text;
|
|
780
|
+
}
|
|
781
|
+
|
|
653
782
|
/**
|
|
654
783
|
* 规整字符串数组(allowedModels / confirmedHosts):去空、去重、截断条数。
|
|
655
784
|
* 与 settings.js 的 normalizeStringList 同语义,前端只用它来显示。
|
|
@@ -689,9 +818,17 @@ window.__ModuleLoader__.load({
|
|
|
689
818
|
temperature: null,
|
|
690
819
|
postAnswer: input.postAnswer === "card" ? "card" : "off",
|
|
691
820
|
advisorTools: input.advisorTools === true,
|
|
821
|
+
tracePrompt: input.tracePrompt === "off" ? "off" : "preview",
|
|
822
|
+
currency: input.currency === "CNY" ? "CNY" : "USD",
|
|
823
|
+
usdToCny: 7.2,
|
|
692
824
|
allowedModels: normalizeStringList(input.allowedModels),
|
|
693
825
|
confirmedHosts: normalizeStringList(input.confirmedHosts),
|
|
694
826
|
};
|
|
827
|
+
let rawRate = Number(input.usdToCny);
|
|
828
|
+
out.usdToCny =
|
|
829
|
+
Number.isFinite(rawRate) && rawRate > 0
|
|
830
|
+
? clampMoney(rawRate, SETTINGS_DEFAULTS.usdToCny, 0.1, 100, 4)
|
|
831
|
+
: SETTINGS_DEFAULTS.usdToCny;
|
|
695
832
|
for (let index = 0; index < SETTINGS_INT_FIELDS.length; index += 1) {
|
|
696
833
|
let key = SETTINGS_INT_FIELDS[index];
|
|
697
834
|
out[key] = clampInt(
|
|
@@ -701,6 +838,16 @@ window.__ModuleLoader__.load({
|
|
|
701
838
|
SETTINGS_LIMITS[key][1],
|
|
702
839
|
);
|
|
703
840
|
}
|
|
841
|
+
for (let key of Object.keys(SETTINGS_MONEY_FIELDS)) {
|
|
842
|
+
if (key === "usdToCny") continue;
|
|
843
|
+
out[key] = clampMoney(
|
|
844
|
+
input[key],
|
|
845
|
+
SETTINGS_DEFAULTS[key],
|
|
846
|
+
SETTINGS_LIMITS[key][0],
|
|
847
|
+
SETTINGS_LIMITS[key][1],
|
|
848
|
+
SETTINGS_MONEY_FIELDS[key],
|
|
849
|
+
);
|
|
850
|
+
}
|
|
704
851
|
out.temperature =
|
|
705
852
|
input.temperature === null || input.temperature === undefined || input.temperature === ""
|
|
706
853
|
? null
|
|
@@ -730,6 +877,80 @@ window.__ModuleLoader__.load({
|
|
|
730
877
|
return n;
|
|
731
878
|
}
|
|
732
879
|
|
|
880
|
+
/**
|
|
881
|
+
* 币种规整:未知值按 USD。
|
|
882
|
+
* @param {any} value
|
|
883
|
+
* @returns {"USD"|"CNY"}
|
|
884
|
+
*/
|
|
885
|
+
function currencyOf(value) {
|
|
886
|
+
return value === "CNY" ? "CNY" : "USD";
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* USD → 设置币种金额;汇率非法时回落 7.2。
|
|
891
|
+
* @param {any} amountUsd
|
|
892
|
+
* @param {any} currency
|
|
893
|
+
* @param {any} rate
|
|
894
|
+
* @returns {number}
|
|
895
|
+
*/
|
|
896
|
+
function fromUsd(amountUsd, currency, rate) {
|
|
897
|
+
let n = Number(amountUsd);
|
|
898
|
+
if (!Number.isFinite(n)) return 0;
|
|
899
|
+
if (currencyOf(currency) === "USD") return n;
|
|
900
|
+
let r = Number(rate);
|
|
901
|
+
if (!Number.isFinite(r) || r <= 0) r = 7.2;
|
|
902
|
+
return n * r;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* 金额显示:USD 用 $,CNY 用 ¥。
|
|
907
|
+
* @param {any} amount
|
|
908
|
+
* @param {any} currency
|
|
909
|
+
* @param {number} [digits]
|
|
910
|
+
* @returns {string}
|
|
911
|
+
*/
|
|
912
|
+
function formatMoney(amount, currency, digits) {
|
|
913
|
+
let n = Number(amount);
|
|
914
|
+
let value = Number.isFinite(n) ? n : 0;
|
|
915
|
+
let places =
|
|
916
|
+
typeof digits === "number" && Number.isFinite(digits)
|
|
917
|
+
? Math.max(0, Math.min(8, Math.round(digits)))
|
|
918
|
+
: 4;
|
|
919
|
+
return `${currencyOf(currency) === "CNY" ? "¥" : "$"}${value.toFixed(places)}`;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* 把草稿里的金额字段从当前币种换到目标币种,保持真实价值不变。
|
|
924
|
+
* 汇率是 1 USD = ? CNY;切换时用当前草稿里的汇率。
|
|
925
|
+
* @param {any} source
|
|
926
|
+
* @param {any} nextCurrency
|
|
927
|
+
* @returns {any}
|
|
928
|
+
*/
|
|
929
|
+
function convertCurrency(source, nextCurrency) {
|
|
930
|
+
let from = currencyOf(source.currency);
|
|
931
|
+
let to = currencyOf(nextCurrency);
|
|
932
|
+
let next = Object.assign({}, source, { currency: to });
|
|
933
|
+
if (from === to) return next;
|
|
934
|
+
let rate = Number(source.usdToCny);
|
|
935
|
+
if (!Number.isFinite(rate) || rate <= 0) rate = 7.2;
|
|
936
|
+
let factor = to === "CNY" ? rate : 1 / rate;
|
|
937
|
+
/** @type {Record<string, number>} */
|
|
938
|
+
let fields = {
|
|
939
|
+
maxCostPerDay: 2,
|
|
940
|
+
workspaceMaxCostPerDay: 2,
|
|
941
|
+
priceInputPerMTok: 4,
|
|
942
|
+
priceOutputPerMTok: 4,
|
|
943
|
+
};
|
|
944
|
+
for (let key of Object.keys(fields)) {
|
|
945
|
+
let n = Number(source[key]);
|
|
946
|
+
if (!Number.isFinite(n)) n = 0;
|
|
947
|
+
let digits = fields[key];
|
|
948
|
+
let scale = 10 ** digits;
|
|
949
|
+
next[key] = Math.round(n * factor * scale) / scale;
|
|
950
|
+
}
|
|
951
|
+
return next;
|
|
952
|
+
}
|
|
953
|
+
|
|
733
954
|
/**
|
|
734
955
|
* 校验 `advisor/options`:settings 必须可用,其余字段缺失时降级为空。
|
|
735
956
|
* 畸形一律 null(调用方显示内联错误 + 重试)。
|
|
@@ -804,6 +1025,7 @@ window.__ModuleLoader__.load({
|
|
|
804
1025
|
: null,
|
|
805
1026
|
lastSkip: asString(raw.lastSkip).trim(),
|
|
806
1027
|
ledgerPath: asString(raw.ledgerPath).trim(),
|
|
1028
|
+
settingsPath: asString(raw.settingsPath).trim(),
|
|
807
1029
|
};
|
|
808
1030
|
}
|
|
809
1031
|
|
|
@@ -1043,6 +1265,11 @@ window.__ModuleLoader__.load({
|
|
|
1043
1265
|
summary: asString(item.summary),
|
|
1044
1266
|
model: asString(item.model).trim(),
|
|
1045
1267
|
usage: asString(item.usage).trim(),
|
|
1268
|
+
at: countOf(item.at),
|
|
1269
|
+
trigger: asString(item.trigger).trim(),
|
|
1270
|
+
requestChars: countOf(item.requestChars),
|
|
1271
|
+
requestPreview: asString(item.requestPreview),
|
|
1272
|
+
requestPreviewTruncated: item.requestPreviewTruncated === true,
|
|
1046
1273
|
anchors:
|
|
1047
1274
|
anchorsRaw === null
|
|
1048
1275
|
? null
|
|
@@ -1074,6 +1301,60 @@ window.__ModuleLoader__.load({
|
|
|
1074
1301
|
return String(Math.round(n)).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
1075
1302
|
}
|
|
1076
1303
|
|
|
1304
|
+
/** 触发方式白名单;未知值归到 other。 */
|
|
1305
|
+
let ADVICE_TRIGGERS = ["tool", "shadow", "manual", "post-answer"];
|
|
1306
|
+
|
|
1307
|
+
/**
|
|
1308
|
+
* 触发方式的本地化标签。
|
|
1309
|
+
* @param {(key: string) => string} t
|
|
1310
|
+
* @param {string} trigger
|
|
1311
|
+
* @returns {string}
|
|
1312
|
+
*/
|
|
1313
|
+
function triggerLabel(t, trigger) {
|
|
1314
|
+
let key =
|
|
1315
|
+
trigger === "post-answer"
|
|
1316
|
+
? "postAnswer"
|
|
1317
|
+
: ADVICE_TRIGGERS.indexOf(trigger) >= 0
|
|
1318
|
+
? trigger
|
|
1319
|
+
: "other";
|
|
1320
|
+
return t(`tail.trigger.${key}`);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
/**
|
|
1324
|
+
* 本地时间 HH:mm;无效/缺失返回空串。
|
|
1325
|
+
* @param {any} epochMs
|
|
1326
|
+
* @returns {string}
|
|
1327
|
+
*/
|
|
1328
|
+
function formatClock(epochMs) {
|
|
1329
|
+
let n = Number(epochMs);
|
|
1330
|
+
if (!Number.isFinite(n) || n <= 0) return "";
|
|
1331
|
+
let date = new Date(n);
|
|
1332
|
+
let hours = String(date.getHours()).padStart(2, "0");
|
|
1333
|
+
let minutes = String(date.getMinutes()).padStart(2, "0");
|
|
1334
|
+
return `${hours}:${minutes}`;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
/**
|
|
1338
|
+
* 顾问线展开后的「本次徵询」摘要:触发方式 · 时间 · 模型 · 字符数 · 用量/成本。
|
|
1339
|
+
* @param {any} record
|
|
1340
|
+
* @param {(key: string) => string} t
|
|
1341
|
+
* @returns {string}
|
|
1342
|
+
*/
|
|
1343
|
+
function traceTextOf(record, t) {
|
|
1344
|
+
let parts = [];
|
|
1345
|
+
let trigger = asString(record.trigger).trim();
|
|
1346
|
+
if (trigger !== "") parts.push(triggerLabel(t, trigger));
|
|
1347
|
+
let clock = formatClock(record.at);
|
|
1348
|
+
if (clock !== "") parts.push(clock);
|
|
1349
|
+
let model = asString(record.model).trim();
|
|
1350
|
+
if (model !== "") parts.push(model);
|
|
1351
|
+
let chars = countOf(record.requestChars);
|
|
1352
|
+
if (chars > 0) parts.push(t("tail.trace.chars").replace("{chars}", formatCount(chars)));
|
|
1353
|
+
let usage = asString(record.usage).trim();
|
|
1354
|
+
if (usage !== "") parts.push(usage);
|
|
1355
|
+
return parts.join(" · ");
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1077
1358
|
/**
|
|
1078
1359
|
* 极简 store:组件用 useSyncExternalStore 订阅,写入方直接 set。
|
|
1079
1360
|
* @param {any} initial
|
|
@@ -1200,6 +1481,9 @@ window.__ModuleLoader__.load({
|
|
|
1200
1481
|
let expandedState = React.useState(false);
|
|
1201
1482
|
let expanded = expandedState[0];
|
|
1202
1483
|
let setExpanded = expandedState[1];
|
|
1484
|
+
let previewState = React.useState(false);
|
|
1485
|
+
let previewOpen = previewState[0];
|
|
1486
|
+
let setPreviewOpen = previewState[1];
|
|
1203
1487
|
|
|
1204
1488
|
// 一次拉全量并按 sessionId 缓存;props.turn 变化不重拉。失败静默(不 toast、不弹错)。
|
|
1205
1489
|
React.useEffect(
|
|
@@ -1286,6 +1570,7 @@ window.__ModuleLoader__.load({
|
|
|
1286
1570
|
60,
|
|
1287
1571
|
);
|
|
1288
1572
|
let severityLabel = t(`tail.severity.${severity}`);
|
|
1573
|
+
let clock = formatClock(record.at);
|
|
1289
1574
|
|
|
1290
1575
|
/** @type {any[]} */
|
|
1291
1576
|
let headChildren = [];
|
|
@@ -1307,6 +1592,19 @@ window.__ModuleLoader__.load({
|
|
|
1307
1592
|
);
|
|
1308
1593
|
}
|
|
1309
1594
|
}
|
|
1595
|
+
if (clock !== "") {
|
|
1596
|
+
headChildren.push(
|
|
1597
|
+
h(
|
|
1598
|
+
"span",
|
|
1599
|
+
{
|
|
1600
|
+
className: "dsh-advisor-turn-time",
|
|
1601
|
+
key: "time",
|
|
1602
|
+
title: new Date(record.at).toLocaleString(),
|
|
1603
|
+
},
|
|
1604
|
+
clock,
|
|
1605
|
+
),
|
|
1606
|
+
);
|
|
1607
|
+
}
|
|
1310
1608
|
|
|
1311
1609
|
/** @type {any[]} */
|
|
1312
1610
|
let bodyChildren = [
|
|
@@ -1316,11 +1614,60 @@ window.__ModuleLoader__.load({
|
|
|
1316
1614
|
asString(record.advice) === "" ? t("tail.empty") : record.advice,
|
|
1317
1615
|
),
|
|
1318
1616
|
];
|
|
1319
|
-
let
|
|
1320
|
-
|
|
1321
|
-
.
|
|
1322
|
-
|
|
1323
|
-
|
|
1617
|
+
let traceText = traceTextOf(record, t);
|
|
1618
|
+
if (traceText !== "") {
|
|
1619
|
+
bodyChildren.push(
|
|
1620
|
+
h(
|
|
1621
|
+
"div",
|
|
1622
|
+
{ className: "dsh-advisor-turn-meta", "data-advisor-trace": "", key: "trace" },
|
|
1623
|
+
`${t("tail.trace.label")}${t("tail.trace.sep")}${traceText}`,
|
|
1624
|
+
),
|
|
1625
|
+
);
|
|
1626
|
+
}
|
|
1627
|
+
let requestPreview = asString(record.requestPreview);
|
|
1628
|
+
if (requestPreview !== "") {
|
|
1629
|
+
let previewChars = countOf(record.requestChars);
|
|
1630
|
+
let previewNote =
|
|
1631
|
+
record.requestPreviewTruncated === true
|
|
1632
|
+
? t("tail.trace.previewTruncated").replace("{chars}", formatCount(previewChars))
|
|
1633
|
+
: t("tail.trace.previewFull").replace("{chars}", formatCount(previewChars));
|
|
1634
|
+
bodyChildren.push(
|
|
1635
|
+
h("div", { className: "dsh-advisor-turn-preview", key: "preview" }, [
|
|
1636
|
+
h("div", { className: "dsh-advisor-turn-preview-row", key: "row" }, [
|
|
1637
|
+
h("span", { className: "dsh-advisor-turn-meta", key: "note" }, previewNote),
|
|
1638
|
+
h(
|
|
1639
|
+
"button",
|
|
1640
|
+
{
|
|
1641
|
+
className: "dsh-advisor-btn",
|
|
1642
|
+
"data-advisor-preview-toggle": "",
|
|
1643
|
+
key: "toggle",
|
|
1644
|
+
onClick: function togglePreview() {
|
|
1645
|
+
setPreviewOpen(function flip(/** @type {boolean} */ prev) {
|
|
1646
|
+
return !prev;
|
|
1647
|
+
});
|
|
1648
|
+
},
|
|
1649
|
+
type: "button",
|
|
1650
|
+
},
|
|
1651
|
+
previewOpen ? t("tail.trace.previewHide") : t("tail.trace.preview"),
|
|
1652
|
+
),
|
|
1653
|
+
]),
|
|
1654
|
+
previewOpen
|
|
1655
|
+
? h(
|
|
1656
|
+
"pre",
|
|
1657
|
+
{ className: "dsh-advisor-turn-pre", "data-advisor-preview": "", key: "pre" },
|
|
1658
|
+
requestPreview,
|
|
1659
|
+
)
|
|
1660
|
+
: null,
|
|
1661
|
+
]),
|
|
1662
|
+
);
|
|
1663
|
+
} else if (countOf(record.requestChars) > 0) {
|
|
1664
|
+
bodyChildren.push(
|
|
1665
|
+
h(
|
|
1666
|
+
"div",
|
|
1667
|
+
{ className: "dsh-advisor-turn-meta", key: "previewNone" },
|
|
1668
|
+
t("tail.trace.previewNone"),
|
|
1669
|
+
),
|
|
1670
|
+
);
|
|
1324
1671
|
}
|
|
1325
1672
|
let anchors = record.anchors;
|
|
1326
1673
|
if (anchors && typeof anchors === "object") {
|
|
@@ -1350,6 +1697,7 @@ window.__ModuleLoader__.load({
|
|
|
1350
1697
|
className: "dsh-advisor-turn",
|
|
1351
1698
|
"data-advisor-turn": String(turnNumber),
|
|
1352
1699
|
"data-advisor-status": declined ? "declined" : "reviewed",
|
|
1700
|
+
"data-advisor-trigger": asString(record.trigger).trim(),
|
|
1353
1701
|
},
|
|
1354
1702
|
[
|
|
1355
1703
|
h(
|
|
@@ -1389,6 +1737,13 @@ window.__ModuleLoader__.load({
|
|
|
1389
1737
|
// 设置页卡片(settings.general.item)
|
|
1390
1738
|
// ------------------------------------------------------------------
|
|
1391
1739
|
|
|
1740
|
+
/**
|
|
1741
|
+
* 设置卡折叠/帮助的 UI 状态。放在组件外:宿主重渲染设置槽位时组件可能重挂,
|
|
1742
|
+
* 但用户已经展开的高级区不应该被悄悄收起;页面刷新才复位。
|
|
1743
|
+
*/
|
|
1744
|
+
/** @type {Record<string, any>} */
|
|
1745
|
+
let settingsUiState = { advanced: false, status: false, off: false, help: "" };
|
|
1746
|
+
|
|
1392
1747
|
/**
|
|
1393
1748
|
* 设置页 → 通用 的「顾问」卡片。`settings.general.item` 是无 owner props 的 list 槽,
|
|
1394
1749
|
* sessionId 拿不到时传空串(宿主只跳过按会话的字段);数据全部经 props.api 现取。
|
|
@@ -1451,6 +1806,46 @@ window.__ModuleLoader__.load({
|
|
|
1451
1806
|
let previewOpenState = React.useState(false);
|
|
1452
1807
|
let previewOpen = previewOpenState[0];
|
|
1453
1808
|
let setPreviewOpen = previewOpenState[1];
|
|
1809
|
+
/** 高级设置默认折叠;状态与诊断再单独一层。 */
|
|
1810
|
+
/**
|
|
1811
|
+
* 折叠/帮助状态用模块级缓存做初值,组件重挂载时不会把已展开的高级区收起。
|
|
1812
|
+
* @param {string} key
|
|
1813
|
+
* @param {any} initial
|
|
1814
|
+
* @returns {[any, (next: any) => void]}
|
|
1815
|
+
*/
|
|
1816
|
+
function useUiState(key, initial) {
|
|
1817
|
+
let state = React.useState(
|
|
1818
|
+
settingsUiState[key] === undefined ? initial : settingsUiState[key],
|
|
1819
|
+
);
|
|
1820
|
+
let value = state[0];
|
|
1821
|
+
let setValue = state[1];
|
|
1822
|
+
let set = React.useCallback(
|
|
1823
|
+
function update(/** @type {any} */ next) {
|
|
1824
|
+
setValue(function apply(/** @type {any} */ prev) {
|
|
1825
|
+
let resolved = typeof next === "function" ? next(prev) : next;
|
|
1826
|
+
settingsUiState[key] = resolved;
|
|
1827
|
+
return resolved;
|
|
1828
|
+
});
|
|
1829
|
+
},
|
|
1830
|
+
[key],
|
|
1831
|
+
);
|
|
1832
|
+
return [value, set];
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
let advancedState = useUiState("advanced", false);
|
|
1836
|
+
let advancedOpen = advancedState[0];
|
|
1837
|
+
let setAdvancedOpen = advancedState[1];
|
|
1838
|
+
let statusState = useUiState("status", false);
|
|
1839
|
+
let statusOpen = statusState[0];
|
|
1840
|
+
let setStatusOpen = statusState[1];
|
|
1841
|
+
/** off 时也可以显式展开配置;默认收起。 */
|
|
1842
|
+
let offExpandState = useUiState("off", false);
|
|
1843
|
+
let offExpanded = offExpandState[0];
|
|
1844
|
+
let setOffExpanded = offExpandState[1];
|
|
1845
|
+
/** 同一时间只展开一个字段的说明。 */
|
|
1846
|
+
let helpState = useUiState("help", "");
|
|
1847
|
+
let openHelp = helpState[0];
|
|
1848
|
+
let setOpenHelp = helpState[1];
|
|
1454
1849
|
/** provider/model 切换可能并发:只接受最后一次请求的返回。 */
|
|
1455
1850
|
let modelsSeq = React.useRef(0);
|
|
1456
1851
|
let infoSeq = React.useRef(0);
|
|
@@ -1492,6 +1887,9 @@ window.__ModuleLoader__.load({
|
|
|
1492
1887
|
let key = SETTINGS_INT_FIELDS[index];
|
|
1493
1888
|
out[key] = String(settings[key]);
|
|
1494
1889
|
}
|
|
1890
|
+
for (let key of Object.keys(SETTINGS_MONEY_FIELDS)) {
|
|
1891
|
+
out[key] = formatMoneyInput(settings[key], SETTINGS_MONEY_FIELDS[key]);
|
|
1892
|
+
}
|
|
1495
1893
|
out.temperature = settings.temperature === null ? "" : String(settings.temperature);
|
|
1496
1894
|
out.allowedModels = normalizeStringList(settings.allowedModels).join(", ");
|
|
1497
1895
|
return out;
|
|
@@ -1670,6 +2068,19 @@ window.__ModuleLoader__.load({
|
|
|
1670
2068
|
if (text === "") continue;
|
|
1671
2069
|
next[key] = clampInt(text, next[key], SETTINGS_LIMITS[key][0], SETTINGS_LIMITS[key][1]);
|
|
1672
2070
|
}
|
|
2071
|
+
for (let key of Object.keys(SETTINGS_MONEY_FIELDS)) {
|
|
2072
|
+
let raw = texts[key];
|
|
2073
|
+
if (typeof raw !== "string") continue;
|
|
2074
|
+
let text = raw.trim();
|
|
2075
|
+
if (text === "") continue;
|
|
2076
|
+
next[key] = clampMoney(
|
|
2077
|
+
text,
|
|
2078
|
+
next[key],
|
|
2079
|
+
SETTINGS_LIMITS[key][0],
|
|
2080
|
+
SETTINGS_LIMITS[key][1],
|
|
2081
|
+
SETTINGS_MONEY_FIELDS[key],
|
|
2082
|
+
);
|
|
2083
|
+
}
|
|
1673
2084
|
if (typeof texts.temperature === "string") {
|
|
1674
2085
|
let tempText = texts.temperature.trim();
|
|
1675
2086
|
next.temperature = tempText === "" ? null : clampFloat(tempText, null, 0, 2);
|
|
@@ -1696,14 +2107,24 @@ window.__ModuleLoader__.load({
|
|
|
1696
2107
|
);
|
|
1697
2108
|
return;
|
|
1698
2109
|
}
|
|
2110
|
+
let limit = SETTINGS_LIMITS[key];
|
|
2111
|
+
let digits = SETTINGS_MONEY_FIELDS[key];
|
|
1699
2112
|
if (text === "") {
|
|
1700
|
-
|
|
2113
|
+
let restored =
|
|
2114
|
+
digits === undefined ? String(draft[key]) : formatMoneyInput(draft[key], digits);
|
|
2115
|
+
setTexts(Object.assign({}, texts, { [key]: restored }));
|
|
1701
2116
|
return;
|
|
1702
2117
|
}
|
|
1703
|
-
let
|
|
1704
|
-
|
|
2118
|
+
let value =
|
|
2119
|
+
digits === undefined
|
|
2120
|
+
? clampInt(text, draft[key], limit[0], limit[1])
|
|
2121
|
+
: clampMoney(text, draft[key], limit[0], limit[1], digits);
|
|
1705
2122
|
setDraft(Object.assign({}, draft, { [key]: value }));
|
|
1706
|
-
setTexts(
|
|
2123
|
+
setTexts(
|
|
2124
|
+
Object.assign({}, texts, {
|
|
2125
|
+
[key]: digits === undefined ? String(value) : formatMoneyInput(value, digits),
|
|
2126
|
+
}),
|
|
2127
|
+
);
|
|
1707
2128
|
}
|
|
1708
2129
|
|
|
1709
2130
|
/** 保存:只发改过的字段,成功后用返回值刷新本地状态。 */
|
|
@@ -1956,6 +2377,8 @@ window.__ModuleLoader__.load({
|
|
|
1956
2377
|
function chooseMode(mode) {
|
|
1957
2378
|
if (!draft) return;
|
|
1958
2379
|
setDraft(Object.assign({}, draft, { mode: mode }));
|
|
2380
|
+
// 切回 off 时回到紧凑态;切到其它模式时保持/展开基础设置。
|
|
2381
|
+
if (mode === "off") setOffExpanded(false);
|
|
1959
2382
|
}
|
|
1960
2383
|
|
|
1961
2384
|
/** @param {string} scope */
|
|
@@ -1974,6 +2397,59 @@ window.__ModuleLoader__.load({
|
|
|
1974
2397
|
);
|
|
1975
2398
|
}
|
|
1976
2399
|
|
|
2400
|
+
/** @param {string} value */
|
|
2401
|
+
function chooseTracePrompt(value) {
|
|
2402
|
+
if (!draft) return;
|
|
2403
|
+
setDraft(
|
|
2404
|
+
Object.assign({}, draft, {
|
|
2405
|
+
tracePrompt: SETTINGS_TRACE_PROMPT.indexOf(value) >= 0 ? value : "preview",
|
|
2406
|
+
}),
|
|
2407
|
+
);
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
/** 切换币种:按当前汇率折算金额,保持真实价值不变。 @param {string} value */
|
|
2411
|
+
function chooseCurrency(value) {
|
|
2412
|
+
if (!draft) return;
|
|
2413
|
+
let nextCurrency = currencyOf(value);
|
|
2414
|
+
if (nextCurrency === draft.currency) return;
|
|
2415
|
+
let next = convertCurrency(draft, nextCurrency);
|
|
2416
|
+
setDraft(next);
|
|
2417
|
+
setTexts(textsOf(next));
|
|
2418
|
+
setError(null);
|
|
2419
|
+
setNotice(
|
|
2420
|
+
t("settings.currency.converted")
|
|
2421
|
+
.replace("{currency}", nextCurrency)
|
|
2422
|
+
.replace("{rate}", String(next.usdToCny)),
|
|
2423
|
+
);
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
/** 金额字段的币种单位。 @returns {string} */
|
|
2427
|
+
function currencyLabel() {
|
|
2428
|
+
return draft !== null && draft.currency === "CNY"
|
|
2429
|
+
? t("settings.unit.cny")
|
|
2430
|
+
: t("settings.unit.usd");
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
/** 单价的币种单位。 @returns {string} */
|
|
2434
|
+
function priceUnit() {
|
|
2435
|
+
return draft !== null && draft.currency === "CNY"
|
|
2436
|
+
? t("settings.unit.cnyPerMTok")
|
|
2437
|
+
: t("settings.unit.usdPerMTok");
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
/** 币种一行。 @returns {any} */
|
|
2441
|
+
function currencyField() {
|
|
2442
|
+
return selectField(
|
|
2443
|
+
"currency",
|
|
2444
|
+
"settings.currency",
|
|
2445
|
+
["USD", "CNY"],
|
|
2446
|
+
"settings.currency.",
|
|
2447
|
+
draft.currency,
|
|
2448
|
+
chooseCurrency,
|
|
2449
|
+
{ hint: t("settings.currencyHint") },
|
|
2450
|
+
);
|
|
2451
|
+
}
|
|
2452
|
+
|
|
1977
2453
|
/**
|
|
1978
2454
|
* @param {string} key
|
|
1979
2455
|
* @param {boolean} on
|
|
@@ -2024,214 +2500,267 @@ window.__ModuleLoader__.load({
|
|
|
2024
2500
|
}
|
|
2025
2501
|
|
|
2026
2502
|
/**
|
|
2027
|
-
*
|
|
2028
|
-
* @param {string}
|
|
2029
|
-
* @param {
|
|
2030
|
-
* @param {string[]} values
|
|
2031
|
-
* @param {string} prefix
|
|
2032
|
-
* @param {string} current
|
|
2033
|
-
* @param {(value: string) => void} onPick
|
|
2503
|
+
* 高级区里的小分组标题。
|
|
2504
|
+
* @param {string} titleKey
|
|
2505
|
+
* @param {any[]} children
|
|
2034
2506
|
* @param {string} key
|
|
2035
2507
|
* @returns {any}
|
|
2036
2508
|
*/
|
|
2037
|
-
function
|
|
2038
|
-
let choices = values.map(function renderChoice(/** @type {string} */ value) {
|
|
2039
|
-
return h("label", { className: "dsh-advisor-choice", key: value }, [
|
|
2040
|
-
h("input", {
|
|
2041
|
-
checked: current === value,
|
|
2042
|
-
key: "input",
|
|
2043
|
-
name: `advisor-${name}`,
|
|
2044
|
-
onChange: function onChoice() {
|
|
2045
|
-
onPick(value);
|
|
2046
|
-
},
|
|
2047
|
-
type: "radio",
|
|
2048
|
-
value: value,
|
|
2049
|
-
}),
|
|
2050
|
-
h("span", { className: "dsh-advisor-choice-label", key: "label" }, t(prefix + value)),
|
|
2051
|
-
h(
|
|
2052
|
-
"span",
|
|
2053
|
-
{ className: "dsh-advisor-choice-hint", key: "hint" },
|
|
2054
|
-
t(`${prefix}${value}Hint`),
|
|
2055
|
-
),
|
|
2056
|
-
]);
|
|
2057
|
-
});
|
|
2509
|
+
function subgroup(titleKey, children, key) {
|
|
2058
2510
|
return h(
|
|
2059
2511
|
"div",
|
|
2060
|
-
{
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2512
|
+
{ className: "dsh-advisor-subgroup", key: key },
|
|
2513
|
+
[h("div", { className: "dsh-advisor-subgroup-title", key: "title" }, t(titleKey))].concat(
|
|
2514
|
+
children,
|
|
2515
|
+
),
|
|
2516
|
+
);
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
/**
|
|
2520
|
+
* 字段外壳:label + 可选「?」帮助按钮 + 控件 + 可选内联提示。
|
|
2521
|
+
* 帮助说明只在点开时渲染,避免每个字段常驻两三行说明把页面撑长。
|
|
2522
|
+
* @param {string} key
|
|
2523
|
+
* @param {string} labelKey
|
|
2524
|
+
* @param {any[]} controlNodes
|
|
2525
|
+
* @param {{ controlId?: string, hint?: string, helpText?: string, metaText?: string }} [options]
|
|
2526
|
+
* @returns {any}
|
|
2527
|
+
*/
|
|
2528
|
+
function fieldShell(key, labelKey, controlNodes, options) {
|
|
2529
|
+
let opts = options === undefined ? {} : options;
|
|
2530
|
+
let controlId = typeof opts.controlId === "string" ? opts.controlId : `dsh-advisor-${key}`;
|
|
2531
|
+
let helpText = typeof opts.helpText === "string" ? opts.helpText : "";
|
|
2532
|
+
let metaText = typeof opts.metaText === "string" ? opts.metaText : "";
|
|
2533
|
+
let hint = typeof opts.hint === "string" ? opts.hint : "";
|
|
2534
|
+
let helpId = `dsh-advisor-help-${key}`;
|
|
2535
|
+
let isHelpOpen = openHelp === key;
|
|
2536
|
+
let labelChildren = [
|
|
2537
|
+
h(
|
|
2538
|
+
"label",
|
|
2539
|
+
{ className: "dsh-advisor-label", htmlFor: controlId, key: "label" },
|
|
2540
|
+
t(labelKey),
|
|
2541
|
+
),
|
|
2542
|
+
];
|
|
2543
|
+
if (helpText !== "") {
|
|
2544
|
+
labelChildren.push(
|
|
2067
2545
|
h(
|
|
2068
|
-
"
|
|
2546
|
+
"button",
|
|
2069
2547
|
{
|
|
2070
|
-
"aria-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2548
|
+
"aria-controls": isHelpOpen ? helpId : undefined,
|
|
2549
|
+
"aria-expanded": isHelpOpen ? "true" : "false",
|
|
2550
|
+
"aria-label": t("settings.help.open").replace("{field}", t(labelKey)),
|
|
2551
|
+
className: "dsh-advisor-help-btn",
|
|
2552
|
+
key: "help",
|
|
2553
|
+
onClick: function toggleHelp() {
|
|
2554
|
+
setOpenHelp(isHelpOpen ? "" : key);
|
|
2555
|
+
},
|
|
2556
|
+
onKeyDown: function closeHelp(/** @type {any} */ event) {
|
|
2557
|
+
if (event && event.key === "Escape") setOpenHelp("");
|
|
2558
|
+
},
|
|
2559
|
+
title: t("settings.help.open").replace("{field}", t(labelKey)),
|
|
2560
|
+
type: "button",
|
|
2074
2561
|
},
|
|
2075
|
-
|
|
2562
|
+
"?",
|
|
2076
2563
|
),
|
|
2077
|
-
|
|
2564
|
+
);
|
|
2565
|
+
}
|
|
2566
|
+
let rowChildren = [
|
|
2567
|
+
h("div", { className: "dsh-advisor-label-wrap", key: "labelWrap" }, labelChildren),
|
|
2568
|
+
].concat(controlNodes);
|
|
2569
|
+
if (hint !== "") {
|
|
2570
|
+
rowChildren.push(h("span", { className: "dsh-advisor-hint", key: "hint" }, hint));
|
|
2571
|
+
}
|
|
2572
|
+
let children = [
|
|
2573
|
+
h(
|
|
2574
|
+
"div",
|
|
2575
|
+
{ className: "dsh-advisor-row", "data-advisor-row": key, key: "row" },
|
|
2576
|
+
rowChildren,
|
|
2577
|
+
),
|
|
2578
|
+
];
|
|
2579
|
+
if (helpText !== "" && isHelpOpen) {
|
|
2580
|
+
let helpChildren = [h("p", { key: "text" }, helpText)];
|
|
2581
|
+
if (metaText !== "") {
|
|
2582
|
+
helpChildren.push(
|
|
2583
|
+
h("p", { className: "dsh-advisor-help-meta", key: "meta" }, metaText),
|
|
2584
|
+
);
|
|
2585
|
+
}
|
|
2586
|
+
helpChildren.push(
|
|
2587
|
+
h(
|
|
2588
|
+
"p",
|
|
2589
|
+
{ className: "dsh-advisor-help-tech", key: "tech" },
|
|
2590
|
+
t("settings.help.tech").replace("{key}", key),
|
|
2591
|
+
),
|
|
2592
|
+
);
|
|
2593
|
+
children.push(
|
|
2594
|
+
h(
|
|
2595
|
+
"div",
|
|
2596
|
+
{ className: "dsh-advisor-help-body", id: helpId, key: "helpBody", role: "note" },
|
|
2597
|
+
helpChildren,
|
|
2598
|
+
),
|
|
2599
|
+
);
|
|
2600
|
+
}
|
|
2601
|
+
return h(
|
|
2602
|
+
"div",
|
|
2603
|
+
{ className: "dsh-advisor-field", "data-advisor-field": key, key: key },
|
|
2604
|
+
children,
|
|
2078
2605
|
);
|
|
2079
2606
|
}
|
|
2080
2607
|
|
|
2081
2608
|
/**
|
|
2082
|
-
*
|
|
2609
|
+
* 默认值 + 范围提示;数值字段共用。
|
|
2083
2610
|
* @param {string} key
|
|
2084
|
-
* @
|
|
2085
|
-
* @param {string} extraHint 已翻译的前缀说明,可为空串
|
|
2086
|
-
* @returns {any}
|
|
2611
|
+
* @returns {string}
|
|
2087
2612
|
*/
|
|
2088
|
-
function
|
|
2613
|
+
function rangeText(key) {
|
|
2089
2614
|
let limit = SETTINGS_LIMITS[key];
|
|
2090
2615
|
let rangeKey =
|
|
2091
2616
|
SETTINGS_UNLIMITED_FIELDS.indexOf(key) >= 0
|
|
2092
2617
|
? "settings.budget.rangeUnlimited"
|
|
2093
2618
|
: "settings.budget.range";
|
|
2094
|
-
|
|
2619
|
+
return t(rangeKey)
|
|
2095
2620
|
.replace("{default}", String(SETTINGS_DEFAULTS[key]))
|
|
2096
2621
|
.replace("{min}", String(limit[0]))
|
|
2097
2622
|
.replace("{max}", String(limit[1]));
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
})
|
|
2125
|
-
|
|
2126
|
-
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
/**
|
|
2626
|
+
* 数字输入 + 可选单位 + 可选帮助说明。
|
|
2627
|
+
* @param {string} key
|
|
2628
|
+
* @param {string} labelKey
|
|
2629
|
+
* @param {{ hint?: string, help?: string, unit?: string }} [options]
|
|
2630
|
+
* @returns {any}
|
|
2631
|
+
*/
|
|
2632
|
+
function numberField(key, labelKey, options) {
|
|
2633
|
+
let opts = options === undefined ? {} : options;
|
|
2634
|
+
let limit = SETTINGS_LIMITS[key];
|
|
2635
|
+
let digits = SETTINGS_MONEY_FIELDS[key];
|
|
2636
|
+
let step = digits === 2 ? "0.01" : digits === 4 ? "0.001" : "1";
|
|
2637
|
+
let helpText = typeof opts.help === "string" ? opts.help : "";
|
|
2638
|
+
let hint = typeof opts.hint === "string" ? opts.hint : "";
|
|
2639
|
+
if (helpText === "" && hint === "") hint = rangeText(key);
|
|
2640
|
+
let control = h("input", {
|
|
2641
|
+
className: "dsh-advisor-input",
|
|
2642
|
+
id: `dsh-advisor-${key}`,
|
|
2643
|
+
key: "input",
|
|
2644
|
+
max: String(limit[1]),
|
|
2645
|
+
min: String(limit[0]),
|
|
2646
|
+
onBlur: function onNumberBlur() {
|
|
2647
|
+
commitOne(key);
|
|
2648
|
+
},
|
|
2649
|
+
onChange: function onNumberChange(/** @type {any} */ event) {
|
|
2650
|
+
let value = String(event.target.value);
|
|
2651
|
+
setTexts(function mergeNumber(/** @type {any} */ prev) {
|
|
2652
|
+
return Object.assign({}, prev, { [key]: value });
|
|
2653
|
+
});
|
|
2654
|
+
},
|
|
2655
|
+
inputMode: digits === undefined ? "numeric" : "decimal",
|
|
2656
|
+
step: step,
|
|
2657
|
+
type: "number",
|
|
2658
|
+
value: typeof texts[key] === "string" ? texts[key] : "",
|
|
2659
|
+
});
|
|
2660
|
+
let controls = [control];
|
|
2661
|
+
if (typeof opts.unit === "string" && opts.unit !== "") {
|
|
2662
|
+
controls.push(h("span", { className: "dsh-advisor-unit", key: "unit" }, opts.unit));
|
|
2663
|
+
}
|
|
2664
|
+
return fieldShell(key, labelKey, controls, {
|
|
2665
|
+
controlId: `dsh-advisor-${key}`,
|
|
2666
|
+
helpText: helpText,
|
|
2667
|
+
hint: hint,
|
|
2668
|
+
metaText: helpText === "" ? "" : rangeText(key),
|
|
2669
|
+
});
|
|
2127
2670
|
}
|
|
2128
2671
|
|
|
2129
2672
|
/** temperature:留空表示不传,可为小数。 @returns {any} */
|
|
2130
2673
|
function temperatureField() {
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
)
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
},
|
|
2157
|
-
placeholder: t("settings.advanced.temperatureEmpty"),
|
|
2158
|
-
step: "0.1",
|
|
2159
|
-
type: "number",
|
|
2160
|
-
value: typeof texts.temperature === "string" ? texts.temperature : "",
|
|
2161
|
-
}),
|
|
2162
|
-
h(
|
|
2163
|
-
"span",
|
|
2164
|
-
{ className: "dsh-advisor-hint", key: "hint" },
|
|
2165
|
-
t("settings.advanced.temperatureHint"),
|
|
2166
|
-
),
|
|
2167
|
-
]);
|
|
2674
|
+
let control = h("input", {
|
|
2675
|
+
className: "dsh-advisor-input",
|
|
2676
|
+
id: "dsh-advisor-temperature",
|
|
2677
|
+
key: "input",
|
|
2678
|
+
max: "2",
|
|
2679
|
+
min: "0",
|
|
2680
|
+
onBlur: function onTemperatureBlur() {
|
|
2681
|
+
commitOne("temperature");
|
|
2682
|
+
},
|
|
2683
|
+
onChange: function onTemperatureChange(/** @type {any} */ event) {
|
|
2684
|
+
let value = String(event.target.value);
|
|
2685
|
+
setTexts(function mergeTemperature(/** @type {any} */ prev) {
|
|
2686
|
+
return Object.assign({}, prev, { temperature: value });
|
|
2687
|
+
});
|
|
2688
|
+
},
|
|
2689
|
+
placeholder: t("settings.advanced.temperatureEmpty"),
|
|
2690
|
+
step: "0.1",
|
|
2691
|
+
type: "number",
|
|
2692
|
+
value: typeof texts.temperature === "string" ? texts.temperature : "",
|
|
2693
|
+
});
|
|
2694
|
+
return fieldShell("temperature", "settings.advanced.temperature", [control], {
|
|
2695
|
+
controlId: "dsh-advisor-temperature",
|
|
2696
|
+
helpText: t("settings.advanced.temperatureHint"),
|
|
2697
|
+
metaText: t("settings.help.defaultNotSent"),
|
|
2698
|
+
});
|
|
2168
2699
|
}
|
|
2169
2700
|
|
|
2170
2701
|
/**
|
|
2171
2702
|
* 开关一行。
|
|
2172
2703
|
* @param {string} key
|
|
2173
2704
|
* @param {string} labelKey
|
|
2174
|
-
* @param {string}
|
|
2705
|
+
* @param {{ hint?: string, help?: string, meta?: string }} [options]
|
|
2175
2706
|
* @returns {any}
|
|
2176
2707
|
*/
|
|
2177
|
-
function switchField(key, labelKey,
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
checked
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
]);
|
|
2708
|
+
function switchField(key, labelKey, options) {
|
|
2709
|
+
let opts = options === undefined ? {} : options;
|
|
2710
|
+
let control = h("input", {
|
|
2711
|
+
checked: draft[key] === true,
|
|
2712
|
+
"data-advisor-switch": key,
|
|
2713
|
+
id: `dsh-advisor-${key}`,
|
|
2714
|
+
key: "input",
|
|
2715
|
+
onChange: function onSwitch(/** @type {any} */ event) {
|
|
2716
|
+
toggleFlag(key, event.target.checked === true);
|
|
2717
|
+
},
|
|
2718
|
+
type: "checkbox",
|
|
2719
|
+
});
|
|
2720
|
+
return fieldShell(key, labelKey, [control], {
|
|
2721
|
+
controlId: `dsh-advisor-${key}`,
|
|
2722
|
+
helpText: typeof opts.help === "string" ? opts.help : "",
|
|
2723
|
+
hint: typeof opts.hint === "string" ? opts.hint : "",
|
|
2724
|
+
metaText: typeof opts.meta === "string" ? opts.meta : "",
|
|
2725
|
+
});
|
|
2196
2726
|
}
|
|
2197
2727
|
|
|
2198
2728
|
/**
|
|
2199
|
-
* 下拉一行(枚举字段,如 postAnswer)。
|
|
2729
|
+
* 下拉一行(枚举字段,如 mode / scope / postAnswer)。
|
|
2200
2730
|
* @param {string} key
|
|
2201
2731
|
* @param {string} labelKey
|
|
2202
2732
|
* @param {string[]} values 合法取值;选项文案拼成 `${prefix}${value}`
|
|
2203
2733
|
* @param {string} prefix
|
|
2204
2734
|
* @param {string} current
|
|
2205
2735
|
* @param {(value: string) => void} onPick
|
|
2206
|
-
* @param {string}
|
|
2736
|
+
* @param {{ hint?: string, help?: string, meta?: string }} [options]
|
|
2207
2737
|
* @returns {any}
|
|
2208
2738
|
*/
|
|
2209
|
-
function selectField(key, labelKey, values, prefix, current, onPick,
|
|
2210
|
-
let
|
|
2739
|
+
function selectField(key, labelKey, values, prefix, current, onPick, options) {
|
|
2740
|
+
let opts = options === undefined ? {} : options;
|
|
2741
|
+
let optionNodes = values.map(function renderOption(/** @type {string} */ value) {
|
|
2211
2742
|
return h("option", { key: value, value: value }, t(prefix + value));
|
|
2212
2743
|
});
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
className: "dsh-advisor-select",
|
|
2223
|
-
"data-advisor-select": key,
|
|
2224
|
-
id: `dsh-advisor-${key}`,
|
|
2225
|
-
key: "select",
|
|
2226
|
-
onChange: function onSelectChange(/** @type {any} */ event) {
|
|
2227
|
-
onPick(String(event.target.value));
|
|
2228
|
-
},
|
|
2229
|
-
value: current,
|
|
2744
|
+
let control = h(
|
|
2745
|
+
"select",
|
|
2746
|
+
{
|
|
2747
|
+
className: "dsh-advisor-select",
|
|
2748
|
+
"data-advisor-select": key,
|
|
2749
|
+
id: `dsh-advisor-${key}`,
|
|
2750
|
+
key: "select",
|
|
2751
|
+
onChange: function onSelectChange(/** @type {any} */ event) {
|
|
2752
|
+
onPick(String(event.target.value));
|
|
2230
2753
|
},
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2754
|
+
value: current,
|
|
2755
|
+
},
|
|
2756
|
+
optionNodes,
|
|
2757
|
+
);
|
|
2758
|
+
return fieldShell(key, labelKey, [control], {
|
|
2759
|
+
controlId: `dsh-advisor-${key}`,
|
|
2760
|
+
helpText: typeof opts.help === "string" ? opts.help : "",
|
|
2761
|
+
hint: typeof opts.hint === "string" ? opts.hint : "",
|
|
2762
|
+
metaText: typeof opts.meta === "string" ? opts.meta : "",
|
|
2763
|
+
});
|
|
2235
2764
|
}
|
|
2236
2765
|
|
|
2237
2766
|
/**
|
|
@@ -2239,38 +2768,26 @@ window.__ModuleLoader__.load({
|
|
|
2239
2768
|
* @returns {any}
|
|
2240
2769
|
*/
|
|
2241
2770
|
function allowedModelsField() {
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
}
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
});
|
|
2263
|
-
},
|
|
2264
|
-
placeholder: t("settings.advanced.allowedModelsPlaceholder"),
|
|
2265
|
-
type: "text",
|
|
2266
|
-
value: typeof texts.allowedModels === "string" ? texts.allowedModels : "",
|
|
2267
|
-
}),
|
|
2268
|
-
h(
|
|
2269
|
-
"span",
|
|
2270
|
-
{ className: "dsh-advisor-hint", key: "hint" },
|
|
2271
|
-
t("settings.advanced.allowedModelsHint"),
|
|
2272
|
-
),
|
|
2273
|
-
]);
|
|
2771
|
+
let control = h("input", {
|
|
2772
|
+
className: "dsh-advisor-input",
|
|
2773
|
+
id: "dsh-advisor-allowedModels",
|
|
2774
|
+
key: "input",
|
|
2775
|
+
onBlur: commitAllowedModels,
|
|
2776
|
+
onChange: function onAllowedModelsChange(/** @type {any} */ event) {
|
|
2777
|
+
let value = String(event.target.value);
|
|
2778
|
+
setTexts(function mergeAllowed(/** @type {any} */ prev) {
|
|
2779
|
+
return Object.assign({}, prev, { allowedModels: value });
|
|
2780
|
+
});
|
|
2781
|
+
},
|
|
2782
|
+
placeholder: t("settings.advanced.allowedModelsPlaceholder"),
|
|
2783
|
+
type: "text",
|
|
2784
|
+
value: typeof texts.allowedModels === "string" ? texts.allowedModels : "",
|
|
2785
|
+
});
|
|
2786
|
+
return fieldShell("allowedModels", "settings.advanced.allowedModels", [control], {
|
|
2787
|
+
controlId: "dsh-advisor-allowedModels",
|
|
2788
|
+
helpText: t("settings.advanced.allowedModelsHint"),
|
|
2789
|
+
metaText: t("settings.help.defaultEmpty"),
|
|
2790
|
+
});
|
|
2274
2791
|
}
|
|
2275
2792
|
|
|
2276
2793
|
/** provider 下拉:来自 options.routes,declared 标「自定义」。 @returns {any} */
|
|
@@ -2296,30 +2813,24 @@ window.__ModuleLoader__.load({
|
|
|
2296
2813
|
),
|
|
2297
2814
|
);
|
|
2298
2815
|
}
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
className: "dsh-advisor-select",
|
|
2309
|
-
"data-advisor-provider": "",
|
|
2310
|
-
id: "dsh-advisor-provider",
|
|
2311
|
-
key: "select",
|
|
2312
|
-
onChange: function onProviderChange(/** @type {any} */ event) {
|
|
2313
|
-
chooseProvider(String(event.target.value));
|
|
2314
|
-
},
|
|
2315
|
-
value: draft.provider,
|
|
2816
|
+
let control = h(
|
|
2817
|
+
"select",
|
|
2818
|
+
{
|
|
2819
|
+
className: "dsh-advisor-select",
|
|
2820
|
+
"data-advisor-provider": "",
|
|
2821
|
+
id: "dsh-advisor-provider",
|
|
2822
|
+
key: "select",
|
|
2823
|
+
onChange: function onProviderChange(/** @type {any} */ event) {
|
|
2824
|
+
chooseProvider(String(event.target.value));
|
|
2316
2825
|
},
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2826
|
+
value: draft.provider,
|
|
2827
|
+
},
|
|
2828
|
+
options,
|
|
2829
|
+
);
|
|
2830
|
+
return fieldShell("provider", "settings.provider", [control], {
|
|
2831
|
+
controlId: "dsh-advisor-provider",
|
|
2832
|
+
hint: routes.length === 0 ? t("settings.provider.none") : "",
|
|
2833
|
+
});
|
|
2323
2834
|
}
|
|
2324
2835
|
|
|
2325
2836
|
/** 模型下拉 + 手填输入。 @returns {any} */
|
|
@@ -2349,52 +2860,44 @@ window.__ModuleLoader__.load({
|
|
|
2349
2860
|
else if (list === null) hint = t("settings.model.loading");
|
|
2350
2861
|
else if (list.length === 0) hint = t("settings.model.none");
|
|
2351
2862
|
if (hint !== "") hint = `${hint} · ${t("settings.model.manualHint")}`;
|
|
2352
|
-
|
|
2863
|
+
let controls = h("div", { className: "dsh-advisor-controls", key: "controls" }, [
|
|
2353
2864
|
h(
|
|
2354
|
-
"
|
|
2355
|
-
{
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
"select",
|
|
2361
|
-
{
|
|
2362
|
-
|
|
2363
|
-
"data-advisor-model": "",
|
|
2364
|
-
disabled: list === null,
|
|
2365
|
-
id: "dsh-advisor-model",
|
|
2366
|
-
key: "select",
|
|
2367
|
-
onChange: function onModelChange(/** @type {any} */ event) {
|
|
2368
|
-
chooseModel(String(event.target.value));
|
|
2369
|
-
},
|
|
2370
|
-
value: draft.model,
|
|
2371
|
-
},
|
|
2372
|
-
options,
|
|
2373
|
-
),
|
|
2374
|
-
h("input", {
|
|
2375
|
-
"aria-label": t("settings.model.manual"),
|
|
2376
|
-
className: "dsh-advisor-input",
|
|
2377
|
-
"data-advisor-model-text": "",
|
|
2378
|
-
key: "manual",
|
|
2379
|
-
onBlur: function onModelTextBlur() {
|
|
2380
|
-
if (draft.model !== "" && draft.provider !== "") {
|
|
2381
|
-
loadInfoFor(draft.provider, draft.model);
|
|
2382
|
-
}
|
|
2383
|
-
},
|
|
2384
|
-
onChange: function onModelTextChange(/** @type {any} */ event) {
|
|
2385
|
-
onModelText(String(event.target.value));
|
|
2865
|
+
"select",
|
|
2866
|
+
{
|
|
2867
|
+
className: "dsh-advisor-select",
|
|
2868
|
+
"data-advisor-model": "",
|
|
2869
|
+
disabled: list === null,
|
|
2870
|
+
id: "dsh-advisor-model",
|
|
2871
|
+
key: "select",
|
|
2872
|
+
onChange: function onModelChange(/** @type {any} */ event) {
|
|
2873
|
+
chooseModel(String(event.target.value));
|
|
2386
2874
|
},
|
|
2387
|
-
placeholder: t("settings.model.manual"),
|
|
2388
|
-
type: "text",
|
|
2389
2875
|
value: draft.model,
|
|
2390
|
-
}
|
|
2391
|
-
|
|
2392
|
-
h(
|
|
2393
|
-
"span",
|
|
2394
|
-
{ className: "dsh-advisor-hint", key: "hint" },
|
|
2395
|
-
hint === "" ? t("settings.model.manualHint") : hint,
|
|
2876
|
+
},
|
|
2877
|
+
options,
|
|
2396
2878
|
),
|
|
2879
|
+
h("input", {
|
|
2880
|
+
"aria-label": t("settings.model.manual"),
|
|
2881
|
+
className: "dsh-advisor-input",
|
|
2882
|
+
"data-advisor-model-text": "",
|
|
2883
|
+
key: "manual",
|
|
2884
|
+
onBlur: function onModelTextBlur() {
|
|
2885
|
+
if (draft.model !== "" && draft.provider !== "") {
|
|
2886
|
+
loadInfoFor(draft.provider, draft.model);
|
|
2887
|
+
}
|
|
2888
|
+
},
|
|
2889
|
+
onChange: function onModelTextChange(/** @type {any} */ event) {
|
|
2890
|
+
onModelText(String(event.target.value));
|
|
2891
|
+
},
|
|
2892
|
+
placeholder: t("settings.model.manual"),
|
|
2893
|
+
type: "text",
|
|
2894
|
+
value: draft.model,
|
|
2895
|
+
}),
|
|
2397
2896
|
]);
|
|
2897
|
+
return fieldShell("model", "settings.model", [controls], {
|
|
2898
|
+
controlId: "dsh-advisor-model",
|
|
2899
|
+
hint: hint === "" ? t("settings.model.manualHint") : hint,
|
|
2900
|
+
});
|
|
2398
2901
|
}
|
|
2399
2902
|
|
|
2400
2903
|
/** 思考档下拉:auto + modelInfo.efforts;拿不到只留 auto。 @returns {any} */
|
|
@@ -2427,29 +2930,25 @@ window.__ModuleLoader__.load({
|
|
|
2427
2930
|
else if (info.state === "error") hint = t("settings.error.modelInfo");
|
|
2428
2931
|
else if (info.state === "empty" || efforts.length === 0) hint = t("settings.effort.none");
|
|
2429
2932
|
else hint = t("settings.effort.count").replace("{count}", String(efforts.length));
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
"select",
|
|
2438
|
-
{
|
|
2439
|
-
|
|
2440
|
-
"data-advisor-effort": "",
|
|
2441
|
-
disabled: draft.model === "" || info.state === "loading",
|
|
2442
|
-
id: "dsh-advisor-effort",
|
|
2443
|
-
key: "select",
|
|
2444
|
-
onChange: function onEffortChange(/** @type {any} */ event) {
|
|
2445
|
-
chooseEffort(String(event.target.value));
|
|
2446
|
-
},
|
|
2447
|
-
value: draft.reasoningEffort,
|
|
2933
|
+
let control = h(
|
|
2934
|
+
"select",
|
|
2935
|
+
{
|
|
2936
|
+
className: "dsh-advisor-select",
|
|
2937
|
+
"data-advisor-effort": "",
|
|
2938
|
+
disabled: draft.model === "" || info.state === "loading",
|
|
2939
|
+
id: "dsh-advisor-effort",
|
|
2940
|
+
key: "select",
|
|
2941
|
+
onChange: function onEffortChange(/** @type {any} */ event) {
|
|
2942
|
+
chooseEffort(String(event.target.value));
|
|
2448
2943
|
},
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2944
|
+
value: draft.reasoningEffort,
|
|
2945
|
+
},
|
|
2946
|
+
options,
|
|
2947
|
+
);
|
|
2948
|
+
return fieldShell("effort", "settings.effort", [control], {
|
|
2949
|
+
controlId: "dsh-advisor-effort",
|
|
2950
|
+
hint: hint,
|
|
2951
|
+
});
|
|
2453
2952
|
}
|
|
2454
2953
|
|
|
2455
2954
|
// 初次加载 / 重载:还没有可用快照时只渲染标题与加载态,避免半张卡片。
|
|
@@ -2476,9 +2975,201 @@ window.__ModuleLoader__.load({
|
|
|
2476
2975
|
);
|
|
2477
2976
|
}
|
|
2478
2977
|
|
|
2978
|
+
/**
|
|
2979
|
+
* 当前草稿是否有未保存改动。
|
|
2980
|
+
* @returns {boolean}
|
|
2981
|
+
*/
|
|
2982
|
+
function isDirty() {
|
|
2983
|
+
if (snap === null || draft === null) return false;
|
|
2984
|
+
return Object.keys(diffSettings(snap.settings, draft)).length > 0;
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
/**
|
|
2988
|
+
* 数组按内容比较、浮点按 epsilon 比较;其余用严格相等。
|
|
2989
|
+
* @param {any} a
|
|
2990
|
+
* @param {any} b
|
|
2991
|
+
* @returns {boolean}
|
|
2992
|
+
*/
|
|
2993
|
+
function valuesEqual(a, b) {
|
|
2994
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
2995
|
+
return normalizeStringList(a).join("\u0000") === normalizeStringList(b).join("\u0000");
|
|
2996
|
+
}
|
|
2997
|
+
if (a === null || a === undefined) return b === null || b === undefined;
|
|
2998
|
+
if (typeof a === "number" && typeof b === "number") return Math.abs(a - b) < 1e-9;
|
|
2999
|
+
return a === b;
|
|
3000
|
+
}
|
|
3001
|
+
|
|
3002
|
+
/** 高级区里与默认值不同的项数;用于折叠标题徽标。 @returns {number} */
|
|
3003
|
+
function advancedChangedCount() {
|
|
3004
|
+
if (draft === null) return 0;
|
|
3005
|
+
let count = 0;
|
|
3006
|
+
for (let index = 0; index < SETTINGS_ADVANCED_FIELDS.length; index += 1) {
|
|
3007
|
+
let key = SETTINGS_ADVANCED_FIELDS[index];
|
|
3008
|
+
if (valuesEqual(draft[key], SETTINGS_DEFAULTS[key]) === false) count += 1;
|
|
3009
|
+
}
|
|
3010
|
+
return count;
|
|
3011
|
+
}
|
|
3012
|
+
|
|
3013
|
+
/** 恢复高级字段默认值;不动模式、路由、隐私这些基础字段。 */
|
|
3014
|
+
function resetAdvanced() {
|
|
3015
|
+
if (draft === null) return;
|
|
3016
|
+
let next = Object.assign({}, draft);
|
|
3017
|
+
for (let index = 0; index < SETTINGS_ADVANCED_FIELDS.length; index += 1) {
|
|
3018
|
+
let key = SETTINGS_ADVANCED_FIELDS[index];
|
|
3019
|
+
let fallback = SETTINGS_DEFAULTS[key];
|
|
3020
|
+
next[key] = Array.isArray(fallback) ? fallback.slice() : fallback;
|
|
3021
|
+
}
|
|
3022
|
+
setDraft(next);
|
|
3023
|
+
setTexts(textsOf(next));
|
|
3024
|
+
setError(null);
|
|
3025
|
+
setNotice(t("settings.advanced.resetDone"));
|
|
3026
|
+
}
|
|
3027
|
+
|
|
3028
|
+
/** 复制设置文件路径;剪贴板不可用时只提示手动复制。 */
|
|
3029
|
+
function copySettingsPath() {
|
|
3030
|
+
let path = snap !== null && typeof snap.settingsPath === "string" ? snap.settingsPath : "";
|
|
3031
|
+
if (path === "") {
|
|
3032
|
+
setNotice(t("settings.advanced.pathUnknown"));
|
|
3033
|
+
return;
|
|
3034
|
+
}
|
|
3035
|
+
try {
|
|
3036
|
+
if (
|
|
3037
|
+
typeof navigator !== "undefined" &&
|
|
3038
|
+
navigator.clipboard &&
|
|
3039
|
+
typeof navigator.clipboard.writeText === "function"
|
|
3040
|
+
) {
|
|
3041
|
+
navigator.clipboard.writeText(path).then(
|
|
3042
|
+
function onCopied() {
|
|
3043
|
+
setNotice(t("settings.advanced.copied"));
|
|
3044
|
+
},
|
|
3045
|
+
function onCopyFailed() {
|
|
3046
|
+
setNotice(t("settings.advanced.copyFailed"));
|
|
3047
|
+
},
|
|
3048
|
+
);
|
|
3049
|
+
return;
|
|
3050
|
+
}
|
|
3051
|
+
} catch (_error) {
|
|
3052
|
+
/* 落回手动复制提示 */
|
|
3053
|
+
}
|
|
3054
|
+
setNotice(t("settings.advanced.copyFailed"));
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
/**
|
|
3058
|
+
* 一个可折叠区块:高级设置、状态与诊断共用。
|
|
3059
|
+
* @param {string} key
|
|
3060
|
+
* @param {string} title
|
|
3061
|
+
* @param {string} badge
|
|
3062
|
+
* @param {any[]} children
|
|
3063
|
+
* @param {boolean} isOpen
|
|
3064
|
+
* @param {() => void} onToggle
|
|
3065
|
+
* @returns {any}
|
|
3066
|
+
*/
|
|
3067
|
+
function disclosure(key, title, badge, children, isOpen, onToggle) {
|
|
3068
|
+
return h(
|
|
3069
|
+
"section",
|
|
3070
|
+
{ className: "dsh-advisor-disclosure", "data-advisor-disclosure": key, key: key },
|
|
3071
|
+
[
|
|
3072
|
+
h(
|
|
3073
|
+
"button",
|
|
3074
|
+
{
|
|
3075
|
+
"aria-expanded": isOpen ? "true" : "false",
|
|
3076
|
+
className: "dsh-advisor-disclosure-toggle",
|
|
3077
|
+
"data-advisor-disclosure-toggle": key,
|
|
3078
|
+
key: "toggle",
|
|
3079
|
+
onClick: onToggle,
|
|
3080
|
+
type: "button",
|
|
3081
|
+
},
|
|
3082
|
+
[
|
|
3083
|
+
h("span", { className: "dsh-advisor-caret", key: "caret" }, isOpen ? "▾" : "▸"),
|
|
3084
|
+
h("span", { className: "dsh-advisor-disclosure-title", key: "title" }, title),
|
|
3085
|
+
badge === ""
|
|
3086
|
+
? null
|
|
3087
|
+
: h("span", { className: "dsh-advisor-badge", key: "badge" }, badge),
|
|
3088
|
+
],
|
|
3089
|
+
),
|
|
3090
|
+
isOpen
|
|
3091
|
+
? h("div", { className: "dsh-advisor-disclosure-body", key: "body" }, children)
|
|
3092
|
+
: null,
|
|
3093
|
+
],
|
|
3094
|
+
);
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
/** off 时的紧凑卡片:只解释状态、给配置入口,不铺开任何设置。 @returns {any} */
|
|
3098
|
+
function offNotice() {
|
|
3099
|
+
let configured = draft.provider !== "" && draft.model !== "";
|
|
3100
|
+
let dirty = isDirty();
|
|
3101
|
+
return h("div", { className: "dsh-advisor-off", "data-advisor-off": "", key: "off" }, [
|
|
3102
|
+
h("div", { className: "dsh-advisor-off-title", key: "title" }, t("settings.off.title")),
|
|
3103
|
+
h(
|
|
3104
|
+
"div",
|
|
3105
|
+
{ className: "dsh-advisor-note", key: "state" },
|
|
3106
|
+
configured
|
|
3107
|
+
? t("settings.off.configured")
|
|
3108
|
+
.replace("{provider}", draft.provider)
|
|
3109
|
+
.replace("{model}", draft.model)
|
|
3110
|
+
: t("settings.off.unconfigured"),
|
|
3111
|
+
),
|
|
3112
|
+
dirty
|
|
3113
|
+
? h("div", { className: "dsh-advisor-dirty", key: "dirty" }, t("settings.dirty"))
|
|
3114
|
+
: null,
|
|
3115
|
+
h("div", { className: "dsh-advisor-actions", key: "actions" }, [
|
|
3116
|
+
h(
|
|
3117
|
+
"button",
|
|
3118
|
+
{
|
|
3119
|
+
className: "dsh-advisor-btn",
|
|
3120
|
+
"data-advisor-configure": "",
|
|
3121
|
+
key: "configure",
|
|
3122
|
+
onClick: function toggleOffForm() {
|
|
3123
|
+
setOffExpanded(!offExpanded);
|
|
3124
|
+
},
|
|
3125
|
+
type: "button",
|
|
3126
|
+
},
|
|
3127
|
+
offExpanded ? t("settings.off.collapse") : t("settings.off.configure"),
|
|
3128
|
+
),
|
|
3129
|
+
]),
|
|
3130
|
+
]);
|
|
3131
|
+
}
|
|
3132
|
+
|
|
3133
|
+
/** 保存 / 重新加载 / 未保存提示。 @param {boolean} dirty @returns {any} */
|
|
3134
|
+
function actionBar(dirty) {
|
|
3135
|
+
return h("div", { className: "dsh-advisor-actions", key: "actions" }, [
|
|
3136
|
+
h(
|
|
3137
|
+
"button",
|
|
3138
|
+
{
|
|
3139
|
+
className: "dsh-advisor-btn dsh-advisor-btn--primary",
|
|
3140
|
+
"data-advisor-save": "",
|
|
3141
|
+
disabled: busy === "save" || busy === "load",
|
|
3142
|
+
key: "save",
|
|
3143
|
+
onClick: save,
|
|
3144
|
+
type: "button",
|
|
3145
|
+
},
|
|
3146
|
+
busy === "save" ? t("settings.saving") : t("settings.save"),
|
|
3147
|
+
),
|
|
3148
|
+
h(
|
|
3149
|
+
"button",
|
|
3150
|
+
{
|
|
3151
|
+
className: "dsh-advisor-btn",
|
|
3152
|
+
"data-advisor-reload": "",
|
|
3153
|
+
disabled: busy === "load",
|
|
3154
|
+
key: "reload",
|
|
3155
|
+
onClick: reload,
|
|
3156
|
+
type: "button",
|
|
3157
|
+
},
|
|
3158
|
+
t("settings.reload"),
|
|
3159
|
+
),
|
|
3160
|
+
dirty
|
|
3161
|
+
? h(
|
|
3162
|
+
"span",
|
|
3163
|
+
{ className: "dsh-advisor-dirty", "data-advisor-dirty": "", key: "dirty" },
|
|
3164
|
+
t("settings.dirty"),
|
|
3165
|
+
)
|
|
3166
|
+
: null,
|
|
3167
|
+
]);
|
|
3168
|
+
}
|
|
3169
|
+
|
|
2479
3170
|
let sep = t("settings.status.sep");
|
|
2480
3171
|
let totals = snap.totals;
|
|
2481
|
-
let priced = snap.
|
|
3172
|
+
let priced = snap.price.source !== "none";
|
|
2482
3173
|
let lastText =
|
|
2483
3174
|
snap.last === null
|
|
2484
3175
|
? t("settings.status.none")
|
|
@@ -2490,14 +3181,17 @@ window.__ModuleLoader__.load({
|
|
|
2490
3181
|
.replace("{output}", formatCount(totals.outputTokens)),
|
|
2491
3182
|
t("settings.status.cost") +
|
|
2492
3183
|
sep +
|
|
2493
|
-
(priced
|
|
3184
|
+
(priced
|
|
3185
|
+
? `≈${formatMoney(
|
|
3186
|
+
fromUsd(totals.costUsd, snap.settings.currency, snap.settings.usdToCny),
|
|
3187
|
+
snap.settings.currency,
|
|
3188
|
+
4,
|
|
3189
|
+
)}`
|
|
3190
|
+
: t("settings.status.costUnset")),
|
|
2494
3191
|
t("settings.status.last") + sep + lastText,
|
|
2495
3192
|
t("settings.status.skip") +
|
|
2496
3193
|
sep +
|
|
2497
3194
|
(snap.lastSkip === "" ? t("settings.status.none") : snap.lastSkip),
|
|
2498
|
-
t("settings.status.ledger") +
|
|
2499
|
-
sep +
|
|
2500
|
-
(snap.ledgerPath === "" ? t("settings.status.none") : snap.ledgerPath),
|
|
2501
3195
|
];
|
|
2502
3196
|
|
|
2503
3197
|
let doctorNode = null;
|
|
@@ -2531,41 +3225,213 @@ window.__ModuleLoader__.load({
|
|
|
2531
3225
|
let priceSourceText = t(`settings.budget.priceSource.${snap.price.source}`);
|
|
2532
3226
|
let poolLine = t("settings.budget.poolLine")
|
|
2533
3227
|
.replace("{calls}", formatCount(snap.pool.calls))
|
|
2534
|
-
.replace(
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
3228
|
+
.replace(
|
|
3229
|
+
"{cost}",
|
|
3230
|
+
formatMoney(
|
|
3231
|
+
fromUsd(snap.pool.costUsd, snap.settings.currency, snap.settings.usdToCny),
|
|
3232
|
+
snap.settings.currency,
|
|
3233
|
+
4,
|
|
3234
|
+
),
|
|
3235
|
+
);
|
|
3236
|
+
|
|
3237
|
+
// 基础设置:只放开启前必须做的决定,以及每日预算与发送范围。
|
|
3238
|
+
let basicBody = [
|
|
3239
|
+
subgroup("settings.group.model", [providerField(), modelField(), effortField()], "model"),
|
|
3240
|
+
subgroup(
|
|
3241
|
+
"settings.group.spend",
|
|
3242
|
+
[
|
|
3243
|
+
currencyField(),
|
|
3244
|
+
numberField("maxCostPerDay", "settings.budget.maxCostPerDay", {
|
|
3245
|
+
hint: t("settings.basic.budgetHint"),
|
|
3246
|
+
unit: currencyLabel(),
|
|
3247
|
+
}),
|
|
3248
|
+
],
|
|
3249
|
+
"spend",
|
|
2545
3250
|
),
|
|
2546
|
-
|
|
2547
|
-
"
|
|
2548
|
-
|
|
2549
|
-
|
|
3251
|
+
subgroup(
|
|
3252
|
+
"settings.group.privacy",
|
|
3253
|
+
[
|
|
3254
|
+
selectField(
|
|
3255
|
+
"scope",
|
|
3256
|
+
"settings.scope",
|
|
3257
|
+
SETTINGS_SCOPES,
|
|
3258
|
+
"settings.scope.",
|
|
3259
|
+
draft.privacyScope,
|
|
3260
|
+
chooseScope,
|
|
3261
|
+
{ hint: t(`settings.scope.${draft.privacyScope}Hint`) },
|
|
3262
|
+
),
|
|
3263
|
+
switchField("redact", "settings.privacy.redact", {
|
|
3264
|
+
hint: t("settings.privacy.redactHint"),
|
|
3265
|
+
}),
|
|
3266
|
+
],
|
|
3267
|
+
"privacy",
|
|
2550
3268
|
),
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
3269
|
+
];
|
|
3270
|
+
|
|
3271
|
+
// 高级设置:调用限额、单价、生成参数、投递行为;默认折叠。
|
|
3272
|
+
let advancedBody = [
|
|
3273
|
+
h("div", { className: "dsh-advisor-note", key: "intro" }, t("settings.advanced.intro")),
|
|
3274
|
+
subgroup(
|
|
3275
|
+
"settings.group.limits",
|
|
3276
|
+
[
|
|
3277
|
+
h(
|
|
3278
|
+
"div",
|
|
3279
|
+
{ className: "dsh-advisor-note", key: "dailyBudgetNote" },
|
|
3280
|
+
t("settings.advanced.dailyBudgetNote"),
|
|
3281
|
+
),
|
|
3282
|
+
numberField("maxCallsPerTurn", "settings.budget.maxCallsPerTurn", {
|
|
3283
|
+
help: t("settings.help.calls"),
|
|
3284
|
+
unit: t("settings.unit.calls"),
|
|
3285
|
+
}),
|
|
3286
|
+
numberField("maxCallsPerSession", "settings.budget.maxCallsPerSession", {
|
|
3287
|
+
help: t("settings.help.calls"),
|
|
3288
|
+
unit: t("settings.unit.calls"),
|
|
3289
|
+
}),
|
|
3290
|
+
numberField("maxCallsPerHour", "settings.budget.maxCallsPerHour", {
|
|
3291
|
+
help: t("settings.help.calls"),
|
|
3292
|
+
unit: t("settings.unit.calls"),
|
|
3293
|
+
}),
|
|
3294
|
+
numberField("workspaceMaxCallsPerDay", "settings.budget.workspaceMaxCallsPerDay", {
|
|
3295
|
+
help: t("settings.budget.workspaceHint"),
|
|
3296
|
+
unit: t("settings.unit.calls"),
|
|
3297
|
+
}),
|
|
3298
|
+
numberField("workspaceMaxCostPerDay", "settings.budget.workspaceMaxCostPerDay", {
|
|
3299
|
+
help: t("settings.budget.workspaceHint"),
|
|
3300
|
+
unit: currencyLabel(),
|
|
3301
|
+
}),
|
|
3302
|
+
h(
|
|
3303
|
+
"div",
|
|
3304
|
+
{ className: "dsh-advisor-readout", "data-advisor-pool": "", key: "pool" },
|
|
3305
|
+
poolLine,
|
|
3306
|
+
),
|
|
3307
|
+
],
|
|
3308
|
+
"limits",
|
|
3309
|
+
),
|
|
3310
|
+
subgroup(
|
|
3311
|
+
"settings.group.money",
|
|
3312
|
+
[
|
|
3313
|
+
numberField("usdToCny", "settings.usdToCny", {
|
|
3314
|
+
help: t("settings.usdToCnyHint"),
|
|
3315
|
+
unit: t("settings.unit.cnyPerUsd"),
|
|
3316
|
+
}),
|
|
3317
|
+
numberField("priceInputPerMTok", "settings.budget.priceInputPerMTok", {
|
|
3318
|
+
help: t("settings.budget.priceHint"),
|
|
3319
|
+
unit: priceUnit(),
|
|
3320
|
+
}),
|
|
3321
|
+
numberField("priceOutputPerMTok", "settings.budget.priceOutputPerMTok", {
|
|
3322
|
+
help: t("settings.budget.priceHint"),
|
|
3323
|
+
unit: priceUnit(),
|
|
3324
|
+
}),
|
|
3325
|
+
h("div", { className: "dsh-advisor-readout", key: "priceSource" }, priceSourceText),
|
|
3326
|
+
],
|
|
3327
|
+
"money",
|
|
2559
3328
|
),
|
|
2560
|
-
|
|
2561
|
-
"
|
|
2562
|
-
|
|
2563
|
-
|
|
3329
|
+
subgroup(
|
|
3330
|
+
"settings.group.generation",
|
|
3331
|
+
[
|
|
3332
|
+
numberField("maxTokens", "settings.advanced.maxTokens", {
|
|
3333
|
+
help: t("settings.advanced.maxTokensHint"),
|
|
3334
|
+
unit: t("settings.unit.tokens"),
|
|
3335
|
+
}),
|
|
3336
|
+
temperatureField(),
|
|
3337
|
+
numberField("maxInputChars", "settings.advanced.maxInputChars", {
|
|
3338
|
+
help: t("settings.advanced.maxInputCharsHint"),
|
|
3339
|
+
unit: t("settings.unit.chars"),
|
|
3340
|
+
}),
|
|
3341
|
+
],
|
|
3342
|
+
"generation",
|
|
3343
|
+
),
|
|
3344
|
+
subgroup(
|
|
3345
|
+
"settings.group.delivery",
|
|
3346
|
+
[
|
|
3347
|
+
numberField("sessionCap", "settings.advanced.sessionCap", {
|
|
3348
|
+
help: t("settings.advanced.sessionCapHint"),
|
|
3349
|
+
unit: t("settings.unit.items"),
|
|
3350
|
+
}),
|
|
3351
|
+
allowedModelsField(),
|
|
3352
|
+
selectField(
|
|
3353
|
+
"postAnswer",
|
|
3354
|
+
"settings.postAnswer",
|
|
3355
|
+
SETTINGS_POST_ANSWER,
|
|
3356
|
+
"settings.postAnswer.",
|
|
3357
|
+
draft.postAnswer,
|
|
3358
|
+
choosePostAnswer,
|
|
3359
|
+
{ help: t("settings.postAnswer.hint"), meta: t("settings.help.defaultOffOption") },
|
|
3360
|
+
),
|
|
3361
|
+
switchField("advisorTools", "settings.advisorTools", {
|
|
3362
|
+
help: t("settings.advisorToolsHint"),
|
|
3363
|
+
meta: t("settings.help.defaultOff"),
|
|
3364
|
+
}),
|
|
3365
|
+
switchField("dedupe", "settings.privacy.dedupe", {
|
|
3366
|
+
help: t("settings.privacy.dedupeHint"),
|
|
3367
|
+
meta: t("settings.help.defaultOn"),
|
|
3368
|
+
}),
|
|
3369
|
+
selectField(
|
|
3370
|
+
"tracePrompt",
|
|
3371
|
+
"settings.tracePrompt",
|
|
3372
|
+
SETTINGS_TRACE_PROMPT,
|
|
3373
|
+
"settings.tracePrompt.",
|
|
3374
|
+
draft.tracePrompt,
|
|
3375
|
+
chooseTracePrompt,
|
|
3376
|
+
{
|
|
3377
|
+
help: t("settings.tracePrompt.hint"),
|
|
3378
|
+
meta: t("settings.help.defaultPreview"),
|
|
3379
|
+
},
|
|
3380
|
+
),
|
|
3381
|
+
],
|
|
3382
|
+
"delivery",
|
|
3383
|
+
),
|
|
3384
|
+
subgroup(
|
|
3385
|
+
"settings.group.more",
|
|
3386
|
+
[
|
|
3387
|
+
h("div", { className: "dsh-advisor-more", key: "more" }, [
|
|
3388
|
+
h(
|
|
3389
|
+
"p",
|
|
3390
|
+
{ key: "text" },
|
|
3391
|
+
t("settings.advanced.more").replace("{fields}", t("settings.advanced.moreFields")),
|
|
3392
|
+
),
|
|
3393
|
+
h(
|
|
3394
|
+
"p",
|
|
3395
|
+
{ className: "dsh-advisor-path", key: "path" },
|
|
3396
|
+
snap.settingsPath === ""
|
|
3397
|
+
? t("settings.advanced.pathUnknown")
|
|
3398
|
+
: t("settings.paths.settings").replace("{path}", snap.settingsPath),
|
|
3399
|
+
),
|
|
3400
|
+
snap.settingsPath === ""
|
|
3401
|
+
? null
|
|
3402
|
+
: h(
|
|
3403
|
+
"button",
|
|
3404
|
+
{
|
|
3405
|
+
className: "dsh-advisor-btn",
|
|
3406
|
+
"data-advisor-copy-path": "",
|
|
3407
|
+
key: "copy",
|
|
3408
|
+
onClick: copySettingsPath,
|
|
3409
|
+
type: "button",
|
|
3410
|
+
},
|
|
3411
|
+
t("settings.advanced.copyPath"),
|
|
3412
|
+
),
|
|
3413
|
+
]),
|
|
3414
|
+
],
|
|
3415
|
+
"more",
|
|
2564
3416
|
),
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
3417
|
+
h("div", { className: "dsh-advisor-divider", key: "resetDivider" }),
|
|
3418
|
+
h("div", { className: "dsh-advisor-actions", key: "resetActions" }, [
|
|
3419
|
+
h(
|
|
3420
|
+
"button",
|
|
3421
|
+
{
|
|
3422
|
+
className: "dsh-advisor-btn",
|
|
3423
|
+
"data-advisor-reset": "",
|
|
3424
|
+
key: "reset",
|
|
3425
|
+
onClick: resetAdvanced,
|
|
3426
|
+
type: "button",
|
|
3427
|
+
},
|
|
3428
|
+
t("settings.advanced.reset"),
|
|
3429
|
+
),
|
|
3430
|
+
]),
|
|
3431
|
+
h(
|
|
3432
|
+
"div",
|
|
3433
|
+
{ className: "dsh-advisor-note", key: "resetHint" },
|
|
3434
|
+
t("settings.advanced.resetHint"),
|
|
2569
3435
|
),
|
|
2570
3436
|
];
|
|
2571
3437
|
|
|
@@ -2623,12 +3489,20 @@ window.__ModuleLoader__.load({
|
|
|
2623
3489
|
]);
|
|
2624
3490
|
}
|
|
2625
3491
|
|
|
2626
|
-
let
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
3492
|
+
let statusBody = [
|
|
3493
|
+
h(
|
|
3494
|
+
"div",
|
|
3495
|
+
{ className: "dsh-advisor-summary", "data-advisor-summary": "", key: "summary" },
|
|
3496
|
+
summaryLines.map(
|
|
3497
|
+
function renderSummaryLine(/** @type {string} */ line, /** @type {number} */ index) {
|
|
3498
|
+
return h(
|
|
3499
|
+
"div",
|
|
3500
|
+
{ className: "dsh-advisor-summary-line", key: `line-${index}` },
|
|
3501
|
+
line,
|
|
3502
|
+
);
|
|
3503
|
+
},
|
|
3504
|
+
),
|
|
3505
|
+
),
|
|
2632
3506
|
h("div", { className: "dsh-advisor-row", key: "previewRow" }, [
|
|
2633
3507
|
h("span", { className: "dsh-advisor-label", key: "label" }, t("settings.preview")),
|
|
2634
3508
|
h(
|
|
@@ -2646,31 +3520,13 @@ window.__ModuleLoader__.load({
|
|
|
2646
3520
|
]),
|
|
2647
3521
|
previewNode,
|
|
2648
3522
|
confirmRow,
|
|
2649
|
-
h("div", { className: "dsh-advisor-divider", key: "divider" }),
|
|
2650
|
-
h(
|
|
2651
|
-
"div",
|
|
2652
|
-
{ className: "dsh-advisor-subtitle", key: "statusTitle" },
|
|
2653
|
-
t("settings.status.title"),
|
|
2654
|
-
),
|
|
2655
|
-
h(
|
|
2656
|
-
"div",
|
|
2657
|
-
{ className: "dsh-advisor-summary", "data-advisor-summary": "", key: "summary" },
|
|
2658
|
-
summaryLines.map(
|
|
2659
|
-
function renderSummaryLine(/** @type {string} */ line, /** @type {number} */ index) {
|
|
2660
|
-
return h(
|
|
2661
|
-
"div",
|
|
2662
|
-
{ className: "dsh-advisor-summary-line", key: `line-${index}` },
|
|
2663
|
-
line,
|
|
2664
|
-
);
|
|
2665
|
-
},
|
|
2666
|
-
),
|
|
2667
|
-
),
|
|
2668
3523
|
h("div", { className: "dsh-advisor-row", key: "doctorRow" }, [
|
|
2669
3524
|
h("span", { className: "dsh-advisor-label", key: "label" }, t("settings.doctor")),
|
|
2670
3525
|
h(
|
|
2671
3526
|
"button",
|
|
2672
3527
|
{
|
|
2673
3528
|
className: "dsh-advisor-btn",
|
|
3529
|
+
"data-advisor-doctor-run": "",
|
|
2674
3530
|
disabled: busy === "doctor",
|
|
2675
3531
|
key: "run",
|
|
2676
3532
|
onClick: runDoctor,
|
|
@@ -2680,6 +3536,22 @@ window.__ModuleLoader__.load({
|
|
|
2680
3536
|
),
|
|
2681
3537
|
]),
|
|
2682
3538
|
doctorNode,
|
|
3539
|
+
h("div", { className: "dsh-advisor-paths", key: "paths" }, [
|
|
3540
|
+
snap.settingsPath === ""
|
|
3541
|
+
? null
|
|
3542
|
+
: h(
|
|
3543
|
+
"div",
|
|
3544
|
+
{ key: "settingsPath" },
|
|
3545
|
+
t("settings.paths.settings").replace("{path}", snap.settingsPath),
|
|
3546
|
+
),
|
|
3547
|
+
snap.ledgerPath === ""
|
|
3548
|
+
? null
|
|
3549
|
+
: h(
|
|
3550
|
+
"div",
|
|
3551
|
+
{ key: "ledgerPath" },
|
|
3552
|
+
t("settings.paths.ledger").replace("{path}", snap.ledgerPath),
|
|
3553
|
+
),
|
|
3554
|
+
]),
|
|
2683
3555
|
];
|
|
2684
3556
|
|
|
2685
3557
|
let noticeNode =
|
|
@@ -2687,6 +3559,64 @@ window.__ModuleLoader__.load({
|
|
|
2687
3559
|
? null
|
|
2688
3560
|
: h("div", { className: "dsh-advisor-saved", key: "notice", role: "status" }, notice);
|
|
2689
3561
|
|
|
3562
|
+
let advancedChanged = advancedChangedCount();
|
|
3563
|
+
let advancedBadge =
|
|
3564
|
+
advancedChanged === 0
|
|
3565
|
+
? t("settings.advanced.defaults")
|
|
3566
|
+
: t("settings.advanced.changed").replace("{count}", String(advancedChanged));
|
|
3567
|
+
let modeRow = selectField(
|
|
3568
|
+
"mode",
|
|
3569
|
+
"settings.mode",
|
|
3570
|
+
SETTINGS_MODES,
|
|
3571
|
+
"settings.mode.",
|
|
3572
|
+
draft.mode,
|
|
3573
|
+
chooseMode,
|
|
3574
|
+
{ hint: t(`settings.mode.${draft.mode}Hint`) },
|
|
3575
|
+
);
|
|
3576
|
+
let showForm = draft.mode !== "off" || offExpanded;
|
|
3577
|
+
let dirty = isDirty();
|
|
3578
|
+
|
|
3579
|
+
let children = [
|
|
3580
|
+
h("div", { className: "dsh-advisor-head", key: "head" }, [
|
|
3581
|
+
h("div", { className: "dsh-advisor-title", key: "title" }, t("settings.title")),
|
|
3582
|
+
h("div", { className: "dsh-advisor-desc", key: "desc" }, t("settings.desc")),
|
|
3583
|
+
]),
|
|
3584
|
+
errorBanner(),
|
|
3585
|
+
modeRow,
|
|
3586
|
+
];
|
|
3587
|
+
if (!showForm) {
|
|
3588
|
+
children.push(offNotice());
|
|
3589
|
+
} else {
|
|
3590
|
+
if (draft.mode === "off") children.push(offNotice());
|
|
3591
|
+
children.push(group("settings.group.basic", basicBody, "basic"));
|
|
3592
|
+
children.push(
|
|
3593
|
+
disclosure(
|
|
3594
|
+
"advanced",
|
|
3595
|
+
t("settings.group.advanced"),
|
|
3596
|
+
advancedBadge,
|
|
3597
|
+
advancedBody,
|
|
3598
|
+
advancedOpen,
|
|
3599
|
+
function toggleAdvanced() {
|
|
3600
|
+
setAdvancedOpen(!advancedOpen);
|
|
3601
|
+
},
|
|
3602
|
+
),
|
|
3603
|
+
);
|
|
3604
|
+
children.push(
|
|
3605
|
+
disclosure(
|
|
3606
|
+
"status",
|
|
3607
|
+
t("settings.group.status"),
|
|
3608
|
+
t("settings.status.calls").replace("{count}", formatCount(totals.calls)),
|
|
3609
|
+
statusBody,
|
|
3610
|
+
statusOpen,
|
|
3611
|
+
function toggleStatus() {
|
|
3612
|
+
setStatusOpen(!statusOpen);
|
|
3613
|
+
},
|
|
3614
|
+
),
|
|
3615
|
+
);
|
|
3616
|
+
}
|
|
3617
|
+
children.push(noticeNode);
|
|
3618
|
+
children.push(actionBar(dirty));
|
|
3619
|
+
|
|
2690
3620
|
return h(
|
|
2691
3621
|
"div",
|
|
2692
3622
|
{
|
|
@@ -2695,87 +3625,7 @@ window.__ModuleLoader__.load({
|
|
|
2695
3625
|
"data-advisor-settings": "",
|
|
2696
3626
|
role: "group",
|
|
2697
3627
|
},
|
|
2698
|
-
|
|
2699
|
-
h("div", { className: "dsh-advisor-head", key: "head" }, [
|
|
2700
|
-
h("div", { className: "dsh-advisor-title", key: "title" }, t("settings.title")),
|
|
2701
|
-
h("div", { className: "dsh-advisor-desc", key: "desc" }, t("settings.desc")),
|
|
2702
|
-
]),
|
|
2703
|
-
errorBanner(),
|
|
2704
|
-
group(
|
|
2705
|
-
"settings.group.basic",
|
|
2706
|
-
[
|
|
2707
|
-
radioField(
|
|
2708
|
-
"mode",
|
|
2709
|
-
"settings.mode",
|
|
2710
|
-
SETTINGS_MODES,
|
|
2711
|
-
"settings.mode.",
|
|
2712
|
-
draft.mode,
|
|
2713
|
-
chooseMode,
|
|
2714
|
-
"mode",
|
|
2715
|
-
),
|
|
2716
|
-
providerField(),
|
|
2717
|
-
modelField(),
|
|
2718
|
-
effortField(),
|
|
2719
|
-
selectField(
|
|
2720
|
-
"postAnswer",
|
|
2721
|
-
"settings.postAnswer",
|
|
2722
|
-
SETTINGS_POST_ANSWER,
|
|
2723
|
-
"settings.postAnswer.",
|
|
2724
|
-
draft.postAnswer,
|
|
2725
|
-
choosePostAnswer,
|
|
2726
|
-
"settings.postAnswer.hint",
|
|
2727
|
-
),
|
|
2728
|
-
switchField("advisorTools", "settings.advisorTools", "settings.advisorToolsHint"),
|
|
2729
|
-
],
|
|
2730
|
-
"basic",
|
|
2731
|
-
),
|
|
2732
|
-
group("settings.group.budget", budgetGroup, "budget"),
|
|
2733
|
-
group(
|
|
2734
|
-
"settings.group.privacy",
|
|
2735
|
-
[
|
|
2736
|
-
radioField(
|
|
2737
|
-
"scope",
|
|
2738
|
-
"settings.scope",
|
|
2739
|
-
SETTINGS_SCOPES,
|
|
2740
|
-
"settings.scope.",
|
|
2741
|
-
draft.privacyScope,
|
|
2742
|
-
chooseScope,
|
|
2743
|
-
"scope",
|
|
2744
|
-
),
|
|
2745
|
-
switchField("redact", "settings.privacy.redact", "settings.privacy.redactHint"),
|
|
2746
|
-
switchField("dedupe", "settings.privacy.dedupe", "settings.privacy.dedupeHint"),
|
|
2747
|
-
],
|
|
2748
|
-
"privacy",
|
|
2749
|
-
),
|
|
2750
|
-
group("settings.group.advanced", advancedGroup, "advanced"),
|
|
2751
|
-
noticeNode,
|
|
2752
|
-
h("div", { className: "dsh-advisor-actions", key: "actions" }, [
|
|
2753
|
-
h(
|
|
2754
|
-
"button",
|
|
2755
|
-
{
|
|
2756
|
-
className: "dsh-advisor-btn dsh-advisor-btn--primary",
|
|
2757
|
-
"data-advisor-save": "",
|
|
2758
|
-
disabled: busy === "save" || busy === "load",
|
|
2759
|
-
key: "save",
|
|
2760
|
-
onClick: save,
|
|
2761
|
-
type: "button",
|
|
2762
|
-
},
|
|
2763
|
-
busy === "save" ? t("settings.saving") : t("settings.save"),
|
|
2764
|
-
),
|
|
2765
|
-
h(
|
|
2766
|
-
"button",
|
|
2767
|
-
{
|
|
2768
|
-
className: "dsh-advisor-btn",
|
|
2769
|
-
"data-advisor-reload": "",
|
|
2770
|
-
disabled: busy === "load",
|
|
2771
|
-
key: "reload",
|
|
2772
|
-
onClick: reload,
|
|
2773
|
-
type: "button",
|
|
2774
|
-
},
|
|
2775
|
-
t("settings.reload"),
|
|
2776
|
-
),
|
|
2777
|
-
]),
|
|
2778
|
-
],
|
|
3628
|
+
children,
|
|
2779
3629
|
);
|
|
2780
3630
|
}
|
|
2781
3631
|
|
|
@@ -2787,22 +3637,21 @@ window.__ModuleLoader__.load({
|
|
|
2787
3637
|
// 而 slot 的 t() 只认这里注册的字典。两处必须同步(`test/locale-parity.test.js` 会守住)。
|
|
2788
3638
|
const LOCALE_EXTRA = {
|
|
2789
3639
|
zh: {
|
|
2790
|
-
|
|
2791
|
-
"settings.postAnswer": "
|
|
2792
|
-
"settings.postAnswer.
|
|
2793
|
-
"settings.postAnswer.
|
|
2794
|
-
|
|
3640
|
+
"settings.postAnswer": "回合结束后自动复查",
|
|
3641
|
+
"settings.postAnswer.off": "不跑",
|
|
3642
|
+
"settings.postAnswer.card": "只记录一行",
|
|
3643
|
+
"settings.postAnswer.hint":
|
|
3644
|
+
"每轮回答后自动复查一次;只记录建议,不插回对话。会产生额外调用和费用。",
|
|
2795
3645
|
"settings.advisorTools": "允许顾问读文件核实",
|
|
2796
3646
|
"settings.advisorToolsHint":
|
|
2797
|
-
"
|
|
2798
|
-
"settings.budget.workspaceMaxCallsPerDay": "
|
|
2799
|
-
"settings.budget.workspaceMaxCostPerDayUsd": "工作区每日预算(USD)",
|
|
3647
|
+
"允许顾问读取工作目录里的文件来核实结论(最多 5 个、只读);会多一次模型调用。",
|
|
3648
|
+
"settings.budget.workspaceMaxCallsPerDay": "工作区每日调用上限",
|
|
2800
3649
|
"settings.budget.workspaceHint": "工作区级,跨会话累计、按本地日重置",
|
|
2801
3650
|
"settings.budget.poolLine": "工作区今日:{calls} 次 · ≈{cost}",
|
|
2802
3651
|
"settings.budget.priceSource.builtin": "单价来源:内置参考价",
|
|
2803
3652
|
"settings.budget.priceSource.settings": "单价来源:你设置的",
|
|
2804
3653
|
"settings.budget.priceSource.none": "单价来源:未配置(只记 token)",
|
|
2805
|
-
"settings.advanced.allowedModels": "模型白名单
|
|
3654
|
+
"settings.advanced.allowedModels": "模型白名单",
|
|
2806
3655
|
"settings.advanced.allowedModelsHint": "留空=不限制;可写 provider/model 或裸 model id",
|
|
2807
3656
|
"settings.advanced.allowedModelsPlaceholder": "例如 deepseek/deepseek-chat, gpt-4o",
|
|
2808
3657
|
"settings.preview": "发送预览",
|
|
@@ -2818,26 +3667,132 @@ window.__ModuleLoader__.load({
|
|
|
2818
3667
|
"settings.confirm.done": "已确认 {provider}",
|
|
2819
3668
|
"settings.error.preview": "预览失败,稍后重试",
|
|
2820
3669
|
"settings.error.confirm": "确认失败,稍后重试",
|
|
3670
|
+
"settings.tracePrompt": "记录发送内容",
|
|
3671
|
+
"settings.tracePrompt.preview": "首尾预览",
|
|
3672
|
+
"settings.tracePrompt.off": "不记录",
|
|
3673
|
+
"settings.tracePrompt.hint":
|
|
3674
|
+
"在会话记录里保留本次实际发送文本的首尾各 2,000 字符(脱敏后);关掉后只记元数据。发送前脱敏关闭时,预览也会包含原文。",
|
|
3675
|
+
"settings.help.defaultPreview": "默认:首尾预览",
|
|
3676
|
+
"settings.currency": "币种",
|
|
3677
|
+
"settings.currency.USD": "美元(USD)",
|
|
3678
|
+
"settings.currency.CNY": "人民币(CNY)",
|
|
3679
|
+
"settings.currencyHint":
|
|
3680
|
+
"金额和单价按此币种填写;切换时会按汇率折算金额,保持真实价值不变。",
|
|
3681
|
+
"settings.currency.converted": "已按 1 USD = {rate} CNY 折算金额(尚未保存)。",
|
|
3682
|
+
"settings.usdToCny": "人民币汇率",
|
|
3683
|
+
"settings.usdToCnyHint":
|
|
3684
|
+
"1 USD = ? CNY;只在币种为人民币时用于换算。插件不联网取汇率,请手动维护。",
|
|
3685
|
+
"settings.unit.cny": "元",
|
|
3686
|
+
"settings.unit.cnyPerMTok": "元 / 百万 token",
|
|
3687
|
+
"settings.unit.cnyPerUsd": "元 / USD",
|
|
3688
|
+
"settings.budget.maxCostPerDay": "每日预算",
|
|
3689
|
+
"settings.budget.workspaceMaxCostPerDay": "工作区每日预算",
|
|
3690
|
+
"tail.trace.preview": "查看发送内容",
|
|
3691
|
+
"tail.trace.previewHide": "收起发送内容",
|
|
3692
|
+
"tail.trace.previewTruncated": "实际发送(脱敏后,首尾各 2,000 字符;共 {chars} 字符)",
|
|
3693
|
+
"tail.trace.previewFull": "实际发送(脱敏后,共 {chars} 字符)",
|
|
3694
|
+
"tail.trace.previewNone":
|
|
3695
|
+
"这条记录没有保存发送内容(可能是旧记录,或已在高级设置里关闭记录)。",
|
|
3696
|
+
"settings.desc": "基础设置开箱即用;高级项默认折叠。保存后的改动对下一次徵询生效。",
|
|
3697
|
+
"settings.group.basic": "基础设置",
|
|
3698
|
+
"settings.group.budget": "预算与限额",
|
|
3699
|
+
"settings.group.advanced": "高级设置",
|
|
3700
|
+
"settings.mode.off": "关闭",
|
|
3701
|
+
"settings.mode.shadow": "影子",
|
|
3702
|
+
"settings.mode.advisory": "顾问",
|
|
3703
|
+
"settings.mode.shadowHint": "会调用顾问并记账,但不会把建议放进对话;适合先观察。",
|
|
3704
|
+
"settings.mode.advisoryHint": "会徵询顾问,并把建议交给模型;模型可以采纳或忽略。",
|
|
3705
|
+
"settings.provider": "服务商",
|
|
3706
|
+
"settings.model": "模型",
|
|
3707
|
+
"settings.budget.maxCallsPerTurn": "每回合调用上限",
|
|
3708
|
+
"settings.budget.maxCallsPerSession": "每会话调用上限",
|
|
3709
|
+
"settings.budget.maxCallsPerHour": "每小时调用上限",
|
|
3710
|
+
"settings.budget.priceInputPerMTok": "输入单价",
|
|
3711
|
+
"settings.budget.priceOutputPerMTok": "输出单价",
|
|
3712
|
+
"settings.scope.off": "不发送",
|
|
3713
|
+
"settings.scope.summary": "摘要",
|
|
3714
|
+
"settings.scope.full": "完整",
|
|
3715
|
+
"settings.scope.summaryHint": "只发一段约 300 字的会话摘要,不发文件全文。",
|
|
3716
|
+
"settings.scope.fullHint": "发送完整上下文,按输入上限截断。",
|
|
3717
|
+
"settings.privacy.redact": "发送前脱敏",
|
|
3718
|
+
"settings.privacy.redactHint": "自动遮掉常见的密钥格式;不能保证全部遮住。",
|
|
3719
|
+
"settings.privacy.dedupe": "影子模式去重",
|
|
3720
|
+
"settings.privacy.dedupeHint": "影子模式下,相同的建议只记一次。",
|
|
3721
|
+
"settings.advanced.maxTokens": "输出上限",
|
|
3722
|
+
"settings.advanced.temperature": "随机性",
|
|
3723
|
+
"settings.advanced.temperatureHint": "留空 = 由模型决定;范围 0–2。",
|
|
3724
|
+
"settings.advanced.maxInputChars": "输入上限",
|
|
3725
|
+
"settings.advanced.sessionCap": "建议条数上限",
|
|
3726
|
+
"settings.off.title": "顾问已关闭",
|
|
3727
|
+
"settings.off.desc": "不会调用顾问,也不产生费用。",
|
|
3728
|
+
"settings.off.unconfigured": "还没有选择顾问模型。点「配置顾问」选择服务商和模型。",
|
|
3729
|
+
"settings.off.configured": "已配置:{provider} / {model}。启用后生效。",
|
|
3730
|
+
"settings.off.configure": "配置顾问",
|
|
3731
|
+
"settings.off.collapse": "收起配置",
|
|
3732
|
+
"settings.dirty": "有未保存的改动",
|
|
3733
|
+
"settings.advanced.intro": "以下都有合理默认值,通常不用改;改过的项会显示在标题上。",
|
|
3734
|
+
"settings.advanced.defaults": "默认值",
|
|
3735
|
+
"settings.advanced.changed": "{count} 项已修改",
|
|
3736
|
+
"settings.advanced.reset": "恢复默认",
|
|
3737
|
+
"settings.advanced.resetHint": "只重置高级字段,不影响模式、服务商、模型和隐私。",
|
|
3738
|
+
"settings.advanced.resetDone": "高级设置已恢复默认(尚未保存)。",
|
|
3739
|
+
"settings.advanced.more": "还有 {fields} 等冷门项;需要时可直接编辑设置文件。",
|
|
3740
|
+
"settings.advanced.moreFields": "tiers、pairingEnforcement、timeoutMs、immuneTurns",
|
|
3741
|
+
"settings.advanced.copyPath": "复制路径",
|
|
3742
|
+
"settings.advanced.copied": "已复制",
|
|
3743
|
+
"settings.advanced.copyFailed": "复制失败,请手动复制。",
|
|
3744
|
+
"settings.advanced.pathUnknown": "宿主没有返回设置文件路径。",
|
|
3745
|
+
"settings.advanced.dailyBudgetNote":
|
|
3746
|
+
"每日预算在基础设置里;这里是调用次数和工作区级限额。",
|
|
3747
|
+
"settings.group.model": "顾问模型",
|
|
3748
|
+
"settings.group.spend": "预算",
|
|
3749
|
+
"settings.group.limits": "调用限额",
|
|
3750
|
+
"settings.group.money": "单价",
|
|
3751
|
+
"settings.group.generation": "生成参数",
|
|
3752
|
+
"settings.group.delivery": "投递与行为",
|
|
3753
|
+
"settings.group.more": "更多",
|
|
3754
|
+
"settings.group.status": "状态与诊断",
|
|
3755
|
+
"settings.basic.budgetHint":
|
|
3756
|
+
"0 = 不限;默认 0,范围 0–10000(按当前币种)。切换币种会按汇率折算;更细的限额在高级设置里。",
|
|
3757
|
+
"settings.budget.maxCostHint": "每天最多花多少钱;0 = 不限。只有填了单价才会计算金额。",
|
|
3758
|
+
"settings.advanced.maxTokensHint": "单次回答最多生成多少 token;越大越贵。",
|
|
3759
|
+
"settings.advanced.maxInputCharsHint":
|
|
3760
|
+
"一次最多发送多少字符的会话内容;超出会保留首尾、省略中间。",
|
|
3761
|
+
"settings.advanced.sessionCapHint": "一个会话最多展示几条建议;到顶后只保留 blocker 级。",
|
|
3762
|
+
"settings.help.calls": "超过上限就跳过本次徵询;0 = 不限。",
|
|
3763
|
+
"settings.help.tech": "技术名:{key}",
|
|
3764
|
+
"settings.help.open": "查看 {field} 的说明",
|
|
3765
|
+
"settings.help.defaultOn": "默认:开",
|
|
3766
|
+
"settings.help.defaultOff": "默认:关",
|
|
3767
|
+
"settings.help.defaultOffOption": "默认:不跑",
|
|
3768
|
+
"settings.help.defaultEmpty": "默认:不限制",
|
|
3769
|
+
"settings.help.defaultNotSent": "默认:不传(由模型决定)",
|
|
3770
|
+
"settings.unit.usd": "USD",
|
|
3771
|
+
"settings.unit.usdPerMTok": "USD / 百万 token",
|
|
3772
|
+
"settings.unit.tokens": "token",
|
|
3773
|
+
"settings.unit.chars": "字符",
|
|
3774
|
+
"settings.unit.calls": "次",
|
|
3775
|
+
"settings.unit.items": "条",
|
|
3776
|
+
"settings.paths.settings": "设置文件:{path}",
|
|
3777
|
+
"settings.paths.ledger": "账本:{path}",
|
|
2821
3778
|
},
|
|
2822
3779
|
en: {
|
|
2823
|
-
|
|
2824
|
-
"settings.postAnswer": "
|
|
2825
|
-
"settings.postAnswer.
|
|
2826
|
-
"settings.postAnswer.card": "card (record one line)",
|
|
3780
|
+
"settings.postAnswer": "Auto-review after each turn",
|
|
3781
|
+
"settings.postAnswer.off": "Do not run",
|
|
3782
|
+
"settings.postAnswer.card": "Record one line",
|
|
2827
3783
|
"settings.postAnswer.hint":
|
|
2828
|
-
"
|
|
3784
|
+
"Runs the advisor once after each answer; records advice only, never inserts it into the conversation. Costs an extra call.",
|
|
2829
3785
|
"settings.advisorTools": "Let the advisor read files",
|
|
2830
3786
|
"settings.advisorToolsHint":
|
|
2831
|
-
"
|
|
2832
|
-
"settings.budget.workspaceMaxCallsPerDay": "Workspace
|
|
2833
|
-
"settings.budget.workspaceMaxCostPerDayUsd": "Workspace daily budget (USD)",
|
|
3787
|
+
"Lets the advisor read files in the working directory to verify conclusions (up to 5 files, read-only); costs one extra model call.",
|
|
3788
|
+
"settings.budget.workspaceMaxCallsPerDay": "Workspace calls per day",
|
|
2834
3789
|
"settings.budget.workspaceHint":
|
|
2835
3790
|
"Workspace-wide: shared across sessions, resets on the local day",
|
|
2836
3791
|
"settings.budget.poolLine": "Workspace today: {calls} calls · ≈{cost}",
|
|
2837
3792
|
"settings.budget.priceSource.builtin": "Price source: built-in reference",
|
|
2838
3793
|
"settings.budget.priceSource.settings": "Price source: yours",
|
|
2839
3794
|
"settings.budget.priceSource.none": "Price source: not set (tokens only)",
|
|
2840
|
-
"settings.advanced.allowedModels": "Model allowlist
|
|
3795
|
+
"settings.advanced.allowedModels": "Model allowlist",
|
|
2841
3796
|
"settings.advanced.allowedModelsHint":
|
|
2842
3797
|
"Empty = no limit; accepts provider/model or a bare model id",
|
|
2843
3798
|
"settings.advanced.allowedModelsPlaceholder": "e.g. deepseek/deepseek-chat, gpt-4o",
|
|
@@ -2855,6 +3810,125 @@ window.__ModuleLoader__.load({
|
|
|
2855
3810
|
"settings.confirm.done": "Confirmed {provider}",
|
|
2856
3811
|
"settings.error.preview": "Preview failed — try again later",
|
|
2857
3812
|
"settings.error.confirm": "Confirmation failed — try again later",
|
|
3813
|
+
"settings.tracePrompt": "Keep sent content",
|
|
3814
|
+
"settings.tracePrompt.preview": "Head/tail preview",
|
|
3815
|
+
"settings.tracePrompt.off": "Do not record",
|
|
3816
|
+
"settings.tracePrompt.hint":
|
|
3817
|
+
"Stores the first and last 2,000 characters of the text actually sent (after redaction) in the session record; off stores metadata only. If redaction is off, the preview contains raw text.",
|
|
3818
|
+
"settings.help.defaultPreview": "Default: head/tail preview",
|
|
3819
|
+
"settings.currency": "Currency",
|
|
3820
|
+
"settings.currency.USD": "US dollars (USD)",
|
|
3821
|
+
"settings.currency.CNY": "Chinese yuan (CNY)",
|
|
3822
|
+
"settings.currencyHint":
|
|
3823
|
+
"Amounts and prices are entered in this currency; switching converts them at the configured rate so the real value stays the same.",
|
|
3824
|
+
"settings.currency.converted": "Converted amounts at 1 USD = {rate} CNY (not saved yet).",
|
|
3825
|
+
"settings.usdToCny": "CNY per USD",
|
|
3826
|
+
"settings.usdToCnyHint":
|
|
3827
|
+
"1 USD = ? CNY; only used when the currency is CNY. The plugin never fetches rates; maintain it manually.",
|
|
3828
|
+
"settings.unit.cny": "CNY",
|
|
3829
|
+
"settings.unit.cnyPerMTok": "CNY / 1M tokens",
|
|
3830
|
+
"settings.unit.cnyPerUsd": "CNY / USD",
|
|
3831
|
+
"settings.budget.maxCostPerDay": "Daily budget",
|
|
3832
|
+
"settings.budget.workspaceMaxCostPerDay": "Workspace daily budget",
|
|
3833
|
+
"tail.trace.preview": "View sent content",
|
|
3834
|
+
"tail.trace.previewHide": "Hide sent content",
|
|
3835
|
+
"tail.trace.previewTruncated": "Sent (redacted; first/last 2,000 of {chars} chars)",
|
|
3836
|
+
"tail.trace.previewFull": "Sent (redacted; {chars} chars)",
|
|
3837
|
+
"tail.trace.previewNone":
|
|
3838
|
+
"No sent content saved for this record (older record, or disabled in Advanced).",
|
|
3839
|
+
"settings.desc":
|
|
3840
|
+
"The basics work out of the box; advanced knobs stay folded. Saved changes apply to the next consultation.",
|
|
3841
|
+
"settings.group.basic": "Basics",
|
|
3842
|
+
"settings.group.budget": "Budgets & limits",
|
|
3843
|
+
"settings.group.advanced": "Advanced",
|
|
3844
|
+
"settings.mode.off": "Off",
|
|
3845
|
+
"settings.mode.shadow": "Shadow",
|
|
3846
|
+
"settings.mode.advisory": "Advisory",
|
|
3847
|
+
"settings.mode.shadowHint":
|
|
3848
|
+
"Calls the advisor and records it, but never puts advice into the conversation — useful for observing first.",
|
|
3849
|
+
"settings.mode.advisoryHint":
|
|
3850
|
+
"Calls the advisor and hands the advice to the model; the model may take it or ignore it.",
|
|
3851
|
+
"settings.provider": "Provider",
|
|
3852
|
+
"settings.model": "Model",
|
|
3853
|
+
"settings.budget.maxCallsPerTurn": "Calls per turn",
|
|
3854
|
+
"settings.budget.maxCallsPerSession": "Calls per session",
|
|
3855
|
+
"settings.budget.maxCallsPerHour": "Calls per hour",
|
|
3856
|
+
"settings.budget.priceInputPerMTok": "Input price",
|
|
3857
|
+
"settings.budget.priceOutputPerMTok": "Output price",
|
|
3858
|
+
"settings.scope.off": "None",
|
|
3859
|
+
"settings.scope.summary": "Summary",
|
|
3860
|
+
"settings.scope.full": "Full",
|
|
3861
|
+
"settings.scope.summaryHint":
|
|
3862
|
+
"Sends a ~300-character conversation summary; no file contents.",
|
|
3863
|
+
"settings.scope.fullHint": "Sends the full context, truncated to the input limit.",
|
|
3864
|
+
"settings.privacy.redact": "Redact before sending",
|
|
3865
|
+
"settings.privacy.redactHint":
|
|
3866
|
+
"Masks common key formats; it cannot guarantee every secret is caught.",
|
|
3867
|
+
"settings.privacy.dedupe": "Dedupe in shadow mode",
|
|
3868
|
+
"settings.privacy.dedupeHint": "In shadow mode, the same advice is recorded only once.",
|
|
3869
|
+
"settings.advanced.maxTokens": "Output limit",
|
|
3870
|
+
"settings.advanced.temperature": "Randomness",
|
|
3871
|
+
"settings.advanced.temperatureHint": "Empty = let the model decide; range 0–2.",
|
|
3872
|
+
"settings.advanced.maxInputChars": "Input limit",
|
|
3873
|
+
"settings.advanced.sessionCap": "Advice items per session",
|
|
3874
|
+
"settings.off.title": "Advisor is off",
|
|
3875
|
+
"settings.off.desc": "It never calls the advisor and never spends.",
|
|
3876
|
+
"settings.off.unconfigured":
|
|
3877
|
+
"No advisor model selected yet. Choose “Configure advisor” to pick a provider and model.",
|
|
3878
|
+
"settings.off.configured": "Configured: {provider} / {model}. Takes effect when enabled.",
|
|
3879
|
+
"settings.off.configure": "Configure advisor",
|
|
3880
|
+
"settings.off.collapse": "Hide configuration",
|
|
3881
|
+
"settings.dirty": "Unsaved changes",
|
|
3882
|
+
"settings.advanced.intro":
|
|
3883
|
+
"Sensible defaults; you normally do not need to change these. Modified items show on the heading.",
|
|
3884
|
+
"settings.advanced.defaults": "Defaults",
|
|
3885
|
+
"settings.advanced.changed": "{count} changed",
|
|
3886
|
+
"settings.advanced.reset": "Reset to defaults",
|
|
3887
|
+
"settings.advanced.resetHint":
|
|
3888
|
+
"Only resets advanced fields; mode, provider, model and privacy stay.",
|
|
3889
|
+
"settings.advanced.resetDone": "Advanced settings restored to defaults (not saved yet).",
|
|
3890
|
+
"settings.advanced.more":
|
|
3891
|
+
"Rarely changed keys such as {fields} can be edited directly in the settings file.",
|
|
3892
|
+
"settings.advanced.moreFields": "tiers, pairingEnforcement, timeoutMs, immuneTurns",
|
|
3893
|
+
"settings.advanced.copyPath": "Copy path",
|
|
3894
|
+
"settings.advanced.copied": "Copied",
|
|
3895
|
+
"settings.advanced.copyFailed": "Copy failed — copy it manually.",
|
|
3896
|
+
"settings.advanced.pathUnknown": "The host did not return the settings file path.",
|
|
3897
|
+
"settings.advanced.dailyBudgetNote":
|
|
3898
|
+
"The daily budget is under Basics; this section has call and workspace-level limits.",
|
|
3899
|
+
"settings.group.model": "Advisor model",
|
|
3900
|
+
"settings.group.spend": "Budget",
|
|
3901
|
+
"settings.group.limits": "Call limits",
|
|
3902
|
+
"settings.group.money": "Prices",
|
|
3903
|
+
"settings.group.generation": "Generation",
|
|
3904
|
+
"settings.group.delivery": "Delivery & behavior",
|
|
3905
|
+
"settings.group.more": "More",
|
|
3906
|
+
"settings.group.status": "Status & diagnostics",
|
|
3907
|
+
"settings.basic.budgetHint":
|
|
3908
|
+
"0 = unlimited; default 0, range 0–10000. Finer limits are under Advanced.",
|
|
3909
|
+
"settings.budget.maxCostHint":
|
|
3910
|
+
"Maximum spend per day; 0 = unlimited. Only counted when prices are set.",
|
|
3911
|
+
"settings.advanced.maxTokensHint": "Maximum output tokens per answer; higher costs more.",
|
|
3912
|
+
"settings.advanced.maxInputCharsHint":
|
|
3913
|
+
"Maximum characters of conversation sent per call; excess in the middle is elided, head and tail kept.",
|
|
3914
|
+
"settings.advanced.sessionCapHint":
|
|
3915
|
+
"Maximum advice items shown per session; once reached only blocker items get through.",
|
|
3916
|
+
"settings.help.calls": "Above the limit, the consultation is skipped; 0 = unlimited.",
|
|
3917
|
+
"settings.help.tech": "Key: {key}",
|
|
3918
|
+
"settings.help.open": "Show help for {field}",
|
|
3919
|
+
"settings.help.defaultOn": "Default: on",
|
|
3920
|
+
"settings.help.defaultOff": "Default: off",
|
|
3921
|
+
"settings.help.defaultOffOption": "Default: off",
|
|
3922
|
+
"settings.help.defaultEmpty": "Default: no limit",
|
|
3923
|
+
"settings.help.defaultNotSent": "Default: not sent (model default)",
|
|
3924
|
+
"settings.unit.usd": "USD",
|
|
3925
|
+
"settings.unit.usdPerMTok": "USD / 1M tokens",
|
|
3926
|
+
"settings.unit.tokens": "tokens",
|
|
3927
|
+
"settings.unit.chars": "chars",
|
|
3928
|
+
"settings.unit.calls": "calls",
|
|
3929
|
+
"settings.unit.items": "items",
|
|
3930
|
+
"settings.paths.settings": "Settings file: {path}",
|
|
3931
|
+
"settings.paths.ledger": "Ledger: {path}",
|
|
2858
3932
|
},
|
|
2859
3933
|
};
|
|
2860
3934
|
|
|
@@ -3403,6 +4477,10 @@ window.__ModuleLoader__.load({
|
|
|
3403
4477
|
interpretSetModel: interpretSetModel,
|
|
3404
4478
|
clampInt: clampInt,
|
|
3405
4479
|
clampFloat: clampFloat,
|
|
4480
|
+
clampMoney: clampMoney,
|
|
4481
|
+
formatMoneyInput: formatMoneyInput,
|
|
4482
|
+
convertCurrency: convertCurrency,
|
|
4483
|
+
normalizeSettingsView: normalizeSettingsView,
|
|
3406
4484
|
normalizeOptions: normalizeOptions,
|
|
3407
4485
|
normalizeModels: normalizeModels,
|
|
3408
4486
|
normalizeModelInfo: normalizeModelInfo,
|
|
@@ -3412,6 +4490,9 @@ window.__ModuleLoader__.load({
|
|
|
3412
4490
|
diffSettings: diffSettings,
|
|
3413
4491
|
interpretUpdate: interpretUpdate,
|
|
3414
4492
|
normalizeAdviceItems: normalizeAdviceItems,
|
|
4493
|
+
formatClock: formatClock,
|
|
4494
|
+
traceTextOf: traceTextOf,
|
|
4495
|
+
triggerLabel: triggerLabel,
|
|
3415
4496
|
truncateText: truncateText,
|
|
3416
4497
|
turnNumberOf: turnNumberOf,
|
|
3417
4498
|
slotTurnNumber: slotTurnNumber,
|