dsh-cost-meter 1.7.39 → 1.7.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,9 +8,9 @@
8
8
 
9
9
  Per-conversation cost · daily totals · OpenCode Go subscription quota display · budget with usage percentage · official account balance · custom provider balance · balance progress bar · history · peak/off-peak pricing hours display (peak hours UTC 01:00–04:00, 06:00–10:00; weekends and Chinese public holidays are off-peak all day, with separate labels) · pre-switch popup & system-notification alerts for peak/off-peak changes (position / lead time / alert type configurable) · one-click price sync from the official docs · Codex-style token usage heat grid · multi-vendor model pricing (built-in 90+ model price catalog with auto-matching) · mainstream Coding Plan quota queries & display (Anthropic / Z.ai / MiniMax / Kimi / OpenRouter / SiliconFlow / CommandCode / SCNet / Volcano Ark / Qwen / Xiaomi MiMo) plan/API dual-track billing (subscription quota vs pay-as-you-go money separated, per-1% & full-window token/equivalent-cost estimates with daily/weekly/monthly curves) · · quota strip above the input box (budget / Go / coding-plan usage in one row, toggleable)
10
10
 
11
- [![version](https://img.shields.io/badge/version-1.7.39-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
11
+ [![version](https://img.shields.io/badge/version-1.7.41-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
12
12
 
13
- **v1.7.39** fixes quota and balance caching, duplicate billing after 1,024 sessions, malformed ledger recovery, and external usage validation. See the [release notes](docs/release-notes/v1.7.39.md).
13
+ **v1.7.41** fixes balance reconciliation with external usage, adds a sidebar token view and official CNY model tiers, and prevents unsafe model price matches. See the [release notes](docs/release-notes/v1.7.41.md).
14
14
 
15
15
  [![npm](https://img.shields.io/npm/v/dsh-cost-meter?label=npm)](https://www.npmjs.com/package/dsh-cost-meter)
16
16
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
@@ -40,7 +40,7 @@ Per-conversation cost · daily totals · OpenCode Go subscription quota display
40
40
  | Today's cost | Sidebar bottom (above the settings button) | “Today ¥x”, hover for call count and token details |
41
41
  | Budget box | Sidebar bottom (between the balance row and the settings button) | Rounded-square frame: budget, used %, progress bar, today's cost & share of budget, used/limit; ≥80% warning, ≥100% over-budget |
42
42
  | Summary cards | Settings page | Today / this month / cumulative cost and call counts |
43
- | External usage | Settings → Cost | [Read-only snapshots](docs/external-usage.md#english) from other processes on the same account; per-source tokens/calls/cost and recent days, plus DSH + external daily/monthly/all-time totals. Official balance reconciliation stays DSH-only. |
43
+ | External usage | Settings → Cost | [Read-only snapshots](docs/external-usage.md#english) from other processes on the same account; per-source tokens/calls/cost and recent days, plus DSH + external daily/monthly/all-time totals. Fresh external cost for today joins official balance reconciliation. |
44
44
  | Token usage stats | Settings page (Cost section) | All-time token totals (input/cache/output/calls) + a Codex-style 26-week daily usage heat grid that fills the settings width; hover a cell for that day's detail |
45
45
  | Token Plan usage stats | Settings page (Usage) | Per enabled coding plan (incl. Go): per-1% quota and full-window token / equivalent-cost estimates for the current windows (sample delta / live ratio), plus daily/weekly/monthly usage curves; plan-channel amounts are equivalent-only and never touch real money (issue #64) |
46
46
  | Today's sessions | Settings page | Per-session call count, input/cache/output tokens and cost |
@@ -317,22 +317,22 @@ On Node.js 20, use `npm install -g pnpm@10` instead. See [pnpm installation and
317
317
  dsh plugin --profile web add dsh-cost-meter
318
318
  ```
319
319
 
320
- **PowerShell one-click script** (copy the whole line, paste, press Enter; pnpm is provisioned automatically, git is auto-detected — no clone needed; the install chain is **pinned to the release tag `v1.7.39`** — review the script before running):
320
+ **PowerShell one-click script** (copy the whole line, paste, press Enter; pnpm is provisioned automatically, git is auto-detected — no clone needed; the install chain is **pinned to the release tag `v1.7.41`** — review the script before running):
321
321
 
322
322
  ```powershell
323
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.39/install.ps1 | iex
323
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.41/install.ps1 | iex
324
324
  ```
325
325
 
326
326
  **Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
327
327
 
328
328
  ```sh
329
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.39
329
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.41
330
330
  ```
331
331
 
332
332
  Without git, use the GitHub tag archive:
333
333
 
334
334
  ```sh
335
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.39.tar.gz
335
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.41.tar.gz
336
336
  ```
337
337
 
338
338
  After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
package/README.zh-CN.md CHANGED
@@ -8,9 +8,9 @@
8
8
 
9
9
  本会话费用 · 当日费用 · OpenCode Go 订阅额度显示 · 预算与已用百分比 · 官方账户余额 · 自定义 Provider 余额查询(可配任意 HTTP 端点) · 余额三段进度条 · 历史记录 · 峰谷计价时段显示(UTC 01:00–04:00、06:00–10:00 为峰时段;周末与中国法定假日全天按谷价,分别标注) · 峰/谷切换前弹窗与系统通知提醒(位置/提前量/提醒类型可配) · 官方价格一键同步 · 类 Codex Token 用量热图 · 多厂商多模型价格计费(内置 90+ 模型价格目录与自动匹配) · 主流 Coding Plan 额度查询与显示(Anthropic / Z.ai / MiniMax / Kimi / OpenRouter / SiliconFlow / CommandCode / SCNet / 火山方舟 / 千问 / 小米 MiMo 十一家,含 Volcano Ark AK/SK 签名与 MiMo 控制台 Cookie 查询) · Plan/API 双轨计费(订阅额度与按量金额分离统计,每 1% 额度与满窗的 token/等值金额估算及日/周/月曲线) · 输入框上方额度横条(预算/Go/Coding Plan 用量一条横排显示,可开关)
10
10
 
11
- [![version](https://img.shields.io/badge/version-1.7.39-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
11
+ [![version](https://img.shields.io/badge/version-1.7.41-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
12
12
 
13
- **v1.7.39**:修复额度与余额缓存、超过 1024 个会话后的重复计费、异常账本恢复和外部用量校验。详见[更新说明](docs/release-notes/v1.7.39.md)。
13
+ **v1.7.41**:修复外部用量的余额对账,增加侧边栏 Token 视图和官方人民币价格档位,并收紧模型价格匹配。详见[更新说明](docs/release-notes/v1.7.41.md)。
14
14
 
15
15
  [![npm](https://img.shields.io/npm/v/dsh-cost-meter?label=npm)](https://www.npmjs.com/package/dsh-cost-meter)
16
16
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
@@ -40,7 +40,7 @@
40
40
  | 当日费用 | 侧边栏底部(设置按钮上方) | 「今日 ¥x」,悬停见调用次数与 token 明细 |
41
41
  | 预算图框 | 侧边栏底部(余额行与设置按钮之间) | 圆角方形图框:预算、已用%、进度条、今日费用与占预算%、已用/额度,≥80% 预警、≥100% 超支 |
42
42
  | 汇总卡片 | 设置页 | 今日 / 本月 / 累计费用与调用次数 |
43
- | 外部用量 | 设置 → 费用 | 同账户其他进程通过[只读快照](docs/external-usage.md#中文)提供用量;按来源查看 token、调用、费用和近期每日记录,并显示 DSH + 外部的日/月/累计合计。官方余额对账仍只用 DSH 账本。 |
43
+ | 外部用量 | 设置 → 费用 | 同账户其他进程通过[只读快照](docs/external-usage.md#中文)提供用量;按来源查看 token、调用、费用和近期每日记录,并显示 DSH + 外部的日/月/累计合计。有效快照的今日费用参与官方余额对账。 |
44
44
  | Token 用量统计 | 设置页(费用设置) | 历史累计 token 总量(输入/缓存/输出/调用)+ 类 Codex 的 26 周每日用量方格热图,横向铺满设置页宽度,悬停见当日明细 |
45
45
  | Token Plan 用量统计 | 设置页(用量) | 各已启用 Coding Plan(含 Go)当前窗口的「每 1% 额度」与「满窗 100%」对应的 token 数与等值金额估算(采样差分/当前用量折算),附每日/每周/每月用量曲线;Plan 类调用金额只记等值,不动真金白银(issue #64) |
46
46
  | 今日会话明细 | 设置页 | 每个会话的调用次数、输入/缓存/输出 token 与费用 |
@@ -317,22 +317,22 @@ Node.js 20 请改用 `npm install -g pnpm@10`。版本要求见 [pnpm 官方安
317
317
  dsh plugin --profile web add dsh-cost-meter
318
318
  ```
319
319
 
320
- **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.7.39`**,建议先下载审阅再运行):
320
+ **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.7.41`**,建议先下载审阅再运行):
321
321
 
322
322
  ```powershell
323
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.39/install.ps1 | iex
323
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.41/install.ps1 | iex
324
324
  ```
325
325
 
326
326
  **或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
327
327
 
328
328
  ```sh
329
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.39
329
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.41
330
330
  ```
331
331
 
332
332
  没有 git 时可用 GitHub tag 打包直链:
333
333
 
334
334
  ```sh
335
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.39.tar.gz
335
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.41.tar.gz
336
336
  ```
337
337
 
338
338
  安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## English
4
4
 
5
- Another local process can write `$DSH_HOME/storages/cost-meter/external_usage.json` to add usage from the **same account** that bypasses DSH. The plugin reads the file on each state refresh. It never calls Hindsight or any other external service. Settings → Cost shows DSH and external usage separately, plus combined today/month/all-time totals. Expand a source to see its token buckets, calls, costs and up to 90 recent daily rows. DSH session totals and official balance reconciliation remain DSH-only.
5
+ Another local process can write `$DSH_HOME/storages/cost-meter/external_usage.json` to add usage from the **same account** that bypasses DSH. The plugin reads the file on each state refresh. It never calls Hindsight or any other external service. Settings → Cost shows DSH and external usage separately, plus combined today/month/all-time totals. Expand a source to see its token buckets, calls, costs and up to 90 recent daily rows. DSH session totals remain separate. Official balance reconciliation includes the external snapshot's cost for today when the snapshot is less than 24 hours old; a stale snapshot mutes drift warnings until refreshed. A missing today entry counts as zero.
6
6
 
7
7
  Write the entire snapshot to a temporary file in the same directory, then atomically rename it to `external_usage.json`. Replace the file on every refresh; **do not append deltas**. The same snapshot can be read repeatedly without double-counting. Use ISO 8601 timestamps with `Z` or an explicit offset. `source` is a stable name (1–64 characters), not a model name. Up to eight sources are accepted. The file is capped at 512 KiB; each source can supply up to 3,660 daily summaries, or the whole file can supply up to 5,000 individual records. Snapshots older than 24 hours are marked stale; those older than 30 days, malformed, oversized, or unreadable are ignored. The producer should refresh regularly and keep historical days in each replacement snapshot. All-time totals cover only the days supplied by the producer.
8
8
 
@@ -52,7 +52,7 @@ A snapshot can contain a single top-level source as above, or a `sources` array.
52
52
 
53
53
  ## 中文
54
54
 
55
- 其他本地进程可将同一账户、但绕过 DSH 的用量写入 `$DSH_HOME/storages/cost-meter/external_usage.json`。插件每次刷新状态时读取,不直接请求 Hindsight 等服务。设置 → 费用按来源显示外部用量、DSH 与外部合计,以及近 90 天的逐日数据;DSH 会话金额和官方余额对账仍只使用 DSH 账本。
55
+ 其他本地进程可将同一账户、但绕过 DSH 的用量写入 `$DSH_HOME/storages/cost-meter/external_usage.json`。插件每次刷新状态时读取,不直接请求 Hindsight 等服务。设置 → 费用按来源显示外部用量、DSH 与外部合计,以及近 90 天的逐日数据。DSH 会话金额保持独立;官方余额对账会计入 24 小时内有效快照的今日外部费用。快照过期时暂停偏差提示,缺少今日条目按零计。
56
56
 
57
57
  采集器先在同目录写完整临时文件,再原子重命名为 `external_usage.json`。每次刷新替换整份快照,**不要追加增量**;重复读取不会重复计费。时间使用带 `Z` 或时区偏移的 ISO 8601。`source` 是稳定的来源名称,不是模型名。最多 8 个来源;文件上限 512 KiB;每来源最多 3660 条日汇总,或整份快照最多 5000 条调用记录。超过 24 小时未更新会标为过期;超过 30 天、损坏、过大或不可读的快照会被忽略。刷新时应保留所需的历史日期;累计费用只覆盖采集器提供的日期。
58
58
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "generatedAt": "2026-09-11",
2
+ "generatedAt": "2026-09-28",
3
3
  "note": "Auto-generated from lib/pricing.js DEFAULT_PROVIDER_PRICE_TABLE. USD per 1M tokens; unpriced entries have no verified official price.",
4
4
  "providers": {
5
5
  "openai": {
@@ -608,13 +608,56 @@
608
608
  },
609
609
  "xiaomi": {
610
610
  "models": {
611
+ "mimo-v2.6-pro": {
612
+ "input": 0.435,
613
+ "cachedInput": 0.0036,
614
+ "output": 0.87,
615
+ "cny": {
616
+ "cacheHit": 0.025,
617
+ "cacheMiss": 3,
618
+ "output": 6
619
+ },
620
+ "billingMode": "flat",
621
+ "sourceUrl": "https://mimo.mi.com/docs/zh-CN/price/pay-as-you-go",
622
+ "checkedAt": "2026-09-28",
623
+ "notes": "批量推理按半价"
624
+ },
625
+ "mimo-v2.6-flash": {
626
+ "input": 0.14,
627
+ "cachedInput": 0.0028,
628
+ "output": 0.28,
629
+ "cny": {
630
+ "cacheHit": 0.02,
631
+ "cacheMiss": 1,
632
+ "output": 2
633
+ },
634
+ "billingMode": "flat",
635
+ "sourceUrl": "https://mimo.mi.com/docs/zh-CN/price/pay-as-you-go",
636
+ "checkedAt": "2026-09-28",
637
+ "notes": "批量推理按半价"
638
+ },
639
+ "mimo-v2.6-pro-ultraspeed": {
640
+ "input": 4.35,
641
+ "cachedInput": 0.036,
642
+ "output": 8.7,
643
+ "cny": {
644
+ "cacheHit": 0.25,
645
+ "cacheMiss": 30,
646
+ "output": 60
647
+ },
648
+ "billingMode": "flat",
649
+ "sourceUrl": "https://mimo.mi.com/docs/zh-CN/price/pay-as-you-go",
650
+ "checkedAt": "2026-09-28",
651
+ "notes": "速度优先档;官方未提供批量推理档"
652
+ },
611
653
  "mimo-v2.5": {
612
654
  "input": 0.14,
613
655
  "cachedInput": 0.0028,
614
656
  "output": 0.28,
615
657
  "billingMode": "flat",
616
658
  "sourceUrl": "https://opencode.ai/docs/go",
617
- "checkedAt": "2026-08-17"
659
+ "checkedAt": "2026-08-17",
660
+ "notes": "官方标注即将下线,由 mimo-v2.6-flash 接替"
618
661
  },
619
662
  "mimo-v2.5-pro": {
620
663
  "input": 0.435,
@@ -622,7 +665,8 @@
622
665
  "output": 0.87,
623
666
  "billingMode": "flat",
624
667
  "sourceUrl": "https://opencode.ai/docs/go",
625
- "checkedAt": "2026-08-17"
668
+ "checkedAt": "2026-08-17",
669
+ "notes": "官方标注即将下线,由 mimo-v2.6-pro 接替"
626
670
  }
627
671
  }
628
672
  },
@@ -773,6 +817,22 @@
773
817
  "sourceUrl": "https://opencode.ai/docs/go",
774
818
  "checkedAt": "2026-08-17"
775
819
  },
820
+ "mimo-v2.6-flash": {
821
+ "input": 0.14,
822
+ "cachedInput": 0.0028,
823
+ "output": 0.28,
824
+ "billingMode": "flat",
825
+ "sourceUrl": "https://opencode.ai/docs/go",
826
+ "checkedAt": "2026-09-28"
827
+ },
828
+ "mimo-v2.6-pro": {
829
+ "input": 0.435,
830
+ "cachedInput": 0.003625,
831
+ "output": 0.87,
832
+ "billingMode": "flat",
833
+ "sourceUrl": "https://opencode.ai/docs/go",
834
+ "checkedAt": "2026-09-28"
835
+ },
776
836
  "mimo-v2.5": {
777
837
  "input": 0.14,
778
838
  "cachedInput": 0.0028,
@@ -863,6 +923,44 @@
863
923
  "notes": "低价换取提示词/补全用于训练 Meta 模型;限地区"
864
924
  }
865
925
  }
926
+ },
927
+ "openrouter": {
928
+ "models": {
929
+ "meta/muse-spark-1.3-contributor": {
930
+ "input": 0.1,
931
+ "cachedInput": 0.002,
932
+ "output": 0.2,
933
+ "billingMode": "flat",
934
+ "sourceUrl": "https://openrouter.ai/api/v1/models",
935
+ "checkedAt": "2026-09-17"
936
+ },
937
+ "google/gemini-3.8-flash": {
938
+ "input": 0.75,
939
+ "cachedInput": 0.075,
940
+ "cacheWrite": 0.041667,
941
+ "output": 3.75,
942
+ "billingMode": "flat",
943
+ "sourceUrl": "https://openrouter.ai/api/v1/models",
944
+ "checkedAt": "2026-09-17"
945
+ },
946
+ "qwen/qwen3.8-flash": {
947
+ "input": 0.15,
948
+ "cachedInput": 0.016,
949
+ "cacheWrite": 0.2,
950
+ "output": 0.47,
951
+ "billingMode": "flat",
952
+ "sourceUrl": "https://openrouter.ai/api/v1/models",
953
+ "checkedAt": "2026-09-17"
954
+ },
955
+ "z-ai/glm-5.3-flash": {
956
+ "input": 0.09,
957
+ "cachedInput": 0.018,
958
+ "output": 0.3,
959
+ "billingMode": "flat",
960
+ "sourceUrl": "https://openrouter.ai/api/v1/models",
961
+ "checkedAt": "2026-09-17"
962
+ }
963
+ }
866
964
  }
867
965
  }
868
966
  }
package/lib/backfill.js CHANGED
@@ -490,9 +490,7 @@ export function replaySessionRecords(records, config, wantDates = null) {
490
490
  // 官方价格币种为人民币(issue #47)时,DeepSeek 主表计出的成本为人民币,
491
491
  // 按展示汇率折算为美元入账——与 store.account() 完全同口径。
492
492
  const priced = resolved.priced ? costOf(buckets, resolved.entry, atMs, peak) : 0
493
- const cost = usdFromCost(priced,
494
- resolved.billingMode === 'deepseek-peak' && config?.prices?.currency === 'CNY' ? 'CNY' : 'USD',
495
- config?.exchangeRate)
493
+ const cost = usdFromCost(priced, resolved.currency, config?.exchangeRate)
496
494
  // Plan/API 双轨分类(issue #64):与 store.account() 同一分类器,回放条目
497
495
  // 的 apiCost 只含真金白银部分(plan 类金额仅记等值);传 prices 供路由判定。
498
496
  const apiCost = billingClassOf(effectiveProvider, sampleModel, config?.planBilling, enabledPlanSetOf(config), config?.prices) === 'api' ? cost : 0