dsh-cost-meter 1.9.13 → 1.9.14
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 +9 -9
- package/README.zh-CN.md +9 -9
- package/docs/display-settings.md +1 -1
- package/docs/update-notes-1.9.14.md +29 -0
- package/lib/client.codex.js +1 -1
- package/lib/client.display.js +1 -1
- package/lib/client.js +5 -5
- package/lib/store.js +6 -6
- package/lib/typert.host.js +1 -1
- package/package.json +3 -2
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
|
-
[](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.
|
|
19
|
+
**v1.9.14** supports Codex quota from `@eddyskywalker/dsh-chatgpt-subscription`. The sidebar and composer show the actual 5-hour and weekly windows and reset times. Use auto-detection or select the plugin in Codex display settings.
|
|
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.
|
|
26
|
+
Release notes: [v1.9.14](docs/update-notes-1.9.14.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,7 +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
|
|
57
|
+
| Codex quota display | Settings → Display → Codex / sidebar & quota strip | Reads actual 5-hour and 7-day windows from `dsh-codex-subscription` or `@eddyskywalker/dsh-chatgpt-subscription`, with `dsh-codex-connect` compatibility. Select `auto` (tries those three plugins in order), `subscription`, `chatgpt`, or `connect`. An explicit source shows only that plugin's current account. Independent of the billing classification in “Subscription plugin compatibility”. |
|
|
58
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) |
|
|
59
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) |
|
|
60
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 |
|
|
@@ -341,22 +341,22 @@ On Node.js 20, use `npm install -g pnpm@10` instead. See [pnpm installation and
|
|
|
341
341
|
dsh plugin --profile web add dsh-cost-meter
|
|
342
342
|
```
|
|
343
343
|
|
|
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.
|
|
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.14`** — review the script before running):
|
|
345
345
|
|
|
346
346
|
```powershell
|
|
347
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.
|
|
347
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.14/install.ps1 | iex
|
|
348
348
|
```
|
|
349
349
|
|
|
350
350
|
**Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
|
|
351
351
|
|
|
352
352
|
```sh
|
|
353
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.
|
|
353
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.14
|
|
354
354
|
```
|
|
355
355
|
|
|
356
356
|
Without git, use the GitHub tag archive:
|
|
357
357
|
|
|
358
358
|
```sh
|
|
359
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.
|
|
359
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.14.tar.gz
|
|
360
360
|
```
|
|
361
361
|
|
|
362
362
|
After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
|
|
@@ -421,7 +421,7 @@ Workarounds:
|
|
|
421
421
|
|
|
422
422
|
```yaml
|
|
423
423
|
minimumReleaseAgeExclude:
|
|
424
|
-
- dsh-cost-meter@1.9.
|
|
424
|
+
- dsh-cost-meter@1.9.14
|
|
425
425
|
```
|
|
426
426
|
|
|
427
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
|
-
[](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.
|
|
19
|
+
**v1.9.14** 支持 `@eddyskywalker/dsh-chatgpt-subscription` 的 Codex 额度,侧栏与输入区显示实际返回的 5 小时、周额度和重置时间。自动检测可直接使用,也可在 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.
|
|
26
|
+
更新说明:[v1.9.14](docs/update-notes-1.9.14.md#中文)。更新后完全重启 DSH。
|
|
27
27
|
|
|
28
28
|
声明范围内的宿主记录与此前的 0.1.x 历史见[兼容记录](docs/host-compatibility.md);逐版本清单在 `package.json` 的 `dsh.compatibility.dshReleases`。
|
|
29
29
|
|
|
@@ -54,7 +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 / 侧边栏与额度横条 |
|
|
57
|
+
| Codex 额度显示 | 设置 → 显示 → Codex / 侧边栏与额度横条 | 读取 `dsh-codex-subscription`、`@eddyskywalker/dsh-chatgpt-subscription` 的实际 5 小时与 7 天窗口,兼容 `dsh-codex-connect`;数据源可选 `auto`(依次尝试上述三个插件)/ `subscription` / `chatgpt` / `connect`。固定来源只显示该插件当前账号的额度;与「订阅插件兼容」的计费归类设置互不影响。 |
|
|
58
58
|
| SQLite 会话存储(better-session) | 宿主集成 | 自动探测宿主会话后端;当 `@morlay/better-session` / `@morlay/session-rdb`(SQLite)接管存储时,历史回填、旧账本导入、历史重定价、小时桶修复、fork 清洗与逐会话费用/轨迹/调用详情继续可用。JSONL 路径行为不变;旧 JSONL 与 RDB 历史不自动合并。[说明](docs/better-session.md) |
|
|
59
59
|
| OpenDesign 额度 | 侧边栏 / 设置页(OpenDesign 厂商) | 从控制台 API 读取工作区 coding plan 窗口;使用 Control Key 时主端点 401/403 会保守回退一次 `/billing/preflight`,窗口与钱包读取独立降级。[排查说明](docs/opendesign-billing.md#中文) |
|
|
60
60
|
| 手机端适配(dsh-pocket) | 全部费用界面 | ≤1023px 窄屏与 dsh-pocket 移动布局下:卡片单列、标签横向滚动、36px 触控高度、对话框不超过 90vh 并避开安全区、宽表横向滚动;桌面布局不变 |
|
|
@@ -341,22 +341,22 @@ Node.js 20 请改用 `npm install -g pnpm@10`。版本要求见 [pnpm 官方安
|
|
|
341
341
|
dsh plugin --profile web add dsh-cost-meter
|
|
342
342
|
```
|
|
343
343
|
|
|
344
|
-
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.9.
|
|
344
|
+
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.9.14`**,建议先下载审阅再运行):
|
|
345
345
|
|
|
346
346
|
```powershell
|
|
347
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.
|
|
347
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.14/install.ps1 | iex
|
|
348
348
|
```
|
|
349
349
|
|
|
350
350
|
**或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
|
|
351
351
|
|
|
352
352
|
```sh
|
|
353
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.
|
|
353
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.14
|
|
354
354
|
```
|
|
355
355
|
|
|
356
356
|
没有 git 时可用 GitHub tag 打包直链:
|
|
357
357
|
|
|
358
358
|
```sh
|
|
359
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.
|
|
359
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.14.tar.gz
|
|
360
360
|
```
|
|
361
361
|
|
|
362
362
|
安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
|
|
@@ -421,7 +421,7 @@ DSH **0.2.1-rc.1 / 0.2.1-rc.2** 宿主自带 pnpm **11.28.5**,默认启用内
|
|
|
421
421
|
|
|
422
422
|
```yaml
|
|
423
423
|
minimumReleaseAgeExclude:
|
|
424
|
-
- dsh-cost-meter@1.9.
|
|
424
|
+
- dsh-cost-meter@1.9.14
|
|
425
425
|
```
|
|
426
426
|
|
|
427
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 上实测可用。
|
package/docs/display-settings.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
关闭输入框上方的 Codex 额度条:选择“输入区 → 调整组件 → Codex 额度”,取消“在输入区显示 Codex 额度”。该开关与侧栏额度独立,不影响预算、Go 或其他套餐的额度条;两个 Codex 显示位置都隐藏时停止查询。
|
|
6
6
|
|
|
7
|
-
Codex 额度的真实数据来自已启用并登录的 `dsh-codex-subscription` 或 `dsh-codex-connect
|
|
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 不随其他套餐的进度条方向切换口径。示例百分比只用于预览;真实查询未成功时,已开启的侧栏卡片会显示登录与重试提示,可以点击重新查询。启用期间每分钟检查一次,成功数据缓存五分钟,失败一分钟后重试;两个显示位置都关闭后停止检查。查询只读取额度,不发送模型请求。
|
|
8
8
|
|
|
9
9
|
进入 DSH 设置 → 费用 → 显示。默认勾选“使用示例数据”,展示余额、预算、Go、套餐、峰谷和三种模型的完整效果。选中 Codex 或自定义余额时也提供对应示例。取消勾选后展示当前缓存数据,缺失的会话值显示“—”。数据来源的选择仅保存在本机预览偏好中,不更改插件配置或账本。
|
|
10
10
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# v1.9.14
|
|
2
|
+
|
|
3
|
+
## 中文
|
|
4
|
+
|
|
5
|
+
### ChatGPT 订阅插件的 Codex 额度
|
|
6
|
+
|
|
7
|
+
安装并登录 `@eddyskywalker/dsh-chatgpt-subscription` 后,在“费用 → 额度”开启 Codex 额度。侧栏和输入区显示该插件当前账号的剩余额度、实际返回的 5 小时与周窗口,以及本机时间的重置日期;只返回周窗口时不补出 5 小时额度。
|
|
8
|
+
|
|
9
|
+
在“费用 → 显示”选择侧栏或输入区的 Codex 组件,可将数据源设为 `dsh-chatgpt-subscription`(配置值 `chatgpt`)。默认自动检测依次尝试 `dsh-codex-subscription`、`dsh-chatgpt-subscription`、`dsh-codex-connect`。固定数据源查询失败时显示登录与重试提示,点击即可重新查询。
|
|
10
|
+
|
|
11
|
+
普通查询使用已登录插件的同源状态接口,点击刷新调用其额度刷新接口。侧栏与输入区共用请求和缓存:成功缓存五分钟,失败一分钟后重试;两个位置都关闭后停止检查。适配代码按需加载,不读取或保存登录凭据,不发送模型请求。
|
|
12
|
+
|
|
13
|
+
接口依据为 [dsh-chatgpt-subscription](https://github.com/Aa728848/dsh-chatgpt-subscription) 的 npm 发布包 `0.29.0`。验证覆盖原发布包的额度解析与 HTTP 路由、源码和构建产物、配置保存、登录恢复、来源回退、迟到响应、双窗口与周窗口,以及真实浏览器中的侧栏和输入区显示。
|
|
14
|
+
|
|
15
|
+
更新后完全退出 DSH(包括托盘)再打开。
|
|
16
|
+
|
|
17
|
+
## English
|
|
18
|
+
|
|
19
|
+
### Codex quota from the ChatGPT subscription plugin
|
|
20
|
+
|
|
21
|
+
Sign in to `@eddyskywalker/dsh-chatgpt-subscription`, then enable Codex quota under Cost → Quotas. The sidebar and composer show the active account's remaining quota, actual 5-hour and weekly windows, and local reset times. Weekly-only responses stay weekly-only.
|
|
22
|
+
|
|
23
|
+
Select `dsh-chatgpt-subscription` in the Codex display component's data-source control (`chatgpt` in configuration), or keep auto-detection. Auto tries `dsh-codex-subscription`, `dsh-chatgpt-subscription`, then `dsh-codex-connect`. An explicitly selected source keeps its sign-in and retry entry when unavailable.
|
|
24
|
+
|
|
25
|
+
Normal reads use the signed-in plugin's same-origin status endpoint; clicking refresh uses its quota-refresh endpoint. Both display positions share requests and cache. Successful reads are cached for five minutes; failures can retry after one minute. Hiding both positions stops reads. The adapter loads on demand, keeps no login credentials, and sends no model requests.
|
|
26
|
+
|
|
27
|
+
Validated against the original parser and HTTP routes in the published `0.29.0` package, source and built assets, configuration persistence, sign-in recovery, fallback and stale-request isolation, actual windows, and the sidebar and composer in a real browser.
|
|
28
|
+
|
|
29
|
+
Fully exit DSH, including its tray process, and reopen after updating.
|
package/lib/client.codex.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.codex.js",factory:
|
|
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}}});
|