@kenz1117/dsh-ui-usage-billing 1.4.0 → 1.4.1

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 CHANGED
@@ -112,7 +112,7 @@ The billing channel is detected from the current session's model: DeepSeek meter
112
112
 
113
113
  Check your host generation first (`dsh --version`), then pick the matching install command — **a mismatched line is rejected by the DSH Store via the `engines.dsh` declaration** (declared since v1.0.41). Note that `dsh plugin add` requires an explicit `--profile` (otherwise it fails with `required option '--profile <name>' not specified`), and prefer **pinning an exact version** over `@latest` (pnpm's `minimumReleaseAge` cooldown skips freshly published versions and may fall back to the other line):
114
114
 
115
- - **DSH 0.1.2 ~ 0.1.5 era** (0.1.2-alpha.1 and later; npm `latest` currently at 0.1.5-rc.1; `npm ls -g @deepseek-ai/dsh` shows 0.1.2-* ~ 0.1.5-*):
115
+ - **DSH 0.1.2 ~ 0.1.6 era** (0.1.2-alpha.1 and later; npm `latest` currently at 0.1.6-alpha.1; `npm ls -g @deepseek-ai/dsh` shows 0.1.2-* ~ 0.1.6-*):
116
116
 
117
117
  ```sh
118
118
  dsh plugin --profile web add npm:@kenz1117/dsh-ui-usage-billing@latest
@@ -202,7 +202,7 @@ The public HTTP endpoints and field definitions are documented in source: `GET /
202
202
  | Field | Default | Description |
203
203
  | ----------------------- | --------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
204
204
  | `statsPath` | unset | Absolute path to a fallback `.dsh-usage-stats.json` (used when `sessionPersistence` is unavailable) |
205
- | `ledgerPath` | `~/.dsh/.dsh-usage-ledger.json` | Independent durable ledger path; stores folded metrics only (no message bodies or session titles), so deletion does not erase recorded usage |
205
+ | `ledgerPath` | `<harness home>/.dsh-usage-ledger.json` | Independent durable ledger path; stores folded metrics only (no message bodies or session titles), so deletion does not erase recorded usage. The default root follows the host harness home (`DSH_HOME` env first, falling back to `~/.dsh`), so isolated environments never share ledger data (issue #52) |
206
206
  | `balanceApiKeyEnv` | `DEEPSEEK_API_KEY` | Credential ref for the DeepSeek balance query; only used as a fallback when llm-pi-ai has no `apiKeyEnv` for deepseek |
207
207
  | `subscriptionProviders` | 11 built-ins (incl. `tencent-token-plan`) | Subscription (coding / token plan) provider id list — tokens counted, cost 0; aligned with the subscription-card recognition |
208
208
  | `routeAliases` | not set | Historical route aliases (old provider route name -> current route): renamed/deleted routes relocate into their channel instead of the "unknown" bucket. Example: `{ "deepseek-official": "tencent" }` |
@@ -211,7 +211,7 @@ The public HTTP endpoints and field definitions are documented in source: `GET /
211
211
  | `lowBalanceThreshold` | `50` | Low-balance alert threshold (CNY); sent with usage-stats, alerts once a day when any provider's CNY balance is below it |
212
212
  | `subscriptionPlans` | auto-detect | Subscription quota adapter whitelist (`{ provider, baseUrl?, region? }`); when unset, auto-detects all subscription providers from `llm-pi-ai` (queries those with a quota API, marks the rest) |
213
213
  | `declaredEndpoints` | unset | Declared endpoints (`{ displayName, origin, path, fields?, windows?, raw? }`): self-declare balance/quota interfaces for providers absent from the built-in table, writing only dot-paths ("where the number is") with no expressions; the request URL is built from the matched same-origin provider's `origin` and safety bounds (single-slash absolute path, GET only, reject cross-origin redirects, response-size/timeout caps, credentials only from the matched provider's own `apiKeyEnv`) are enforced by `src/declarative.ts` |
214
- | `reconcilePath` | `~/.dsh/.dsh-usage-reconcile.json` | Balance-delta reconcile baseline path; cross-checks the official (DeepSeek-direct only) balance change against the local ledger's official-channel cost for the day, and flags a drift above the threshold (0.3 CNY and >15%); top-ups / grants / currency changes reset the baseline instead of alerting |
214
+ | `reconcilePath` | `<harness home>/.dsh-usage-reconcile.json` | Balance-delta reconcile baseline path (default root also follows `DSH_HOME` / `~/.dsh`); cross-checks the official (DeepSeek-direct only) balance change against the local ledger's official-channel cost for the day, and flags a drift above the threshold (0.3 CNY and >15%); top-ups / grants / currency changes reset the baseline instead of alerting |
215
215
 
216
216
  ## 🛠 Development
217
217
 
@@ -237,7 +237,7 @@ The host discovers the browser side automatically via the `dsh.client` declarati
237
237
 
238
238
  - **Permission level: high**: reads durable session logs (files), calls official multi-vendor / subscription / balance / pricing APIs (network), reads `apiKeyEnv` via the credentials seam (credentials), writes the ledger under `~/.dsh` (persistent state); **no** command execution / shell.
239
239
  - **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.
240
- - **Compatibility**: the preview line (npm `latest`/`alpha`, 1.2.x — kept above the stable line to kill the version inversion) targets DSH `0.1.2` ~ `0.1.5` (host `latest` currently at 0.1.5-rc.1, verified on real hardware); the stable line (npm `stable`, 1.1.x, **frozen**, final v1.1.17) targets legacy hosts `0.1.0-rc.8` ~ `0.1.1-rc.2`. Per-version declarations live in `package.json` under `dsh.compatibility`; the two-line mapping and monitoring mechanism are documented in [COMPATIBILITY.md](COMPATIBILITY.md). Node.js `^22.19.0 || >=24.0.0`.
240
+ - **Compatibility**: the preview line (npm `latest`/`alpha`, 1.2.x — kept above the stable line to kill the version inversion) targets DSH `0.1.2` ~ `0.1.6` (host `latest` currently at 0.1.5-rc.1, verified on real hardware; 0.1.6-alpha.1 declared compatible — zero code changes in the plugin's dependency packages); the stable line (npm `stable`, 1.1.x, **frozen**, final v1.1.17) targets legacy hosts `0.1.0-rc.8` ~ `0.1.1-rc.2`. Per-version declarations live in `package.json` under `dsh.compatibility`; the two-line mapping and monitoring mechanism are documented in [COMPATIBILITY.md](COMPATIBILITY.md). Node.js `^22.19.0 || >=24.0.0`.
241
241
  - **Lifecycle**: no `preinstall` / `install` / `postinstall` / `prepare` (ready on install).
242
242
  - **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/*`.
243
243
  - **Build artifacts**: runtime files `lib/*` and `cordis.patch.yml` are committed at the pinned commit and declared in `files`.
package/README.md CHANGED
@@ -112,7 +112,7 @@ DeepSeek / Kimi / 智谱 GLM / 腾讯云 TokenHub 等 7 家官方余额、Coding
112
112
 
113
113
  先确认宿主代际(`dsh --version`),再按代际选安装命令——**装错线会在市场侧被 `engines.dsh` 声明拦截**(v1.0.41 起声明生效)。注意 `dsh plugin add` 需要显式 `--profile`(缺省会报 `required option '--profile <name>' not specified`),且建议**钉具体版本号**而非 `@latest`(pnpm 的 `minimumReleaseAge` 冷静期会让刚发布的版本被跳过、回退到旧线):
114
114
 
115
- - **DSH 0.1.2 ~ 0.1.5 系**(0.1.2-alpha.1 起,现行 latest 为 0.1.5-rc.1;`npm ls -g @deepseek-ai/dsh` 显示 0.1.2-* ~ 0.1.5-*):
115
+ - **DSH 0.1.2 ~ 0.1.6 系**(0.1.2-alpha.1 起,现行 latest 为 0.1.6-alpha.1;`npm ls -g @deepseek-ai/dsh` 显示 0.1.2-* ~ 0.1.6-*):
116
116
 
117
117
  ```sh
118
118
  dsh plugin --profile web add npm:@kenz1117/dsh-ui-usage-billing@latest
@@ -214,7 +214,7 @@ cost(CNY)= (missInput × p_input + cacheHit × p_cacheHit + output × p_outp
214
214
  | 字段 | 默认 | 说明 |
215
215
  | ----------------------- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------ |
216
216
  | `statsPath` | 未设置 | 回退统计文件 `.dsh-usage-stats.json` 的绝对路径(`sessionPersistence` 不可用时生效) |
217
- | `ledgerPath` | `~/.dsh/.dsh-usage-ledger.json` | 独立持久用量账本的绝对路径;只保存折叠后的统计(不保存消息正文或会话标题),永久删除会话不会删除已记录的费用与 token |
217
+ | `ledgerPath` | `<harness home>/.dsh-usage-ledger.json` | 独立持久用量账本的绝对路径;只保存折叠后的统计(不保存消息正文或会话标题),永久删除会话不会删除已记录的费用与 token。**默认根跟随宿主 harness home**(`DSH_HOME` 环境变量优先,回退 `~/.dsh`),自定义 `DSH_HOME` 的多套隔离环境互不污染(issue #52) |
218
218
  | `balanceApiKeyEnv` | `DEEPSEEK_API_KEY` | DeepSeek 余额查询的凭据引用;仅在 llm-pi-ai 未配置 deepseek 的 `apiKeyEnv` 时兜底使用 |
219
219
  | `subscriptionProviders` | 内置 11 项(含 `tencent-token-plan`) | 订阅制(coding / token 套餐)provider id 列表,照常统计 token、费用记 0;与订阅卡识别口径对齐 |
220
220
  | `routeAliases` | 未设置 | 历史路由别名(旧 provider 路由名 → 当前路由名):改名/删除过的路由,其历史用量原落「未知路由」桶且订阅/官方判定失效;配置后按目标路由归位。例:`{ "deepseek-official": "tencent", "tencent-cloud": "tencent" }` |
@@ -223,7 +223,7 @@ cost(CNY)= (missInput × p_input + cacheHit × p_cacheHit + output × p_outp
223
223
  | `lowBalanceThreshold` | `50` | 余额不足告警阈值(人民币元);随 usage-stats 下发,任一厂商余额折算人民币低于此值时每天提醒一次 |
224
224
  | `subscriptionPlans` | 自动识别 | 订阅额度适配器白名单(`{ provider, baseUrl?, region? }`);缺省时自动从 `llm-pi-ai` 设置识别所有订阅类 provider(有额度 API 的查额度,无 API 的仅标识) |
225
225
  | `declaredEndpoints` | 未设置 | 声明端点(`{ displayName, origin, path, fields?, windows?, raw? }`):为内置表没有的供应商自声明余额/额度接口,只写「数字在哪里」的点路径、无表达式;请求由匹配到同源 provider 的 origin 构造,安全边界(单斜杠绝对路径、仅 GET、拒绝跨源重定向、响应体/超时上限、凭据只取匹配 provider 自有的 apiKeyEnv)由 `src/declarative.ts` 强制执行 |
226
- | `reconcilePath` | `~/.dsh/.dsh-usage-reconcile.json` | 余额差对账基准的绝对路径;用官方(仅 DeepSeek 官方方向)余额当日变动与本地账本当日的官方渠道费用做交叉校验,偏差超阈值(0.3 元且 >15%)时提示核对;充值/授信/币种变化重置基准而非告警 |
226
+ | `reconcilePath` | `<harness home>/.dsh-usage-reconcile.json` | 余额差对账基准的绝对路径(默认根同样跟随 `DSH_HOME` / `~/.dsh`);用官方(仅 DeepSeek 官方方向)余额当日变动与本地账本当日的官方渠道费用做交叉校验,偏差超阈值(0.3 元且 >15%)时提示核对;充值/授信/币种变化重置基准而非告警 |
227
227
  | `searchCallEstimateCny` | `0.02` | 联网搜索请求(`web/deepseek-search-llm-request`,日志无用量事件)的单次费用估算(人民币元);设 0 关闭估算(调用仍计数、不计费) |
228
228
 
229
229
  ## 🛠 开发
@@ -248,9 +248,9 @@ npm publish --access public
248
248
 
249
249
  ## 🔐 权限与兼容声明(DSH STORE)
250
250
 
251
- - **权限等级:high**:读取持久会话日志(文件)、访问多厂商官方 / 订阅 / 余额 / 定价 API(网络)、经凭据 seam 读取 `apiKeyEnv`(凭据)、写入 `~/.dsh` 账本(持久状态);**不含**命令执行 / Shell。
251
+ - **权限等级:high**:读取持久会话日志(文件)、访问多厂商官方 / 订阅 / 余额 / 定价 API(网络)、经凭据 seam 读取 `apiKeyEnv`(凭据)、写入 harness home(`DSH_HOME` / `~/.dsh`)下的账本与快照(持久状态);**不含**命令执行 / Shell。
252
252
  - **更新通道:`user-reviewed`**:本插件具备文件 / 网络 / 凭据能力,DSH STORE 采用每次安装需本机人工确认的通道;安装前请复核仓库、固定 Commit、生命周期脚本与影响范围。
253
- - **兼容范围**:预览线(npm `latest`/`alpha`,1.2.x,自 v1.2.0 起恒高于稳定线以消除版本号倒挂)适配 DSH `0.1.2` ~ `0.1.5` 系(宿主 `latest` 现指向 0.1.5-rc.1,已真机验证);稳定线(npm `stable`,1.1.x,**已冻结**,终版 v1.1.17)适配旧宿主 `0.1.0-rc.8` ~ `0.1.1-rc.2`。逐版本声明见 `package.json` 的 `dsh.compatibility`,双线对照与监控机制见 [COMPATIBILITY.md](COMPATIBILITY.md)。Node.js `^22.19.0 || >=24.0.0`。
253
+ - **兼容范围**:预览线(npm `latest`/`alpha`,1.2.x,自 v1.2.0 起恒高于稳定线以消除版本号倒挂)适配 DSH `0.1.2` ~ `0.1.6` 系(宿主 `latest` 现指向 0.1.5-rc.1,已真机验证;0.1.6-alpha.1 已声明兼容,插件依赖包零代码变更);稳定线(npm `stable`,1.1.x,**已冻结**,终版 v1.1.17)适配旧宿主 `0.1.0-rc.8` ~ `0.1.1-rc.2`。逐版本声明见 `package.json` 的 `dsh.compatibility`,双线对照与监控机制见 [COMPATIBILITY.md](COMPATIBILITY.md)。Node.js `^22.19.0 || >=24.0.0`。
254
254
  - **生命周期**:无 `preinstall` / `install` / `postinstall` / `prepare`(安装即用)。
255
255
  - **不冒用官方**:仅新增自有 entry id `ui-usage-billing`;对 `@deepseek-ai/dsh-*` 仅为 `peerDependencies` 依赖(不重复安装 / 不替换 / 不遮蔽官方组件),包名使用第三方命名空间 `@kenz1117/*`。
256
256
  - **打包产物**:运行文件 `lib/*` 与 `cordis.patch.yml` 已随固定 Commit 提交并声明在 `files`。