@kenz1117/dsh-ui-usage-billing 1.8.8 → 1.8.9
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 +7 -6
- package/README.md +7 -6
- package/lib/client.js +2 -2
- package/lib/index.js +46 -33
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/client/usage-command.d.ts +10 -5
- package/package.json +63 -60
package/README.en.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<a href="https://github.com/kenz1117/dsh-ui-usage-billing/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/kenz1117/dsh-ui-usage-billing/actions/workflows/ci.yml/badge.svg"></a>
|
|
8
8
|
<a href="https://www.npmjs.com/package/@kenz1117/dsh-ui-usage-billing"><img alt="npm version" src="https://img.shields.io/npm/v/@kenz1117/dsh-ui-usage-billing?logo=npm"></a>
|
|
9
9
|
<a href="https://www.npmjs.com/package/@kenz1117/dsh-ui-usage-billing"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@kenz1117/dsh-ui-usage-billing?logo=npm"></a>
|
|
10
|
-
<a href="https://github.com/kenz1117/dsh-ui-usage-billing/blob/main/COMPATIBILITY.md"><img alt="DSH compat" src="https://img.shields.io/badge/DSH-0.1.2_%7E_0.2.
|
|
10
|
+
<a href="https://github.com/kenz1117/dsh-ui-usage-billing/blob/main/COMPATIBILITY.md"><img alt="DSH compat" src="https://img.shields.io/badge/DSH-0.1.2_%7E_0.2.2--rc.5-blue"></a>
|
|
11
11
|
<a href="https://github.com/kenz1117/dsh-ui-usage-billing/blob/main/LICENSE"><img alt="License MIT" src="https://img.shields.io/github/license/kenz1117/dsh-ui-usage-billing"></a>
|
|
12
12
|
</p>
|
|
13
13
|
|
|
@@ -63,6 +63,7 @@ Most billing plugins stop at "token count × unit price". dsh-ui-usage-billing t
|
|
|
63
63
|
|
|
64
64
|
- **Trigger card**: today / week / month headline, 7-day trend and daily gauge; choose a full card, compact icon or hidden entry, with a quick look on hover.
|
|
65
65
|
- **Cost bar and alerts**: live turn / Session cost, model-aware peak and quota warnings, plus optional system notifications for tier switches and Session completion.
|
|
66
|
+
- **Shortcut**: bind "Open usage billing dashboard" in the host's Settings → Shortcuts — `⌘⇧U` by default (`Ctrl+Shift+U` on Windows / Linux), rebindable or clearable — so the dashboard stays one keystroke away even with the sidebar entry hidden.
|
|
66
67
|
|
|
67
68
|

