dsh-cost-meter 1.6.2 → 1.6.4
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 +22 -6
- package/README.md +22 -6
- package/lib/backfill.js +6 -1
- package/lib/client.js +3 -6324
- package/lib/coding-plans.js +13 -7
- package/lib/index.js +27 -2
- package/lib/pricing.js +31 -0
- package/lib/store.js +123 -0
- package/lib/typert.host.js +7 -0
- package/package.json +11 -5
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
|
-
[](https://github.com/Han-1413141/dsh-cost-meter)
|
|
10
10
|
[](https://www.npmjs.com/package/dsh-cost-meter)
|
|
11
11
|
[](LICENSE)
|
|
12
12
|
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
@@ -231,22 +231,22 @@ Real captures from an actual DSH sidebar of the period strip and collapsed verti
|
|
|
231
231
|
dsh plugin --profile web add dsh-cost-meter
|
|
232
232
|
```
|
|
233
233
|
|
|
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.6.
|
|
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.6.4`** — review the script before running):
|
|
235
235
|
|
|
236
236
|
```powershell
|
|
237
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.6.
|
|
237
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.6.4/install.ps1 | iex
|
|
238
238
|
```
|
|
239
239
|
|
|
240
240
|
**Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
|
|
241
241
|
|
|
242
242
|
```sh
|
|
243
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.6.
|
|
243
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.6.4
|
|
244
244
|
```
|
|
245
245
|
|
|
246
246
|
Without git, use the GitHub tag archive:
|
|
247
247
|
|
|
248
248
|
```sh
|
|
249
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.6.
|
|
249
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.6.4.tar.gz
|
|
250
250
|
```
|
|
251
251
|
|
|
252
252
|
After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
|
|
@@ -255,6 +255,22 @@ After installing, **restart** `dsh web` (plugin rows, the Typert manifest and th
|
|
|
255
255
|
dsh web
|
|
256
256
|
```
|
|
257
257
|
|
|
258
|
+
### Install troubleshooting: ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION
|
|
259
|
+
|
|
260
|
+
Symptom: `dsh plugin --profile web add` fails with `[ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION] N lockfile entries failed verification`.
|
|
261
|
+
|
|
262
|
+
Cause: your environment (pnpm config or a policy bundled into the invoking installer) enforces the "minimum release age" supply-chain protection — any lockfile entry **published more recently than the threshold** is rejected. Plugin releases up to v1.6.3 declared floating ranges for their runtime dependencies, so a fresh install resolved them to whatever was newest at that moment (`^0.1.0-rc.6` was observed to float onto rc.8 published barely a week earlier), which such a policy refuses.
|
|
263
|
+
|
|
264
|
+
Fix:
|
|
265
|
+
|
|
266
|
+
1. **Upgrade to v1.6.4+**: all three runtime dependencies (`@deepseek-ai/dsh-credentials`, `@deepseek-ai/dsh-home-paths`, `zod`) are now exact-pinned — a pinned version's publish date never changes, so it satisfies any age threshold and this plugin can no longer trigger the error;
|
|
267
|
+
2. If the error is triggered by **another plugin's** dependencies instead, append an exclusion for the offending `name@version` printed in the error to the profile's `pnpm-workspace.yaml` (default `$DSH_HOME/profiles/web/pnpm-workspace.yaml`) and retry:
|
|
268
|
+
|
|
269
|
+
```yaml
|
|
270
|
+
minimumReleaseAgeExclude:
|
|
271
|
+
- '<name@version from the error>'
|
|
272
|
+
```
|
|
273
|
+
|
|
258
274
|
### Update / Uninstall
|
|
259
275
|
|
|
260
276
|
```sh
|
|
@@ -284,7 +300,7 @@ dsh plugin --profile web add link:./dsh-cost-meter # symlink; edit lib/client.j
|
|
|
284
300
|
- Billing sources are the `usage` block of every model call (including sub-agents, compression, title generation and other auxiliary calls), matching the billable view;
|
|
285
301
|
- Budget and over-budget warnings **only warn — they never block calls**.
|
|
286
302
|
- **Plan/API dual-track billing** (issue #64): calls on subscription-style channels (MiniMax, manually-marked Codex, etc.) are recorded as catalog-price equivalents only; budget/today-cost/overview cards count the pay-as-you-go (API) channel exclusively.
|
|
287
|
-
- **Full-repo security audit fixes
|
|
303
|
+
- **Full-repo security audit fixes**: resolved 3 high-risk findings — ledger writes lost on exit (close/flush ordering), command injection in the release script, panel null-pointer crash on null Go monthly window — plus 30+ medium/low issues including missing hour-bucket entries for routed calls, dead balance-reconciliation warnings, failed custom-balance extraction silently showing $0, and leaked upstream streams on consumer abort; ledger corruption auto-backup, write-failure retry, config-patch atomicity and prototype-chain hardening included. Itemized list: [CHANGELOG.md](CHANGELOG.md).
|
|
288
304
|
- **"Include plan totals" toggle** under the overview cards switches every amount between real-money (API channels only, default) and total equivalent cost (plan subscriptions included); routed calls with a missing provider whose models match third-party catalogs are auto-classified into the matching plan, and legacy per-day residuals without model details count toward the API scope; The Token Plan stats panel in Settings → Usage provides per-1% and full-window token/equivalent-cost estimates plus daily/weekly/monthly usage curves; classification is configurable per vendor and per provider:model.
|
|
289
305
|
|
|
290
306
|
## Data storage
|
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
|
-
[](https://github.com/Han-1413141/dsh-cost-meter)
|
|
10
10
|
[](https://www.npmjs.com/package/dsh-cost-meter)
|
|
11
11
|
[](LICENSE)
|
|
12
12
|
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
@@ -233,22 +233,22 @@
|
|
|
233
233
|
dsh plugin --profile web add dsh-cost-meter
|
|
234
234
|
```
|
|
235
235
|
|
|
236
|
-
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.6.
|
|
236
|
+
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.6.4`**,建议先下载审阅再运行):
|
|
237
237
|
|
|
238
238
|
```powershell
|
|
239
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.6.
|
|
239
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.6.4/install.ps1 | iex
|
|
240
240
|
```
|
|
241
241
|
|
|
242
242
|
**或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
|
|
243
243
|
|
|
244
244
|
```sh
|
|
245
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.6.
|
|
245
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.6.4
|
|
246
246
|
```
|
|
247
247
|
|
|
248
248
|
没有 git 时可用 GitHub tag 打包直链:
|
|
249
249
|
|
|
250
250
|
```sh
|
|
251
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.6.
|
|
251
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.6.4.tar.gz
|
|
252
252
|
```
|
|
253
253
|
|
|
254
254
|
安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
|
|
@@ -257,6 +257,22 @@ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archi
|
|
|
257
257
|
dsh web
|
|
258
258
|
```
|
|
259
259
|
|
|
260
|
+
### 安装排障:ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION
|
|
261
|
+
|
|
262
|
+
症状:`dsh plugin --profile web add` 阶段安装失败,pnpm 报 `[ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION] N lockfile entries failed verification`。
|
|
263
|
+
|
|
264
|
+
原因:你的环境(pnpm 配置或上层安装器自带策略)启用了「最小发布年龄」供应链保护——lockfile 中**发布时间距今小于阈值**的包一律拒绝。插件 v1.6.3 及更早版本的生产依赖是浮动区间,首次安装会解析到当时最新发布版(实测 `^0.1.0-rc.6` 漂到仅发布一周左右的 rc.8),在该策略下即被拒绝。
|
|
265
|
+
|
|
266
|
+
处理:
|
|
267
|
+
|
|
268
|
+
1. **升级到 v1.6.4+**:三个运行时依赖(`@deepseek-ai/dsh-credentials`、`@deepseek-ai/dsh-home-paths`、`zod`)已全部精确锁版——锁定版本的发布时间固定不变,对任意年龄阈值永远满足,本插件不再可能触发该错误;
|
|
269
|
+
2. 若报错由**其他插件**的依赖触发,可在 profile 目录的 `pnpm-workspace.yaml`(默认 `$DSH_HOME/profiles/web/pnpm-workspace.yaml`)按报错列出的条目追加排除后重试:
|
|
270
|
+
|
|
271
|
+
```yaml
|
|
272
|
+
minimumReleaseAgeExclude:
|
|
273
|
+
- '<报错中的包名>@<版本>'
|
|
274
|
+
```
|
|
275
|
+
|
|
260
276
|
### 更新 / 卸载
|
|
261
277
|
|
|
262
278
|
```sh
|
|
@@ -287,7 +303,7 @@ dsh plugin --profile web add link:./dsh-cost-meter # 符号链接,改 lib/clien
|
|
|
287
303
|
- 预算与超支提示**仅提醒,不阻止调用**。
|
|
288
304
|
- **Plan/API 双轨计费**(issue #64):订阅制渠道(MiniMax / Codex 手动标记等)的调用金额只记「等值」,预算/今日费用/概览卡片等金额展示仅统计按量计费(API)部分;
|
|
289
305
|
- **「含 Plan 总额」开关**:概览页汇总卡片下的快捷开关切换全部金额展示口径——关闭时仅计真金白银(API 渠道),开启后显示含 Plan 等值的总金额;网关路由(provider 缺失)调用的第三方目录模型自动归入对应订阅归类,无模型明细的历史残差计入 API 口径;设置 → 用量 的 Token Plan 统计面板提供每 1% 额度与满窗的 token/等值金额估算与日/周/月曲线;分类可在配置中按厂商或 provider:model 级覆盖。
|
|
290
|
-
-
|
|
306
|
+
- **全仓安全审计修复**:账本退出丢写(close/flush 次序)、发版脚本命令注入、面板空指针崩溃(Go 月窗空值)3 项高危,及路由调用小时桶漏记、官方余额对账告警失效、自定义余额提取失败误显 $0、计费流中断泄漏等 30 余项中低危问题全量修复;账本损坏自动备份、写失败重试、配置补丁原子性、原型链与凭据处理加固。逐项清单见 [CHANGELOG.md](CHANGELOG.md)。
|
|
291
307
|
|
|
292
308
|
## 数据存储
|
|
293
309
|
|
package/lib/backfill.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { readdirSync, readFileSync, statSync } from 'node:fs'
|
|
14
14
|
import { join } from 'node:path'
|
|
15
15
|
import * as zlib from 'node:zlib'
|
|
16
|
-
import { costOf, providerPriceEntryFor, usdFromCost } from './pricing.js'
|
|
16
|
+
import { costOf, providerPriceEntryFor, usdFromCost, isWrapperProviderId } from './pricing.js'
|
|
17
17
|
import { localDayKey, zeroDay, splitLedgerApiCost } from './store.js'
|
|
18
18
|
import { billingClassOf, enabledPlanSetOf } from './plan-billing.js'
|
|
19
19
|
|
|
@@ -266,6 +266,11 @@ export function replaySessionRecords(records, config, wantDates = null) {
|
|
|
266
266
|
if (!Number.isFinite(atMs) || atMs <= 0) continue
|
|
267
267
|
const date = localDayKey(atMs)
|
|
268
268
|
if (wantDates !== null && !wantDates.has(date)) continue
|
|
269
|
+
// modlens 视觉包装层(modlens-<upstream> / deepseek-modlens)把同一份 usage
|
|
270
|
+
// 经上游 llm.stream 再转发一次:日志里同一调用出现两套 header+usage 事件,
|
|
271
|
+
// 且因 provider 不同绕过 (turn, step) 键去重,回放会翻倍(issue #70)。与
|
|
272
|
+
// 实时钩子/投影一致,包装层 provider 状态下的 usage 事件跳过,只记上游真实流。
|
|
273
|
+
if (isWrapperProviderId(provider)) continue
|
|
269
274
|
const buckets = {
|
|
270
275
|
input: num(usage.inputTokens),
|
|
271
276
|
output: num(usage.outputTokens),
|