dsh-cost-meter 1.9.66 → 1.9.68
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 +4 -4
- package/README.zh-CN.md +4 -4
- package/docs/balance-credentials.md +14 -10
- package/docs/billing-currency.md +4 -0
- package/docs/custom-balance-sources.en.md +184 -182
- package/docs/custom-balance-sources.md +240 -238
- package/docs/display-settings.md +77 -69
- package/docs/exchange-rates.md +25 -1
- package/docs/update-notes-1.9.67.md +27 -0
- package/docs/update-notes-1.9.68.md +25 -0
- package/lib/backfill.js +32 -14
- package/lib/balance-accounts.js +56 -0
- package/lib/billing-export.js +6 -3
- package/lib/billing-history.js +13 -6
- package/lib/client.display.js +3 -3
- package/lib/client.js +8 -8
- package/lib/client.plan-settings.js +1 -1
- package/lib/client.pricing.js +3 -3
- package/lib/client.statistics.js +8 -8
- package/lib/currency-catalog.js +64 -0
- package/lib/currency-view.js +7 -1
- package/lib/exchange-rate-refresh.js +20 -8
- package/lib/exchange-rates.js +19 -3
- package/lib/index.js +68 -13
- package/lib/ledger-writer-worker.js +1 -1
- package/lib/store.js +18 -2
- package/lib/typert.host.js +16 -5
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<p align="center">Cost tracking and subscription quotas for DeepSeek Harness</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<a href="https://github.com/Han-1413141/dsh-cost-meter/releases/latest"><img src="https://img.shields.io/badge/version-1.9.
|
|
6
|
+
<a href="https://github.com/Han-1413141/dsh-cost-meter/releases/latest"><img src="https://img.shields.io/badge/version-1.9.68-4176E6?style=flat-square" alt="version"></a>
|
|
7
7
|
<a href="https://www.npmjs.com/package/dsh-cost-meter"><img src="https://img.shields.io/npm/dm/dsh-cost-meter?label=downloads&style=flat-square&color=4176E6" alt="npm monthly downloads"></a>
|
|
8
8
|
<a href="https://github.com/Han-1413141/dsh-cost-meter/stargazers"><img src="https://img.shields.io/github/stars/Han-1413141/dsh-cost-meter?label=stars&style=flat-square&color=D9A400" alt="GitHub stars"></a>
|
|
9
9
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" alt="MIT license"></a>
|
|
@@ -42,20 +42,20 @@ Restart `dsh web` after installation or updates. **Desktop** uses its bundled CL
|
|
|
42
42
|
The PowerShell installer checks pnpm and Git and uses the `web` profile by default:
|
|
43
43
|
|
|
44
44
|
```powershell
|
|
45
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.
|
|
45
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.68/install.ps1 | iex
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
Install a pinned Git tag:
|
|
49
49
|
|
|
50
50
|
```sh
|
|
51
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.
|
|
51
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.68
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
See [installation and updates](docs/install.en.md) for uninstalling or installing without Git.
|
|
55
55
|
|
|
56
56
|
</details>
|
|
57
57
|
|
|
58
|
-
Current release **v1.9.
|
|
58
|
+
Current release **v1.9.68**: [release notes](docs/update-notes-1.9.68.md#english) · [troubleshooting](docs/install-troubleshooting.md)
|
|
59
59
|
|
|
60
60
|
## Feature overview
|
|
61
61
|
|
package/README.zh-CN.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<p align="center">DeepSeek Harness 费用统计与订阅额度插件</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<a href="https://github.com/Han-1413141/dsh-cost-meter/releases/latest"><img src="https://img.shields.io/badge/version-1.9.
|
|
6
|
+
<a href="https://github.com/Han-1413141/dsh-cost-meter/releases/latest"><img src="https://img.shields.io/badge/version-1.9.68-4176E6?style=flat-square" alt="version"></a>
|
|
7
7
|
<a href="https://www.npmjs.com/package/dsh-cost-meter"><img src="https://img.shields.io/npm/dm/dsh-cost-meter?label=downloads&style=flat-square&color=4176E6" alt="npm monthly downloads"></a>
|
|
8
8
|
<a href="https://github.com/Han-1413141/dsh-cost-meter/stargazers"><img src="https://img.shields.io/github/stars/Han-1413141/dsh-cost-meter?label=stars&style=flat-square&color=D9A400" alt="GitHub stars"></a>
|
|
9
9
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" alt="MIT license"></a>
|
|
@@ -42,20 +42,20 @@ dsh plugin --profile web add dsh-cost-meter
|
|
|
42
42
|
PowerShell 脚本自动检查 pnpm 和 Git,默认安装到 `web` Profile:
|
|
43
43
|
|
|
44
44
|
```powershell
|
|
45
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.
|
|
45
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.68/install.ps1 | iex
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
固定 Git tag 安装:
|
|
49
49
|
|
|
50
50
|
```sh
|
|
51
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.
|
|
51
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.68
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
更新、卸载及无 Git 的安装方法见[安装说明](docs/install.md)。
|
|
55
55
|
|
|
56
56
|
</details>
|
|
57
57
|
|
|
58
|
-
当前版本 **v1.9.
|
|
58
|
+
当前版本 **v1.9.68**:[更新说明](docs/update-notes-1.9.68.md#中文) · [安装排障](docs/install-troubleshooting.md)
|
|
59
59
|
|
|
60
60
|
## 功能总览
|
|
61
61
|
|
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
DSH 的账号登录模式使用推理令牌,它与开放平台 API Key 是不同凭据:把推理令牌当作 `Authorization: Bearer` 发给 `/user/balance` 会返回 401。旧版插件只读取模型设置指定的凭据名,在该名称被宿主进程环境覆盖时无法选用凭据库里的开放平台 Key([#201](https://github.com/Han-1413141/dsh-cost-meter/issues/201))。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 已登录的官方账号
|
|
6
6
|
|
|
7
7
|
登录官方账号后,无需另行保存 API Key。未选择其他余额账号、未配置余额专用 Key 或模型 Key 时,插件通过宿主 `deepseekAccount` 服务读取与「设置 → 账号」同源的钱包,包含充值钱包与赠送钱包,再沿用插件自身的多币种挑选规则。凭据由宿主账号服务持有并负责鉴权,插件不接触 token,也不直接请求 `platform.deepseek.com`。账号服务缺席或明确退出时,该来源不可用;已登录账号的查询失败会显示错误。
|
|
8
8
|
|
|
9
|
-
模型 Key
|
|
9
|
+
模型 Key 与登录账号可以属于不同账户。自动模式下,未选择其他余额账号、也未配置专用 Key 时,模型 Key 优先于登录账号钱包。
|
|
10
|
+
|
|
11
|
+
从 1.9.67 起,可在「设置 → 费用 → 概览 → 官方账户余额 → 余额来源」选择“自动(模型 Key 优先)”或“DSH 登录钱包”。默认仍为自动;选择登录钱包后,未配置专用 Key 且未手选其他余额账号时,只读取宿主登录钱包,忽略模型 Key。未登录或钱包读取失败时显示错误,不改查模型 Key。手选账号和专用余额 Key 始终优先。选择会保存到配置,重启后保留;切换时取消旧请求并重建余额对账基准。登录钱包可能与模型实际计费账户不同。
|
|
10
12
|
|
|
11
13
|
## 余额专用 API Key
|
|
12
14
|
|
|
13
|
-
从 1.7.46 起,也可以在「设置 → 费用 → 官方账户余额」的「余额专用 API Key」中填写开放平台 Key,点击「保存」,再点击「刷新余额」。密钥通过现有凭据接口写入 DSH 凭据库中的 `DEEPSEEK_BALANCE_API_KEY`,不写入插件配置、账本或安装目录,不回传到浏览器。输入框保存后清空,只显示是否配置及来源。也可以在启动 DSH
|
|
15
|
+
从 1.7.46 起,也可以在「设置 → 费用 → 官方账户余额」的「余额专用 API Key」中填写开放平台 Key,点击「保存」,再点击「刷新余额」。密钥通过现有凭据接口写入 DSH 凭据库中的 `DEEPSEEK_BALANCE_API_KEY`,不写入插件配置、账本或安装目录,不回传到浏览器。输入框保存后清空,只显示是否配置及来源。也可以在启动 DSH 的环境中设置同名变量;来源顺序由宿主决定。已验证的 DSH 0.2.2-rc.1 和 0.2.2-rc.3 优先读取凭据文件,文件未配置该引用时再读取环境变量;旧宿主的来源顺序可能不同。
|
|
14
16
|
|
|
15
17
|
Desktop 使用相同的费用设置页与宿主凭据接口。更新时使用 Desktop 自带 CLI 的 `--profile desktop`,然后完全退出并重新打开 Desktop;[桌面端安装步骤](install-troubleshooting.md#desktop-安装与更新)包含命令来源与重装禁用状态的处理。
|
|
16
18
|
|
|
@@ -18,8 +20,8 @@ Desktop 使用相同的费用设置页与宿主凭据接口。更新时使用 De
|
|
|
18
20
|
|
|
19
21
|
1. 手动选择了其他余额账号时,只使用所选账号的 Key 请求 `https://api.deepseek.com/user/balance`。Key 缺失或查询失败时直接显示错误。
|
|
20
22
|
2. 使用默认余额账号且配置了专用 Key 时,只使用该 Key 请求官方余额,与模型的 `baseURL`、`apiKeyEnv` 及账号登录状态无关。
|
|
21
|
-
3.
|
|
22
|
-
4.
|
|
23
|
+
3. 自动模式下,未配置专用 Key,但配置了模型 API Key 时,用模型 Key 查询余额。支持 DeepSeek 官方 HTTPS 根地址、版本路径以及 `/anthropic`、`/anthropic/v1`;实际余额请求始终发往 `/user/balance`。中转或代理地址不受支持,不发送请求,也不改查登录账号的钱包。
|
|
24
|
+
4. 未配置显式余额 Key 时,选择登录钱包会直接经宿主账号服务查询;自动模式则在没有模型 API Key 时使用账号钱包。两种情形都不依赖模型设置是否可读。账号服务缺席或明确退出时,该来源不可用;已登录但查询失败时显示账号侧错误,自动查询按刷新间隔重试。
|
|
23
25
|
5. 专用 Key 返回 401 时显示认证失败及配置方法,不改用其他账户重试。自动查询遵守刷新间隔,手动刷新可立即重试。
|
|
24
26
|
6. 保存或清除专用 Key 会作废旧余额、取消在途请求并重新建立对账基准;不修改模型凭据。清除后按上面的顺序重新选择来源。
|
|
25
27
|
|
|
@@ -31,23 +33,25 @@ Desktop 使用相同的费用设置页与宿主凭据接口。更新时使用 De
|
|
|
31
33
|
|
|
32
34
|
请在 DeepSeek 开放平台确认 Key 状态。旧 Key 已丢失、无法核对时,创建新 Key,保存到“余额专用 API Key”,然后点击“刷新余额”。输入框保存后清空是隐藏密钥的正常行为,不是凭据丢失。不要在 issue 中上传 Key、凭据文件或请求头。
|
|
33
35
|
|
|
34
|
-
[#502](https://github.com/Han-1413141/dsh-cost-meter/issues/502#issuecomment-6877106296) 的报告者 @7WhiteChocolate 确认换用新建 Key 后恢复。旧 Key
|
|
36
|
+
[#502](https://github.com/Han-1413141/dsh-cost-meter/issues/502#issuecomment-6877106296) 的报告者 @7WhiteChocolate 确认换用新建 Key 后恢复。旧 Key 未保留,具体失效原因没有得到验证;本次没有把该问题归因于窗口恢复或插件更新,该次排查没有改变余额来源顺序。
|
|
35
37
|
|
|
36
38
|
## 验证
|
|
37
39
|
|
|
38
|
-
验证使用合成凭据和 HTTP 响应,覆盖真实 DSH 凭据 provider
|
|
40
|
+
验证使用合成凭据和 HTTP 响应,覆盖真实 DSH 凭据 provider 的来源优先级、保存/清除、缓存取消、迟到响应、对账基准以及 Host/Client codec。专项回归还覆盖账号与模型 Key 的来源优先级、旧版设置接口与新版配置描述、模型路由切换、官方 Messages 地址、账号异常脱敏、刷新节流、对账基准持久化及客户端错误渲染。
|
|
39
41
|
|
|
40
42
|
## English
|
|
41
43
|
|
|
42
44
|
DSH account login uses an inference token, which is not an Open Platform API key: sending it as `Authorization: Bearer` to `/user/balance` returns 401. Older plugin versions read only the credential name named by the model settings, so a host-provided environment variable of that name could shadow a stored Open Platform key ([#201](https://github.com/Han-1413141/dsh-cost-meter/issues/201)).
|
|
43
45
|
|
|
44
|
-
**Signed-in official account
|
|
46
|
+
**Signed-in official account.** No additional API key is needed. When no other balance account is selected and no dedicated or model Key is configured, the plugin reads the same wallet as **Settings → Account** (topped-up plus bonus) through the host `deepseekAccount` service, then applies its multi-currency selection. The host account service holds and uses the credential; the plugin never sees the token and never requests `platform.deepseek.com` directly. A missing account service or an explicit sign-out makes this source unavailable; a failed query for a signed-in account produces an error.
|
|
47
|
+
|
|
48
|
+
The model Key and the signed-in account can belong to different accounts. In Auto mode, when no other balance account is selected and no dedicated key is configured, a model key takes priority over the signed-in account’s wallet.
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
Since 1.9.67, **Settings → Cost → Overview → Account balance → Balance source** offers **Auto (model key first)** and **DSH account wallet**. Auto remains the default. The wallet choice bypasses model credentials and never falls back to them when the wallet is unavailable. Selected balance accounts and dedicated keys still take priority. The preference survives restart; changing it cancels pending requests and resets reconciliation. The signed-in wallet may belong to a different account from the model key.
|
|
47
51
|
|
|
48
52
|
Alternatively, since 1.7.46, enter an Open Platform key in **Settings → Cost → Account balance → Balance API key**, save it, then refresh the balance. DSH stores it as `DEEPSEEK_BALANCE_API_KEY`; the plugin never stores it in its config or ledger, or returns it to the browser. The same environment variable is supported under the host's normal credential priority rules.
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
In Auto mode, query priority is **manually selected balance account → dedicated Key → model Key → signed-in account**. A manually selected account or dedicated Key uses the fixed official HTTPS balance endpoint. A missing or invalid selected Key produces an error. Model settings support the official root, version paths, `/anthropic`, and `/anthropic/v1`. Balance requests use `https://api.deepseek.com/user/balance`. A relay or proxy `baseURL` produces an unsupported-endpoint error without sending the Key or querying the signed-in wallet. Account-query failures remain visible, and automatic retries follow the refresh interval. Saving or clearing the dedicated Key leaves model credentials intact. Account-login inference tokens cannot query the Open Platform balance endpoint directly.
|
|
51
55
|
|
|
52
56
|
Changes to the active balance credential or its model route (`apiKeyEnv` or `baseURL`) invalidate cached and in-flight balances and clear reconciliation baselines. Unrelated model changes leave manually selected accounts and dedicated Keys unchanged. Account sign-out, expiry, and account-service replacement also clear old state. The plugin reads public configuration descriptions and lifecycle events. Every balance source establishes a new reconciliation baseline when the plugin mounts again.
|
|
53
57
|
|
package/docs/billing-currency.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
**Display currency** changes how amounts are shown. **Official price currency** selects the DeepSeek price table fetched by Sync. USD prices multiplied by a display exchange rate are not the official CNY prices.
|
|
6
6
|
|
|
7
|
+
The display-currency selector lists 26 ECB reference currencies (USD, CNY, EUR, GBP, JPY, KRW, INR, HKD, SGD, AUD, CAD, CHF, NZD, BRL, MXN, ZAR, TRY, SEK, NOK, DKK, PLN, THB, IDR, MYR, PHP, ILS). CNY and EUR keep the amount recorded at the time of each call; every other currency converts at the latest daily reference rate, so its historical totals follow that rate. Switching the display currency never changes the ledger, which stays in USD.
|
|
8
|
+
|
|
7
9
|
For a CNY account, open **Settings → Cost → Prices → Official price sync**, choose **CNY**, wait for auto-save, then click **Sync from official docs** and apply. The CNY hint includes a button to select CNY; this selection alone does not fetch prices or reprice history. Check the sync result: if the CNY page is unavailable and syncing falls back to USD, the hint remains. Switching the table currency preserves recorded amounts. Historical repricing is a separate, explicitly confirmed action that creates a backup and skips records with incomplete logs. No setting changes merely because the hint appears.
|
|
8
10
|
|
|
9
11
|
For the September 2026 Flash off-peak rates, USD prices of $0.003 / $0.15 / $0.60 correspond to CNY prices of ¥0.02 / ¥1 / ¥4 per million cache-read / uncached-input / output tokens. Multiplying the USD prices by 7.2 gives ¥0.0216 / ¥1.08 / ¥4.32, 8% above that CNY table. The ratio is a comparison of those published prices, not a market exchange rate or a universal rule for every model. Sources: [DeepSeek USD prices](https://api-docs.deepseek.com/quick_start/pricing/) and [DeepSeek CNY prices](https://api-docs.deepseek.com/zh-cn/quick_start/pricing/).
|
|
@@ -14,6 +16,8 @@ Use the matching official table when comparing bills. Exchange-rate changes appl
|
|
|
14
16
|
|
|
15
17
|
**显示币种**只决定金额如何展示;**官方价格币种**决定同步哪套 DeepSeek 价格。美元价格乘以显示汇率,不等于官方人民币报价。
|
|
16
18
|
|
|
19
|
+
展示币种选择器提供 26 种 ECB 参考汇率(USD、CNY、EUR、GBP、JPY、KRW、INR、HKD、SGD、AUD、CAD、CHF、NZD、BRL、MXN、ZAR、TRY、SEK、NOK、DKK、PLN、THB、IDR、MYR、PHP、ILS)。人民币和欧元保留每次调用发生时记录的金额,其他币种按最新每日参考汇率折算,因此历史合计会跟随该汇率变动。切换展示币种不会改动账本,账本恒以美元保存。
|
|
20
|
+
|
|
17
21
|
人民币账户请进入**设置 → 费用 → 价格 → 官方价格同步**,选择 **CNY**,等待自动保存,再点击同步并应用。提示中的按钮可以直接选择 CNY;仅选择币种不会抓取价格或重算历史。同步后应查看结果:若人民币页面不可用、回退到美元表,提示仍然保留。切换价目表币种保留已有金额;历史重定价是需要确认的独立操作,会保存备份并跳过日志不完整的记录。出现提示本身不会修改设置。
|
|
18
22
|
|
|
19
23
|
以 2026 年 9 月 Flash 谷价为例,每百万缓存读取/未命中输入/输出为 $0.003/$0.15/$0.60,对应官方 ¥0.02/¥1/¥4;美元报价乘以 7.2 后是 ¥0.0216/¥1.08/¥4.32,比这套人民币价高 8%。这个比值只描述这些报价,不是市场汇率,也不适用于所有模型。来源见上方 DeepSeek 中英文官方价格页。
|