@linxin666/dsh-usage 0.3.21 → 0.3.23
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.i18n.yaml +2 -2
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/lib/client.js +5 -5
- package/lib/client.js.map +1 -1
- package/lib/types/client/voucher.d.ts +2 -2
- package/package.json +2 -2
- package/src/client/UsageSectionCard.tsx +1 -1
- package/src/client/locales.ts +2 -2
- package/src/client/voucher.ts +2 -2
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# node scripts/verify-docs.mjs --write <dir>
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: b81a10bae215e90a7f133586d448dffb79fe368c
|
|
6
|
+
README.zh.md: e7bc8e716ff3398b3fe29185c811b4e37c56a123
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ The plugin runs a host-side service and a first-level settings section (使用
|
|
|
10
10
|
|
|
11
11
|
- **Usage tab (用量)**: today's token totals per bucket (input / output / cache read / cache write, disjoint as the provider reports them) with per-provider and per-model breakdown, the last 30 days as a horizontal provider/model bar chart, and the balance of every configured provider. For the official DeepSeek family the tab also shows the current peak/off-peak pricing period (Beijing weekdays 09:00-12:00 and 14:00-18:00 are peak, billed at double) and today's estimated spend in CNY. The ledger folds live `session/event` streams (`request/header` route attribution plus `assistant/message` usage) into `$DSH_HOME/dsh-usage/usage-ledger.json` with day-based retention; counting starts when the plugin is first enabled.
|
|
12
12
|
- **Plans tab (个人套餐)**: coding-plan quota windows for every configured provider that exposes one — used percent and reset time per window (Kimi For Coding 5h/week, GLM Coding Plan 5h/week, OpenCode Go rolling/weekly/monthly, MiniMax 5h/week, Codex / ChatGPT subscription 5h/week). Providers without a real plan or subscription (DeepSeek, ZenMux, Moonshot, OpenRouter, SiliconFlow) never appear on this tab; their balance shows on the usage tab instead.
|
|
13
|
-
- **Token Bank tab (Token 银行)**: the whale-yuan voucher (鲸元券) minted from the official DeepSeek family's ledger at an anti-inflation exchange rate of 1,000 tokens per whale yuan. The tab sums the family's retained-ledger tokens (the `deepseek` catalog alias and the live `deepseek-official` route combined), stamps the minted face value onto the banknote artwork with a serial line carrying the minting window, and offers a save-image button plus a native share button when the browser supports sharing files. The spend line shows the real CNY total observed from the official balance once available — balance decreases accrue as spend, top-ups never count — and falls back to the fold-time estimate before the first observation. The minted total prefers the host's whole-ledger aggregate and falls back to the last 30 days on an older host; with no official DeepSeek usage the tab shows its empty state. The on-note text is locale-neutral (digits, latin captions, ISO dates) and the export is rendered locally in the browser.
|
|
13
|
+
- **Token Bank tab (Token 银行)**: the whale-yuan voucher (鲸元券) minted from the official DeepSeek family's ledger at an anti-inflation exchange rate of 1,000,000 tokens per whale yuan. The tab sums the family's retained-ledger tokens (the `deepseek` catalog alias and the live `deepseek-official` route combined), stamps the minted face value onto the banknote artwork with a serial line carrying the minting window, and offers a save-image button plus a native share button when the browser supports sharing files. The spend line shows the real CNY total observed from the official balance once available — balance decreases accrue as spend, top-ups never count — and falls back to the fold-time estimate before the first observation. The minted total prefers the host's whole-ledger aggregate and falls back to the last 30 days on an older host; with no official DeepSeek usage the tab shows its empty state. The on-note text is locale-neutral (digits, latin captions, ISO dates) and the export is rendered locally in the browser.
|
|
14
14
|
- **Pet linkage**: the pet renders a dedicated announcement bubble (own glass style, tone accent, mini quota meter) following the current session provider. Plan providers (Kimi, GLM, Codex subscription, ...) show their tightest percent window; the official DeepSeek family shows today's estimated spend with the current peak/off-peak period and the account balance. When the session provider has no announceable probe fact (a relay station or local runtime without an adapter, failing probes, percent-less windows), the bubble falls back to that provider's live usage today (tokens and call count); with neither fact nor usage it stays silent. `bubbleMode` controls it: always (refreshed every poll with a poll-cadence TTL, so the bubble stays visible) / on change / off.
|
|
15
15
|
- Probes run entirely host-side on a poll cycle (default 60 s, manual refresh button); API keys are resolved through the harness credential seam (`llm-pi-ai` records, `apiKeyEnv` references) and never reach the browser.
|
|
16
16
|
|
package/README.zh.md
CHANGED
|
@@ -10,7 +10,7 @@ dsh Web GUI 的使用统计插件:多 provider 余额与编程套餐用量检
|
|
|
10
10
|
|
|
11
11
|
- **用量页签**:今日 token 分桶合计(输入 / 输出 / 缓存读 / 缓存写,按 provider 上报口径互不相加),分 provider 与模型细分,近 30 天以「提供方-模型」水平条形图展示,以及所有已配置 provider 的余额。对 DeepSeek 官方路由,页签还展示当前峰谷计价时段(北京时间工作日 09:00-12:00、14:00-18:00 为高峰,按双倍计费)与今日消费估算(CNY)。台账从 `session/event` 实时流折叠(`request/header` 归因路由 + `assistant/message` 用量),持久化到 `$DSH_HOME/dsh-usage/usage-ledger.json`,按本地日保留;统计自插件首次启用起计。
|
|
12
12
|
- **个人套餐页签**:每个已配置且暴露套餐端点的 provider 的配额窗口——已用百分比与重置时间(Kimi For Coding 5 小时/每周、GLM 编程计划 5 小时/每周、OpenCode Go 滚动/每周/每月、MiniMax 5 小时/每周、Codex / ChatGPT 订阅 5 小时/每周)。没有真实套餐/订阅体系的厂商(DeepSeek、ZenMux、Moonshot、OpenRouter、SiliconFlow)不出现在此页签,其余额显示在用量页签。
|
|
13
|
-
- **Token 银行页签**:以 DeepSeek 官方家族的台账用量铸造「鲸元券」,汇率按
|
|
13
|
+
- **Token 银行页签**:以 DeepSeek 官方家族的台账用量铸造「鲸元券」,汇率按 100 万 tokens 兑 1 鲸元(防膨胀)。页签把该家族保留台账内的 token 总量(`deepseek` 目录别名与运行时路由 `deepseek-official` 合并计算)折算成票面面额印在钞票图上,附带走票窗口的序列号行,并提供保存图片按钮与(浏览器支持文件分享时的)系统分享按钮。消费行优先展示从官方余额观测到的真实累计花费——余额下降即计为消费,充值上涨不计——首次观测到下降之前回落为折叠时刻估算。铸造总量优先取宿主的全台账聚合,旧宿主回落为近 30 天;无官方用量时展示空状态。票面文字与语言无关(数字、拉丁小字、ISO 日期),导出图在浏览器本地渲染。
|
|
14
14
|
- **宠物联动**:宠物渲染一只专用公告气泡(独立玻璃样式、色调描边、微型配额计量条),跟随当前会话提供方。套餐类 provider(Kimi、GLM、Codex 订阅等)展示最紧的百分比窗口;DeepSeek 官方路由展示今日消费估算、当前峰谷时段与账户余额。会话提供方没有可公告的探测事实时(无适配器的中转站或本地运行时、探测失败、无百分比窗口),气泡回落为该提供方今日的实时用量(tokens 与调用次数);事实与用量皆无时保持沉默。`bubbleMode` 控制行为:常驻(每次轮询即刷新,TTL 随轮询周期走,气泡保持可见)/ 仅变化时 / 关闭。
|
|
15
15
|
- 探测完全在宿主侧按轮询周期执行(默认 60 秒,可手动刷新);API key 经宿主凭据缝解析(`llm-pi-ai` 记录、`apiKeyEnv` 引用),永不进入浏览器。
|
|
16
16
|
|
package/lib/client.js
CHANGED
|
@@ -102,7 +102,7 @@ window.__ModuleLoader__.load({
|
|
|
102
102
|
"usage.config.bubbleMode.change": "仅变化时",
|
|
103
103
|
"usage.config.bubbleMode.off": "关闭",
|
|
104
104
|
"usage.bank.title": "鲸元券",
|
|
105
|
-
"usage.bank.hint": "官方 API 每消耗
|
|
105
|
+
"usage.bank.hint": "官方 API 每消耗 100 万 tokens 铸造 1 鲸元;保存或分享这张票券。",
|
|
106
106
|
"usage.bank.noUsage": "暂无 DeepSeek 官方用量数据(统计自插件启用起)",
|
|
107
107
|
"usage.bank.minted": "累计铸造 {minted} 鲸元({tokens} tokens)",
|
|
108
108
|
"usage.bank.spend.observed": "官方余额实测花费 ¥{cost}(自 {since} 起)",
|
|
@@ -158,7 +158,7 @@ window.__ModuleLoader__.load({
|
|
|
158
158
|
"usage.config.bubbleMode.change": "On change",
|
|
159
159
|
"usage.config.bubbleMode.off": "Off",
|
|
160
160
|
"usage.bank.title": "Whale-yuan voucher",
|
|
161
|
-
"usage.bank.hint": "Every 1,000 tokens spent on the official API mint one whale yuan; save or share the note.",
|
|
161
|
+
"usage.bank.hint": "Every 1,000,000 tokens spent on the official API mint one whale yuan; save or share the note.",
|
|
162
162
|
"usage.bank.noUsage": "No official DeepSeek usage yet (counting starts when the plugin is enabled)",
|
|
163
163
|
"usage.bank.minted": "Minted {minted} whale yuan ({tokens} tokens)",
|
|
164
164
|
"usage.bank.spend.observed": "Spent ¥{cost} observed on the official balance (watching since {since})",
|
|
@@ -728,8 +728,8 @@ window.__ModuleLoader__.load({
|
|
|
728
728
|
* section renders as its failure line.
|
|
729
729
|
* @module @linxin666/dsh-usage/client/voucher
|
|
730
730
|
*/
|
|
731
|
-
/** Anti-inflation exchange rate:
|
|
732
|
-
const TOKENS_PER_WHALE_YUAN =
|
|
731
|
+
/** Anti-inflation exchange rate: 1,000,000 tokens mint one whale yuan. */
|
|
732
|
+
const TOKENS_PER_WHALE_YUAN = 1e6;
|
|
733
733
|
/** The note's face value in whale yuan; the smallest denomination is 1. */
|
|
734
734
|
function faceValue(tokens) {
|
|
735
735
|
return Math.max(1, Math.round(tokens / TOKENS_PER_WHALE_YUAN));
|
|
@@ -1320,7 +1320,7 @@ window.__ModuleLoader__.load({
|
|
|
1320
1320
|
}
|
|
1321
1321
|
/**
|
|
1322
1322
|
* The Token 银行 card: the DeepSeek official family's retained-ledger usage
|
|
1323
|
-
* minted onto the whale-yuan note at
|
|
1323
|
+
* minted onto the whale-yuan note at 1,000,000 tokens per whale yuan. The window
|
|
1324
1324
|
* prefers the host's whole-ledger aggregate and falls back to the 30-day
|
|
1325
1325
|
* trend when an older host serves no `all`; the spend line prefers the
|
|
1326
1326
|
* official balance watch and falls back to the fold-time estimate; the
|