|
|
68
69
|
|
|
@@ -118,12 +119,12 @@ Overview / Queue / Billing / Usage / Trends / Agents / Rates / Settings. The her
|
|
|
118
119
|
|
|
119
120
|
## 🚀 Quick start
|
|
120
121
|
|
|
121
|
-
One codebase currently supports DSH `0.1.2-alpha.1` through `0.2.2-rc.
|
|
122
|
+
One codebase currently supports DSH `0.1.2-alpha.1` through `0.2.2-rc.5`. Stable and preview releases share the same compatibility matrix: stable releases use npm `latest`, while previews use `alpha`. npm `latest` currently points to the stable `1.8.9` release (ledger rows whose session logs were deleted are merged by catalog key and repriced from the catalog, issue #127; channel visibility; cache-write priced by each vendor's own rate; the `⌘⇧U` dashboard shortcut; the `/usage` command registration-timing fix; an extra keyless FX source; host `0.2.2-rc.4` / `0.2.2-rc.5` compatibility); `alpha` points to `1.8.3-alpha.13` (its content is now a subset of the stable release), and the next preview starts at `1.8.3-alpha.14`.
|
|
122
123
|
|
|
123
124
|
`dsh plugin add` requires an explicit `--profile`. Pinning an exact version is recommended so a package manager's release cooldown cannot resolve a different version. Install the current stable release with:
|
|
124
125
|
|
|
125
126
|
```sh
|
|
126
|
-
dsh plugin --profile web add npm:@kenz1117/dsh-ui-usage-billing@1.8.
|
|
127
|
+
dsh plugin --profile web add npm:@kenz1117/dsh-ui-usage-billing@1.8.9
|
|
127
128
|
```
|
|
128
129
|
|
|
129
130
|
Default installations can also use `@latest`. Check the host with `dsh --version` or `npm ls -g @deepseek-ai/dsh`.
|
|
@@ -175,7 +176,7 @@ Browser Server (Node)
|
|
|
175
176
|
|
|
176
177
|
## 💡 Billing details
|
|
177
178
|
|
|
178
|
-
The rate table (`src/client/pricing.ts`) stores each model in its **native currency**: domestic providers enter CNY directly, overseas providers enter USD. Cost is computed and displayed in CNY uniformly — USD models convert via the **live rate**, domestic models never pass through a rate. At startup the server fetches the live rate and model prices (`src/pricing-fetch.ts`): USD→CNY prefers the Tencent Finance quote (keyless, reachable in China), falling back to open.er-api then the built-in default; it then refreshes every 6 hours, and the rate-table modal shows a "today's rate" marker plus live / built-in badge. The **display currency follows the user**: switching ¥ / $ converts each per-1M-token unit price via `convertUnitPrice` at the live rate (falling back to the native currency when the rate is unavailable).
|
|
179
|
+
The rate table (`src/client/pricing.ts`) stores each model in its **native currency**: domestic providers enter CNY directly, overseas providers enter USD. Cost is computed and displayed in CNY uniformly — USD models convert via the **live rate**, domestic models never pass through a rate. At startup the server fetches the live rate and model prices (`src/pricing-fetch.ts`): USD→CNY prefers the Tencent Finance quote (keyless, reachable in China), falling back to open.er-api, then the keyless AllRatesToday endpoint (ECB reference rates, [Exchange rates by AllRatesToday](https://allratestoday.com)), then the built-in default; it then refreshes every 6 hours, and the rate-table modal shows a "today's rate" marker plus live / built-in badge. The **display currency follows the user**: switching ¥ / $ converts each per-1M-token unit price via `convertUnitPrice` at the live rate (falling back to the native currency when the rate is unavailable).
|
|
179
180
|
|
|
180
181
|
```
|
|
181
182
|
cost (CNY) = (missInput × p_input + cacheHit × p_cacheHit + output × p_output) / 10⁶
|
|
@@ -261,7 +262,7 @@ For on-machine debugging: `dsh plugin --profile web add "link:<absolute path to
|
|
|
261
262
|
|
|
262
263
|
## 📦 Release
|
|
263
264
|
|
|
264
|
-
This standalone npm package maintains one `main` codebase. Stable releases use non-prerelease versions and npm `latest`; previews use prerelease versions and npm `alpha`. npm `latest` currently points to the stable `1.8.
|
|
265
|
+
This standalone npm package maintains one `main` codebase. Stable releases use non-prerelease versions and npm `latest`; previews use prerelease versions and npm `alpha`. npm `latest` currently points to the stable `1.8.9` release, while `alpha` points to `1.8.3-alpha.13`; see [COMPATIBILITY.md](COMPATIBILITY.md).
|
|
265
266
|
|
|
266
267
|
```sh
|
|
267
268
|
pnpm test && pnpm run build # full tests + build before release
|
|
@@ -276,7 +277,7 @@ The host discovers the browser side automatically via the `dsh.client` declarati
|
|
|
276
277
|
|
|
277
278
|
- **Permission level: high**: reads durable Session logs, calls vendor / subscription / balance / pricing APIs, reads `apiKeyEnv` through the credentials seam, and writes the ledger, snapshots and task queue under the harness home. The plugin itself has **no** command-execution / shell capability; only explicit enqueueing creates a host Session and submits a Prompt, while Agent tools remain governed by the host's existing permissions and approvals.
|
|
278
279
|
- **Update channel: `user-reviewed`**: with file / network / credential capabilities, DSH STORE requires local manual confirmation on every install; review the repo, pinned commit, lifecycle scripts, and impact scope before installing.
|
|
279
|
-
- **Compatibility**: stable and preview releases from the current `main` share one matrix covering DSH `0.1.2-alpha.1` through `0.2.2-rc.
|
|
280
|
+
- **Compatibility**: stable and preview releases from the current `main` share one matrix covering DSH `0.1.2-alpha.1` through `0.2.2-rc.5`, with 38 per-version declarations. The current stable release is `1.8.9` (npm `latest`; ledger rows whose session logs were deleted are merged by catalog key and repriced from the catalog, issue #127; channel visibility; cache-write priced by each vendor's own rate; the dashboard shortcut; the `/usage` registration fix; an extra keyless FX source; host `0.2.2-rc.4` / `0.2.2-rc.5` compatibility); the preview channel is `1.8.3-alpha.13` (npm `alpha`; its content is now a subset of the stable release). Release channels and monitoring are documented in [COMPATIBILITY.md](COMPATIBILITY.md). Node.js `^22.19.0 || >=24.0.0`.
|
|
280
281
|
- **Lifecycle**: no `preinstall` / `install` / `postinstall` / `prepare` (ready on install).
|
|
281
282
|
- **No impersonation**: adds only its own entry id `ui-usage-billing`; `@deepseek-ai/dsh-*` packages are `peerDependencies` only (no reinstall / replace / shadowing of official components); the package uses the third-party namespace `@kenz1117/*`.
|
|
282
283
|
- **Build artifacts**: runtime files `lib/*` and `cordis.patch.yml` are committed at the pinned commit and declared in `files`.
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<a href="https://github.com/kenz1117/dsh-ui-usage-billing/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/kenz1117/dsh-ui-usage-billing/actions/workflows/ci.yml/badge.svg"></a>
|
|
8
8
|
<a href="https://www.npmjs.com/package/@kenz1117/dsh-ui-usage-billing"><img alt="npm version" src="https://img.shields.io/npm/v/@kenz1117/dsh-ui-usage-billing?logo=npm"></a>
|
|
9
9
|
<a href="https://www.npmjs.com/package/@kenz1117/dsh-ui-usage-billing"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@kenz1117/dsh-ui-usage-billing?logo=npm"></a>
|
|
10
|
-
<a href="https://github.com/kenz1117/dsh-ui-usage-billing/blob/main/COMPATIBILITY.md"><img alt="DSH 兼容" src="https://img.shields.io/badge/DSH-0.1.2_%7E_0.2.
|
|
10
|
+
<a href="https://github.com/kenz1117/dsh-ui-usage-billing/blob/main/COMPATIBILITY.md"><img alt="DSH 兼容" src="https://img.shields.io/badge/DSH-0.1.2_%7E_0.2.2--rc.5-blue"></a>
|
|
11
11
|
<a href="https://github.com/kenz1117/dsh-ui-usage-billing/blob/main/LICENSE"><img alt="License MIT" src="https://img.shields.io/github/license/kenz1117/dsh-ui-usage-billing"></a>
|
|
12
12
|
</p>
|
|
13
13
|
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
|
|
64
64
|
- **触发卡**:今日 / 本周 / 本月主数字、近 7 天趋势与当日水位;支持完整卡片、紧凑图标、完全隐藏,悬停可看速览。
|
|
65
65
|
- **费用条与提醒**:常驻本轮 / 会话费用,按当前模型显示峰谷和订阅额度预警;切档与会话完成可发系统通知。
|
|
66
|
+
- **快捷键**:宿主「设置 → 快捷键」可绑定「打开用量计费仪表盘」,默认 `⌘⇧U`(Windows / Linux `Ctrl+Shift+U`),可改绑或清空;侧栏隐藏后也能一键打开面板。
|
|
66
67
|
|
|
67
68
|

|
|
68
69
|
|
|
@@ -118,12 +119,12 @@
|
|
|
118
119
|
|
|
119
120
|
## 🚀 快速开始
|
|
120
121
|
|
|
121
|
-
当前维护 DSH `0.1.2-alpha.1` ~ `0.2.2-rc.
|
|
122
|
+
当前维护 DSH `0.1.2-alpha.1` ~ `0.2.2-rc.5` 的一份代码。正式版与预览版共享同一兼容矩阵:正式版使用 npm `latest`,预览版使用 `alpha`。当前 `latest` 指向 `1.8.9` 正式版(日志已删的存量账本行按目录键归一并按目录价补价 + 通道可见性 + 缓存写入按厂商费率独立计价 + 仪表盘快捷键 `⌘⇧U` 与 `/usage` 命令注册时机修正 + 汇率兜底源 + 宿主 0.2.2-rc.4 / rc.5 兼容声明);`alpha` 指向 `1.8.3-alpha.13`(其内容已是正式版的子集),下一轮预览从 `1.8.3-alpha.14` 起。
|
|
122
123
|
|
|
123
124
|
`dsh plugin add` 需要显式 `--profile`,且建议钉具体版本号,避免包管理器的发布冷静期解析到其他版本。当前正式版安装命令:
|
|
124
125
|
|
|
125
126
|
```sh
|
|
126
|
-
dsh plugin --profile web add npm:@kenz1117/dsh-ui-usage-billing@1.8.
|
|
127
|
+
dsh plugin --profile web add npm:@kenz1117/dsh-ui-usage-billing@1.8.9
|
|
127
128
|
```
|
|
128
129
|
|
|
129
130
|
默认安装也可使用 `@latest`。可用 `dsh --version` 或 `npm ls -g @deepseek-ai/dsh` 确认宿主版本。
|
|
@@ -179,7 +180,7 @@ GitHub Pages 发布。
|
|
|
179
180
|
|
|
180
181
|
## 💡 计费细节
|
|
181
182
|
|
|
182
|
-
单价表(`src/client/pricing.ts`)采用**原生币种**存储:国内厂商直接录入人民币价格,国外厂商录入美元价格。费用统一以人民币计算与展示——美元模型按**实时汇率**折算,国内模型全程不经过汇率换算。启动时服务端拉取实时汇率与模型价(`src/pricing-fetch.ts`):USD→CNY 优先腾讯财经行情(免 key、国内可达),失败依次降级 open.er-api
|
|
183
|
+
单价表(`src/client/pricing.ts`)采用**原生币种**存储:国内厂商直接录入人民币价格,国外厂商录入美元价格。费用统一以人民币计算与展示——美元模型按**实时汇率**折算,国内模型全程不经过汇率换算。启动时服务端拉取实时汇率与模型价(`src/pricing-fetch.ts`):USD→CNY 优先腾讯财经行情(免 key、国内可达),失败依次降级 open.er-api、AllRatesToday 免 key 端点(ECB 参考汇率,[Exchange rates by AllRatesToday](https://allratestoday.com))与内置默认值;之后每 6 小时后台刷新,单价表弹窗标注「今日汇率」与实时 / 内置徽标。金额与费率表的**展示币种跟随用户所选**:切 ¥ / $ 时把每条每百万 token 单价经 `convertUnitPrice` 按实时汇率换算到目标币种再显示(汇率缺失时回退原生币种)。
|
|
183
184
|
|
|
184
185
|
```
|
|
185
186
|
cost(CNY)= (missInput × p_input + cacheWrite × p_cacheWrite + cacheHit × p_cacheHit + output × p_output) / 10⁶
|
|
@@ -281,7 +282,7 @@ pnpm run build # tsc -b && tsdown,产出 lib/index.js 与 lib/client.js
|
|
|
281
282
|
|
|
282
283
|
## 📦 发布
|
|
283
284
|
|
|
284
|
-
本包为独立 npm 包,只维护一份 `main` 代码。正式版使用非预发布版本号并切 `latest`,预览版使用预发布版本号并切 `alpha`;当前 `latest` 指向 `1.8.
|
|
285
|
+
本包为独立 npm 包,只维护一份 `main` 代码。正式版使用非预发布版本号并切 `latest`,预览版使用预发布版本号并切 `alpha`;当前 `latest` 指向 `1.8.9` 正式版,`alpha` 指向 `1.8.3-alpha.13`,详见 [COMPATIBILITY.md](COMPATIBILITY.md)。
|
|
285
286
|
|
|
286
287
|
```sh
|
|
287
288
|
pnpm test && pnpm run build # 发版前全量测试 + 构建
|
|
@@ -296,7 +297,7 @@ npm dist-tag add @kenz1117/dsh-ui-usage-billing@<版本> latest # 正式版
|
|
|
296
297
|
|
|
297
298
|
- **权限等级:high**:读取持久会话日志(文件)、访问多厂商官方 / 订阅 / 余额 / 定价 API(网络)、经凭据 seam 读取 `apiKeyEnv`(凭据)、写入 harness home 下的账本、快照与任务队列(持久状态)。插件自身**不含**命令执行 / Shell;仅用户显式入队时才经宿主创建会话并提交 Prompt,Agent 的工具调用仍由宿主原有权限与审批控制。
|
|
298
299
|
- **更新通道:`user-reviewed`**:本插件具备文件 / 网络 / 凭据能力,DSH STORE 采用每次安装需本机人工确认的通道;安装前请复核仓库、固定 Commit、生命周期脚本与影响范围。
|
|
299
|
-
- **兼容范围**:当前 `main` 的正式版与预览版共享同一兼容矩阵,适配 DSH `0.1.2-alpha.1` ~ `0.2.2-rc.
|
|
300
|
+
- **兼容范围**:当前 `main` 的正式版与预览版共享同一兼容矩阵,适配 DSH `0.1.2-alpha.1` ~ `0.2.2-rc.5`,共 38 项逐版本声明。当前正式版为 `1.8.9`(npm `latest`,日志已删的存量账本行按目录键归一并按目录价补价 + 通道可见性 + 缓存写入按厂商费率独立计价 + 仪表盘快捷键与 `/usage` 注册修正 + 汇率兜底源 + 宿主 0.2.2-rc.4 / rc.5 兼容声明),预览通道为 `1.8.3-alpha.13`(npm `alpha`,内容已是正式版的子集)。发行通道与监控机制见 [COMPATIBILITY.md](COMPATIBILITY.md)。Node.js `^22.19.0 || >=24.0.0`。
|
|
300
301
|
- **生命周期**:无 `preinstall` / `install` / `postinstall` / `prepare`(安装即用)。
|
|
301
302
|
- **不冒用官方**:仅新增自有 entry id `ui-usage-billing`;对 `@deepseek-ai/dsh-*` 仅为 `peerDependencies` 依赖(不重复安装 / 不替换 / 不遮蔽官方组件),包名使用第三方命名空间 `@kenz1117/*`。
|
|
302
303
|
- **打包产物**:运行文件 `lib/*` 与 `cordis.patch.yml` 已随固定 Commit 提交并声明在 `files`。
|