dsh-cost-meter 1.7.35 → 1.7.36
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 +6 -6
- package/README.zh-CN.md +6 -6
- package/lib/net.js +17 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
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 / Volcano Ark / Qwen / Xiaomi MiMo) 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)
|
|
10
10
|
|
|
11
|
-
[](https://github.com/Han-1413141/dsh-cost-meter)
|
|
12
12
|
|
|
13
|
-
**v1.7.
|
|
13
|
+
**v1.7.36** prevents CommandCode quota failures caused by CDN responses that contain compressed bytes without a `Content-Encoding` header. Requests use `Accept-Encoding: identity` by default while retaining explicit overrides. See the [release notes](docs/release-notes/v1.7.36.md).
|
|
14
14
|
|
|
15
15
|
[](https://www.npmjs.com/package/dsh-cost-meter)
|
|
16
16
|
[](LICENSE)
|
|
@@ -316,22 +316,22 @@ On Node.js 20, use `npm install -g pnpm@10` instead. See [pnpm installation and
|
|
|
316
316
|
dsh plugin --profile web add dsh-cost-meter
|
|
317
317
|
```
|
|
318
318
|
|
|
319
|
-
**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.
|
|
319
|
+
**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.36`** — review the script before running):
|
|
320
320
|
|
|
321
321
|
```powershell
|
|
322
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.
|
|
322
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.36/install.ps1 | iex
|
|
323
323
|
```
|
|
324
324
|
|
|
325
325
|
**Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
|
|
326
326
|
|
|
327
327
|
```sh
|
|
328
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.
|
|
328
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.36
|
|
329
329
|
```
|
|
330
330
|
|
|
331
331
|
Without git, use the GitHub tag archive:
|
|
332
332
|
|
|
333
333
|
```sh
|
|
334
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.
|
|
334
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.36.tar.gz
|
|
335
335
|
```
|
|
336
336
|
|
|
337
337
|
After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
|
package/README.zh-CN.md
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
本会话费用 · 当日费用 · 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 / 火山方舟 / 千问 / 小米 MiMo 十一家,含 Volcano Ark AK/SK 签名与 MiMo 控制台 Cookie 查询) · Plan/API 双轨计费(订阅额度与按量金额分离统计,每 1% 额度与满窗的 token/等值金额估算及日/周/月曲线) · 输入框上方额度横条(预算/Go/Coding Plan 用量一条横排显示,可开关)
|
|
10
10
|
|
|
11
|
-
[](https://github.com/Han-1413141/dsh-cost-meter)
|
|
12
12
|
|
|
13
|
-
**v1.7.
|
|
13
|
+
**v1.7.36**:修复 CDN 返回压缩数据却缺失 `Content-Encoding` 时 CommandCode 额度解析失败;请求默认协商明文响应,保留调用方显式指定的编码。详见[更新说明](docs/release-notes/v1.7.36.md)。
|
|
14
14
|
|
|
15
15
|
[](https://www.npmjs.com/package/dsh-cost-meter)
|
|
16
16
|
[](LICENSE)
|
|
@@ -316,22 +316,22 @@ Node.js 20 请改用 `npm install -g pnpm@10`。版本要求见 [pnpm 官方安
|
|
|
316
316
|
dsh plugin --profile web add dsh-cost-meter
|
|
317
317
|
```
|
|
318
318
|
|
|
319
|
-
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.7.
|
|
319
|
+
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.7.36`**,建议先下载审阅再运行):
|
|
320
320
|
|
|
321
321
|
```powershell
|
|
322
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.
|
|
322
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.36/install.ps1 | iex
|
|
323
323
|
```
|
|
324
324
|
|
|
325
325
|
**或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
|
|
326
326
|
|
|
327
327
|
```sh
|
|
328
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.
|
|
328
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.36
|
|
329
329
|
```
|
|
330
330
|
|
|
331
331
|
没有 git 时可用 GitHub tag 打包直链:
|
|
332
332
|
|
|
333
333
|
```sh
|
|
334
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.
|
|
334
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.36.tar.gz
|
|
335
335
|
```
|
|
336
336
|
|
|
337
337
|
安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
|
package/lib/net.js
CHANGED
|
@@ -48,13 +48,29 @@ const sleep = (ms, signal) => new Promise((resolve, reject) => {
|
|
|
48
48
|
* 每次尝试用 timeoutMs 新建超时信号——重试若复用已中止的 AbortSignal.timeout
|
|
49
49
|
* 会立即再抛 AbortError,重试形同虚设。
|
|
50
50
|
* @param {string} url - 请求地址。
|
|
51
|
-
* @param {RequestInit} [init] - fetch init(headers/method/body 等)
|
|
51
|
+
* @param {RequestInit} [init] - fetch init(headers/method/body 等);未显式指定
|
|
52
|
+
* accept-encoding 时默认注入 identity(见函数首注释)。
|
|
52
53
|
* @param {{ attempts?: number, backoffMs?: number, timeoutMs?: number }} [options]
|
|
53
54
|
* - attempts:总尝试次数(含首次),默认 4。
|
|
54
55
|
* - backoffMs:退避基数,默认 300(实际等待 backoffMs * 2^(尝试序-2))。
|
|
55
56
|
* - timeoutMs:单次尝试超时;>0 时覆盖 init.signal,默认 0(沿用调用方信号)。
|
|
56
57
|
*/
|
|
57
58
|
export async function fetchWithRetry(url, init = {}, { attempts = 4, backoffMs = 300, timeoutMs = 0, fetchImpl = fetch } = {}) {
|
|
59
|
+
// 部分 CDN(实测 api.commandcode.ai:DSH 0.1.7 宿主的全局 undici 8 dispatcher
|
|
60
|
+
// 默认在请求头里协商 br)会返回压缩响应体却丢失 Content-Encoding 响应头——
|
|
61
|
+
// 违反 HTTP 语义,fetch 因此不做自动解压,response.json() 对着压缩字节直接报
|
|
62
|
+
// 「额度响应无法读取为有效 JSON」。brotli 流没有可靠魔数,事后嗅探无法稳健
|
|
63
|
+
// 补救(与 #172/#173 的裸 gzip 场景同族但更难防);这些接口的响应都很小,压缩
|
|
64
|
+
// 本无收益,故调用方未显式指定时统一默认 accept-encoding: identity 关闭
|
|
65
|
+
// 内容协商,从请求侧根除,显式指定的值不被覆盖。仅对纯对象形态的 headers
|
|
66
|
+
// 注入(本仓库所有调用方均如此)且不改其形状,Headers 实例等其余形态原样透传。
|
|
67
|
+
const headers = init.headers
|
|
68
|
+
if (headers === undefined || headers === null) {
|
|
69
|
+
init = { ...init, headers: { 'accept-encoding': 'identity' } }
|
|
70
|
+
} else if (typeof headers === 'object' && typeof headers.entries !== 'function'
|
|
71
|
+
&& !Object.keys(headers).some(name => name.toLowerCase() === 'accept-encoding')) {
|
|
72
|
+
init = { ...init, headers: { ...headers, 'accept-encoding': 'identity' } }
|
|
73
|
+
}
|
|
58
74
|
const request = typeof fetchImpl === 'function' ? fetchImpl : fetch
|
|
59
75
|
for (let attempt = 1; ; attempt++) {
|
|
60
76
|
init.signal?.throwIfAborted()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cost-meter",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.36",
|
|
4
4
|
"description": "DeepSeek Harness 会话费用统计插件:本会话成本、当日费用、历史记录与官方价格同步,支持多厂商多模型价格计费(内置 90+ 模型价格目录与自动匹配)、主流 Coding Plan 订阅额度查询与显示(11 家,含小米 MiMo Token Plan 控制台 Cookie 查询、SCNet Token Plan 本地 Credits 计量与火山方舟 Volcano Ark Coding Plan AK/SK 签名查询)、自定义 Provider 余额查询(可配任意 HTTP 端点)与余额进度条、峰谷计价时段显示与切换前弹窗/系统通知提醒(位置/提前量/类型可配),界面中英双语。Session cost tracking plugin for DeepSeek Harness: per-conversation cost, daily totals, history and official price sync, with multi-vendor model pricing (built-in 90+ model catalog with auto-matching), Coding Plan quota queries & display for 11 vendors (incl. Xiaomi MiMo Token Plan via console cookie, local credits metering for the SCNet Token Plan and Volcano Ark Coding Plan via AK/SK signature), plan/API dual-track billing with per-1% & full-window Token Plan usage estimates, custom provider balance lookup (configurable HTTP endpoint) and balance progress bar, plus peak/off-peak pricing display with pre-switch popup & system-notification alerts (position / lead time / type configurable), in a bilingual (Chinese/English) UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|