@pinkbanana/dsh-balance 0.14.0 → 0.15.2

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 CHANGED
@@ -23,7 +23,7 @@ DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API 余额,以及 De
23
23
  - 缓存查询结果并支持手动刷新
24
24
  - 模型列表标注内置参考价(输入 / 输出每百万 tokens),未收录价格的模型明确标记
25
25
  - 统计页「会话」分类中点击任一会话,下钻查看该会话的完整请求明细,可随时返回总览
26
- - 按本会话近期已计费请求的 token 构成估算下轮费用:当前时段、下个峰谷切换后、新开会话(全部未命中缓存),以及本 Harness 已配置且可计价的其他官方模型;同时给出继续本会话相对新开因缓存节省的费用。这是估算而非官方账单,不会自动换模型,也不会把会话内容送出本机
26
+ - 按本会话近期已计费请求的 token 构成估算下轮费用:当前时段、下个峰谷切换后、新开会话(全部未命中缓存)、现在 /compact(摘要请求 + 压缩后首轮;摘要长度按约 4,000 tokens 假设),以及本 Harness 已配置且可计价的其他官方模型;同时给出继续本会话相对新开因缓存节省的费用。这是估算而非官方账单,不会自动换模型,也不会把会话内容送出本机
27
27
  - 一键导出当前视图为 JSON 或 CSV(总览导出所选分类或完整摘要,会话导出请求级记录),数据不离开本机
28
28
  - 统计页可直接填写 USD→CNY 汇率(存于浏览器 localStorage,无需重启);插件配置 `usdToCny` 优先生效
29
29
  - 配置 `pricingOverrides` 可用自定义费率替换内置价格(按 provider + model 匹配,支持生效时间),模型列表与计费估算同步生效
@@ -31,14 +31,14 @@ DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API 余额,以及 De
31
31
  - 统计页支持自定义日期范围与 12 个常用时区(默认跟随浏览器),月度按当前节奏预测,限定范围时与上一同期对比
32
32
  - 余额与模型查询对 429 / 5xx 自动重试(尊重 `Retry-After`,指数退避,最多 3 次尝试)
33
33
  - 依据 DeepSeek 峰谷定价,在高峰时段(北京时间周一至周五 9:00–12:00、14:00–18:00,中国法定节假日除外)将聊天框下方的余额指示灯变为橙色
34
- - 原生支持简体中文和英文,并跟随 Harness 系统语言切换
34
+ - 原生支持简体中文、繁體中文(zh-TW,缺失键回退到简体中文)和英文,并跟随 Harness 系统语言切换
35
35
  - 支持 Harness 已保存的 `DEEPSEEK_API_KEY`
36
36
 
37
37
  ![会话消费页示例](./docs/dsh-session-usage-v0100.jpg)
38
38
 
39
39
  ## 兼容性
40
40
 
41
- 插件 `0.14.0` 支持 DSH **`>=0.2.1-rc.3 <1.0.0-0`**,需要 Node.js **24.9+**。DSH 的安装和启动检查将预发布版本纳入匹配,范围内无需添加版本豁免。DSH peer 依赖也显式涵盖 `0.2.2-rc.1` 起的 `0.2.2` 预发布版,以便包管理器使用标准 semver 规则解析这些版本。Cordis peer 范围为 `^4.0.5`。开发依赖固定在 DSH `0.2.2-rc.1` 和 Cordis `~4.1.0`,以保持构建可复现。
41
+ 插件 `0.14.2` 支持 DSH **`>=0.2.1-rc.3 <1.0.0-0`**,需要 Node.js **24.9+**。DSH 的安装和启动检查将预发布版本纳入匹配,范围内无需添加版本豁免。DSH peer 依赖也显式涵盖 `0.2.2-rc.1` 起的 `0.2.2` 预发布版,以及 `0.2.3` 预发布版(`0.2.3-alpha.1` 起),以便包管理器使用标准 semver 规则解析这些版本。Cordis peer 范围为 `^4.0.5`。开发依赖固定在 DSH `0.2.2-rc.1` 和 Cordis `~4.1.0`,以保持构建可复现。
42
42
 
43
43
  已在 DSH `0.2.1-rc.3` 和 `0.2.2-rc.5` 的 Web profile 验证安装和启动。仍使用 DSH `0.2.1-rc.2` 的用户可使用插件 `0.11.0`,DSH `0.2.0-rc.2` 的用户可使用插件 `0.10.2`。
44
44
 
@@ -155,6 +155,8 @@ providers:
155
155
 
156
156
  ## 下轮费用估算
157
157
 
