@laoyuehanni/dsh-token-usage 0.3.7

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 (215) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +178 -0
  3. package/README.zh.md +182 -0
  4. package/cordis.patch.yml +7 -0
  5. package/lib/client/CostDeltaFlyLabel.d.ts +8 -0
  6. package/lib/client/CostDeltaFlyLabel.d.ts.map +1 -0
  7. package/lib/client/CostDeltaFlyLabel.js +24 -0
  8. package/lib/client/CostDeltaFlyLabel.js.map +1 -0
  9. package/lib/client/HitRateText.d.ts +21 -0
  10. package/lib/client/HitRateText.d.ts.map +1 -0
  11. package/lib/client/HitRateText.js +16 -0
  12. package/lib/client/HitRateText.js.map +1 -0
  13. package/lib/client/QuotaButton.d.ts +70 -0
  14. package/lib/client/QuotaButton.d.ts.map +1 -0
  15. package/lib/client/QuotaButton.js +346 -0
  16. package/lib/client/QuotaButton.js.map +1 -0
  17. package/lib/client/SessionStatsChip.d.ts +47 -0
  18. package/lib/client/SessionStatsChip.d.ts.map +1 -0
  19. package/lib/client/SessionStatsChip.js +141 -0
  20. package/lib/client/SessionStatsChip.js.map +1 -0
  21. package/lib/client/StatCard.d.ts +26 -0
  22. package/lib/client/StatCard.d.ts.map +1 -0
  23. package/lib/client/StatCard.js +10 -0
  24. package/lib/client/StatCard.js.map +1 -0
  25. package/lib/client/TokenUsageCard.d.ts +41 -0
  26. package/lib/client/TokenUsageCard.d.ts.map +1 -0
  27. package/lib/client/TokenUsageCard.js +164 -0
  28. package/lib/client/TokenUsageCard.js.map +1 -0
  29. package/lib/client/TokenUsageSection.d.ts +32 -0
  30. package/lib/client/TokenUsageSection.d.ts.map +1 -0
  31. package/lib/client/TokenUsageSection.js +266 -0
  32. package/lib/client/TokenUsageSection.js.map +1 -0
  33. package/lib/client/TrendChart.d.ts +53 -0
  34. package/lib/client/TrendChart.d.ts.map +1 -0
  35. package/lib/client/TrendChart.js +141 -0
  36. package/lib/client/TrendChart.js.map +1 -0
  37. package/lib/client/UsageView.d.ts +42 -0
  38. package/lib/client/UsageView.d.ts.map +1 -0
  39. package/lib/client/UsageView.js +158 -0
  40. package/lib/client/UsageView.js.map +1 -0
  41. package/lib/client/async-resource.d.ts +54 -0
  42. package/lib/client/async-resource.d.ts.map +1 -0
  43. package/lib/client/async-resource.js +90 -0
  44. package/lib/client/async-resource.js.map +1 -0
  45. package/lib/client/card-form.d.ts +171 -0
  46. package/lib/client/card-form.d.ts.map +1 -0
  47. package/lib/client/card-form.js +300 -0
  48. package/lib/client/card-form.js.map +1 -0
  49. package/lib/client/cost-inflate-motion.d.ts +17 -0
  50. package/lib/client/cost-inflate-motion.d.ts.map +1 -0
  51. package/lib/client/cost-inflate-motion.js +61 -0
  52. package/lib/client/cost-inflate-motion.js.map +1 -0
  53. package/lib/client/cost-inflate.d.ts +28 -0
  54. package/lib/client/cost-inflate.d.ts.map +1 -0
  55. package/lib/client/cost-inflate.js +49 -0
  56. package/lib/client/cost-inflate.js.map +1 -0
  57. package/lib/client/day.d.ts +49 -0
  58. package/lib/client/day.d.ts.map +1 -0
  59. package/lib/client/day.js +84 -0
  60. package/lib/client/day.js.map +1 -0
  61. package/lib/client/format.d.ts +120 -0
  62. package/lib/client/format.d.ts.map +1 -0
  63. package/lib/client/format.js +163 -0
  64. package/lib/client/format.js.map +1 -0
  65. package/lib/client/index.d.ts +26 -0
  66. package/lib/client/index.d.ts.map +1 -0
  67. package/lib/client/index.js +131 -0
  68. package/lib/client/index.js.map +1 -0
  69. package/lib/client/locales.d.ts +131 -0
  70. package/lib/client/locales.d.ts.map +1 -0
  71. package/lib/client/locales.js +230 -0
  72. package/lib/client/locales.js.map +1 -0
  73. package/lib/client/quota-format.d.ts +69 -0
  74. package/lib/client/quota-format.d.ts.map +1 -0
  75. package/lib/client/quota-format.js +147 -0
  76. package/lib/client/quota-format.js.map +1 -0
  77. package/lib/client/session-stats.d.ts +105 -0
  78. package/lib/client/session-stats.d.ts.map +1 -0
  79. package/lib/client/session-stats.js +142 -0
  80. package/lib/client/session-stats.js.map +1 -0
  81. package/lib/client/trend-chart/axis.d.ts +21 -0
  82. package/lib/client/trend-chart/axis.d.ts.map +1 -0
  83. package/lib/client/trend-chart/axis.js +33 -0
  84. package/lib/client/trend-chart/axis.js.map +1 -0
  85. package/lib/client/trend-chart/bucket.d.ts +24 -0
  86. package/lib/client/trend-chart/bucket.d.ts.map +1 -0
  87. package/lib/client/trend-chart/bucket.js +28 -0
  88. package/lib/client/trend-chart/bucket.js.map +1 -0
  89. package/lib/client/trend-chart/index.d.ts +12 -0
  90. package/lib/client/trend-chart/index.d.ts.map +1 -0
  91. package/lib/client/trend-chart/index.js +9 -0
  92. package/lib/client/trend-chart/index.js.map +1 -0
  93. package/lib/client/trend-chart/points.d.ts +46 -0
  94. package/lib/client/trend-chart/points.d.ts.map +1 -0
  95. package/lib/client/trend-chart/points.js +82 -0
  96. package/lib/client/trend-chart/points.js.map +1 -0
  97. package/lib/client/trend-chart/scale.d.ts +47 -0
  98. package/lib/client/trend-chart/scale.d.ts.map +1 -0
  99. package/lib/client/trend-chart/scale.js +75 -0
  100. package/lib/client/trend-chart/scale.js.map +1 -0
  101. package/lib/client/use-color-scheme.d.ts +18 -0
  102. package/lib/client/use-color-scheme.d.ts.map +1 -0
  103. package/lib/client/use-color-scheme.js +37 -0
  104. package/lib/client/use-color-scheme.js.map +1 -0
  105. package/lib/client/use-cost-inflate.d.ts +33 -0
  106. package/lib/client/use-cost-inflate.d.ts.map +1 -0
  107. package/lib/client/use-cost-inflate.js +108 -0
  108. package/lib/client/use-cost-inflate.js.map +1 -0
  109. package/lib/client.js +3892 -0
  110. package/lib/client.js.map +1 -0
  111. package/lib/index.d.ts +132 -0
  112. package/lib/index.d.ts.map +1 -0
  113. package/lib/index.js +599 -0
  114. package/lib/index.js.map +1 -0
  115. package/lib/migrate.d.ts +60 -0
  116. package/lib/migrate.d.ts.map +1 -0
  117. package/lib/migrate.js +126 -0
  118. package/lib/migrate.js.map +1 -0
  119. package/lib/pricing.d.ts +212 -0
  120. package/lib/pricing.d.ts.map +1 -0
  121. package/lib/pricing.js +492 -0
  122. package/lib/pricing.js.map +1 -0
  123. package/lib/quota/adapters/deepseek-balance.d.ts +18 -0
  124. package/lib/quota/adapters/deepseek-balance.d.ts.map +1 -0
  125. package/lib/quota/adapters/deepseek-balance.js +76 -0
  126. package/lib/quota/adapters/deepseek-balance.js.map +1 -0
  127. package/lib/quota/adapters/kimi.d.ts +26 -0
  128. package/lib/quota/adapters/kimi.d.ts.map +1 -0
  129. package/lib/quota/adapters/kimi.js +91 -0
  130. package/lib/quota/adapters/kimi.js.map +1 -0
  131. package/lib/quota/adapters/minimax.d.ts +24 -0
  132. package/lib/quota/adapters/minimax.d.ts.map +1 -0
  133. package/lib/quota/adapters/minimax.js +136 -0
  134. package/lib/quota/adapters/minimax.js.map +1 -0
  135. package/lib/quota/adapters/opencode-go.d.ts +25 -0
  136. package/lib/quota/adapters/opencode-go.d.ts.map +1 -0
  137. package/lib/quota/adapters/opencode-go.js +105 -0
  138. package/lib/quota/adapters/opencode-go.js.map +1 -0
  139. package/lib/quota/adapters/openrouter.d.ts +15 -0
  140. package/lib/quota/adapters/openrouter.d.ts.map +1 -0
  141. package/lib/quota/adapters/openrouter.js +54 -0
  142. package/lib/quota/adapters/openrouter.js.map +1 -0
  143. package/lib/quota/adapters/zhipu.d.ts +38 -0
  144. package/lib/quota/adapters/zhipu.d.ts.map +1 -0
  145. package/lib/quota/adapters/zhipu.js +246 -0
  146. package/lib/quota/adapters/zhipu.js.map +1 -0
  147. package/lib/quota/credentials.d.ts +79 -0
  148. package/lib/quota/credentials.d.ts.map +1 -0
  149. package/lib/quota/credentials.js +130 -0
  150. package/lib/quota/credentials.js.map +1 -0
  151. package/lib/quota/http.d.ts +49 -0
  152. package/lib/quota/http.d.ts.map +1 -0
  153. package/lib/quota/http.js +114 -0
  154. package/lib/quota/http.js.map +1 -0
  155. package/lib/quota/provider-tracking.d.ts +45 -0
  156. package/lib/quota/provider-tracking.d.ts.map +1 -0
  157. package/lib/quota/provider-tracking.js +52 -0
  158. package/lib/quota/provider-tracking.js.map +1 -0
  159. package/lib/quota/quota-route.d.ts +22 -0
  160. package/lib/quota/quota-route.d.ts.map +1 -0
  161. package/lib/quota/quota-route.js +57 -0
  162. package/lib/quota/quota-route.js.map +1 -0
  163. package/lib/quota/quota-service.d.ts +54 -0
  164. package/lib/quota/quota-service.d.ts.map +1 -0
  165. package/lib/quota/quota-service.js +171 -0
  166. package/lib/quota/quota-service.js.map +1 -0
  167. package/lib/quota/registry.d.ts +24 -0
  168. package/lib/quota/registry.d.ts.map +1 -0
  169. package/lib/quota/registry.js +38 -0
  170. package/lib/quota/registry.js.map +1 -0
  171. package/lib/quota/types.d.ts +79 -0
  172. package/lib/quota/types.d.ts.map +1 -0
  173. package/lib/quota/types.js +24 -0
  174. package/lib/quota/types.js.map +1 -0
  175. package/lib/record-cache.d.ts +38 -0
  176. package/lib/record-cache.d.ts.map +1 -0
  177. package/lib/record-cache.js +143 -0
  178. package/lib/record-cache.js.map +1 -0
  179. package/lib/rollup.d.ts +52 -0
  180. package/lib/rollup.d.ts.map +1 -0
  181. package/lib/rollup.js +117 -0
  182. package/lib/rollup.js.map +1 -0
  183. package/lib/stats-route.d.ts +88 -0
  184. package/lib/stats-route.d.ts.map +1 -0
  185. package/lib/stats-route.js +313 -0
  186. package/lib/stats-route.js.map +1 -0
  187. package/lib/stats.d.ts +158 -0
  188. package/lib/stats.d.ts.map +1 -0
  189. package/lib/stats.js +426 -0
  190. package/lib/stats.js.map +1 -0
  191. package/lib/sync-state.d.ts +27 -0
  192. package/lib/sync-state.d.ts.map +1 -0
  193. package/lib/sync-state.js +56 -0
  194. package/lib/sync-state.js.map +1 -0
  195. package/lib/sync.d.ts +74 -0
  196. package/lib/sync.d.ts.map +1 -0
  197. package/lib/sync.js +64 -0
  198. package/lib/sync.js.map +1 -0
  199. package/lib/trend-bucket.d.ts +48 -0
  200. package/lib/trend-bucket.d.ts.map +1 -0
  201. package/lib/trend-bucket.js +87 -0
  202. package/lib/trend-bucket.js.map +1 -0
  203. package/lib/usage-log.d.ts +64 -0
  204. package/lib/usage-log.d.ts.map +1 -0
  205. package/lib/usage-log.js +144 -0
  206. package/lib/usage-log.js.map +1 -0
  207. package/lib/usage-record.d.ts +59 -0
  208. package/lib/usage-record.d.ts.map +1 -0
  209. package/lib/usage-record.js +115 -0
  210. package/lib/usage-record.js.map +1 -0
  211. package/lib/wire.d.ts +452 -0
  212. package/lib/wire.d.ts.map +1 -0
  213. package/lib/wire.js +144 -0
  214. package/lib/wire.js.map +1 -0
  215. package/package.json +100 -0
