@eddyskywalker/dsh-chatgpt-subscription 0.40.2 → 0.41.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.
Files changed (29) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/lib/client.js +420 -15
  3. package/lib/client.js.map +1 -1
  4. package/lib/index.js +649 -218
  5. package/lib/types/client/common/AccountPoolSection.d.ts +19 -0
  6. package/lib/types/client/common/AccountPoolSection.d.ts.map +1 -1
  7. package/lib/types/client/kimi-code/KimiCodeSection.d.ts.map +1 -1
  8. package/lib/types/client/kimi-code/KimiQuotaCard.d.ts +31 -0
  9. package/lib/types/client/kimi-code/KimiQuotaCard.d.ts.map +1 -0
  10. package/lib/types/client/kimi-code/locales.d.ts +74 -2
  11. package/lib/types/client/kimi-code/locales.d.ts.map +1 -1
  12. package/lib/types/client/kimi-code/staff-art.d.ts +19 -0
  13. package/lib/types/client/kimi-code/staff-art.d.ts.map +1 -0
  14. package/lib/types/client/kimi-code/styles.d.ts.map +1 -1
  15. package/lib/types/client/locales-ru/kimi-code.d.ts.map +1 -1
  16. package/lib/types/compat.d.ts +1 -1
  17. package/lib/types/host/kimi-code/adapter.d.ts +29 -0
  18. package/lib/types/host/kimi-code/adapter.d.ts.map +1 -1
  19. package/lib/types/host/kimi-code/cache-hint.d.ts +5 -5
  20. package/lib/types/host/kimi-code/client.d.ts.map +1 -1
  21. package/lib/types/host/kimi-code/mapper.d.ts.map +1 -1
  22. package/lib/types/host/kimi-code/routes.d.ts.map +1 -1
  23. package/lib/types/host/kimi-code/session-cache-state.d.ts +140 -0
  24. package/lib/types/host/kimi-code/session-cache-state.d.ts.map +1 -0
  25. package/lib/types/host/progress-updates/index.d.ts.map +1 -1
  26. package/lib/types/host/progress-updates/prompt.d.ts +6 -3
  27. package/lib/types/host/progress-updates/prompt.d.ts.map +1 -1
  28. package/lib/types/index.d.ts.map +1 -1
  29. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.41.0 - 2026-10-26
6
+
7
+ - **[kimi-code] 前缀缓存不再因为工具集变化整段重建:改走消息级工具声明,加/撤工具只动历史尾部**
8
+ - **现象**:会话里一旦有插件中途增删工具(例如看板的 `expose`),下一次请求的前缀就整体失效。真实会话上抓到过一次:闲置 36 分钟后续跑,`prompt=622,735 / cached=1,280`,整段 62 万 token 重算;而它的下一条立刻又把 62 万读回来,说明问题不在拼前缀的方式,在"工具表变了就重写"。
9
+ - **为什么能修**:这条线路的缓存按内容前缀匹配,而请求前缀的顺序是 system → tools → messages。把新工具放进顶层 `tools` 等于改前缀;把它作为 `messages[].tools` 追加到历史尾部则只增长尾巴。官方 kosong 把这个能力叫 `dynamically_loaded_tools`,本仓库的 `supportsDynamicTools` 就是它。
10
+ - **改法**:`resolveModel` 对声明该能力的模型输出 `toolUpdate: 'in-history'`(三重门控:能力位、OpenAI 兼容面、`DSH_KIMI_CODE_TOOL_UPDATE` 未关闭);mapper 把 harness 的 `tool-addition` / `tool-removal` 开发消息按原历史位置投影成消息级声明与撤销说明;延迟定义的条目不再进入顶层 `tools`。选 `in-history` 而非 `addition-only`,是因为只有前者能表达"撤销"而不缩短声明表——后者下撤掉一个工具会让顶层数组变短,前缀照样作废。
11
+ - **实测**(`scripts/probe-kimi-tool-declaration.probe.ts`,真实端点五组):冷启动 0;追加两轮 1280;追加工具声明 1536;追加撤销说明 1536;对照组改写顶层 tools 0。另一组证明模型会调用只存在于消息里的工具:顶层只放了一个诱饵,模型调起的却是 `probe_echo`。
12
+ - **代价**:撤销是软撤销——声明仍留在顶层(这是前缀不崩的前提),模型靠那条说明知道工具已不可用;若它无视说明,宿主会拒绝调用,错误可恢复。
13
+
14
+ - **[kimi-code] 缓存状态落盘:过期提示与失效归因能跨重启活下来**
15
+ - **现象**:设置卡片上那句"这次续跑会重算多少"从来不出现。三个输入全在进程内存里,而且未指定会话时 `sessionLastActiveAt(undefined)` 直接返回 `undefined`——卡片恰恰是这么问的。重启之后连命中率与失效原因也一起消失。
16
+ - **改法**:新增 `session-cache-state.ts`,把每个会话的最后活跃时间、最近一次请求的提示词规模、滚动读写量与上次失效原因写到 `~/.dsh/storages/dsh-chatgpt-subscription-kimi-cache.json`(临时文件 + rename 原子写,保留最近 64 个会话,解析失败按空文档处理)。适配器每轮收尾写一条;路由改为内存优先、落盘兜底,未指定会话时按最近活跃会话回答。
17
+ - **阈值**:过期判定从 30 分钟改为 25 分钟——公开实测给出的区间是 [5, 30) 分钟,25 分钟是最后一次确认全部仍热的年龄;更晚的提醒描述的是账单,不是预防。
18
+ - **归因**:前缀因我们自己的改动而重建时,日志里每个会话打一行(`prompt cache rebuilt ... tools changed`),不再无声无息。
19
+
20
+ - **[progress-updates] 提示词引导不再随开关变化**
21
+ - 系统提示是缓存前缀的第一段,开关一切换就改字,等于把所有线路的前缀整体作废。现在开关只影响工具本身(关闭时 `execute` 返回 `displayed:false`),文本恒定。
22
+
5
23
  ## 0.40.2 - 2026-10-25
6
24
 
7
25
  - **[antigravity] 响应体中途断流归为可重试的传输失败,长回答不再一次断线就作废**
package/lib/client.js CHANGED
@@ -1293,12 +1293,12 @@ window.__ModuleLoader__.load({
1293
1293
  children: t.noAccounts
1294
1294
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1295
1295
  className: "dsha-accounts-list",
1296
- children: accounts.map((account) => {
1296
+ children: accounts.map((account, index) => {
1297
1297
  const isActive = account.id === props.activeAccountId;
1298
1298
  const cooling = isCoolingDown(account, now);
1299
1299
  const needsRelogin = account.authStatus !== void 0 && account.authStatus !== "ok";
1300
1300
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1301
- className: `dsha-account-card ${isActive ? "active" : ""}`,
1301
+ className: `dsha-account-card ${isActive ? "active" : ""}${props.accountCardClassName === void 0 ? "" : ` ${props.accountCardClassName}`}`,
1302
1302
  children: [
1303
1303
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1304
1304
  className: "dsha-account-header",
@@ -1368,24 +1368,24 @@ window.__ModuleLoader__.load({
1368
1368
  className: "dsha-account-details",
1369
1369
  children: [
1370
1370
  props.renderDetails?.(account),
1371
- account.email !== void 0 && account.email !== account.alias && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
1371
+ account.email !== void 0 && account.email !== account.alias && props.omitDetails?.includes("email") !== true && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
1372
1372
  t.email,
1373
1373
  ": ",
1374
1374
  account.email
1375
1375
  ] }),
1376
- account.expiresAt !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
1376
+ account.expiresAt !== void 0 && props.omitDetails?.includes("expires") !== true && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
1377
1377
  t.expires,
1378
1378
  ": ",
1379
1379
  formatAccountDate(account.expiresAt)
1380
1380
  ] }),
1381
- account.lastUsedAt !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
1381
+ account.lastUsedAt !== void 0 && props.omitDetails?.includes("lastUsed") !== true && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
1382
1382
  t.lastUsed,
1383
1383
  ": ",
1384
1384
  formatAccountDate(account.lastUsedAt)
1385
1385
  ] })
1386
1386
  ]
1387
1387
  }),
