dsh-cost-meter 1.6.8 → 1.6.9
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.en.md +9 -9
- package/README.md +9 -9
- package/lib/backfill.js +14 -2
- package/lib/client.js +2 -2
- package/lib/pricing.js +4 -1
- package/lib/store.js +4 -1
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
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; from Aug 23, 2026 weekends are billed at off-peak prices all day, shown as “Weekend — all off-peak”) · 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) 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)
|
|
8
8
|
|
|
9
|
-
[](https://github.com/Han-1413141/dsh-cost-meter)
|
|
10
10
|
[](https://www.npmjs.com/package/dsh-cost-meter)
|
|
11
11
|
[](LICENSE)
|
|
12
12
|
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
@@ -231,22 +231,22 @@ Real captures from an actual DSH sidebar of the period strip and collapsed verti
|
|
|
231
231
|
dsh plugin --profile web add dsh-cost-meter
|
|
232
232
|
```
|
|
233
233
|
|
|
234
|
-
**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.6.
|
|
234
|
+
**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.6.9`** — review the script before running):
|
|
235
235
|
|
|
236
236
|
```powershell
|
|
237
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.6.
|
|
237
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.6.9/install.ps1 | iex
|
|
238
238
|
```
|
|
239
239
|
|
|
240
240
|
**Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
|
|
241
241
|
|
|
242
242
|
```sh
|
|
243
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.6.
|
|
243
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.6.9
|
|
244
244
|
```
|
|
245
245
|
|
|
246
246
|
Without git, use the GitHub tag archive:
|
|
247
247
|
|
|
248
248
|
```sh
|
|
249
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.6.
|
|
249
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.6.9.tar.gz
|
|
250
250
|
```
|
|
251
251
|
|
|
252
252
|
After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
|
|
@@ -263,7 +263,7 @@ Cause: your environment (pnpm config or a policy bundled into the invoking insta
|
|
|
263
263
|
|
|
264
264
|
Fix:
|
|
265
265
|
|
|
266
|
-
1. **Upgrade to
|
|
266
|
+
1. **Upgrade to a version with exact-pinned dependencies**: all three runtime dependencies (`@deepseek-ai/dsh-credentials`, `@deepseek-ai/dsh-home-paths`, `zod`) are now exact-pinned — a pinned version's publish date never changes, so it satisfies any age threshold and this plugin can no longer trigger the error;
|
|
267
267
|
2. If the error is triggered by **another plugin's** dependencies instead, append an exclusion for the offending `name@version` printed in the error to the profile's `pnpm-workspace.yaml` (default `$DSH_HOME/profiles/web/pnpm-workspace.yaml`) and retry:
|
|
268
268
|
|
|
269
269
|
```yaml
|
|
@@ -299,8 +299,8 @@ dsh plugin --profile web add link:./dsh-cost-meter # symlink; edit lib/client.j
|
|
|
299
299
|
- The session badge is **billed exactly** at the moment each call is made (host-exported per-call cost), just like daily/monthly/cumulative totals and the budget;
|
|
300
300
|
- Billing sources are the `usage` block of every model call (including sub-agents, compression, title generation and other auxiliary calls), matching the billable view;
|
|
301
301
|
- **Peak/off-peak tiers follow the request-initiation moment**: a streaming call can span the tier boundary hour; attributing by completion time would put a request started minutes earlier into the wrong tier;
|
|
302
|
-
- **Peak effective-time anchoring
|
|
303
|
-
- **Switching pricing currency re-bases the whole history
|
|
302
|
+
- **Peak effective-time anchoring**: the official pricing page no longer lists an effective time, and price sync no longer resets the peak effective moment to "now" — historical recomputes (session projection refolds / per-model backfill) always tier events against the 2026-08-16 16:00 UTC boundary, so peak-hour history is no longer re-costed at half price; ledgers polluted earlier are clamped back automatically on upgrade (idempotent migration);
|
|
303
|
+
- **Switching pricing currency re-bases the whole history**: after the pricing-currency setting flips and re-syncs, historical entries are re-costed on the new price table in the background (days fully covered by session logs are replaced wholesale; sessions whose logs were cleaned keep their original basis), so history and the official bill share one basis, with a notice on completion; on upgrading to this version, existing ledgers that had switched currency and ended up with mixed bases are recomputed once automatically;
|
|
304
304
|
- **Aligning with official bills**: ① minute-level lag vs live official numbers is expected — the ledger flushes on a 2s debounce, and streams still in flight at shutdown are billed server-side while their usage block is never received (the gap concentrates in cache-hit columns); ② reasoning tokens are reported separately by the API and are **not billed** — the token columns sum five buckets and will never line up with the official three columns, so **reconcile by amount**; ③ with pricing currency set to CNY, entries are recorded directly on the official CNY price list (recommended for CNY-billed accounts); with USD, displayed amounts go through a fixed FX rate and carry a small structural difference (the two lists' per-column ratios are not uniform);
|
|
305
305
|
- Budget and over-budget warnings **only warn — they never block calls**.
|
|
306
306
|
- **Plan/API dual-track billing** (issue #64): calls on subscription-style channels (MiniMax, manually-marked Codex, etc.) are recorded as catalog-price equivalents only; budget/today-cost/overview cards count the pay-as-you-go (API) channel exclusively.
|
|
@@ -310,7 +310,7 @@ dsh plugin --profile web add link:./dsh-cost-meter # symlink; edit lib/client.j
|
|
|
310
310
|
## Data storage
|
|
311
311
|
|
|
312
312
|
- Ledger: `$DSH_HOME/storages/cost-meter/ledger.json` (atomic write + 2-second debounce; retained per `historyDays`, up to 200 per-session entries per day);
|
|
313
|
-
- **API keys never touch disk
|
|
313
|
+
- **API keys never touch disk**: all credentials (OpenCode Go key, coding-plan keys, Volcano AK/SK) live only in the DSH credential store — neither the ledger file nor anything sent back to the settings page contains plaintext; the settings inputs are write-only and never echo a saved key back;
|
|
314
314
|
- Every settings change is **saved instantly and automatically** (600 ms debounce) — no manual save needed;
|
|
315
315
|
- Delete the ledger file to reset everything, or use “Clear all history” in Settings;
|
|
316
316
|
- Privacy boundary: balance/quota endpoints (official balance and each coding plan) **only get contacted after you explicitly enable the corresponding provider** — no network traffic for disabled ones.
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
本会话费用 · 当日费用 · OpenCode Go 订阅额度显示 · 预算与已用百分比 · 官方账户余额 · 自定义 Provider 余额查询(可配任意 HTTP 端点) · 余额三段进度条 · 历史记录 · 峰谷计价时段显示(UTC 01:00–04:00、06:00–10:00 为峰时段;2026-08-23 起周末全天按谷价,显示「周末时段——全谷价」) · 峰/谷切换前弹窗与系统通知提醒(位置/提前量/提醒类型可配) · 官方价格一键同步 · 类 Codex Token 用量热图 · 多厂商多模型价格计费(内置 90+ 模型价格目录与自动匹配) · 主流 Coding Plan 额度查询与显示(Anthropic / Z.ai / MiniMax / Kimi / OpenRouter / SiliconFlow / CommandCode / SCNet / 火山方舟 九家,含 Volcano Ark AK/SK 签名) · Plan/API 双轨计费(订阅额度与按量金额分离统计,每 1% 额度与满窗的 token/等值金额估算及日/周/月曲线) · 输入框上方额度横条(预算/Go/Coding Plan 用量一条横排显示,可开关)
|
|
8
8
|
|
|
9
|
-
[](https://github.com/Han-1413141/dsh-cost-meter)
|
|
10
10
|
[](https://www.npmjs.com/package/dsh-cost-meter)
|
|
11
11
|
[](LICENSE)
|
|
12
12
|
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
@@ -233,22 +233,22 @@
|
|
|
233
233
|
dsh plugin --profile web add dsh-cost-meter
|
|
234
234
|
```
|
|
235
235
|
|
|
236
|
-
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.6.
|
|
236
|
+
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.6.9`**,建议先下载审阅再运行):
|
|
237
237
|
|
|
238
238
|
```powershell
|
|
239
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.6.
|
|
239
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.6.9/install.ps1 | iex
|
|
240
240
|
```
|
|
241
241
|
|
|
242
242
|
**或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
|
|
243
243
|
|
|
244
244
|
```sh
|
|
245
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.6.
|
|
245
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.6.9
|
|
246
246
|
```
|
|
247
247
|
|
|
248
248
|
没有 git 时可用 GitHub tag 打包直链:
|
|
249
249
|
|
|
250
250
|
```sh
|
|
251
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.6.
|
|
251
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.6.9.tar.gz
|
|
252
252
|
```
|
|
253
253
|
|
|
254
254
|
安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
|
|
@@ -265,7 +265,7 @@ dsh web
|
|
|
265
265
|
|
|
266
266
|
处理:
|
|
267
267
|
|
|
268
|
-
1.
|
|
268
|
+
1. **升级到含依赖精确锁版的版本**:三个运行时依赖(`@deepseek-ai/dsh-credentials`、`@deepseek-ai/dsh-home-paths`、`zod`)已全部精确锁版——锁定版本的发布时间固定不变,对任意年龄阈值永远满足,本插件不再可能触发该错误;
|
|
269
269
|
2. 若报错由**其他插件**的依赖触发,可在 profile 目录的 `pnpm-workspace.yaml`(默认 `$DSH_HOME/profiles/web/pnpm-workspace.yaml`)按报错列出的条目追加排除后重试:
|
|
270
270
|
|
|
271
271
|
```yaml
|
|
@@ -301,8 +301,8 @@ dsh plugin --profile web add link:./dsh-cost-meter # 符号链接,改 lib/clien
|
|
|
301
301
|
- 会话徽章与当日/月度/累计、预算一样,按每次调用的**实际时刻精确计费**(宿主导出的逐次成本);
|
|
302
302
|
- 计费来源为每次模型调用的 usage 块(含子代理、压缩、标题等辅助调用),与账单口径一致;
|
|
303
303
|
- **峰谷档位按请求发起时刻判定**:流式调用可能跨峰谷边界整点,以完成时刻归档会把数分钟前发起的请求算进另一个峰位;
|
|
304
|
-
-
|
|
305
|
-
-
|
|
304
|
+
- **峰谷生效时刻锚定**:官方价格页已不再标注生效时间,价格同步不再把峰谷生效时刻重置为「同步时刻」——历史重算(会话投影回放 / 按模型回填)一律按 2026-08-16 16:00 UTC 分界判档,峰时历史事件不再被按谷价半价重算;此前被污染的存量账本升级时自动钳制修复(幂等迁移);
|
|
305
|
+
- **币种切换即全量换基准**:「价格币种」切换并同步后,历史账目按新价目在后台整体重算(会话日志覆盖完整的日子整体替换,日志已清理的会话保持原口径),历史与官方账单同基准,完成后有提示;升级到本版时,此前切换过币种而新旧口径并存的存量账本自动重算一次;
|
|
306
306
|
- **官方账单对齐口径**:① 与官方实时数字存在**分钟级时差**属预期——账本 2 秒防抖落盘,关停瞬间仍在途的流会被服务端照常扣费而 usage 块无人接收(缺口集中在缓存命中列);② reasoning tokens 由 API 单独上报且**不计费**,token 列为五桶合计,与官方「三列」天然对不齐,**对账请以金额为准**;③ 「价格币种」设为人民币时按官方 CNY 价目直计入账,与人民币账单币种一致(CNY 计价账号推荐);设为 USD 时显示金额经固定汇率折算,与 CNY 直计存在结构性细差(两套价目比值非均匀);
|
|
307
307
|
- 预算与超支提示**仅提醒,不阻止调用**。
|
|
308
308
|
- **Plan/API 双轨计费**(issue #64):订阅制渠道(MiniMax / Codex 手动标记等)的调用金额只记「等值」,预算/今日费用/概览卡片等金额展示仅统计按量计费(API)部分;
|
|
@@ -312,7 +312,7 @@ dsh plugin --profile web add link:./dsh-cost-meter # 符号链接,改 lib/clien
|
|
|
312
312
|
## 数据存储
|
|
313
313
|
|
|
314
314
|
- 账本:`$DSH_HOME/storages/cost-meter/ledger.json`(原子写入 + 2 秒防抖;按 `historyDays` 保留,每日最多 200 个会话明细);
|
|
315
|
-
- **API Key
|
|
315
|
+
- **API Key 不落盘**:所有密钥(OpenCode Go Key、各 Coding Plan Key、火山 AK/SK)只存入 DSH 凭据库,账本文件与设置页回传均不含明文;设置页输入框为 write-only,保存后不可回显;
|
|
316
316
|
- 所有设置修改**即时自动保存**(600ms 防抖),无需手动保存;
|
|
317
317
|
- 删除账本文件即可清零,或使用设置页「清除全部历史」;
|
|
318
318
|
- 隐私边界:余额/额度类端点(官方余额与各 Coding Plan)**仅在用户显式启用对应 Provider 时**才会出站请求,未启用不产生任何网络流量。
|
package/lib/backfill.js
CHANGED
|
@@ -862,7 +862,8 @@ export async function repairForkSeed(ledger, sessionsRoot) {
|
|
|
862
862
|
* 40 次调用 token 逐位相同)。本函数对每个日期与其下每个会话的
|
|
863
863
|
* byProviderModel 按指纹分组——键的模型后缀(首个冒号之后,嵌套包装链
|
|
864
864
|
* 每层透传同一 model)与六值桶(input/output/cacheRead/cacheWrite/
|
|
865
|
-
* reasoning/calls)
|
|
865
|
+
* reasoning/calls)完全一致才算同组;每组保留**非包装层(上游真实)键**
|
|
866
|
+
* (同包装层性时取字母序第一),其余条目从
|
|
866
867
|
* 所在容器(day 或 session)的顶层合计(含 cost、calls)中扣除后删除。
|
|
867
868
|
*
|
|
868
869
|
* 幂等由调用方用账本 migrations 标记(provider-dedup-v1)保证只跑一次;
|
|
@@ -891,7 +892,18 @@ export async function repairProviderDupes(ledger) {
|
|
|
891
892
|
let touched = false
|
|
892
893
|
for (const keys of groups.values()) {
|
|
893
894
|
if (keys.length < 2) continue
|
|
894
|
-
|
|
895
|
+
// 保留键优选:非包装层(上游真实)键优先,同包装层性时保留字母序第一个。
|
|
896
|
+
// 此前恒保留字母序第一,而 'deepseek-modlens:' 恰排在 'deepseek-official:'
|
|
897
|
+
// 之前——官方键被删、包装层键存活,依赖后续 modlens-wrapper-dedup-v1 的
|
|
898
|
+
// 形态 3 改挂才恢复正确;改为直接保住上游键,消除迁移间的配合依赖。
|
|
899
|
+
keys.sort((a, b) => {
|
|
900
|
+
const sepA = a.indexOf(':')
|
|
901
|
+
const sepB = b.indexOf(':')
|
|
902
|
+
const wrapA = isWrapperProviderId(sepA > 0 ? a.slice(0, sepA) : '') ? 1 : 0
|
|
903
|
+
const wrapB = isWrapperProviderId(sepB > 0 ? b.slice(0, sepB) : '') ? 1 : 0
|
|
904
|
+
if (wrapA !== wrapB) return wrapA - wrapB
|
|
905
|
+
return a < b ? -1 : a > b ? 1 : 0
|
|
906
|
+
})
|
|
895
907
|
for (const key of keys.slice(1)) {
|
|
896
908
|
const bucket = pm[key]
|
|
897
909
|
subtractBucketInto(container, bucket)
|