dsh-cost-meter 1.7.25 → 1.7.27

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 CHANGED
@@ -6,9 +6,9 @@
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
- [![version](https://img.shields.io/badge/version-1.7.25-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
9
+ [![version](https://img.shields.io/badge/version-1.7.27-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
10
10
 
11
- **v1.7.25** adds a collapsible per-model cost card with Today / Last 90 days, Top-N and Other totals. Quota settings now use independent cards with enabled entries first. Enable the model card under Settings → Cost → Display. See the [guide](docs/model-cost-card.md#english).
11
+ **v1.7.27** fixes `codec has no create() factory` when loading the plugin in source builds of DSH, while retaining the older `schema` interface. The [session recovery guide](docs/session-history-recovery.md#english) now explains backup placement and Zstandard header frames following the feedback on #140.
12
12
 
13
13
  [![npm](https://img.shields.io/npm/v/dsh-cost-meter?label=npm)](https://www.npmjs.com/package/dsh-cost-meter)
14
14
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
@@ -64,10 +64,36 @@ English | [中文](README.md)
64
64
 
65
65
  For Qianwen / Alibaba Cloud fund accounts, use **Add Qianwen / Alibaba Cloud balance** to query available funds with a RAM AccessKey signature. The card uses the currency returned by the API. See the [setup, permissions and balance definition](docs/qianwen-balance.md#english).
66
66
 
67
+ Qwen Token Plan can use the [official CLI subscription quota](docs/qwen-cli-quota.md#english). Install the CLI on the DSH host and run `qianwen auth login` as the same OS user. Local estimates remain the default; CLI mode shows current account credits without changing the local ledger.
68
+
67
69
  Local Qwen Token Plan credits include only the subscription providers `qwen`, `qwen-tokenplan`, `qianwen-tokenplan`, `qwen-token-plan` and `qianwen-token-plan` (case-insensitive, optional `llm-` prefix). Explicit API classifications are excluded. The `qianwen` pay-as-you-go provider does not consume estimated plan credits even when its model ID is identical. Use one of the supported subscription provider names; models outside the credits table need all three rates configured.
68
70
 
71
+ Each CLIProxyAPI source has a **Gemini quota only** option for its Antigravity groups. It defaults to off. Intentional filtering to no visible quota shows an empty list; malformed quota data still reports an error.
72
+
69
73
  The `extract` rules accept four forms: a numeric constant, a dot path string, `add`/`subtract` over multiple paths, and `divide` scaling by a `by` divisor. **`divide` fits NewApi and other endpoints that meter balance in integer quota** (1 USD = 500000 quota — the same conversion cc-switch uses).
70
74
 
75
+ - **`unit: "CREDITS"`**: displays non-monetary credits using the configured decimal precision and a Credits suffix. Dollar spend is not converted to credits or shown as today's credit usage. Credit bars use the endpoint's credit cap; the global monetary budget does not apply.
76
+ - **Plain HTTP is allowed for loopback endpoints**: `http://` is accepted when the host is `127.0.0.1` / `localhost` / `[::1]` (the traffic never leaves the machine), which covers local read-only routes that listen on loopback only and serve no TLS (e.g. `dsh-workbuddy-connect`'s `/plugins/dsh-workbuddy-connect/status`). **Every non-loopback host still requires https**; plaintext is refused.
77
+
78
+ ### WorkBuddy credits example (local plugin route)
79
+
80
+ With `dsh-workbuddy-connect` installed, its web status route already returns the aggregated credit total — no credential needs to be copied:
81
+
82
+ ```json
83
+ {
84
+ "enabled": true,
85
+ "display": "sidebar",
86
+ "refreshMinutes": 15,
87
+ "label": "WorkBuddy 积分",
88
+ "labelEn": "WorkBuddy Credits",
89
+ "unit": "CREDITS",
90
+ "request": { "url": "http://127.0.0.1:3080/plugins/dsh-workbuddy-connect/status", "method": "GET", "headers": {} },
91
+ "extract": { "remaining": "credits.total" }
92
+ }
93
+ ```
94
+
95
+ Adjust the port and response fields to the local service. This example requires the other plugin to expose that route. Cost-meter refuses redirects and continues to enforce configured credential host allowlists.
96
+
71
97
  For NewApi `GET /api/usage/token` (response `{ "code": 200, "data": { "total_granted": ..., "total_used": ..., "total_available": ..., "unlimited_quota": false } }`):
72
98
 
73
99
  ```json
@@ -262,22 +288,22 @@ Real captures from an actual DSH sidebar of the period strip and collapsed verti
262
288
  dsh plugin --profile web add dsh-cost-meter
263
289
  ```
264
290
 
265
- **PowerShell one-click script** (copy the whole line, paste, press Enter; pnpm is provisioned automatically, git is auto-detected — no clone needed; the install chain is **pinned to the release tag `v1.7.25`** — review the script before running):
291
+ **PowerShell one-click script** (copy the whole line, paste, press Enter; pnpm is provisioned automatically, git is auto-detected — no clone needed; the install chain is **pinned to the release tag `v1.7.27`** — review the script before running):
266
292
 
267
293
  ```powershell
268
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.25/install.ps1 | iex
294
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.27/install.ps1 | iex
269
295
  ```
270
296
 
271
297
  **Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
272
298
 
273
299
  ```sh
274
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.25
300
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.27
275
301
  ```
276
302
 
277
303
  Without git, use the GitHub tag archive:
278
304
 
279
305
  ```sh
280
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.25.tar.gz
306
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.27.tar.gz
281
307
  ```
282
308
 
283
309
  After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
package/README.md CHANGED
@@ -6,9 +6,9 @@
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
- [![version](https://img.shields.io/badge/version-1.7.25-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
9
+ [![version](https://img.shields.io/badge/version-1.7.27-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
10
10
 
11
- **v1.7.25**:侧栏新增可折叠的按模型花费卡片,支持今日 / 近 90 天、Top-N 与其它汇总;额度区统一为独立卡片,启用项自动置顶。入口:设置 → 费用 → 显示。详见 [使用说明](docs/model-cost-card.md)。
11
+ **v1.7.27**:修复 DSH 源码版加载插件时的 `codec has no create() factory`,同时兼容旧版 `schema` 接口;根据 #140 的恢复反馈补充备份目录与 Zstandard 头帧说明。详见[会话恢复指南](docs/session-history-recovery.md)。
12
12
 
13
13
  [![npm](https://img.shields.io/npm/v/dsh-cost-meter?label=npm)](https://www.npmjs.com/package/dsh-cost-meter)
14
14
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
@@ -65,10 +65,36 @@
65
65
 
66
66
  千问 / 阿里云资金账户余额可直接点击「添加千问 / 阿里云余额」,使用 RAM AccessKey 签名查询,显示接口返回的可用金与币种;配置步骤、所需权限及口径见[千问余额说明](docs/qianwen-balance.md)。
67
67
 
68
+ 千问 Token Plan 可在卡片内选择[官方 CLI 订阅额度](docs/qwen-cli-quota.md),需在 DSH 主机以同一系统账号安装 CLI 并运行 `qianwen auth login`。默认保留本地估算;CLI 模式显示账号当前 Credits,不修改本地账本。
69
+
68
70
  千问 Token Plan 的本地 Credits 仅统计 `qwen`、`qwen-tokenplan`、`qianwen-tokenplan`、`qwen-token-plan`、`qianwen-token-plan` 订阅 provider(大小写不敏感,可带 `llm-` 前缀);显式归类为 API 的调用不计。`qianwen` 按量 provider 即使使用相同模型名也不会计入订阅额度。自定义渠道名需使用上述订阅名称之一,模型不在抵扣表中时需补充三项费率。
69
71
 
72
+ CLIProxyAPI 网关来源卡片可勾选「只显示 Gemini 额度」,仅影响该来源的 Antigravity 分组。默认显示全部分组;过滤后无可见额度时显示空列表,解析错误仍单独报告。
73
+
70
74
  自定义 Provider 余额的 `extract` 规则支持四种形式:数字常量、点路径字符串、`add`/`subtract` 多路径加减、`divide` 按 `by` 除数缩放。**`divide` 适用于 NewApi 等以 quota 整数计量的端点**(1 USD = 500000 quota,与 cc-switch 同款换算)。
71
75
 
76
+ - **`unit: "CREDITS"`**:非货币计数端点可选 `CREDITS`,按小数精度设置显示并标明 Credits。美元花费不转换为积分,也不显示由它推算的今日积分消耗;进度条仅使用接口返回的积分上限,全局货币预算不适用。
77
+ - **本机回环端点支持明文 HTTP**:端点主机为 `127.0.0.1` / `localhost` / `[::1]` 时允许 `http://`(流量不出网卡),用于只监听回环、不提供 TLS 的本地只读路由(如 `dsh-workbuddy-connect` 的 `/plugins/dsh-workbuddy-connect/status`)。**非回环主机仍强制 https**,明文请求一律拒绝。
78
+
79
+ ### WorkBuddy 积分示例(本机插件路由)
80
+
81
+ 已安装 `dsh-workbuddy-connect` 时,其 Web 状态路由直接返回聚合积分,无需复制任何凭据:
82
+
83
+ ```json
84
+ {
85
+ "enabled": true,
86
+ "display": "sidebar",
87
+ "refreshMinutes": 15,
88
+ "label": "WorkBuddy 积分",
89
+ "labelEn": "WorkBuddy Credits",
90
+ "unit": "CREDITS",
91
+ "request": { "url": "http://127.0.0.1:3080/plugins/dsh-workbuddy-connect/status", "method": "GET", "headers": {} },
92
+ "extract": { "remaining": "credits.total" }
93
+ }
94
+ ```
95
+
96
+ 端口和响应字段按实际本机服务调整。该示例要求对应插件已提供此路由;本插件拒绝跟随重定向,现有凭据主机白名单继续生效。
97
+
72
98
  以 NewApi 的 `GET /api/usage/token` 为例(响应 `{ "code": 200, "data": { "total_granted": ..., "total_used": ..., "total_available": ..., "unlimited_quota": false } }`):
73
99
 
74
100
  ```json
@@ -264,22 +290,22 @@
264
290
  dsh plugin --profile web add dsh-cost-meter
265
291
  ```
266
292
 
267
- **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.7.25`**,建议先下载审阅再运行):
293
+ **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.7.27`**,建议先下载审阅再运行):
268
294
 
269
295
  ```powershell
270
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.25/install.ps1 | iex
296
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.27/install.ps1 | iex
271
297
  ```
272
298
 
273
299
  **或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
274
300
 
275
301
  ```sh
276
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.25
302
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.27
277
303
  ```
278
304
 
279
305
  没有 git 时可用 GitHub tag 打包直链:
280
306
 
281
307
  ```sh
282
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.25.tar.gz
308
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.27.tar.gz
283
309
  ```
284
310
 
285
311
  安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):