@@ -0,0 +1,131 @@
1
+ /**
2
+ * `token-usage` locale namespace dictionaries (browser half). zh is the
3
+ * key-set source of truth; en is checked complete against it — the typed
4
+ * `ctx.locale.register(NS, { zh, en })` call enforces both at compile time
5
+ * and the `t` standard seat narrows its key domain to this union plus the
6
+ * shared common vocabulary.
7
+ *
8
+ * @module token-usage/client/locales
9
+ */
10
+ /** Dictionary namespace owned by this plugin. */
11
+ export declare const NS = "token-usage";
12
+ /** Simplified Chinese dictionary (the key-set source of truth). */
13
+ export declare const zh: {
14
+ readonly 'nav.label': "Token 用量";
15
+ readonly 'filter.quickRange': "快捷区间";
16
+ readonly 'filter.custom': "自定义";
17
+ readonly 'filter.from': "开始日期";
18
+ readonly 'filter.to': "结束日期";
19
+ readonly 'filter.separator': "至";
20
+ readonly 'filter.model': "模型";
21
+ readonly 'filter.allModels': "全部模型";
22
+ readonly 'stat.requests': "请求数";
23
+ readonly 'stat.totalTokens': "总 token";
24
+ readonly 'stat.hitRate': "命中率";
25
+ readonly 'stat.cost': "费用";
26
+ readonly 'stat.input': "入";
27
+ readonly 'stat.output': "出";
28
+ readonly 'stat.cacheRead': "缓";
29
+ readonly 'stat.cacheWrite': "写";
30
+ readonly 'byModel.title': "按模型";
31
+ readonly 'pricing.title': "模型定价";
32
+ readonly 'pricing.view': "查看 {model} 定价";
33
+ readonly 'pricing.viewShort': "定价";
34
+ readonly 'pricing.close': "关闭";
35
+ readonly 'pricing.condition': "计费条件";
36
+ readonly 'pricing.default': "默认";
37
+ readonly 'pricing.regular': "常规(规则期外)";
38
+ readonly 'pricing.tier': "上下文 ≥{threshold}";
39
+ readonly 'pricing.peak': "峰时";
40
+ readonly 'pricing.input': "入";
41
+ readonly 'pricing.output': "出";
42
+ readonly 'pricing.cacheRead': "缓";
43
+ readonly 'pricing.cacheWrite': "写";
44
+ readonly 'pricing.perMillion': "/M";
45
+ readonly 'pricing.exchangeRateNote': "按 1 USD = {rate} CNY 换算";
46
+ readonly 'pricing.unpriced': "未定价";
47
+ readonly 'pricing.windowSep': "、";
48
+ readonly 'unpriced.warning': "{count} 个模型未定价:{models}(费用按 {zero} 计)";
49
+ readonly dataDir: "数据目录:{path}";
50
+ readonly 'card.title': "Token 用量";
51
+ readonly 'card.description': "数据目录与定价数据源";
52
+ readonly 'card.expand': "展开";
53
+ readonly 'card.collapse': "折叠";
54
+ readonly 'card.unsaved': "未保存";
55
+ readonly 'card.readOnly': "设置文档当前为只读,本次无法修改。";
56
+ readonly 'card.pathLabel': "数据目录";
57
+ readonly 'card.pathHint': "留空使用默认位置(~/.dsh/token-usage)。";
58
+ readonly 'card.browse': "浏览…";
59
+ readonly 'card.picking': "选择中…";
60
+ readonly 'card.migratingCopy': "正在复制数据 {done}/{total} 个文件…";
61
+ readonly 'card.migratingClean': "正在清理旧目录 {done}/{total} 个文件…";
62
+ readonly 'card.regionLabel': "定价区域";
63
+ readonly 'card.regionDefault': "默认(国内 Gitee)";
64
+ readonly 'card.region.domestic': "国内(Gitee)";
65
+ readonly 'card.region.overseas': "全球(GitHub)";
66
+ readonly 'card.hint': "切换到「全球」后从 GitHub 镜像拉取定价表,费用按美元展示(RMB ÷ 汇率);保存后立即重新同步,失败沿用旧镜像。";
67
+ readonly 'card.overridden': "已覆盖默认值";
68
+ readonly 'card.save': "保存";
69
+ readonly 'card.saving': "保存中…";
70
+ readonly 'card.saveFailed': "保存未生效,请重试。";
71
+ readonly 'card.saveBlockedSessions': "有会话正在进行对话,无法保存目录修改;请等待对话结束(当前 {count} 个)。";
72
+ readonly 'card.discard': "放弃";
73
+ readonly 'card.fullSync.title': "全量扫描同步";
74
+ readonly 'card.fullSync.hint': "手动扫一遍所有 session 日志,把可能漏掉的历史请求补进来(已记录的会跳过)。";
75
+ readonly 'card.fullSync.button': "开始扫描";
76
+ readonly 'card.fullSync.running': "扫描中…";
77
+ readonly 'card.fullSync.progress': "已处理 {processed}/{total} 个 session,新增 {added} 条,跳过 {skipped} 条";
78
+ readonly 'card.fullSync.done': "扫描完成:新增 {added} 条,跳过 {skipped} 条";
79
+ readonly 'card.fullSync.failed': "扫描失败:{error}";
80
+ readonly loadFailed: "统计加载失败:{message}";
81
+ readonly empty: "暂无数据。可调整筛选条件;模型请求成功后会自动写入,安装前已发生的历史记录会在首次启动时自动补齐。";
82
+ readonly 'chart.empty': "区间内暂无数据";
83
+ readonly 'chart.aria': "每日总 token 曲线";
84
+ readonly 'chart.ariaHour': "单日分时 token 曲线";
85
+ readonly 'chart.ariaRequests': "按时间分段的 token 曲线";
86
+ readonly 'chart.pointLabel': "{day} 总量 {tokens}";
87
+ readonly 'chart.bucket': "{window} · {count} 请求 · {tokens}";
88
+ readonly 'view.usage': "用量";
89
+ readonly 'view.scope.label': "统计范围";
90
+ readonly 'view.scope.session': "本会话";
91
+ readonly 'view.scope.tree': "含子会话";
92
+ readonly 'view.back': "← 返回 {title}";
93
+ readonly 'view.ttft': "平均首token";
94
+ readonly 'view.speed': "token速度";
95
+ readonly 'view.empty': "该会话暂无用量记录。";
96
+ readonly 'view.chart.title': "趋势";
97
+ readonly 'view.subagents.title': "子会话({count})";
98
+ readonly 'view.subagents.none': "无子会话";
99
+ readonly 'view.subagents.titleCol': "会话";
100
+ readonly 'view.subagents.nested': "含 {count} 个子会话";
101
+ readonly 'view.note': "注:token 与费用来自本插件的请求记录(安装后);平均首token 与 token速度来自 DSH 会话投影(含安装前历史)。";
102
+ readonly 'chip.tokens': "含子会话 token 用量 {value}";
103
+ readonly 'chip.hitRate': "含子会话缓存命中率 {value}";
104
+ readonly 'chip.cost': "含子会话费用 {value}";
105
+ readonly 'quota.trigger': "供应商配额";
106
+ readonly 'quota.triggerSummary': "{name} · {figure}";
107
+ readonly 'quota.panel': "供应商配额面板";
108
+ readonly 'quota.tier.fiveHour': "5 小时";
109
+ readonly 'quota.tier.weekly': "每周";
110
+ readonly 'quota.tier.monthly': "每月";
111
+ readonly 'quota.tier.balance': "余额";
112
+ readonly 'quota.resetIn': "{time} 后重置";
113
+ readonly 'quota.updatedAt': "更新于 {time}";
114
+ readonly 'quota.retry': "重试";
115
+ readonly 'quota.error.auth': "鉴权失败({message});请检查该供应商的 API Key。";
116
+ readonly 'quota.error.noCredential': "未解析到 API Key({ref});请先在供应商设置中配置密钥。";
117
+ readonly 'quota.error.http': "供应商接口返回错误({message})。";
118
+ readonly 'quota.error.network': "网络错误({message})。";
119
+ readonly 'quota.error.parse': "响应解析失败({message})。";
120
+ };
121
+ /** English dictionary (same key set). */
122
+ export declare const en: Record<TokenUsageKey, string>;
123
+ /** Union of this namespace's dictionary keys. */
124
+ export type TokenUsageKey = keyof typeof zh;
125
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
126
+ interface LocaleNamespaceMap {
127
+ /** Copy of this plugin's settings nav label and stats page. */
128
+ 'token-usage': TokenUsageKey;
129
+ }
130
+ }
131
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../src/client/locales.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,iDAAiD;AACjD,eAAO,MAAM,EAAE,gBAAgB,CAAA;AAE/B,mEAAmE;AACnE,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2GL,CAAA;AAEV,yCAAyC;AACzC,eAAO,MAAM,EAAE,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CA2G5C,CAAA;AAED,iDAAiD;AACjD,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,EAAE,CAAA;AAE3C,OAAO,QAAQ,kCAAkC,CAAC;IAChD,UAAU,kBAAkB;QAC1B,+DAA+D;QAC/D,aAAa,EAAE,aAAa,CAAA;KAC7B;CACF"}
@@ -0,0 +1,230 @@
1
+ /**
2
+ * `token-usage` locale namespace dictionaries (browser half). zh is the
3
+ * key-set source of truth; en is checked complete against it — the typed
4
+ * `ctx.locale.register(NS, { zh, en })` call enforces both at compile time
5
+ * and the `t` standard seat narrows its key domain to this union plus the
6
+ * shared common vocabulary.
7
+ *
8
+ * @module token-usage/client/locales
9
+ */
10
+ /** Dictionary namespace owned by this plugin. */
11
+ export const NS = 'token-usage';
12
+ /** Simplified Chinese dictionary (the key-set source of truth). */
13
+ export const zh = {
14
+ 'nav.label': 'Token 用量',
15
+ 'filter.quickRange': '快捷区间',
16
+ 'filter.custom': '自定义',
17
+ 'filter.from': '开始日期',
18
+ 'filter.to': '结束日期',
19
+ 'filter.separator': '至',
20
+ 'filter.model': '模型',
21
+ 'filter.allModels': '全部模型',
22
+ 'stat.requests': '请求数',
23
+ 'stat.totalTokens': '总 token',
24
+ 'stat.hitRate': '命中率',
25
+ 'stat.cost': '费用',
26
+ 'stat.input': '入',
27
+ 'stat.output': '出',
28
+ 'stat.cacheRead': '缓',
29
+ 'stat.cacheWrite': '写',
30
+ 'byModel.title': '按模型',
31
+ 'pricing.title': '模型定价',
32
+ 'pricing.view': '查看 {model} 定价',
33
+ 'pricing.viewShort': '定价',
34
+ 'pricing.close': '关闭',
35
+ 'pricing.condition': '计费条件',
36
+ 'pricing.default': '默认',
37
+ 'pricing.regular': '常规(规则期外)',
38
+ 'pricing.tier': '上下文 ≥{threshold}',
39
+ 'pricing.peak': '峰时',
40
+ 'pricing.input': '入',
41
+ 'pricing.output': '出',
42
+ 'pricing.cacheRead': '缓',
43
+ 'pricing.cacheWrite': '写',
44
+ 'pricing.perMillion': '/M',
45
+ 'pricing.exchangeRateNote': '按 1 USD = {rate} CNY 换算',
46
+ 'pricing.unpriced': '未定价',
47
+ 'pricing.windowSep': '、',
48
+ 'unpriced.warning': '{count} 个模型未定价:{models}(费用按 {zero} 计)',
49
+ 'dataDir': '数据目录:{path}',
50
+ 'card.title': 'Token 用量',
51
+ 'card.description': '数据目录与定价数据源',
52
+ 'card.expand': '展开',
53
+ 'card.collapse': '折叠',
54
+ 'card.unsaved': '未保存',
55
+ 'card.readOnly': '设置文档当前为只读,本次无法修改。',
56
+ 'card.pathLabel': '数据目录',
57
+ 'card.pathHint': '留空使用默认位置(~/.dsh/token-usage)。',
58
+ 'card.browse': '浏览…',
59
+ 'card.picking': '选择中…',
60
+ 'card.migratingCopy': '正在复制数据 {done}/{total} 个文件…',
61
+ 'card.migratingClean': '正在清理旧目录 {done}/{total} 个文件…',
62
+ 'card.regionLabel': '定价区域',
63
+ 'card.regionDefault': '默认(国内 Gitee)',
64
+ 'card.region.domestic': '国内(Gitee)',
65
+ 'card.region.overseas': '全球(GitHub)',
66
+ 'card.hint': '切换到「全球」后从 GitHub 镜像拉取定价表,费用按美元展示(RMB ÷ 汇率);保存后立即重新同步,失败沿用旧镜像。',
67
+ 'card.overridden': '已覆盖默认值',
68
+ 'card.save': '保存',
69
+ 'card.saving': '保存中…',
70
+ 'card.saveFailed': '保存未生效,请重试。',
71
+ 'card.saveBlockedSessions': '有会话正在进行对话,无法保存目录修改;请等待对话结束(当前 {count} 个)。',
72
+ 'card.discard': '放弃',
73
+ 'card.fullSync.title': '全量扫描同步',
74
+ 'card.fullSync.hint': '手动扫一遍所有 session 日志,把可能漏掉的历史请求补进来(已记录的会跳过)。',
75
+ 'card.fullSync.button': '开始扫描',
76
+ 'card.fullSync.running': '扫描中…',
77
+ 'card.fullSync.progress': '已处理 {processed}/{total} 个 session,新增 {added} 条,跳过 {skipped} 条',
78
+ 'card.fullSync.done': '扫描完成:新增 {added} 条,跳过 {skipped} 条',
79
+ 'card.fullSync.failed': '扫描失败:{error}',
80
+ 'loadFailed': '统计加载失败:{message}',
81
+ 'empty': '暂无数据。可调整筛选条件;模型请求成功后会自动写入,安装前已发生的历史记录会在首次启动时自动补齐。',
82
+ 'chart.empty': '区间内暂无数据',
83
+ 'chart.aria': '每日总 token 曲线',
84
+ 'chart.ariaHour': '单日分时 token 曲线',
85
+ 'chart.ariaRequests': '按时间分段的 token 曲线',
86
+ 'chart.pointLabel': '{day} 总量 {tokens}',
87
+ 'chart.bucket': '{window} · {count} 请求 · {tokens}',
88
+ 'view.usage': '用量',
89
+ 'view.scope.label': '统计范围',
90
+ 'view.scope.session': '本会话',
91
+ 'view.scope.tree': '含子会话',
92
+ 'view.back': '← 返回 {title}',
93
+ 'view.ttft': '平均首token',
94
+ 'view.speed': 'token速度',
95
+ 'view.empty': '该会话暂无用量记录。',
96
+ 'view.chart.title': '趋势',
97
+ 'view.subagents.title': '子会话({count})',
98
+ 'view.subagents.none': '无子会话',
99
+ 'view.subagents.titleCol': '会话',
100
+ 'view.subagents.nested': '含 {count} 个子会话',
101
+ 'view.note': '注:token 与费用来自本插件的请求记录(安装后);平均首token 与 token速度来自 DSH 会话投影(含安装前历史)。',
102
+ 'chip.tokens': '含子会话 token 用量 {value}',
103
+ 'chip.hitRate': '含子会话缓存命中率 {value}',
104
+ 'chip.cost': '含子会话费用 {value}',
105
+ 'quota.trigger': '供应商配额',
106
+ 'quota.triggerSummary': '{name} · {figure}',
107
+ 'quota.panel': '供应商配额面板',
108
+ 'quota.tier.fiveHour': '5 小时',
109
+ 'quota.tier.weekly': '每周',
110
+ 'quota.tier.monthly': '每月',
111
+ 'quota.tier.balance': '余额',
112
+ 'quota.resetIn': '{time} 后重置',
113
+ 'quota.updatedAt': '更新于 {time}',
114
+ 'quota.retry': '重试',
115
+ 'quota.error.auth': '鉴权失败({message});请检查该供应商的 API Key。',
116
+ 'quota.error.noCredential': '未解析到 API Key({ref});请先在供应商设置中配置密钥。',
117
+ 'quota.error.http': '供应商接口返回错误({message})。',
118
+ 'quota.error.network': '网络错误({message})。',
119
+ 'quota.error.parse': '响应解析失败({message})。',
120
+ };
121
+ /** English dictionary (same key set). */
122
+ export const en = {
123
+ 'nav.label': 'Token Usage',
124
+ 'filter.quickRange': 'Quick range',
125
+ 'filter.custom': 'Custom',
126
+ 'filter.from': 'Start date',
127
+ 'filter.to': 'End date',
128
+ 'filter.separator': 'to',
129
+ 'filter.model': 'Model',
130
+ 'filter.allModels': 'All models',
131
+ 'stat.requests': 'Requests',
132
+ 'stat.totalTokens': 'Total',
133
+ 'stat.hitRate': 'Hit %',
134
+ 'stat.cost': 'Cost',
135
+ 'stat.input': 'In',
136
+ 'stat.output': 'Out',
137
+ 'stat.cacheRead': 'Cache',
138
+ 'stat.cacheWrite': 'Write',
139
+ 'byModel.title': 'By model',
140
+ 'pricing.title': 'Model pricing',
141
+ 'pricing.view': 'View rates for {model}',
142
+ 'pricing.viewShort': 'Rates',
143
+ 'pricing.close': 'Close',
144
+ 'pricing.condition': 'Condition',
145
+ 'pricing.default': 'Default',
146
+ 'pricing.regular': 'Regular (outside rule windows)',
147
+ 'pricing.tier': 'context ≥{threshold}',
148
+ 'pricing.peak': 'Peak',
149
+ 'pricing.input': 'In',
150
+ 'pricing.output': 'Out',
151
+ 'pricing.cacheRead': 'Cache',
152
+ 'pricing.cacheWrite': 'Write',
153
+ 'pricing.perMillion': '/M',
154
+ 'pricing.exchangeRateNote': 'Converted at 1 USD = {rate} CNY',
155
+ 'pricing.unpriced': 'Unpriced',
156
+ 'pricing.windowSep': ', ',
157
+ 'unpriced.warning': '{count} models unpriced: {models} (cost counts as {zero})',
158
+ 'dataDir': 'Data directory: {path}',
159
+ 'card.title': 'Token Usage',
160
+ 'card.description': 'Data directory and pricing source',
161
+ 'card.expand': 'Expand',
162
+ 'card.collapse': 'Collapse',
163
+ 'card.unsaved': 'Unsaved',
164
+ 'card.readOnly': 'The settings document is read-only right now; changes are disabled.',
165
+ 'card.pathLabel': 'Data directory',
166
+ 'card.pathHint': 'Leave empty for the default location (~/.dsh/token-usage).',
167
+ 'card.browse': 'Browse…',
168
+ 'card.picking': 'Picking…',
169
+ 'card.migratingCopy': 'Copying data {done}/{total} files…',
170
+ 'card.migratingClean': 'Cleaning the old directory {done}/{total} files…',
171
+ 'card.regionLabel': 'Pricing region',
172
+ 'card.regionDefault': 'Default (Gitee)',
173
+ 'card.region.domestic': 'CN (Gitee)',
174
+ 'card.region.overseas': 'Global (GitHub)',
175
+ 'card.hint': 'Switching to Global pulls the pricing table from the GitHub mirror and shows costs in USD (RMB ÷ rate); saving re-syncs immediately, falling back to the previous mirror on failure.',
176
+ 'card.overridden': 'Overriding the default',
177
+ 'card.save': 'Save',
178
+ 'card.saving': 'Saving…',
179
+ 'card.saveFailed': 'The save did not land; try again.',
180
+ 'card.saveBlockedSessions': 'A conversation is still in progress, so the directory change was not saved; wait for it to end first ({count} active).',
181
+ 'card.discard': 'Discard',
182
+ 'card.fullSync.title': 'Full scan sync',
183
+ 'card.fullSync.hint': 'Walk every session log once and fold any historical requests the log does not yet hold (rows already recorded are skipped).',
184
+ 'card.fullSync.button': 'Start scan',
185
+ 'card.fullSync.running': 'Scanning…',
186
+ 'card.fullSync.progress': 'Processed {processed}/{total} sessions, added {added}, skipped {skipped}',
187
+ 'card.fullSync.done': 'Scan complete: added {added}, skipped {skipped}',
188
+ 'card.fullSync.failed': 'Scan failed: {error}',
189
+ 'loadFailed': 'Failed to load stats: {message}',
190
+ 'empty': 'No data yet. Adjust the filters; requests are written automatically after each successful model call, and pre-install history is backfilled automatically on the first startup.',
191
+ 'chart.empty': 'No data in range',
192
+ 'chart.aria': 'Daily total token trend',
193
+ 'chart.ariaHour': 'Single-day hourly token trend',
194
+ 'chart.ariaRequests': 'Time-bucketed token trend',
195
+ 'chart.pointLabel': '{day} total {tokens}',
196
+ 'chart.bucket': '{window} · {count} requests · {tokens}',
197
+ 'view.usage': 'Usage',
198
+ 'view.scope.label': 'Scope',
199
+ 'view.scope.session': 'Session',
200
+ 'view.scope.tree': 'With subagents',
201
+ 'view.back': '← Back to {title}',
202
+ 'view.ttft': 'Avg TTFT',
203
+ 'view.speed': 'Token speed',
204
+ 'view.empty': 'No usage recorded for this session.',
205
+ 'view.chart.title': 'Trend',
206
+ 'view.subagents.title': 'Subagents ({count})',
207
+ 'view.subagents.none': 'No subagents',
208
+ 'view.subagents.titleCol': 'Session',
209
+ 'view.subagents.nested': 'With {count} subagents',
210
+ 'view.note': 'Note: tokens and cost come from this plugin\'s request log (post-install); average TTFT and token speed come from the DSH session projection (includes pre-install history).',
211
+ 'chip.tokens': 'Tokens with subagents {value}',
212
+ 'chip.hitRate': 'Cache hit rate with subagents {value}',
213
+ 'chip.cost': 'Cost with subagents {value}',
214
+ 'quota.trigger': 'Provider quota',
215
+ 'quota.triggerSummary': '{name} · {figure}',
216
+ 'quota.panel': 'Provider quota panel',
217
+ 'quota.tier.fiveHour': '5-hour',
218
+ 'quota.tier.weekly': 'Weekly',
219
+ 'quota.tier.monthly': 'Monthly',
220
+ 'quota.tier.balance': 'Balance',
221
+ 'quota.resetIn': 'resets in {time}',
222
+ 'quota.updatedAt': 'Updated {time}',
223
+ 'quota.retry': 'Retry',
224
+ 'quota.error.auth': 'Authentication failed ({message}); check this provider\'s API key.',
225
+ 'quota.error.noCredential': 'No API key resolved ({ref}); configure the provider\'s key first.',
226
+ 'quota.error.http': 'The provider endpoint returned an error ({message}).',
227
+ 'quota.error.network': 'Network error ({message}).',
228
+ 'quota.error.parse': 'Failed to parse the response ({message}).',
229
+ };
230
+ //# sourceMappingURL=locales.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locales.js","sourceRoot":"","sources":["../../src/client/locales.ts"],"names":[],"mappings":"AAAA;;;;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B,EAAE,sBAAsB;IAC1C,cAAc,EAAE,wCAAwC;IACxD,YAAY,EAAE,OAAO;IACrB,kBAAkB,EAAE,OAAO;IAC3B,oBAAoB,EAAE,SAAS;IAC/B,iBAAiB,EAAE,gBAAgB;IACnC,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,UAAU;IACvB,YAAY,EAAE,aAAa;IAC3B,YAAY,EAAE,qCAAqC;IACnD,kBAAkB,EAAE,OAAO;IAC3B,sBAAsB,EAAE,qBAAqB;IAC7C,qBAAqB,EAAE,cAAc;IACrC,yBAAyB,EAAE,SAAS;IACpC,uBAAuB,EAAE,wBAAwB;IACjD,WAAW,EAAE,8KAA8K;IAC3L,aAAa,EAAE,+BAA+B;IAC9C,cAAc,EAAE,uCAAuC;IACvD,WAAW,EAAE,6BAA6B;IAC1C,eAAe,EAAE,gBAAgB;IACjC,sBAAsB,EAAE,mBAAmB;IAC3C,aAAa,EAAE,sBAAsB;IACrC,qBAAqB,EAAE,QAAQ;IAC/B,mBAAmB,EAAE,QAAQ;IAC7B,oBAAoB,EAAE,SAAS;IAC/B,oBAAoB,EAAE,SAAS;IAC/B,eAAe,EAAE,kBAAkB;IACnC,iBAAiB,EAAE,gBAAgB;IACnC,aAAa,EAAE,OAAO;IACtB,kBAAkB,EAAE,oEAAoE;IACxF,0BAA0B,EAAE,mEAAmE;IAC/F,kBAAkB,EAAE,sDAAsD;IAC1E,qBAAqB,EAAE,4BAA4B;IACnD,mBAAmB,EAAE,2CAA2C;CACjE,CAAA"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Browser-side display formatting of the quota panel: the derived
3
+ * remaining share, the three-stop severity band, the trigger-ring fill
4
+ * share, the trigger tooltip figure, the reset countdown, and the money /
5
+ * percent figures. Pure functions, shared by the button (the trigger icon
6
+ * reads the finest-granularity window) and the panel's window columns.
7
+ *
8
+ * @module token-usage/client/quota-format
9
+ */
10
+ import type { QuotaWindow } from '../wire.ts';
11
+ /** The three color stops the quota surfaces use, best → worst. */
12
+ export type QuotaSeverity = 'ok' | 'warn' | 'exhausted';
13
+ /** Whole-number percent, one decimal kept when it exists (`62%`, `87.5%`). */
14
+ export declare function formatQuotaPercent(value: number): string;
15
+ /** A money figure with its symbol: `$6.80` / `¥110.00`. */
16
+ export declare function formatQuotaMoney(value: number, unit: 'usd' | 'cny'): string;
17
+ /**
18
+ * The used share of one window, 0–100, whichever direction the provider
19
+ * reported: the explicit `usedPercent`, else `remainingPercent` inverted,
20
+ * else the balance fraction (`1 - remaining/max`). Undefined when the
21
+ * window carries no computable ratio (a balance without a total).
22
+ */
23
+ export declare function quotaUsedPercent(window: QuotaWindow): number | undefined;
24
+ /**
25
+ * The remaining share of one window, 0–100 — the severity input (severity
26
+ * reads what is LEFT, not what is spent). Mirrors {@link quotaUsedPercent}'s
27
+ * fallback chain in the opposite direction.
28
+ */
29
+ export declare function quotaRemainingPercent(window: QuotaWindow): number | undefined;
30
+ /** Map a remaining share (percent) to the traffic-light band: green above
31
+ * 60, yellow 20–60, red below 20. A window with no computable ratio reads
32
+ * by its absolute amount: an overdrawn/empty balance (≤ 0) is red,
33
+ * anything else uncolored — a plain balance never paints alarm just for
34
+ * lacking a total. */
35
+ export declare function quotaSeverityOf(window: QuotaWindow): QuotaSeverity;
36
+ /**
37
+ * The FINEST-granularity window of a payload — 5-hour over weekly over
38
+ * monthly over balance. The trigger icon reads this one, not the worst
39
+ * across windows: the finest unit is the constraint the session is
40
+ * currently acting inside (a calm 5-hour window carries the icon even when
41
+ * the weekly pool runs low). Undefined when there is no window at all.
42
+ */
43
+ export declare function finestQuotaWindow(windows: readonly QuotaWindow[]): QuotaWindow | undefined;
44
+ /**
45
+ * Fill share of the trigger ring, 0–1. Ratio windows map the remaining
46
+ * percent; a funded balance without a total paints a full ring (the color
47
+ * stays neutral — amounts tint only at ≤ 0); empty / overdrawn / missing
48
+ * windows leave the track only.
49
+ */
50
+ export declare function quotaIconFillShare(window: QuotaWindow | undefined): number;
51
+ /**
52
+ * The trigger tooltip's figure for one window: the remaining share as a
53
+ * percent when a ratio exists (any direction, or the balance fraction),
54
+ * else the remaining amount (a ratio-less balance, the DeepSeek shape);
55
+ * undefined when the window carries neither (nothing to show beyond the
56
+ * plain label).
57
+ */
58
+ export declare function quotaTriggerFigure(window: QuotaWindow | undefined): string | undefined;
59
+ /**
60
+ * The reset countdown in the shell's compact shape: `2h 14m` under a day,
61
+ * `48m` under an hour, `1d 3h` above; a non-positive remainder reads `0m`
62
+ * (the next poll refreshes the stale window).
63
+ * @param resetAt - epoch ms of the window's reset.
64
+ * @param now - epoch ms the countdown is taken at.
65
+ */
66
+ export declare function formatResetCountdown(resetAt: number, now: number): string;
67
+ /** A wall-clock `HH:MM` stamp of an epoch-ms time (the "updated at" figure). */
68
+ export declare function formatQuotaClock(ms: number): string;
69
+ //# sourceMappingURL=quota-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quota-format.d.ts","sourceRoot":"","sources":["../../src/client/quota-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,kEAAkE;AAClE,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,MAAM,GAAG,WAAW,CAAA;AAQvD,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED,2DAA2D;AAC3D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAE3E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAOxE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAO7E;AAED;;;;sBAIsB;AACtB,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAQlE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,WAAW,GAAG,SAAS,CAO1F;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAM1E;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAQtF;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAMzE;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAInD"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Browser-side display formatting of the quota panel: the derived
3
+ * remaining share, the three-stop severity band, the trigger-ring fill
4
+ * share, the trigger tooltip figure, the reset countdown, and the money /
5
+ * percent figures. Pure functions, shared by the button (the trigger icon
6
+ * reads the finest-granularity window) and the panel's window columns.
7
+ *
8
+ * @module token-usage/client/quota-format
9
+ */
10
+ /** Severity thresholds on the REMAINING share (percent) — the traffic-light
11
+ * standard: above 60 reads green (plenty left), 20–60 yellow (watch it),
12
+ * below 20 red (effectively gone). */
13
+ const REMAIN_YELLOW = 60;
14
+ const REMAIN_RED = 20;
15
+ /** Whole-number percent, one decimal kept when it exists (`62%`, `87.5%`). */
16
+ export function formatQuotaPercent(value) {
17
+ const rounded = Math.round(value * 10) / 10;
18
+ return `${Number.isInteger(rounded) ? String(rounded) : rounded.toFixed(1)}%`;
19
+ }
20
+ /** A money figure with its symbol: `$6.80` / `¥110.00`. */
21
+ export function formatQuotaMoney(value, unit) {
22
+ return `${unit === 'usd' ? '$' : '¥'}${value.toFixed(2)}`;
23
+ }
24
+ /**
25
+ * The used share of one window, 0–100, whichever direction the provider
26
+ * reported: the explicit `usedPercent`, else `remainingPercent` inverted,
27
+ * else the balance fraction (`1 - remaining/max`). Undefined when the
28
+ * window carries no computable ratio (a balance without a total).
29
+ */
30
+ export function quotaUsedPercent(window) {
31
+ if (window.usedPercent !== undefined)
32
+ return clampPercent(window.usedPercent);
33
+ if (window.remainingPercent !== undefined)
34
+ return clampPercent(100 - window.remainingPercent);
35
+ if (window.remainingValue !== undefined && window.maxValue !== undefined && window.maxValue > 0) {
36
+ return clampPercent((1 - window.remainingValue / window.maxValue) * 100);
37
+ }
38
+ return undefined;
39
+ }
40
+ /**
41
+ * The remaining share of one window, 0–100 — the severity input (severity
42
+ * reads what is LEFT, not what is spent). Mirrors {@link quotaUsedPercent}'s
43
+ * fallback chain in the opposite direction.
44
+ */
45
+ export function quotaRemainingPercent(window) {
46
+ if (window.remainingPercent !== undefined)
47
+ return clampPercent(window.remainingPercent);
48
+ if (window.usedPercent !== undefined)
49
+ return clampPercent(100 - window.usedPercent);
50
+ if (window.remainingValue !== undefined && window.maxValue !== undefined && window.maxValue > 0) {
51
+ return clampPercent((window.remainingValue / window.maxValue) * 100);
52
+ }
53
+ return undefined;
54
+ }
55
+ /** Map a remaining share (percent) to the traffic-light band: green above
56
+ * 60, yellow 20–60, red below 20. A window with no computable ratio reads
57
+ * by its absolute amount: an overdrawn/empty balance (≤ 0) is red,
58
+ * anything else uncolored — a plain balance never paints alarm just for
59
+ * lacking a total. */
60
+ export function quotaSeverityOf(window) {
61
+ const remaining = quotaRemainingPercent(window);
62
+ if (remaining === undefined) {
63
+ return window.remainingValue !== undefined && window.remainingValue <= 0 ? 'exhausted' : 'ok';
64
+ }
65
+ if (remaining < REMAIN_RED)
66
+ return 'exhausted';
67
+ if (remaining <= REMAIN_YELLOW)
68
+ return 'warn';
69
+ return 'ok';
70
+ }
71
+ /**
72
+ * The FINEST-granularity window of a payload — 5-hour over weekly over
73
+ * monthly over balance. The trigger icon reads this one, not the worst
74
+ * across windows: the finest unit is the constraint the session is
75
+ * currently acting inside (a calm 5-hour window carries the icon even when
76
+ * the weekly pool runs low). Undefined when there is no window at all.
77
+ */
78
+ export function finestQuotaWindow(windows) {
79
+ const rank = { five_hour: 0, weekly: 1, monthly: 2, balance: 3 };
80
+ let pick;
81
+ for (const window of windows) {
82
+ if (pick === undefined || rank[window.tier] < rank[pick.tier])
83
+ pick = window;
84
+ }
85
+ return pick;
86
+ }
87
+ /**
88
+ * Fill share of the trigger ring, 0–1. Ratio windows map the remaining
89
+ * percent; a funded balance without a total paints a full ring (the color
90
+ * stays neutral — amounts tint only at ≤ 0); empty / overdrawn / missing
91
+ * windows leave the track only.
92
+ */
93
+ export function quotaIconFillShare(window) {
94
+ if (window === undefined)
95
+ return 0;
96
+ const remaining = quotaRemainingPercent(window);
97
+ if (remaining !== undefined)
98
+ return remaining / 100;
99
+ if (window.remainingValue !== undefined && window.remainingValue > 0)
100
+ return 1;
101
+ return 0;
102
+ }
103
+ /**
104
+ * The trigger tooltip's figure for one window: the remaining share as a
105
+ * percent when a ratio exists (any direction, or the balance fraction),
106
+ * else the remaining amount (a ratio-less balance, the DeepSeek shape);
107
+ * undefined when the window carries neither (nothing to show beyond the
108
+ * plain label).
109
+ */
110
+ export function quotaTriggerFigure(window) {
111
+ if (window === undefined)
112
+ return undefined;
113
+ const remaining = quotaRemainingPercent(window);
114
+ if (remaining !== undefined)
115
+ return formatQuotaPercent(remaining);
116
+ if (window.remainingValue !== undefined) {
117
+ return formatQuotaMoney(window.remainingValue, window.unit ?? 'cny');
118
+ }
119
+ return undefined;
120
+ }
121
+ /**
122
+ * The reset countdown in the shell's compact shape: `2h 14m` under a day,
123
+ * `48m` under an hour, `1d 3h` above; a non-positive remainder reads `0m`
124
+ * (the next poll refreshes the stale window).
125
+ * @param resetAt - epoch ms of the window's reset.
126
+ * @param now - epoch ms the countdown is taken at.
127
+ */
128
+ export function formatResetCountdown(resetAt, now) {
129
+ const minutes = Math.max(0, Math.floor((resetAt - now) / 60_000));
130
+ if (minutes < 60)
131
+ return `${String(minutes)}m`;
132
+ const hours = Math.floor(minutes / 60);
133
+ if (hours < 24)
134
+ return `${String(hours)}h ${String(minutes % 60)}m`;
135
+ return `${String(Math.floor(hours / 24))}d ${String(hours % 24)}h`;
136
+ }
137
+ /** A wall-clock `HH:MM` stamp of an epoch-ms time (the "updated at" figure). */
138
+ export function formatQuotaClock(ms) {
139
+ const date = new Date(ms);
140
+ const pad = (value) => String(value).padStart(2, '0');
141
+ return `${pad(date.getHours())}:${pad(date.getMinutes())}`;
142
+ }
143
+ /** Clamp into 0–100. */
144
+ function clampPercent(value) {
145
+ return Math.min(100, Math.max(0, value));
146
+ }
147
+ //# sourceMappingURL=quota-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quota-format.js","sourceRoot":"","sources":["../../src/client/quota-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH;;sCAEsC;AACtC,MAAM,aAAa,GAAG,EAAE,CAAA;AACxB,MAAM,UAAU,GAAG,EAAE,CAAA;AAErB,8EAA8E;AAC9E,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,EAAE,CAAA;IAC3C,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAA;AAC/E,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,IAAmB;IACjE,OAAO,GAAG,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA;AAC3D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAmB;IAClD,IAAI,MAAM,CAAC,WAAW,K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