dsh-cost-meter 1.9.2 → 1.9.4

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,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
- [![version](https://img.shields.io/badge/version-1.9.2-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
13
+ [![version](https://img.shields.io/badge/version-1.9.4-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.2** fixes OpenDesign Control Key quota queries, supports host-relative custom-balance URLs, explicitly enabled LAN HTTP and WorkBuddy2API credits, fixes skin opacity on pages and dialogs, and reduces automatic-language overhead in cost queries. It also includes the accounting, flush and rendering improvements recorded under v1.9.1. Ledger format and historical amounts are unchanged.
19
+ **v1.9.4** adds compact, stable model pricing, independent model statistics and display controls, and a peak-period progress style. It fixes OpenDesign credential saving and partial query feedback, and adds Codex quota windows with protected source switching.
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.2](docs/update-notes-1.9.2.md#english). Fully restart DSH after updating.
26
+ Release notes: [v1.9.4](docs/update-notes-1.9.4.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
 
@@ -54,6 +54,7 @@ If startup reports **Ledger is busy** and the cost widgets are missing, see [led
54
54
  | OpenCode Go quota | Sidebar / Settings / bottom-right dock (configurable) | Rolling-5h / weekly / monthly usage percent and reset times, each window toggleable independently, budget used % can show alongside; key auto-discovered (dedicated ref / official Go route apiKeyEnv / env / opencode login) or entered manually |
55
55
  | Coding plan quotas | Sidebar / Settings page (per vendor) | Multi-vendor coding-plan quota queries (Anthropic Claude Pro/Max, Z.ai / Zhipu GLM Coding Plan, MiniMax Token Plan, Kimi Code weekly + 5-hour quotas with PAYG balance fallback when no subscription key, OpenRouter credits, SiliconFlow balance, CommandCode 5h/weekly windows + monthly credits balance, Xiaomi MiMo Token Plan plan/compensation credit windows + period-end reset + balance via console cookie); per-vendor enable switch, key, display position and refresh interval (sidebar card in the same box style as the Go quota; the collapsed rail shows percentages), official endpoints by default, with a [configurable trusted MiniMax origin](docs/minimax-quota-endpoint.md#english); neutral hints when no credentials/subscription; SCNet Token Plan supports [external console snapshots](docs/scnet-official-snapshot.md#english); without a valid snapshot, monthly usage is estimated from the local ledger via the official credits deduction table (no credentials needed) |
56
56
  | Subscription plugin compatibility | Settings → Cost → Codex / sidebar & quota cards | Detects installed Codex / ChatGPT subscription plugins and classifies their subscription calls as Plan quota instead of pay-as-you-go API spend; new usage is classified at record time, and a one-time dismissible prompt decides whether historical Codex billing is reclassified (idempotent). Explicit plan/API choices are never overridden. [Details](docs/update-notes-1.9.0.md#english) |
57
+ | Codex quota display | Settings → Display → Codex / sidebar & quota strip | Reads the 5-hour and 7-day windows from `dsh-codex-subscription` directly, while staying compatible with the weekly window from `dsh-codex-connect`; the source can be `auto` (subscription first, fallback to connect), `subscription`, or `connect`. Independent of the billing classification in “Subscription plugin compatibility”. |
57
58
  | SQLite session storage (better-session) | Host integration | Auto-detects the host session backend; with `@morlay/better-session` / `@morlay/session-rdb` (SQLite) storage, historical backfill, legacy import, history repricing, hour-bucket repair, fork cleanup and per-session cost/trajectory/call details keep working. The JSONL path is unchanged; old JSONL and RDB histories are not merged automatically. [Guide](docs/better-session.md) |
58
59
  | OpenDesign quota | Sidebar / Settings (OpenDesign vendor) | Workspace coding-plan windows from the console API; with a Control Key, a 401/403 from the primary endpoint triggers one conservative `/billing/preflight` Bearer fallback, and window/wallet reads degrade independently. [Troubleshooting](docs/opendesign-billing.md#english) |
59
60
  | Mobile / dsh-pocket layout | All cost UIs | On screens ≤1023px and dsh-pocket mobile layouts: single-column cards, horizontally scrolling tabs, 36px touch targets, dialogs capped at 90vh with safe-area padding and scrolling wide tables; desktop layout unchanged |
@@ -340,22 +341,22 @@ On Node.js 20, use `npm install -g pnpm@10` instead. See [pnpm installation and
340
341
  dsh plugin --profile web add dsh-cost-meter
341
342
  ```
342
343
 
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.2`** — review the script before running):
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.4`** — review the script before running):
344
345
 
345
346
  ```powershell
346
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.2/install.ps1 | iex
347
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.4/install.ps1 | iex
347
348
  ```
348
349
 
349
350
  **Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
350
351
 
351
352
  ```sh
352
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.2
353
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.4
353
354
  ```
354
355
 
355
356
  Without git, use the GitHub tag archive:
356
357
 
357
358
  ```sh
358
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.2.tar.gz
359
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.4.tar.gz
359
360
  ```
360
361
 
361
362
  After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
@@ -420,7 +421,7 @@ Workarounds:
420
421
 
421
422
  ```yaml
422
423
  minimumReleaseAgeExclude:
423
- - dsh-cost-meter@1.9.2
424
+ - dsh-cost-meter@1.9.4
424
425
  ```
425
426
 
426
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
- [![version](https://img.shields.io/badge/version-1.9.2-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
13
+ [![version](https://img.shields.io/badge/version-1.9.4-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.2** 修复 OpenDesign Control Key 额度查询,支持跟随宿主随机端口的自定义余额地址、显式配置的局域网 HTTP 和 WorkBuddy2API 积分查询;修复皮肤透明度下的页面与弹窗透出,并减少自动语言模式的费用查询开销。此前 v1.9.1 的记账、落盘与渲染优化一并发布。账本格式与历史金额口径不变。
19
+ **v1.9.4** 带来固定顺序的紧凑定价列表、每模型独立统计、独立显示开关与峰谷进度条;修复 OpenDesign 凭据保存和部分查询反馈,加入 Codex 双窗口与数据源切换保护。
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.2](docs/update-notes-1.9.2.md#中文)。更新后完全重启 DSH。
26
+ 更新说明:[v1.9.4](docs/update-notes-1.9.4.md#中文)。更新后完全重启 DSH。
27
27
 
28
28
  声明范围内的宿主记录与此前的 0.1.x 历史见[兼容记录](docs/host-compatibility.md);逐版本清单在 `package.json` 的 `dsh.compatibility.dshReleases`。
29
29
 
@@ -54,6 +54,7 @@
54
54
  | OpenCode Go 额度 | 侧边栏 / 设置页 / 右下角(dock,可配) | 滚动 5 小时 / 本周 / 本月用量百分比与重置时间,三档可分别开关,可同时显示预算已用%;Key 自动发现(专用引用 / 官方 Go 路由 apiKeyEnv / 环境变量 / opencode 登录态)或手动填写 |
55
55
  | Coding Plan 额度 | 侧边栏 / 设置页(每家可配) | 多厂商 coding plan 订阅额度查询(Anthropic Claude Pro/Max、Z.ai/智谱 GLM、MiniMax Token Plan、Kimi Code 本周/5 小时配额(无订阅 Key 时回落 PAYG 余额)、OpenRouter credits、SiliconFlow 余额、CommandCode 5h/周窗口与月度 Credits 余额、小米 MiMo Token Plan 套餐/补偿积分窗口与周期截止重置、余额(控制台 Cookie 凭据)、火山方舟 Volcano Ark 5h/周/月三档(需 AK/SK 管控面 HMAC 签名,需 ArkReadOnlyAccess + BillingCenterReadOnlyAccess)),各家独立启用开关、凭据、显示位置与刷新间隔(侧边栏卡片与 Go 额度同款,收起窄栏显示百分比),默认使用官方端点,MiniMax 可[配置可信查询域名](docs/minimax-quota-endpoint.md);无凭据/无订阅为中性提示;SCNet 超算互联网 Token Plan 支持[外部控制台额度快照](docs/scnet-official-snapshot.md),无有效快照时按官方 Credits 抵扣表由本地账本估算月度用量(无需凭据) |
56
56
  | 订阅插件兼容 | 设置 → 费用 → Codex / 侧边栏与额度卡片 | 自动检测已安装的 Codex / ChatGPT 订阅插件,把其订阅调用归为 Plan 订阅额度、不计入 API 按量花费;新用量在记账时直接归类,历史 Codex 计费由一次性可关闭提示确认后重算(幂等)。显式 plan/API 配置不被覆盖。[说明](docs/update-notes-1.9.0.md#中文) |
57
+ | Codex 额度显示 | 设置 → 显示 → Codex / 侧边栏与额度横条 | 直接读取 `dsh-codex-subscription` 的 5 小时与 7 天窗口,同时兼容 `dsh-codex-connect` 的周窗口;数据源可选 `auto`(优先订阅插件,失败回退 connect)/ `subscription` / `connect`。与「订阅插件兼容」的计费归类别互不影响。 |
57
58
  | SQLite 会话存储(better-session) | 宿主集成 | 自动探测宿主会话后端;当 `@morlay/better-session` / `@morlay/session-rdb`(SQLite)接管存储时,历史回填、旧账本导入、历史重定价、小时桶修复、fork 清洗与逐会话费用/轨迹/调用详情继续可用。JSONL 路径行为不变;旧 JSONL 与 RDB 历史不自动合并。[说明](docs/better-session.md) |
58
59
  | OpenDesign 额度 | 侧边栏 / 设置页(OpenDesign 厂商) | 从控制台 API 读取工作区 coding plan 窗口;使用 Control Key 时主端点 401/403 会保守回退一次 `/billing/preflight`,窗口与钱包读取独立降级。[排查说明](docs/opendesign-billing.md#中文) |
59
60
  | 手机端适配(dsh-pocket) | 全部费用界面 | ≤1023px 窄屏与 dsh-pocket 移动布局下:卡片单列、标签横向滚动、36px 触控高度、对话框不超过 90vh 并避开安全区、宽表横向滚动;桌面布局不变 |
@@ -340,22 +341,22 @@ Node.js 20 请改用 `npm install -g pnpm@10`。版本要求见 [pnpm 官方安
340
341
  dsh plugin --profile web add dsh-cost-meter
341
342
  ```
342
343
 
343
- **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.9.2`**,建议先下载审阅再运行):
344
+ **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.9.4`**,建议先下载审阅再运行):
344
345
 
345
346
  ```powershell
346
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.2/install.ps1 | iex
347
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.4/install.ps1 | iex
347
348
  ```
348
349
 
349
350
  **或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
350
351
 
351
352
  ```sh
352
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.2
353
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.4
353
354
  ```
354
355
 
355
356
  没有 git 时可用 GitHub tag 打包直链:
356
357
 
357
358
  ```sh
358
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.2.tar.gz
359
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.4.tar.gz
359
360
  ```
360
361
 
361
362
  安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
@@ -420,7 +421,7 @@ DSH **0.2.1-rc.1 / 0.2.1-rc.2** 宿主自带 pnpm **11.28.5**,默认启用内
420
421
 
421
422
  ```yaml
422
423
  minimumReleaseAgeExclude:
423
- - dsh-cost-meter@1.9.2
424
+ - dsh-cost-meter@1.9.4
424
425
  ```
425
426
 
426
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 上实测可用。
@@ -6,10 +6,24 @@
6
6
 
7
7
  右侧直接展示简洁、标准和紧凑三种样式的小预览,复用实际预算与多时段额度的进度卡片。小预览标记为样式示例,未配置的额度使用本地示例数值。紧凑样式将多时段额度排成两列,预算卡片保持完整。点击峰谷条可切换细条或分段样式;点击“今日金额 · 模型数”可调整模型卡片的展开、周期、摘要、位置、行数、Token 和费用占比条。预算、余额、会话费用和额度条的选项各自放在对应组件旁。金额格式、换算和语言集中在下方。宽窗口将样式缩略图横向排列,窄窗口再改为竖向;右侧面板在空间不足时排到预览下方。放大预览中按 Escape 返回。
8
8
 
9
- 侧栏预览和真实侧栏共用完整的呈现函数与当前缓存数据,包含余额错误状态、Go 与预算合并卡、预算内的今日用量和峰谷条、模型花费卡片。选择框使用独立覆盖层,不改变组件 DOM 层级和紧凑布局。打开时最多读取三个宿主表面的背景、圆角、字体等六项外观属性;主题属性变化时更新。共用插件组件、DSH 图标和主题变量,跟随这些外观的皮肤修改;其他插件的独立控件不重复挂载。
9
+ 侧栏预览和真实侧栏共用完整的呈现函数与当前缓存数据,包含余额错误状态、Go 与预算合并卡、独立显示的预算、今日用量和峰谷条、模型花费卡片。选择框使用独立覆盖层,不改变组件 DOM 层级和紧凑布局。打开时最多读取三个宿主表面的背景、圆角、字体等六项外观属性;主题属性变化时更新。共用插件组件、DSH 图标和主题变量,跟随这些外观的皮肤修改;其他插件的独立控件不重复挂载。
10
10
 
11
11
  两种数据来源共用实际展示组件。示例状态只传给预览,不写入配置、余额、额度或账本,也不会启用账户查询或 Codex 探测。预览不复制会话内容,不遍历整页 DOM,不创建 iframe,不解码图片,不订阅会话投影。选择框只测量当前预览内最多 32 个标记节点,使用一个局部尺寸监听器;关闭时清理尺寸与主题监听器。异常组件由预览内部的错误边界隔离,仍可使用详细显示选项。
12
12
 
13
13
  预算显示和预算统计分别控制。隐藏预算卡片不会关闭预算统计;隐藏峰谷条不会关闭峰谷计价;显示 Go 占位不会启用账户查询。
14
14
 
15
15
  原生图标的来源和许可证见仓库根目录 THIRD_PARTY_NOTICES.md。
16
+
17
+ 侧栏区域上方直接提供预算、今日用量、峰谷时段和模型花费四个显示开关,不必先选中组件。今日用量单行与“今日金额 · 模型数”摘要分别控制;关闭其中一个不影响其他组件,没有其他组件时也可以只显示峰谷条。隐藏侧栏今日用量不会隐藏概览里的今日费用,预算详细信息开关也不影响今日用量。所有组件关闭时不保留空白区域。
18
+
19
+ 选择套餐进度条后,可以在同一面板选择 MiniMax 等账户、调整该账户的显示位置和侧栏开关。切换账户只切换编辑对象,不启用额度查询;进度条方向统一应用于所有套餐。需要修改凭据或查询参数时,点击“账户与额度设置”直接展开并定位到所选账户。
20
+
21
+ 价格 → 模型定价中,每个模型下方的“计入统计”可展开三个独立开关:今日费用、月度与累计、预算。开关按渠道和模型保存,只改变对应汇总,不删除原始调用或重新定价。重新勾选可恢复统计。今日模型花费摘要跟随今日费用的选择;月度与累计、预算各用自己的选择。
22
+
23
+ 模型定价以固定排序的紧凑列表展示,宽窗口中三项单价按列对齐,窄窗口在模型名下方排列。切换价格来源时模型保留原位置;选择自定义后,只定位一次到自定义编辑区的开头。保存价格或修改币种时不重新滚动。
24
+
25
+ 峰谷时段新增“进度条”样式,显示当前计价时段已过的比例。峰时使用橙色,平价、周末和节假日使用 DSH 主题蓝色。标准侧栏显示完整信息,简洁侧栏使用两行,紧凑侧栏使用单行;可选择倒计时、切换时间或同时显示两者,悬停查看完整说明。周末和节假日会显示下一次切换的星期或日期,进度从连续谷价时段真正开始的时刻计算。
26
+
27
+ 选中峰谷时段后,右侧以三张紧凑的实际效果卡片展示进度条、细条和分段样式,复用侧栏呈现函数,包含当前时段文字、橙蓝轨道和倒计时。蓝色边框和“已选”标明当前选择,样式说明放在悬停提示中,点击后立即更新左侧预览。右侧收窄并减少内边距和重复说明;桌面设置保持左侧预览、右侧调整,与其他组件使用相同的窄屏换行条件。显示时间的完整选项放在右侧卡片下方。预览中超长的时段文字以省略号收起,保留可见轨道,悬停或键盘聚焦可读取完整说明。样式示例只渲染峰谷组件,不挂载余额、额度和模型卡片,也不会把示例开关写入配置。
28
+
29
+ 已开启峰谷计价且未隐藏峰谷显示的用户,更新后首次进入会看到一次介绍和三种布局预览。可以使用新进度条,也可以保留原样;关闭或选择后不再重复提示。原细条和分段样式保留。介绍中的预览只读取配置和本机时间,不查询余额、不发送模型请求、不改变计价或历史记录。新界面按需加载,页面隐藏时停止刷新,关闭组件时清理定时器和监听器。
@@ -1,93 +1,99 @@
1
- # OpenDesign billing and quota / 计费与额度
2
-
3
- ## English
4
-
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
-
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
-
9
- ### Conversation costs
10
-
11
- - The offline catalog contains 35 token-priced models checked on **2026-10-15**, from the [official public API](https://amr-api.open-design.ai/api/v1/public/model-prices). Prices are **USD per 1M tokens**, with cache read/write rates and long-context tiers where provided. The long tier applies to the entire request only above its input threshold, including cached input.
12
- - Provider IDs `opendesign`, `open-design`, `open-design-api` and `amr-link.open-design.ai`, including DSH's `llm-` prefix, use this separate catalog. A custom price under the original alias takes priority. Other provider IDs can use the existing explicit price mapping and plan-assignment controls.
13
- - OpenDesign prices never serve as fallback prices for another provider. Unknown OpenDesign models stay unpriced; the plugin does not borrow a direct-vendor price.
14
- - **Settings → Cost → Prices → Sync official prices** also refreshes the public OpenDesign catalog. A used/enabled OpenDesign channel refreshes at startup and hourly. No key or model request is needed. User-edited prices and removed models stay intact. Saved price versions preserve existing details when rates change; recalculation is explicit and retains the original amounts. A historical price version that was never captured cannot be reconstructed.
15
-
16
- OpenDesign uses shared subscription allowances and can fall back to its wallet; see its [model-credit rules](https://open-design.ai/model-credits/). Calls default to **Plan-equivalent cost**, which is not a subscription payment or a cash bill. Set wallet-funded calls to **API** in the billing-classification controls, or assign individual models explicitly. DSH's standard usage response does not identify each request's funding source, account-specific discount, image charge or automatic top-up. Those amounts are not invented from the list price or balance movement.
17
-
18
- ### Quota queries
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
-
22
- 1. Open **Settings → Cost → Quotas**, find **OpenDesign**, and expand its settings.
23
- 2. Enter the exact **workspace ID** from your OpenDesign Cloud workspace.
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
- 4. Enable the card and refresh. Select its location to also show it in the sidebar or quota strip.
26
-
27
- The host issues only these authenticated GET requests to the fixed official HTTPS origin:
28
-
29
- ```text
30
- https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/billing/preflight # direct Bearer-only window query
31
- https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/wallet/balance # wallet, read independently
32
- ```
33
-
34
- #### Endpoint permissions and 401 troubleshooting
35
-
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.
40
-
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.
42
-
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.
44
-
45
- ### Evidence and limits
46
-
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.
48
-
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.
50
-
51
- ## 中文
52
-
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、注册账户或改变模型路由。
54
-
55
- ### 会话计费
56
-
57
- - 从[官方公开价表](https://amr-api.open-design.ai/api/v1/public/model-prices)加入 **35 个模型**,核对日期为 **2026-10-15**。单位为 **美元/百万 Token**,包含已公布的缓存读取、缓存写入和长上下文价格。超过输入阈值后,整次请求使用长档,输入阈值包含缓存输入。
58
- - `opendesign`、`open-design`、`open-design-api`、`amr-link.open-design.ai` 及其 `llm-` 前缀使用独立目录;原渠道中手工配置的价格优先。其他自定义名称可通过既有价格映射和套餐归属入口关联。
59
- - 未收录的 OpenDesign 模型标为未定价,不借用直连厂商价格;其他渠道也不会使用 OpenDesign 价作为兜底。
60
- - **设置 → 费用 → 价格 → 同步官方价格**会同步公开目录。已使用或开启 OpenDesign 时,启动和每小时也会刷新;不需要密钥,不调用模型。自定义价格、取消挂载和已保存价格版本的历史明细保留。历史重算需要主动确认并保留原金额;未保存过的历史价格版本无法还原。
61
-
62
- OpenDesign 的 API 与客户端共用套餐,套餐用尽后可以继续扣钱包,详见[官方额度规则](https://open-design.ai/zh/model-credits/)。因此默认计入 **Plan 等值费用**,不把额度当成现金支出。钱包付款可在计费分类中设为 **API**,也可逐模型配置。DSH 的标准用量回执没有逐次扣款来源、账户折扣、图片费用或自动充值金额,这些金额不会通过公开单价或余额变化猜算。
63
-
64
- ### 额度查询
65
-
66
- **只使用 DSH 的情况:**在 DSH 调用 OpenDesign 模型 API、统计会话费用,都不需要安装 OpenDesign 应用。远端额度查询另外需要 OpenDesign Cloud 账户的工作区 ID 和 Control Key,推理 API Key 不能代替。如果只有推理密钥,可以关闭额度卡片,价格匹配和会话计费照常工作。
67
-
68
- 1. 在 **设置 → 费用 → 额度**找到并展开 **OpenDesign**。
69
- 2. 填入 OpenDesign Cloud 中对应的**工作区 ID**。
70
- 3. 在凭据编辑器中配置 **Control Key**,或向 DSH 宿主提供 `OPENDESIGN_CONTROL_KEY` / `VELA_CONTROL_KEY`。Cloud API Keys 页生成的推理密钥与查询凭据不同,不能混用。已有 OpenDesign/Vela 登录将控制端凭据保存在其自身配置中,本插件不会自动读取或修改那个配置。
71
- 4. 开启并刷新,可选择在侧栏或额度横条显示。
72
-
73
- 查询只访问以下固定官方 HTTPS GET 端点,并在凭据/工作区校验之后才发起:
74
-
75
- ```text
76
- https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/billing/preflight # 直接使用纯 Bearer 查询窗口
77
- https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/wallet/balance # 钱包端点,独立读取
78
- ```
79
-
80
- #### 端点权限与 401 排查
81
-
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 控制台查看额度;可读的钱包仍单独显示。
86
-
87
- 查询只访问上文列出的固定官方 HTTPS GET 端点;核对工作区,钱包必须提供成员身份,额度响应提供成员身份时再核对二者一致。preflight 响应省略外层冗余 `workspaceId` 时,在已由请求范围校验工作区的前提下仍接受;若响应指向不同工作区则拒绝。凭据由 DSH 凭据库管理,不回显、不写入账本,不跟随重定向,也不附带浏览器 Cookie。
88
-
89
- 所有实际返回的窗口分别显示已用百分比和重置时间,不相加、不标成无限。钱包作为独立的美元等值额度显示,真实零余额保留。额度与钱包独立查询:一侧失败时另一侧仍照常显示;`eligible: false`/空窗口回执会明确报告为**无生效订阅**,不再与凭据失效混为一谈。认证失败、缺失回执或身份不匹配不显示虚构的零额度,两侧都失败时才显示错误/不可用状态。工作区配置跨重启保留,改变后清理原查询缓存。
90
-
91
- 公开价表已经直接读取;认证查询、直接读取 Bearer-only `preflight`与中英文设置使用模拟数据验证,覆盖大整数、零余额、串工作区/成员、单侧认证失败、preflight 形状的 `codingPlan` 回执、价格持久化等情况。**没有真实账户验证,没有调用付费模型。**真实账户的 Control Key 权限与服务端响应需要在配置后核对。
92
-
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 有可执行的接入需求;仅凭“便宜、可能流行”的一句话,不能认定为广告。
1
+ # OpenDesign billing and quota / 计费与额度
2
+
3
+ ## English
4
+
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
+
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
+
9
+ ### Conversation costs
10
+
11
+ - The offline catalog contains 35 token-priced models checked on **2026-10-15**, from the [official public API](https://amr-api.open-design.ai/api/v1/public/model-prices). Prices are **USD per 1M tokens**, with cache read/write rates and long-context tiers where provided. The long tier applies to the entire request only above its input threshold, including cached input.
12
+ - Provider IDs `opendesign`, `open-design`, `open-design-api` and `amr-link.open-design.ai`, including DSH's `llm-` prefix, use this separate catalog. A custom price under the original alias takes priority. Other provider IDs can use the existing explicit price mapping and plan-assignment controls.
13
+ - OpenDesign prices never serve as fallback prices for another provider. Unknown OpenDesign models stay unpriced; the plugin does not borrow a direct-vendor price.
14
+ - **Settings → Cost → Prices → Sync official prices** also refreshes the public OpenDesign catalog. A used/enabled OpenDesign channel refreshes at startup and hourly. No key or model request is needed. User-edited prices and removed models stay intact. Saved price versions preserve existing details when rates change; recalculation is explicit and retains the original amounts. A historical price version that was never captured cannot be reconstructed.
15
+
16
+ OpenDesign uses shared subscription allowances and can fall back to its wallet; see its [model-credit rules](https://open-design.ai/model-credits/). Calls default to **Plan-equivalent cost**, which is not a subscription payment or a cash bill. Set wallet-funded calls to **API** in the billing-classification controls, or assign individual models explicitly. DSH's standard usage response does not identify each request's funding source, account-specific discount, image charge or automatic top-up. Those amounts are not invented from the list price or balance movement.
17
+
18
+ ### Quota queries
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
+
22
+ 1. Open **Settings → Cost → Quotas**, find **OpenDesign**, and expand its settings.
23
+ 2. Enter the exact **workspace ID** from your OpenDesign Cloud workspace.
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
+ 4. Enable the card and refresh. Select its location to also show it in the sidebar or quota strip.
26
+
27
+ The credential editor saves to `OPENDESIGN_CONTROL_KEY` in the DSH credential store. Both it and the `VELA_CONTROL_KEY` alias are reflected in the configured/source indicator. Clearing the editor removes the primary stored key; an alias or host environment value can remain active. Legacy OpenDesign config keys also use the existing startup migration. This repairs the missing editor mapping reported and located by @unifilitence in [#317](https://github.com/Han-1413141/dsh-cost-meter/issues/317).
28
+
29
+ The host issues only these authenticated GET requests to the fixed official HTTPS origin:
30
+
31
+ ```text
32
+ https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/billing/preflight # direct Bearer-only window query
33
+ https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/wallet/balance # wallet, read independently
34
+ ```
35
+
36
+ #### Endpoint permissions and 401 troubleshooting
37
+
38
+ - `/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.
39
+ - 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, including when no subscription is active. Failure on one side preserves the other; no missing value becomes a fabricated zero. The failing side and reason appear in the settings card, sidebar/strip tooltip and manual-refresh result. A fallback balance is labelled as coming from `billing/preflight`.
40
+ - 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`.
41
+ - 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.
42
+
43
+ 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.
44
+
45
+ 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.
46
+
47
+ ### Evidence and limits
48
+
49
+ The public catalog was fetched without authentication; all 35 prices still matched the bundled catalog on 2026-10-18. The credential RPC is covered through save, read, clear, migration, aliases, workspace/key changes during an in-flight read, both wire codecs and ledger redaction. With host dependencies available, the same test also exercises the real DSH local credential provider in an isolated profile. Authenticated HTTP responses remain synthetic, including large credit counts, zero balances, mismatched identities, independent failures, no-subscription fallback balances, and price-refresh persistence. **No live account query or paid model request was made.**
50
+
51
+ 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.
52
+
53
+ ## 中文
54
+
55
+ 本版本实现了 @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、注册账户或改变模型路由。
56
+
57
+ ### 会话计费
58
+
59
+ - 从[官方公开价表](https://amr-api.open-design.ai/api/v1/public/model-prices)加入 **35 个模型**,核对日期为 **2026-10-15**。单位为 **美元/百万 Token**,包含已公布的缓存读取、缓存写入和长上下文价格。超过输入阈值后,整次请求使用长档,输入阈值包含缓存输入。
60
+ - `opendesign`、`open-design`、`open-design-api`、`amr-link.open-design.ai` 及其 `llm-` 前缀使用独立目录;原渠道中手工配置的价格优先。其他自定义名称可通过既有价格映射和套餐归属入口关联。
61
+ - 未收录的 OpenDesign 模型标为未定价,不借用直连厂商价格;其他渠道也不会使用 OpenDesign 价作为兜底。
62
+ - **设置 → 费用 → 价格 → 同步官方价格**会同步公开目录。已使用或开启 OpenDesign 时,启动和每小时也会刷新;不需要密钥,不调用模型。自定义价格、取消挂载和已保存价格版本的历史明细保留。历史重算需要主动确认并保留原金额;未保存过的历史价格版本无法还原。
63
+
64
+ OpenDesign 的 API 与客户端共用套餐,套餐用尽后可以继续扣钱包,详见[官方额度规则](https://open-design.ai/zh/model-credits/)。因此默认计入 **Plan 等值费用**,不把额度当成现金支出。钱包付款可在计费分类中设为 **API**,也可逐模型配置。DSH 的标准用量回执没有逐次扣款来源、账户折扣、图片费用或自动充值金额,这些金额不会通过公开单价或余额变化猜算。
65
+
66
+ ### 额度查询
67
+
68
+ **只使用 DSH 的情况:**在 DSH 调用 OpenDesign 模型 API、统计会话费用,都不需要安装 OpenDesign 应用。远端额度查询另外需要 OpenDesign Cloud 账户的工作区 ID 和 Control Key,推理 API Key 不能代替。如果只有推理密钥,可以关闭额度卡片,价格匹配和会话计费照常工作。
69
+
70
+ 1. 在 **设置 → 费用 → 额度**找到并展开 **OpenDesign**。
71
+ 2. 填入 OpenDesign Cloud 中对应的**工作区 ID**。
72
+ 3. 在凭据编辑器中配置 **Control Key**,或向 DSH 宿主提供 `OPENDESIGN_CONTROL_KEY` / `VELA_CONTROL_KEY`。Cloud API Keys 页生成的推理密钥与查询凭据不同,不能混用。已有 OpenDesign/Vela 登录将控制端凭据保存在其自身配置中,本插件不会自动读取或修改那个配置。
73
+ 4. 开启并刷新,可选择在侧栏或额度横条显示。
74
+
75
+ 凭据编辑器会把密钥保存到 DSH 凭据库的 `OPENDESIGN_CONTROL_KEY`。该名称与 `VELA_CONTROL_KEY` 别名都会反映到“已配置/来源”状态。清除只移除编辑器保存的首选密钥;别名或宿主环境变量仍可能生效。旧配置中的 OpenDesign 密钥也会参与既有的启动迁移。这修复了 @unifilitence 在 [#317](https://github.com/Han-1413141/dsh-cost-meter/issues/317) 报告并定位的凭据映射遗漏。
76
+
77
+ 查询只访问以下固定官方 HTTPS GET 端点,并在凭据/工作区校验之后才发起:
78
+
79
+ ```text
80
+ https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/billing/preflight # 直接使用纯 Bearer 查询窗口
81
+ https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/wallet/balance # 钱包端点,独立读取
82
+ ```
83
+
84
+ #### 端点权限与 401 排查
85
+
86
+ - `/billing/preflight` 和 `/wallet/balance` 使用 `Authorization: Bearer ...` 与 `x-vela-workspace-id` 并行读取,不再请求需要浏览器会话的 `coding-plan-usage`。preflight 把窗口放在 `codingPlan` 内;解析前会核对内外两层工作区和成员身份。
87
+ - 钱包保留独立查询,按 `billingScopeVersion: 2` 契约校验。成功读取的钱包金额优先;钱包不可读时,经校验的 preflight 响应可提供 `balanceUsd` 作为余额,包括没有生效套餐的情况。一侧失败保留另一侧,缺失数据不会变成零。设置卡片、侧栏/横条提示和手动刷新结果都会显示失败的一侧与原因;备用余额会注明来自 `billing/preflight`。
88
+ - 工作区 ID 来自 `GET https://amr-api.open-design.ai/api/v1/workspaces` 的 `items[].workspaceId`,不能填 `~/.amr/config.json` 中的 `profiles.prod.user.id`。
89
+ - 遇到 401/403,检查 Control Key 是否有效、是否属于所填工作区、是否有读取权限。推理 API Key 不能代替 Control Key,用户 ID 不能代替工作区 ID。如果该账户连 preflight 也拒绝,可在 OpenDesign Cloud 控制台查看额度;可读的钱包仍单独显示。
90
+
91
+ 查询只访问上文列出的固定官方 HTTPS GET 端点;核对工作区,钱包必须提供成员身份,额度响应提供成员身份时再核对二者一致。preflight 响应省略外层冗余 `workspaceId` 时,在已由请求范围校验工作区的前提下仍接受;若响应指向不同工作区则拒绝。凭据由 DSH 凭据库管理,不回显、不写入账本,不跟随重定向,也不附带浏览器 Cookie。
92
+
93
+ 所有实际返回的窗口分别显示已用百分比和重置时间,不相加、不标成无限。钱包作为独立的美元等值额度显示,真实零余额保留。额度与钱包独立查询:一侧失败时另一侧仍照常显示;`eligible: false`/空窗口回执会明确报告为**无生效订阅**,不再与凭据失效混为一谈。认证失败、缺失回执或身份不匹配不显示虚构的零额度,两侧都失败时才显示错误/不可用状态。工作区配置跨重启保留,改变后清理原查询缓存。
94
+
95
+ 2026-10-18 直接读取官方公开价表,35 个模型的价格与内置目录一致。凭据 RPC 验证覆盖保存、读取、清除、迁移、别名、查询期间切换工作区/密钥、双端 codec 和账本脱敏;具备宿主依赖时,同一测试还会在隔离配置中使用真实 DSH 本地凭据库。认证 HTTP 响应使用模拟数据,覆盖大整数、零余额、串工作区/成员、单侧失败、无订阅时保留备用余额、价格持久化等情况。**没有真实 OpenDesign 账户查询,没有调用付费模型。**
96
+
97
+ 本次还核对了官方 [preflight 类型契约](https://github.com/nexu-io/open-design/blob/78d5637cb49da07e81314d1544b5fc6d37c95084/packages/contracts/src/api/collab.ts)与 [Vela 解析器](https://github.com/nexu-io/open-design/blob/78d5637cb49da07e81314d1544b5fc6d37c95084/apps/daemon/src/integrations/vela-billing.ts),检查工作区、成员、窗口和钱包字段。
98
+
99
+ 端点来源:官方 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 有可执行的接入需求;仅凭“便宜、可能流行”的一句话,不能认定为广告。