158
+ 除继续、等待下个峰谷切换、新开会话外,卡片新增「现在 /compact」估算:一次读取整段历史的摘要请求(假设输出约 4,000 tokens,至多历史的四分之一)加压缩后的首轮(仅会话中最小的缓存命中前缀仍命中)。仅为估算,不会自动压缩。
159
+
158
160
  会话「消费」页会展示下轮费用估算卡片;聊天框下方的余额摘要可按需展开同一估算,默认收起以免占用空间。估算使用本会话最近若干次已计费请求各 token 桶(未缓存输入 / 缓存读取 / 缓存写入 / 输出)的中位数,通过现有计价引擎计算,不另建第二套价格路径。下轮实际用量可能不同,例如上下文压缩、大段粘贴或视觉输入。
159
161
 
160
162
  返回结果包括当前时段、下一次峰谷切换时间、样本数量、token 构成,以及当前模型此刻、切换后、新开会话的估算,还有其他已配置且可计价官方模型的对照。无法定价的模型会被省略,不会显示为 $0。美元与原生人民币分别展示;只有配置了 `usdToCny` 才会给出人民币合计。接口为 `GET /dsh-balance/api/advice?session=…`,仅本机可访问,响应不含 prompt 或会话正文。
package/README_EN.md CHANGED
@@ -31,12 +31,12 @@ The composer readout follows the current session’s provider and model. The Set
31
31
  - Custom date ranges and twelve common time zones (browser default); month-to-date projection at the current pace, plus a comparison with the immediately preceding period for bounded ranges
32
32
  - Retry balance and model queries on 429 / 5xx (honoring `Retry-After`, exponential backoff, at most three attempts)
33
33
  - Follows DeepSeek peak/off-peak pricing: the balance indicator below the composer turns orange during peak hours (09:00–12:00 and 14:00–18:00 Beijing time, Monday–Friday, excluding Chinese public holidays)
34
- - Native Simplified Chinese and English that follows the Harness system language
34
+ - Native Simplified Chinese, Traditional Chinese (zh-TW, falling back to Simplified Chinese per key) and English that follows the Harness system language
35
35
  - Use the `DEEPSEEK_API_KEY` saved by Harness
36
36
 
37
37
  ## Compatibility
38
38
 
39
- Plugin `0.14.0` supports DSH **`>=0.2.1-rc.3 <1.0.0-0`** and requires Node.js **24.9+**. DSH includes prereleases in its install and startup checks. Versions in this range require no exemption. The DSH peer ranges explicitly include `0.2.2` prereleases starting at `0.2.2-rc.1` so package managers can resolve them under standard semver rules. The Cordis peer range is `^4.0.5`. Development dependencies are pinned to DSH `0.2.2-rc.1` and Cordis `~4.1.0` for reproducible builds.
39
+ Plugin `0.14.2` supports DSH **`>=0.2.1-rc.3 <1.0.0-0`** and requires Node.js **24.9+**. DSH includes prereleases in its install and startup checks. Versions in this range require no exemption. The DSH peer ranges explicitly include `0.2.2` prereleases starting at `0.2.2-rc.1` and `0.2.3` prereleases starting at `0.2.3-alpha.1`, so package managers can resolve them under standard semver rules. The Cordis peer range is `^4.0.5`. Development dependencies are pinned to DSH `0.2.2-rc.1` and Cordis `~4.1.0` for reproducible builds.
40
40
 
41
41
  Installation and startup were verified with the web profile on DSH `0.2.1-rc.3` and `0.2.2-rc.5`. For DSH `0.2.1-rc.2`, use plugin `0.11.0`. For DSH `0.2.0-rc.2`, use plugin `0.10.2`.
42
42
 
