dsh-cost-meter 1.9.26 → 1.9.28

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 (39) hide show
  1. package/README.md +9 -9
  2. package/README.zh-CN.md +9 -9
  3. package/docs/billion-context-billing.md +10 -2
  4. package/docs/openrouter-prices.md +12 -0
  5. package/docs/plugin-compatibility-watch.md +2 -0
  6. package/docs/provider-pricing-2026-10.md +2 -2
  7. package/docs/update-notes-1.9.27.md +38 -0
  8. package/docs/update-notes-1.9.28.md +91 -0
  9. package/lib/backfill.js +108 -59
  10. package/lib/billion-context-billing.js +85 -10
  11. package/lib/billion-context-history.js +86 -11
  12. package/lib/billion-context-proxy.js +16 -5
  13. package/lib/bootstrap.js +7 -7
  14. package/lib/client.display.js +2 -2
  15. package/lib/client.js +6 -6
  16. package/lib/client.sidebar-order.js +3 -2
  17. package/lib/client.statistics.js +6 -6
  18. package/lib/coding-plans.js +7 -5
  19. package/lib/exchange-rate-refresh.js +2 -3
  20. package/lib/gateway-quota-adapters.js +42 -3
  21. package/lib/gateway-quotas.js +36 -2
  22. package/lib/index.js +62 -20
  23. package/lib/journal-storage.js +88 -0
  24. package/lib/ledger-persistence.js +4 -1
  25. package/lib/ledger-writer-worker.js +30 -0
  26. package/lib/ledger-writer.js +33 -0
  27. package/lib/native-search-history.js +30 -10
  28. package/lib/net.js +49 -21
  29. package/lib/openrouter-pricing.js +8 -2
  30. package/lib/openrouter-refresh-state.js +57 -0
  31. package/lib/pi-ai-codex-quota.js +66 -0
  32. package/lib/plan-billing.js +39 -16
  33. package/lib/session-cost-source.js +2 -2
  34. package/lib/statistics-warmup.js +3 -2
  35. package/lib/store.js +98 -16
  36. package/lib/typert.host.js +21 -2
  37. package/lib/usage-dedup.js +24 -11
  38. package/lib/usage-totals.js +7 -0
  39. package/package.json +5 -2
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  **Session cost tracking plugin for the DeepSeek Harness web GUI (bilingual UI)**
8
8
 
