@eddyskywalker/dsh-chatgpt-subscription 0.77.0 → 0.78.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/lib/client.js CHANGED
@@ -938,6 +938,32 @@ window.__ModuleLoader__.load({
938
938
  defaultReasoningEffort: "high",
939
939
  reasoningProfile: "standard",
940
940
  supportsReasoningSummary: false
941
+ },
942
+ {
943
+ id: "gpt-6.2-astra",
944
+ name: "6.2 Astra",
945
+ contextWindow: 272e3,
946
+ inputModalities: ["text", "image"],
947
+ defaultReasoningEffort: "low",
948
+ reasoningProfile: "gpt-6",
949
+ supportsReasoningSummary: true,
950
+ maxTokens: GPT_6_MAX_TOKENS,
951
+ supportsOutputVerbosity: true,
952
+ defaultOutputVerbosity: "low",
953
+ useResponsesLite: true
954
+ },
955
+ {
956
+ id: "gpt-6.2-sol",
957
+ name: "6.2 Sol",
958
+ contextWindow: 5e5,
959
+ inputModalities: ["text", "image"],
960
+ defaultReasoningEffort: "low",
961
+ reasoningProfile: "gpt-6",
962
+ supportsReasoningSummary: true,
963
+ maxTokens: GPT_6_MAX_TOKENS,
964
+ supportsOutputVerbosity: true,
965
+ defaultOutputVerbosity: "low",
966
+ useResponsesLite: true
941
967
  }
942
968
  ];
943
969
  const DEFAULT_VISIBLE_CODEX_MODEL_IDS = [
@@ -948,7 +974,9 @@ window.__ModuleLoader__.load({
948
974
  "gpt-6-luna",
949
975
  "gpt-5.6-sol",
950
976
  "gpt-5.6-terra",
951
- "gpt-5.6-luna"
977
+ "gpt-5.6-luna",
978
+ "gpt-6.2-astra",
979
+ "gpt-6.2-sol"
952
980
  ];
953
981
  const DEFAULT_CODEX_MODEL = CODEX_MODEL_CATALOG[0];
954
982
  /**
@@ -5491,7 +5519,7 @@ window.__ModuleLoader__.load({
5491
5519
  /** 提示条箭头离气泡两端的最小距离,免得圆角把三角切掉。 */
5492
5520
  const ARROW_INSET = 12;
5493
5521
  /** 百分比,最多两位小数;非有限数不画。舍入规则放在共享的 `formatPercent`。 */
5494
- function percentText$3(value) {
5522
+ function percentText$2(value) {
5495
5523
  if (!Number.isFinite(value)) return "0%";
5496
5524
  return `${formatPercent$1(value)}%`;
5497
5525
  }
@@ -5666,7 +5694,7 @@ window.__ModuleLoader__.load({
5666
5694
  children: headline
5667
5695
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5668
5696
  className: "dsha-kq-value",
5669
- children: percentText$3(totalPercent)
5697
+ children: percentText$2(totalPercent)
5670
5698
  })]
5671
5699
  }),
5672
5700
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -5692,7 +5720,7 @@ window.__ModuleLoader__.load({
5692
5720
  "--kq-tip-shift": `${tipPlacement.shift}px`,
5693
5721
  ...tipPlacement.arrowPx === null ? {} : { "--kq-tip-arrow": `${tipPlacement.arrowPx}px` }
5694
5722
  },
5695
- children: t.kqTip.replace("{pct}", percentText$3(totalPercent))
5723
+ children: t.kqTip.replace("{pct}", percentText$2(totalPercent))
5696
5724
  })]
5697
5725
  }),