@@ -151,6 +151,8 @@ Built-in estimates use [official DeepSeek USD rates](https://api-docs.deepseek.c
151
151
 
152
152
  ## Next-turn estimates
153
153
 
154
+ Besides continue / wait for the next peak change / fresh session, the card now prices **`/compact` now**: one summarizer request over the whole history (about 4,000 output tokens assumed, at most a quarter of the history) plus the first turn afterwards, where only the smallest cache-hit prefix seen in the session still hits. Estimate only; nothing is compacted automatically.
155
+
154
156
  The session Usage tab shows a next-turn estimate card. The composer balance dock can expand the same estimate on demand; it stays collapsed by default so it does not clutter the row. The token shape is the per-bucket median of the session’s most recent priced requests (uncached input, cache read, cache write, output), priced through the existing billing engines rather than a second pricing path. The next turn may not match, for example after compaction, a large paste, or vision input.
155
157
 
156
158
  The response includes the current period, the next peak-change time, the sample size, the token shape, estimates for the current model now, after the change, and as a fresh session, plus other configured official models that can be priced. Unpriced models are omitted rather than shown as $0. Native USD and CNY are shown separately; a combined CNY total appears only when `usdToCny` is set. The Host route is `GET /dsh-balance/api/advice?session=…`, loopback-only, and the payload never includes prompt or session text.
package/lib/client.js CHANGED
@@ -712,13 +712,27 @@ window.__ModuleLoader__.load({
712
712
  if (rate === null || rate === void 0) return null;
713
713
  return (estimate.costCny ?? 0) + (estimate.costUsd ?? 0) * rate;
714
714
  }
715
- function formatCost(estimate, locale, rate, t) {
715
+ function formatCostParts(estimate, locale, rate, t) {
716
716
  const parts = [];
717
717
  if (estimate.costUsd !== null) parts.push(displayAmount(String(estimate.costUsd), "USD", locale));
718
718
  if (estimate.costCny !== void 0) parts.push(displayAmount(String(estimate.costCny), "CNY", locale));
719
719
  const converted = combined(estimate, rate);
720
720
  if (converted !== null && estimate.costUsd !== null) parts.push(`${displayAmount(String(converted), "CNY", locale)} (${t("billing.fixedRate")})`);
721
- return parts.length === 0 ? t("advice.noEstimate") : parts.join(" · ");
721
+ return parts.length === 0 ? [t("advice.noEstimate")] : parts;
722
+ }
723
+ function formatCost(estimate, locale, rate, t) {
724
+ return formatCostParts(estimate, locale, rate, t).join(" · ");
725
+ }
726
+ /** Each amount stays on one line; long rows wrap between amounts, never inside "(fixed rate)". */
727
+ function CostText({ estimate, locale, usdToCny, t }) {
728
+ const parts = formatCostParts(estimate, locale, usdToCny, t);
729
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
730
+ className: "dsh-advice-cost",
731
+ children: parts.map((part, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [index > 0 ? " · " : "", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
732
+ className: "dsh-advice-amount",
733
+ children: part
734
+ })] }, index))
735
+ });
722
736
  }
723
737
  /** Session-shaped next-turn estimates. Prompt text is never requested or rendered. */
724
738
  function AdviceCard({ sessionId, provider, model, loadAdvice, t, usdToCny = null, compact = false }) {
@@ -778,6 +792,7 @@ window.__ModuleLoader__.load({
778
792
  const now = advice.now === void 0 ? t("advice.noEstimate") : formatCost(advice.now, locale, usdToCny, t);
779
793
  const after = advice.afterChange === void 0 ? void 0 : formatCost(advice.afterChange, locale, usdToCny, t);
780
794
  const fresh = advice.fresh === void 0 ? void 0 : formatCost(advice.fresh, locale, usdToCny, t);
795
+ const compactCost = advice.compact === void 0 ? void 0 : formatCost(advice.compact, locale, usdToCny, t);
781
796
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
782
797
  className: "dsh-advice-dock",
783
798
  children: [
@@ -798,6 +813,12 @@ window.__ModuleLoader__.load({
798
813
  ": ",
799
814
  fresh
800
815
  ] }),
816
+ compactCost === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
817
+ " · ",
818
+ t("advice.compact"),
819
+ ": ",
820
+ compactCost
821
+ ] }),
801
822
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
802
823
  className: "dsh-advice-note",
803
824
  children: t("advice.estimateOnly")
@@ -810,7 +831,12 @@ window.__ModuleLoader__.load({
810
831
  className: "dsh-advice-row",
811
832
  children: [
812
833
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label }),
813
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: formatCost(estimate, locale, usdToCny, t) }),
834
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CostText, {
835
+ estimate,
836
+ locale,
837
+ usdToCny,
838
+ t
839
+ }),
814
840
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("small", { children: [
815
841
  estimate.provider,
816
842
  " / ",
@@ -882,13 +908,25 @@ window.__ModuleLoader__.load({
882
908
  usdToCny,
883
909
  locale
884
910
  }),
911
+ advice.compact === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EstimateRow, {
912
+ label: t("advice.compact"),
913
+ estimate: advice.compact,
914
+ t,
915
+ usdToCny,
916
+ locale
917
+ }),
885
918
  advice.cacheSavings === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
886
919
  className: "dsh-advice-row",
887
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("advice.cacheSavings") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: formatCost({
888
- costUsd: advice.cacheSavings.costUsd,
889
- combinedCny: advice.cacheSavings.combinedCny,
890
- ...advice.cacheSavings.costCny === void 0 ? {} : { costCny: advice.cacheSavings.costCny }
891
- }, locale, usdToCny, t) })]
920
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("advice.cacheSavings") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CostText, {
921
+ estimate: {
922
+ costUsd: advice.cacheSavings.costUsd,
923
+ combinedCny: advice.cacheSavings.combinedCny,
924
+ ...advice.cacheSavings.costCny === void 0 ? {} : { costCny: advice.cacheSavings.costCny }
925
+ },
926
+ locale,
927
+ usdToCny,
928
+ t
929
+ })]
892
930
  }),
893
931
  advice.alternatives.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
894
932
  className: "dsh-advice-alternatives",