9
- [![version](https://img.shields.io/badge/version-1.9.26-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
9
+ [![version](https://img.shields.io/badge/version-1.9.28-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
10
10
  [![npm](https://img.shields.io/npm/v/dsh-cost-meter?label=npm)](https://www.npmjs.com/package/dsh-cost-meter)
11
11
  [![dshfind](https://dshfind.com/api/badge/Han-1413141/dsh-cost-meter?metric=downloads&lang=en)](https://dshfind.com/zh/plugins/Han-1413141/dsh-cost-meter?ref=badge)
12
12
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
@@ -16,11 +16,11 @@
16
16
 
17
17
  </div>
18
18
 
19
- **v1.9.26** fixes reversed OpenDesign 5-hour and weekly quotas, keeping each percentage paired with its reset time.
19
+ **v1.9.28** fixes nine billing and release defects, with background ledger saves, archived history and stable Plan/API attribution.
20
20
 
21
21
  **Host floor: DSH 0.2.0** · Adaptation target: **0.2.1-rc.2** (npm `next`). Expand the compatibility notes below for exact declarations, host records and troubleshooting.
22
22
 
23
- Release notes: [v1.9.26](docs/update-notes-1.9.26.md#english). Fully restart DSH after updating.
23
+ Release notes: [v1.9.28](docs/update-notes-1.9.28.md#english). Fully restart DSH after updating.
24
24
 
25
25
  ![Promo art](docs/promo.en.png)
26
26
 
@@ -65,7 +65,7 @@ Community and feedback: [Join the WeChat group →](#community). The WeChat grou
65
65
  | OpenCode Go quota | Sidebar / Settings / bottom-right dock (configurable) | Rolling-5h / weekly / monthly usage percent and reset times, each window toggleable independently, budget used % can show alongside; key auto-discovered (dedicated ref / official Go route apiKeyEnv / env / opencode login) or entered manually |
66
66
  | Coding plan quotas | Sidebar / Settings page (per vendor) | Multi-vendor coding-plan quota queries (Anthropic Claude Pro/Max, Z.ai / Zhipu GLM Coding Plan, MiniMax Token Plan, Kimi Code weekly + 5-hour quotas with PAYG balance fallback when no subscription key, OpenRouter credits, SiliconFlow balance, CommandCode 5h/weekly windows + monthly credits balance, Cline Pass 5-hour/weekly/monthly windows, Xiaomi MiMo Token Plan plan/compensation credit windows + period-end reset + balance via console cookie); per-vendor enable switch, key, display position and refresh interval (sidebar card in the same box style as the Go quota; the collapsed rail shows percentages), official endpoints by default, with a [configurable trusted MiniMax origin](docs/minimax-quota-endpoint.md#english); neutral hints when no credentials/subscription; SCNet Token Plan supports [external console snapshots](docs/scnet-official-snapshot.md#english); without a valid snapshot, monthly usage is estimated from the local ledger via the official credits deduction table (no credentials needed) |
67
67
  | Subscription plugin compatibility | Settings → Cost → Codex / sidebar & quota cards | Detects installed Codex / ChatGPT subscription plugins and classifies their subscription calls as Plan quota instead of pay-as-you-go API spend; new usage is classified at record time, and a one-time dismissible prompt decides whether historical Codex billing is reclassified (idempotent). Explicit plan/API choices are never overridden. [Details](docs/update-notes-1.9.0.md#english) |
68
- | Codex quota display | Settings → Display → Codex / sidebar & quota strip | Reads actual 5-hour and 7-day windows from `dsh-codex-subscription` or `@eddyskywalker/dsh-chatgpt-subscription`, with `dsh-codex-connect` compatibility. Select `auto` (tries those three plugins in order), `subscription`, `chatgpt`, or `connect`. An explicit source shows only that plugin's current account. Independent of the billing classification in “Subscription plugin compatibility”. |
68
+ | Codex quota display | Settings → Display → Codex / sidebar & quota strip | Reads actual quota windows from `dsh-codex-subscription`, the native DSH pi-ai login, `@eddyskywalker/dsh-chatgpt-subscription`, or `dsh-codex-connect`. Select `auto` (tries these sources in order), `subscription`, `pi-ai`, `chatgpt`, or `connect`. Native pi-ai needs no extra subscription plugin. Weekly-only accounts show no 5h bar. An explicit source uses only that source's current account; billing classification remains separate. |
69
69
  | SQLite session storage (better-session) | Host integration | Auto-detects the host session backend; with `@morlay/better-session` / `@morlay/session-rdb` (SQLite) storage, historical backfill, legacy import, history repricing, hour-bucket repair, fork cleanup and per-session cost/trajectory/call details keep working. The JSONL path is unchanged; old JSONL and RDB histories are not merged automatically. [Guide](docs/better-session.md) |
70
70
  | OpenDesign quota | Sidebar / Settings (OpenDesign vendor) | Workspace coding-plan windows from the console API; with a Control Key, a 401/403 from the primary endpoint triggers one conservative `/billing/preflight` Bearer fallback, and window/wallet reads degrade independently. [Troubleshooting](docs/opendesign-billing.md#english) |
71
71
  | Mobile / dsh-pocket layout | All cost UIs | On screens ≤1023px and dsh-pocket mobile layouts: single-column cards, horizontally scrolling tabs, 36px touch targets, dialogs capped at 90vh with safe-area padding and scrolling wide tables; desktop layout unchanged |
@@ -352,22 +352,22 @@ On Node.js 20, use `npm install -g pnpm@10` instead. See [pnpm installation and
352
352
  dsh plugin --profile web add dsh-cost-meter
353
353
  ```
354
354
 
355
- **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.9.26`** — review the script before running):
355
+ **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.9.28`** — review the script before running):
356
356
 
357
357
  ```powershell
358
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.26/install.ps1 | iex
358
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.28/install.ps1 | iex
359
359
  ```
360
360
 
361
361
  **Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
362
362
 
363
363
  ```sh
364
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.26
364
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.28
365
365
  ```
366
366
 
367
367
  Without git, use the GitHub tag archive:
368
368
 
369
369
  ```sh
370
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.26.tar.gz
370
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.28.tar.gz
371
371
  ```
372
372
 
373
373
  After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
@@ -432,7 +432,7 @@ Workarounds:
432
432
 
433
433
  ```yaml
434
434
  minimumReleaseAgeExclude:
435
- - dsh-cost-meter@1.9.26
435
+ - dsh-cost-meter@1.9.28
436
436
  ```
437
437
 
438
438
  3. For a one-off CLI operation, forward the pnpm flag: `dsh plugin --profile desktop remove dsh-cost-meter --config.minimum-release-age=0` (or add `--trust-lockfile` when only lockfile verification fails). Both flags were verified against pnpm 11.28.5 in a temporary profile.
package/README.zh-CN.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  **DeepSeek Harness 会话费用统计插件(界面中英双语)**
8
8
 
9
- [![version](https://img.shields.io/badge/version-1.9.26-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
9
+ [![version](https://img.shields.io/badge/version-1.9.28-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
10
10
  [![npm](https://img.shields.io/npm/v/dsh-cost-meter?label=npm)](https://www.npmjs.com/package/dsh-cost-meter)
11
11
  [![dshfind](https://dshfind.com/api/badge/Han-1413141/dsh-cost-meter?metric=downloads&lang=zh)](https://dshfind.com/zh/plugins/Han-1413141/dsh-cost-meter?ref=badge)
12
12
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
@@ -16,11 +16,11 @@
16
16
 
17
17
  </div>
18
18
 
19
- **v1.9.26** 修复 OpenDesign 的 5h 与每周额度颠倒问题,额度百分比与各自重置时间保持对应。
19
+ **v1.9.28** 修复九项计费与发布问题,增加账本后台保存、历史日志归档,并分离额度查询与套餐归属。
20
20
 
21
21
  **宿主要求:DSH 0.2.0 起支持** · 适配目标 **0.2.1-rc.2**(npm `next`)。完整声明、历史记录与安装排障见下方展开项。
22
22
 
23
- 更新说明:[v1.9.26](docs/update-notes-1.9.26.md#中文)。更新后完全重启 DSH。
23
+ 更新说明:[v1.9.28](docs/update-notes-1.9.28.md#中文)。更新后完全重启 DSH。
24
24
 
25
25
  ![宣传图](docs/promo.png)
26
26
 
@@ -65,7 +65,7 @@
65
65
  | OpenCode Go 额度 | 侧边栏 / 设置页 / 右下角(dock,可配) | 滚动 5 小时 / 本周 / 本月用量百分比与重置时间,三档可分别开关,可同时显示预算已用%;Key 自动发现(专用引用 / 官方 Go 路由 apiKeyEnv / 环境变量 / opencode 登录态)或手动填写 |
66
66
  | Coding Plan 额度 | 侧边栏 / 设置页(每家可配) | 多厂商 coding plan 订阅额度查询(Anthropic Claude Pro/Max、Z.ai/智谱 GLM、MiniMax Token Plan、Kimi Code 本周/5 小时配额(无订阅 Key 时回落 PAYG 余额)、OpenRouter credits、SiliconFlow 余额、CommandCode 5h/周窗口与月度 Credits 余额、Cline Pass 5 小时/周/月三窗口用量%、小米 MiMo Token Plan 套餐/补偿积分窗口与周期截止重置、余额(控制台 Cookie 凭据)、火山方舟 Volcano Ark 5h/周/月三档(需 AK/SK 管控面 HMAC 签名,需 ArkReadOnlyAccess + BillingCenterReadOnlyAccess)),各家独立启用开关、凭据、显示位置与刷新间隔(侧边栏卡片与 Go 额度同款,收起窄栏显示百分比),默认使用官方端点,MiniMax 可[配置可信查询域名](docs/minimax-quota-endpoint.md);无凭据/无订阅为中性提示;SCNet 超算互联网 Token Plan 支持[外部控制台额度快照](docs/scnet-official-snapshot.md),无有效快照时按官方 Credits 抵扣表由本地账本估算月度用量(无需凭据) |
67
67
  | 订阅插件兼容 | 设置 → 费用 → Codex / 侧边栏与额度卡片 | 自动检测已安装的 Codex / ChatGPT 订阅插件,把其订阅调用归为 Plan 订阅额度、不计入 API 按量花费;新用量在记账时直接归类,历史 Codex 计费由一次性可关闭提示确认后重算(幂等)。显式 plan/API 配置不被覆盖。[说明](docs/update-notes-1.9.0.md#中文) |
68
- | Codex 额度显示 | 设置 → 显示 → Codex / 侧边栏与额度横条 | 读取 `dsh-codex-subscription`、`@eddyskywalker/dsh-chatgpt-subscription` 的实际 5 小时与 7 天窗口,兼容 `dsh-codex-connect`;数据源可选 `auto`(依次尝试上述三个插件)/ `subscription` / `chatgpt` / `connect`。固定来源只显示该插件当前账号的额度;与「订阅插件兼容」的计费归类设置互不影响。 |
68
+ | Codex 额度显示 | 设置 → 显示 → Codex / 侧边栏与额度横条 | 读取 `dsh-codex-subscription`、DSH 内置 pi-ai 登录、`@eddyskywalker/dsh-chatgpt-subscription`、`dsh-codex-connect` 的实际额度窗口;数据源可选 `auto`(按上述顺序尝试)/ `subscription` / `pi-ai` / `chatgpt` / `connect`。pi-ai 登录无需额外订阅插件,只有周额度的账号不显示 5h 条。固定来源只查询该来源的当前账号,与计费归类设置互不影响。 |
69
69
  | SQLite 会话存储(better-session) | 宿主集成 | 自动探测宿主会话后端;当 `@morlay/better-session` / `@morlay/session-rdb`(SQLite)接管存储时,历史回填、旧账本导入、历史重定价、小时桶修复、fork 清洗与逐会话费用/轨迹/调用详情继续可用。JSONL 路径行为不变;旧 JSONL 与 RDB 历史不自动合并。[说明](docs/better-session.md) |
70
70
  | OpenDesign 额度 | 侧边栏 / 设置页(OpenDesign 厂商) | 从控制台 API 读取工作区 coding plan 窗口;使用 Control Key 时主端点 401/403 会保守回退一次 `/billing/preflight`,窗口与钱包读取独立降级。[排查说明](docs/opendesign-billing.md#中文) |
71
71
  | 手机端适配(dsh-pocket) | 全部费用界面 | ≤1023px 窄屏与 dsh-pocket 移动布局下:卡片单列、标签横向滚动、36px 触控高度、对话框不超过 90vh 并避开安全区、宽表横向滚动;桌面布局不变 |
@@ -352,22 +352,22 @@ Node.js 20 请改用 `npm install -g pnpm@10`。版本要求见 [pnpm 官方安
352
352
  dsh plugin --profile web add dsh-cost-meter
353
353
  ```
354
354
 
355
- **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.9.26`**,建议先下载审阅再运行):
355
+ **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.9.28`**,建议先下载审阅再运行):
356
356
 
357
357
  ```powershell
358
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.26/install.ps1 | iex
358
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.28/install.ps1 | iex
359
359
  ```
360
360
 
361
361
  **或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
362
362
 
363
363
  ```sh
364
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.26
364
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.28
365
365
  ```
366
366
 
367
367
  没有 git 时可用 GitHub tag 打包直链:
368
368
 
369
369
  ```sh
370
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.26.tar.gz
370
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.28.tar.gz
371
371
  ```
372
372
 
373
373
  安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
@@ -432,7 +432,7 @@ DSH **0.2.1-rc.1 / 0.2.1-rc.2** 宿主自带 pnpm **11.28.5**,默认启用内
432
432
 
433
433
  ```yaml
434
434
  minimumReleaseAgeExclude:
435
- - dsh-cost-meter@1.9.26
435
+ - dsh-cost-meter@1.9.28
436
436
  ```
437
437
 
438
438
  3. 仅本次操作用 CLI 透传 pnpm 参数:`dsh plugin --profile desktop remove dsh-cost-meter --config.minimum-release-age=0`;若只是 lockfile 校验阶段失败,可改用 `--trust-lockfile`。这两个参数已在本机 pnpm 11.28.5 临时 Profile 上实测可用。
@@ -21,7 +21,11 @@ The integration adds observers in memory when the verified local Node proxy star
21
21
  - Uncached input, cache reads, cache writes, output and reasoning usage across OpenAI Chat Completions, Responses, Anthropic Messages and Google GenerateContent, including streams.
22
22
  - Actual upstream origin/model, request identity, attempt, completion status, owning DSH conversation and active turn/step.
23
23
 
24
- After durable proxy records are confirmed, those requests replace the corresponding ordinary DSH usage charge. Producer sequences and ledger receipts prevent repeated imports. Main/subagent totals, daily/week/all statistics, turn details and step views share these records and historical price versions. Inherited fork history is not charged again.
24
+ After usable proxy records are confirmed, those requests replace the corresponding ordinary DSH usage charge. A persistence receipt alone does not establish usage coverage. Producer sequences and ledger receipts prevent repeated imports. Main/subagent totals, daily/week/all statistics, turn details and step views share these records and historical price versions. Inherited fork history is not charged again.
25
+
26
+ When proxy model usage is missing but the host reports valid usage, one host sample is recorded for the correlated stream, regardless of the number of missing retries or groups. Independently measured compression remains separate. Mixed known and missing model usage is not added to an overlapping host aggregate: known calls and the original host sample are retained, with a notice when the overlap cannot be resolved. Known zero usage remains distinct from missing usage.
27
+
28
+ On import, retained legacy bridge records with `covered:true` and missing model usage can restore an omitted host sample even if proxy cursors already advanced or the session contains another provider. A durable stream receipt prevents repeated recovery. Records marked `covered:false` are not automatically repaired because ordinary host billing may already have accounted them. Missing original host usage cannot be reconstructed.
25
29
 
26
30
  Main requests retain the configured DSH provider price. Internal models use their actual upstream/model. Zero usage, missing usage, partial responses and missing prices remain distinct. Charges are not inferred from savings percentages or balance changes. The correlation header is removed before forwarding to a model endpoint.
27
31
 
@@ -52,7 +56,11 @@ Checks use original npm packages, isolated local responses, both plugin loading
52
56
 
53
57
  记录内部压缩、HTTP 重试和追加请求,以及未缓存输入、缓存读取、缓存写入、输出和推理用量;支持四种模型协议的 JSON 与流式响应。每条记录关联实际上游、模型、请求、重试次数、完成状态、所属 DSH 会话和轮次/步骤。
54
58
 
55
- 收到持久化回执后,逐次请求替换对应的普通 DSH 汇总记账。调用序号和账本入账凭据防止重复收费。会话金额、子代理、日/周/全部统计、单轮和步骤明细共用记录,并沿用保存的历史价格版本;分叉继承的历史不重复计费。
59
+ 确认代理记录含有可用用量后,逐次请求替换对应的普通 DSH 汇总记账;持久化成功本身不代表用量完整。调用序号和账本入账凭据防止重复收费。会话金额、子代理、日/周/全部统计、单轮和步骤明细共用记录,并沿用保存的历史价格版本;分叉继承的历史不重复计费。
60
+
61
+ 代理模型用量缺失、宿主用量有效时,按对应调用流补记一次宿主用量,不按缺失的重试次数或请求组数重复补记;独立测得的压缩费用仍单独保留。已知与缺失的模型用量混在一起时,保留已知调用和宿主原始汇总;无法判断重叠部分时提示核对,不把两者直接相加。已知零用量仍作为有效记录处理。
62
+
63
+ 导入时,旧版保留的桥接记录若标记 `covered:true`、模型用量缺失而宿主用量有效,可恢复遗漏的宿主费用,即使代理游标已经推进,或同一会话已记入其他渠道费用。每次恢复都有持久化凭据,重启后不重复。`covered:false` 的旧记录可能已走普通宿主记账,不自动补记;缺少原始宿主用量的历史无法重建。
56
64
 
57
65
  主请求沿用 DSH 渠道配置价格,内部模型按实际上游和模型匹配。零用量、缺失用量、部分回执和未定价分别显示,不按节省比例或余额差补算。关联标识在转发模型端点前删除。
58
66
 
@@ -16,6 +16,12 @@ This lookup only sends an unauthenticated `GET` to [OpenRouter's public models e
16
16
 
17
17
  The catalog is a reference, not a binding quote for the next request. Provider routing, price tiers, promotions and additional image/search/request fees can affect the actual bill. Open the model's official page for those details. The UI uses the existing DSH theme variables and controls, supports Chinese and English, and requires the host's asynchronous module loader (also used by Cost statistics).
18
18
 
19
+ ### Background billing-price synchronization
20
+
21
+ Startup and hourly checks share a persistent one-hour cooldown. The last attempt is saved before downloading, so restart loops, failures and interrupted requests cannot bypass it. Parallel hosts sharing a ledger admit one automatic task per cooldown. Fresh startup checks only read the state and do not rewrite it or the ledger. Manual billing-price synchronization still runs immediately and retains the existing in-flight request sharing.
22
+
23
+ The private `ledger.json.openrouter-prices.json` file beside the ledger stores only `fetchedAt` and `attemptedAt` timestamps. A successful price snapshot is persisted before recording its successful fetch time. Failed downloads retain the previous prices. The separately opened read-only price panel and model tooltip keep their foreground polling behavior.
24
+
19
25
  ## 中文
20
26
 
21
27
  打开输入框旁的模型选择菜单,悬停 **OpenRouter** 模型,DSH 原有提示中会显示输入、输出、缓存读取和缓存写入单价、上下文长度以及最近成功更新时间。模型列表出现时查询价格,菜单与浏览器处于前台时每分钟刷新;悬停模型或返回前台也会检查更新,两次请求至少间隔 15 秒。关闭菜单后停止价格请求,无需先进入设置。
@@ -31,3 +37,9 @@ The catalog is a reference, not a binding quote for the next request. Provider r
31
37
  查询仅对 [OpenRouter 公开模型接口](https://openrouter.ai/api/v1/models) 发送不带凭据的 `GET` 请求,无需 API Key,不发送模型推理请求,不产生模型使用费用。浏览价格不会修改计费单价配置、凭据或历史账本。原有后台计费价格同步继续独立运行。
32
38
 
33
39
  目录价格是参考价,具体路由、价格阶梯、优惠以及图片、搜索、请求等附加费用以 OpenRouter 为准,可点击模型查看详情。界面沿用 DSH 主题变量和控件,支持中英文;需要宿主支持异步模块加载,与费用统计页要求一致。
40
+
41
+ ### 后台计费价格同步
42
+
43
+ 启动与小时级定时检查共用持久化的一小时冷却。下载前保存最近尝试时间,重启循环、请求失败或下载途中退出均不能绕过冷却。共用账本的并行宿主在一个冷却周期内只放行一次自动任务。快照仍新时只读取刷新状态,不改写它或账本。手动同步计费价格仍可立即执行,保留已有的在途请求合并。
44
+
45
+ 账本旁的私有文件 `ledger.json.openrouter-prices.json` 只保存 `fetchedAt` 和 `attemptedAt` 两个时间戳。价格快照落盘后才记录成功时间;下载失败保留旧价格。单独打开的只读价格面板和模型提示仍沿用各自的前台刷新行为。
@@ -11,3 +11,5 @@ GitHub Actions 工作流 `plugin-compatibility-watch` 每日北京时间 08:23
11
11
  本地查看:`node scripts/watch-plugin-compatibility.mjs`。本地默认不创建 issue。单元检查:`node test/plugin-compatibility-watch.mjs`。
12
12
 
13
13
  2026-10-20 已验证并接受 `billion-context@0.1.202` 与 `dsh-codex-subscription@3.1.2`。前者通过实际发布包的代理、原生传输、重试、摘要、历史回放与原版 CLI 自动接入检查,后者通过实际额度解析和 RPC 的单周、双窗口、刷新、失败回退检查。测试使用合成数据与本机服务器,未查询用户账户或调用外部模型。两者接入接口指纹均未变化,v1.9.16 无需修改运行时代码即可兼容;对应版本已加入持续集成。
14
+
15
+ 2026-10-22 已验证并接受 `billion-context@0.1.204` 与 `dsh-codex-subscription@3.1.4`(监控 issue [#379](https://github.com/Han-1413141/dsh-cost-meter/issues/379)、[#380](https://github.com/Han-1413141/dsh-cost-meter/issues/380))。前者使用实际发布包验证代理、原生传输、重试、压缩、父子会话、历史回放和无配套包的 CLI 自动接入;后者验证发布包的单周、双窗口、强制刷新与失败回退。3.1.4 的 RPC 分发变化涉及语音功能,额度接口保持兼容。两版均加入持续集成,本次只接受已验证的两个版本,保留 `dsh-codex-connect` 原基线。
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## 中文
6
6
 
7
- 此前针对 #224 补齐 GPT-6 Sol/Luna、GPT-6.1 Sol、Gemini 3.8 Flash、Claude Fable 5.1、Opus 5.5 等模型,并按公开价格页面扩充其他模型。内置第三方目录包含 290 个「厂商 / 模型」条目、191 个不同模型 ID(含官方别名和历史快照 ID);其中 288 条有可执行价格,2 条明确未核价。DeepSeek 主表单独保留。OpenRouter 仍在启动、手动同步及每小时从公开目录补充本渠道模型,静态目录的数量不是在线目录的上限。
7
+ 此前针对 #224 补齐 GPT-6 Sol/Luna、GPT-6.1 Sol、Gemini 3.8 Flash、Claude Fable 5.1、Opus 5.5 等模型,并按公开价格页面扩充其他模型。内置第三方目录包含 290 个「厂商 / 模型」条目、191 个不同模型 ID(含官方别名和历史快照 ID);其中 288 条有可执行价格,2 条明确未核价。DeepSeek 主表单独保留。OpenRouter 在启动及小时级定时检查时按跨重启的一小时冷却补充本渠道模型,失败或中断也保留冷却;手动同步仍可立即执行。静态目录的数量不是在线目录的上限。
8
8
 
9
9
  ### 10 月 15 日更新
10
10
 
@@ -44,7 +44,7 @@ Haiku 5.5 按 100,000 输入 Token 分档,缓存读取和写入也计入阈值
44
44
 
45
45
  ## English
46
46
 
47
- The third-party catalog now contains 290 provider/model entries and 191 distinct model IDs, including official aliases and dated snapshots: 288 executable prices and 2 explicitly unpriced entries. The separate DeepSeek table remains intact. OpenRouter continues its existing public-directory refresh at startup, on manual sync and hourly.
47
+ The third-party catalog now contains 290 provider/model entries and 191 distinct model IDs, including official aliases and dated snapshots: 288 executable prices and 2 explicitly unpriced entries. The separate DeepSeek table remains intact. OpenRouter startup and hourly checks share a persistent one-hour cooldown, including after failures or interrupted downloads. Manual synchronization can refresh immediately.
48
48
 
49
49
  Use direct vendor IDs for their own API prices, `opencode-zen` for all 87 currently published Zen PAYG endpoints, and `opencode-go` for all 32 currently published Go subscription-reference endpoints. Historical host IDs `zen` / `opencode` retain their Go meaning; manually entered prices and explicit mappings win. These are pricing keys, not newly registered inference providers. If a PAYG host uses a historical name, explicitly map its model to `opencode-zen:<model ID>` and set that host model’s Plan/API class to API. A model-level Plan/API override remains authoritative. Catalog growth does not infer new subscription usage from a bare model name.
50
50
 
@@ -0,0 +1,38 @@
1
+ # v1.9.27
2
+
3
+ ## 中文
4
+
5
+ ### OpenRouter 重启冷却
6
+
7
+ 修复每次启动都重新下载 OpenRouter 价目表的问题。启动与小时级定时任务共用跨重启的一小时冷却,下载失败或中途退出后也保留冷却;多个共用账本的宿主只放行一次自动任务。冷却期间不改写账本或刷新状态,继续使用已有价格。手动同步仍可立即执行。
8
+
9
+ 按 issue 中每 11.4 秒启动一次的频率模拟 4,300 次启动,实际冷却检查只放行 14 次自动刷新任务;另验证了四个并行进程、小时边界、失败重启、无效缓存和手动同步。此结果是本地测试,不是对报告者真实流量的再次测量。
10
+
11
+ 感谢 [@yanzhaohui1999](https://github.com/yanzhaohui1999) 在 [issue #384](https://github.com/Han-1413141/dsh-cost-meter/issues/384) 提供重启循环的流量测量、代码定位和持久化冷却建议。
12
+
13
+ ### 本版同时发布的已合并修复
14
+
15
+ - 直接读取 DSH 内置 pi-ai 登录的 Codex 额度,支持自动回退和只有每周额度的账号;超时后释放等待状态,令牌更新后可重试。直接重载插件时恢复 billion-context 观察器和 RPC,卸载时取消额度查询。来自 [PR #383](https://github.com/Han-1413141/dsh-cost-meter/pull/383)。
16
+ - 恢复代理未报告模型用量、但宿主记录有效用量的 billion-context 调用,保留独立压缩费用,重启与重复导入不重复入账。感谢 [@Sieuno](https://github.com/Sieuno) 在 [#382](https://github.com/Han-1413141/dsh-cost-meter/issues/382) 独立复现并报告。
17
+ - Antigravity 过滤占位项目 ID,补全 Gemini 模型额度,并保留逐模型的重置时间;感谢 [@Oct1AtJoe](https://github.com/Oct1AtJoe) 在 [PR #381](https://github.com/Han-1413141/dsh-cost-meter/pull/381) 贡献代码。
18
+ - WorkBuddy 紧凑侧栏标题占满整行,余额靠右显示;[@SternChiri](https://github.com/SternChiri) 的 [#377](https://github.com/Han-1413141/dsh-cost-meter/issues/377) 触发排查。同步发布今日消费与余额同行的金额对齐修复。
19
+ - 更新 billion-context 0.1.204、dsh-codex-subscription 3.1.4 的发布包兼容验证与 CI 基线([#379](https://github.com/Han-1413141/dsh-cost-meter/issues/379)、[#380](https://github.com/Han-1413141/dsh-cost-meter/issues/380))。
20
+
21
+ 更新后完全退出并重启 DSH。无须新增设置;需要立即更新价格时仍可手动同步。
22
+
23
+ ## English
24
+
25
+ ### OpenRouter restart cooldown
26
+
27
+ Startup and hourly billing-price checks now share a persistent one-hour cooldown, including after failed or interrupted downloads. Hosts sharing a ledger admit one automatic task per cooldown. A recent snapshot requires no ledger or refresh-state writes. Existing prices remain available, and manual synchronization can run immediately.
28
+
29
+ At the reported 11.4-second restart cadence, a local simulation of 4,300 starts admitted 14 automatic tasks. Checks also cover four concurrent processes, hourly boundaries, failed restarts, invalid metadata and manual synchronization. This is synthetic validation, not a remeasurement of the reporter's traffic. Thanks to [@yanzhaohui1999](https://github.com/yanzhaohui1999) for the measurements, code pointers and cooldown proposal in [#384](https://github.com/Han-1413141/dsh-cost-meter/issues/384).
30
+
31
+ ### Previously merged fixes included in this release
32
+
33
+ - Native pi-ai Codex quota queries, weekly-only accounts, bounded cancellation, direct-reload observer/RPC recovery and inline Today/Balance alignment from [PR #383](https://github.com/Han-1413141/dsh-cost-meter/pull/383).
34
+ - Recover missing billion-context model usage without duplicating compression costs or replayed calls; reported independently by [@Sieuno in #382](https://github.com/Han-1413141/dsh-cost-meter/issues/382).
35
+ - Antigravity project filtering and per-model Gemini quota/reset handling, contributed by [@Oct1AtJoe in PR #381](https://github.com/Han-1413141/dsh-cost-meter/pull/381).
36
+ - Full-width compact WorkBuddy headings, investigated after [@SternChiri's #377](https://github.com/Han-1413141/dsh-cost-meter/issues/377), plus published-package compatibility baselines for billion-context 0.1.204 and dsh-codex-subscription 3.1.4.
37
+
38
+ Fully quit and restart DSH after updating. No new setting is required; use manual synchronization whenever an immediate price update is needed.
@@ -0,0 +1,91 @@
1
+ # v1.9.28
2
+
3
+ ## 中文
4
+
5
+ 本版修复代码审查确认的 9 个问题,完成 6 项计费、存储、网络与测试优化,并保留 v1.9.27 已发布的 pi-ai Codex、billion-context、Antigravity 与 OpenRouter 冷却修复。
6
+
7
+ ### 9 项问题修复
8
+
9
+ | 编号 | 问题 | 本版处理 |
10
+ | --- | --- | --- |
11
+ | F1 | 单个合法 zstd 帧超过 8 MiB 时,历史记录被跳过 | 区分未完整帧与无效帧,继续读取跨块压缩帧;保留截断尾部处理。 |
12
+ | F2 | 解压预算计算压缩字节,未限制实际输出 | 按实际解压字节执行预算;普通 JSONL 同样受字节、行长和事件数限制。大型文本块跳过后继续读取用量记录。 |
13
+ | F3 | 并发请求乱序结束时,独立调用被错误去重 | 按请求时刻的绝对间隔匹配,保留有界候选;实时入账、历史重放和宿主投影采用一致判定。 |
14
+ | F4 | billion-context 已完成、但没有调用明细时漏记宿主用量 | 独立读取完成的 stream,补记一次有效宿主用量;重启、重复导入和日志归档后仍能恢复,且不重复计费。 |
15
+ | F5 | 推理 Token 在部分总量统计中被重复相加 | 统一总量为输入、输出、缓存读写之和;推理保留为输出细分,不额外叠加到 Token 总数。已有独立推理单价规则保持有效。 |
16
+ | F6 | 周/月套餐统计忽略供应商实际重置周期 | 优先采用接口起点、窗口时长和重置时刻,区分固定与滚动窗口;小时桶保留 35 天,覆盖周期首日的部分时段。缺少窗口信息时才回退自然周期。 |
17
+ | F7 | 已有发布标签可能指向旧代码 | 发布前刷新并核对 master、本地标签、远端标签和 HEAD;提交不符时终止。远端缺标签时推送已核验标签,创建 Release 必须使用已存在的标签。 |
18
+ | F8 | 网关把空值或布尔值当作 0% 已用 | 只接收有限数值或非空数字字符串;缺少比例但明确耗尽时显示 100% 已用,其他缺失数据保持未知。 |
19
+ | F9 | 生成发布说明被自身写入操作拦截 | `--regen-notes` 独立生成素材,允许在开发分支使用;正式发布只读取已提交的文案,仍要求版本一致且工作树干净。 |
20
+
21
+ ### 6 项优化
22
+
23
+ | 编号 | 优化 | 实现与边界 |
24
+ | --- | --- | --- |
25
+ | O1 | 减少保存账本时的主线程停顿 | 日常保存交给串行工作线程,继续使用跨进程锁和原子替换;显式保存及卸载等待同一事务。文件内保存有界提交回执,处理“已写入但确认消息丢失”,避免重复入账。 |
26
+ | O2 | 分离套餐归属与额度查询开关 | 首次读取旧配置时保存既有自动套餐集合;随后开关查询或显示不再改变历史 API/Plan 归属。需要改变归属时,显式修改提供商或模型的计费分类。 |
27
+ | O3 | 辅助日志轮转、归档与增量发现 | billion-context 调用日志和原生搜索日志达到 8 MiB 后轮转。只压缩封存且至少 5 分钟未变化的分段,每小时执行受限归档;历史读取透明支持 gzip。变更标记、文件游标和定期清单共同发现增量。stream/分组元数据保留,历史文件不自动删除。 |
28
+ | O4 | 统一网络读取边界 | 余额、套餐、汇率和价格页面复用有界流式读取、解压输出限制、正文超时及取消清理;不依赖 `Content-Length` 判断实际体积。各接口保留相应大小限制。 |
29
+ | O5 | 集中计费计算并补充边界回归 | 抽出共享 Token 总量函数;新增日志、乱序去重、零明细补记、重启恢复、跨宿主后台保存、归档及发布命令的行为测试。后台预热与去重缓存设置容量上限。 |
30
+ | O6 | 对齐网络声明与实现 | 补充 `chatgpt.com` 权限声明,说明 Codex 额度查询及 MiniMax 用户配置的可信 HTTPS 来源;自定义来源仍拒绝重定向。 |
31
+
32
+ ### 保留 v1.9.27 的兼容修复
33
+
34
+ - **pi-ai Codex:**直接读取 DSH 内置 pi-ai OAuth 登录的额度,自动回退并兼容只有周额度的账号;超时后释放等待,凭据更新后可重试。
35
+ - **重载与卸载:**直接重载宿主入口后恢复 RPC 和 billion-context 观察器,卸载时取消额度请求。
36
+ - **billion-context:**代理用量缺失但宿主有效时按流补记,保留独立压缩费用;修复旧版错误覆盖状态,无法明确拆分的混合用量保留原记录并提示核对。兼容基线更新至 0.1.204。
37
+ - **Codex 连接插件:**验证 dsh-codex-subscription 3.1.4 的实际发布包。
38
+ - **Antigravity:**过滤占位项目 ID,逐模型保留 Gemini 额度和重置时间,取消后停止回退。
39
+ - **既有布局修复:**今日消费金额与余额首行对齐,WorkBuddy 紧凑布局标题横跨整张卡片,避免余额被截断。
40
+
41
+ ### 验证与性能
42
+
43
+ - 完整回归通过;覆盖真实 DSH 宿主会话读取、RPC 生命周期、8 个并发账本进程、重启及提交确认丢失恢复。
44
+ - 本机 Windows / Node.js 24 的 10,000 行合成账本后台保存样本:主线程最大延迟约 **40 ms**,完整事务约 **251 ms**;审查时的旧同步保存样本约 **421 ms**。两者是单次合成测量,不代表生产环境平均值。
45
+ - 独立浏览器测试:冷缓存、无悬停预取、4,800 次调用、3 个会话、两层子代理,浏览器 CPU 限速 4 倍;弹窗约 **115 ms** 出现,约 **760 ms** 显示完整真实统计,未发起外部请求。
46
+ - 测试使用临时账本及模拟上游响应,没有查询真实供应商账号。纯外观调整不属于本次审查范围。
47
+
48
+ ### 升级与历史数据
49
+
50
+ 通过插件市场更新,或在终端运行:
51
+
52
+ ```powershell
53
+ dsh plugin --profile web add dsh-cost-meter@1.9.28
54
+ ```
55
+
56
+ 更新后完全退出并重启 DSH。首次启动会利用现存会话记录恢复套餐小时统计,并清理旧估算样本;没有可读历史时保留恢复状态等待后续读取。此恢复不按新单价重算历史金额。小时桶按小时近似,窗口边界不足一小时仍存在粒度误差;旧版已经裁剪且没有可回放日志的数据无法凭空补全。
57
+
58
+ ### 贡献署名
59
+
60
+ - [@Sieuno](https://github.com/Sieuno):在 [#382](https://github.com/Han-1413141/dsh-cost-meter/issues/382) 独立复现 billion-context 用量漏记。
61
+ - [@Oct1AtJoe](https://github.com/Oct1AtJoe):在 [PR #381](https://github.com/Han-1413141/dsh-cost-meter/pull/381) 提交 Antigravity 项目与 Gemini 额度支持代码;合并前补充审查修正。
62
+ - [@SternChiri](https://github.com/SternChiri):在 [#377](https://github.com/Han-1413141/dsh-cost-meter/issues/377) 提出对齐反馈,触发 WorkBuddy 紧凑布局检查。报告者已撤回原先的“文字左对齐”定位;最终修复依据浏览器中实际的标题宽度与余额位置。
63
+ - [#379](https://github.com/Han-1413141/dsh-cost-meter/issues/379)、[#380](https://github.com/Han-1413141/dsh-cost-meter/issues/380) 为自动兼容监控记录,对应发布包已纳入验证。
64
+
65
+ ## English
66
+
67
+ This release fixes all nine defects from the code review and implements six billing, persistence, network and test improvements. It retains the pi-ai Codex, billion-context, Antigravity and OpenRouter cooldown changes published in v1.9.27.
68
+
69
+ ### Correctness
70
+
71
+ - Read complete zstd frames spanning multiple input chunks. Bound actual decompressed bytes, ordinary JSONL, line size and event counts; skip large packed text blocks without dropping later usage.
72
+ - Deduplicate out-of-order requests by absolute request-time distance, retaining bounded candidates across live billing, replay and host projection.
73
+ - Recover valid host usage once per completed billion-context stream even when the proxy journal has no call rows; retain restart and archived-history recovery.
74
+ - Count reasoning as an output breakdown rather than adding it twice to token totals. Use provider reset times and explicit durations for quota estimates, with a 35-day hourly history.
75
+ - Reject null, empty and boolean gateway percentages. Preserve explicit quota-exhausted signals.
76
+ - Separate release-note generation from publication. Verify local and remote tags against the release commit; never move an existing mismatched version tag.
77
+
78
+ ### Persistence and integration
79
+
80
+ - Save routine ledger transactions in a worker while retaining atomic replacement, cross-process locking, shutdown barriers and recovery when a commit acknowledgement is lost.
81
+ - Persist the automatic Plan provider set on configuration migration. Quota query/display switches no longer reclassify historical API spending; explicit provider/model billing settings control attribution.
82
+ - Rotate billion-context and native-search journals at 8 MiB. Compress only sealed, unchanged segments, preserve all history, and combine change markers, cursors and periodic inventory checks. Stream/group metadata remains available; no history is automatically deleted.
83
+ - Share bounded HTTP body reading, decoded-output limits, timeouts and cancellation across balance, quota, exchange-rate and pricing requests. Centralize token totals, bound caches and add behavior-based regression tests.
84
+ - Document actual MiniMax custom HTTPS origins and declare `chatgpt.com` for native Codex quota queries.
85
+ - Read native DSH pi-ai OAuth quotas, restore observers/RPC after direct reload, preserve per-model Antigravity quotas, and ship the pending Today/Balance and compact WorkBuddy alignment fixes. Contributor links are listed above.
86
+
87
+ ### Validation and upgrade
88
+
89
+ The full regression suite passed, including real-host session/RPC lifecycles, concurrent ledger writers, restart, lost-acknowledgement recovery and archived journals. A local 10,000-row synthetic background save recorded about 40 ms maximum main-loop delay and 251 ms total duration. A separate cold-browser test with 4,800 calls and nested subagents displayed full totals in 760 ms under 4× CPU throttling. These are individual synthetic measurements, not production averages or universal latency guarantees.
90
+
91
+ Update with the command above and fully restart DSH. Startup rebuilds derived quota-hour statistics from available session records without repricing historical charges. Hour-boundary estimates retain hourly granularity, and missing historical source data cannot be reconstructed. Tests used temporary ledgers and simulated upstream responses, without querying live supplier accounts.