5698
5726
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -5702,7 +5730,7 @@ window.__ModuleLoader__.load({
5702
5730
  className: "dsha-kq-legend-item",
5703
5731
  children: [
5704
5732
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", { className: "dsha-kq-dot dsha-kq-dot--recent" }),
5705
- t.kqShortWindow.replace("{pct}", percentText$3(used(shortWindow))),
5733
+ t.kqShortWindow.replace("{pct}", percentText$2(used(shortWindow))),
5706
5734
  shortReset !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5707
5735
  className: "dsha-kq-legend-note",
5708
5736
  children: shortReset > clock ? t.kqResetIn.replace("{time}", durationText(t, shortReset - clock)) : t.kqResetSoon
@@ -13974,7 +14002,7 @@ window.__ModuleLoader__.load({
13974
14002
  return stepCodeRegionOf(profile) === "cn" ? t.regionCn : t.regionIntl;
13975
14003
  }
13976
14004
  /** 百分比,最多一位小数;调用方已经排除了非有限值。 */
13977
- function percentText$2(ratio) {
14005
+ function percentText$1(ratio) {
13978
14006
  const value = Math.max(0, Math.min(1, ratio));
13979
14007
  try {
13980
14008
  return `${new Intl.NumberFormat(void 0, { maximumFractionDigits: 1 }).format(value * 100)}%`;
@@ -13987,7 +14015,7 @@ window.__ModuleLoader__.load({
13987
14015
  return usedPercent >= 95 ? "danger" : usedPercent >= 80 ? "warning" : "normal";
13988
14016
  }
13989
14017
  /** 千分位;Intl 不可用时退回原值,不让一个格式化失败变成一次渲染失败。 */
13990
- function tokenText$2(value) {
14018
+ function tokenText$1(value) {
13991
14019
  try {
13992
14020
  return new Intl.NumberFormat().format(value);
13993
14021
  } catch {
@@ -14051,7 +14079,7 @@ window.__ModuleLoader__.load({
14051
14079
  measured ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14052
14080
  className: "dshsc-quota-track",
14053
14081
  role: "progressbar",
14054
- "aria-label": `${name}: ${percentText$2(used / 100)} ${t.quotaUsed}`,
14082
+ "aria-label": `${name}: ${percentText$1(used / 100)} ${t.quotaUsed}`,
14055
14083
  "aria-valuemin": 0,
14056
14084
  "aria-valuemax": 100,
14057
14085
  "aria-valuenow": used,
@@ -14062,7 +14090,7 @@ window.__ModuleLoader__.load({
14062
14090
  }),
14063
14091
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14064
14092
  className: "dshsc-quota-value",
14065
- children: measured ? percentText$2(used / 100) : t.quotaUsedUnknown
14093
+ children: measured ? percentText$1(used / 100) : t.quotaUsedUnknown
14066
14094
  }),
14067
14095
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14068
14096
  className: "dshsc-quota-meta",
@@ -14357,7 +14385,7 @@ window.__ModuleLoader__.load({
14357
14385
  children: [
14358
14386
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14359
14387
  className: "dsha-meter-label",
14360
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t.cacheHitRatio }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: hitRatio === null ? t.cacheHitRatioUnavailable : percentText$2(hitRatio) })]
14388
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t.cacheHitRatio }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: hitRatio === null ? t.cacheHitRatioUnavailable : percentText$1(hitRatio) })]
14361
14389
  }),
14362
14390
  hitRatio !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
14363
14391
  className: `dsha-meter ${hitRatio >= .9 ? "dsha-meter-green" : "dsha-meter-cyan"}`,
@@ -14369,17 +14397,17 @@ window.__ModuleLoader__.load({
14369
14397
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
14370
14398
  t.cacheReadTokens,
14371
14399
  ": ",
14372
- tokenText$2(cache.cacheReadTokens)
14400
+ tokenText$1(cache.cacheReadTokens)
14373
14401
  ] }),
14374
14402
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
14375
14403
  t.cacheMissedTokens,
14376
14404
  ": ",
14377
- tokenText$2(cache.missedInputTokens)
14405
+ tokenText$1(cache.missedInputTokens)
14378
14406
  ] }),
14379
14407
  cache.requests !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
14380
14408
  t.cacheRequests,
14381
14409
  ": ",
14382
- tokenText$2(cache.requests)
14410
+ tokenText$1(cache.requests)
14383
14411
  ] })
14384
14412
  ]
14385
14413
  })
