dsh-cost-meter 1.7.24 → 1.7.26

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.24-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
9
+ [![version](https://img.shields.io/badge/version-1.7.26-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
10
10
 
11
- **v1.7.24** discovers OpenCode Go credentials from your official Go route, regardless of its name. See [credential discovery](docs/opencode-go-credentials.md#english). See the [recovery guide](docs/session-history-recovery.md#english) for sessions affected by the earlier native-search log issue.
11
+ **v1.7.26** adds an official Qianwen CLI quota source for subscription and add-on Credits, an option to show only Gemini quota groups in Antigravity, and decimal Credits plus loopback HTTP support for custom balances. See the [Qianwen CLI guide](docs/qwen-cli-quota.md#english).
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)
@@ -28,6 +28,7 @@ English | [中文](README.md)
28
28
 
29
29
  | Feature | Location | Description |
30
30
  |---|---|---|
31
+ | Per-model cost card | Sidebar / composer dock (optional) | Disabled by default; inline Top-N, Other totals, shares and optional tokens, Today / Last 90 days, remembered expansion and a Top-1 chip. See the [guide](docs/model-cost-card.md#english) |
31
32
  | Per-conversation cost | Below the composer / session title bar | Live accumulated cost + input/cache/output tokens; position configurable |
32
33
  | Official balance | Sidebar top / Settings page (configurable) | Total / granted / topped-up balance, auto-refresh + manual refresh; optional three-segment progress bar (blue/orange/gray), whose today segment only counts official-channel spend (coding plans / custom providers excluded) |
33
34
  | Custom provider balance | Sidebar / Settings page (configurable) | Configurable HTTP balance lookup (e.g. LiteLLM); bilingual labels, currency, extract rules (dot path / number / add / subtract / divide — use divide for NewApi-style quota endpoints, see [example](#custom-provider-balance-example-newapi-template)); collapsible panel alongside Coding Plan quotas |
@@ -63,10 +64,36 @@ English | [中文](README.md)
63
64
 
64
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).
65
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
+
66
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.
67
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
+
68
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).
69
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
+
70
97
  For NewApi `GET /api/usage/token` (response `{ "code": 200, "data": { "total_granted": ..., "total_used": ..., "total_available": ..., "unlimited_quota": false } }`):
71
98
 
72
99
  ```json
@@ -261,22 +288,22 @@ Real captures from an actual DSH sidebar of the period strip and collapsed verti
261
288
  dsh plugin --profile web add dsh-cost-meter
262
289
  ```
263
290
 
264
- **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.24`** — 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.26`** — review the script before running):
265
292
 
266
293
  ```powershell
267
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.24/install.ps1 | iex
294
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.26/install.ps1 | iex
268
295
  ```
269
296
 
270
297
  **Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
271
298
 
272
299
  ```sh
273
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.24
300
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.26
274
301
  ```
275
302
 
276
303
  Without git, use the GitHub tag archive:
277
304
 
278
305
  ```sh
279
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.24.tar.gz
306
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.26.tar.gz
280
307
  ```
281
308
 
282
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.24-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
9
+ [![version](https://img.shields.io/badge/version-1.7.26-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
10
10
 
11
- **v1.7.24**:OpenCode Go 额度自动读取官方 Go 路由配置的凭据,路由名无需固定。见 [凭据发现说明](docs/opencode-go-credentials.md)。此前受原生搜索日志问题影响的会话,仍可按 [恢复说明](docs/session-history-recovery.md) 备份修复。
11
+ **v1.7.26**:千问额度新增官方 CLI 来源,查询订阅 Credits 与加量包;Antigravity 可只显示 Gemini 额度;自定义余额支持小数积分与本机回环 HTTP。详见 [千问 CLI 使用说明](docs/qwen-cli-quota.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)
@@ -28,6 +28,7 @@
28
28
 
29
29
  | 功能 | 位置 | 说明 |
30
30
  |---|---|---|
31
+ | 按模型花费卡片 | 侧栏 / 右下角 dock(可配) | 默认关闭;就地展开 Top-N、其它汇总、占比和可选 Token;支持今日 / 近 90 天、展开记忆及 Top-1 角标,见[使用说明](docs/model-cost-card.md) |
31
32
  | 本会话费用 | 输入区下方 / 会话标题栏 | 实时累计费用 + 输入/缓存/输出 token,位置可配 |
32
33
  | 官方余额 | 侧边栏顶部 / 设置页(可配) | 总余额 / 赠送 / 充值,自动刷新 + 手动刷新;可选三段进度条(蓝/橙/灰),当日段只统计官方渠道费用(不含 Coding Plan / 自定义 Provider) |
33
34
  | 自定义 Provider 余额 | 侧边栏 / 设置页(可配) | 可配置 HTTP 查询任意 Provider 余额(LiteLLM 等);中/英名称、币种、extract 规则(点路径 / 数字常量 / add / subtract / divide,divide 适配 NewApi 等 quota 端点,见下方[示例](#自定义-provider-余额配置示例newapi-模板));与 Coding Plan 同区可折叠配置 |
@@ -64,10 +65,36 @@
64
65
 
65
66
  千问 / 阿里云资金账户余额可直接点击「添加千问 / 阿里云余额」,使用 RAM AccessKey 签名查询,显示接口返回的可用金与币种;配置步骤、所需权限及口径见[千问余额说明](docs/qianwen-balance.md)。
66
67
 
68
+ 千问 Token Plan 可在卡片内选择[官方 CLI 订阅额度](docs/qwen-cli-quota.md),需在 DSH 主机以同一系统账号安装 CLI 并运行 `qianwen auth login`。默认保留本地估算;CLI 模式显示账号当前 Credits,不修改本地账本。
69
+
67
70
  千问 Token Plan 的本地 Credits 仅统计 `qwen`、`qwen-tokenplan`、`qianwen-tokenplan`、`qwen-token-plan`、`qianwen-token-plan` 订阅 provider(大小写不敏感,可带 `llm-` 前缀);显式归类为 API 的调用不计。`qianwen` 按量 provider 即使使用相同模型名也不会计入订阅额度。自定义渠道名需使用上述订阅名称之一,模型不在抵扣表中时需补充三项费率。
68
71
 
72
+ CLIProxyAPI 网关来源卡片可勾选「只显示 Gemini 额度」,仅影响该来源的 Antigravity 分组。默认显示全部分组;过滤后无可见额度时显示空列表,解析错误仍单独报告。
73
+
69
74
  自定义 Provider 余额的 `extract` 规则支持四种形式:数字常量、点路径字符串、`add`/`subtract` 多路径加减、`divide` 按 `by` 除数缩放。**`divide` 适用于 NewApi 等以 quota 整数计量的端点**(1 USD = 500000 quota,与 cc-switch 同款换算)。
70
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
+
71
98
  以 NewApi 的 `GET /api/usage/token` 为例(响应 `{ "code": 200, "data": { "total_granted": ..., "total_used": ..., "total_available": ..., "unlimited_quota": false } }`):
72
99
 
73
100
  ```json
@@ -263,22 +290,22 @@
263
290
  dsh plugin --profile web add dsh-cost-meter
264
291
  ```
265
292
 
266
- **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.7.24`**,建议先下载审阅再运行):
293
+ **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.7.26`**,建议先下载审阅再运行):
267
294
 
268
295
  ```powershell
269
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.24/install.ps1 | iex
296
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.26/install.ps1 | iex
270
297
  ```
271
298
 
272
299
  **或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
273
300
 
274
301
  ```sh
275
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.24
302
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.26
276
303
  ```
277
304
 
278
305
  没有 git 时可用 GitHub tag 打包直链:
279
306
 
280
307
  ```sh
281
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.24.tar.gz
308
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.26.tar.gz
282
309
  ```
283
310
 
284
311
  安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):