dsh-cost-meter 1.9.30 → 1.9.32

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
@@ -6,7 +6,7 @@
6
6
 
7
7
  **Session cost tracking plugin for the DeepSeek Harness web GUI (bilingual UI)**
8
8
 
9
- [![version](https://img.shields.io/badge/version-1.9.30-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
9
+ [![version](https://img.shields.io/badge/version-1.9.32-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
10
10
  [![npm](https://img.shields.io/npm/v/dsh-cost-meter?label=npm)](https://www.npmjs.com/package/dsh-cost-meter)
11
11
  [![dshfind](https://dshfind.com/api/badge/Han-1413141/dsh-cost-meter?metric=downloads&lang=en)](https://dshfind.com/zh/plugins/Han-1413141/dsh-cost-meter?ref=badge)
12
12
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
@@ -16,11 +16,11 @@
16
16
 
17
17
  </div>
18
18
 
19
- **v1.9.30** fixes Desktop sidebar spacing, OpenDesign balance placement, two-line Today alignment and background ledger saving/disposal.
19
+ **v1.9.32** adds full settings to the plugin details page and fixes concurrent saves, CNY conversion and frozen currency totals. The future read-only settings page is prepared but remains disabled.
20
20
 
21
21
  **Host floor: DSH 0.2.0** · Adaptation target: **0.2.1-rc.2** (npm `next`). Expand the compatibility notes below for exact declarations, host records and troubleshooting.
22
22
 
23
- Release notes: [v1.9.30](docs/update-notes-1.9.30.md#english). Fully restart DSH after updating.
23
+ Release notes: [v1.9.32](docs/update-notes-1.9.32.md#english). Fully restart DSH after updating.
24
24
 
25
25
  ![Promo art](docs/promo.en.png)
26
26
 
@@ -65,7 +65,7 @@ Community and feedback: [Join the WeChat group →](#community). The WeChat grou
65
65
  | 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 |
66
66
  | 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, Cline Pass 5-hour/weekly/monthly windows, 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) |
67
67
  | 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) |
68
- | Codex quota display | Settings → Display → Codex / sidebar & quota strip | Reads actual quota windows from `dsh-codex-subscription`, the native DSH pi-ai login, `@eddyskywalker/dsh-chatgpt-subscription`, or `dsh-codex-connect`. Select `auto` (tries these sources in order), `subscription`, `pi-ai`, `chatgpt`, or `connect`. Native pi-ai needs no extra subscription plugin. Weekly-only accounts show no 5h bar. An explicit source uses only that source's current account; billing classification remains separate. |
68
+ | Codex quota display | Settings → Display → Codex / sidebar & quota strip | Reads actual quota windows from `dsh-codex-subscription`, the native DSH pi-ai login, `dsh-chatgpt-sub`, `@eddyskywalker/dsh-chatgpt-subscription`, or `dsh-codex-connect`. Select `auto` (tries these sources in order), `subscription`, `pi-ai`, `chatgpt-sub`, `chatgpt`, or `connect`. Enable quota display and select `dsh-chatgpt-sub` for its bound account's remaining bars and reset times. Weekly-only accounts show no 5h bar. An explicit source uses only that source's current account; billing classification remains separate. |
69
69
  | 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) |
70
70
  | 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) |
71
71
  | 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 |
@@ -352,22 +352,22 @@ On Node.js 20, use `npm install -g pnpm@10` instead. See [pnpm installation and
352
352
  dsh plugin --profile web add dsh-cost-meter
353
353
  ```
354
354
 
355
- **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.30`** — review the script before running):
355
+ **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.32`** — review the script before running):
356
356
 
357
357
  ```powershell
358
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.30/install.ps1 | iex
358
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.32/install.ps1 | iex
359
359
  ```
360
360
 
361
361
  **Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
362
362
 
363
363
  ```sh
364
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.30
364
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.32
365
365
  ```
366
366
 
367
367
  Without git, use the GitHub tag archive:
368
368
 
369
369
  ```sh
370
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.30.tar.gz
370
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.32.tar.gz
371
371
  ```
372
372
 
373
373
  After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
@@ -432,7 +432,7 @@ Workarounds:
432
432
 
433
433
  ```yaml
434
434
  minimumReleaseAgeExclude:
435
- - dsh-cost-meter@1.9.30
435
+ - dsh-cost-meter@1.9.32
436
436
  ```
437
437
 
438
438
  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
@@ -6,7 +6,7 @@
6
6
 
7
7
  **DeepSeek Harness 会话费用统计插件(界面中英双语)**
8
8
 
9
- [![version](https://img.shields.io/badge/version-1.9.30-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
9
+ [![version](https://img.shields.io/badge/version-1.9.32-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
10
10
  [![npm](https://img.shields.io/npm/v/dsh-cost-meter?label=npm)](https://www.npmjs.com/package/dsh-cost-meter)
11
11
  [![dshfind](https://dshfind.com/api/badge/Han-1413141/dsh-cost-meter?metric=downloads&lang=zh)](https://dshfind.com/zh/plugins/Han-1413141/dsh-cost-meter?ref=badge)
12
12
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
@@ -16,11 +16,11 @@
16
16
 
17
17
  </div>
18
18
 
19
- **v1.9.30** 修复桌面侧栏底部留白、OpenDesign 余额位置、今日消费两行对齐,以及后台账本保存和卸载卡住的问题。
19
+ **v1.9.32** 插件详情页新增完整费用设置,修复并发保存、人民币折算和历史币种金额同步。实时费用与额度展示页已备好,暂不启用。
20
20
 
21
21
  **宿主要求:DSH 0.2.0 起支持** · 适配目标 **0.2.1-rc.2**(npm `next`)。完整声明、历史记录与安装排障见下方展开项。
22
22
 
23
- 更新说明:[v1.9.30](docs/update-notes-1.9.30.md#中文)。更新后完全重启 DSH。
23
+ 更新说明:[v1.9.32](docs/update-notes-1.9.32.md#中文)。更新后完全重启 DSH。
24
24
 
25
25
  ![宣传图](docs/promo.png)
26
26
 
@@ -65,7 +65,7 @@
65
65
  | OpenCode Go 额度 | 侧边栏 / 设置页 / 右下角(dock,可配) | 滚动 5 小时 / 本周 / 本月用量百分比与重置时间,三档可分别开关,可同时显示预算已用%;Key 自动发现(专用引用 / 官方 Go 路由 apiKeyEnv / 环境变量 / opencode 登录态)或手动填写 |
66
66
  | 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 余额、Cline Pass 5 小时/周/月三窗口用量%、小米 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 抵扣表由本地账本估算月度用量(无需凭据) |
67
67
  | 订阅插件兼容 | 设置 → 费用 → Codex / 侧边栏与额度卡片 | 自动检测已安装的 Codex / ChatGPT 订阅插件,把其订阅调用归为 Plan 订阅额度、不计入 API 按量花费;新用量在记账时直接归类,历史 Codex 计费由一次性可关闭提示确认后重算(幂等)。显式 plan/API 配置不被覆盖。[说明](docs/update-notes-1.9.0.md#中文) |
68
- | Codex 额度显示 | 设置 → 显示 → Codex / 侧边栏与额度横条 | 读取 `dsh-codex-subscription`、DSH 内置 pi-ai 登录、`@eddyskywalker/dsh-chatgpt-subscription`、`dsh-codex-connect` 的实际额度窗口;数据源可选 `auto`(按上述顺序尝试)/ `subscription` / `pi-ai` / `chatgpt` / `connect`。pi-ai 登录无需额外订阅插件,只有周额度的账号不显示 5h 条。固定来源只查询该来源的当前账号,与计费归类设置互不影响。 |
68
+ | Codex 额度显示 | 设置 → 显示 → Codex / 侧边栏与额度横条 | 读取 `dsh-codex-subscription`、DSH 内置 pi-ai 登录、`dsh-chatgpt-sub`、`@eddyskywalker/dsh-chatgpt-subscription`、`dsh-codex-connect` 的实际额度窗口;数据源可选 `auto`(按上述顺序尝试)/ `subscription` / `pi-ai` / `chatgpt-sub` / `chatgpt` / `connect`。开启额度显示并选择 `dsh-chatgpt-sub`,即可查看其绑定账号的剩余进度条和重置时间。只有周额度的账号不显示 5h 条。固定来源只查询该来源的当前账号,与计费归类设置互不影响。 |
69
69
  | SQLite 会话存储(better-session) | 宿主集成 | 自动探测宿主会话后端;当 `@morlay/better-session` / `@morlay/session-rdb`(SQLite)接管存储时,历史回填、旧账本导入、历史重定价、小时桶修复、fork 清洗与逐会话费用/轨迹/调用详情继续可用。JSONL 路径行为不变;旧 JSONL 与 RDB 历史不自动合并。[说明](docs/better-session.md) |
70
70
  | OpenDesign 额度 | 侧边栏 / 设置页(OpenDesign 厂商) | 从控制台 API 读取工作区 coding plan 窗口;使用 Control Key 时主端点 401/403 会保守回退一次 `/billing/preflight`,窗口与钱包读取独立降级。[排查说明](docs/opendesign-billing.md#中文) |
71
71
  | 手机端适配(dsh-pocket) | 全部费用界面 | ≤1023px 窄屏与 dsh-pocket 移动布局下:卡片单列、标签横向滚动、36px 触控高度、对话框不超过 90vh 并避开安全区、宽表横向滚动;桌面布局不变 |
@@ -352,22 +352,22 @@ Node.js 20 请改用 `npm install -g pnpm@10`。版本要求见 [pnpm 官方安
352
352
  dsh plugin --profile web add dsh-cost-meter
353
353
  ```
354
354
 
355
- **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.9.30`**,建议先下载审阅再运行):
355
+ **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.9.32`**,建议先下载审阅再运行):
356
356
 
357
357
  ```powershell
358
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.30/install.ps1 | iex
358
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.32/install.ps1 | iex
359
359
  ```
360
360
 
361
361
  **或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
362
362
 
363
363
  ```sh
364
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.30
364
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.32
365
365
  ```
366
366
 
367
367
  没有 git 时可用 GitHub tag 打包直链:
368
368
 
369
369
  ```sh
370
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.30.tar.gz
370
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.32.tar.gz
371
371
  ```
372
372
 
373
373
  安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
@@ -432,7 +432,7 @@ DSH **0.2.1-rc.1 / 0.2.1-rc.2** 宿主自带 pnpm **11.28.5**,默认启用内
432
432
 
433
433
  ```yaml
434
434
  minimumReleaseAgeExclude:
435
- - dsh-cost-meter@1.9.30
435
+ - dsh-cost-meter@1.9.32
436
436
  ```
437
437
 
438
438
  3. 仅本次操作用 CLI 透传 pnpm 参数:`dsh plugin --profile desktop remove dsh-cost-meter --config.minimum-release-age=0`;若只是 lockfile 校验阶段失败,可改用 `--trust-lockfile`。这两个参数已在本机 pnpm 11.28.5 临时 Profile 上实测可用。
@@ -4,7 +4,9 @@
4
4
 
5
5
  关闭输入框上方的 Codex 额度条:选择“输入区 → 调整组件 → Codex 额度”,取消“在输入区显示 Codex 额度”。该开关与侧栏额度独立,不影响预算、Go 或其他套餐的额度条;两个 Codex 显示位置都隐藏时停止查询。
6
6
 
7
- Codex 额度的真实数据来自已启用并登录的 `dsh-codex-subscription`、`@eddyskywalker/dsh-chatgpt-subscription` 或 `dsh-codex-connect`。自动检测依次尝试这三个插件;在 Codex 显示设置中指定数据源后,只读取所选插件当前账号的额度。subscription 使用宿主 `/api` RPC;ChatGPT 订阅插件读取 `/api/dsh-chatgpt-subscription/status`,点击刷新使用其 `/quota/refresh` 接口;connect 使用原状态路由。侧栏以“周额度 · 剩余 83% · 10/25 08:10 重置”显示,5h 窗口单列一行;会话额度条也标明“剩余”。只返回周额度的账号仅显示周窗口。重置时间按本机时区显示,Codex 不随其他套餐的进度条方向切换口径。示例百分比只用于预览;真实查询未成功时,已开启的侧栏卡片会显示登录与重试提示,可以点击重新查询。启用期间每分钟检查一次,成功数据缓存五分钟,失败一分钟后重试;两个显示位置都关闭后停止检查。查询只读取额度,不发送模型请求。
7
+ Codex 额度的真实数据来自已启用并登录的 `dsh-codex-subscription`、DSH 内置 pi-ai 登录、`dsh-chatgpt-sub`、`@eddyskywalker/dsh-chatgpt-subscription` 或 `dsh-codex-connect`。自动检测按上述顺序尝试;在 Codex 显示设置中指定数据源后,只读取所选来源当前账号的额度。侧栏以“周额度 · 剩余 83% · 10/25 08:10 重置”显示,5h 窗口单列一行;会话额度条也标明“剩余”。只返回周额度的账号仅显示周窗口。重置时间按本机时区显示,Codex 不随其他套餐的进度条方向切换口径。示例百分比只用于预览;真实查询未成功时,已开启的侧栏卡片会显示登录与重试提示,可以点击重新查询。启用期间每分钟检查一次,成功数据缓存五分钟,失败一分钟后重试;两个显示位置都关闭后停止检查。查询只读取额度,不发送模型请求。
8
+
9
+ `dsh-chatgpt-sub` 与 `@eddyskywalker/dsh-chatgpt-subscription` 是两个独立插件。前者只提供登录绑定状态:费用插件先确认它已绑定且通道可用,再由服务端用 DSH 中该插件管理的凭据查询额度;不会读取共享的 Codex 登录文件,也不要求安装 Bottom Info Bar。后者沿用 `/api/dsh-chatgpt-subscription/status` 与 `/quota/refresh` 接口。使用 `dsh-chatgpt-sub` 时,在“侧栏 → 调整组件 → Codex 额度”中开启显示并选择同名数据源,也可单独开启输入区额度条。该设置与计费归类独立。
8
10
 
9
11
  进入 DSH 设置 → 费用 → 显示。默认勾选“使用示例数据”,展示余额、预算、Go、套餐、峰谷和三种模型的完整效果。选中 Codex 或自定义余额时也提供对应示例。取消勾选后展示当前缓存数据,缺失的会话值显示“—”。数据来源的选择仅保存在本机预览偏好中,不更改插件配置或账本。
10
12
 
@@ -0,0 +1,24 @@
1
+ # 设置页与插件页
2
+
3
+ 当前迁移阶段,以下两个入口显示同一个完整设置组件:
4
+
5
+ - 左下角设置 → 费用。
6
+ - 插件 → 费用计量(dsh-cost-meter)→ 插件详情页中的配置区域。
7
+
8
+ 两个入口共用现有配置、实时快照、自动保存和按需加载,不产生第二份账本或轮询。插件页通过 DSH 原生 `plugins.bundle.config` 插槽注册,包名为 `dsh-cost-meter`。旧宿主没有该插槽时,设置入口继续可用;插件管理器稍后加载时会自动接入。
9
+
10
+ ## 待启用的纯展示页
11
+
12
+ `src/settings-overview/index.js` 提供只读看板,展示今日、本月和累计费用、预算、已启用的余额及额度来源、Token 用量和今日会话。数据来自现有快照与 Codex 额度订阅,保留查询错误和查询时间;未查询不当作零额度。费用沿用既有币种及是否计入 Plan 的配置,额度百分比标明“剩余”。
13
+
14
+ 该页面没有配置输入、凭据编辑、历史导入、清除或价格同步操作。设置调整仍在插件页完成。
15
+
16
+ 目前 `src/client/03-settings-panels-main.js` 中的 `SETTINGS_DISPLAY_ONLY` 为 `false`,纯展示页不会取代现有设置页,也不会在正常导航中加载。
17
+
18
+ 后续 DSH 启用新的设置布局时,将该常量改为 `true` 后运行 `npm run build`。届时只有左下角设置 → 费用改为只读看板;插件页继续保留完整设置。改回 `false` 并重新构建即可恢复双入口配置,不迁移或修改用户数据。
19
+
20
+ ## 验证
21
+
22
+ `node test/settings-pages.mjs` 检查当前源码、构建产物和未来启用模式的原生插槽、共享状态、语言切换及卸载清理。
23
+
24
+ `node test/settings-pages-browser.mjs` 启动使用合成数据的本地 React 预览,提供两个当前入口及待启用展示页的交互检查,不读取真实账户或账本。
@@ -0,0 +1,45 @@
1
+ # v1.9.31 更新说明
2
+
3
+ ## 中文
4
+
5
+ 本次更新把完整费用设置接入插件详情页,并修复代码审查中复现的配置保存和金额一致性问题。
6
+
7
+ ### 页面入口
8
+
9
+ 左下角「设置 → 费用」与「插件 → 费用计量」显示同一个完整设置组件,共用配置、实时数据和自动保存。插件管理器晚于费用插件加载时也能接入;旧宿主继续使用原有设置入口。
10
+
11
+ 未来使用的纯展示页已做好,包含实时费用、余额、额度、预算、Token 用量和今日会话,没有配置控件。**本版本不启用该页面**;后续只需切换构建常量,详见[设置页说明](settings-pages.md)。
12
+
13
+ ### 修复
14
+
15
+ - 两个入口快速提交修改时,较慢的旧请求可能最后写入,覆盖后一次操作。保存现在共用串行队列,单次失败不会阻塞后续保存。
16
+ - 外部逐调用快照、旧账本价格修复曾把显示汇率用于人民币计费。在回归样例中,人民币 7.2 元本应折合 1 美元;美元显示时错误得到 7.2 美元,欧元汇率为 0.9 时错误得到 8 美元。现在均使用 CNY 汇率,三个显示币种得到相同美元成本。
17
+ - 旧价格修复同时调整已冻结的人民币、欧元金额,并保留原记录的汇率和其他费用。按完整会话校正日级模型汇总时,也检查币种金额;缺失的历史币种明细不作为零值覆盖。
18
+
19
+ 本版本没有新增全账本重算任务,也不修改费用统计口径。上述旧价格修复仍只在既有迁移或明确修复路径中执行。
20
+
21
+ ### 验证范围
22
+
23
+ 回归测试覆盖三种显示币种、冻结金额和重复修复、部分旧记录、并发及失败保存、插件管理器延迟加载、双入口共享配置、语言切换和卸载清理。浏览器合成数据检查覆盖展示页无配置控件、费用与额度实时更新、查询错误及 960/560/360 像素宽度。
24
+
25
+ 本次代码审查覆盖计费与历史导入、账本并发持久化、套餐与余额、配置和凭据、网络读取边界、客户端生命周期、构建和安装发布路径。验证使用本地回归及合成响应,不代表对所有供应商真实账号逐一查询。
26
+
27
+ ### 升级
28
+
29
+ 在插件市场更新到 **1.9.31**,或执行:
30
+
31
+ ```powershell
32
+ dsh plugin --profile desktop add dsh-cost-meter@1.9.31
33
+ ```
34
+
35
+ 网页端将 `desktop` 换成 `web`。更新后完全退出并重启对应的 DSH 客户端。
36
+
37
+ ## English
38
+
39
+ This patch adds the complete cost settings to plugin details, sharing the component, live state and save queue with the existing settings entry. A read-only page for live costs and quotas is prepared but **remains disabled**.
40
+
41
+ - Serialize saves across both entries so a slow earlier request cannot overwrite a later edit; a failed save does not block subsequent saves.
42
+ - Use the CNY conversion rate for CNY-priced external calls and legacy pricing repair, regardless of the display currency.
43
+ - Update frozen CNY/EUR amounts alongside repaired USD costs, retaining recorded FX rates and unrelated amounts. Reconcile complete model currency totals even when USD totals already match; missing legacy currency fields do not imply zero.
44
+
45
+ No new full-ledger repricing task is introduced. Tests cover currencies, idempotence, partial legacy rows, concurrent/failed saves, slot lifecycle and responsive read-only rendering with synthetic data. Update to **1.9.31** and restart DSH.
@@ -0,0 +1,33 @@
1
+ # v1.9.32 更新说明
2
+
3
+ ## 中文
4
+
5
+ 新增 `dsh-chatgpt-sub` 的图形化额度显示。它与此前支持的 `@eddyskywalker/dsh-chatgpt-subscription` 是两个独立插件,现已接入现有 ChatGPT (Codex) 额度卡片。
6
+
7
+ ### 使用
8
+
9
+ 1. 在 `dsh-chatgpt-sub` 中完成 ChatGPT 登录。
10
+ 2. 进入“设置 → 费用 → 显示 → 侧栏”,在“调整组件”中选择“Codex 额度”,打开额度显示,数据源选择 **dsh-chatgpt-sub**。自动检测也包含该来源。
11
+ 3. 在“输入区”中可单独开启 Codex 额度横条。两个位置共用查询结果,点击卡片可刷新。
12
+
13
+ 侧栏显示 5 小时和每周的剩余进度条,右上角显示重置时间。账号只提供每周窗口时只显示每周额度,不补造 5 小时窗口。查询失败或解除绑定后显示重试提示,不继续展示本次刷新前的额度。
14
+
15
+ ### 数据来源与验证
16
+
17
+ 适配 [songoao25/dsh-chatgpt-sub 0.6.3](https://github.com/songoao25/dsh-chatgpt-sub):先检查其同源绑定状态,再由费用插件服务端读取它保存在 DSH 中的凭据,向官方额度地址发起只读查询。前端和账本不接收令牌,不读取或修改共享 Codex 登录文件,不需要安装 Bottom Info Bar。额度显示和计费归类保持独立。
18
+
19
+ 使用真实 DSH 0.2.1-rc.2 宿主、发布的浏览器产物与模拟账号响应,检查了双窗口、周窗口、百分比方向、重置时间、登录恢复、解除绑定、来源切换、凭据轮换、错误与超时、卸载和旧 RPC 清单兼容。模拟额度只用于检查显示,没有查询真实供应商账号。
20
+
21
+ ### 升级
22
+
23
+ 在插件市场更新到 **1.9.32**,完全退出并重启对应的 DSH Desktop 或 Web 进程,然后按上方步骤开启显示。
24
+
25
+ ## English
26
+
27
+ Add graphical quota for `dsh-chatgpt-sub`, independently of the already supported multi-provider ChatGPT subscription plugin.
28
+
29
+ Sign in through `dsh-chatgpt-sub`, then open Settings → Cost → Display → Sidebar, select Codex quota, enable it and choose **dsh-chatgpt-sub**. Auto-detection also includes this source. The composer quota strip has a separate display switch.
30
+
31
+ Both positions show remaining 5h/weekly quota and share one cached query. Weekly-only accounts do not get an invented 5h window. Clicking refresh after unbinding clears the old graph. The host reads the plugin-managed DSH credential after the browser verifies the current binding; tokens never reach the browser or ledger, and shared Codex login files are not read or changed.
32
+
33
+ Validation uses the real DSH 0.2.1-rc.2 host, shipped browser bundles and synthetic account responses. Update to **1.9.32** and fully restart DSH before enabling the display.
@@ -0,0 +1,24 @@
1
+ /** dsh-chatgpt-sub stores its bound OAuth access token in this DSH credential slot.
2
+ * Reuse the bounded quota reader; never read shared Codex login files or refresh tokens. */
3
+ import { createPiAiCodexQuota } from './pi-ai-codex-quota.js'
4
+
5
+ export function createChatgptSubQuota(ctx, options = {}) {
6
+ return createPiAiCodexQuota({ get: () => ({
7
+ async readRecord() {
8
+ const resolved = await ctx.get?.('credentials')?.resolve?.('OPENAI_CODEX_API_KEY')
9
+ const access = resolved?.value
10
+ if (typeof access !== 'string' || !access || access.length > 32768 || /[\r\n]/.test(access)) return null
11
+ let claims
12
+ try {
13
+ const parts = access.split('.')
14
+ if (parts.length !== 3) return null
15
+ claims = JSON.parse(Buffer.from(parts[1], 'base64url').toString('utf8'))
16
+ } catch { return null }
17
+ // Account selection follows the same access token as the plugin's model route.
18
+ const accountId = claims?.['https://api.openai.com/auth']?.chatgpt_account_id
19
+ if (typeof accountId !== 'string' || !accountId || accountId.length > 512 || /[\r\n]/.test(accountId)) return null
20
+ const expires = typeof claims.exp === 'number' && Number.isFinite(claims.exp) ? claims.exp * 1000 : undefined
21
+ return { kind: 'grant', payload: { type: 'oauth', access, accountId, expires } }
22
+ },
23
+ }) }, { ...options, label: 'dsh-chatgpt-sub' })
24
+ }
@@ -1 +1 @@
1
- window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.codex.js",factory:P=>{const S=P("react"),{createElement:t,useState:f,useEffect:C,useRef:h}=S;async function D(e=!1){try{const m=await fetch("/api/dsh-chatgpt-subscription/"+(e?"quota/refresh":"status"),{credentials:"same-origin",signal:AbortSignal.timeout(8e3),headers:{accept:"application/json",...e?{"content-type":"application/json"}:{}},...e?{method:"POST",body:"{}"}:{}});if(!m.ok)return null;const s=await m.json();if(s?.ok!==!0)return null;const l=e?s.value:s.value?.quota;if(!e&&s.value?.authenticated!==!0||!["ready","stale"].includes(l?.state))return null;const c=Array.isArray(l.buckets)?l.buckets.find(a=>a?.id==="codex"):null;if(!Array.isArray(c?.windows))return null;const o={};for(const a of c.windows){const i=a?.windowDurationMins===300?"five":a?.windowDurationMins===10080?"weekly":null,r=a?.usedPercent;if(!i||typeof r!="number"||!Number.isFinite(r)||r<0||r>100)continue;const n=new Date(typeof a.resetsAt=="number"&&a.resetsAt>0?a.resetsAt*1e3:NaN);o[i]={percent:Math.round(r*10)/10,resetsAt:Number.isFinite(n.getTime())?n.toISOString():""}}return o}catch{return null}}const I="cm-stat-dialog cm-codex-compat-dialog";if(typeof document<"u"){const e=document.createElement("style");e.textContent=".cm-codex-compat-dialog{width:min(560px,94vw)}.cm-codex-compat{display:flex;flex-direction:column;gap:8px;font-size:13px}.cm-codex-compat :is(h3,p){margin:0}.cm-codex-compat h3{font-size:14px;font-weight:600}",e.textContent+='@media (max-width:1023px){.cm-codex-compat-dialog{width:calc(100vw - 32px)}.cm-codex-compat{padding:0 2px}}body[data-dsh-pocket-layout="mobile"] .cm-codex-compat-dialog{width:calc(100vw - 32px)}',document.head.appendChild(e)}const w="dsh-cost-meter:codex-compat-prompt-dismissed",x=new Set;let v=!1;function _(){if(v)return!0;try{return window.localStorage.getItem(w)==="1"}catch{return!1}}function q(){v=!0;try{window.localStorage.setItem(w,"1")}catch{}for(const e of x)e(!0)}function N(){const[e,m]=f(!1),[s,l]=f(null),c=h(!1);return[e,s,a=>{c.current||(c.current=!0,m(!0),l(null),Promise.resolve().then(a).catch(i=>l(i?.message??String(i))).finally(()=>{c.current=!1,m(!1)}))}]}function A(e){const s=e.state?.codexCompat,l=e.api,c=e.locale==="en",o=(g,F)=>c?F:g,a=h(null),[i,r,n]=N(),[u,d]=f(_),y=s?.enabled===!0&&s?.promptDue===!0&&!u;if(C(()=>(x.add(d),()=>x.delete(d)),[]),C(()=>{y&&a.current&&!a.current.open&&a.current.showModal()},[y]),!y)return null;const p=s.usage??{},b=()=>{a.current?.close(),d(!0),q(),Promise.resolve().then(()=>l.dismissCodexCompat()).catch(()=>{})};return t("dialog",{ref:a,className:I,"aria-label":o("兼容修复","Compatibility fix"),onCancel:g=>{g.preventDefault(),b()}},t("header",{className:"cm-stat-dialog-head"},o("兼容修复","Compatibility fix"),t("button",{type:"button",className:"cm-btn","aria-label":o("关闭","Close"),onClick:b},"×")),t("div",{className:"cm-stat-dialog-body"},t("p",null,o("检测到 dsh-codex-subscription {version}。Codex 订阅用量不计入 API 费用;为兼容本插件,新产生的 Codex 用量已自动归类为 Plan。是否将历史 codex 类模型的计费统一归类为 Plan(订阅额度,不计入 API 费用)?","Detected dsh-codex-subscription {version}. Codex subscription usage is not billed as API usage; for compatibility this plugin now defaults new Codex usage to Plan. Reclassify the billing of historical codex-class models as Plan (subscription quota, excluded from API usage)?").replace("{version}","v"+(s.version??""))),p.calls>0?t("p",{className:"cm-note"},o("历史 Codex 用量:{calls} 次调用 · {cost} · {days} 天","Historical Codex usage: {calls} calls · {cost} · {days} days").replace("{calls}",p.calls).replace("{cost}","$"+Number(p.cost??0).toFixed(2)).replace("{days}",p.days)):null,r?t("div",{className:"cm-msg err"},o("失败:","Failed: ")+r):null,t("div",{className:"cm-buttons"},t("button",{type:"button",className:"cm-btn",onClick:b},o("保持现状","Keep status quo")),t("button",{type:"button",className:"cm-btn primary",disabled:i,onClick:()=>n(l.applyCodexCompatHistory)},o("统一归类为 Plan","Reclassify as Plan"))),t("p",{className:"cm-note"},o("之后可在 设置 → 费用 → Codex 订阅兼容 中处理。","You can change this later in Settings → Cost → Codex subscription compatibility."))))}function k(e){const s=e.state?.codexCompat,[l,c,o]=N();if(s?.installed!==!0||s?.enabled!==!0)return null;const a=e.api,i=e.t,r=e.locale==="en",n=(p,b)=>r?b:p,u=s.usage??{},d=s.historyAppliedAt>0,y=s.planClass==="plan"?i("billingClassPlan"):s.planClass==="api"?i("billingClassApi"):i("billingClassAuto");return t("div",{className:"cm-codex-compat"},t("h3",null,n("Codex 订阅兼容","Codex subscription compatibility")),t("p",null,n("检测版本:{version}","Detected version: {version}").replace("{version}","v"+(s.version??""))),t("p",null,n("当前计费方式:{planClass}","Current billing class: {planClass}").replace("{planClass}",y)),t("p",null,n("历史用量:{calls} 次调用 · {cost} · {tokens} tokens · {days} 天","Historical usage: {calls} calls · {cost} · {tokens} tokens · {days} days").replace("{calls}",u.calls).replace("{cost}","$"+Number(u.cost??0).toFixed(2)).replace("{tokens}",Number(u.tokens??0).toLocaleString(r?"en-US":"zh-CN")).replace("{days}",u.days)),c?t("div",{className:"cm-msg err",role:"alert"},n("失败:","Failed: ")+c):null,d?t("p",{className:"cm-note"},n("已归类于 {time}","Reclassified at {time}").replace("{time}",new Date(s.historyAppliedAt).toLocaleString())):t("p",null,n("历史用量未归类。","Historical usage is not reclassified yet.")),!d&&u.providers?.length?t("p",{className:"cm-note"},n("来源:{providers}","Sources: {providers}").replace("{providers}",u.providers.join(", "))):null,d?null:t("div",{className:"cm-buttons"},t("button",{type:"button",className:"cm-btn primary",disabled:l,onClick:()=>o(a.applyCodexCompatHistory)},n("统一归类为 Plan","Reclassify as Plan"))),!d&&s.promptDismissed===!0?t("p",{className:"cm-note"},n("此前选择保持现状,可随时统一归类。","You chose Keep status quo earlier; you can reclassify anytime.")):null)}function E(){return e=>t(e.view==="prompt"?A:k,e)}return{mount:E,CodexCompatPrompt:A,CodexCompatPanel:k,readChatgptQuota:D}}});
1
+ window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.codex.js",factory:S=>{const P=S("react"),{createElement:s,useState:f,useEffect:h,useRef:C}=P;async function D(e=!1){try{const u=await fetch("/api/dsh-chatgpt-subscription/"+(e?"quota/refresh":"status"),{credentials:"same-origin",signal:AbortSignal.timeout(8e3),headers:{accept:"application/json",...e?{"content-type":"application/json"}:{}},...e?{method:"POST",body:"{}"}:{}});if(!u.ok)return null;const t=await u.json();if(t?.ok!==!0)return null;const l=e?t.value:t.value?.quota;if(!e&&t.value?.authenticated!==!0||!["ready","stale"].includes(l?.state))return null;const c=Array.isArray(l.buckets)?l.buckets.find(a=>a?.id==="codex"):null;if(!Array.isArray(c?.windows))return null;const o={};for(const a of c.windows){const i=a?.windowDurationMins===300?"five":a?.windowDurationMins===10080?"weekly":null,r=a?.usedPercent;if(!i||typeof r!="number"||!Number.isFinite(r)||r<0||r>100)continue;const n=new Date(typeof a.resetsAt=="number"&&a.resetsAt>0?a.resetsAt*1e3:NaN);o[i]={percent:Math.round(r*10)/10,resetsAt:Number.isFinite(n.getTime())?n.toISOString():""}}return o}catch{return null}}async function I(e){try{const u=await fetch("/_dsh/dsh-chatgpt-sub/getCodexBridgeStatus",{credentials:"same-origin",redirect:"error",headers:{accept:"application/json"},signal:AbortSignal.timeout(8e3)});if(!u.ok)return null;const t=await u.json();if(t?.ok!==!0||t.bound!==!0||t.routeConfigured!==!0)return null;const l=await e?.();return l?.ok===!0?l.value:null}catch{return null}}const _="cm-stat-dialog cm-codex-compat-dialog";if(typeof document<"u"){const e=document.createElement("style");e.textContent=".cm-codex-compat-dialog{width:min(560px,94vw)}.cm-codex-compat{display:flex;flex-direction:column;gap:8px;font-size:13px}.cm-codex-compat :is(h3,p){margin:0}.cm-codex-compat h3{font-size:14px;font-weight:600}",e.textContent+='@media (max-width:1023px){.cm-codex-compat-dialog{width:calc(100vw - 32px)}.cm-codex-compat{padding:0 2px}}body[data-dsh-pocket-layout="mobile"] .cm-codex-compat-dialog{width:calc(100vw - 32px)}',document.head.appendChild(e)}const w="dsh-cost-meter:codex-compat-prompt-dismissed",g=new Set;let v=!1;function j(){if(v)return!0;try{return window.localStorage.getItem(w)==="1"}catch{return!1}}function q(){v=!0;try{window.localStorage.setItem(w,"1")}catch{}for(const e of g)e(!0)}function N(){const[e,u]=f(!1),[t,l]=f(null),c=C(!1);return[e,t,a=>{c.current||(c.current=!0,u(!0),l(null),Promise.resolve().then(a).catch(i=>l(i?.message??String(i))).finally(()=>{c.current=!1,u(!1)}))}]}function A(e){const t=e.state?.codexCompat,l=e.api,c=e.locale==="en",o=(x,F)=>c?F:x,a=C(null),[i,r,n]=N(),[d,p]=f(j),y=t?.enabled===!0&&t?.promptDue===!0&&!d;if(h(()=>(g.add(p),()=>g.delete(p)),[]),h(()=>{y&&a.current&&!a.current.open&&a.current.showModal()},[y]),!y)return null;const m=t.usage??{},b=()=>{a.current?.close(),p(!0),q(),Promise.resolve().then(()=>l.dismissCodexCompat()).catch(()=>{})};return s("dialog",{ref:a,className:_,"aria-label":o("兼容修复","Compatibility fix"),onCancel:x=>{x.preventDefault(),b()}},s("header",{className:"cm-stat-dialog-head"},o("兼容修复","Compatibility fix"),s("button",{type:"button",className:"cm-btn","aria-label":o("关闭","Close"),onClick:b},"×")),s("div",{className:"cm-stat-dialog-body"},s("p",null,o("检测到 dsh-codex-subscription {version}。Codex 订阅用量不计入 API 费用;为兼容本插件,新产生的 Codex 用量已自动归类为 Plan。是否将历史 codex 类模型的计费统一归类为 Plan(订阅额度,不计入 API 费用)?","Detected dsh-codex-subscription {version}. Codex subscription usage is not billed as API usage; for compatibility this plugin now defaults new Codex usage to Plan. Reclassify the billing of historical codex-class models as Plan (subscription quota, excluded from API usage)?").replace("{version}","v"+(t.version??""))),m.calls>0?s("p",{className:"cm-note"},o("历史 Codex 用量:{calls} 次调用 · {cost} · {days} 天","Historical Codex usage: {calls} calls · {cost} · {days} days").replace("{calls}",m.calls).replace("{cost}","$"+Number(m.cost??0).toFixed(2)).replace("{days}",m.days)):null,r?s("div",{className:"cm-msg err"},o("失败:","Failed: ")+r):null,s("div",{className:"cm-buttons"},s("button",{type:"button",className:"cm-btn",onClick:b},o("保持现状","Keep status quo")),s("button",{type:"button",className:"cm-btn primary",disabled:i,onClick:()=>n(l.applyCodexCompatHistory)},o("统一归类为 Plan","Reclassify as Plan"))),s("p",{className:"cm-note"},o("之后可在 设置 → 费用 → Codex 订阅兼容 中处理。","You can change this later in Settings → Cost → Codex subscription compatibility."))))}function k(e){const t=e.state?.codexCompat,[l,c,o]=N();if(t?.installed!==!0||t?.enabled!==!0)return null;const a=e.api,i=e.t,r=e.locale==="en",n=(m,b)=>r?b:m,d=t.usage??{},p=t.historyAppliedAt>0,y=t.planClass==="plan"?i("billingClassPlan"):t.planClass==="api"?i("billingClassApi"):i("billingClassAuto");return s("div",{className:"cm-codex-compat"},s("h3",null,n("Codex 订阅兼容","Codex subscription compatibility")),s("p",null,n("检测版本:{version}","Detected version: {version}").replace("{version}","v"+(t.version??""))),s("p",null,n("当前计费方式:{planClass}","Current billing class: {planClass}").replace("{planClass}",y)),s("p",null,n("历史用量:{calls} 次调用 · {cost} · {tokens} tokens · {days} 天","Historical usage: {calls} calls · {cost} · {tokens} tokens · {days} days").replace("{calls}",d.calls).replace("{cost}","$"+Number(d.cost??0).toFixed(2)).replace("{tokens}",Number(d.tokens??0).toLocaleString(r?"en-US":"zh-CN")).replace("{days}",d.days)),c?s("div",{className:"cm-msg err",role:"alert"},n("失败:","Failed: ")+c):null,p?s("p",{className:"cm-note"},n("已归类于 {time}","Reclassified at {time}").replace("{time}",new Date(t.historyAppliedAt).toLocaleString())):s("p",null,n("历史用量未归类。","Historical usage is not reclassified yet.")),!p&&d.providers?.length?s("p",{className:"cm-note"},n("来源:{providers}","Sources: {providers}").replace("{providers}",d.providers.join(", "))):null,p?null:s("div",{className:"cm-buttons"},s("button",{type:"button",className:"cm-btn primary",disabled:l,onClick:()=>o(a.applyCodexCompatHistory)},n("统一归类为 Plan","Reclassify as Plan"))),!p&&t.promptDismissed===!0?s("p",{className:"cm-note"},n("此前选择保持现状,可随时统一归类。","You chose Keep status quo earlier; you can reclassify anytime.")):null)}function E(){return e=>s(e.view==="prompt"?A:k,e)}return{mount:E,CodexCompatPrompt:A,CodexCompatPanel:k,readChatgptQuota:D,readChatgptSubQuota:I}}});