@@ -14395,7 +14423,7 @@ window.__ModuleLoader__.load({
14395
14423
  children: [
14396
14424
  t.cacheWriteNoteValue,
14397
14425
  ": ",
14398
- tokenText$2(cache.cacheWriteTokens),
14426
+ tokenText$1(cache.cacheWriteTokens),
14399
14427
  " · ",
14400
14428
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14401
14429
  className: "dshsc-mono",
@@ -14629,9 +14657,9 @@ window.__ModuleLoader__.load({
14629
14657
  children: [
14630
14658
  t.quotaBucketRemaining,
14631
14659
  ": ",
14632
- tokenText$2(bucket.remaining),
14660
+ tokenText$1(bucket.remaining),
14633
14661
  " / ",
14634
- tokenText$2(bucket.total)
14662
+ tokenText$1(bucket.total)
14635
14663
  ]
14636
14664
  }),
14637
14665
  bucket.expiresAt !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
@@ -17183,7 +17211,7 @@ window.__ModuleLoader__.load({
17183
17211
  * 说明」。
17184
17212
  */
17185
17213
  /** 百分比,最多一位小数;调用方已经排除了非有限值。 */
17186
- function percentText$1(ratio) {
17214
+ function percentText(ratio) {
17187
17215
  const value = Math.max(0, Math.min(1, ratio));
17188
17216
  try {
17189
17217
  return new Intl.NumberFormat(void 0, { maximumFractionDigits: 1 }).format(value * 100) + "%";
@@ -17192,7 +17220,7 @@ window.__ModuleLoader__.load({
17192
17220
  }
17193
17221
  }
17194
17222
  /** 千分位;Intl 不可用时退回原值,不让一个格式化失败变成一次渲染失败。 */
17195
- function tokenText$1(value) {
17223
+ function tokenText(value) {
17196
17224
  try {
17197
17225
  return new Intl.NumberFormat().format(value);
17198
17226
  } catch {
@@ -17202,8 +17230,8 @@ window.__ModuleLoader__.load({
17202
17230
  /** 一只桶的量文本:「剩余 / 总额 单位」,缺哪格哪格就明说「未报」。 */
17203
17231
  function bucketAmountText(bucket, t) {
17204
17232
  const unit = bucket.unit !== null && bucket.unit !== "" ? " " + bucket.unit : "";
17205
- const remaining = bucket.remaining !== null ? tokenText$1(bucket.remaining) : "—";
17206
- const total = bucket.total !== null ? tokenText$1(bucket.total) : "—";
17233
+ const remaining = bucket.remaining !== null ? tokenText(bucket.remaining) : "—";
17234
+ const total = bucket.total !== null ? tokenText(bucket.total) : "—";
17207
17235
  return t.quotaRemaining + " " + remaining + " / " + t.quotaTotal + " " + total + unit;
17208
17236
  }
17209
17237
  /** 档位 → 字典键。六个取值一一对应,没有兜底串。 */
@@ -17507,7 +17535,7 @@ window.__ModuleLoader__.load({
17507
17535
  children: [
17508
17536
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17509
17537
  className: "dsha-meter-label",
17510
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t.cacheHitRatio }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: hitRatio === null ? t.cacheHitRatioUnavailable : percentText$1(hitRatio) })]
17538
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t.cacheHitRatio }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: hitRatio === null ? t.cacheHitRatioUnavailable : percentText(hitRatio) })]
17511
17539
  }),
17512
17540
  hitRatio !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
17513
17541
  className: "dsha-meter " + (hitRatio >= .9 ? "dsha-meter-green" : "dsha-meter-cyan"),
@@ -17519,22 +17547,22 @@ window.__ModuleLoader__.load({
17519
17547
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
17520
17548
  t.cacheReadTokens,
17521
17549
  ": ",
17522
- tokenText$1(cache.cacheReadTokens)
17550
+ tokenText(cache.cacheReadTokens)
17523
17551
  ] }),
17524
17552
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
17525
17553
  t.cacheMissedTokens,
17526
17554
  ": ",
17527
- tokenText$1(cache.missedInputTokens)
17555
+ tokenText(cache.missedInputTokens)
17528
17556
  ] }),
17529
17557
  cache.cacheWriteTokens > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
17530
17558
  t.cacheWriteTokens,
17531
17559
  ": ",
17532
- tokenText$1(cache.cacheWriteTokens)
17560
+ tokenText(cache.cacheWriteTokens)
17533
17561
  ] }),
17534
17562
  cache.requests !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
17535
17563
  t.cacheRequests,
17536
17564
  ": ",
17537
- tokenText$1(cache.requests)
17565
+ tokenText(cache.requests)
17538
17566
  ] })
17539
17567
  ]
17540
17568
  })
@@ -17749,7 +17777,7 @@ window.__ModuleLoader__.load({
17749
17777
  children: [
17750
17778
  t.quotaUsed,
17751
17779
  " ",
17752
- percentText$1(bucket.used / bucket.total)
17780
+ percentText(bucket.used / bucket.total)
17753
17781
  ]
17754
17782
  })
17755
17783
  ]
