dsh-cost-meter 1.5.36 → 1.5.37
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 +5 -5
- package/README.md +5 -5
- package/lib/coding-plans.js +17 -7
- package/package.json +1 -1
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) · 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) · 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)
|
|
@@ -228,22 +228,22 @@ Real captures from an actual DSH sidebar of the period strip and collapsed verti
|
|
|
228
228
|
dsh plugin --profile web add dsh-cost-meter
|
|
229
229
|
```
|
|
230
230
|
|
|
231
|
-
**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.5.
|
|
231
|
+
**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.5.37`** — review the script before running):
|
|
232
232
|
|
|
233
233
|
```powershell
|
|
234
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.5.
|
|
234
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.5.37/install.ps1 | iex
|
|
235
235
|
```
|
|
236
236
|
|
|
237
237
|
**Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
|
|
238
238
|
|
|
239
239
|
```sh
|
|
240
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.5.
|
|
240
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.5.37
|
|
241
241
|
```
|
|
242
242
|
|
|
243
243
|
Without git, use the GitHub tag archive:
|
|
244
244
|
|
|
245
245
|
```sh
|
|
246
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.5.
|
|
246
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.5.37.tar.gz
|
|
247
247
|
```
|
|
248
248
|
|
|
249
249
|
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 为峰时段) · 峰/谷切换前弹窗与系统通知提醒(位置/提前量/提醒类型可配) · 官方价格一键同步 · 类 Codex Token 用量热图 · 多厂商多模型价格计费(内置 90+ 模型价格目录与自动匹配) · 主流 Coding Plan 额度查询与显示(Anthropic / Z.ai / MiniMax / Kimi / OpenRouter / SiliconFlow / CommandCode / SCNet 八家) · 输入框上方额度横条(预算/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)
|
|
@@ -230,22 +230,22 @@
|
|
|
230
230
|
dsh plugin --profile web add dsh-cost-meter
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
-
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.5.
|
|
233
|
+
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.5.37`**,建议先下载审阅再运行):
|
|
234
234
|
|
|
235
235
|
```powershell
|
|
236
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.5.
|
|
236
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.5.37/install.ps1 | iex
|
|
237
237
|
```
|
|
238
238
|
|
|
239
239
|
**或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
|
|
240
240
|
|
|
241
241
|
```sh
|
|
242
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.5.
|
|
242
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.5.37
|
|
243
243
|
```
|
|
244
244
|
|
|
245
245
|
没有 git 时可用 GitHub tag 打包直链:
|
|
246
246
|
|
|
247
247
|
```sh
|
|
248
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.5.
|
|
248
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.5.37.tar.gz
|
|
249
249
|
```
|
|
250
250
|
|
|
251
251
|
安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
|
package/lib/coding-plans.js
CHANGED
|
@@ -126,10 +126,12 @@ export function parseAnthropicUsage(data) {
|
|
|
126
126
|
/**
|
|
127
127
|
* 解析 Z.ai / 智谱 GLM Coding Plan 用量响应。
|
|
128
128
|
* 兼容三种已见形态(按优先级):
|
|
129
|
-
* - { data: { limits: [{ type
|
|
130
|
-
*
|
|
131
|
-
* /api/monitor/usage/quota/limit,issue #42;TOKENS_LIMIT 为 token
|
|
132
|
-
* 为
|
|
129
|
+
* - { data: { limits: [{ type, unit, number, percentage, nextResetTime, usage,
|
|
130
|
+
* currentValue, ... }], level } }(2026-08 起的监控端点
|
|
131
|
+
* /api/monitor/usage/quota/limit,issue #42;TOKENS_LIMIT 为 token 窗口(Pro/Max),
|
|
132
|
+
* CREDIT_LIMIT 为 Credit 计费窗口(Lite,percentage/currentValue 语义与
|
|
133
|
+
* TOKENS_LIMIT 一致,issue #44),两者均按 unit 3=小时档、6=周档映射;
|
|
134
|
+
* TIME_LIMIT 为 MCP/工具调用月度额度、量纲不同不纳入;unit 缺失时按
|
|
133
135
|
* nextResetTime 排序兜底——0% 用量的滚动窗口不返回重置时间,排最前)
|
|
134
136
|
* - { plans: [{ status, total_units, used_units, available_units, period_end, capabilities }] }
|
|
135
137
|
* (旧计费端点;period_end 语义按数值大小推断:重置跨度 >1 天视为周档,否则为 5 小时档)
|
|
@@ -147,7 +149,9 @@ export function parseZaiUsage(data) {
|
|
|
147
149
|
const monWindows = {}
|
|
148
150
|
const rest = []
|
|
149
151
|
for (const limit of limits) {
|
|
150
|
-
|
|
152
|
+
// TOKENS_LIMIT(Pro/Max token 窗口)与 CREDIT_LIMIT(Lite Credit 窗口,issue #44)
|
|
153
|
+
// 的 percentage/currentValue/usage 与 unit 语义完全一致,一并接受。
|
|
154
|
+
if (limit === null || typeof limit !== 'object' || (limit.type !== 'TOKENS_LIMIT' && limit.type !== 'CREDIT_LIMIT')) continue
|
|
151
155
|
// percentage 已是 0-100 百分数;缺失时用 currentValue/usage 反推。
|
|
152
156
|
const pct = limit.percentage !== undefined ? clampPct(Number(limit.percentage))
|
|
153
157
|
: Number.isFinite(Number(limit.usage)) && Number(limit.usage) > 0 && Number.isFinite(Number(limit.currentValue))
|
|
@@ -610,6 +614,10 @@ export async function queryCodingPlan(provider, key, locale, t) {
|
|
|
610
614
|
const urls = CODING_PLAN_ENDPOINTS[provider]
|
|
611
615
|
const parse = CODING_PLAN_PARSERS[provider]
|
|
612
616
|
let lastError = null
|
|
617
|
+
// 200 但解析失败的「结构化错误」(业务信封 / 结构已变):比后续端点的 404 等传输层
|
|
618
|
+
// 错误更有诊断价值,单独保留且最终优先抛出——否则最后端点的 404 会盖住 monitor
|
|
619
|
+
// 端点解析失败的真实原因(issue #44 的误导性报错即由此而来)。
|
|
620
|
+
let parseError = null
|
|
613
621
|
for (const url of urls) {
|
|
614
622
|
let response
|
|
615
623
|
try {
|
|
@@ -643,14 +651,16 @@ export async function queryCodingPlan(provider, key, locale, t) {
|
|
|
643
651
|
// 200 但业务失败(如 Z.ai 的错误信封 {code:1001,msg:...}):透出服务端 msg,避免误报「接口结构已变」。
|
|
644
652
|
const envelope = data !== null && typeof data === 'object' && typeof data.code === 'number' && data.code !== 0
|
|
645
653
|
&& typeof (data.msg ?? data.message) === 'string' ? (data.msg ?? data.message) : null
|
|
646
|
-
|
|
654
|
+
const error = envelope !== null
|
|
647
655
|
? new Error(`${meta.label}: ${envelope}`)
|
|
648
656
|
: new Error(t(locale, 'codingPlanNoUsage', { provider: meta.label }))
|
|
657
|
+
parseError ??= error
|
|
658
|
+
lastError = error
|
|
649
659
|
continue
|
|
650
660
|
}
|
|
651
661
|
return { windows, endpoint: url }
|
|
652
662
|
}
|
|
653
|
-
throw lastError ?? new Error(t(locale, 'codingPlanNoUsage', { provider: meta.label }))
|
|
663
|
+
throw parseError ?? lastError ?? new Error(t(locale, 'codingPlanNoUsage', { provider: meta.label }))
|
|
654
664
|
}
|
|
655
665
|
|
|
656
666
|
export { CUSTOM_BALANCE_ADAPTER_ID, emptyCustomBalance, extractByRule, queryCustomBalance } from './custom-balance.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cost-meter",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.37",
|
|
4
4
|
"description": "DeepSeek Harness 会话费用统计插件:本会话成本、当日费用、历史记录与官方价格同步,支持多厂商多模型价格计费(内置 90+ 模型价格目录与自动匹配)、主流 Coding Plan 订阅额度查询与显示(7 家,含 SCNet Token Plan 本地 Credits 计量)、自定义 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 7 vendors (incl. local credits metering for the SCNet Token Plan), 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",
|