@@ -1943,7 +1981,7 @@ window.__ModuleLoader__.load({
1943
1981
  }
1944
1982
  //#endregion
1945
1983
  //#region src/client/UsagePage.tsx
1946
- function UsagePage({ loadUsage, t }) {
1984
+ function UsagePage({ loadUsage, loadAdvice, t }) {
1947
1985
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("main", {
1948
1986
  className: "dsh-usage-page",
1949
1987
  "aria-label": t("nav.usage"),
@@ -1951,6 +1989,7 @@ window.__ModuleLoader__.load({
1951
1989
  className: "dsh-usage-content",
1952
1990
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BillingOverview, {
1953
1991
  loadUsage,
1992
+ ...loadAdvice === void 0 ? {} : { loadAdvice },
1954
1993
  t
1955
1994
  })
1956
1995
  })
@@ -2034,7 +2073,36 @@ window.__ModuleLoader__.load({
2034
2073
  "2026-10-04",
2035
2074
  "2026-10-05",
2036
2075
  "2026-10-06",
2037
- "2026-10-07"
2076
+ "2026-10-07",
2077
+ "2027-01-01",
2078
+ "2027-01-02",
2079
+ "2027-01-03",
2080
+ "2027-02-05",
2081
+ "2027-02-06",
2082
+ "2027-02-07",
2083
+ "2027-02-08",
2084
+ "2027-02-09",
2085
+ "2027-02-10",
2086
+ "2027-02-11",
2087
+ "2027-02-12",
2088
+ "2027-02-13",
2089
+ "2027-04-03",
2090
+ "2027-04-04",
2091
+ "2027-04-05",
2092
+ "2027-05-01",
2093
+ "2027-05-02",
2094
+ "2027-05-03",
2095
+ "2027-05-04",
2096
+ "2027-05-05",
2097
+ "2027-06-09",
2098
+ "2027-09-15",
2099
+ "2027-10-01",
2100
+ "2027-10-02",
2101
+ "2027-10-03",
2102
+ "2027-10-04",
2103
+ "2027-10-05",
2104
+ "2027-10-06",
2105
+ "2027-10-07"
2038
2106
  ]);
2039
2107
  function pad(value) {
2040
2108
  return String(value).padStart(2, "0");
@@ -3102,6 +3170,7 @@ window.__ModuleLoader__.load({
3102
3170
  "advice.now": "当前时段",
3103
3171
  "advice.afterChange": "下个峰谷切换后",
3104
3172
  "advice.fresh": "新开会话(全部未命中缓存)",
3173
+ "advice.compact": "现在 /compact(摘要请求 + 压缩后首轮)",
3105
3174
  "advice.alternative": "其他已配置模型",
3106
3175
  "advice.cacheSavings": "继续本会话相对新开可节省",
3107
3176
  "advice.sample": "取最近 {count} / {limit} 次已计费请求的中位数",
@@ -3118,6 +3187,8 @@ window.__ModuleLoader__.load({
3118
3187
  "advice.caveat.tokener-snapshot": "Tokener 费用按 2026-11-03 目录快照估算,不套用原厂价格或 DeepSeek 峰谷倍率。",
3119
3188
  "advice.caveat.no-priced-sample": "本会话还没有已计费请求,无法根据历史用量估算下轮费用。",
3120
3189
  "advice.caveat.unpriced-omitted": "无法定价的模型已省略,不会显示为 $0。",
3190
+ "advice.caveat.holiday-calendar-stale": "内置法定节假日仅到 2027 年;此后的节假日会被按普通工作日(峰时)估算,请升级插件。",
3191
+ "advice.caveat.compact-assumptions": "/compact 估算假设:摘要请求读取整段历史并输出约 4,000 tokens(至多历史的四分之一),压缩后仅会话中最小的缓存命中前缀仍命中,摘要与新输入均未命中;实际摘要长度和压缩模型可能不同。",
3121
3192
  "advice.period.peak": "高峰时段",
3122
3193
  "advice.period.off-peak": "低谷时段",
3123
3194
  "advice.period.standard": "标准价",
@@ -3303,6 +3374,7 @@ window.__ModuleLoader__.load({
3303
3374
  "advice.now": "Current period",
3304
3375
  "advice.afterChange": "After the next peak change",
3305
3376
  "advice.fresh": "Fresh session (all cache-miss)",
3377
+ "advice.compact": "Compact now (summary request + first turn after)",
3306
3378
  "advice.alternative": "Other configured model",
3307
3379
  "advice.cacheSavings": "Saved by continuing this session vs starting over",
3308
3380
  "advice.sample": "Median of the last {count} / {limit} priced requests",
@@ -3319,6 +3391,8 @@ window.__ModuleLoader__.load({
3319
3391
  "advice.caveat.tokener-snapshot": "Tokener costs use the 2026-11-03 catalog snapshot, without vendor rates or the DeepSeek peak multiplier.",
3320
3392
  "advice.caveat.no-priced-sample": "This session has no priced requests yet, so the next turn cannot be estimated from usage history.",
3321
3393
  "advice.caveat.unpriced-omitted": "Models that cannot be priced are omitted rather than shown as $0.",
3394
+ "advice.caveat.holiday-calendar-stale": "Built-in Chinese public holidays end in 2027; later holidays are priced as ordinary weekdays (peak). Update the plugin.",
3395
+ "advice.caveat.compact-assumptions": "/compact assumes the summary request reads the whole history and writes about 4,000 tokens (at most a quarter of the history); afterwards only the smallest cache-hit prefix seen in this session still hits, while the summary and new input miss. The real summary length and model may differ.",
3322
3396
  "advice.period.peak": "Peak hours",
3323
3397
  "advice.period.off-peak": "Off-peak hours",
3324
3398
  "advice.period.standard": "Standard rate",
@@ -3713,6 +3787,212 @@ window.__ModuleLoader__.load({
3713
3787
  });
3714
3788
  }
3715
3789
  //#endregion
3790
+ //#region src/client/locales-zh-tw.ts
3791
+ /** Traditional Chinese (Taiwan) dictionary; the language falls back to `zh`, then `en`, per key. */
3792
+ const zhTW = {
3793
+ "locale.tag": "zh-TW",
3794
+ "panel.ledger": "帳戶總覽",
3795
+ "panel.private": "金鑰僅存本機",
3796
+ "panel.title": "帳戶餘額",
3797
+ "panel.copy": "查看各供應商的帳戶餘額與 API 消費。",
3798
+ "panel.providers": "選擇供應商",
3799
+ "panel.models": "可用模型",
3800
+ "panel.activity": "消費記錄",
3801
+ "panel.allProviders": "全部供應商",
3802
+ "panel.account": "帳戶餘額",
3803
+ "balance.availableAmount": "目前可用餘額",
3804
+ "balance.totalCash": "總儲值金額",
3805
+ "balance.totalVoucher": "總贈送金額",
3806
+ "balance.prepaid": "預付費帳戶",
3807
+ "balance.postpaid": "後付費帳戶",
3808
+ "balance.totalsNote": "總儲值與總贈送金額為帳戶累計金額,不代表目前剩餘餘額;帳戶類型不表示服務可用狀態。",
3809
+ "balance.setupDeepSeek": "在「設定 → 模型」儲存 DeepSeek API 金鑰,或設定 {ref} 環境變數。",
3810
+ "balance.setup": "在「設定 → 模型」新增自訂供應商,Provider ID 填寫 {provider}(大小寫不限),並儲存 API 金鑰。預設憑證為 {ref};自訂憑證請檢查外掛設定。",
3811
+ "error.UNSUPPORTED_PROVIDER": "暫不支援此供應商的餘額查詢",
3812
+ "nav.balance": "模型餘額",
3813
+ "nav.usage": "用量統計",
3814
+ "billing.byProvider": "依供應商",
3815
+ "punchcard.title": "活動打卡圖",
3816
+ "punchcard.copy": "星期 × 小時 · {timeZone} · 圓點越大,請求越多",
3817
+ "punchcard.less": "少",
3818
+ "punchcard.more": "多",
3819
+ "punchcard.total": "目前範圍共 {count} 次請求",
3820
+ "punchcard.detail": "{day} {hour}:00–{hour}:59 · {count} 次請求 · {tokens} tokens",
3821
+ "punchcard.hint": "將滑鼠移到圓點上查看詳情",
3822
+ "punchcard.keyboard": "請求活動打卡圖,使用方向鍵瀏覽星期與小時",
3823
+ "action.loading": "查詢中…",
3824
+ "balance.title": "{provider} 帳戶",
3825
+ "balance.copy": "餘額由本機 Host 使用已儲存的 API 金鑰查詢,金鑰不會傳送到瀏覽器。",
3826
+ "balance.refresh": "重新整理餘額",
3827
+ "balance.loading": "正在查詢帳戶餘額…",
3828
+ "balance.available": "目前帳戶有可用餘額",
3829
+ "balance.unavailable": "目前帳戶沒有可用餘額",
3830
+ "balance.empty": "供應商未傳回任何幣種餘額。",
3831
+ "balance.history": "近期餘額走勢",
3832
+ "balance.lowBalance": "餘額低於警示門檻",
3833
+ "balance.lowBalanceDetail": "{currency} 餘額 {balance} 已低於 {amount}",
3834
+ "balance.toppedUp": "儲值餘額",
3835
+ "balance.granted": "贈送餘額",
3836
+ "dock.label": "{provider} 餘額",
3837
+ "dock.noSelection": "尚未獲取目前模型",
3838
+ "dock.usageLabel": "{provider} 用量",
3839
+ "dock.usageOnly": "請查看用量統計",
3840
+ "tokener.account": "Tokener 用量統計來自本機儲存的工作階段。餘額與帳戶帳單請在 Tokener 控制台查看。",
3841
+ "tokener.console": "開啟 Tokener 控制台",
3842
+ "error.BALANCE_NOT_SUPPORTED": "此供應商尚未公開餘額查詢介面",
3843
+ "billing.reason.unknown-cache-write-price": "快取寫入價格未公開",
3844
+ "dock.loading": "查詢中…",
3845
+ "dock.unavailable": "暫時無法獲取",
3846
+ "dock.empty": "暫無餘額資訊",
3847
+ "dock.lowBalance": "餘額不足,請儘快儲值",
3848
+ "models.title": "{provider} 可用模型",
3849
+ "models.copy": "查看 {provider} 傳回的可用模型。",
3850
+ "models.refresh": "重新整理模型",
3851
+ "models.loading": "正在查詢模型清單…",
3852
+ "models.count": "目前可用 {count} 個模型",
3853
+ "models.empty": "供應商未傳回任何可用模型。",
3854
+ "models.owner": "由 {owner} 提供",
3855
+ "models.created": "建立於 {date}",
3856
+ "models.price": "輸入 {input} · 輸出 {output} / 百萬 tokens",
3857
+ "models.priceUnknown": "未收錄價格",
3858
+ "billing.tab": "消費",
3859
+ "billing.title": "API 消費統計",
3860
+ "billing.copy": "依供應商、模型、工作階段和日期統計實際用量;日期依 {timeZone} 分組。",
3861
+ "billing.provider": "統計供應商",
3862
+ "billing.range": "統計範圍",
3863
+ "billing.todayRange": "今日",
3864
+ "billing.sevenDays": "最近 7 天",
3865
+ "billing.thirtyDays": "最近 30 天",
3866
+ "billing.allTime": "全部時間",
3867
+ "billing.customRange": "自訂",
3868
+ "billing.exportJson": "匯出 JSON",
3869
+ "billing.exportCsv": "匯出 CSV",
3870
+ "billing.sessionDrill": "查看該工作階段的請求明細",
3871
+ "billing.sessionDrillTitle": "工作階段消費明細",
3872
+ "billing.sessionDrillCopy": "該工作階段的全部請求記錄,不受上方範圍與供應商篩選影響。",
3873
+ "billing.backToOverview": "返回總覽",
3874
+ "billing.fromDate": "開始日期",
3875
+ "billing.toDate": "結束日期",
3876
+ "billing.invalidRange": "開始日期不能晚於結束日期,且日期必須完整",
3877
+ "billing.timeZone": "統計時區",
3878
+ "billing.timeZoneBrowser": "依瀏覽器設定",
3879
+ "rate.usdToCny": "USD→CNY 匯率",
3880
+ "rate.hint": "僅影響本瀏覽器顯示;外掛設定 usdToCny 優先生效",
3881
+ "rate.configured": "已由外掛設定 usdToCny 固定",
3882
+ "rate.invalid": "匯率需為大於 0 的數字",
3883
+ "billing.refresh": "重新整理消費",
3884
+ "billing.loading": "正在讀取消費記錄…",
3885
+ "billing.empty": "暫無消費記錄。",
3886
+ "billing.totalCost": "總消費",
3887
+ "billing.todayCost": "今日消費",
3888
+ "billing.today": "日期 {date}",
3889
+ "billing.pricedRequests": "已計費請求 {count} 次",
3890
+ "billing.freeRequests": "免費請求 {count} 次",
3891
+ "billing.free": "免費",
3892
+ "billing.tokens": "Token 總量",
3893
+ "billing.requestCount": "{count} 次請求",
3894
+ "billing.share": "佔已知消費 {percent}",
3895
+ "billing.unpriced": "未計費請求",
3896
+ "billing.unpricedHint": "缺少 usage 或價格未知,不進行估算",
3897
+ "billing.fixedRate": "固定匯率換算",
3898
+ "billing.tokensBreakdown": "未快取輸入 {input} · 輸出 {output} · 快取讀取 {cacheHit} · 快取寫入 {cacheWrite}",
3899
+ "billing.byModel": "依模型",
3900
+ "billing.categories": "分類明細",
3901
+ "billing.sessionDetails": "工作階段明細",
3902
+ "billing.modelsLabel": "模型",
3903
+ "billing.providersLabel": "供應商",
3904
+ "billing.sessionsLabel": "工作階段",
3905
+ "billing.daysLabel": "日期",
3906
+ "billing.inputShort": "輸入",
3907
+ "billing.outputShort": "輸出",
3908
+ "billing.cacheReadShort": "快取讀取",
3909
+ "billing.cacheWriteShort": "快取寫入",
3910
+ "billing.filterModel": "篩選模型",
3911
+ "billing.allModels": "全部模型",
3912
+ "billing.pagination": "明細分頁",
3913
+ "billing.pageSize": "每頁條數",
3914
+ "billing.perPage": "每頁 {count} 條",
3915
+ "billing.pageRange": "{from}–{to} / 共 {count} 條",
3916
+ "billing.previousPage": "上一頁",
3917
+ "billing.nextPage": "下一頁",
3918
+ "billing.bySession": "依工作階段",
3919
+ "billing.byDay": "依日期",
3920
+ "billing.sessionTitle": "目前工作階段消費",
3921
+ "billing.sessionCopy": "僅展示目前工作階段的 token 與計費結果,不展示 prompt 內容。",
3922
+ "billing.requestDetails": "請求明細",
3923
+ "billing.unknownModel": "未知模型",
3924
+ "billing.inputOutput": "輸入 {input} · 輸出 {output}",
3925
+ "billing.notPriced": "未計費",
3926
+ "billing.partial": "僅包含已知價格的請求",
3927
+ "billing.nativeCny": "人民幣計價",
3928
+ "billing.estimate": "費用依公開標準價估算,實際帳單可能包含套餐、折扣或歷史價格調整。",
3929
+ "billing.monthProjection": "本月預計 {amount}",
3930
+ "billing.monthProjectionHint": "依已用 {elapsed}/{total} 天平均速度估算",
3931
+ "billing.comparePrevious": "較上一週期",
3932
+ "billing.compareDelta": "{sign}{percent}%({previous} → {current})",
3933
+ "billing.compareNew": "上一週期無記錄",
3934
+ "billing.compareSame": "與上一週期基本持平",
3935
+ "billing.compareNA": "上一週期無可用資料",
3936
+ "billing.skippedSessions": "有 {count} 個工作階段暫無法讀取,以下統計不包含這些工作階段。",
3937
+ "billing.reason.missing-usage": "缺少 provider usage",
3938
+ "billing.reason.unknown-provider": "未知 provider",
3939
+ "billing.reason.unknown-model": "未知模型價格",
3940
+ "billing.reason.missing-request-metadata": "缺少請求模型資訊",
3941
+ "billing.error.FORBIDDEN": "此統計僅允許從本機存取",
3942
+ "billing.error.INVALID_REQUEST": "消費統計參數無效",
3943
+ "billing.error.METHOD_NOT_ALLOWED": "請求方法不受支援",
3944
+ "billing.error.SESSION_NOT_FOUND": "找不到指定工作階段",
3945
+ "billing.error.UPSTREAM_UNAVAILABLE": "無法讀取工作階段消費記錄",
3946
+ "pricing.peak": "尖峰時段",
3947
+ "pricing.offPeak": "離峰時段",
3948
+ "pricing.peakHint": "DeepSeek 尖峰時段,API 價格為離峰的兩倍,{time} 恢復離峰價",
3949
+ "pricing.offPeakHint": "DeepSeek 離峰時段,API 價格為尖峰的一半,{time} 進入尖峰",
3950
+ "meta.updated": "更新於 {time}",
3951
+ "meta.cached": " · 快取",
3952
+ "error.FORBIDDEN": "此查詢僅允許從本機存取",
3953
+ "error.INVALID_API_KEY": "API 金鑰無效或沒有查詢權限",
3954
+ "error.INVALID_RESPONSE": "傳回了無法識別的回應",
3955
+ "error.METHOD_NOT_ALLOWED": "請求方法不受支援",
3956
+ "error.MISSING_API_KEY": "未設定查詢憑證",
3957
+ "error.RATE_LIMITED": "API 請求過於頻繁,請稍後重試",
3958
+ "error.UPSTREAM_ERROR": "API 傳回了錯誤",
3959
+ "error.UPSTREAM_TIMEOUT": "查詢 API 逾時",
3960
+ "error.UPSTREAM_UNAVAILABLE": "無法連線到 API",
3961
+ "advice.title": "下輪費用估算",
3962
+ "advice.copy": "依本工作階段近期已計費請求的 token 構成估算下輪費用,不是官方帳單。估算不會外傳工作階段內容,也不會自動換模型。",
3963
+ "advice.dockToggle": "下輪估算",
3964
+ "advice.dockCollapse": "收起估算",
3965
+ "advice.loading": "正在估算下輪費用…",
3966
+ "advice.unavailable": "暫時無法估算下輪費用",
3967
+ "advice.now": "目前時段",
3968
+ "advice.afterChange": "下個尖離峰切換後",
3969
+ "advice.fresh": "新開工作階段(全部未命中快取)",
3970
+ "advice.compact": "現在 /compact(摘要請求 + 壓縮後首輪)",
3971
+ "advice.alternative": "其他已設定模型",
3972
+ "advice.cacheSavings": "繼續本工作階段相對新開可節省",
3973
+ "advice.sample": "取最近 {count} / {limit} 次已計費請求的中位數",
3974
+ "advice.shape": "估算用量:未快取輸入 {input} · 輸出 {output} · 快取讀取 {cacheHit} · 快取寫入 {cacheWrite}",
3975
+ "advice.nextChange": "{time} 切換",
3976
+ "advice.coverage.priced": "本工作階段 {requests} 次請求均已計價",
3977
+ "advice.coverage.partial": "本工作階段 {requests} 次請求中 {priced} 次已計價、{unpriced} 次未計價",
3978
+ "advice.coverage.unpriced": "本工作階段 {requests} 次請求均未能計價",
3979
+ "advice.coverage.empty": "本工作階段還沒有可用於估算的請求",
3980
+ "advice.catalog": "參考價目錄:{versions}",
3981
+ "advice.caveat.estimate-not-a-bill": "以上為公開標準價估算,不是官方帳單;套餐、折扣或帳戶特殊價格可能導致實際扣款不同。",
3982
+ "advice.caveat.shape-may-differ": "下輪實際用量可能與此中位數不同,例如上下文壓縮、大段貼上或視覺輸入。",
3983
+ "advice.caveat.stepfun-grandfathering": "step-5-preview 快取命中標準價自 2026-10-14 起為 0.70 元/百萬 tokens;此前已依量呼叫的帳戶可能仍適用 0.35 元,外掛無法識別該保留價。",
3984
+ "advice.caveat.tokener-snapshot": "Tokener 費用依 2026-11-03 目錄快照估算,不套用原廠價格或 DeepSeek 尖離峰倍率。",
3985
+ "advice.caveat.no-priced-sample": "本工作階段還沒有已計費請求,無法根據歷史用量估算下輪費用。",
3986
+ "advice.caveat.unpriced-omitted": "無法定價的模型已省略,不會顯示為 $0。",
3987
+ "advice.caveat.holiday-calendar-stale": "內建法定假日僅到 2027 年;此後的假日會依一般工作日(尖峰)估算,請升級外掛。",
3988
+ "advice.caveat.compact-assumptions": "/compact 估算假設:摘要請求讀取整段歷史並輸出約 4,000 tokens(至多歷史的四分之一),壓縮後僅工作階段中最小的快取命中前綴仍命中,摘要與新輸入均未命中;實際摘要長度與壓縮模型可能不同。",
3989
+ "advice.period.peak": "尖峰時段",
3990
+ "advice.period.off-peak": "離峰時段",
3991
+ "advice.period.standard": "標準價",
3992
+ "advice.estimateOnly": "估算,非帳單",
3993
+ "advice.noEstimate": "暫無估算"
3994
+ };
3995
+ //#endregion
3716
3996
  //#region src/client/styles.ts
3717
3997
  const balanceStyles = `
3718
3998
  .dsh-deepseek-panel, .dsh-usage-content, .dsh-billing-view {
@@ -3996,7 +4276,10 @@ window.__ModuleLoader__.load({
3996
4276
  .dsh-advice-card-head .dsh-balance-heading { font-size: 16px; }
3997
4277
  .dsh-advice-meta { margin: 0; color: var(--ledger-muted); font-size: 12px; line-height: 1.6; }
3998
4278
  .dsh-advice-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; font-size: 13px; }
3999
- .dsh-advice-row strong { font-variant-numeric: tabular-nums; }
4279
+ .dsh-advice-row strong { font-variant-numeric: tabular-nums; min-width: 0; }
4280
+ .dsh-advice-amount { display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
4281
+ .dsh-advice-row > span:first-child { min-width: 0; overflow-wrap: anywhere; }
4282
+ .dsh-advice-meta, .dsh-advice-caveats li { overflow-wrap: anywhere; }
4000
4283
  .dsh-advice-row small { flex-basis: 100%; color: var(--ledger-muted); font-size: 11px; }
4001
4284
  .dsh-advice-alternatives { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; border-top: 1px solid var(--ledger-line); }
4002
4285
  .dsh-advice-caveats { margin: 0; padding-left: 18px; color: var(--ledger-muted); font-size: 11px; line-height: 1.6; }
@@ -4108,8 +4391,14 @@ window.__ModuleLoader__.load({
4108
4391
  function apply(ctx) {
4109
4392
  ctx.effect(() => ctx.locale.register(LOCALE_NS, {
4110
4393
  zh,
4111
- en
4394
+ en,
4395
+ "zh-tw": zhTW
4112
4396
  }), "dsh-balance: dictionaries");
4397
+ ctx.effect(() => ctx.locale.addLanguage({
4398
+ id: "zh-tw",
4399
+ label: "繁體中文",
4400
+ fallback: "zh"
4401
+ }), "dsh-balance: zh-TW language");
4113
4402
  const t = ctx.locale.bind(LOCALE_NS);
4114
4403
  ctx.effect(() => {
4115
4404
  const style = document.createElement("style");