@@ -20760,24 +20788,13 @@ window.__ModuleLoader__.load({
20760
20788
  routeOwned: "本插件正在服务该模型路由。",
20761
20789
  routeConflict: "模型路由被其他 Provider 占用:{detail}",
20762
20790
  cacheSection: "显式缓存",
20763
- cacheDesc: "Qwen4 自动断点与稳定前缀断点共同复用输入;这里只统计本机 Token,不代表上游账单或剩余 Credits。",
20791
+ cacheDesc: "Qwen4 自动断点与稳定前缀断点共同复用输入;用量统计见 DSH 自带的使用统计与千问用量控制台。",
20764
20792
  cacheEnabled: "启用显式缓存",
20765
20793
  cacheTtl: "缓存 TTL",
20766
20794
  ttl5m: "5 分钟(5m)",
20767
20795
  ttl1h: "1 小时(1h)",
20768
20796
  cacheHitRatio: "缓存命中率",
20769
- cacheRead: "缓存读取",
20770
- cacheMissed: "未缓存输入",
20771
- cacheWrite5m: "5m 缓存写入",
20772
- cacheWrite1h: "1h 缓存写入",
20773
- cacheRequests: "统计请求数",
20774
- reasoningTokens: "思考 Token",
20775
- encryptedReplays: "密文回放次数",
20776
- missingEncrypted: "密文缺失次数",
20777
- cacheEmpty: "还没有缓存用量样本。",
20778
- cacheUnavailable: "—",
20779
20797
  cacheHint: "缓存可能已过期:距最近请求约 {minutes} 分钟。",
20780
- resetCache: "清空本地统计",
20781
20798
  thinkingSection: "思考",
20782
20799
  defaultEffort: "默认推理档位",
20783
20800
  effortDefault: "跟随上游默认(high)",
@@ -20816,7 +20833,6 @@ window.__ModuleLoader__.load({
20816
20833
  maxPixelsReset: "恢复默认",
20817
20834
  invalidPixels: "max_pixels 必须是 65536 至 16777216 的整数。",
20818
20835
  visionHint: "普通截图建议使用 auto/low;OCR 或细小文字可切换 high。显式 max_pixels 优先。",
20819
- quotaNote: "本线路没有公开、可验证的剩余 Credits 查询接口,因此不显示余额或金额。",
20820
20836
  dashboard: "打开千问用量控制台",
20821
20837
  composerLabel: "Qwen 缓存",
20822
20838
  noQuota: "无配额数据",
@@ -20847,24 +20863,13 @@ window.__ModuleLoader__.load({
20847
20863
  routeOwned: "This plugin serves the model route.",
20848
20864
  routeConflict: "Another provider owns the model route: {detail}",
20849
20865
  cacheSection: "Explicit cache",
20850
- cacheDesc: "Qwen4 automatic and stable-prefix breakpoints reuse input. These are local token figures, not an upstream bill or remaining Credits.",
20866
+ cacheDesc: "Qwen4 automatic and stable-prefix breakpoints reuse input; usage figures live in DSH built-in usage stats and the Qianwen usage console.",
20851
20867
  cacheEnabled: "Enable explicit cache",
20852
20868
  cacheTtl: "Cache TTL",
20853
20869
  ttl5m: "5 minutes (5m)",
20854
20870
  ttl1h: "1 hour (1h)",
20855
20871
  cacheHitRatio: "Cache hit ratio",
20856
- cacheRead: "Cache reads",
20857
- cacheMissed: "Uncached input",
20858
- cacheWrite5m: "5m cache writes",
20859
- cacheWrite1h: "1h cache writes",
20860
- cacheRequests: "Requests counted",
20861
- reasoningTokens: "Reasoning tokens",
20862
- encryptedReplays: "Encrypted replays",
20863
- missingEncrypted: "Missing ciphertext",
20864
- cacheEmpty: "No cache usage samples yet.",
20865
- cacheUnavailable: "—",
20866
20872
  cacheHint: "The cache may be cold: about {minutes} minutes since the latest request.",
20867
- resetCache: "Clear local stats",
20868
20873
  thinkingSection: "Thinking",
20869
20874
  defaultEffort: "Default reasoning effort",
20870
20875
  effortDefault: "Upstream default (high)",
@@ -20903,7 +20908,6 @@ window.__ModuleLoader__.load({
20903
20908
  maxPixelsReset: "Restore default",
20904
20909
  invalidPixels: "max_pixels must be an integer from 65536 through 16777216.",
20905
20910
  visionHint: "Use auto/low for ordinary screenshots and high for OCR or small text. Explicit max_pixels wins.",
20906
- quotaNote: "No public verified remaining-Credits endpoint is available, so this card shows no balance or money.",
20907
20911
  dashboard: "Open Qianwen usage console",
20908
20912
  composerLabel: "Qwen cache",
20909
20913
  noQuota: "No quota data",
@@ -20976,99 +20980,6 @@ window.__ModuleLoader__.load({
20976
20980
  setBusy(null);
20977
20981
  }
20978
20982
  }, [adopt, onModelChange]);
20979
- const saveKey = (0, react.useCallback)(async () => {
20980
- const apiKey = keyValue.trim();
20981
- if (apiKey === "") return;
20982
- setBusy("key");
20983
- setError(null);
20984
- try {
20985
- adopt(await request("/credentials", {
20986
- method: "PUT",
20987
- body: JSON.stringify({ apiKey })
20988
- }));
20989
- setKeyValue("");
20990
- setConnection(null);
20991
- onModelChange?.();
20992
- } catch (cause) {
20993
- setError(messageOf(cause));
20994
- } finally {
20995
- setBusy(null);
20996
- }
20997
- }, [
20998
- adopt,
20999
- keyValue,
21000
- onModelChange
21001
- ]);
21002
- const removeKey = (0, react.useCallback)(async () => {
21003
- setBusy("remove-key");
21004
- setError(null);
21005
- try {
21006
- adopt(await request("/credentials", { method: "DELETE" }));
21007
- setConnection(null);
21008
- onModelChange?.();
21009
- } catch (cause) {
21010
- setError(messageOf(cause));
21011
- } finally {
21012
- setBusy(null);
21013
- }
21014
- }, [adopt, onModelChange]);
21015
- const testConnection = (0, react.useCallback)(async () => {
21016
- setBusy("connection");
21017
- setError(null);
21018
- try {
21019
- setConnection(await post("/connection", {}));
21020
- } catch (cause) {
21021
- setError(messageOf(cause));
21022
- } finally {
21023
- setBusy(null);
21024
- }
21025
- }, []);
21026
- const toggleModel = (0, react.useCallback)((id, enabled) => {
21027
- if (status === null) return;
21028
- const ids = status.models.filter((model) => model.id === id ? enabled : model.enabled).map((model) => model.id);
21029
- update({ enabledModelIds: ids }, "models").catch(() => void 0);
21030
- }, [status, update]);
21031
- const setAllModels = (0, react.useCallback)((enabled) => {
21032
- if (status === null) return;
21033
- update({ enabledModelIds: enabled ? status.models.map((model) => model.id) : [] }, "models").catch(() => void 0);
21034
- }, [status, update]);
21035
- const saveContextWindow = (0, react.useCallback)(async (id) => {
21036
- const raw = contextDrafts[id] ?? "";
21037
- const parsed = parsePositiveCapacity$1(raw);
21038
- if (parsed === null) {
21039
- setError("Invalid capacity: " + raw);
21040
- return;
21041
- }
21042
- setSavingModel(id);
21043
- try {
21044
- await update({ contextWindowOverrides: { [id]: parsed } }, "context:" + id);
21045
- } catch {} finally {
21046
- setSavingModel(null);
21047
- }
21048
- }, [contextDrafts, update]);
21049
- const resetContextWindow = (0, react.useCallback)(async (id) => {
21050
- setSavingModel(id);
21051
- try {
21052
- await update({ contextWindowOverrides: { [id]: null } }, "context:" + id);
21053
- } catch {} finally {
21054
- setSavingModel(null);
21055
- }
21056
- }, [update]);
21057
- const resetAllContextWindows = (0, react.useCallback)(async () => {
21058
- const overrides = Object.fromEntries(Object.keys(status?.contextWindowOverrides ?? {}).map((id) => [id, null]));
21059
- if (Object.keys(overrides).length > 0) await update({ contextWindowOverrides: overrides }, "context");
21060
- }, [status, update]);
21061
- const savePixels = (0, react.useCallback)(async () => {
21062
- const raw = pixelsDraft.trim();
21063
- const value = raw === "" ? null : Number(raw);
21064
- if (value !== null && (!Number.isSafeInteger(value) || value < 65536 || value > 16777216)) {
21065
- setError("max_pixels must be an integer from 65536 through 16777216.");
21066
- return;
21067
- }
21068
- try {
21069
- await update({ maxPixels: value }, "pixels");
21070
- } catch {}
21071
- }, [pixelsDraft, update]);
21072
20983
  return {
21073
20984
  status,
21074
20985
  loading,
@@ -21079,27 +20990,108 @@ window.__ModuleLoader__.load({
21079
20990
  contextDrafts,
21080
20991
  savingModel,
21081
20992
  pixelsDraft,
21082
- cache: status?.cacheStats ?? null,
21083
- cacheHitRatio: qianwenCacheHitRatio(status?.cacheStats ?? null),
21084
20993
  setKeyValue,
21085
20994
  setPixelsDraft,
21086
20995
  setContextDraft: (id, draft) => setContextDrafts((current) => ({
21087
20996
  ...current,
21088
20997
  [id]: draft
21089
20998
  })),
21090
- saveKey,
21091
- removeKey,
21092
- testConnection,
20999
+ saveKey: (0, react.useCallback)(async () => {
21000
+ const apiKey = keyValue.trim();
21001
+ if (apiKey === "") return;
21002
+ setBusy("key");
21003
+ setError(null);
21004
+ try {
21005
+ adopt(await request("/credentials", {
21006
+ method: "PUT",
21007
+ body: JSON.stringify({ apiKey })
21008
+ }));
21009
+ setKeyValue("");
21010
+ setConnection(null);
21011
+ onModelChange?.();
21012
+ } catch (cause) {
21013
+ setError(messageOf(cause));
21014
+ } finally {
21015
+ setBusy(null);
21016
+ }
21017
+ }, [
21018
+ adopt,
21019
+ keyValue,
21020
+ onModelChange
21021
+ ]),
21022
+ removeKey: (0, react.useCallback)(async () => {
21023
+ setBusy("remove-key");
21024
+ setError(null);
21025
+ try {
21026
+ adopt(await request("/credentials", { method: "DELETE" }));
21027
+ setConnection(null);
21028
+ onModelChange?.();
21029
+ } catch (cause) {
21030
+ setError(messageOf(cause));
21031
+ } finally {
21032
+ setBusy(null);
21033
+ }
21034
+ }, [adopt, onModelChange]),
21035
+ testConnection: (0, react.useCallback)(async () => {
21036
+ setBusy("connection");
21037
+ setError(null);
21038
+ try {
21039
+ setConnection(await post("/connection", {}));
21040
+ } catch (cause) {
21041
+ setError(messageOf(cause));
21042
+ } finally {
21043
+ setBusy(null);
21044
+ }
21045
+ }, []),
21093
21046
  update,
21094
- toggleModel,
21095
- setAllModels,
21096
- saveContextWindow,
21097
- resetContextWindow,
21098
- resetAllContextWindows,
21099
- savePixels,
21047
+ toggleModel: (0, react.useCallback)((id, enabled) => {
21048
+ if (status === null) return;
21049
+ const ids = status.models.filter((model) => model.id === id ? enabled : model.enabled).map((model) => model.id);
21050
+ update({ enabledModelIds: ids }, "models").catch(() => void 0);
21051
+ }, [status, update]),
21052
+ setAllModels: (0, react.useCallback)((enabled) => {
21053
+ if (status === null) return;
21054
+ update({ enabledModelIds: enabled ? status.models.map((model) => model.id) : [] }, "models").catch(() => void 0);
21055
+ }, [status, update]),
21056
+ saveContextWindow: (0, react.useCallback)(async (id) => {
21057
+ const raw = contextDrafts[id] ?? "";
21058
+ const parsed = parsePositiveCapacity$1(raw);
21059
+ if (parsed === null) {
21060
+ setError("Invalid capacity: " + raw);
21061
+ return;
21062
+ }
21063
+ setSavingModel(id);
21064
+ try {
21065
+ await update({ contextWindowOverrides: { [id]: parsed } }, "context:" + id);
21066
+ } catch {} finally {
21067
+ setSavingModel(null);
21068
+ }
21069
+ }, [contextDrafts, update]),
21070
+ resetContextWindow: (0, react.useCallback)(async (id) => {
21071
+ setSavingModel(id);
21072
+ try {
21073
+ await update({ contextWindowOverrides: { [id]: null } }, "context:" + id);
21074
+ } catch {} finally {
21075
+ setSavingModel(null);
21076
+ }
21077
+ }, [update]),
21078
+ resetAllContextWindows: (0, react.useCallback)(async () => {
21079
+ const overrides = Object.fromEntries(Object.keys(status?.contextWindowOverrides ?? {}).map((id) => [id, null]));
21080
+ if (Object.keys(overrides).length > 0) await update({ contextWindowOverrides: overrides }, "context");
21081
+ }, [status, update]),
21082
+ savePixels: (0, react.useCallback)(async () => {
21083
+ const raw = pixelsDraft.trim();
21084
+ const value = raw === "" ? null : Number(raw);
21085
+ if (value !== null && (!Number.isSafeInteger(value) || value < 65536 || value > 16777216)) {
21086
+ setError("max_pixels must be an integer from 65536 through 16777216.");
21087
+ return;
21088
+ }
21089
+ try {
21090
+ await update({ maxPixels: value }, "pixels");
21091
+ } catch {}
21092
+ }, [pixelsDraft, update]),
21100
21093
  setDefaultEffort: (defaultReasoningEffort) => update({ defaultReasoningEffort }, "effort"),
21101
- setImageDetail: (imageDetail) => update({ imageDetail }, "vision"),
21102
- clearCache: () => post("/cache/reset", {}).then(adopt)
21094
+ setImageDetail: (imageDetail) => update({ imageDetail }, "vision")
21103
21095
  };
21104
21096
  }
21105
21097
  //#endregion
@@ -21113,26 +21105,12 @@ window.__ModuleLoader__.load({
21113
21105
  xhigh: "effortXhigh",
21114
21106
  max: "effortMax"
21115
21107
  };
21116
- const tokenText = (value) => {
21117
- try {
21118
- return new Intl.NumberFormat().format(value);
21119
- } catch {
21120
- return String(value);
21121
- }
21122
- };
21123
- const percentText = (value) => Math.round(value * 1e3) / 10 + "%";
21124
21108
  function more(title, lines) {
21125
21109
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
21126
21110
  className: "dshqw-details",
21127
21111
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", { children: title }), lines.map((line) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: line }, line))]
21128
21112
  });
21129
21113
  }
21130
- function stat(label, value) {
21131
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
21132
- className: "dshqw-stat",
21133
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tokenText(value) })]
21134
- });
21135
- }
21136
21114
  function QianwenTokenPlanSection(props = {}) {
21137
21115
  const t = useLineDict(NS_QIANWEN, zh$3);
21138
21116
  const view = useQianwenSection(props);
@@ -21143,7 +21121,6 @@ window.__ModuleLoader__.load({
21143
21121
  });
21144
21122
  const models = status?.models ?? [];
21145
21123
  const enabledModels = models.filter((model) => model.enabled);
21146
- const cache = view.cache;
21147
21124
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
21148
21125
  className: "dsha-page dshqw-page",
21149
21126
  "data-provider": "qianwen-token-plan",
@@ -21230,14 +21207,9 @@ window.__ModuleLoader__.load({
21230
21207
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
21231
21208
  className: "dsha-group dshqw-cache",
21232
21209
  children: [
21233
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
21210
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
21234
21211
  className: "dsha-grouphead",
21235
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t.cacheSection }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
21236
- className: "dsha-btn",
21237
- disabled: busy !== null || cache === null,
21238
- onClick: () => void view.clearCache(),
21239
- children: t.resetCache
21240
- })]
21212
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t.cacheSection })
21241
21213
  }),
