dsh-cost-meter 1.9.40 → 1.9.42

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 dsh-cost-meter contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-cost-meter contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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.40-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
9
+ [![version](https://img.shields.io/badge/version-1.9.42-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.40** moves billing accuracy guidance into settings and improves balance-query backoff to reduce redundant requests and related operational risks.
19
+ **v1.9.42** fixes the stuck balance-refresh notice, guards cross-currency price updates, and adds a compact text-only sidebar.
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.40](docs/update-notes-1.9.40.md#english). Fully restart DSH after updating.
23
+ Release notes: [v1.9.42](docs/update-notes-1.9.42.md#english). Fully restart DSH after updating.
24
24
 
25
25
  ![Promo art](docs/promo.en.png)
26
26
 
@@ -121,6 +121,8 @@ Qwen Token Plan can use the [official CLI subscription quota](docs/qwen-cli-quot
121
121
 
122
122
  Local Qwen Token Plan credits include Plan calls assigned to Qwen. Existing subscription aliases such as `qwen` and `qwen-tokenplan` remain supported; custom providers can select Qwen under Model statistics → Billing class, or use an explicit vendor name and plan marker for auto detection. Explicit API calls are excluded. The pay-as-you-go `qianwen` provider is not assigned merely because its model ID is identical. Models outside the credits table need all three rates configured.
123
123
 
124
+ Baidu Qianfan Token Plan Personal now supports [quota queries via console Cookie](docs/baidu-token-plan.md), including credits and Token modes. Store the Cookie in the Baidu quota card or set `BAIDU_QIANFAN_COOKIE` on the DSH host.
125
+
124
126
  Xiaomi MiMo Token Plan quotas are queried with the **MiMo console cookie**, not an API key: log in at `platform.xiaomimimo.com`, press F12 → Network → find the `balanceAlertConfig` request and paste the full `cookie` request header into the MiMo card in Settings → Cost → Quotas (it must include `serviceToken` and `userId`; the DSH credential store keeps it as `MIMO_COOKIE`). The card shows the plan/compensation credit windows with the period-end reset (Beijing time) plus a balance row. Copy a fresh console cookie when the card reports an expired login. Token Plan inference keys (`tp-*` / `ttp-*`) are not accepted by this console adapter. Local plan statistics use the calendar month; compensation and balance are displayed without estimates because local calls cannot be attributed to those pools.
125
127
 
126
128
  Each CLIProxyAPI source has a **Gemini quota only** option for its Antigravity groups. It defaults to off. Intentional filtering to no visible quota shows an empty list; malformed quota data still reports an error.
@@ -354,22 +356,22 @@ On Node.js 20, use `npm install -g pnpm@10` instead. See [pnpm installation and
354
356
  dsh plugin --profile web add dsh-cost-meter
355
357
  ```
356
358
 
357
- **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.40`** — review the script before running):
359
+ **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.42`** — review the script before running):
358
360
 
359
361
  ```powershell
360
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.40/install.ps1 | iex
362
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.42/install.ps1 | iex
361
363
  ```
362
364
 
363
365
  **Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
364
366
 
365
367
  ```sh
366
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.40
368
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.42
367
369
  ```
368
370
 
369
371
  Without git, use the GitHub tag archive:
370
372
 
371
373
  ```sh
372
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.40.tar.gz
374
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.42.tar.gz
373
375
  ```
374
376
 
375
377
  After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
@@ -434,7 +436,7 @@ Workarounds:
434
436
 
435
437
  ```yaml
436
438
  minimumReleaseAgeExclude:
437
- - dsh-cost-meter@1.9.40
439
+ - dsh-cost-meter@1.9.42
438
440
  ```
439
441
 
440
442
  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.40-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
9
+ [![version](https://img.shields.io/badge/version-1.9.42-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.40** 将费用误差说明移入设置页,并优化余额查询等待策略,减少无效重复请求及相关使用风险。
19
+ **v1.9.42** 修复余额刷新提醒点不掉的问题,保护跨币种价格更新,并新增仅显示紧凑文本的侧栏开关。
20
20
 
21
21
  **宿主要求:DSH 0.2.0 起支持** · 适配目标 **0.2.1-rc.2**(npm `next`)。完整声明、历史记录与安装排障见下方展开项。
22
22
 
23
- 更新说明:[v1.9.40](docs/update-notes-1.9.40.md#中文)。更新后完全重启 DSH。
23
+ 更新说明:[v1.9.42](docs/update-notes-1.9.42.md#中文)。更新后完全重启 DSH。
24
24
 
25
25
  ![宣传图](docs/promo.png)
26
26
 
@@ -120,6 +120,8 @@
120
120
 
121
121
  千问 Token Plan 的本地 Credits 统计归属千问套餐的 Plan 调用。保留 `qwen`、`qwen-tokenplan` 等订阅别名,自定义渠道也可在「按模型统计 → 计费方式」选择千问套餐,或使用明确的厂商名与套餐特征自动识别。显式 API 调用不计;`qianwen` 按量渠道不会仅因同名模型自动归入。模型不在抵扣表中时需补充三项费率。
122
122
 
123
+ 百度千帆 Token Plan 个人版现已支持[通过控制台 Cookie 查询额度](docs/baidu-token-plan.md),分别显示积分制和 Token 制用量。在百度额度卡片保存 Cookie,或在 DSH 主机配置 `BAIDU_QIANFAN_COOKIE`。
124
+
123
125
  小米 MiMo Token Plan 的额度查询使用**控制台 Cookie**(而非 API Key):登录 `platform.xiaomimimo.com` 后按 F12 →「网络」→ 找到 `balanceAlertConfig` 请求,把请求头 `cookie` 整段粘贴进「设置 → 费用 → 额度」的 MiMo 卡片(需含 `serviceToken` 与 `userId`,DSH 凭据库以 `MIMO_COOKIE` 托管)。卡片显示套餐/补偿积分窗口与周期截止重置(北京时间)及余额行。控制台 Cookie 过期后,按卡片提示重新复制。此控制台查询不接受 Token Plan 推理专用 Key(`tp-*` / `ttp-*`)。本地套餐统计按自然月汇总;补偿积分和余额只展示查询结果,不用无法区分归属的本地调用估算。
124
126
 
125
127
  CLIProxyAPI 网关来源卡片可勾选「只显示 Gemini 额度」,仅影响该来源的 Antigravity 分组。默认显示全部分组;过滤后无可见额度时显示空列表,解析错误仍单独报告。
@@ -354,22 +356,22 @@ Node.js 20 请改用 `npm install -g pnpm@10`。版本要求见 [pnpm 官方安
354
356
  dsh plugin --profile web add dsh-cost-meter
355
357
  ```
356
358
 
357
- **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.9.40`**,建议先下载审阅再运行):
359
+ **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.9.42`**,建议先下载审阅再运行):
358
360
 
359
361
  ```powershell
360
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.40/install.ps1 | iex
362
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.9.42/install.ps1 | iex
361
363
  ```
362
364
 
363
365
  **或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
364
366
 
365
367
  ```sh
366
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.40
368
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.9.42
367
369
  ```
368
370
 
369
371
  没有 git 时可用 GitHub tag 打包直链:
370
372
 
371
373
  ```sh
372
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.40.tar.gz
374
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.9.42.tar.gz
373
375
  ```
374
376
 
375
377
  安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
@@ -434,7 +436,7 @@ DSH **0.2.1-rc.1 / 0.2.1-rc.2** 宿主自带 pnpm **11.28.5**,默认启用内
434
436
 
435
437
  ```yaml
436
438
  minimumReleaseAgeExclude:
437
- - dsh-cost-meter@1.9.40
439
+ - dsh-cost-meter@1.9.42
438
440
  ```
439
441
 
440
442
  3. 仅本次操作用 CLI 透传 pnpm 参数:`dsh plugin --profile desktop remove dsh-cost-meter --config.minimum-release-age=0`;若只是 lockfile 校验阶段失败,可改用 `--trust-lockfile`。这两个参数已在本机 pnpm 11.28.5 临时 Profile 上实测可用。
@@ -0,0 +1,24 @@
1
+ # 百度千帆 Token Plan 额度
2
+
3
+ 支持千帆 Token Plan 个人版的积分制和 Token 制,显示月度已用百分比、已用量 / 总额度及套餐到期时间。数值由百度控制台读取,不按模型调用费用换算。
4
+
5
+ ## 配置
6
+
7
+ 1. 登录 [百度智能云千帆控制台](https://console.bce.baidu.com/qianfan/resource/token-plan),确认个人版套餐有效。
8
+ 2. 打开浏览器开发者工具的「网络」,刷新页面,找到 `tokenPlanPersonal/resource` 请求,复制请求头中的完整 `Cookie`。
9
+ 3. 在费用插件的「订阅额度」中启用「百度千帆 Token Plan」,展开卡片,将 Cookie 粘贴到凭据框并保存,点击刷新。也可在 DSH 主机配置 `BAIDU_QIANFAN_COOKIE` 环境变量。
10
+
11
+ Cookie 由 DSH 凭据库保管,不写入账本、配置备份或公开状态。登录过期后重新复制 Cookie。推理用的 API Key 不能代替控制台 Cookie;不要将 Cookie 发到 issue 或评论。
12
+
13
+ 本次接入个人版套餐本身的额度;加油包、企业版和旧 Coding Plan 的独立窗口不在此卡片中。到期时间独立显示,不当作月度重置时间。既有 `baidu-coding` 计费分类保持兼容,并识别 `baidu-token-plan`、`qianfan-token-plan` 等别名。
14
+
15
+ ## 接口依据与验证
16
+
17
+ 2026-10-26 核对 [官方个人版文档](https://cloud.baidu.com/doc/qianfan/s/Dmrabu8b6)及控制台公开前端:
18
+
19
+ - [订阅查询代码](https://aip-static.cdn.bcebos.com/mb-static/resource/assets/useRedeemCodeActivation-74e52f9e.js):`GET /api/qianfan/charge/tokenPlanPersonal/resource`,成功信封为 `success: true`,套餐在 `result.items` 中。
20
+ - `billingMode: "credit"` 使用 `usedCredits`、`totalCredits`;`"token"` 使用 `usedTokens`、`totalTokens`。`expiresAt` 是套餐到期时间,`resourceStatus: "Released"` 为已释放资源。
21
+ - [请求封装](https://aip-static.cdn.bcebos.com/mb-static/resource/assets/caller-368e0844.js):GET 使用同源 Cookie 和 `X-Requested-With: XMLHttpRequest`,没有修改套餐的操作。
22
+ - 未登录访问该只读端点实测返回 HTTP 302。插件拒绝跟随重定向,Cookie 只发送到固定官方端点。
23
+
24
+ 回归测试使用上述官方结构构造的数据,覆盖两种计量模式、过期套餐、无订阅、缺字段、认证失败、取消、凭据保管和状态编码。尚未使用真实付费账号核对数值。
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## English
4
4
 
5
+ ### Channel billing
6
+
7
+ In **Cost → Overview → Channel billing**, select a channel and choose Automatic, Plan subscription or Metered API. The choice applies to its models; individual model overrides take priority. Saving updates historical API/Plan classification without changing tokens, API-equivalent amounts or recorded exchange rates. Quota-query switches remain independent.
8
+
9
+ Automatic classification recognizes `dsh-opencode-go`, `opencode-go` and `opencode-go-plus` (including the `llm-` prefix) as Go subscriptions even when `planBilling.autoProviders` is empty. Explicit model/channel/family choices still take priority. Existing records receive a one-time classification correction. Other ambiguous channels continue using their saved automatic membership; `opencode-zen` remains metered API.
10
+
5
11
  ### Conversation cost views
6
12
 
7
13
  The conversation **Cost details** view defaults to the treemap and offers four layouts over the same complete cost totals:
@@ -41,7 +47,7 @@ From 1.8.10, the ledger retains every conversation instead of pruning details af
41
47
 
42
48
  API costs are **estimates from reported usage and configured rates**, not provider invoices. Plan costs are the API-equivalent value of subscription usage, not an extra charge. External usage snapshots remain separately visible in Overview; this page analyzes DSH's own ledger.
43
49
 
44
- With **Include subagents in session cost** enabled, the conversation badge, selected-conversation statistics and details include all continuous subagent descendants. The detail view lists each agent's recorded costs and identifies the owning conversation for every call, turn and step. Expanding a child turn reads that child's input and tools. Ordinary forks are excluded and inherited history is not billed twice. Disabling the setting limits ordinary conversations to their own costs. From 1.9.23, a live agent-team lead automatically includes its team members and their descendants even with this setting disabled. The host's public team roster identifies membership; agents retain separate ledger entries.
50
+ With **Include subagents in session cost** enabled, the conversation badge, selected-conversation statistics and details include all continuous subagent descendants. The detail view lists each agent's recorded costs and identifies the owning conversation for every call, turn and step. Expanding a child turn reads that child's input and tools. Ordinary forks are excluded and inherited history is not billed twice. Disabling the setting limits ordinary conversations to their own costs. From 1.9.23, a live agent-team lead automatically includes its team members and their descendants even with this setting disabled. The host's public team roster identifies membership; agents retain separate ledger entries. The session-list cost uses the same scope for both today and total. The durable `agentTeam` snapshot identifies the lead by its top-level `id` and contains only teammates in `members`; the client wire view adds `lead` / `teammate` roles. Both shapes are supported (verified against `@deepseek-ai/dsh-experimental-agent-team` 0.2.0-rc.2 and 0.2.1-rc.2, `lib/types/projection.js`, issue #420).
45
51
 
46
52
  Call details use the price version recorded for the call time, including peak/off-peak and long-context tiers. Editing rates, mappings or price currency affects subsequent calls. Older installations keep their existing ledger amounts and use the pre-upgrade price configuration as the baseline for available call logs; prices that were never recorded cannot be recovered. Missing logs and missing prices do not mean zero cost.
47
53
 
@@ -53,6 +59,12 @@ The statistics screen uses DSH's package-local asynchronous module loader. Since
53
59
 
54
60
  ## 简体中文
55
61
 
62
+ ### 渠道计费方式
63
+
64
+ 在 **费用 → 概览 → 渠道计费方式** 中选择渠道,再选择“自动”“Plan 订阅”或“API 按量”。设置适用于该渠道所有模型,模型单独设置优先。保存后更新历史 API/Plan 归属,保留 Token、API 等值金额和记录时的汇率金额。额度查询开关独立控制。
65
+
66
+ 自动归类按明确的订阅渠道识别 `dsh-opencode-go`、`opencode-go`、`opencode-go-plus`,支持 `llm-` 前缀,不再受空 `planBilling.autoProviders` 列表影响。用户显式设置的模型、原始渠道或套餐家族分类优先。已有账本启动后进行一次分类修正;其他无法仅凭渠道名判断的来源继续使用已保存的自动归属,`opencode-zen` 仍为 API 按量。
67
+
56
68
  ### 对话费用视图
57
69
 
58
70
  对话中的「费用明细」提供四种视图,使用同一份完整费用:
@@ -88,7 +100,7 @@ The statistics screen uses DSH's package-local asynchronous module loader. Since
88
100
 
89
101
  汇总读取 DSH 账本,打开页面会同步其他进程已写入的记录,不重新定价或修改历史金额。全局日、周及全部统计中,跨天对话合并成一行,开启子代理费用合计时,排行把子代理及其后代归入所属主会话,点击后的明细与排行金额一致;关闭时各会话分别列出。每笔费用只计一次。历史中未归属模型或对话的金额会单独提示。从 1.8.10 起,账本保留全部对话记录,不再按每日 200 个裁剪。若已记录的全部 Token 与调用次数完整覆盖一个日期,旧日总额会按这些对话已记录的金额修复;匿名调用和旧版裁剪留下的金额保留。此修复不重新定价。
90
102
 
91
- 开启设置中的“本会话费用包含子代理”后,会话费用徽章、单对话汇总和费用明细均包含该会话的子代理及全部子代理后代。明细单列主会话与各子代理的账本费用,逐次调用、轮次和步骤标注所属会话,展开子代理轮次可查看它自己的输入与工具调用。普通分叉会话不归入父会话,子代理继承的历史消息不重复收费。关闭开关时,普通对话只显示自身费用。从 1.9.23 起,正在运行的智能体团队主代理会根据宿主公开的团队名册自动包含成员及其后代,不受此开关影响;各代理继续分别入账。
103
+ 开启设置中的“本会话费用包含子代理”后,会话费用徽章、单对话汇总和费用明细均包含该会话的子代理及全部子代理后代。明细单列主会话与各子代理的账本费用,逐次调用、轮次和步骤标注所属会话,展开子代理轮次可查看它自己的输入与工具调用。普通分叉会话不归入父会话,子代理继承的历史消息不重复收费。关闭开关时,普通对话只显示自身费用。从 1.9.23 起,正在运行的智能体团队主代理会根据宿主公开的团队名册自动包含成员及其后代,不受此开关影响;各代理继续分别入账。会话列表的今日与累计费用采用同一范围。宿主 `agentTeam` 快照的顶层 `id` 标识主代理,`members` 只包含队友;客户端视图才添加 `lead` / `teammate` 角色。两种格式均已支持,依据 `@deepseek-ai/dsh-experimental-agent-team` 0.2.0-rc.2 和 0.2.1-rc.2 发布包中的 `lib/types/projection.js` 核对([#420](https://github.com/Han-1413141/dsh-cost-meter/issues/420))。
92
104
 
93
105
  API 费用是按上报用量和配置单价计算的估算,不是厂商账单;Plan 费用是订阅用量的 API 等值,不代表额外扣款。外部用量快照仍在原概览中单列,这个页面统计 DSH 自身账本。
94
106
 
@@ -1,5 +1,9 @@
1
1
  # 自定义余额:随机端口、局域网与 WorkBuddy2API
2
2
 
3
+ ## 侧栏跳转链接
4
+
5
+ 在“费用 → 额度”展开任一自定义余额条目,填写“跳转链接(可选)”(`dashboardUrl`)。链接可指向中转站账户、充值或控制台页面,使用完整 HTTP(S) 地址,不能包含用户名或密码。保存后,侧栏余额行或进度卡的名称旁显示跳转箭头;点击箭头打开新标签页,不触发余额刷新。各条目独立设置,留空时不显示链接。余额接口 URL、请求头和凭据不会被用作跳转链接。
6
+
3
7
  ## 跟随 DSH 随机端口
4
8
 
5
9
  在 **设置 → 费用 → 额度 → 自定义 Provider 余额** 中,请求 URL 可以填写以单个 `/` 开头的路径:
@@ -63,6 +67,8 @@ HTTPS 和本机回环 HTTP 继续可用。访问 `http://192.168.1.20:8790` 等
63
67
 
64
68
  ## English setup
65
69
 
70
+ Each custom balance entry has an optional **Dashboard link** (`dashboardUrl`) under **Cost → Quotas**. Use a complete HTTP(S) account or billing URL without embedded credentials. The sidebar row and progress card show an arrow next to that entry's name; it opens a new tab without refreshing the balance. Leave it blank to omit the link. Query URLs, headers and credentials are never used to construct navigation links.
71
+
66
72
  Root-relative URLs such as `/plugins/dsh-workbuddy-connect/status` follow the running DSH web server's actual port. Independent WorkBuddy2API deployments use an absolute URL. Non-loopback HTTP requires both `allowInsecureHttp: true` and an exact `host:port` in `allowedHosts`; this explicitly permits plaintext transport. Redirects remain blocked.
67
73
 
68
74
  The **+ WorkBuddy2API credits** preset reads `GET /api/credits/expiry?package_limit=1` with an admin `X-Admin-Token` stored as `WORKBUDDY2API_ADMIN_TOKEN` in DSH credentials. Set the real server address and matching allowlist, update expired admin tokens, then enable the card. The displayed `summary.available_remaining` is the active account pool's available credits, not currency, a single model API key's allowance, or the incomplete expiry snapshot total. No model request or upstream credit-refresh task is triggered. Authentication was tested with synthetic responses, not a live account.
@@ -1,5 +1,13 @@
1
1
  # 显示设置预览
2
2
 
3
+ 在“费用 → 显示 → 侧栏”打开“隐藏进度条,仅显示紧凑文本”,可去掉峰谷时段、套餐额度、余额、预算和模型占比的图形条。额度保留窗口名与百分比,峰谷保留当前时段、倒计时和切换时间;悬停详情、点击刷新与超额警告仍可使用。偏好会保存,重启后保留。此选项只影响侧栏和侧栏预览,不改变用量查询、账本、计价、输入区额度条或原有布局/条形方向;关闭后恢复原样式。在峰谷组件里仍可选择只显示倒计时或切换时间。
4
+
5
+ **Compact text:** In **Cost → Display → Sidebar**, enable **Hide progress bars, show compact text** to hide sidebar pricing-period, quota, balance, budget and model-share bars. Window labels, percentages, period times, hover details, refresh actions and warnings remain available. The preference survives restart, applies to the sidebar preview, and never changes billing, account queries, composer bars or the saved graphical style. Disable it to restore the existing bars.
6
+
7
+ 在“费用 → 额度”展开自定义余额条目,可设置“跳转链接(可选)”。填写账户、充值或控制台的 HTTP(S) 地址后,侧栏该条余额名称旁显示跳转箭头;余额行、进度卡和查询失败提示均可使用。点击箭头在新标签页打开,不触发余额刷新。每条链接独立保存,留空时不显示箭头;不从余额查询接口或请求头推导链接。
8
+
9
+ 选择“侧栏 → 调整组件 → 余额”,可开启“仅官方渠道显示”(`balance.officialChannelOnly`,默认关闭)。开启后,侧栏官方余额只在当前会话使用 `deepseek`、`deepseek-official` 或 `deepseek-account` 渠道时显示;带 `llm-` 前缀的名称按相同渠道识别。无活跃会话或宿主未提供渠道投影时,按今日账本是否有官方渠道调用判断,包括零费用调用。当前会话明确使用其他渠道时,即使今天调用过官方渠道也隐藏;切换渠道后下一次调用更新显示。设置页官方余额面板和显示预览不受渠道限制,“隐藏官方余额”、显示位置与来源标注继续独立生效。
10
+
3
11
  会话列表行末金额默认关闭。在“侧栏 → 调整组件 → 会话列表金额”打开“显示此组件”,选择累计或今日。金额沿用显示币种、精度与汇率设置;没有记录显示“—”,悬停查看输入、缓存和输出 Token。仅合并查询当前可见行,结果缓存五秒,显示期间每十秒刷新;关闭功能或隐藏页面时停止定时查询,收起为图标侧栏时不显示。
4
12
 
5
13
  关闭输入框上方的 Codex 额度条:选择“输入区 → 调整组件 → Codex 额度”,取消“在输入区显示 Codex 额度”。该开关与侧栏额度独立,不影响预算、Go 或其他套餐的额度条;两个 Codex 显示位置都隐藏时停止查询。
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## English
4
4
 
5
+ ### Configuration recovery after an abnormal shutdown
6
+
7
+ The ledger and its independent `ledger.json.config-bak` are written to temporary files in the same directory, flushed, and then renamed over their destinations. POSIX systems also flush the directory after replacement. The backup stores only configuration and migration markers, using the ledger's existing secret filtering; credentials remain in the DSH credential store and configuration placeholders are preserved. Usage-only updates do not rewrite an unchanged backup.
8
+
9
+ A healthy existing ledger creates or updates this backup when loaded. If the ledger is corrupt, the original `.corrupt-*` file is retained and settings are recovered from the backup. A missing ledger can also use the backup. The log reports successful restoration and the number of custom balance sources; an unreadable backup is reported and defaults are used. Usage history continues through the existing backfill mechanism. An already zeroed file from before this protection, with no backup, contains no settings to recover. See [#412](https://github.com/Han-1413141/dsh-cost-meter/issues/412).
10
+
5
11
  Issue [#237](https://github.com/Han-1413141/dsh-cost-meter/issues/237) reports a startup failure with **Ledger is busy; preserving pending changes for retry**. The sidebar balance and quota widgets disappear because the cost-meter loader entry did not activate. An old lock can name a PID that now belongs to a different process; checking only whether that PID exists cannot identify the original owner.
6
12
 
7
13
  ### Update and recover
@@ -25,6 +31,12 @@ Implementation references: [Linux process start ticks](https://man7.org/linux/ma
25
31
 
26
32
  ## 简体中文
27
33
 
34
+ ### 异常退出后的配置恢复
35
+
36
+ 账本及独立的 `ledger.json.config-bak` 均先写入同目录临时文件,刷盘后再替换目标文件;POSIX 系统同时同步目录。备份只保存配置和迁移记录,沿用账本的脱敏规则,凭据仍由 DSH 凭据库保存,配置中的占位符保留。仅用量变化时不重写配置备份。
37
+
38
+ 已有的正常账本加载时即建立或更新备份。账本损坏后保留原始 `.corrupt-*` 文件,并从备份恢复设置;账本缺失时同样读取备份。日志显示恢复结果及自定义余额源数量;备份也无法读取时记录错误并使用默认配置。用量历史继续由现有补录流程处理。启用此保护之前已经全零且没有备份的文件,没有可恢复的配置内容。问题来源:[#412](https://github.com/Han-1413141/dsh-cost-meter/issues/412)。
39
+
28
40
  Issue [#237](https://github.com/Han-1413141/dsh-cost-meter/issues/237) 报告启动时出现 **Ledger is busy; preserving pending changes for retry**。费用插件未成功挂载,侧栏余额和额度卡片随之消失。旧锁中的 PID 可能已经被系统分配给另一个进程,仅检查 PID 是否存在不能确认原锁持有者。
29
41
 
30
42
  ### 升级与恢复
@@ -0,0 +1,25 @@
1
+ # 官方价格币种保护与历史核对
2
+
3
+ ## 中文
4
+
5
+ 官方页面可能只解析出部分模型。此前,从人民币价格切换到美元价格时,部分同步会保留未返回模型的旧数值,却把整张价目表的币种改为美元;展示为人民币时又乘一次汇率。v1.9.42 在这种情况下拒绝整个同步,保留原配置及价格历史。完整同步和不改变币种的部分同步仍可正常工作。
6
+
7
+ 这项保护防止新的错误计价,**不会把已有账本改成推测金额**。仅凭导出的费用报表,不能确认原价格配置、所有历史版本或另一个插件的统计范围。另一插件显示的总额也不等于供应商结算凭证。
8
+
9
+ ### 安全核对顺序
10
+
11
+ 1. 保留原始导出、完整账本和会话日志的只读备份,不删除迁移标记,不清空账本。费用导出是核对报表,不是可以覆盖 `ledger.json` 的备份。
12
+ 2. 在“费用 → 价格”核对受影响**渠道+模型**的币种、缓存命中/未命中及输出单价、倍率、峰谷和上下文档位。另一个插件必须使用同一时间范围、渠道、子代理范围和计费口径才能对比。
13
+ 3. 正确保存未来调用的价格;若同步提示模型不完整,保留原值并检查官方页面,不能仅修改币种标签来强行同步。
14
+ 4. 仅在确认当前单价适用于所选渠道模型的全部保留历史后,使用[按模型重算历史费用](model-history-repricing.md)的明确确认流程。系统先备份账本,再记录重算范围、前后金额和价格版本;调用 Token、原汇率及其他模型不变,日志不完整的记录跳过。
15
+ 5. 若只有某一时段的价格异常,而其他时段有真实价格变化,**不要用当前价格覆盖整个模型历史**。应先依据原始配置/价格历史与日志核对分段范围,确认修复方案后再操作。当前模型重算入口不是按时间段修复工具。
16
+
17
+ 升级与价格同步本身均不执行第 4 步。未得到可靠来源确认前,保留“金额待核对”的结论比强行凑成某个总额更安全。
18
+
19
+ ## English
20
+
21
+ A partially parsed official page previously could keep omitted models' CNY numbers while changing the whole table's currency to USD. Converting those charges to CNY then multiplied them by the exchange rate again. Version 1.9.42 rejects that entire cross-currency synchronization, preserving configuration and pricing history. Complete synchronization and same-currency partial updates remain supported.
22
+
23
+ This protection does not rewrite recorded charges. Keep read-only copies of the original export, complete ledger and session logs. An export is a report, not a replacement ledger. Compare the same time range, channel, model, subagent scope, cache rates, multipliers and pricing tiers; another plugin's total is not an authoritative invoice.
24
+
25
+ Correct future pricing first. Use the explicitly confirmed [channel/model history recalculation](model-history-repricing.md) only when those current rates are appropriate for all retained calls in the selected scope. That path creates a full backup, records before/after totals and retains original exchange rates; incomplete logs are skipped. It is not an interval-specific repair tool. If only one historical interval is wrong, verify the original pricing versions and affected interval before authorizing a scoped repair. Updating the plugin or synchronizing prices never starts historical recalculation automatically.
@@ -23,3 +23,5 @@ GitHub Actions 工作流 `plugin-compatibility-watch` 每日北京时间 08:23
23
23
  | dsh-codex-connect | 0.2.0-alpha.10 | 宿主依赖与状态路由变化,状态读取使用同一账号快照。新增实际发布包检查,执行原版额度解析器、公开状态类与 GET 路由,覆盖读取期间切换账号、下一次刷新、登录失效、额度失败、401/403 拒绝、405 方法限制与卸载清理。 |
24
24
 
25
25
  基线更新为 `0.1.206 / 3.1.6 / 0.2.0-alpha.10`,保存对应发布包的 SHA-512 完整性。Connect 的账号、认证和额度服务使用本地模拟对象;原版插件初始化、OAuth 登录与外部模型请求没有执行。检查入口为 `test/codex-connect-published.mjs`,通过 `DSH_TEST_CONNECT_PACKAGE` 指定已下载的 npm 压缩包。
26
+
27
+ 2026-10-26 已验证 `billion-context@0.1.208` 与 `dsh-codex-subscription@3.1.7`,处理 `github-actions[bot]` 的 [#416](https://github.com/Han-1413141/dsh-cost-meter/issues/416)、[#417](https://github.com/Han-1413141/dsh-cost-meter/issues/417)。前者接口指纹未变,实际发布包的四协议计费、压缩、重试、父子会话、历史回放与原版 CLI 自动接入检查通过。后者 RPC 分发变化涉及语音取消、错误分类及切换账号后的模型目录初始化,`usage/read` 分支未变;实际发布包的单周、双窗口、强制刷新与失败回退检查通过。两版加入 CI,保留旧版本及 Connect 基线。
@@ -0,0 +1,29 @@
1
+ # v1.9.41:Web 启动修复与账本配置恢复
2
+
3
+ ## 中文
4
+
5
+ 本次更新修复 Web 端插件加载失败,并增加账本配置的独立备份与恢复。
6
+
7
+ - 为 `conversation.chat.turnTail` 补齐 chain 插槽要求的 `select`,修复启动时的 `requires options.select` 报错。
8
+ - 账本与 `ledger.json.config-bak` 均先写入同目录临时文件、刷盘,再替换目标文件。POSIX 系统同时同步目录;临时文件刷盘或替换失败时保留原文件。
9
+ - 正常账本加载时建立配置备份,之后仅在配置或迁移记录变化时更新。备份沿用现有脱敏规则,保留凭据占位符。
10
+ - 账本损坏或缺失时,从备份恢复自定义余额源等设置;保留损坏账本,并在日志中显示恢复结果。用量历史继续由现有补录流程处理。
11
+
12
+ 此前已经全零且没有备份的文件,没有可恢复的配置内容。
13
+
14
+ 感谢 [@korion3](https://github.com/korion3) 在 [#413](https://github.com/Han-1413141/dsh-cost-meter/issues/413) 报告、定位 Web 启动故障,并在 [#414](https://github.com/Han-1413141/dsh-cost-meter/pull/414) 提供修复;感谢 [@kevindawn11-hash](https://github.com/kevindawn11-hash) 在 [#412](https://github.com/Han-1413141/dsh-cost-meter/issues/412) 提供账本损坏证据与配置备份建议。
15
+
16
+ 更新后完全重启 DSH,使插件服务端加载新版本。
17
+
18
+ ## English
19
+
20
+ This update fixes Web plugin startup and adds independent configuration backup and recovery.
21
+
22
+ - Add the required `select` function to the `conversation.chat.turnTail` chain slot, fixing the startup error `requires options.select`.
23
+ - Write the ledger and `ledger.json.config-bak` to temporary files in the same directory, flush them, then replace their destinations. POSIX systems also flush the directory; file-sync or replacement failures preserve the original file.
24
+ - Create a configuration backup when a healthy ledger loads, then update it only when configuration or migration markers change. The backup uses existing secret filtering and preserves credential placeholders.
25
+ - Restore settings, including custom balance sources, when the ledger is corrupt or missing. Keep the corrupt ledger and log the restoration result. Usage history continues through the existing backfill process.
26
+
27
+ A file that was already zeroed before this protection, with no backup, contains no configuration to recover.
28
+
29
+ Thanks to [@korion3](https://github.com/korion3) for the report and diagnosis in [#413](https://github.com/Han-1413141/dsh-cost-meter/issues/413) and the fix in [#414](https://github.com/Han-1413141/dsh-cost-meter/pull/414), and to [@kevindawn11-hash](https://github.com/kevindawn11-hash) for the corruption evidence and backup suggestions in [#412](https://github.com/Han-1413141/dsh-cost-meter/issues/412). Fully restart DSH after updating.
@@ -0,0 +1,21 @@
1
+ # v1.9.42:提醒交互、计价币种保护与纯文本侧栏
2
+
3
+ ## 中文
4
+
5
+ - **提醒可正常关闭**:“新增:余额图框点击刷新”使用现有顶层浮卡,避免侧栏裁剪、窗口拖动区域及浮动插件拦截按钮。点击“知道了”、关闭按钮或按 Escape 后立即消失;设置服务失败不会重新弹出,同页重复挂载一起关闭。正常本地存储可跨刷新保留已读;本地存储和服务同时不可用时,仅能保证当前页面与组件重挂不再显示。
6
+ - **纯文本侧栏**:在“费用 → 显示 → 侧栏”开启“隐藏进度条,仅显示紧凑文本”。隐藏余额、预算、套餐额度和峰谷时间的图形条,保留数值、时间、悬停与刷新操作。原布局和进度条偏好不被删除,关闭开关即可恢复。
7
+ - **官方同步币种保护**:从一种币种切换到另一种币种时,如果官方页面只返回部分模型,拒绝整个同步,而不是把遗漏模型的旧价格误标为新币种。历史费用不自动重算;请先按[安全核对说明](official-price-sync-safety.md)确认价格与范围。
8
+
9
+ 本版还包含 `master` 已有的多账号额度查询、Go 订阅计费分类、自定义余额跳转链接、Agent Teams 统计范围、百度千帆 Token Plan、官方余额渠道过滤以及发布包兼容性更新。原始问题与贡献署名完整保留于 [CHANGELOG](../CHANGELOG.md#1942---2026-10-28),本次修复未替代或重署这些贡献。
10
+
11
+ 升级后完全重启 DSH,使服务端价格保护生效,再刷新 Web 页面。用户提交的账本与截图未放入仓库或安装包。
12
+
13
+ ## English
14
+
15
+ The balance-refresh announcement now uses the existing protected top-layer card. Dismissal is immediate and does not reopen after a failed settings request. Duplicate mounts close together; local storage preserves dismissal across reloads. If both storage and the service are unavailable, dismissal can only survive remounts in the current page.
16
+
17
+ Enable **Cost → Display → Sidebar → Hide progress bars, show compact text** to retain values, timing, tooltips and refresh actions without graphical bars. Disabling it restores the saved layout and bar preferences.
18
+
19
+ Official price synchronization now rejects incomplete cross-currency updates rather than relabeling retained numbers. Historical amounts are never automatically rewritten; follow the [verification and repair guidance](official-price-sync-safety.md).
20
+
21
+ This release also includes the existing unreleased main-branch features listed with original contributor credits in the changelog. Fully restart DSH and refresh the Web UI after updating. Private reports and screenshots are not included in the repository or package.
@@ -0,0 +1,82 @@
1
+ import { fetchWithRetry, readJsonBounded } from './net.js'
2
+
3
+ // Official console contract and evidence: docs/baidu-token-plan.md.
4
+ // The model API key is not a console credential. Never return the resource's apiKey.
5
+ export const BAIDU_TOKEN_PLAN_URL = 'https://console.bce.baidu.com/api/qianfan/charge/tokenPlanPersonal/resource'
6
+
7
+ export function normalizeBaiduCookie(value) {
8
+ if (typeof value !== 'string' || /[\r\n\x00-\x1f\x7f]/.test(value) || value.length > 16384) return null
9
+ const cookie = value.trim().replace(/^cookie:\s*/i, '')
10
+ const parts = cookie.split(';').filter(part => part.trim())
11
+ return parts.length && parts.some(part => /=\s*\S/.test(part))
12
+ && parts.every(part => /^\s*[^=\s;]+=[^;]*$/.test(part)) ? cookie : null
13
+ }
14
+
15
+ const number = value => (typeof value === 'number' || (typeof value === 'string' && value.trim()))
16
+ && Number.isFinite(Number(value)) && Number(value) >= 0 ? Number(value) : null
17
+ const expiryOf = value => {
18
+ if (typeof value !== 'string' || !value.trim()) return null
19
+ // BCE console wall-clock timestamps are in China Standard Time, independent of host timezone.
20
+ const date = new Date(/^\d{4}-\d\d-\d\d[ T]\d\d:\d\d:\d\d(?:\.\d+)?$/.test(value)
21
+ ? value.replace(' ', 'T') + '+08:00' : value)
22
+ return Number.isFinite(date.getTime()) ? date : null
23
+ }
24
+
25
+ export function parseBaiduTokenPlan(data, locale = 'zh', now = Date.now()) {
26
+ if (data?.success !== true || !Array.isArray(data.result?.items)) return null
27
+ const item = data.result.items.find(row => row && typeof row === 'object'
28
+ && row.resourceStatus !== 'Released' && (expiryOf(row.expiresAt)?.getTime() ?? Infinity) > now)
29
+ if (!item || !['credit', 'token', undefined].includes(item.billingMode)) return null
30
+ const credit = item.billingMode === 'credit'
31
+ const used = number(credit ? item.usedCredits : item.usedTokens)
32
+ const total = number(credit ? item.totalCredits : item.totalTokens)
33
+ if (used === null || total === null || total <= 0) return null
34
+ const unit = credit ? locale === 'en' ? 'credits' : '积分' : 'Tokens'
35
+ const format = value => value.toLocaleString(locale === 'en' ? 'en-US' : 'zh-CN', { maximumFractionDigits: 4 })
36
+ const expiry = expiryOf(item.expiresAt)
37
+ return {
38
+ windows: {
39
+ monthly: { percent: Math.min(100, Math.round(used / total * 1000) / 10), resetsAt: '' },
40
+ usage: { text: `${format(used)} / ${format(total)} ${unit}`, resetsAt: '' },
41
+ },
42
+ // Subscription expiry is not the monthly quota reset time.
43
+ message: expiry ? (locale === 'en' ? 'Expires: ' : '套餐到期:')
44
+ + expiry.toLocaleString(locale === 'en' ? 'en-GB' : 'zh-CN', { timeZone: 'Asia/Shanghai', hour12: false }) + ' (UTC+8)' : '',
45
+ }
46
+ }
47
+
48
+ export async function queryBaiduTokenPlan(key, locale, { signal } = {}) {
49
+ const text = (zh, en) => locale === 'en' ? en : zh
50
+ const fail = (kind, soft = false) => {
51
+ const messages = {
52
+ cookie: text('请填写百度智能云控制台的完整 Cookie,或配置 BAIDU_QIANFAN_COOKIE;推理 API Key 不用于额度查询。', 'Enter the full Baidu Cloud console Cookie or set BAIDU_QIANFAN_COOKIE; inference API keys cannot query quotas.'),
53
+ login: text('百度智能云登录已过期,请登录 console.bce.baidu.com 并重新复制 Cookie。', 'Baidu Cloud login expired. Sign in at console.bce.baidu.com and copy a fresh Cookie.'),
54
+ usage: text('未读取到有效的千帆 Token Plan 个人版额度,请在控制台确认套餐状态。', 'No active Qianfan Token Plan Personal quota found. Check the subscription in the console.'),
55
+ network: text('千帆额度查询失败,请稍后重试。', 'Qianfan quota request failed. Please retry later.'),
56
+ }
57
+ const error = new Error(messages[kind]); error.soft = soft; return error
58
+ }
59
+ signal?.throwIfAborted()
60
+ const cookie = normalizeBaiduCookie(key)
61
+ if (!cookie) throw fail('cookie', true)
62
+ let response
63
+ try {
64
+ response = await fetchWithRetry(BAIDU_TOKEN_PLAN_URL, {
65
+ method: 'GET', headers: { cookie, accept: 'application/json', 'X-Requested-With': 'XMLHttpRequest' },
66
+ redirect: 'manual', signal,
67
+ }, { timeoutMs: 15000, attempts: 2 })
68
+ } catch { signal?.throwIfAborted(); throw fail('network') }
69
+ if (!response.ok) {
70
+ try { await response.body?.cancel?.() } catch {}
71
+ if ([401, 403].includes(response.status) || (response.status >= 300 && response.status < 400)) throw fail('login', true)
72
+ throw fail('network')
73
+ }
74
+ let data
75
+ try { data = await readJsonBounded(response, 262144, { signal }) }
76
+ catch { signal?.throwIfAborted(); throw fail('usage') }
77
+ signal?.throwIfAborted()
78
+ if (data?.message?.redirect || [401, 403, '401', '403'].includes(data?.code)) throw fail('login', true)
79
+ const result = parseBaiduTokenPlan(data, locale)
80
+ if (!result) throw fail('usage', true)
81
+ return { ...result, endpoint: BAIDU_TOKEN_PLAN_URL }
82
+ }