1388
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AccountQuota, {
1388
+ props.renderQuota !== void 0 ? props.renderQuota(account, index, now) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AccountQuota, {
1389
1389
  quota: account.quota,
1390
1390
  labels: t,
1391
1391
  showEmpty: props.showQuota === true || anyQuota,
@@ -4759,6 +4759,30 @@ window.__ModuleLoader__.load({
4759
4759
  quotaWalletUsed: "本月已用",
4760
4760
  updatedAt: "更新时间:{time}",
4761
4761
  resetAt: "重置:{time}",
4762
+ kqTotal: "总使用量",
4763
+ kqTip: "Kimi Code 用量 {pct}",
4764
+ kqPoolKimi: "Kimi",
4765
+ kqPoolCode: "Code",
4766
+ kqResetAfter: "{time} 后重置",
4767
+ kqAccount: "账号{n}",
4768
+ kqAgo: "{time}更新",
4769
+ kqLastUsed: "最后调用 {time}",
4770
+ kqShortWindow: "5 小时窗口 {pct}",
4771
+ kqRestUsed: "其他已用",
4772
+ kqExpires: "令牌到期 {time}",
4773
+ kqJustNow: "刚刚",
4774
+ kqMinutesAgo: "{n} 分钟前",
4775
+ kqHoursAgo: "{n} 小时前",
4776
+ kqDaysAgo: "{n} 天前",
4777
+ kqWindow5h: "5 小时窗口",
4778
+ kqWindow7d: "7 天用量",
4779
+ kqDurationDay: "{n} 天",
4780
+ kqDurationHour: "{n} 小时",
4781
+ kqDurationMinute: "{n} 分钟",
4782
+ kqResetIn: "{time}后重置",
4783
+ kqResetSoon: "即将重置",
4784
+ kqRegionMainland: "中国区",
4785
+ kqRegionGlobal: "国际区",
4762
4786
  loading: "加载中...",
4763
4787
  loginFailed: "登录失败",
4764
4788
  requests: "次请求",
@@ -4890,6 +4914,30 @@ window.__ModuleLoader__.load({
4890
4914
  quotaWalletUsed: "Used this month",
4891
4915
  updatedAt: "Updated at: {time}",
4892
4916
  resetAt: "Reset: {time}",
4917
+ kqTotal: "Total usage",
4918
+ kqTip: "Kimi Code usage {pct}",
4919
+ kqPoolKimi: "Kimi",
4920
+ kqPoolCode: "Code",
4921
+ kqResetAfter: "resets {time}",
4922
+ kqAccount: "Account {n}",
4923
+ kqAgo: "updated {time}",
4924
+ kqLastUsed: "last used {time}",
4925
+ kqShortWindow: "5-hour window {pct}",
4926
+ kqRestUsed: "Other usage",
4927
+ kqExpires: "Token expires {time}",
4928
+ kqJustNow: "just now",
4929
+ kqMinutesAgo: "{n} min ago",
4930
+ kqHoursAgo: "{n} h ago",
4931
+ kqDaysAgo: "{n} d ago",
4932
+ kqWindow5h: "5-hour window",
4933
+ kqWindow7d: "7-day usage",
4934
+ kqDurationDay: "{n}d",
4935
+ kqDurationHour: "{n}h",
4936
+ kqDurationMinute: "{n}m",
4937
+ kqResetIn: "resets in {time}",
4938
+ kqResetSoon: "resetting soon",
4939
+ kqRegionMainland: "China",
4940
+ kqRegionGlobal: "Global",
4893
4941
  loading: "Loading...",
4894
4942
  loginFailed: "Sign-in failed",
4895
4943
  requests: "requests",
@@ -5082,6 +5130,290 @@ window.__ModuleLoader__.load({
5082
5130
  });
5083
5131
  }
5084
5132
  //#endregion
5133
+ //#region src/client/kimi-code/staff-art.ts
5134
+ /** 档位名(小写)到插图的映射;认不出来的档位按 Allegretto 那一档画。 */
5135
+ const TIER_ART = {
5136
+ adagio: "trial",
5137
+ andante: "trial",
5138
+ moderato: "basic",
5139
+ allegretto: "intermediate",
5140
+ allegro: "advanced",
5141
+ vivace: "standard"
5142
+ };
5143
+ const STAFF_ART = {
5144
+ trial: [
5145
+ { d: "M10.781 13.002c.784-.043 1.387.689 1.765 1.394a10.27 10.27 0 0 1 .873 7.323c-.63 2.435-2.202 4.602-4.3 5.926l.595 2.92c.078.384.085 1.146.297 1.465.23.343.286.247.75.27.885.043 2.09.283 2.819.858h-.003c2.628 2.084 1.61 5.7 1.61 5.7-.532 2.286-3.073 3.058-3.11 3.069l.013.066q.127.665.26 1.328l.144.745c.203 1.047.398 2.097.496 3.158.042.456.076.92-.026 1.37-.074.327-.213.63-.372.923a4.5 4.5 0 0 1-.706.976 4.54 4.54 0 0 1-2.14 1.23c-.359.094-.756.176-1.131.158-.015 0-3.078.12-4.478-2.138l-.046-.08c-.043-.07-.088-.135-.125-.21l.015.004a2.75 2.75 0 0 1-.315-1.262c0-1.51 1.197-2.733 2.676-2.733 1.478 0 2.675 1.223 2.675 2.733a2.73 2.73 0 0 1-1.414 2.397l.054.009q.316.054.634.037c.422-.02.838-.127 1.224-.3.543-.242 1.057-.57 1.465-1.01q.203-.222.361-.475c.24-.38.412-.824.455-1.274 0-.219.014-.433.006-.654a26 26 0 0 0-.195-2.063 40 40 0 0 0-.394-2.577c-1.374.35-2.821.276-4.22.048-1.102-.178-2.215-.463-3.16-1.074-1.442-.933-2.362-2.572-2.688-4.283a8.35 8.35 0 0 1 .585-4.961c1.168-2.59 3.546-4.348 5.757-6.091.152-.12.312-.253.375-.437.058-.172.023-.362-.01-.54-.36-1.868-.575-3.78-.396-5.676.18-1.896.775-3.782 1.909-5.292.36-.477.829-.942 1.416-.977M8.28 28.478a16.3 16.3 0 0 0-3.707 3.445c-1.034 1.314-1.897 2.9-1.818 4.585.067 1.467.864 2.834 1.96 3.783h.003c1.724 1.495 4.216 2.003 6.372 1.303q-.006-.017-.007-.034a369 369 0 0 0-1.467-7.035c-1.315.125-2.291 1.029-2.53 2.343a4.1 4.1 0 0 0 .102 1.873c.065.217.525 1.488.813 1.456-.67.073-1.326-.35-1.686-.932s-.46-1.294-.45-1.984c.032-1.823 1.002-3.59 2.583-4.47.214-.121.455-.24.558-.468.095-.208.047-.451-.004-.675zm3.43 11.63c.005.028.005.055.01.083l.185.993c2.434-1.336 1.983-3.45 1.98-3.462-.535-2.82-2.596-3.188-3.333-3.229zm9.935-7.777a.8.8 0 0 0 .349-.112q.113-.09.135-.112.033-.035.134-.057.011-.011.068-.01.135 0 .225.089a.29.29 0 0 1 .102.225q0 .135-.102.236a.3.3 0 0 1-.225.09h-.686v1.756h.72q.09 0 .135.045.045.056.045.123a.15.15 0 0 1-.045.113q-.045.045-.135.045h-2.272a.2.2 0 0 1-.125-.045.17.17 0 0 1-.044-.124q0-.068.044-.112a.2.2 0 0 1 .125-.045h.73V32.68h-2.711v-.349q.158-.258.495-.776a278 278 0 0 1 2.576-4.027h.462zm-1.092-3.161q-.247.416-.81 1.328-.561.912-.99 1.631l-.123.214h2.194v-3.611zm1.092-5.173a.8.8 0 0 0 .349-.112q.113-.09.135-.112.033-.034.134-.057.011-.011.068-.01.135 0 .225.089a.29.29 0 0 1 .102.225q0 .135-.102.236a.3.3 0 0 1-.225.09h-.686v1.756h.72q.09 0 .135.045.045.056.045.123a.15.15 0 0 1-.045.113q-.045.045-.135.045h-2.272a.2.2 0 0 1-.125-.045.17.17 0 0 1-.044-.124q0-.067.044-.112a.2.2 0 0 1 .125-.045h.73v-1.756h-2.711v-.349q.158-.258.495-.776a279 279 0 0 1 2.576-4.027h.462zm-9.198-6.262c-.163-1.794-2.432-2.435-3.481-.989 0 0-.64.756-.829 1.885-.14.851-.1 3.049.132 4.582.016.093.03.333.047.427l.263 1.278c.882-.812 1.642-1.57 1.997-2.065 2.19-2.547 1.871-5.119 1.871-5.119m8.106 3.101q-.247.416-.81 1.328-.561.912-.99 1.631l-.123.214h2.194v-3.611z" },
5146
+ { d: "M33.148 30c.068 0 .124.058.124.126v15.512h-.002a2.5 2.5 0 0 1-.117.764h1.648c.03 0 .055.025.055.055v.612c0 .03-.026.055-.055.055h-1.976c-.335.55-.86 1.065-1.58 1.44-1.64.853-3.422.668-3.984-.41a1.6 1.6 0 0 1-.139-1.03h-2.067a.056.056 0 0 1-.055-.055v-.612c0-.03.025-.055.055-.055h2.317c.344-.662.987-1.3 1.842-1.745 1.18-.614 2.433-.688 3.253-.281v-14.25c0-.068.056-.126.125-.126z" },
5147
+ { d: "M47.148 30c.068 0 .124.058.124.126v15.512h-.002a2.5 2.5 0 0 1-.117.764h1.648c.03 0 .055.025.055.055v.612c0 .03-.026.055-.055.055h-1.976c-.335.55-.86 1.065-1.58 1.44-1.64.853-3.422.668-3.984-.41a1.6 1.6 0 0 1-.139-1.03h-2.067a.055.055 0 0 1-.055-.055v-.612c0-.03.025-.055.055-.055h2.317c.344-.662.987-1.3 1.842-1.745 1.18-.614 2.433-.688 3.253-.281v-14.25c0-.068.056-.126.125-.126z" },
5148
+ { d: "M61.86 36.699V21.126a.124.124 0 0 0-.12-.126h-.526a.124.124 0 0 0-.12.126v14.307c-.776-.408-1.963-.335-3.082.282-1.555.855-2.382 2.428-1.852 3.51.533 1.083 2.222 1.269 3.777.411 1.296-.713 1.927-1.93 1.92-2.937z" },
5149
+ { d: "M74.86 36.699V21.126a.124.124 0 0 0-.12-.126h-.526a.124.124 0 0 0-.12.126v14.307c-.776-.408-1.963-.335-3.082.282-1.555.855-2.382 2.428-1.852 3.51.533 1.083 2.222 1.269 3.776.411 1.297-.713 1.927-1.93 1.921-2.937z" },
5150
+ {
5151
+ d: "M79.5 22h1v20h-1z",
5152
+ opacity: ".03"
5153
+ },
5154
+ { d: "M91.86 33.699V18.126a.124.124 0 0 0-.12-.126h-.526a.124.124 0 0 0-.12.126v14.307c-.776-.408-1.963-.335-3.082.282-1.555.855-2.382 2.428-1.852 3.51.533 1.083 2.222 1.269 3.776.411 1.297-.713 1.927-1.93 1.921-2.937z" },
5155
+ { d: "M104.859 33.699V18.126c0-.069-.054-.126-.119-.126h-.526c-.065 0-.119.057-.119.126v14.307c-.777-.408-1.964-.335-3.083.282-1.555.855-2.382 2.428-1.852 3.51.533 1.083 2.222 1.269 3.777.411 1.296-.713 1.926-1.93 1.92-2.937z" },
5156
+ { d: "M117.275 23h-.576a.12.12 0 0 0-.119.121l-.007 14.005a1.2 1.2 0 0 0-.205-.12c-.881-.418-2.123-.31-3.241.282-1.7.9-2.546 2.562-1.923 3.782.315.616.943 1.002 1.768 1.087q.173.018.349.018c.659 0 1.367-.185 2.029-.535 1.315-.696 1.95-1.88 1.916-2.978l.009-.007.117-15.531a.12.12 0 0 0-.119-.122zm-2.353 17.795c-.62.328-1.277.476-1.853.417-.292-.03-.814-.147-1.035-.582-.368-.723.329-1.867 1.525-2.502.531-.281 1.098-.428 1.599-.428.306 0 .587.055.821.167h.007c.018.012.412.209.553.792.041.724-.634 1.617-1.617 2.136" }
5157
+ ],
5158
+ basic: [
5159
+ {
5160
+ d: "M8.5 22h1v20h-1z",
5161
+ opacity: ".03"
5162
+ },
5163
+ { d: "M23.148 30c.068 0 .125.058.125.126v16.276H24.8c.03 0 .055.025.055.055v.612c0 .03-.026.055-.055.055h-1.528v5.514h-.003a2.5 2.5 0 0 1-.117.764H24.8c.03 0 .055.025.055.055v.612c0 .03-.026.055-.055.055h-1.976c-.335.55-.86 1.065-1.58 1.44-1.64.853-3.422.668-3.984-.41a1.6 1.6 0 0 1-.139-1.03h-2.067a.056.056 0 0 1-.055-.055v-.612c0-.03.025-.055.055-.055h2.317c.344-.662.987-1.3 1.842-1.745 1.18-.614 2.433-.688 3.253-.281v-3.763c-.314.36-.721.69-1.223.95-1.64.854-3.421.67-3.983-.409a1.6 1.6 0 0 1-.139-1.03h-2.067a.056.056 0 0 1-.055-.055v-.612c0-.03.025-.055.055-.055h2.317c.344-.662.987-1.3 1.842-1.745 1.18-.614 2.433-.688 3.253-.281v-14.25c0-.068.056-.126.125-.126z" },
5164
+ { d: "m57.18 26.121.002.005v15.512h-.003c.006 1.002-.658 2.215-2.026 2.925-1.64.855-3.422.67-3.984-.409-.56-1.078.313-2.645 1.953-3.497 1.18-.614 2.433-.688 3.253-.281V27.663l-14.102 4.111v13.864h-.003a2.5 2.5 0 0 1-.117.764h1.648c.03 0 .055.025.055.055v.612c0 .03-.026.055-.055.055h-1.976c-.335.55-.86 1.065-1.58 1.44-1.64.853-3.422.668-3.984-.41a1.6 1.6 0 0 1-.139-1.03h-2.067a.055.055 0 0 1-.055-.055v-.612c0-.03.025-.055.055-.055h2.317c.344-.662.987-1.3 1.842-1.745 1.18-.614 2.433-.688 3.253-.281v-14.25q.001-.05.033-.084V30l15.68-4.571z" },
5165
+ { d: "M54.709 48.093a.5.5 0 0 1 .698.116c2.324 3.253 7.527 4.255 11.85 1.853a.501.501 0 0 1 .486.876c-4.676 2.598-10.474 1.6-13.15-2.147a.5.5 0 0 1 .116-.698" },
5166
+ { d: "M72.055 28c.069 0 .126.058.126.126v15.512h-.003c.007 1.002-.657 2.215-2.025 2.925-1.64.855-3.421.67-3.983-.409-.56-1.078.312-2.645 1.952-3.497 1.18-.614 2.433-.687 3.253-.281v-14.25c0-.069.057-.126.126-.126z" },
5167
+ { d: "M104.273 31.273v2.006h-.001v13.123h1.529c.029 0 .055.025.055.055v.612c0 .03-.026.055-.055.055h-1.529v5.514h-.001c.001.245-.038.504-.118.764h1.648c.029 0 .055.025.055.055v.612c0 .03-.026.055-.055.055h-1.976c-.335.55-.859 1.065-1.581 1.44-1.64.853-3.421.668-3.983-.41a1.6 1.6 0 0 1-.139-1.03h-2.067a.056.056 0 0 1-.055-.055v-.612c0-.03.025-.055.055-.055h2.317c.344-.662.987-1.3 1.842-1.745 1.181-.614 2.433-.688 3.253-.281v-3.763c-.314.36-.721.69-1.223.95-1.64.854-3.421.67-3.983-.409a1.6 1.6 0 0 1-.139-1.03h-2.067a.056.056 0 0 1-.055-.055v-.612c0-.03.025-.055.055-.055h2.317c.344-.662.987-1.3 1.842-1.745 1.181-.614 2.433-.688 3.253-.281V33.131l-16.195-2.975v15.482h-.002a2.5 2.5 0 0 1-.117.764h1.648c.03 0 .055.025.055.055v.612c0 .03-.025.055-.055.055h-1.976c-.335.55-.86 1.065-1.58 1.44-1.64.853-3.422.668-3.984-.41a1.6 1.6 0 0 1-.139-1.03h-2.067a.056.056 0 0 1-.055-.055v-.612c0-.03.025-.055.055-.055h2.317c.344-.662.987-1.3 1.842-1.745 1.18-.614 2.433-.688 3.253-.281v-14.25c0-.045.025-.084.061-.107l-.067-.011V28z" }
5168
+ ],
5169
+ intermediate: [
5170
+ { d: "M18.055 14c.069 0 .126.057.126.126v19.512h-.003c.007 1.002-.657 2.215-2.025 2.925-1.64.855-3.421.67-3.983-.409-.56-1.078.312-2.645 1.952-3.497 1.18-.614 2.433-.687 3.253-.281V16H6.18v17.638h-.003c.007 1.002-.657 2.215-2.025 2.925-1.64.855-3.421.67-3.983-.409-.56-1.078.312-2.645 1.952-3.497 1.18-.614 2.433-.687 3.253-.281v-18.25c0-.069.057-.126.126-.126z" },
5171
+ {
5172
+ d: "M23.5 22h1v20h-1z",
5173
+ opacity: ".03"
5174
+ },
5175
+ { d: "M59.055 14c.069 0 .126.057.126.126v19.512h-.003c.007 1.002-.657 2.215-2.025 2.925-1.64.855-3.421.67-3.983-.409-.56-1.078.312-2.645 1.952-3.497 1.18-.614 2.433-.687 3.253-.281V19H47.18v14.638h-.003c.007 1.002-.657 2.215-2.025 2.925-1.64.855-3.421.67-3.983-.409-.56-1.078.312-2.645 1.952-3.497 1.18-.614 2.433-.687 3.253-.281V16H35.18v17.638h-.003c.007 1.002-.657 2.215-2.025 2.925-1.64.855-3.421.67-3.983-.409-.56-1.078.312-2.645 1.952-3.497 1.18-.614 2.433-.687 3.253-.281v-18.25c0-.069.057-.126.126-.126zM61.5 34a.5.5 0 1 1 0 1 .5.5 0 0 1 0-1M47.18 18h11.194v-2H47.18z" },
5176
+ { d: "M70.538 6.52q.255 0 .256.232v1.04h.017q.16 0 .248-.032a1 1 0 0 0 .191-.112 1 1 0 0 1 .08-.056.2.2 0 0 1 .105-.024q.096 0 .16.072a.2.2 0 0 1 .071.152.23.23 0 0 1-.071.168.22.22 0 0 1-.16.064h-.641v2.128q0 .784.425.784a1 1 0 0 0 .447-.136l.065.216q0 .008-.12.112a1.2 1.2 0 0 1-.289.192.9.9 0 0 1-.391.088q-.712 0-.712-.968V8.024h-.448a.12.12 0 0 1-.088-.032.14.14 0 0 1-.033-.088q0-.047.033-.08a.12.12 0 0 1 .087-.032h.449V6.584l.128-.032a.6.6 0 0 1 .191-.032M67.2 7.6q.24 0 .376.128a.43.43 0 0 1 .168.328q0 .12-.064.24a.9.9 0 0 1-.232.272q-.248-.296-.56-.296a.66.66 0 0 0-.4.144q-.184.135-.312.384v2.272h.496v.232H65.08v-.232h.52V8.208a.08.08 0 0 0-.024-.056.08.08 0 0 0-.056-.024h-.4v-.2q.24-.072.424-.136.184-.072.4-.168a.3.3 0 0 1 .064-.016q.064 0 .112.056a.15.15 0 0 1 .056.12v.568q.152-.345.44-.544.296-.208.584-.208m1.612.016q.064 0 .112.056a.15.15 0 0 1 .056.12v3.28h.512v.232H67.9v-.232h.504V8.216a.08.08 0 0 0-.024-.056.08.08 0 0 0-.056-.024h-.4v-.2q.24-.072.425-.136.183-.072.399-.168a.3.3 0 0 1 .064-.016M73.5 10a.5.5 0 1 1 0 1 .5.5 0 0 1 0-1m-4.856-4.056a.37.37 0 0 1 .272.112.37.37 0 0 1 .112.272.37.37 0 0 1-.112.272.37.37 0 0 1-.272.112.36.36 0 0 1-.264-.112.37.37 0 0 1-.111-.272.37.37 0 0 1 .11-.272.36.36 0 0 1 .265-.112" },
5177
+ { d: "M100.055 14c.069 0 .126.057.126.126v19.512h-.003c.007 1.002-.657 2.215-2.025 2.925-1.64.855-3.421.67-3.983-.409-.56-1.078.312-2.645 1.952-3.497 1.18-.614 2.433-.687 3.253-.281V16H89.18v17.638h-.003c.007 1.002-.657 2.215-2.025 2.925-1.64.855-3.421.67-3.983-.409-.56-1.078.312-2.645 1.952-3.497 1.18-.614 2.433-.687 3.253-.281V16H73.18v17.638h-.003c.007 1.002-.657 2.215-2.025 2.925-1.64.855-3.421.67-3.983-.409-.56-1.078.312-2.645 1.952-3.497 1.18-.614 2.433-.687 3.253-.281v-18.25c0-.069.057-.126.126-.126zm2.445 20a.5.5 0 1 1 0 1 .5.5 0 0 1 0-1" },
5178
+ {
5179
+ d: "M104.5 22h1v20h-1z",
5180
+ opacity: ".03"
5181
+ },
5182
+ { d: "M115.169 32a.17.17 0 0 1 .155.094q.083.081.128.117a.25.25 0 0 0 .137.035h.457q.894 0 1.406.517.548.597.548 1.7 0 .81-.283 1.361-.274.552-.703.822-.42.257-.85.257-.201 0-.42-.082a3 3 0 0 1-.374-.164v5.003h.712V42H114v-.34h.64v-8.792a.13.13 0 0 0-.028-.082q-.018-.035-.054-.035h-.403v-.294q.31-.117.485-.187.172-.082.456-.247zm-5.736-4c.04 0 .073.038.073.085l.003 4.959c.458-.422 1.109-.697 1.761-.586l-.004.001c.633.107 1.039.674.986 1.376v.027a1 1 0 0 1-.009.091q-.009.073-.022.147a3 3 0 0 1-.11.437 5 5 0 0 1-.236.587 4.6 4.6 0 0 1-.413.686 5.3 5.3 0 0 1-.638.738 7 7 0 0 1-.604.517c-.1.071-.194.144-.295.212a5 5 0 0 1-.519.317c-.085.043-.175.08-.262.123-.039.018-.084.055-.129.05-.01 0-.01-.005-.01-.015q-.003-.018-.002-.035v-.18l.002-9.452c0-.047.034-.085.074-.085zm1.736 4.994c-.632-.107-1.372.37-1.659.901v3.085c2.133-1.389 2.172-3.135 2.173-3.165.027-.369-.122-.754-.514-.82m4.758-.337a.9.9 0 0 0-.311.047q-.119.035-.155.094a.35.35 0 0 0-.072.187q-.019.118-.019.364v2.897q.328.153.603.152.511 0 .877-.433.374-.446.374-1.467 0-.926-.366-1.384a1.14 1.14 0 0 0-.931-.457M119.5 32a.5.5 0 1 1 0 1 .5.5 0 0 1 0-1" }
5183
+ ],
5184
+ advanced: [
5185
+ { d: "M11.443 10.002c.783-.043 1.387.689 1.764 1.394a10.27 10.27 0 0 1 .873 7.323c-.63 2.435-2.202 4.602-4.298 5.926l.593 2.92c.078.384.085 1.146.297 1.465.23.343.287.247.751.27.884.043 2.09.283 2.819.858h-.004c2.63 2.084 1.61 5.7 1.61 5.7-.531 2.286-3.073 3.058-3.11 3.069l.013.066q.128.665.26 1.328c.05.25.095.496.145.745.203 1.047.397 2.097.496 3.158.042.456.076.92-.027 1.37-.073.327-.212.63-.37.923-.193.356-.43.686-.707.976a4.54 4.54 0 0 1-2.14 1.23c-.359.094-.756.176-1.131.158-.015 0-3.079.12-4.478-2.138l-.047-.08c-.042-.07-.087-.135-.125-.21l.016.004a2.75 2.75 0 0 1-.316-1.262c0-1.51 1.198-2.733 2.676-2.733s2.676 1.223 2.676 2.733a2.73 2.73 0 0 1-1.414 2.397l.054.009q.315.054.633.037c.422-.02.839-.127 1.225-.3.543-.242 1.056-.57 1.465-1.01q.202-.222.361-.475c.24-.38.412-.824.454-1.274 0-.219.015-.433.006-.654a27 27 0 0 0-.194-2.063 40 40 0 0 0-.395-2.577c-1.373.35-2.82.276-4.218.048-1.104-.178-2.216-.463-3.16-1.074-1.443-.933-2.363-2.572-2.69-4.283a8.35 8.35 0 0 1 .586-4.961c1.168-2.59 3.546-4.348 5.757-6.091.151-.12.312-.253.375-.437.058-.172.022-.362-.011-.54-.36-1.868-.574-3.78-.396-5.676.181-1.897.775-3.782 1.91-5.292.36-.477.828-.942 1.416-.977M8.942 25.478a16.3 16.3 0 0 0-3.707 3.445c-1.034 1.314-1.897 2.9-1.819 4.585.067 1.467.865 2.834 1.961 3.783h.002c1.724 1.495 4.217 2.003 6.372 1.303q-.005-.017-.007-.034a370 370 0 0 0-1.466-7.036c-1.316.126-2.292 1.03-2.53 2.344a4.1 4.1 0 0 0 .102 1.873c.065.217.524 1.488.812 1.456-.67.073-1.326-.35-1.685-.932-.36-.582-.46-1.294-.45-1.984.032-1.823 1.002-3.59 2.583-4.47.214-.121.455-.24.557-.468.096-.208.048-.451-.004-.675zm3.43 11.63c.005.028.005.055.01.083l.185.993c2.433-1.336 1.983-3.45 1.98-3.462-.536-2.82-2.597-3.188-3.334-3.229zm.737-22.373c-.163-1.794-2.432-2.435-3.482-.989 0 0-.64.756-.828 1.885-.14.851-.1 3.049.132 4.582.016.093.029.333.047.427l.263 1.278c.882-.812 1.642-1.57 1.997-2.065 2.19-2.547 1.87-5.119 1.87-5.119" },
5186
+ { d: "M21.748 29.652c-.844-.203-1.687.3-2.28 1.07l-.003-9.053c0-.086-.043-.155-.095-.155h-.458c-.052 0-.095.07-.095.155l-.003 17.253c-.008.029 0 .077 0 .108v.222q0 .032.003.064c0 .02 0 .03.013.03.059.006.116-.06.166-.094.113-.079.23-.146.34-.225.235-.165.453-.37.672-.576.13-.125.252-.258.38-.388q.122-.133.24-.265a10 10 0 0 0 .996-1.358 10 10 0 0 0 1.302-3.432 6 6 0 0 0 .082-.627q.008-.082.01-.165v-.05c.069-1.282-.456-2.315-1.276-2.511zm.535 2.478c0 .033-.043 3.233-2.812 5.778v-5.632c.372-.969 1.328-1.842 2.146-1.646.508.122.702.826.666 1.5" },
5187
+ { d: "M32.78 16.537c1.64-.854 3.42-.669 3.983.41.191.368.212.794.094 1.229h1.91c.03 0 .055.025.055.055v.612c0 .03-.025.055-.054.055h-2.23c-.363.589-.96 1.146-1.728 1.545-1.181.615-2.433.687-3.252.28V42l9.262-.001V30.463h.003c-.006-1.003.658-2.216 2.026-2.926 1.64-.854 3.422-.669 3.984.41.56 1.077-.313 2.644-1.953 3.496-1.181.615-2.433.687-3.253.28v10.275l11.124-.002V22.463h.002c-.007-1.003.658-2.216 2.026-2.926 1.64-.854 3.422-.669 3.984.41.56 1.077-.313 2.644-1.953 3.496-1.181.615-2.433.687-3.252.28v18.273h9.193V30.462h.003c-.007-1.003.657-2.216 2.025-2.926 1.64-.854 3.422-.669 3.984.41.56 1.077-.313 2.644-1.953 3.496-1.18.615-2.432.687-3.252.28v10.272h.005v2L30.75 44V19.463h.002q-.002-.276.064-.566H29.02a.056.056 0 0 1-.054-.054v-.613c0-.03.025-.054.055-.054h2.064c.324-.624.885-1.22 1.693-1.639" },
5188
+ { d: "M112.65 17.594c1.64-.854 3.422-.67 3.984.409.559 1.078-.313 2.645-1.953 3.497-1.181.614-2.433.688-3.253.281l-.001 17.813h.01v2L74.04 44.067a.12.12 0 0 1-.081.034h-.555a.127.127 0 0 1-.126-.126V33.239h.002c-.007-1.002.659-2.215 2.027-2.925 1.64-.855 3.421-.67 3.983.408.56 1.078-.313 2.645-1.953 3.497-1.18.614-2.432.688-3.252.281v7.565l12.331-.816V30.463h.002c-.007-1.003.658-2.216 2.026-2.926 1.64-.854 3.422-.669 3.984.41.56 1.077-.313 2.645-1.953 3.496-1.181.615-2.432.687-3.252.28v9.472l11.296-.747V22.463h.001c-.006-1.003.659-2.216 2.027-2.926 1.64-.854 3.421-.669 3.983.41.56 1.077-.313 2.645-1.953 3.496-1.181.615-2.433.687-3.253.28v16.672l11.296-.748.002-19.126h.002c-.007-1.003.658-2.217 2.026-2.927M84.111 21c.092 0 .167.08.167.177v2.426l.764-.37c.11-.054.236.031.236.16v1.263a.36.36 0 0 1-.194.32l-.806.391v2.823l.764-.37c.11-.053.236.032.236.16v1.264a.36.36 0 0 1-.194.322l-.806.39v1.456a.17.17 0 0 1-.167.176.17.17 0 0 1-.166-.176v-1.295l-1.334.648v2.058c0 .098-.074.177-.166.177a.17.17 0 0 1-.167-.177v-1.896l-.763.37c-.11.053-.237-.032-.237-.16v-1.264c0-.138.076-.263.195-.32l.805-.392v-2.823l-.763.371c-.11.053-.236-.032-.237-.16v-1.264c0-.138.076-.264.195-.321l.805-.39v-1.986c0-.097.075-.176.167-.176s.166.079.166.176v1.823l1.334-.646v-2.588c0-.098.074-.177.166-.177m-1.5 5.176V29l1.334-.647v-2.824z" }
5189
+ ],
5190
+ standard: [
5191
+ { d: "M17.026 13.924c1.64-.854 3.421-.669 3.983.409.192.369.212.794.095 1.23h1.91c.03 0 .055.025.055.054v.613c0 .03-.025.054-.055.054h-2.23c-.362.59-.96 1.147-1.728 1.546-1.18.614-2.432.687-3.252.28v19.277h-.806V16.85H15q-.003-.276.064-.566h-1.796a.056.056 0 0 1-.055-.054v-.613c0-.03.026-.055.055-.055h2.064c.324-.623.886-1.219 1.694-1.638m-9.02.104 3.24-.81v9.039h-.76v-3.392l-3.24.81V9.692h.76zm0 2v1.457l2.48-.62v-1.457zm16.069-4.652a1.006 1.006 0 1 1-.002 2.011 1.006 1.006 0 0 1 .002-2.011" },
5192
+ { d: "M22.507 38c.71.013.983.454 1.381.696.529.323.567 1.187.296 1.484-.288.315-.683.516-1.083.232-.4-.283-.374-.786-.168-1.083s.58-.697-.4-.722c-.322 0-.645.322-.942.812-.307.508-.322 1.149-.374 1.82-.009.114-.097.39-.234.769l1.966.12-.024.386-2.083-.126c-.758 1.992-2.42 5.774-2.63 6.074-.27.387-1.084.967-1.755 1.393-.62.394-1.496.529-1.832.284-.593-.434-.593-1.149-.503-1.458.12-.41.569-.67.84-.607.386.09.619.595.541.943s-.297.683-.155.838c.189.205.62-.04.993-.31.374-.27.62-.67.852-1.664.155-.665 1.065-3.49 1.844-5.603l-1.248-.075a1 1 0 0 1 .023.403c-.103.619-.554.76-.774.58-.395-.326.142-.446.142-.825 0-.362-.27-.942-1.25-.968-.981-.026-1.24.9-.504 1.483.374.297 1.88 1.105 2 1.845.154.954-1.123 1.974-2.09 2.025-.968.052-2.32-.736-2.336-1.458-.012-.567.335-.747.852-.567.296.103.503.528.53.76.025.233-.362.543-.285.685s.658.36 1.161.335c.503-.026 1.135-.67 1.135-1.161 0-.62-2.238-1.522-2.296-2.4-.064-.967.58-1.805 1.832-1.805.856-.008 1.393.294 1.669.669l1.58.096c.33-.873.623-1.58.814-1.887.657-1.058 1.806-2.026 2.515-2.013" },
5193
+ { d: "M18.957 10.226c24.81-12.138 74.789-12.138 90.139 1.25C94.46.586 47.694-1.02 18.957 10.225" },
5194
+ { d: "M100.529 13.924c1.64-.854 3.422-.669 3.984.409.191.369.212.794.094 1.23h1.911c.029 0 .054.024.054.054v.613c0 .03-.025.054-.054.054h-2.23c-.363.59-.96 1.147-1.728 1.546-1.181.614-2.433.687-3.252.28v18.88h7.264V22.652h.002c-.007-1.002.659-2.215 2.027-2.925 1.64-.855 3.421-.67 3.983.409.559 1.078-.313 2.645-1.953 3.497-1.181.614-2.433.687-3.253.28V42.8h-.003v.212H60.026V20.028h.002c-.006-1.002.659-2.215 2.027-2.925 1.64-.855 3.421-.67 3.983.409.56 1.078-.313 2.645-1.953 3.497-1.18.614-2.433.687-3.253.28v15.7h9.863V25.362h.002c-.006-1.002.659-2.215 2.027-2.925 1.64-.854 3.421-.67 3.983.409.56 1.078-.313 2.645-1.953 3.497-1.181.614-2.433.687-3.253.28V36.99h8.44V22.653h.001c-.006-1.002.659-2.215 2.027-2.925 1.64-.854 3.421-.67 3.983.409.56 1.078-.313 2.645-1.953 3.497-1.18.614-2.433.686-3.253.28V36.99h8.863V20.315h.002c-.006-1.003.659-2.216 2.027-2.926 1.64-.854 3.421-.67 3.983.409.56 1.078-.313 2.645-1.953 3.497-1.18.614-2.433.687-3.253.28V36.99h8.086V16.85h.002q-.002-.274.064-.565h-1.795a.056.056 0 0 1-.055-.054v-.613c0-.03.025-.054.055-.055h2.064c.324-.623.885-1.219 1.693-1.638M60.832 40.963h9.863v-1.925h-9.863zm10.669 0h8.44v-1.925H71.5zm9.245 0h8.863v-1.925h-8.863zm18.562 0h7.264v-1.925h-7.264zm-8.893 0h8.086v-1.925h-8.086z" }
5195
+ ]
5196
+ };
5197
+ //#endregion
5198
+ //#region src/client/kimi-code/KimiQuotaCard.tsx
5199
+ /**
5200
+ * Kimi Code 账号卡片里的额度区。
5201
+ *
5202
+ * 这张卡与其余线路的账号卡是同一张壳(别名、徽标、操作按钮都在 `AccountPoolSection` 里),
5203
+ * 换掉的只是额度那一块:档位名用 Georgia 字标,右侧压一条五线谱,音符按档位换成对应的插图。
5204
+ *
5205
+ * 只有一条进度条,按 Kimi 自己的额度结构折算:7 天额度是 5 个 5 小时额度,月额度是 25 个,
5206
+ * 所以「近 5 小时用掉多少」折进大窗口之后是 `5小时% ÷ 5`(月额度则 ÷ 25)。条子上蓝色那一截
5207
+ * 就是这段最近的消耗,深色那一截是除此之外的已用,底槽是剩下的。
5208
+ *
5209
+ * 大窗口的取法:有月额度就用月额度,否则用 7 天;只有 5 小时一条线的账号就直接以它为准。
5210
+ * 接口给的是「已用比例」,各窗口各自算各自的,不能相加。
5211
+ */
5212
+ /** 5 小时窗口在 7 天窗口里的份数。 */
5213
+ const SHORT_PER_WEEK = 5;
5214
+ /** 5 小时窗口在月额度里的份数。 */
5215
+ const SHORT_PER_MONTH = 25;
5216
+ /** 百分比,最多两位小数;非有限数不画。 */
5217
+ function percentText$2(value) {
5218
+ if (!Number.isFinite(value)) return "0%";
5219
+ return `${Math.round(value * 100) / 100}%`;
5220
+ }
5221
+ /** `YYYY-MM-DD HH:mm`,本地时区;令牌到期用它,年份不能省。 */
5222
+ function dateText(ms) {
5223
+ const date = new Date(ms);
5224
+ const pad = (n) => n < 10 ? `0${n}` : String(n);
5225
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
5226
+ }
5227
+ /** `MM-DD HH:mm`,本地时区。 */
5228
+ function clockText(ms) {
5229
+ const date = new Date(ms);
5230
+ const pad = (n) => n < 10 ? `0${n}` : String(n);
5231
+ return `${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
5232
+ }
5233
+ function minutesOf(window) {
5234
+ return typeof window.windowDurationMins === "number" && Number.isFinite(window.windowDurationMins) ? window.windowDurationMins : null;
5235
+ }
5236
+ /** 5 小时窗口:标签或名义长度任一命中即可。 */
5237
+ function isShortWindow(window) {
5238
+ if (/^5[- ]?hour/i.test(window.label)) return true;
5239
+ return minutesOf(window) === 300;
5240
+ }
5241
+ /** 7 天窗口。 */
5242
+ function isWeekWindow(window) {
5243
+ if (/weekly|7[- ]?day/i.test(window.label)) return true;
5244
+ return minutesOf(window) === 10080;
5245
+ }
5246
+ /** 月度池——两个独立月额度靠它认出来。 */
5247
+ function isMonthlyPool(window) {
5248
+ if (/month/i.test(window.label)) return true;
5249
+ const minutes = minutesOf(window);
5250
+ return minutes !== null && minutes >= 43200;
5251
+ }
5252
+ /** 档位名 → 插图;认不出来按 Allegretto 那一档。 */
5253
+ function artKeyFor(planName) {
5254
+ const key = (planName ?? "").trim().toLowerCase();
5255
+ return Object.prototype.hasOwnProperty.call(TIER_ART, key) ? TIER_ART[key] : "intermediate";
5256
+ }
5257
+ /** 距离重置还有多久:不足一小时只说分钟,整小时不带「0 分钟」。 */
5258
+ function durationText(labels, remainingMs) {
5259
+ const totalMinutes = Math.max(0, Math.ceil(remainingMs / 6e4));
5260
+ const hours = Math.floor(totalMinutes / 60);
5261
+ const minutes = totalMinutes % 60;
5262
+ const hourText = labels.kqDurationHour.replace("{n}", String(hours));
5263
+ const minuteText = labels.kqDurationMinute.replace("{n}", String(minutes));
5264
+ if (hours === 0) return minuteText;
5265
+ if (minutes === 0) return hourText;
5266
+ return `${hourText} ${minuteText}`;
5267
+ }
5268
+ /** 「3 分钟前」这类相对距离,用当前语言的说法拼出来。 */
5269
+ function agoLabel(labels, ms, now) {
5270
+ const minutes = Math.floor(Math.max(0, now - ms) / 6e4);
5271
+ if (minutes < 1) return labels.kqJustNow;
5272
+ if (minutes < 60) return labels.kqMinutesAgo.replace("{n}", String(minutes));
5273
+ const hours = Math.floor(minutes / 60);
5274
+ if (hours < 24) return labels.kqHoursAgo.replace("{n}", String(hours));
5275
+ return labels.kqDaysAgo.replace("{n}", String(Math.floor(hours / 24)));
5276
+ }
5277
+ function KimiQuotaCard(props) {
5278
+ const t = props.labels;
5279
+ const quota = props.quota;
5280
+ const windows = quota?.windows ?? [];
5281
+ const planName = (props.planName ?? "").trim();
5282
+ const art = STAFF_ART[artKeyFor(planName)];
5283
+ const used = (window) => window !== null && Number.isFinite(window.usedPercent) ? window.usedPercent : 0;
5284
+ const shortWindow = windows.find(isShortWindow) ?? null;
5285
+ const monthlyWindow = windows.find(isMonthlyPool) ?? null;
5286
+ const weekWindow = windows.find(isWeekWindow) ?? null;
5287
+ const carrier = monthlyWindow ?? weekWindow ?? shortWindow;
5288
+ const factor = monthlyWindow !== null ? SHORT_PER_MONTH : weekWindow !== null ? SHORT_PER_WEEK : 1;
5289
+ const headline = monthlyWindow !== null ? t.kqTotal : weekWindow !== null ? t.kqWindow7d : t.kqWindow5h;
5290
+ const totalPercent = Math.min(100, used(carrier));
5291
+ const recentPercent = Math.round(Math.min(totalPercent, used(shortWindow) / factor) * 100) / 100;
5292
+ const restPercent = Math.round(Math.max(0, totalPercent - recentPercent) * 100) / 100;
5293
+ const resetAt = carrier !== null && typeof carrier.resetsAt === "number" && Number.isFinite(carrier.resetsAt) ? carrier.resetsAt : null;
5294
+ const lastUsed = props.lastUsedAt;
5295
+ const expires = props.expiresAt;
5296
+ const shortReset = shortWindow !== null && typeof shortWindow.resetsAt === "number" && Number.isFinite(shortWindow.resetsAt) ? shortWindow.resetsAt : null;
5297
+ const [grown, setGrown] = (0, react.useState)(false);
5298
+ (0, react.useEffect)(() => {
5299
+ const frame = requestAnimationFrame(() => setGrown(true));
5300
+ return () => cancelAnimationFrame(frame);
5301
+ }, []);
5302
+ const [clock, setClock] = (0, react.useState)(() => props.now);
5303
+ (0, react.useEffect)(() => {
5304
+ if (shortReset === null) return void 0;
5305
+ setClock(Date.now());
5306
+ const timer = window.setInterval(() => setClock(Date.now()), 3e4);
5307
+ return () => window.clearInterval(timer);
5308
+ }, [shortReset]);
5309
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5310
+ className: "dsha-kq",
5311
+ children: [
5312
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5313
+ className: "dsha-kq-head",
5314
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5315
+ className: "dsha-kq-tier",
5316
+ children: planName || t.planUnknown
5317
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
5318
+ className: "dsha-kq-staff",
5319
+ "aria-hidden": "true",
5320
+ children: [
5321
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {}),
5322
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {}),
5323
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {}),
5324
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {}),
5325
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {}),
5326
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
5327
+ className: "dsha-kq-art",
5328
+ xmlns: "http://www.w3.org/2000/svg",
5329
+ width: "120",
5330
+ height: "64",
5331
+ fill: "none",
5332
+ children: art.map((stroke, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
5333
+ fill: "currentColor",
5334
+ ...stroke.opacity === void 0 ? {} : { fillOpacity: stroke.opacity },
5335
+ style: { "--i": index },
5336
+ d: stroke.d
5337
+ }, index))
5338
+ })
5339
+ ]
5340
+ })]
5341
+ }),
5342
+ carrier === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5343
+ className: "dsha-muted dsha-kq-blank",
5344
+ children: t.quotaNone
5345
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5346
+ className: "dsha-kq-total",
5347
+ children: [
5348
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5349
+ className: "dsha-kq-row",
5350
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5351
+ className: "dsha-kq-label",
5352
+ children: headline
5353
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5354
+ className: "dsha-kq-value",
5355
+ children: percentText$2(totalPercent)
5356
+ })]
5357
+ }),
5358
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5359
+ className: "dsha-kq-barwrap",
5360
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5361
+ className: "dsha-kq-meter dsha-kq-meter--total",
5362
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5363
+ className: "dsha-kq-seg dsha-kq-seg--recent",
5364
+ "data-target": Math.max(0, Math.min(100, recentPercent)),
5365
+ style: { width: `${grown ? Math.max(0, Math.min(100, recentPercent)) : 0}%` }
5366
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5367
+ className: "dsha-kq-seg dsha-kq-seg--rest",
5368
+ "data-target": Math.max(0, Math.min(100, restPercent)),
5369
+ style: { width: `${grown ? Math.max(0, Math.min(100, restPercent)) : 0}%` }
5370
+ })]
5371
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5372
+ className: "dsha-kq-tip",
5373
+ role: "tooltip",
5374
+ children: t.kqTip.replace("{pct}", percentText$2(totalPercent))
5375
+ })]
5376
+ }),
5377
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5378
+ className: "dsha-kq-legend",
5379
+ children: [
5380
+ shortWindow !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
5381
+ className: "dsha-kq-legend-item",
5382
+ children: [
5383
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", { className: "dsha-kq-dot dsha-kq-dot--recent" }),
5384
+ t.kqShortWindow.replace("{pct}", percentText$2(used(shortWindow))),
5385
+ shortReset !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5386
+ className: "dsha-kq-legend-note",
5387
+ children: shortReset > clock ? t.kqResetIn.replace("{time}", durationText(t, shortReset - clock)) : t.kqResetSoon
5388
+ })
5389
+ ]
5390
+ }),
5391
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
5392
+ className: "dsha-kq-legend-item",
5393
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", { className: "dsha-kq-dot dsha-kq-dot--rest" }), t.kqRestUsed]
5394
+ }),
5395
+ resetAt !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5396
+ className: "dsha-kq-reset",
5397
+ children: t.kqResetAfter.replace("{time}", clockText(resetAt))
5398
+ })
5399
+ ]
5400
+ })
5401
+ ]
5402
+ }),
5403
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5404
+ className: "dsha-kq-foot",
5405
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
5406
+ className: "dsha-kq-foot-left",
5407
+ children: [lastUsed !== void 0 && Number.isFinite(lastUsed) && lastUsed > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t.kqLastUsed.replace("{time}", clockText(lastUsed)) }), quota !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t.kqAgo.replace("{time}", agoLabel(t, quota.fetchedAt, props.now)) })]
5408
+ }), expires !== void 0 && Number.isFinite(expires) && expires > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5409
+ className: "dsha-kq-expires",
5410
+ children: t.kqExpires.replace("{time}", dateText(expires))
5411
+ })]
5412
+ })
5413
+ ]
5414
+ });
5415
+ }
5416
+ //#endregion
5085
5417
  //#region src/client/kimi-code/KimiCodeSection.tsx
5086
5418
  const api$12 = createLineApi("/kimi-code/api", "Kimi Code");
5087
5419
  /** Money the service reports in minor units, rendered in its own currency. */
@@ -5464,15 +5796,16 @@ window.__ModuleLoader__.load({
5464
5796
  onRelogin: (accountId) => handleRelogin(accountId),
5465
5797
  onSetStrategy: (strategy) => void handleSetStrategy(strategy),
5466
5798
  showQuota: true,
5467
- renderDetails: (entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [entry.planName && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
5468
- t.plan,
5469
- ": ",
5470
- entry.planName
5471
- ] }), entry.region && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
5472
- t.region,
5473
- ": ",
5474
- entry.region === "global" ? t.regionGlobal : t.regionMainland
5475
- ] })] }),
5799
+ accountCardClassName: "dsha-account-card--kimi",
5800
+ omitDetails: ["lastUsed", "expires"],
5801
+ renderQuota: (entry, _index, now) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(KimiQuotaCard, {
5802
+ quota: entry.quota,
5803
+ planName: entry.planName ?? entry.planLabel ?? quota?.planName ?? status?.account?.planName ?? null,
5804
+ lastUsedAt: entry.lastUsedAt,
5805
+ expiresAt: entry.expiresAt,
5806
+ now,
5807
+ labels: t
5808
+ }),
5476
5809
  children: loginPending && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5477
5810
  className: "dsha-device-box",
5478
5811
  children: [
@@ -20261,6 +20594,30 @@ window.__ModuleLoader__.load({
20261
20594
  quotaWalletUsed: "Израсходовано за месяц",
20262
20595
  updatedAt: "Обновлено: {time}",
20263
20596
  resetAt: "Сброс: {time}",
20597
+ kqTotal: "Всего использовано",
20598
+ kqTip: "Расход Kimi Code {pct}",
20599
+ kqPoolKimi: "Kimi",
20600
+ kqPoolCode: "Code",
20601
+ kqResetAfter: "сброс {time}",
20602
+ kqAccount: "Аккаунт {n}",
20603
+ kqAgo: "обновлено {time}",
20604
+ kqLastUsed: "последний вызов {time}",
20605
+ kqShortWindow: "окно 5 часов {pct}",
20606
+ kqRestUsed: "остальной расход",
20607
+ kqExpires: "токен истекает {time}",
20608
+ kqJustNow: "только что",
20609
+ kqMinutesAgo: "{n} мин назад",
20610
+ kqHoursAgo: "{n} ч назад",
20611
+ kqDaysAgo: "{n} дн назад",
20612
+ kqWindow5h: "окно 5 часов",
20613
+ kqWindow7d: "за 7 дней",
20614
+ kqDurationDay: "{n} д",
20615
+ kqDurationHour: "{n} ч",
20616
+ kqDurationMinute: "{n} мин",
20617
+ kqResetIn: "сброс через {time}",
20618
+ kqResetSoon: "скоро сброс",
20619
+ kqRegionMainland: "Китай",
20620
+ kqRegionGlobal: "Глобальный",
20264
20621
  loading: "Загрузка…",
20265
20622
  loginFailed: "Вход не выполнен",
20266
20623
  requests: "запросов",
@@ -21859,6 +22216,54 @@ window.__ModuleLoader__.load({
21859
22216
  .dsha-cap-cost{color:var(--dsw-alias-label-primary);display:block;font-weight:500;margin-bottom:3px}
21860
22217
  .dsha-cap-footnote{font-size:11px;line-height:1.55;margin:8px 0 0}
21861
22218
  .dsha-warn{border:0.5px solid var(--dsw-alias-border-l2);border-radius:6px;line-height:1.55;margin:0 0 10px;padding:8px 10px}
22219
+
22220
+ /* ---------- Kimi Code 账号卡片里的额度区(KimiQuotaCard) ----------
22221
+ 档位名用 Georgia 字标,右侧压一条五线谱;音符按档位换插图,悬停时逐笔浮入。
22222
+ 总使用量是 Kimi 池与 Code 池的堆叠条,5 小时与 7 天各一条单行进度。 */
22223
+ /* ---------- 卡面:圆角、细边与顶部一道极淡的高光 ----------
22224
+ 形状与层次照搬 index.html 里那张卡;颜色仍走 dsw 令牌,浅色主题下同一套规则也成立。 */
22225
+ .dsha-account-card.dsha-account-card--kimi{border-radius:14px;border-width:1px;background-image:linear-gradient(180deg,color-mix(in srgb,var(--dsw-alias-label-primary) 4%,transparent),transparent 46%);transition:border-color .3s ease,box-shadow .3s ease}
22226
+ .dsha-account-card.dsha-account-card--kimi:hover{border-color:color-mix(in srgb,var(--dsw-alias-label-primary) 22%,var(--dsw-alias-border-l2));box-shadow:0 8px 24px rgba(0,0,0,.16)}
22227
+
22228
+ .dsha-kq{--kq-fg:var(--dsw-alias-label-primary);--kq-fg-2:var(--dsw-alias-label-secondary);--kq-fg-3:var(--dsw-alias-label-tertiary);--kq-line:var(--dsw-alias-border-l2);--kq-track:color-mix(in srgb,var(--dsw-alias-label-primary) 9%,transparent);--kq-rest:var(--dsw-alias-label-primary,#1a1a19);--kq-code:var(--dsw-alias-button-info-fill,#397ee8);--kq-tip-bg:var(--dsw-alias-label-primary,#2f2f2d);color:var(--kq-fg);display:flex;flex-direction:column;min-width:0}
22229
+ .dsha-kq-head{align-items:center;display:flex;gap:6px}
22230
+ .dsha-kq-tier{font-family:Georgia,"Times New Roman",serif;font-size:24px;font-weight:400;letter-spacing:-1.4px;line-height:1.4;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
22231
+ .dsha-kq-staff{display:flex;flex:1;flex-direction:column;gap:4px;height:21px;margin-right:-6px;min-width:48px;position:relative}
22232
+ .dsha-kq-staff>i{background:var(--kq-line);display:block;height:1px;width:100%}
22233
+ .dsha-kq-art{overflow:visible;position:absolute;right:6px;top:50%;transform:translateY(-50%)}
22234
+ .dsha-kq-art path{opacity:0;transform:scale(.8) translateY(16px);transform-origin:bottom;transition:opacity .2s ease-in-out,transform .2s ease-in-out}
22235
+ .dsha-account-card:hover .dsha-kq-art path,.dsha-kq:focus-within .dsha-kq-art path{opacity:1;transform:scale(1) translateY(0);transition:opacity .6s ease-in-out,transform .6s ease-in-out;transition-delay:calc(var(--i,0) * 80ms)}
22236
+ .dsha-kq-total{margin-top:14px}
22237
+ .dsha-kq-row{align-items:baseline;column-gap:10px;display:flex;flex-wrap:wrap;min-width:0;row-gap:2px}
22238
+ .dsha-kq-label{color:var(--kq-fg);font-size:14px;white-space:nowrap}
22239
+ .dsha-kq-value{color:var(--kq-fg);font-size:14px;font-variant-numeric:tabular-nums;white-space:nowrap}
22240
+ .dsha-kq-barwrap{margin-top:11px;position:relative}
22241
+ .dsha-kq-meter{background:var(--kq-track);border-radius:999px;display:flex;gap:2px;height:8px;overflow:hidden}
22242
+ .dsha-kq-meter--total{border-radius:4px;height:12px}
22243
+ .dsha-kq-meter--total .dsha-kq-seg{border-radius:2px}
22244
+ .dsha-kq-seg{border-radius:999px;display:block;height:100%;transition:width .9s cubic-bezier(.22,.61,.36,1)}
22245
+ .dsha-kq-seg--recent{background:var(--kq-code)}
22246
+ .dsha-kq-seg--rest{background:var(--kq-rest)}
22247
+ .dsha-kq-tip{background:var(--kq-tip-bg);border-radius:10px;bottom:calc(100% + 10px);color:var(--dsw-alias-bg-base,#fff);font-size:13px;line-height:1;opacity:0;padding:9px 14px;pointer-events:none;position:absolute;right:0;transform:translateY(4px);transition:opacity .16s ease-out,transform .16s ease-out;white-space:nowrap}
22248
+ .dsha-kq-tip::after{border:6px solid transparent;border-top-color:var(--kq-tip-bg);content:"";position:absolute;right:34px;top:100%}
22249
+ .dsha-kq-barwrap:hover .dsha-kq-tip{opacity:1;transform:translateY(0)}
22250
+ .dsha-kq-legend{align-items:center;color:var(--kq-fg-2);column-gap:16px;display:flex;flex-wrap:wrap;font-size:13px;margin-top:11px;row-gap:6px}
22251
+ .dsha-kq-legend-item{align-items:center;display:inline-flex;gap:6px;white-space:nowrap}
22252
+ .dsha-kq-legend-note{color:var(--kq-fg-3);white-space:nowrap}
22253
+ .dsha-kq-dot{border-radius:2px;display:block;height:8px;width:8px}
22254
+ .dsha-kq-dot--recent{background:var(--kq-code)}
22255
+ .dsha-kq-dot--rest{background:var(--kq-rest)}
22256
+ .dsha-kq-reset{color:var(--kq-fg-3);font-size:12px;font-variant-numeric:tabular-nums;margin-left:auto;white-space:nowrap}
22257
+ .dsha-kq-sep{border:0;border-top:0.5px solid var(--kq-line);height:0;margin:16px 0}
22258
+ .dsha-kq-window+.dsha-kq-window{margin-top:16px}
22259
+ .dsha-kq-window-label{color:var(--kq-fg);font-size:14px}
22260
+ .dsha-kq-window-pct{color:var(--kq-fg);font-size:14px;font-variant-numeric:tabular-nums}
22261
+ .dsha-kq-window .dsha-kq-meter{margin-top:8px}
22262
+ .dsha-kq-foot{align-items:baseline;color:var(--kq-fg-3);column-gap:12px;display:flex;flex-wrap:wrap;font-size:11px;font-variant-numeric:tabular-nums;justify-content:space-between;margin-top:14px;row-gap:4px}
22263
+ .dsha-kq-foot-left{align-items:baseline;column-gap:10px;display:inline-flex;flex-wrap:wrap;min-width:0;row-gap:2px}
22264
+ .dsha-kq-foot-left>span{white-space:nowrap}
22265
+ .dsha-kq-expires{text-align:right;white-space:nowrap}
22266
+ .dsha-kq-blank{margin:12px 0 0}
21862
22267
  `;
21863
22268
  /** Kimi-specific rules layered on top of the shared control styles. */
21864
22269
  function installKimiCodeStyles() {