21242
21214
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
21243
21215
  className: "dsha-muted",
@@ -21270,30 +21242,10 @@ window.__ModuleLoader__.load({
21270
21242
  }, ttl))
21271
21243
  })]
21272
21244
  }),
21273
- cache === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
21274
- className: "dsha-empty",
21275
- children: t.cacheEmpty
21276
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
21277
- className: "dsha-meter-label",
21278
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t.cacheHitRatio }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: view.cacheHitRatio === null ? t.cacheUnavailable : percentText(view.cacheHitRatio) })]
21279
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
21280
- className: "dshqw-stats",
21281
- children: [
21282
- stat(t.cacheRequests, cache.requests),
21283
- stat(t.cacheRead, cache.cacheReadTokens),
21284
- stat(t.cacheMissed, cache.missedInputTokens),
21285
- stat(t.cacheWrite5m, cache.cacheWrite5mTokens),
21286
- stat(t.cacheWrite1h, cache.cacheWrite1hTokens),
21287
- stat(t.reasoningTokens, cache.reasoningTokens),
21288
- stat(t.encryptedReplays, cache.encryptedReplays),
21289
- stat(t.missingEncrypted, cache.missingEncryptedContent)
21290
- ]
21291
- })] }),
21292
21245
  status?.cacheHint && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
