dsh-cost-meter 1.7.44 → 1.7.46
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 +14 -6
- package/README.zh-CN.md +14 -6
- package/cordis.patch.yml +2 -2
- package/lib/backfill.js +10 -2
- package/lib/client.js +5 -5
- package/lib/index.js +55 -25
- package/lib/store.js +1 -0
- package/lib/typert.host.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,9 +8,11 @@
|
|
|
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; 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 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.46** adds a dedicated Open Platform key for balance queries in DSH account-login mode. See the [release notes](docs/release-notes/v1.7.46.md).
|
|
14
|
+
|
|
15
|
+
Desktop users: follow the [Desktop installation instructions](docs/install-troubleshooting.md#desktop-安装与更新) for the application's own CLI and `desktop` Profile.
|
|
14
16
|
|
|
15
17
|
[](https://www.npmjs.com/package/dsh-cost-meter)
|
|
16
18
|
[](LICENSE)
|
|
@@ -317,22 +319,22 @@ On Node.js 20, use `npm install -g pnpm@10` instead. See [pnpm installation and
|
|
|
317
319
|
dsh plugin --profile web add dsh-cost-meter
|
|
318
320
|
```
|
|
319
321
|
|
|
320
|
-
**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.
|
|
322
|
+
**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.46`** — review the script before running):
|
|
321
323
|
|
|
322
324
|
```powershell
|
|
323
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.
|
|
325
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.46/install.ps1 | iex
|
|
324
326
|
```
|
|
325
327
|
|
|
326
328
|
**Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
|
|
327
329
|
|
|
328
330
|
```sh
|
|
329
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.
|
|
331
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.46
|
|
330
332
|
```
|
|
331
333
|
|
|
332
334
|
Without git, use the GitHub tag archive:
|
|
333
335
|
|
|
334
336
|
```sh
|
|
335
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.
|
|
337
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.46.tar.gz
|
|
336
338
|
```
|
|
337
339
|
|
|
338
340
|
After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
|
|
@@ -382,6 +384,10 @@ minimumReleaseAgeExclude:
|
|
|
382
384
|
|
|
383
385
|
DSH `0.2.0-rc.1` passes packed installation, Web startup, shared-module checks, synthetic billing, RPC and the full regression suite. Earlier host checks cover installation, startup, shared modules and removal on DSH `0.1.2-rc.1`, `0.1.3-alpha.2` and `0.1.5-alpha.1`. `0.1.3-alpha.1` remains unknown because its official npm version was unavailable during the earlier check. See the [compatibility record](docs/host-compatibility.md) for the environment and limits.
|
|
384
386
|
|
|
387
|
+
If Plugin Hub reports only `diagnostics: .../.plugin-manager/logs/operation-.../pnpm.log`, that line does not identify the failed package or command. Open the named `pnpm.log` and include the first actual error when reporting the failure; remove credentials and private paths before sharing it. Git URL and npm-name installation on DSH `0.2.0-rc.1` are covered by isolated Windows checks, but an individual machine's failure still requires its diagnostic log.
|
|
388
|
+
|
|
389
|
+
Balance HTTP 401 in account-login mode: configure a dedicated Open Platform API key under **Settings → Cost → Account balance**. See [credential priority and storage](docs/balance-credentials.md).
|
|
390
|
+
|
|
385
391
|
### Update / Uninstall
|
|
386
392
|
|
|
387
393
|
```sh
|
|
@@ -389,6 +395,8 @@ DSH `0.2.0-rc.1` passes packed installation, Web startup, shared-module checks,
|
|
|
389
395
|
dsh plugin --profile web remove dsh-cost-meter # uninstall
|
|
390
396
|
```
|
|
391
397
|
|
|
398
|
+
Installation errors and plugins still disabled after reinstall: see [troubleshooting](docs/install-troubleshooting.md).
|
|
399
|
+
|
|
392
400
|
### Local development
|
|
393
401
|
|
|
394
402
|
```sh
|
package/README.zh-CN.md
CHANGED
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
本会话费用 · 当日费用 · OpenCode Go 订阅额度显示 · 预算与已用百分比 · 官方账户余额 · 自定义 Provider 余额查询(可配任意 HTTP 端点) · 余额三段进度条 · 历史记录 · 峰谷计价时段显示(UTC 01:00–04:00、06:00–10:00 为峰时段;周末与中国法定假日全天按谷价,分别标注) · 峰/谷切换前弹窗与系统通知提醒(位置/提前量/提醒类型可配) · 官方价格一键同步 · 类 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.46**:新增余额专用开放平台 Key,解决账号登录模式下余额凭据被推理令牌覆盖的问题。详见[更新说明](docs/release-notes/v1.7.46.md)。
|
|
14
|
+
|
|
15
|
+
桌面端用户请按 [Desktop 安装说明](docs/install-troubleshooting.md#desktop-安装与更新),使用应用自带的 CLI 和 `desktop` Profile。
|
|
14
16
|
|
|
15
17
|
[](https://www.npmjs.com/package/dsh-cost-meter)
|
|
16
18
|
[](LICENSE)
|
|
@@ -317,22 +319,22 @@ Node.js 20 请改用 `npm install -g pnpm@10`。版本要求见 [pnpm 官方安
|
|
|
317
319
|
dsh plugin --profile web add dsh-cost-meter
|
|
318
320
|
```
|
|
319
321
|
|
|
320
|
-
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.7.
|
|
322
|
+
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.7.46`**,建议先下载审阅再运行):
|
|
321
323
|
|
|
322
324
|
```powershell
|
|
323
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.
|
|
325
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.7.46/install.ps1 | iex
|
|
324
326
|
```
|
|
325
327
|
|
|
326
328
|
**或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
|
|
327
329
|
|
|
328
330
|
```sh
|
|
329
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.
|
|
331
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.7.46
|
|
330
332
|
```
|
|
331
333
|
|
|
332
334
|
没有 git 时可用 GitHub tag 打包直链:
|
|
333
335
|
|
|
334
336
|
```sh
|
|
335
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.
|
|
337
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.7.46.tar.gz
|
|
336
338
|
```
|
|
337
339
|
|
|
338
340
|
安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
|
|
@@ -382,6 +384,10 @@ minimumReleaseAgeExclude:
|
|
|
382
384
|
|
|
383
385
|
DSH `0.2.0-rc.1` 已通过安装包安装、Web 启动、模块复用、合成计费、RPC 和完整回归。此前宿主适配验证覆盖 DSH `0.1.2-rc.1`、`0.1.3-alpha.2`、`0.1.5-alpha.1` 的安装、启动、模块复用和卸载;`0.1.3-alpha.1` 在此前核查中无可获取的官方 npm 版本,暂标记为未知。验证环境及边界见[兼容记录](docs/host-compatibility.md)。
|
|
384
386
|
|
|
387
|
+
如果插件市场仅显示 `diagnostics: .../.plugin-manager/logs/operation-.../pnpm.log`,这行信息无法指出失败的包或命令。请打开所指的 `pnpm.log`,反馈其中第一条实际错误;分享前删去凭据及私人路径。DSH `0.2.0-rc.1` 的 Git 地址和 npm 包名安装已在隔离 Windows 环境通过;特定机器上的失败仍需要该机器的诊断日志。
|
|
388
|
+
|
|
389
|
+
账号模式下余额返回 HTTP 401:请在「设置 → 费用 → 官方账户余额」保存独立的开放平台 API Key。凭据优先级和存储说明见[余额专用凭据](docs/balance-credentials.md)。
|
|
390
|
+
|
|
385
391
|
### 更新 / 卸载
|
|
386
392
|
|
|
387
393
|
```sh
|
|
@@ -389,6 +395,8 @@ DSH `0.2.0-rc.1` 已通过安装包安装、Web 启动、模块复用、合成
|
|
|
389
395
|
dsh plugin --profile web remove dsh-cost-meter # 卸载
|
|
390
396
|
```
|
|
391
397
|
|
|
398
|
+
安装报错或重装后仍被禁用,见[排障说明](docs/install-troubleshooting.md)。
|
|
399
|
+
|
|
392
400
|
### 开发者本地调试
|
|
393
401
|
|
|
394
402
|
```sh
|
package/cordis.patch.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# dsh-cost-meter bundle patch: one host row over the
|
|
1
|
+
# dsh-cost-meter bundle patch: one host row over the Web or Desktop profile.
|
|
2
2
|
# The row name resolves from the profile's own node_modules where
|
|
3
|
-
# `dsh plugin --profile
|
|
3
|
+
# `dsh plugin --profile <profile> add <path>` installed this package.
|
|
4
4
|
- insert:
|
|
5
5
|
- id: cost-meter
|
|
6
6
|
name: dsh-cost-meter
|
package/lib/backfill.js
CHANGED
|
@@ -352,10 +352,13 @@ export function replaySessionRecords(records, config, wantDates = null) {
|
|
|
352
352
|
if (event.type === 'assistant/chunk' && event.data?.chunk?.type === 'usage' && event.data.chunk.usage != null) u = event.data.chunk.usage
|
|
353
353
|
else if (event.type === 'assistant/message' && event.data?.usage != null) u = event.data.usage
|
|
354
354
|
else continue
|
|
355
|
-
|
|
355
|
+
const source = event.type === 'assistant/message' ? event.data?.message?.source : null
|
|
356
|
+
const sampleProvider = typeof source?.provider === 'string' && source.provider.length > 0 ? source.provider : preProvider
|
|
357
|
+
const sampleModel = typeof source?.model === 'string' && source.model.length > 0 ? source.model : preModel
|
|
358
|
+
if (isWrapperProviderId(sampleProvider)) continue
|
|
356
359
|
const at = Number(event.time)
|
|
357
360
|
if (!Number.isFinite(at) || at <= 0) continue
|
|
358
|
-
const fp = usageFingerprint(
|
|
361
|
+
const fp = usageFingerprint(sampleModel, {
|
|
359
362
|
input: num(u.inputTokens), output: num(u.outputTokens), cacheRead: num(u.cacheReadTokens),
|
|
360
363
|
cacheWrite: num(u.cacheWriteTokens), reasoning: num(u.reasoningTokens),
|
|
361
364
|
})
|
|
@@ -437,6 +440,11 @@ export function replaySessionRecords(records, config, wantDates = null) {
|
|
|
437
440
|
// 摘要样本的事件自带路由(header 状态不受影响,后续循环步仍按其 header 计费)。
|
|
438
441
|
let sampleProvider = provider
|
|
439
442
|
let sampleModel = model
|
|
443
|
+
if (event.type === 'assistant/message') {
|
|
444
|
+
const source = event.data?.message?.source
|
|
445
|
+
if (typeof source?.provider === 'string' && source.provider.length > 0) sampleProvider = source.provider
|
|
446
|
+
if (typeof source?.model === 'string' && source.model.length > 0) sampleModel = source.model
|
|
447
|
+
}
|
|
440
448
|
if (isCompaction || isNativeSearch) {
|
|
441
449
|
const source = event.data?.message?.source ?? {}
|
|
442
450
|
if (typeof source.provider === 'string' && source.provider.length > 0) sampleProvider = source.provider
|