dsh-cost-meter 1.7.4 → 1.7.6

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.en.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  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; from Aug 23, 2026 weekends are billed at off-peak prices all day, shown as “Weekend — all off-peak”) · 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 90+ model price catalog with auto-matching) · mainstream Coding Plan quota queries & display (Anthropic / Z.ai / MiniMax / Kimi / OpenRouter / SiliconFlow / CommandCode / SCNet) 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) · · quota strip above the input box (budget / Go / coding-plan usage in one row, toggleable)
8
8
 
9
- [![version](https://img.shields.io/badge/version-1.7.4-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
9
+ [![version](https://img.shields.io/badge/version-1.7.6-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
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
12
12
  [![dsh](https://img.shields.io/badge/DeepSeek%20Harness-dsh--plugin-4176E6)](https://github.com/deepseek-ai/deepseek-harness)
@@ -87,6 +87,13 @@ For NewApi `GET /api/usage/token` (response `{ "code": 200, "data": { "total_gra
87
87
  - Unlimited-quota tokens (`unlimited_quota: true`) have no `total_available`, so `remaining` cannot be extracted and the query reports “remaining is missing or not numeric” — use a limited-quota token or a middle-layer endpoint that converts the units;
88
88
  - Entry point: Settings → Cost (Quota tab) → “Custom provider balance” → expand config; or write `config.customBalance` in `storages/cost-meter/ledger.json`.
89
89
 
90
+ ### Credentials & security (v1.7.6)
91
+
92
+ - **Variable naming**: `{{VAR_NAME}}` follows the `<ROUTE>_API_KEY` convention — `<ROUTE>` is the Provider ID from the DSH Models page (Settings → Models), uppercased with non-alphanumeric characters replaced by underscores, e.g. `openai`→`{{OPENAI_API_KEY}}`, `anthropic`→`{{ANTHROPIC_API_KEY}}`, `abc23-d`→`{{ABC23_D_API_KEY}}`. Sharing a name with the Models page means the balance query and model calls **share the same key** (both resolve from the DSH credential store). This note is also shown above the “Headers (JSON)” input in Settings.
93
+ - **Credential input fields**: after expanding an entry, the “Credential input” section renders one write-only field per `{{VAR}}` placeholder found in the headers — the key goes straight into the DSH credential store (never written to disk, never echoed back, never stored in `ledger.json`); no need to hand-edit environment variables or credential files.
94
+ - **Automatic plaintext migration**: older versions let a literal `Bearer sk-…` in the headers leak into `ledger.json` in plaintext. Since v1.7.6 the plugin imports such keys into the DSH credential store at startup and replaces the header value with a `{{CUSTOM_BALANCE_KEY_…}}` placeholder (derived from the entry's host + header name, stable across restarts) — nothing breaks. From now on `ledger.json` and the config shipped to the browser **never contain plaintext keys**: suspected secret headers (Authorization / X-Api-Key / Bearer / sk- prefixes / long opaque strings) are blanked, while placeholders and ordinary headers pass through.
95
+ - **Credential allowlist `allowedHosts`**: when headers carry credentials (placeholders or plaintext), the outbound host must be on this list or the request is refused — protection against leaked keys when importing someone else's config. Without a list, requests proceed with a one-time logged warning. The entry panel provides an “Allowed hosts” input (comma-separated).
96
+
90
97
  ## Bilingual UI
91
98
 
92
99
  The plugin UI (session badge, sidebar balance row & budget box, and the entire Settings page) supports **Simplified Chinese** and **English**:
@@ -231,22 +238,22 @@ Real captures from an actual DSH sidebar of the period strip and collapsed verti
231
238
  dsh plugin --profile web add dsh-cost-meter
232
239
  ```
233
240
 
234
- **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.7.4`** — review the script before running):
241
+ **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.7.6`** — review the script before running):
235
242
 
236
243
  ```powershell
237
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.4/install.ps1 | iex
244
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.6/install.ps1 | iex
238
245
  ```
239
246
 
240
247
  **Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
241
248
 
242
249
  ```sh
243
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.4
250
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.6
244
251
  ```
245
252
 
246
253
  Without git, use the GitHub tag archive:
247
254
 
248
255
  ```sh
249
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.4.tar.gz
256
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.6.tar.gz
250
257
  ```
251
258
 
252
259
  After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  本会话费用 · 当日费用 · OpenCode Go 订阅额度显示 · 预算与已用百分比 · 官方账户余额 · 自定义 Provider 余额查询(可配任意 HTTP 端点) · 余额三段进度条 · 历史记录 · 峰谷计价时段显示(UTC 01:00–04:00、06:00–10:00 为峰时段;2026-08-23 起周末全天按谷价,显示「周末时段——全谷价」) · 峰/谷切换前弹窗与系统通知提醒(位置/提前量/提醒类型可配) · 官方价格一键同步 · 类 Codex Token 用量热图 · 多厂商多模型价格计费(内置 90+ 模型价格目录与自动匹配) · 主流 Coding Plan 额度查询与显示(Anthropic / Z.ai / MiniMax / Kimi / OpenRouter / SiliconFlow / CommandCode / SCNet / 火山方舟 九家,含 Volcano Ark AK/SK 签名) · Plan/API 双轨计费(订阅额度与按量金额分离统计,每 1% 额度与满窗的 token/等值金额估算及日/周/月曲线) · 输入框上方额度横条(预算/Go/Coding Plan 用量一条横排显示,可开关)
8
8
 
9
- [![version](https://img.shields.io/badge/version-1.7.4-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
9
+ [![version](https://img.shields.io/badge/version-1.7.6-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
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
12
12
  [![dsh](https://img.shields.io/badge/DeepSeek%20Harness-dsh--plugin-4176E6)](https://github.com/deepseek-ai/deepseek-harness)
@@ -88,6 +88,13 @@
88
88
  - 无限额度 token(`unlimited_quota: true`)没有 `total_available`,无法提取 `remaining`,查询会报「remaining is missing or not numeric」——请改用有限额度 token,或在中间层端点换算;
89
89
  - 配置入口:设置 → 费用(额度标签)→「自定义 Provider 余额」展开配置;或直接改 `storages/cost-meter/ledger.json` 的 `config.customBalance`。
90
90
 
91
+ ### 凭据与安全(v1.7.6)
92
+
93
+ - **变量名命名规则**:`{{VAR_NAME}}` 的参考格式为 `<ROUTE>_API_KEY`——`<ROUTE>` 对应 DSH 模型配置页(设置 → 模型)里的 Provider ID,把 ID 大写、非字母数字字符替换为下划线,例如 `openai`→`{{OPENAI_API_KEY}}`、`anthropic`→`{{ANTHROPIC_API_KEY}}`、`abc23-d`→`{{ABC23_D_API_KEY}}`。与模型页共用同一变量名,自定义余额查询与模型调用即**共用同一把密钥**(都从 DSH 凭据库解析)。该说明也展示在设置页「请求头 (JSON)」输入框上方。
94
+ - **凭据输入框**:展开条目配置后,「凭据输入」区会为请求头里出现的每个 `{{VAR}}` 占位符显示一行 write-only 输入框,密钥直接存入 DSH 凭据库(不落盘、不回显、不经 `ledger.json`),无需再手改环境变量或凭据文件。
95
+ - **明文密钥自动迁移**:旧版本把 `Bearer sk-…` 明文写在请求头里时会明文落盘;v1.7.6 起插件在启动时自动把这类明文导入 DSH 凭据库,并把头值替换为 `{{CUSTOM_BALANCE_KEY_…}}` 占位符(名称由条目 host + 头名派生,跨重启稳定),功能不受影响。此后 `ledger.json` 与下发给浏览器的配置**永不包含明文密钥**——疑似密钥头(Authorization / X-Api-Key / Bearer / sk- 前缀 / 长不透明串)一律置空,占位符与普通头照常保留。
96
+ - **凭据白名单 `allowedHosts`**:请求头携带密钥(占位符或明文)时,出站主机必须命中该白名单,否则直接拒绝——用于防止「导入他人配置」导致密钥外带。未配置白名单时放行并在日志警告一次。设置页条目面板内有「凭据白名单主机」输入框(逗号分隔)。
97
+
91
98
  ## 双语界面
92
99
 
93
100
  插件界面(会话徽章、侧边栏余额与预算图框、设置页全部文案)支持**简体中文**与**English**:
@@ -233,22 +240,22 @@
233
240
  dsh plugin --profile web add dsh-cost-meter
234
241
  ```
235
242
 
236
- **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.7.4`**,建议先下载审阅再运行):
243
+ **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.7.6`**,建议先下载审阅再运行):
237
244
 
238
245
  ```powershell
239
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.4/install.ps1 | iex
246
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.6/install.ps1 | iex
240
247
  ```
241
248
 
242
249
  **或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
243
250
 
244
251
  ```sh
245
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.4
252
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.6
246
253
  ```
247
254
 
248
255
  没有 git 时可用 GitHub tag 打包直链:
249
256
 
250
257
  ```sh
251
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.4.tar.gz
258
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.6.tar.gz
252
259
  ```
253
260
 
254
261
  安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
@@ -1,5 +1,5 @@
1
1
  {
2
- "generatedAt": "2026-08-25",
2
+ "generatedAt": "2026-09-01",
3
3
  "note": "Auto-generated from lib/pricing.js DEFAULT_PROVIDER_PRICE_TABLE. USD per 1M tokens; unpriced entries have no verified official price.",
4
4
  "providers": {
5
5
  "openai": {
@@ -322,6 +322,15 @@
322
322
  "checkedAt": "2026-08-17",
323
323
  "notes": "≤200K 档;>200K 按 $4/$18 计"
324
324
  },
325
+ "gemini-3.1-pro": {
326
+ "input": 2,
327
+ "cachedInput": 0.2,
328
+ "output": 12,
329
+ "billingMode": "flat",
330
+ "sourceUrl": "https://opencode.ai/docs/zen",
331
+ "checkedAt": "2026-08-25",
332
+ "notes": "≤200K 档;>200K 按 $4/$18 计"
333
+ },
325
334
  "gemini-3-flash": {
326
335
  "input": 0.5,
327
336
  "cachedInput": 0.05,
@@ -397,9 +406,22 @@
397
406
  "z-ai": {
398
407
  "models": {
399
408
  "glm-5.3": {
400
- "unpriced": true,
409
+ "input": 1.4,
410
+ "cachedInput": 0.26,
411
+ "output": 4.4,
412
+ "billingMode": "flat",
413
+ "sourceUrl": "https://opencode.ai/docs/go",
414
+ "checkedAt": "2026-09-01",
415
+ "notes": "智谱国内直连 ¥8/¥28/缓存¥2(约 1.11/3.89/0.28 USD,目录价略高于直连)"
416
+ },
417
+ "glm-5.3-flash": {
418
+ "input": 0.15,
419
+ "cachedInput": 0.03,
420
+ "output": 0.5,
401
421
  "billingMode": "flat",
402
- "notes": "OpenCode Go 目录在册;官方/Zen 均未公布单价,不编造价格"
422
+ "sourceUrl": "https://opencode.ai/docs/go",
423
+ "checkedAt": "2026-09-01",
424
+ "notes": "Ox Alpha 普惠版(2026-08-26 发布,原生多模态);Go 目录与 Cloudflare 目录同价"
403
425
  },
404
426
  "glm-5.2": {
405
427
  "input": 1.4,
@@ -551,10 +573,10 @@
551
573
  "tencent": {
552
574
  "models": {
553
575
  "hunyuan-a13b": {
554
- "input": 0.5,
555
- "output": 2,
576
+ "input": 0.0694,
577
+ "output": 0.2778,
556
578
  "billingMode": "flat",
557
- "notes": "Official price is CNY; catalog value requires currency conversion before use."
579
+ "notes": "官方价为 CNY ¥0.5/¥2 每百万 token,按默认展示汇率 7.2 折算为 USD 入账"
558
580
  },
559
581
  "hy3": {
560
582
  "input": 0.14,
@@ -667,8 +689,8 @@
667
689
  "cachedInput": 0.3,
668
690
  "output": 6,
669
691
  "billingMode": "flat",
670
- "sourceUrl": "https://opencode.ai/docs/go",
671
- "checkedAt": "2026-08-17"
692
+ "sourceUrl": "https://opencode.ai/docs/zen",
693
+ "checkedAt": "2026-08-25"
672
694
  },
673
695
  "glm-5.3": {
674
696
  "input": 1.4,
@@ -676,7 +698,15 @@
676
698
  "output": 4.4,
677
699
  "billingMode": "flat",
678
700
  "sourceUrl": "https://opencode.ai/docs/go",
679
- "checkedAt": "2026-08-25"
701
+ "checkedAt": "2026-09-01"
702
+ },
703
+ "glm-5.3-flash": {
704
+ "input": 0.15,
705
+ "cachedInput": 0.03,
706
+ "output": 0.5,
707
+ "billingMode": "flat",
708
+ "sourceUrl": "https://opencode.ai/docs/go",
709
+ "checkedAt": "2026-09-01"
680
710
  },
681
711
  "glm-5.2": {
682
712
  "input": 1.4,