dsh-cost-meter 1.9.0 → 1.9.3

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 CHANGED
@@ -10,18 +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
- [![version](https://img.shields.io/badge/version-1.9.0-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
13
+ [![version](https://img.shields.io/badge/version-1.9.3-4176E6)](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.0** adds compatibility with the Codex and ChatGPT subscription plugins (subscription calls classified as Plan quota instead of API spend, with a one-time dismissible history prompt), supports better-session's SQLite session storage, adapts every cost UI to dsh-pocket mobile layouts, and restores OpenDesign coding-plan quota queries via a Control-Key `/billing/preflight` fallback with independent window/wallet degradation ([#274](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236591566)). The ledger format is unchanged and historical amounts are not recalculated automatically.
19
+ **v1.9.3** fixes the Codex compatibility dialog getting stuck, missing history reclassification routes after hot updates, and the blank Codex tab. Cost settings use tighter cards and a collapsible compatibility row.
20
+
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).
20
22
 
21
23
 
22
24
  Desktop users: follow the [Desktop installation instructions](docs/install-troubleshooting.md#desktop-安装与更新) for the application's own CLI and `desktop` Profile.
23
25
 
24
- Release notes: [v1.9.0](docs/update-notes-1.9.0.md#english). Fully restart DSH after updating.
26
+ Release notes: [v1.9.3](docs/update-notes-1.9.3.md#english). Fully restart DSH after updating.
25
27
 
26
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`).
27
29
 
@@ -338,22 +340,22 @@ On Node.js 20, use `npm install -g pnpm@10` instead. See [pnpm installation and
338
340
  dsh plugin --profile web add dsh-cost-meter
339
341
  ```
340
342
 
341
- **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.0`** — review the script before running):
343
+ **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.3`** — review the script before running):
342
344
 
343
345
  ```powershell
344
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.0/install.ps1 | iex
346
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.3/install.ps1 | iex
345
347
  ```
346
348
 
347
349
  **Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
348
350
 
349
351
  ```sh
350
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.0
352
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.3
351
353
  ```
352
354
 
353
355
  Without git, use the GitHub tag archive:
354
356
 
355
357
  ```sh
356
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.0.tar.gz
358
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.3.tar.gz
357
359
  ```
358
360
 
359
361
  After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
@@ -418,7 +420,7 @@ Workarounds:
418
420
 
419
421
  ```yaml
420
422
  minimumReleaseAgeExclude:
421
- - dsh-cost-meter@1.9.0
423
+ - dsh-cost-meter@1.9.3
422
424
  ```
423
425
 
424
426
  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.
@@ -553,6 +555,8 @@ Join the WeChat group to discuss the plugin, share feedback, and suggest feature
553
555
 
554
556
  ## Update history
555
557
 
558
+ **Version policy**: releases increment only the patch number (for example `1.9.0 → 1.9.1`), including feature releases, new plugin compatibility and UI updates. The minor/major positions stay fixed unless a breaking change requires them and is explicitly approved; 1.9.0 was the last minor bump.
559
+
556
560
  A per-version overview and the community-issue resolution log live in [docs/UPDATE-HISTORY.md](docs/UPDATE-HISTORY.md) (中文); the itemized changelog is [CHANGELOG.md](CHANGELOG.md).
557
561
 
558
562
  ## Star History
package/README.zh-CN.md CHANGED
@@ -10,18 +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
- [![version](https://img.shields.io/badge/version-1.9.0-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
13
+ [![version](https://img.shields.io/badge/version-1.9.3-4176E6)](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.0** 新增 Codex / ChatGPT 订阅插件兼容(订阅调用归为 Plan 订阅额度、不计入 API 花费,首次检测弹出一次性可关闭提示处理历史归类)、better-session 的 SQLite 会话存储兼容、全部费用界面的 dsh-pocket 手机端适配,并按 [#274](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236591566) 为 OpenDesign 增加 Control Key `/billing/preflight` 回退与窗口/钱包独立降级。账本格式不变,不自动重算历史金额。
19
+ **v1.9.3** 修复 Codex 兼容弹窗无法关闭、热更新后历史归类接口返回 404,以及 Codex 标签页空白;收紧概览卡片与计费统计的留白,将兼容选项收进可展开的一行。
20
+
21
+ 配置与验证:[OpenDesign 查询说明](docs/opendesign-billing.md)、[随机端口 / 局域网 / WorkBuddy2API 配置](docs/custom-balance-sources.md)、[透明度修复与性能测量](docs/performance-2026-10-18.md)。
20
22
 
21
23
 
22
24
  桌面端用户请按 [Desktop 安装说明](docs/install-troubleshooting.md#desktop-安装与更新),使用应用自带的 CLI 和 `desktop` Profile。
23
25
 
24
- 更新说明:[v1.9.0](docs/update-notes-1.9.0.md#中文)。更新后完全重启 DSH。
26
+ 更新说明:[v1.9.3](docs/update-notes-1.9.3.md#中文)。更新后完全重启 DSH。
25
27
 
26
28
  声明范围内的宿主记录与此前的 0.1.x 历史见[兼容记录](docs/host-compatibility.md);逐版本清单在 `package.json` 的 `dsh.compatibility.dshReleases`。
27
29
 
@@ -338,22 +340,22 @@ Node.js 20 请改用 `npm install -g pnpm@10`。版本要求见 [pnpm 官方安
338
340
  dsh plugin --profile web add dsh-cost-meter
339
341
  ```
340
342
 
341
- **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.9.0`**,建议先下载审阅再运行):
343
+ **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.9.3`**,建议先下载审阅再运行):
342
344
 
343
345
  ```powershell
344
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.0/install.ps1 | iex
346
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.3/install.ps1 | iex
345
347
  ```
346
348
 
347
349
  **或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
348
350
 
349
351
  ```sh
350
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.0
352
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.3
351
353
  ```
352
354
 
353
355
  没有 git 时可用 GitHub tag 打包直链:
354
356
 
355
357
  ```sh
356
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.0.tar.gz
358
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.3.tar.gz
357
359
  ```
358
360
 
359
361
  安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
@@ -418,7 +420,7 @@ DSH **0.2.1-rc.1 / 0.2.1-rc.2** 宿主自带 pnpm **11.28.5**,默认启用内
418
420
 
419
421
  ```yaml
420
422
  minimumReleaseAgeExclude:
421
- - dsh-cost-meter@1.9.0
423
+ - dsh-cost-meter@1.9.3
422
424
  ```
423
425
 
424
426
  3. 仅本次操作用 CLI 透传 pnpm 参数:`dsh plugin --profile desktop remove dsh-cost-meter --config.minimum-release-age=0`;若只是 lockfile 校验阶段失败,可改用 `--trust-lockfile`。这两个参数已在本机 pnpm 11.28.5 临时 Profile 上实测可用。
@@ -557,6 +559,8 @@ dsh --profile web --port 3099 # 真机启动(观察启
557
559
 
558
560
  ## 更新历史
559
561
 
562
+ **版本号策略**:发版只递增补丁号(例如 `1.9.0 → 1.9.1`),新增功能、插件兼容与 UI 更新也按补丁号发布;次版本/主版本号保持不变,除非出现不兼容变更且明确同意。1.9.0 是最后一次升次版本号。
563
+
560
564
  各版本更新总览与社区 issue 处理记录见 [docs/UPDATE-HISTORY.md](docs/UPDATE-HISTORY.md);逐条开发记录见 [CHANGELOG.md](CHANGELOG.md)。
561
565
 
562
566
  ## Star 增长记录
@@ -0,0 +1,68 @@
1
+ # 自定义余额:随机端口、局域网与 WorkBuddy2API
2
+
3
+ ## 跟随 DSH 随机端口
4
+
5
+ 在 **设置 → 费用 → 额度 → 自定义 Provider 余额** 中,请求 URL 可以填写以单个 `/` 开头的路径:
6
+
7
+ ```json
8
+ {
9
+ "enabled": true,
10
+ "label": "WorkBuddy 积分",
11
+ "unit": "CREDITS",
12
+ "request": { "url": "/plugins/dsh-workbuddy-connect/status" },
13
+ "extract": { "remaining": "credits.total" }
14
+ }
15
+ ```
16
+
17
+ 插件在查询时读取 DSH `webServer.port`,访问当前宿主的本机 HTTP 服务。端口改变后旧余额缓存失效,配置仍保存相对路径。服务尚未监听时提示稍后重试;不会扫描端口、改写账本中的 URL,或把浏览器提供的 origin 当作查询目标。`//host/path`、反斜杠和带凭据的 URL 不被接受,重定向不会被跟随。
18
+
19
+ `dsh-workbuddy-connect` 的状态路由与独立部署的 WorkBuddy2API 是两种来源。只有宿主内注册的路由使用相对路径;独立服务填写其实际 URL。
20
+
21
+ ## 局域网 HTTP
22
+
23
+ HTTPS 和本机回环 HTTP 继续可用。访问 `http://192.168.1.20:8790` 等非回环地址时,在同一条余额配置中:
24
+
25
+ 1. 在凭据白名单填写准确的 `192.168.1.20:8790`。
26
+ 2. 勾选“允许非回环 HTTP”。
27
+
28
+ 这对应 `allowedHosts: ["192.168.1.20:8790"]` 和 `allowInsecureHttp: true`。两个条件缺一不可;白名单按准确的主机和端口匹配,不接受 `192.168.*.*`。HTTP 会明文传输请求头中的凭据,开关默认关闭。已有 CLIProxyAPI 网关配置仍使用其原有的同名开关和白名单。
29
+
30
+ ## WorkBuddy2API 积分预设
31
+
32
+ 点击 **+ WorkBuddy2API 积分**,会创建一条默认关闭的可编辑配置:
33
+
34
+ ```json
35
+ {
36
+ "label": "WorkBuddy2API 积分",
37
+ "unit": "CREDITS",
38
+ "refreshMinutes": 15,
39
+ "request": {
40
+ "url": "http://127.0.0.1:8790/api/credits/expiry?package_limit=1",
41
+ "method": "GET",
42
+ "headers": { "X-Admin-Token": "{{WORKBUDDY2API_ADMIN_TOKEN}}" }
43
+ },
44
+ "extract": { "remaining": "summary.available_remaining" },
45
+ "allowedHosts": ["127.0.0.1:8790"],
46
+ "allowInsecureHttp": false
47
+ }
48
+ ```
49
+
50
+ 填入实际地址和端口,在凭据输入框保存 WorkBuddy2API 管理后台的 **X-Admin-Token**,再启用卡片。该令牌与模型推理 API Key 不同;过期后需要更新。密钥通过 DSH 凭据库保存,不写入上述配置。修改服务地址时同步修改白名单。
51
+
52
+ 显示的是**活跃账号池的可用积分**,不与美元费用换算,也不把仅覆盖部分账号的到期快照 `summary.total_remaining` 当成全部余额。没有可信的总额度就不编造进度条上限。查询只读取服务器已有统计,不发模型请求、不触发账号积分刷新任务。`package_limit=1` 缩小不需要的积分包明细;插件只保留提取后的数字。
53
+
54
+ 上游契约核对于 2026-10-18,commit `02f82cdf3282475ce3c1e87f01afdc044636f549`:
55
+
56
+ - [积分路由和汇总字段](https://github.com/xiaofan6ya/workbuddy2api/blob/02f82cdf3282475ce3c1e87f01afdc044636f549/admin/routers/credits.py)
57
+ - [X-Admin-Token 鉴权](https://github.com/xiaofan6ya/workbuddy2api/blob/02f82cdf3282475ce3c1e87f01afdc044636f549/admin/security.py)
58
+ - [默认监听端口](https://github.com/xiaofan6ya/workbuddy2api/blob/02f82cdf3282475ce3c1e87f01afdc044636f549/admin/config.py)
59
+
60
+ 本轮验证包括真实本地 HTTP 服务的随机端口切换、配置往返和合成 WorkBuddy2API 响应;未连接用户的真实 WorkBuddy2API 账号。
61
+
62
+ 贡献来源:@Jav1es 在 [#311](https://github.com/Han-1413141/dsh-cost-meter/issues/311) 提供随机端口复现及相对路径建议;@snhun 在 [#309](https://github.com/Han-1413141/dsh-cost-meter/issues/309) 提出局域网 HTTP 需求,在 [#310](https://github.com/Han-1413141/dsh-cost-meter/issues/310) 提出 WorkBuddy2API 接入需求。
63
+
64
+ ## English setup
65
+
66
+ Root-relative URLs such as `/plugins/dsh-workbuddy-connect/status` follow the running DSH web server's actual port. Independent WorkBuddy2API deployments use an absolute URL. Non-loopback HTTP requires both `allowInsecureHttp: true` and an exact `host:port` in `allowedHosts`; this explicitly permits plaintext transport. Redirects remain blocked.
67
+
68
+ The **+ WorkBuddy2API credits** preset reads `GET /api/credits/expiry?package_limit=1` with an admin `X-Admin-Token` stored as `WORKBUDDY2API_ADMIN_TOKEN` in DSH credentials. Set the real server address and matching allowlist, update expired admin tokens, then enable the card. The displayed `summary.available_remaining` is the active account pool's available credits, not currency, a single model API key's allowance, or the incomplete expiry snapshot total. No model request or upstream credit-refresh task is triggered. Authentication was tested with synthetic responses, not a live account.
@@ -4,7 +4,7 @@
4
4
 
5
5
  This release addresses [#274](https://github.com/Han-1413141/dsh-cost-meter/issues/274), requested by @playgithub. It adds an OpenDesign price channel and read-only workspace quota queries; it is included in version 1.8.27. It does not install OpenDesign, create an account or change a model route.
6
6
 
7
- The quota query also implements the Bearer-only fallback discovered by @yunjuanhuakai in the [#274 follow-up comments](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236591566): on accounts whose usage route rejects a Control Key, the plugin retries the `billing/preflight` endpoint with the same credential. @codeforker654's [401 report](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236228870) is the reproduction behind the fallback.
7
+ The quota query uses the Bearer-only preflight endpoint discovered by @yunjuanhuakai in the [#274 follow-up comments](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236591566): the plugin directly reads `billing/preflight` with a Control Key. @unifilitence confirmed this behavior and the independent wallet contract in [#313](https://github.com/Han-1413141/dsh-cost-meter/issues/313). @codeforker654's [401 report](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236228870) documents the original authentication failure.
8
8
 
9
9
  ### Conversation costs
10
10
 
@@ -17,6 +17,8 @@ OpenDesign uses shared subscription allowances and can fall back to its wallet;
17
17
 
18
18
  ### Quota queries
19
19
 
20
+ **DSH-only use:** you do not need to install the OpenDesign app to use its model API in DSH or track conversation costs. Remote quota reads additionally need the workspace ID and Control Key from your OpenDesign Cloud account. An inference API key cannot supply these credentials. If you only have an inference key, leave this quota card disabled; price matching and conversation costs continue to work.
21
+
20
22
  1. Open **Settings → Cost → Quotas**, find **OpenDesign**, and expand its settings.
21
23
  2. Enter the exact **workspace ID** from your OpenDesign Cloud workspace.
22
24
  3. Configure a **Control Key** in the credential editor, or supply `OPENDESIGN_CONTROL_KEY` / `VELA_CONTROL_KEY` to the DSH host. An inference key from the Cloud API Keys page is a different credential and cannot be used for this query. The existing OpenDesign/Vela login keeps control credentials in its own profile; the plugin does not read or rewrite that profile automatically.
@@ -25,37 +27,30 @@ OpenDesign uses shared subscription allowances and can fall back to its wallet;
25
27
  The host issues only these authenticated GET requests to the fixed official HTTPS origin:
26
28
 
27
29
  ```text
28
- https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/billing/coding-plan-usage # primary window query
29
- https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/billing/preflight # Bearer-only fallback, only after a 401/403
30
+ https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/billing/preflight # direct Bearer-only window query
30
31
  https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/wallet/balance # wallet, read independently
31
32
  ```
32
33
 
33
- #### Endpoint permissions, Bearer-only fallback and 401 troubleshooting
34
+ #### Endpoint permissions and 401 troubleshooting
34
35
 
35
- - The usage endpoint is not always scoped to a Control Key: for some plans/accounts it only accepts a **browser session cookie**, so a Control Key can return `401`/`403` for `billing/coding-plan-usage` while `/billing/preflight`, `/wallet/balance` and other API endpoints still answer `200` with the same key. The plugin never sends a browser cookie. It first queries the usage route with `Authorization: Bearer ...`; when that route answers `401`/`403`, it retries `billing/preflight` once with the same header. `preflight` returns the identical window packet nested under `codingPlan`, so the same parser and percentage rules apply.
36
- - A `200`, a malformed body or any other HTTP status on the primary route never triggers the fallback. The wallet route is read independently and in parallel: when only one side is rejected, the other value is still displayed, the rejected side is omitted rather than fabricated as zero, and its cause (credential rejected / no subscription / invalid response / network) is kept in the refresh trace. Only when both sides fail does the card show an error state.
37
- - A successful fallback keeps the standard `{ windows, endpoint }` answer, with `endpoint` naming the route that actually answered. A fallback response that is itself rejected, malformed or unreachable is reported as the window side's failure cause, not as a wallet failure.
38
- - `preflight` also carries `workspaceMemberId` and `balanceUsd`. The member is checked against the wallet member; `balanceUsd` is only used as the displayed balance when `/wallet/balance` cannot be read, and never adds to or replaces a readable wallet value.
39
- - The workspace ID must be the `workspaceId` field of `items[]` from `GET https://amr-api.open-design.ai/api/v1/workspaces`. It is **not** `profiles.prod.user.id` from `~/.amr/config.json`: that user id authenticates but scopes the request to the wrong resource, and the server replies `403 workspace_billing_scope_forbidden`.
40
- - Troubleshooting a `401`/`403` on the quota endpoint:
41
- 1. Confirm the stored credential is a **Control Key**, not an inference API key from the Cloud API Keys page.
42
- 2. Call `GET /api/v1/workspaces` with the same credential and copy the exact `items[].workspaceId`.
43
- 3. If `/workspaces` succeeds but `/billing/coding-plan-usage` returns `401`/`403`, the automatic `preflight` fallback normally covers this account and needs no browser session. If `preflight` also returns `401`/`403` for the same key, that account does not expose a Control-Key window read; log in to the OpenDesign Cloud console to check usage there. The wallet endpoint may still be readable, and is shown on its own.
44
- 4. Verify the key and workspace belong to the same account and that the key was not rotated or revoked.
36
+ - `/billing/preflight` and `/wallet/balance` run in parallel with `Authorization: Bearer ...` and `x-vela-workspace-id`. The plugin no longer queries the browser-session-only `coding-plan-usage` route. Preflight nests the quota windows under `codingPlan`; both layers' workspace and member identities are validated before unwrapping.
37
+ - The wallet endpoint remains an independent query with its `billingScopeVersion: 2` contract. A valid wallet response is authoritative. When it cannot be read, a validated preflight result may display its `balanceUsd` as a fallback. Failure on one side preserves the other; no missing value becomes a fabricated zero. The refresh trace records the failing side.
38
+ - The workspace ID is `items[].workspaceId` from `GET https://amr-api.open-design.ai/api/v1/workspaces`, not `profiles.prod.user.id` from `~/.amr/config.json`.
39
+ - For a 401/403, check that the Control Key is current, belongs to the selected workspace and can read that workspace. An inference key or a user ID in the workspace field will not work. If the account rejects preflight too, use the OpenDesign Cloud console to check quota; a readable wallet is still shown separately.
45
40
 
46
41
  Quota and wallet responses must match the requested workspace. The wallet must identify its member; if the quota response provides a member identity, both must match. A preflight response that omits the redundant outer `workspaceId` is accepted only after the requested workspace has scoped the request; a body naming a different workspace is rejected. Credentials are never forwarded through a redirect and no cookie is attached. They use the existing DSH credential store and are excluded from the ledger and client snapshot.
47
42
 
48
- Each returned allowance window has its own used percentage and reset time. Simultaneous windows are not added together or called unlimited. Wallet credit remains a separate USD-equivalent value, including a real zero. Quota and wallet are fetched independently, so a failure on one side keeps the other side visible; an `eligible: false` / empty-window answer (from the primary route or the fallback) is reported as **no active subscription** instead of a credential failure. Invalid, unauthorized or missing responses never fabricate a zero allowance; when both sides fail, the card shows an error/unavailable state. The workspace setting is kept across restarts and invalidates the previous query when changed.
43
+ Each returned allowance window has its own used percentage and reset time. Simultaneous windows are not added together or called unlimited. Wallet credit remains a separate USD-equivalent value, including a real zero. Quota and wallet are fetched independently, so a failure on one side keeps the other side visible; an `eligible: false` / empty-window answer is reported as **no active subscription** instead of a credential failure. Invalid, unauthorized or missing responses never fabricate a zero allowance; when both sides fail, the card shows an error/unavailable state. The workspace setting is kept across restarts and invalidates the previous query when changed.
49
44
 
50
45
  ### Evidence and limits
51
46
 
52
- The public catalog was fetched without authentication. The authenticated adapter, the Bearer-only `billing/preflight` fallback and bilingual settings were verified with synthetic responses, including large credit counts, zero balances, mismatched identities, authorization failures on either side, a preflight-shaped `codingPlan` body, and price-refresh persistence. **No live account query or paid model request was made.** Production Control Key permissions and response availability still require a configured account.
47
+ The public catalog was fetched without authentication. The authenticated adapter, direct Bearer-only `billing/preflight` reads and bilingual settings were verified with synthetic responses, including large credit counts, zero balances, mismatched identities, authorization failures on either side, a preflight-shaped `codingPlan` body, and price-refresh persistence. **No live account query or paid model request was made.** Production Control Key permissions and response availability still require a configured account.
53
48
 
54
49
  Endpoint provenance: the official Cloud bundles `cloud-root-B21Emo2w.js` and `pricing-refund-policy-BDFJHl33.js` served on 2026-10-15; the [workspace-wallet contract](https://github.com/nexu-io/open-design/blob/7abd6fc2b11987c3940eb4ffc461478ff37c0b33/packages/contracts/src/api/collab.ts) and [Vela billing adapter](https://github.com/nexu-io/open-design/blob/7abd6fc2b11987c3940eb4ffc461478ff37c0b33/apps/daemon/src/integrations/vela-billing.ts) at the inspected commit. The exact `billing/preflight` shape (`codingPlan`-nested windows, `workspaceMemberId`, `balanceUsd`) comes from @yunjuanhuakai's [#274 comment](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236591566); the 401 reproduction and attached report come from @codeforker654's [comment](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236228870). The [official guide](https://open-design.ai/zh/model-credits/) explicitly lists DSH as a supported API client; the issue has a usable integration request. Its short promotional wording alone does not establish advertising or spam.
55
50
 
56
51
  ## 中文
57
52
 
58
- 本版本实现了 @playgithub 在 [#274](https://github.com/Han-1413141/dsh-cost-meter/issues/274) 提出的接入需求,随 1.8.27 发布。同时落实 #274 后续评论中 @yunjuanhuakai 发现的纯 Bearer 回退端点([评论](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236591566)),并以 @codeforker654 的 [401 复现报告](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236228870) 为验证案例。不会安装 OpenDesign、注册账户或改变模型路由。
53
+ 本版本实现了 @playgithub 在 [#274](https://github.com/Han-1413141/dsh-cost-meter/issues/274) 提出的接入需求,随 1.8.27 发布。同时采用 #274 后续评论中 @yunjuanhuakai 发现的纯 Bearer preflight 端点([评论](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236591566)),并以 @codeforker654 的 [401 复现报告](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236228870) 为验证案例。@unifilitence 在 [#313](https://github.com/Han-1413141/dsh-cost-meter/issues/313) 补充了独立钱包契约与本地验证。不会安装 OpenDesign、注册账户或改变模型路由。
59
54
 
60
55
  ### 会话计费
61
56
 
@@ -68,6 +63,8 @@ OpenDesign 的 API 与客户端共用套餐,套餐用尽后可以继续扣钱
68
63
 
69
64
  ### 额度查询
70
65
 
66
+ **只使用 DSH 的情况:**在 DSH 调用 OpenDesign 模型 API、统计会话费用,都不需要安装 OpenDesign 应用。远端额度查询另外需要 OpenDesign Cloud 账户的工作区 ID 和 Control Key,推理 API Key 不能代替。如果只有推理密钥,可以关闭额度卡片,价格匹配和会话计费照常工作。
67
+
71
68
  1. 在 **设置 → 费用 → 额度**找到并展开 **OpenDesign**。
72
69
  2. 填入 OpenDesign Cloud 中对应的**工作区 ID**。
73
70
  3. 在凭据编辑器中配置 **Control Key**,或向 DSH 宿主提供 `OPENDESIGN_CONTROL_KEY` / `VELA_CONTROL_KEY`。Cloud API Keys 页生成的推理密钥与查询凭据不同,不能混用。已有 OpenDesign/Vela 登录将控制端凭据保存在其自身配置中,本插件不会自动读取或修改那个配置。
@@ -76,28 +73,21 @@ OpenDesign 的 API 与客户端共用套餐,套餐用尽后可以继续扣钱
76
73
  查询只访问以下固定官方 HTTPS GET 端点,并在凭据/工作区校验之后才发起:
77
74
 
78
75
  ```text
79
- https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/billing/coding-plan-usage # 优先窗口端点
80
- https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/billing/preflight # 纯 Bearer 回退,仅在 401/403 后尝试一次
76
+ https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/billing/preflight # 直接使用纯 Bearer 查询窗口
81
77
  https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/wallet/balance # 钱包端点,独立读取
82
78
  ```
83
79
 
84
- #### 端点权限、Bearer 回退与 401 排查
80
+ #### 端点权限与 401 排查
85
81
 
86
- - 用量端点并非总是接受 Control Key:部分套餐/账户只接受**浏览器会话 Cookie**,因此同一个 Control Key 可能在 `billing/coding-plan-usage` 返回 `401`/`403`,而 `/billing/preflight`、`/wallet/balance` 等其它端点仍返回 `200`。插件从不发送浏览器 Cookie:先以 `Authorization: Bearer ...` 查询用量端点;若返回 `401`/`403`,再用同一请求头重试一次 `billing/preflight`。后者把同样的窗口数据嵌套在 `codingPlan` 下,解析与百分比规则完全一致。
87
- - 主端点返回 `200`、响应格式错误或其它 HTTP 状态时都不会触发回退。钱包端点独立并行读取:只有一侧失败时仍显示另一侧数值,失败侧留空而不是编造为零,失败原因(凭据被拒/无订阅/响应无效/网络失败)保留在刷新记录中;两侧都失败才显示错误状态。
88
- - 回退成功仍返回标准 `{ windows, endpoint }`,`endpoint` 指向实际返回数据的端点。回退端点本身被拒、格式错误或网络失败时,记为窗口侧失败原因,而不是钱包失败。
89
- - `preflight` 同时返回 `workspaceMemberId` 与 `balanceUsd`。成员身份会与钱包成员核对;`balanceUsd` 只在 `/wallet/balance` 不可读时作为显示余额的兜底,不会与可读的钱包金额相加或覆盖它。
90
- - 工作区 ID 必须取 `GET https://amr-api.open-design.ai/api/v1/workspaces` 返回的 `items[].workspaceId`;**不能**使用 `~/.amr/config.json` 里的 `profiles.prod.user.id`。后者虽然能通过认证,却会把请求指向错误的资源范围,服务端返回 `403 workspace_billing_scope_forbidden`。
91
- - 额度端点返回 `401`/`403` 时的排查步骤:
92
- 1. 确认保存的是 **Control Key**,不是 Cloud API Keys 页生成的推理密钥。
93
- 2. 用同一凭据调用 `GET /api/v1/workspaces`,复制准确的 `items[].workspaceId`。
94
- 3. 若 `/workspaces` 成功而 `/billing/coding-plan-usage` 返回 `401`/`403`,自动 `preflight` 回退通常已覆盖该账户,不需要浏览器会话。若同一凭据在 `preflight` 也返回 `401`/`403`,说明该账户没有开放 Control Key 的窗口读取;请登录 OpenDesign Cloud 控制台查看用量。钱包端点可能仍可读取,会单独显示。
95
- 4. 核对密钥与工作区属于同一账户,并确认密钥未被轮换或撤销。
82
+ - `/billing/preflight` 和 `/wallet/balance` 使用 `Authorization: Bearer ...` 与 `x-vela-workspace-id` 并行读取,不再请求需要浏览器会话的 `coding-plan-usage`。preflight 把窗口放在 `codingPlan` 内;解析前会核对内外两层工作区和成员身份。
83
+ - 钱包保留独立查询,按 `billingScopeVersion: 2` 契约校验。成功读取的钱包金额优先;钱包不可读时,经校验的 preflight 响应可提供 `balanceUsd` 作为余额。一侧失败保留另一侧,缺失数据不会变成零,失败原因保留在刷新记录中。
84
+ - 工作区 ID 来自 `GET https://amr-api.open-design.ai/api/v1/workspaces` 的 `items[].workspaceId`,不能填 `~/.amr/config.json` 中的 `profiles.prod.user.id`。
85
+ - 遇到 401/403,检查 Control Key 是否有效、是否属于所填工作区、是否有读取权限。推理 API Key 不能代替 Control Key,用户 ID 不能代替工作区 ID。如果该账户连 preflight 也拒绝,可在 OpenDesign Cloud 控制台查看额度;可读的钱包仍单独显示。
96
86
 
97
- 查询只访问上文列出的固定官方 HTTPS GET 端点;核对工作区,钱包必须提供成员身份,额度响应提供成员身份时再核对二者一致。回退响应省略外层冗余 `workspaceId` 时,在已由请求范围校验工作区的前提下仍接受;若响应指向不同工作区则拒绝。凭据由 DSH 凭据库管理,不回显、不写入账本,不跟随重定向,也不附带浏览器 Cookie。
87
+ 查询只访问上文列出的固定官方 HTTPS GET 端点;核对工作区,钱包必须提供成员身份,额度响应提供成员身份时再核对二者一致。preflight 响应省略外层冗余 `workspaceId` 时,在已由请求范围校验工作区的前提下仍接受;若响应指向不同工作区则拒绝。凭据由 DSH 凭据库管理,不回显、不写入账本,不跟随重定向,也不附带浏览器 Cookie。
98
88
 
99
- 所有实际返回的窗口分别显示已用百分比和重置时间,不相加、不标成无限。钱包作为独立的美元等值额度显示,真实零余额保留。额度与钱包独立查询:一侧失败时另一侧仍照常显示;`eligible: false`/空窗口回执(无论来自主端点还是回退端点)会明确报告为**无生效订阅**,不再与凭据失效混为一谈。认证失败、缺失回执或身份不匹配不显示虚构的零额度,两侧都失败时才显示错误/不可用状态。工作区配置跨重启保留,改变后清理原查询缓存。
89
+ 所有实际返回的窗口分别显示已用百分比和重置时间,不相加、不标成无限。钱包作为独立的美元等值额度显示,真实零余额保留。额度与钱包独立查询:一侧失败时另一侧仍照常显示;`eligible: false`/空窗口回执会明确报告为**无生效订阅**,不再与凭据失效混为一谈。认证失败、缺失回执或身份不匹配不显示虚构的零额度,两侧都失败时才显示错误/不可用状态。工作区配置跨重启保留,改变后清理原查询缓存。
100
90
 
101
- 公开价表已经直接读取;认证查询、Bearer-only `preflight` 回退与中英文设置使用模拟数据验证,覆盖大整数、零余额、串工作区/成员、单侧认证失败、preflight 形状的 `codingPlan` 回执、价格持久化等情况。**没有真实账户验证,没有调用付费模型。**真实账户的 Control Key 权限与服务端响应需要在配置后核对。
91
+ 公开价表已经直接读取;认证查询、直接读取 Bearer-only `preflight`与中英文设置使用模拟数据验证,覆盖大整数、零余额、串工作区/成员、单侧认证失败、preflight 形状的 `codingPlan` 回执、价格持久化等情况。**没有真实账户验证,没有调用付费模型。**真实账户的 Control Key 权限与服务端响应需要在配置后核对。
102
92
 
103
93
  端点来源:官方 Cloud bundle `cloud-root-B21Emo2w.js` 与 `pricing-refund-policy-BDFJHl33.js`(2026-10-15 读取);[工作区钱包契约](https://github.com/nexu-io/open-design/blob/7abd6fc2b11987c3940eb4ffc461478ff37c0b33/packages/contracts/src/api/collab.ts)与 [Vela 计费适配器](https://github.com/nexu-io/open-design/blob/7abd6fc2b11987c3940eb4ffc461478ff37c0b33/apps/daemon/src/integrations/vela-billing.ts)(上述 commit)。`billing/preflight` 的准确回执形状(`codingPlan` 内嵌窗口、`workspaceMemberId`、`balanceUsd`)来自 @yunjuanhuakai 的 [#274 评论](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236591566);401 复现与附件来自 @codeforker654 的 [评论](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236228870)。官方明确支持 DSH,说明这条 issue 有可执行的接入需求;仅凭“便宜、可能流行”的一句话,不能认定为广告。