dsh-cost-meter 1.9.9 → 1.9.11
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 +8 -8
- package/README.zh-CN.md +8 -8
- package/docs/update-notes-1.9.10.md +64 -0
- package/docs/update-notes-1.9.11.md +41 -0
- package/docs/update-notes-1.9.9.md +37 -37
- package/lib/backfill.js +24 -8
- package/lib/client.display.js +2 -2
- package/lib/client.js +5 -5
- package/lib/client.pricing.js +1 -1
- package/lib/client.statistics.js +8 -8
- package/lib/ledger-lock-owner.js +34 -6
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -10,20 +10,20 @@ Community and feedback: [Join the WeChat group →](#community). The WeChat grou
|
|
|
10
10
|
|
|
11
11
|
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 170+ model-ID catalog with auto-matching) · mainstream Coding Plan quota queries & display (Anthropic / Z.ai / MiniMax / Kimi / OpenRouter / SiliconFlow / CommandCode / SCNet / Volcano Ark / Qwen / Xiaomi MiMo / Factory Droid) 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) · subscription plugin compatibility (Codex / ChatGPT subscription plans) · mobile layout (dsh-pocket) · quota strip above the input box (budget / Go / coding-plan usage in one row, toggleable)
|
|
12
12
|
|
|
13
|
-
[](https://github.com/Han-1413141/dsh-cost-meter)
|
|
14
14
|
|
|
15
15
|
**Minimum supported host: DSH 0.2.0.** The plugin declares the floor in `engines.dsh`, the host's admission gate for plugins, and no longer supports any DSH 0.1.x release; the adaptation target is the npm `next` release **0.2.1-rc.2**. Exact ranges and how the host reads them: [compatibility declaration](docs/dsh-0.2.1-compatibility.md#english).
|
|
16
16
|
|
|
17
17
|
Supports [official Search/Fetch request fees](docs/web-request-fees.md#english), separately from model tokens.
|
|
18
18
|
|
|
19
|
-
**v1.9.
|
|
19
|
+
**v1.9.11** unifies component visibility switches, right-aligns sidebar amounts, updates official Flash labels to V4.1, and verifies billion-context 0.1.201 and dsh-codex-subscription 3.1.1 compatibility.
|
|
20
20
|
|
|
21
21
|
Configuration and verification: [OpenDesign queries](docs/opendesign-billing.md), [dynamic ports / LAN / WorkBuddy2API setup](docs/custom-balance-sources.md), and [opacity fixes with performance measurements](docs/performance-2026-10-18.md).
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
Desktop users: follow the [Desktop installation instructions](docs/install-troubleshooting.md#desktop-安装与更新) for the application's own CLI and `desktop` Profile.
|
|
25
25
|
|
|
26
|
-
Release notes: [v1.9.
|
|
26
|
+
Release notes: [v1.9.11](docs/update-notes-1.9.11.md#english). Fully restart DSH after updating.
|
|
27
27
|
|
|
28
28
|
Host records inside the declared range, and the earlier 0.1.x history, are in the [compatibility record](docs/host-compatibility.md); the per-release list lives in `package.json` (`dsh.compatibility.dshReleases`).
|
|
29
29
|
|
|
@@ -341,22 +341,22 @@ On Node.js 20, use `npm install -g pnpm@10` instead. See [pnpm installation and
|
|
|
341
341
|
dsh plugin --profile web add dsh-cost-meter
|
|
342
342
|
```
|
|
343
343
|
|
|
344
|
-
**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.
|
|
344
|
+
**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.11`** — review the script before running):
|
|
345
345
|
|
|
346
346
|
```powershell
|
|
347
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.
|
|
347
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.11/install.ps1 | iex
|
|
348
348
|
```
|
|
349
349
|
|
|
350
350
|
**Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
|
|
351
351
|
|
|
352
352
|
```sh
|
|
353
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.
|
|
353
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.11
|
|
354
354
|
```
|
|
355
355
|
|
|
356
356
|
Without git, use the GitHub tag archive:
|
|
357
357
|
|
|
358
358
|
```sh
|
|
359
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.
|
|
359
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.11.tar.gz
|
|
360
360
|
```
|
|
361
361
|
|
|
362
362
|
After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
|
|
@@ -421,7 +421,7 @@ Workarounds:
|
|
|
421
421
|
|
|
422
422
|
```yaml
|
|
423
423
|
minimumReleaseAgeExclude:
|
|
424
|
-
- dsh-cost-meter@1.9.
|
|
424
|
+
- dsh-cost-meter@1.9.11
|
|
425
425
|
```
|
|
426
426
|
|
|
427
427
|
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
|
@@ -10,20 +10,20 @@
|
|
|
10
10
|
|
|
11
11
|
本会话费用 · 当日费用 · OpenCode Go 订阅额度显示 · 预算与已用百分比 · 官方账户余额 · 自定义 Provider 余额查询(可配任意 HTTP 端点) · 余额三段进度条 · 历史记录 · 峰谷计价时段显示(UTC 01:00–04:00、06:00–10:00 为峰时段;周末与中国法定假日全天按谷价,分别标注) · 峰/谷切换前弹窗与系统通知提醒(位置/提前量/提醒类型可配) · 官方价格一键同步 · 类 Codex Token 用量热图 · 多厂商多模型价格计费(内置 170+ 模型 ID 价格目录与自动匹配) · 主流 Coding Plan 额度查询与显示(Anthropic / Z.ai / MiniMax / Kimi / OpenRouter / SiliconFlow / CommandCode / SCNet / 火山方舟 / 千问 / 小米 MiMo 十一家,含 Volcano Ark AK/SK 签名与 MiMo 控制台 Cookie 查询) · Plan/API 双轨计费(订阅额度与按量金额分离统计,每 1% 额度与满窗的 token/等值金额估算及日/周/月曲线) · 订阅插件兼容(Codex / ChatGPT 订阅) · 手机端适配(dsh-pocket) · 输入框上方额度横条(预算/Go/Coding Plan 用量一条横排显示,可开关)
|
|
12
12
|
|
|
13
|
-
[](https://github.com/Han-1413141/dsh-cost-meter)
|
|
14
14
|
|
|
15
15
|
**最低支持宿主:DSH 0.2.0。** 插件把下限声明在 `engines.dsh`(宿主准入插件的闸门),不再支持任何 DSH 0.1.x 版本;本轮适配目标为 npm `next` 标签的 **0.2.1-rc.2**。具体范围与宿主的读取方式见[兼容声明](docs/dsh-0.2.1-compatibility.md#中文)。
|
|
16
16
|
|
|
17
17
|
新增 [DeepSeek Search/Fetch API 次数费](docs/web-request-fees.md#中文),只计有结果的成功请求,并将网页抓取独立分类。
|
|
18
18
|
|
|
19
|
-
**v1.9.
|
|
19
|
+
**v1.9.11** 统一组件显示开关与侧栏金额对齐,更新官方 V4.1 Flash 名称,并验证 billion-context 0.1.201 与 dsh-codex-subscription 3.1.1 兼容。
|
|
20
20
|
|
|
21
21
|
配置与验证:[OpenDesign 查询说明](docs/opendesign-billing.md)、[随机端口 / 局域网 / WorkBuddy2API 配置](docs/custom-balance-sources.md)、[透明度修复与性能测量](docs/performance-2026-10-18.md)。
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
桌面端用户请按 [Desktop 安装说明](docs/install-troubleshooting.md#desktop-安装与更新),使用应用自带的 CLI 和 `desktop` Profile。
|
|
25
25
|
|
|
26
|
-
更新说明:[v1.9.
|
|
26
|
+
更新说明:[v1.9.11](docs/update-notes-1.9.11.md#中文)。更新后完全重启 DSH。
|
|
27
27
|
|
|
28
28
|
声明范围内的宿主记录与此前的 0.1.x 历史见[兼容记录](docs/host-compatibility.md);逐版本清单在 `package.json` 的 `dsh.compatibility.dshReleases`。
|
|
29
29
|
|
|
@@ -341,22 +341,22 @@ Node.js 20 请改用 `npm install -g pnpm@10`。版本要求见 [pnpm 官方安
|
|
|
341
341
|
dsh plugin --profile web add dsh-cost-meter
|
|
342
342
|
```
|
|
343
343
|
|
|
344
|
-
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.9.
|
|
344
|
+
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.9.11`**,建议先下载审阅再运行):
|
|
345
345
|
|
|
346
346
|
```powershell
|
|
347
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.
|
|
347
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.11/install.ps1 | iex
|
|
348
348
|
```
|
|
349
349
|
|
|
350
350
|
**或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
|
|
351
351
|
|
|
352
352
|
```sh
|
|
353
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.
|
|
353
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.11
|
|
354
354
|
```
|
|
355
355
|
|
|
356
356
|
没有 git 时可用 GitHub tag 打包直链:
|
|
357
357
|
|
|
358
358
|
```sh
|
|
359
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.
|
|
359
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.11.tar.gz
|
|
360
360
|
```
|
|
361
361
|
|
|
362
362
|
安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
|
|
@@ -421,7 +421,7 @@ DSH **0.2.1-rc.1 / 0.2.1-rc.2** 宿主自带 pnpm **11.28.5**,默认启用内
|
|
|
421
421
|
|
|
422
422
|
```yaml
|
|
423
423
|
minimumReleaseAgeExclude:
|
|
424
|
-
- dsh-cost-meter@1.9.
|
|
424
|
+
- dsh-cost-meter@1.9.11
|
|
425
425
|
```
|
|
426
426
|
|
|
427
427
|
3. 仅本次操作用 CLI 透传 pnpm 参数:`dsh plugin --profile desktop remove dsh-cost-meter --config.minimum-release-age=0`;若只是 lockfile 校验阶段失败,可改用 `--trust-lockfile`。这两个参数已在本机 pnpm 11.28.5 临时 Profile 上实测可用。
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# v1.9.10
|
|
2
|
+
|
|
3
|
+
## 中文
|
|
4
|
+
|
|
5
|
+
### 费用明细首次打开提速
|
|
6
|
+
|
|
7
|
+
同一次费用计算中,重复使用模型价格匹配和 Plan/API 分类结果;每次调用只解析一次汇率。缓存只在本次计算内存在,遇到不同的历史价格表、覆盖配置或匹配方式会重新查价,不跨请求复用旧金额。
|
|
8
|
+
|
|
9
|
+
使用真实费用按钮、按需加载的统计客户端和真实后端计算,在 Windows 本机顺序对比修改前后:
|
|
10
|
+
|
|
11
|
+
| 条件/结果 | 修改前 | 修改后 |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| 调用记录 | 4,800 次,主会话与两层嵌套子代理 | 相同 |
|
|
14
|
+
| 缓存与预加载 | 冷缓存,无悬停预加载 | 相同 |
|
|
15
|
+
| 浏览器 CPU | 4 倍限速 | 相同 |
|
|
16
|
+
| 弹窗打开 | 67 ms | 66 ms |
|
|
17
|
+
| 实际费用、调用数、Token 与缓存命中率显示 | 4,533 ms | 835 ms |
|
|
18
|
+
| 费用合计 | $2.79144 | $2.79144 |
|
|
19
|
+
|
|
20
|
+
1 秒检查同时覆盖弹窗和真实数字,不以加载动画代替完成。该场景已加入浏览器 CI;这是上述数据规模和本机环境的测量结果。更大记录量、较慢磁盘或远程宿主的完成时间仍取决于实际环境。
|
|
21
|
+
|
|
22
|
+
### 午夜黑皮肤的两处控件
|
|
23
|
+
|
|
24
|
+
感谢 [@transmerger](https://github.com/transmerger) 在 [#258 的最新反馈](https://github.com/Han-1413141/dsh-cost-meter/issues/258#issuecomment-6259570677) 提供“今日”按钮和显示设置下拉菜单截图。
|
|
25
|
+
|
|
26
|
+
- 模型花费的选中按钮使用主题正文色和淡色背景,未悬停时也能辨认,不再让文字与蓝色选中背景接近。
|
|
27
|
+
- 费用插件的原生下拉选项明确使用不透明主题背景和主题文字,允许原生菜单适应系统深浅色;解除浅色宿主对深色皮肤下拉菜单的配色限制。
|
|
28
|
+
- 浏览器回归加载 [Dream Skin 午夜黑的固定版本颜色定义](https://github.com/RevolutionLA/dsh-dream-skin/blob/3829506d17901609f8e558587f40a37d90d4219a/lib/client.js),覆盖浅色宿主与深色系统组合、全部组件选项、实际侧栏按钮和其他插件控件隔离;原有浅色、深色、窄屏与交互检查继续保留。
|
|
29
|
+
|
|
30
|
+
### Windows 账本锁启动优化与版本兼容
|
|
31
|
+
|
|
32
|
+
感谢 [@Oct1AtJoe](https://github.com/Oct1AtJoe) 在 [PR #327](https://github.com/Han-1413141/dsh-cost-meter/pull/327) 定位同步 PowerShell 启动造成的阻塞,并提供原始优化实现。
|
|
33
|
+
|
|
34
|
+
- 无锁竞争时,Windows 直接使用 Node 启动时固定的毫秒时间写入锁身份,不启动 PowerShell。仅在确实需要判断旧版原生锁或其他进程身份时查询原生启动时间,并缓存查询结果。
|
|
35
|
+
- 修正第一处兼容问题:毫秒锁身份使用 v2 元数据,与旧版 ticks 身份区分。旧版遇到仍活跃的新版持有者时继续等待,不会误删锁后同时写账本。
|
|
36
|
+
- 修正第二处兼容问题:比较前将 Windows ticks 换算成毫秒,能够识别 PID 已被其他进程复用的旧锁,不再因为单位不同一律拒绝回收。仅当旧启动时间明确早于当前进程且超过两秒误差范围时回收;原生 ticks 之间仍精确比较。
|
|
37
|
+
- 未知版本、损坏或未写完的身份、无法读取原生身份等情况,不会仅因锁文件较旧而删除活动锁。保留空文件旧锁、死亡进程和 Linux 原生身份的既有处理。
|
|
38
|
+
- 此次仅调整锁元数据,账本数据格式和历史金额不变,不触发费用重算。
|
|
39
|
+
|
|
40
|
+
验证覆盖冻结的 v1.9.9 锁读写器与当前实现、真实 Windows 新旧持有进程和竞争进程、仍活跃但文件时间较旧的锁、文件时间较新的 PID 复用旧锁、当前 PID 的原生身份、死亡进程回收,以及启动零 PowerShell 调用和查询失败。
|
|
41
|
+
|
|
42
|
+
启动时间依据:[Node.js `performance.timeOrigin`](https://nodejs.org/api/perf_hooks.html#performancetimeorigin)。
|
|
43
|
+
|
|
44
|
+
更新后完全退出 DSH(包括托盘)再打开。
|
|
45
|
+
|
|
46
|
+
## English
|
|
47
|
+
|
|
48
|
+
Conversation details now reuse model-price resolution and Plan/API classification within one calculation, and resolve FX once per call. Historical catalog and override identities remain separate; no old amounts are reused across requests.
|
|
49
|
+
|
|
50
|
+
In a Windows cold-click browser comparison with 4,800 calls, two nested subagent levels, no hover warming and 4× browser CPU throttling, real totals painted in **835 ms**, down from **4,533 ms**. The dialog opened in 66 ms. Both runs retained all 4,800 calls and the same $2.79144 total. CI checks the one-second budget for both the dialog and real metrics; larger data sets and remote or slower hosts remain environment-dependent.
|
|
51
|
+
|
|
52
|
+
Midnight skin fixes make the selected Today model-cost button readable without hover and give native display-setting options opaque theme colors, without changing unrelated plugin controls. Thanks to [@transmerger](https://github.com/transmerger) for the [latest #258 screenshots](https://github.com/Han-1413141/dsh-cost-meter/issues/258#issuecomment-6259570677).
|
|
53
|
+
|
|
54
|
+
Thanks to [@Oct1AtJoe](https://github.com/Oct1AtJoe) for identifying blocking PowerShell startup and contributing the original optimization in [PR #327](https://github.com/Han-1413141/dsh-cost-meter/pull/327).
|
|
55
|
+
|
|
56
|
+
- Uncontended Windows ledger writes use Node's fixed startup origin without launching PowerShell. Native identities are queried lazily for older native locks or other processes and cached.
|
|
57
|
+
- Millisecond identities use v2 lock metadata. Older readers preserve live new locks instead of confusing milliseconds with native ticks and allowing concurrent writers.
|
|
58
|
+
- Native ticks are normalized before comparison with milliseconds, allowing recovery after PID reuse. Estimated times must be more than two seconds earlier than the current birth; native-to-native comparisons retain exact precision.
|
|
59
|
+
- Unknown or incomplete identities and failed OS queries preserve live locks. Existing empty-file, dead-process and Linux handling remain supported.
|
|
60
|
+
- Ledger data formats and historical amounts stay unchanged; no repricing is triggered.
|
|
61
|
+
|
|
62
|
+
Regression coverage includes frozen v1.9.9 readers/writers, actual Windows old/new process exclusion, live locks with old file times, reused PIDs with recent file times, native self identities, dead holders, failed probes and zero PowerShell calls on normal owner creation.
|
|
63
|
+
|
|
64
|
+
Fully quit DSH, including its tray process, and reopen after updating.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# v1.9.11
|
|
2
|
+
|
|
3
|
+
## 中文
|
|
4
|
+
|
|
5
|
+
### 显示设置统一
|
|
6
|
+
|
|
7
|
+
在“设置 → 费用 → 显示”中选择组件后,右侧固定显示“显示此组件”开关。侧栏、输入区和会话内容使用相同顺序:选择组件、开关、组件选项。移除预览上方重复的预算、今日用量、峰谷时段和模型花费勾选项;详细选项的开关也统一靠右。
|
|
8
|
+
|
|
9
|
+
显示位置只选择侧栏、设置页等位置,关闭由组件开关控制。隐藏侧栏额度保留设置页查询和凭据;切换显示不启用未配置的额度查询。输入区从关闭状态单独开启一项时,不再顺带显示其他额度条。侧栏布局放在组件选项下方,可展开切换简洁、标准和紧凑样式;窄窗口自动改为上下排列。
|
|
10
|
+
|
|
11
|
+
### 侧栏金额与官方 Flash 名称
|
|
12
|
+
|
|
13
|
+
- 今日费用和模型花费收起摘要的金额、模型数靠右显示,标准、紧凑和简洁布局均保持标签与数值分开。
|
|
14
|
+
- 官方提供商的 `deepseek-flash`、`deepseek-v4-flash`、`deepseek-v4-flash-vision-exp`、`deepseek-v4.1-flash` 统一显示为 **DeepSeek V4.1 Flash**,涵盖本轮费用、原生搜索、逐次调用、模型排行和费用图表。原始调用 ID、价格匹配和历史金额保留,逐次调用悬停仍可查看原始 ID。
|
|
15
|
+
- 只归一化官方提供商名称,第三方提供商的模型名称保持原样。模型依据:[DeepSeek 官方模型与定价说明](https://api-docs.deepseek.com/quick_start/pricing/)。
|
|
16
|
+
|
|
17
|
+
### 两个上游兼容监控 issue
|
|
18
|
+
|
|
19
|
+
针对 GitHub Actions 机器人生成的 [#329](https://github.com/Han-1413141/dsh-cost-meter/issues/329) 和 [#330](https://github.com/Han-1413141/dsh-cost-meter/issues/330),执行实际 npm 发布包的兼容回归后更新监控基线。两版均能使用现有接入,不需要用户安装额外兼容包。
|
|
20
|
+
|
|
21
|
+
- **billion-context 0.1.201**:验证新版 `forceDirect` 绕过自定义传输后仍只记录一次费用;原生回退先恢复请求内容,无法恢复而在本地拒绝的请求不生成计费回执。原有压缩、重试、子代理、四种协议和重启去重继续验证。CI 增加 0.1.201,保留旧版覆盖。
|
|
22
|
+
- **dsh-codex-subscription 3.1.1**:使用发布包中的额度解析器、RPC 处理器、传输注册和真实 DSH 请求格式,验证周额度、5h+周额度、刷新、重置时间、未登录和异常数据回退。仅返回周额度的账户不补造 5h。
|
|
23
|
+
|
|
24
|
+
上述兼容及界面测试使用本地合成数据,不读取真实账户凭据、不请求模型,也不产生模型费用。监控继续检查三个插件,未来接口变化仍会创建或更新 issue。
|
|
25
|
+
|
|
26
|
+
更新后完全退出 DSH(包括托盘)再打开。
|
|
27
|
+
|
|
28
|
+
## English
|
|
29
|
+
|
|
30
|
+
Display settings now provide the same right-hand **Show this component** switch for every sidebar, composer and conversation component. Redundant checkboxes above the preview are removed, boolean options align to the right, and placement is separate from visibility. Sidebar layout choices expand below component options; narrow windows stack the preview and controls. Enabling one item from a disabled composer strip preserves the visibility of its siblings.
|
|
31
|
+
|
|
32
|
+
Today amounts and collapsed model-cost summaries align to the right in all sidebar layouts. Official Flash aliases display as **DeepSeek V4.1 Flash** throughout turn details, native search, calls, rankings and charts. Recorded identifiers, historical prices and amounts stay intact; individual-call tooltips retain the raw identifier. Third-party model names stay unchanged. See the [official DeepSeek documentation](https://api-docs.deepseek.com/quick_start/pricing/).
|
|
33
|
+
|
|
34
|
+
Published-package regressions resolve the GitHub Actions compatibility reports [#329](https://github.com/Han-1413141/dsh-cost-meter/issues/329) and [#330](https://github.com/Han-1413141/dsh-cost-meter/issues/330):
|
|
35
|
+
|
|
36
|
+
- **billion-context 0.1.201**: the new direct transport path remains metered exactly once; native fallback restores the body before sending, and locally refused requests create no billable receipt. Existing retry, compaction, subagent, protocol and restart checks remain covered.
|
|
37
|
+
- **dsh-codex-subscription 3.1.1**: actual published quota parsing and RPC code works with weekly-only and dual-window responses, manual refresh, reset times and failure fallback. Weekly-only accounts gain no fabricated 5h window.
|
|
38
|
+
|
|
39
|
+
Both releases work with the existing automatic integration. No companion installation is required. Monitoring baselines and CI package coverage are updated after these checks. Tests use local synthetic data without account credentials or model requests.
|
|
40
|
+
|
|
41
|
+
Fully quit DSH, including its tray process, and reopen after updating.
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
# v1.9.9
|
|
2
|
-
|
|
3
|
-
## 中文
|
|
4
|
-
|
|
5
|
-
### OpenCode Go 凭据读取与 401 提示
|
|
6
|
-
|
|
7
|
-
感谢 [@weimingyu9312](https://github.com/weimingyu9312) 在 [#325](https://github.com/Han-1413141/dsh-cost-meter/issues/325) 报告 Tauri 桌面环境刷新 Go 额度返回 401。
|
|
8
|
-
|
|
9
|
-
- 单独保存 Key:在 **设置 → 费用 → 额度 → OpenCode Go** 展开配置,编辑凭据并保存,再点击刷新。复制了 `Bearer Key` 时只保留一层 Bearer 认证头;整段请求头、内部空白等无效输入会在本地提示修正。
|
|
10
|
-
- 自动读取:继续按照专用引用、官方 Go 模型路由引用、兼容环境变量、OpenCode 登录态、遗留配置的顺序读取。新增识别 `OPENCODE_AUTH_CONTENT` 和 `XDG_DATA_HOME/opencode/auth.json`,当前有效登录数据优先于旧文件;显式数据目录的登录文件缺失或损坏时不再回退旧目录,退出登录后也不再复活旧文件中的 Key。
|
|
11
|
-
- 401 明确提示当前 Key 未通过认证,不再认定没有订阅。只有 403 且官方响应类型为 `EntitlementError` 时,才提示该 Key 所属工作区没有 Go 权限;其他访问拒绝单独显示。
|
|
12
|
-
- 认证失败按照刷新间隔缓存,避免重复请求。手动刷新、保存或清除专用凭据可立即重试;不会在认证失败后偷偷换成另一个账号的 Key。
|
|
13
|
-
- 费用插件保存和清除只操作自己的 `OPENCODE_GO_API_KEY`,不修改模型路由共用凭据。请求固定发送到官方额度 GET 接口,不发模型请求;空窗口不会被当作 0% 用量。
|
|
14
|
-
|
|
15
|
-
另外在与报告一致的 DSH `0.2.0-rc.2` 内核中,使用真实 Cordis Loader、凭据库和 Typert RPC 验证保存、清除、刷新、401 后恢复及环境/目录自动读取,全部通过;该集成测试已加入 CI 的 `0.2.0-rc.2` 与 `0.2.1-rc.2` 两个宿主。
|
|
16
|
-
|
|
17
|
-
本地测试覆盖单独保存和自动读取两种流程,以及轮换、清除、环境登录态覆盖、数据目录、401/403、缓存、恢复与脱敏。测试使用隔离凭据和官方响应结构,不代表已经取得报告者在其 Tauri 环境的复测结果;原 issue 保留等待该环境确认。
|
|
18
|
-
|
|
19
|
-
依据:[OpenCode 登录态读取源码](https://github.com/anomalyco/opencode/blob/fc7e4cf93e660ad5ddabb0c48ecc99e934ebfe95/packages/opencode/src/auth/index.ts)、[数据目录源码](https://github.com/anomalyco/opencode/blob/fc7e4cf93e660ad5ddabb0c48ecc99e934ebfe95/packages/core/src/global.ts)、[官方 Go 文档](https://opencode.ai/docs/go/)。
|
|
20
|
-
|
|
21
|
-
更新后完全退出 DSH(包括托盘)再打开。
|
|
22
|
-
|
|
23
|
-
## English
|
|
24
|
-
|
|
25
|
-
Thanks to [@weimingyu9312](https://github.com/weimingyu9312) for reporting an HTTP 401 when refreshing Go quotas in a Tauri desktop environment in [#325](https://github.com/Han-1413141/dsh-cost-meter/issues/325).
|
|
26
|
-
|
|
27
|
-
- Both dedicated keys and automatic discovery are covered. A pasted Bearer prefix no longer creates a duplicate authorization prefix; invalid full headers are rejected locally.
|
|
28
|
-
- Automatic discovery now reads `OPENCODE_AUTH_CONTENT` and `XDG_DATA_HOME/opencode/auth.json`. Current sign-in data takes precedence over older files, including an empty login set after logout. An explicit data directory never falls back to an older directory when its login file is missing or corrupt. Existing dedicated-key and official model-route priority is preserved.
|
|
29
|
-
- HTTP 401 is reported as failed authentication, not a missing subscription. Only an explicit 403 `EntitlementError` is classified as missing Go workspace entitlement; other access-control failures have a separate message.
|
|
30
|
-
- Authentication failures respect the refresh interval. Manual refresh and saving or clearing a dedicated credential can retry immediately. A failed credential does not silently switch the query to another account.
|
|
31
|
-
- Shared model credentials remain unchanged. Queries use the fixed official GET endpoint, make no inference calls and do not turn missing usage windows into zero usage.
|
|
32
|
-
|
|
33
|
-
An actual DSH 0.2.0-rc.2 kernel also passes the real Cordis loader, local credential store and Typert RPC save/clear/refresh, 401 recovery and env/XDG discovery checks. CI runs the integration test on both 0.2.0-rc.2 and 0.2.1-rc.2.
|
|
34
|
-
|
|
35
|
-
Local service tests cover both credential flows, rotation, clearing, auth overrides, paths, 401/403 classification, caching, recovery and redaction with isolated credentials. The reporter's Tauri environment has not yet been retested, so the original issue remains open for confirmation.
|
|
36
|
-
|
|
37
|
-
Fully quit DSH, including its tray process, and reopen after updating.
|
|
1
|
+
# v1.9.9
|
|
2
|
+
|
|
3
|
+
## 中文
|
|
4
|
+
|
|
5
|
+
### OpenCode Go 凭据读取与 401 提示
|
|
6
|
+
|
|
7
|
+
感谢 [@weimingyu9312](https://github.com/weimingyu9312) 在 [#325](https://github.com/Han-1413141/dsh-cost-meter/issues/325) 报告 Tauri 桌面环境刷新 Go 额度返回 401。
|
|
8
|
+
|
|
9
|
+
- 单独保存 Key:在 **设置 → 费用 → 额度 → OpenCode Go** 展开配置,编辑凭据并保存,再点击刷新。复制了 `Bearer Key` 时只保留一层 Bearer 认证头;整段请求头、内部空白等无效输入会在本地提示修正。
|
|
10
|
+
- 自动读取:继续按照专用引用、官方 Go 模型路由引用、兼容环境变量、OpenCode 登录态、遗留配置的顺序读取。新增识别 `OPENCODE_AUTH_CONTENT` 和 `XDG_DATA_HOME/opencode/auth.json`,当前有效登录数据优先于旧文件;显式数据目录的登录文件缺失或损坏时不再回退旧目录,退出登录后也不再复活旧文件中的 Key。
|
|
11
|
+
- 401 明确提示当前 Key 未通过认证,不再认定没有订阅。只有 403 且官方响应类型为 `EntitlementError` 时,才提示该 Key 所属工作区没有 Go 权限;其他访问拒绝单独显示。
|
|
12
|
+
- 认证失败按照刷新间隔缓存,避免重复请求。手动刷新、保存或清除专用凭据可立即重试;不会在认证失败后偷偷换成另一个账号的 Key。
|
|
13
|
+
- 费用插件保存和清除只操作自己的 `OPENCODE_GO_API_KEY`,不修改模型路由共用凭据。请求固定发送到官方额度 GET 接口,不发模型请求;空窗口不会被当作 0% 用量。
|
|
14
|
+
|
|
15
|
+
另外在与报告一致的 DSH `0.2.0-rc.2` 内核中,使用真实 Cordis Loader、凭据库和 Typert RPC 验证保存、清除、刷新、401 后恢复及环境/目录自动读取,全部通过;该集成测试已加入 CI 的 `0.2.0-rc.2` 与 `0.2.1-rc.2` 两个宿主。
|
|
16
|
+
|
|
17
|
+
本地测试覆盖单独保存和自动读取两种流程,以及轮换、清除、环境登录态覆盖、数据目录、401/403、缓存、恢复与脱敏。测试使用隔离凭据和官方响应结构,不代表已经取得报告者在其 Tauri 环境的复测结果;原 issue 保留等待该环境确认。
|
|
18
|
+
|
|
19
|
+
依据:[OpenCode 登录态读取源码](https://github.com/anomalyco/opencode/blob/fc7e4cf93e660ad5ddabb0c48ecc99e934ebfe95/packages/opencode/src/auth/index.ts)、[数据目录源码](https://github.com/anomalyco/opencode/blob/fc7e4cf93e660ad5ddabb0c48ecc99e934ebfe95/packages/core/src/global.ts)、[官方 Go 文档](https://opencode.ai/docs/go/)。
|
|
20
|
+
|
|
21
|
+
更新后完全退出 DSH(包括托盘)再打开。
|
|
22
|
+
|
|
23
|
+
## English
|
|
24
|
+
|
|
25
|
+
Thanks to [@weimingyu9312](https://github.com/weimingyu9312) for reporting an HTTP 401 when refreshing Go quotas in a Tauri desktop environment in [#325](https://github.com/Han-1413141/dsh-cost-meter/issues/325).
|
|
26
|
+
|
|
27
|
+
- Both dedicated keys and automatic discovery are covered. A pasted Bearer prefix no longer creates a duplicate authorization prefix; invalid full headers are rejected locally.
|
|
28
|
+
- Automatic discovery now reads `OPENCODE_AUTH_CONTENT` and `XDG_DATA_HOME/opencode/auth.json`. Current sign-in data takes precedence over older files, including an empty login set after logout. An explicit data directory never falls back to an older directory when its login file is missing or corrupt. Existing dedicated-key and official model-route priority is preserved.
|
|
29
|
+
- HTTP 401 is reported as failed authentication, not a missing subscription. Only an explicit 403 `EntitlementError` is classified as missing Go workspace entitlement; other access-control failures have a separate message.
|
|
30
|
+
- Authentication failures respect the refresh interval. Manual refresh and saving or clearing a dedicated credential can retry immediately. A failed credential does not silently switch the query to another account.
|
|
31
|
+
- Shared model credentials remain unchanged. Queries use the fixed official GET endpoint, make no inference calls and do not turn missing usage windows into zero usage.
|
|
32
|
+
|
|
33
|
+
An actual DSH 0.2.0-rc.2 kernel also passes the real Cordis loader, local credential store and Typert RPC save/clear/refresh, 401 recovery and env/XDG discovery checks. CI runs the integration test on both 0.2.0-rc.2 and 0.2.1-rc.2.
|
|
34
|
+
|
|
35
|
+
Local service tests cover both credential flows, rotation, clearing, auth overrides, paths, 401/403 classification, caching, recovery and redaction with isolated credentials. The reporter's Tauri environment has not yet been retested, so the original issue remains open for confirmation.
|
|
36
|
+
|
|
37
|
+
Fully quit DSH, including its tray process, and reopen after updating.
|
package/lib/backfill.js
CHANGED
|
@@ -382,6 +382,24 @@ export async function repairPlanHourBuckets(ledger, sessionsRoot, { nowMs = Date
|
|
|
382
382
|
export function replaySessionRecords(records, config, wantDates = null, collectSamples = false) {
|
|
383
383
|
records = excludeBillionReportedUsage(records)
|
|
384
384
|
const samples = collectSamples ? new Map() : null
|
|
385
|
+
// One replay has fixed classification settings. Price versions can differ per
|
|
386
|
+
// call: reuse a lookup only while its exact catalog and override objects match.
|
|
387
|
+
const enabledPlans = enabledPlanSetOf(config), classifications = new Map(), prices = new Map()
|
|
388
|
+
const resolvePrice = (provider, model, pricing) => {
|
|
389
|
+
const key = JSON.stringify([provider, model]), mode = pricing?.priceMatch === 'exact' ? 'exact' : 'auto'
|
|
390
|
+
let saved = prices.get(key)
|
|
391
|
+
if (!saved || saved.catalog !== pricing?.prices || saved.overrides !== pricing?.priceOverrides || saved.mode !== mode) {
|
|
392
|
+
saved = { catalog: pricing?.prices, overrides: pricing?.priceOverrides, mode,
|
|
393
|
+
value: providerPriceEntryFor(provider, model, pricing?.prices, { mode, overrides: pricing?.priceOverrides }) }
|
|
394
|
+
prices.set(key, saved)
|
|
395
|
+
}
|
|
396
|
+
return saved.value
|
|
397
|
+
}
|
|
398
|
+
const isPlan = (provider, model) => {
|
|
399
|
+
const key = JSON.stringify([provider, model])
|
|
400
|
+
if (!classifications.has(key)) classifications.set(key, billingClassOf(provider, model, config?.planBilling, enabledPlans, config?.prices) === 'plan')
|
|
401
|
+
return classifications.get(key)
|
|
402
|
+
}
|
|
385
403
|
const zeroBuckets = () => ({ input: 0, output: 0, cacheRead: 0, cacheWrite: 0, reasoning: 0, calls: 0, cost: 0, apiCost: 0 })
|
|
386
404
|
const num = value => {
|
|
387
405
|
const n = Number(value)
|
|
@@ -574,10 +592,7 @@ export function replaySessionRecords(records, config, wantDates = null, collectS
|
|
|
574
592
|
const pricedAtMs = !isCompaction && !metered ? stepStarts.get(`${turn}:${step}`) ?? atMs : atMs
|
|
575
593
|
const pricing = pricingConfigAt(config, pricedAtMs, sessionId, `${effectiveProvider}:${sampleModel}`)
|
|
576
594
|
const requestFee = isNativeSearch ? event.data.requestFee : undefined
|
|
577
|
-
const resolved = requestFee ? { priced: true, entry: {}, currency: 'CNY', billingMode: 'flat' } :
|
|
578
|
-
mode: pricing?.priceMatch === 'exact' ? 'exact' : 'auto',
|
|
579
|
-
overrides: pricing?.priceOverrides,
|
|
580
|
-
})
|
|
595
|
+
const resolved = requestFee ? { priced: true, entry: {}, currency: 'CNY', billingMode: 'flat' } : resolvePrice(effectiveProvider, sampleModel, pricing)
|
|
581
596
|
const peak = {
|
|
582
597
|
enabled: ['deepseek-peak', 'utc-peak'].includes(resolved.billingMode) && pricing?.peakEnabled === true,
|
|
583
598
|
effectiveAtMs: Date.parse(pricing?.peakEffectiveAt ?? ''),
|
|
@@ -587,12 +602,13 @@ export function replaySessionRecords(records, config, wantDates = null, collectS
|
|
|
587
602
|
// 官方价格币种为人民币(issue #47)时,DeepSeek 主表计出的成本为人民币,
|
|
588
603
|
// 按展示汇率折算为美元入账——与 store.account() 完全同口径。
|
|
589
604
|
const priced = requestFee ? requestFee.requests * requestFee.rateCny : resolved.priced ? costOf(buckets, resolved.entry, pricedAtMs, peak) : 0
|
|
590
|
-
const
|
|
591
|
-
const
|
|
605
|
+
const fxRates = fxRatesOf(pricing)
|
|
606
|
+
const canonical = usdFromCost(priced, resolved.currency, fxRates.CNY)
|
|
607
|
+
const displayFactor = config._displayCurrency ? fxRates[config._displayCurrency] / config.exchangeRate : 1
|
|
592
608
|
const cost = canonical * displayFactor
|
|
593
609
|
// Plan/API 双轨分类(issue #64):与 store.account() 同一分类器,回放条目
|
|
594
610
|
// 的 apiCost 只含真金白银部分(plan 类金额仅记等值);传 prices 供路由判定。
|
|
595
|
-
const plan = !requestFee &&
|
|
611
|
+
const plan = !requestFee && isPlan(effectiveProvider, sampleModel)
|
|
596
612
|
const apiCost = plan ? 0 : cost
|
|
597
613
|
const providerKey = `${effectiveProvider}:${sampleModel}`
|
|
598
614
|
// 聚合目标按事件分段路由;被替换的旧样本从它当时所在的段扣回(与旧版
|
|
@@ -601,7 +617,7 @@ export function replaySessionRecords(records, config, wantDates = null, collectS
|
|
|
601
617
|
const sample = { key, date, providerKey, buckets, cost, apiCost, ...frozenAmounts(cost, apiCost, pricing), seed: isSeed }
|
|
602
618
|
if (samples) {
|
|
603
619
|
if (prev) samples.delete(prev)
|
|
604
|
-
samples.set(sample, { ...sample, ...(requestFee ? { requestFee } : {}), displayFactor, exchangeRate:
|
|
620
|
+
samples.set(sample, { ...sample, ...(requestFee ? { requestFee } : {}), displayFactor, exchangeRate: fxRates.CNY, fxRates, pricedAtMs, atMs, logSeq: !metered && Number.isSafeInteger(event.seq) && event.seq >= 0 ? event.seq : null, provider: effectiveProvider, model: sampleModel, resolved, peak, plan, kind: isCompaction ? 'compaction' : requestFee ? requestFee.kind : isNativeSearch ? 'search' : 'model',
|
|
605
621
|
...(isBillion ? { metering: event.data.metering } : {}),
|
|
606
622
|
turn: Number.isSafeInteger(event.data?.turn) && event.data.turn >= 0 ? event.data.turn : null,
|
|
607
623
|
step: Number.isSafeInteger(event.data?.step) && event.data.step >= 0 ? event.data.step : null })
|