21293
21246
  className: "dsha-muted",
21294
21247
  children: t.cacheHint.replace("{minutes}", String(Math.floor(status.cacheHint.idleMs / 6e4)))
21295
21248
  }),
21296
- more(t.moreNotes, [t.quotaNote]),
21297
21249
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
21298
21250
  className: "dsha-actions",
21299
21251
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
@@ -24284,24 +24236,13 @@ window.__ModuleLoader__.load({
24284
24236
  routeOwned: "Этот плагин обслуживает маршрут модели.",
24285
24237
  routeConflict: "Маршрут занят другим провайдером: {detail}",
24286
24238
  cacheSection: "Явный кеш",
24287
- cacheDesc: "Автоматические и стабильные точки кеширования Qwen4 повторно используют ввод. Это локальные токены, а не счёт апстрима или остаток Credits.",
24239
+ cacheDesc: "Автоматические и стабильные точки кеширования Qwen4 повторно используют ввод; статистика использования — во встроенной статистике DSH и консоли Qianwen.",
24288
24240
  cacheEnabled: "Включить явный кеш",
24289
24241
  cacheTtl: "TTL кеша",
24290
24242
  ttl5m: "5 минут (5m)",
24291
24243
  ttl1h: "1 час (1h)",
24292
24244
  cacheHitRatio: "Доля попаданий",
24293
- cacheRead: "Прочитано из кеша",
24294
- cacheMissed: "Ввод вне кеша",
24295
- cacheWrite5m: "Запись кеша 5m",
24296
- cacheWrite1h: "Запись кеша 1h",
24297
- cacheRequests: "Учтено запросов",
24298
- reasoningTokens: "Токены reasoning",
24299
- encryptedReplays: "Зашифрованных повторов",
24300
- missingEncrypted: "Отсутствует шифротекст",
24301
- cacheEmpty: "Пока нет данных об использовании кеша.",
24302
- cacheUnavailable: "—",
24303
24245
  cacheHint: "Кеш мог остыть: с последнего запроса прошло около {minutes} мин.",
24304
- resetCache: "Очистить локальную статистику",
24305
24246
  thinkingSection: "Размышления",
24306
24247
  defaultEffort: "Уровень reasoning по умолчанию",
24307
24248
  effortDefault: "По умолчанию апстрима (high)",
@@ -24340,7 +24281,6 @@ window.__ModuleLoader__.load({
24340
24281
  maxPixelsReset: "Сбросить",
24341
24282
  invalidPixels: "max_pixels должно быть целым числом от 65536 до 16777216.",
24342
24283
  visionHint: "Для обычных снимков используйте auto/low, для OCR и мелкого текста — high. Явный max_pixels имеет приоритет.",
24343
- quotaNote: "Публичного проверенного API остатка Credits нет, поэтому баланс и денежные суммы не показываются.",
24344
24284
  dashboard: "Открыть консоль использования Qianwen",
24345
24285
  composerLabel: "Кеш Qwen",
24346
24286
  noQuota: "Нет данных квоты",
@@ -57754,7 +57694,8 @@ window.__ModuleLoader__.load({
57754
57694
  const STYLE_ID = "dsh-qianwen-token-plan-settings-style";
57755
57695
  function installQianwenStyles() {
57756
57696
  installPluginStyle("qianwen-token-plan", `
57757
- .dshqw-key-row{align-items:stretch;display:grid;gap:8px;grid-template-columns:minmax(0,1fr) auto;width:100%}
57697
+ /* 输入行与上方 .dsha-row / .dsha-pref-row 的底部分界线保持间距,避免框线重合 */
57698
+ .dshqw-key-row{align-items:stretch;display:grid;gap:8px;grid-template-columns:minmax(0,1fr) auto;margin-top:10px;width:100%}
57758
57699
  .dshqw-vision-row{grid-template-columns:minmax(0,1fr) auto auto}
57759
57700
  .dshqw-key-row input{box-sizing:border-box;display:block;height:32px;max-width:none;min-width:0;width:100%}
57760
57701
  .dshqw-key-row .dsha-btn{align-items:center;display:inline-flex;height:32px;justify-content:center;min-width:80px;white-space:nowrap}
@@ -57762,10 +57703,6 @@ window.__ModuleLoader__.load({
57762
57703
  .dshqw-key-row,.dshqw-vision-row{grid-template-columns:minmax(0,1fr)}
57763
57704
  .dshqw-key-row .dsha-btn{width:100%}
57764
57705
  }
57765
- .dshqw-stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:9px 18px;margin-top:10px}
57766
- .dshqw-stat{display:flex;flex-direction:column;gap:3px;min-width:0}
57767
- .dshqw-stat>span:first-child{color:var(--dsw-alias-label-tertiary);font-size:11px}
57768
- .dshqw-stat>span:last-child{color:var(--dsw-alias-label-primary);font-size:12px;white-space:nowrap}
57769
57706
  .dshqw-details{border-top:0.5px solid var(--dsw-alias-border-l2);padding:10px 0 2px}
57770
57707
  .dshqw-details>summary{color:var(--dsw-alias-label-secondary);cursor:pointer;font-size:12px;list-style:none}
57771
57708
  .dshqw-details>p{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:1.55;margin:9px 0 0}