dsh-cost-meter 1.8.23 → 1.8.25
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 +7 -7
- package/README.zh-CN.md +6 -6
- package/docs/factory-quota.md +33 -0
- package/docs/qwen-cli-quota.md +9 -5
- package/lib/client.js +5 -5
- package/lib/coding-plans.js +9 -1
- package/lib/factory-quota.js +69 -0
- package/lib/index.js +11 -0
- package/lib/plan-billing.js +6 -1
- package/lib/qwen-cli.js +43 -5
- package/lib/store.js +15 -0
- package/lib/typert.host.js +4 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
**Session cost tracking plugin for the DeepSeek Harness web GUI (bilingual UI)**
|
|
8
8
|
|
|
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 170+ model-ID 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)
|
|
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 170+ model-ID catalog with auto-matching) · mainstream Coding Plan quota queries & display (Anthropic / Z.ai / MiniMax / Kimi / OpenRouter / SiliconFlow / CommandCode / SCNet / Volcano Ark / Qwen / Xiaomi MiMo / Factory Droid) 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.8.
|
|
13
|
+
**v1.8.25** adds Factory (Droid) subscription quota windows: 5-hour, weekly and monthly, with separate Standard/Core pools, optional organization ID, secure credential storage and the existing quota strip. See the [Factory guide](docs/factory-quota.md#english).
|
|
14
14
|
|
|
15
15
|
Desktop users: follow the [Desktop installation instructions](docs/install-troubleshooting.md#desktop-安装与更新) for the application's own CLI and `desktop` Profile.
|
|
16
16
|
|
|
@@ -323,22 +323,22 @@ On Node.js 20, use `npm install -g pnpm@10` instead. See [pnpm installation and
|
|
|
323
323
|
dsh plugin --profile web add dsh-cost-meter
|
|
324
324
|
```
|
|
325
325
|
|
|
326
|
-
**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.8.
|
|
326
|
+
**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.8.25`** — review the script before running):
|
|
327
327
|
|
|
328
328
|
```powershell
|
|
329
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.8.
|
|
329
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.8.25/install.ps1 | iex
|
|
330
330
|
```
|
|
331
331
|
|
|
332
332
|
**Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
|
|
333
333
|
|
|
334
334
|
```sh
|
|
335
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.8.
|
|
335
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.8.25
|
|
336
336
|
```
|
|
337
337
|
|
|
338
338
|
Without git, use the GitHub tag archive:
|
|
339
339
|
|
|
340
340
|
```sh
|
|
341
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.8.
|
|
341
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.8.25.tar.gz
|
|
342
342
|
```
|
|
343
343
|
|
|
344
344
|
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 为峰时段;周末与中国法定假日全天按谷价,分别标注) · 峰/谷切换前弹窗与系统通知提醒(位置/提前量/提醒类型可配) · 官方价格一键同步 · 类 Codex Token 用量热图 · 多厂商多模型价格计费(内置 170+ 模型 ID 价格目录与自动匹配) · 主流 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.8.
|
|
13
|
+
**v1.8.25** 新增 Factory(Droid)订阅额度:5 小时、每周、每月,支持 Standard/Core 分开显示、可选组织 ID、DSH 凭据库及现有额度横条。详见 [Factory 使用说明](docs/factory-quota.md)。
|
|
14
14
|
|
|
15
15
|
桌面端用户请按 [Desktop 安装说明](docs/install-troubleshooting.md#desktop-安装与更新),使用应用自带的 CLI 和 `desktop` Profile。
|
|
16
16
|
|
|
@@ -323,22 +323,22 @@ Node.js 20 请改用 `npm install -g pnpm@10`。版本要求见 [pnpm 官方安
|
|
|
323
323
|
dsh plugin --profile web add dsh-cost-meter
|
|
324
324
|
```
|
|
325
325
|
|
|
326
|
-
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.8.
|
|
326
|
+
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.8.25`**,建议先下载审阅再运行):
|
|
327
327
|
|
|
328
328
|
```powershell
|
|
329
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.8.
|
|
329
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.8.25/install.ps1 | iex
|
|
330
330
|
```
|
|
331
331
|
|
|
332
332
|
**或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
|
|
333
333
|
|
|
334
334
|
```sh
|
|
335
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.8.
|
|
335
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.8.25
|
|
336
336
|
```
|
|
337
337
|
|
|
338
338
|
没有 git 时可用 GitHub tag 打包直链:
|
|
339
339
|
|
|
340
340
|
```sh
|
|
341
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.8.
|
|
341
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.8.25.tar.gz
|
|
342
342
|
```
|
|
343
343
|
|
|
344
344
|
安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Factory(Droid)订阅额度
|
|
2
|
+
|
|
3
|
+
在「设置 → 费用 → 额度」启用 **Factory (Droid)**。展开卡片后可设置额度类型、组织 ID、显示位置和刷新间隔。
|
|
4
|
+
|
|
5
|
+
- **Standard**:默认显示 5 小时、每周、每月三个已用百分比及重置时间。
|
|
6
|
+
- **Droid Core**:显示独立 Core 额度,同样包含三个窗口。
|
|
7
|
+
- **Standard + Core**:分别显示两套额度。输入框上方横条分为两个标签,各含三个窗口;点击任一标签刷新该账号额度。
|
|
8
|
+
|
|
9
|
+
## 凭据与组织
|
|
10
|
+
|
|
11
|
+
点击卡片中的「编辑凭据」,填写有权读取该账号额度的 Factory Bearer 凭据,保存到 DSH 凭据库的 `FACTORY_API_KEY`。也可由 DSH 进程读取同名环境变量。无须另加自定义 ref;凭据库命名与 `dsh-factory-provider` 的默认 `keyEnv` 一致。
|
|
12
|
+
|
|
13
|
+
`dsh-factory-provider` 自己账号库中选中的 key 不会自动复制到 DSH 凭据库。使用其账号时,需在本卡片存入对应凭据;组织 ID 可从该账号信息填写,未填写时不发送组织请求头。凭据失效或无权读取额度时显示认证提示,推理凭据是否可查额度由 Factory 接口决定。
|
|
14
|
+
|
|
15
|
+
凭据只写入 DSH 凭据库,既不回显也不保存到费用账本。关闭来源或将显示位置改为「关闭」即停止查询;组织、额度类型或凭据变化会清空旧缓存并取消旧请求。
|
|
16
|
+
|
|
17
|
+
## 查询与显示
|
|
18
|
+
|
|
19
|
+
只读 `GET https://api.factory.ai/api/billing/limits`,使用 `Authorization: Bearer …`、`x-client-version: 0.231.0`、`x-factory-client: cli` 和可选 `x-factory-org-id`。固定官方域名,拒绝重定向;15 秒单次请求超时,沿用网络重试和有界 JSON 读取。自动查询按卡片设置的 1–1440 分钟间隔缓存,默认 15 分钟;手动刷新立即查询。
|
|
20
|
+
|
|
21
|
+
`usedPercent` 已是 0–100 百分比,不乘以 100。优先使用 `windowEnd`,缺少有效绝对时间时使用 `secondsRemaining`;无重置字段时仍显示用量。缺失/无效窗口省略,不补造 0%;选择 Standard 时不偷偷回退到 Core。
|
|
22
|
+
|
|
23
|
+
账户百分比与 DSH 的调用记录分别统计。Factory 的 `factory-a`、`factory-g`、`factory-o` 归为同一套餐提供商;启用后可按既有 Plan/API 设置分类。由于本地记录无法逐次归属到 Standard/Core 池及其滚动周期,Factory 不生成每 1%/满窗 Token 与费用估算。
|
|
24
|
+
|
|
25
|
+
来源:[Factory 个人计划](https://docs.factory.ai/pricing/individuals)、[核验的提供商查询源码](https://github.com/Dalizi2026/dsh-factory-provider/blob/801c3a2be1927e804ad9e0e493c52e9aa13421df/lib/quota.js)。回归使用响应夹具与模拟网络,验证 DSH 服务、双端 codec、缓存、取消、落盘与真实 Chromium 界面;未使用真实付费账号验证。
|
|
26
|
+
|
|
27
|
+
## English
|
|
28
|
+
|
|
29
|
+
Enable **Factory (Droid)** under Settings → Cost → Quotas. Choose Standard (default), Droid Core, or both. Each pool has independent 5-hour, weekly and monthly windows. The sidebar shows all selected windows; the composer quota strip uses separate Standard/Core chips with three windows each. Either chip refreshes the Factory source.
|
|
30
|
+
|
|
31
|
+
Save a Factory Bearer credential with access to billing limits through the card's credential editor. It uses DSH's `FACTORY_API_KEY` credential ref or the same host environment variable. Keys selected in the provider plugin's private account store are not copied automatically. An optional organization ID scopes the request. Credentials are never echoed or stored in the ledger.
|
|
32
|
+
|
|
33
|
+
The adapter sends only a fixed read-only GET to the official billing-limits endpoint, rejects redirects, bounds response size and request time, and reuses the configured refresh cache. Disabling the source stops queries; credential, organization or pool changes cancel old work. Percentages are already on a 0–100 scale; reset time prefers `windowEnd`, then `secondsRemaining`. Missing windows remain absent. Account quota data does not become recorded DSH usage or a per-1% cost estimate without pool attribution. Tests use synthetic account data and network mocks plus real Chromium; no live paid account was queried.
|
package/docs/qwen-cli-quota.md
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
npm install -g @qianwenai/qianwen-cli
|
|
11
11
|
qianwen auth login
|
|
12
12
|
qianwen usage summary --format json
|
|
13
|
+
qianwen subscription status --format json
|
|
13
14
|
```
|
|
14
15
|
|
|
15
16
|
安装后重启 DSH,使宿主读取新的 `PATH`。远程 DSH、容器或服务账号需要在对应环境安装和登录;只在本地浏览器所在机器登录不生效。插件使用 CLI 自己保存的登录态,不要求复制模型 API Key、Cookie 或管理令牌。
|
|
@@ -18,10 +19,11 @@ qianwen usage summary --format json
|
|
|
18
19
|
|
|
19
20
|
## 显示口径
|
|
20
21
|
|
|
21
|
-
-
|
|
22
|
+
- 优先读取 `usage summary --format json` 中的 `token_plan`:总 Credits、剩余 Credits、已用比例,以及可选加量包剩余量。已用量由总量减剩余量计算,小数 Credits 保留,标记 `(CLI)`。
|
|
23
|
+
- 若汇总命令成功但未提供有效额度(包括 `subscribed: false`),补查 `subscription status --format json`,只读取 `individual.status: active` 下明确返回的 `monthlyCredits`/`weeklyCredits`。`usedPct` 已是百分比,保留小数;`resetTime` 是该额度窗口的重置时间。总 Credits 单独显示,CLI 未提供的绝对已用/剩余额度不自行推算。原查询有效时不增加命令;认证失败、超时及无效 JSON 不触发补查。
|
|
22
24
|
- CLI 的 `resetDate` 在核验版本中来自订阅实例 `EndTime`,因此显示为「CLI 订阅到期」,不作为月度重置倒计时或采样边界。
|
|
23
|
-
- 官方快照包含该账号在其他工具中的用量;插件不会把这些总量写进 DSH 账本。CLI
|
|
24
|
-
- 未登录、超时、异常 JSON 或无有效订阅额度时显示提示并清空本次额度。CLI 会把部分上游失败转换为 `subscribed: false
|
|
25
|
+
- 官方快照包含该账号在其他工具中的用量;插件不会把这些总量写进 DSH 账本。CLI 未提供用于采样的完整额度周期边界,因此此模式不生成千问「每 1% / 满窗 Token」估算。
|
|
26
|
+
- 未登录、超时、异常 JSON 或无有效订阅额度时显示提示并清空本次额度。CLI 会把部分上游失败转换为 `subscribed: false`,补查也无有效额度时,插件仍不能据此断言账号没有订阅。可检查终端输出后刷新,或手动切回本地估算;不会自动用本地数值冒充官方数值。
|
|
25
27
|
- 本地估算的月度额度、起始日和抵扣率保留,切回后继续使用。`usage summary` 未提供可用主订阅额度、只有加量包时,当前显示无有效订阅额度提示。
|
|
26
28
|
|
|
27
29
|
## 执行与验证
|
|
@@ -65,9 +67,9 @@ Expand **Settings → Cost → Quota → Qwen Token Plan**, enable it and select
|
|
|
65
67
|
|
|
66
68
|
Install `@qianwenai/qianwen-cli` on the DSH host, run `qianwen auth login` as the same OS user, then verify `qianwen usage summary --format json`. Restart DSH after installation so it receives the updated PATH. Browser-side login alone does not configure a remote host or container.
|
|
67
69
|
|
|
68
|
-
The card reads the current `token_plan` credits, computes used credits from total minus remaining, preserves fractional credits, and labels the result `(CLI)`. Optional add-on credits appear separately. The verified CLI maps `resetDate` from subscription `EndTime`; it is shown as subscription expiry, never a monthly reset. No account-wide totals are imported into the ledger, and this mode does not produce Qwen per-1% / full-window token estimates without a reliable billing period.
|
|
70
|
+
The card first reads the current `token_plan` credits, computes used credits from total minus remaining, preserves fractional credits, and labels the result `(CLI)`. Optional add-on credits appear separately. The verified CLI maps `resetDate` from subscription `EndTime`; it is shown as subscription expiry, never a monthly reset. No account-wide totals are imported into the ledger, and this mode does not produce Qwen per-1% / full-window token estimates without a reliable billing period.
|
|
69
71
|
|
|
70
|
-
Refreshes share one child process and use the configured 1–1440 minute cache (15 by default), including failed attempts. Manual refresh retries immediately. Disabling the source or switching to local estimates cancels pending work. Errors clear the quota and provide a setup/retry hint.
|
|
72
|
+
Refreshes share one child process and use the configured 1–1440 minute cache (15 by default), including failed attempts. Manual refresh retries immediately. Disabling the source or switching to local estimates cancels pending work. Errors clear the quota and provide a setup/retry hint. When summary succeeds without valid quota, the plugin reads `subscription status --format json` and accepts only active individual monthly/weekly windows. `usedPct` is already a percentage; fractional values and the explicit window reset time are preserved. Total Credits are displayed separately; missing used/remaining Credits are not inferred. Valid summaries avoid the second command, and command failures, invalid JSON and timeouts do not trigger it. An unavailable fallback still does not prove that the account is unsubscribed. Add-on-only results without a usable main subscription also show this hint. Select local estimates explicitly when needed; saved local settings remain available.
|
|
71
73
|
|
|
72
74
|
Execution uses fixed arguments without a shell, an absolute PATH entry, closed stdin, a hidden window, a 15-second timeout and 1 MiB limits for stdout/stderr. Windows npm installations run their Node entry directly. Credentials remain in the CLI's store; raw child output is never returned to the browser or saved in the ledger.
|
|
73
75
|
|
|
@@ -90,3 +92,5 @@ Tests use synthetic output, real child processes and bilingual component callbac
|
|
|
90
92
|
Bailian source verification (2026-09-23): [Token Plan output](https://github.com/modelstudioai/cli/blob/72bc8fcce7f5ede6a5df81c1ce72d86de3f3ccd5/packages/commands/src/commands/usage/token-plan.ts), [Coding Plan output](https://github.com/modelstudioai/cli/blob/72bc8fcce7f5ede6a5df81c1ce72d86de3f3ccd5/packages/commands/src/commands/usage/coding-plan.ts), [ratio formatting](https://github.com/modelstudioai/cli/blob/72bc8fcce7f5ede6a5df81c1ce72d86de3f3ccd5/packages/commands/src/commands/usage/quota-box.ts). Tested with source-shaped fixtures and real local child processes; no live paid subscription was queried.
|
|
91
93
|
|
|
92
94
|
Login source verification (2026-10-05): [auth status](https://github.com/modelstudioai/cli/blob/8bbbbc722d70fb200641ef22b6f6d033aeae9f74/packages/commands/src/commands/auth/status.ts), [console login](https://github.com/modelstudioai/cli/blob/8bbbbc722d70fb200641ef22b6f6d033aeae9f74/packages/commands/src/commands/auth/login-console.ts), [exit codes](https://github.com/modelstudioai/cli/blob/8bbbbc722d70fb200641ef22b6f6d033aeae9f74/packages/core/src/errors/codes.ts).
|
|
95
|
+
|
|
96
|
+
#260 源码核验:[个人订阅额度映射](https://github.com/QianWen-AI/qianwen-cli/blob/054b874c985021ab4424dcf2d7e01c28aa99ad23/src/services/tokenplan-service.ts)、[订阅 JSON 输出](https://github.com/QianWen-AI/qianwen-cli/blob/054b874c985021ab4424dcf2d7e01c28aa99ad23/src/view-models/subscription/shared.ts)。新增回归覆盖 issue 中的 `0.00169%`、月/周窗口、到期与格式错误、补查失败/超时/脱敏及缓存并发;未查询真实付费订阅账号。
|