@kenz1117/dsh-ui-usage-billing 0.9.16 → 0.9.18

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
@@ -44,6 +44,7 @@
44
44
 
45
45
  ![Providers: provider billing & subscriptions (balance, plan quota, model usage)](screenshots/3.png)
46
46
  - **Custom provider balance**: configure any HTTP endpoint for balance (`extract` supports constant / dot-path / add-subtract / divide, header `{{ENV}}` via the credentials seam); DeepSeek / Kimi / StepFun / SiliconFlow have built-in official balances, and the balance column estimates "≈N days" from the 7-day daily burn.
47
+ - **Declared endpoints + balance reconcile**: **declared endpoints** (`declaredEndpoints`) let you self-declare balance/quota interfaces for vendors absent from the built-in table — you write only dot-paths ("where the number is"), 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`; a wrong path is shown in the UI as `declared` with a `reason`. **Balance reconcile** (`reconcilePath`) 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%) so you can double-check the price table or recent bills; top-ups / grants / currency changes reset the baseline instead of alerting, and a flat balance (subscription spend) stays silent.
47
48
  - **Real usage aggregation**: the server aggregates from session logs on demand (incremental cache recomputes only written sessions), with per-session corruption tolerance and snapshot fallback; an optional `usage_stats` tool lets the model query today / month / current session / cumulative spend, plus `bySite` (relay-attributed) and `relay` (relay-only) summaries (**off by default** — toggle it in the Settings tab; takes effect after a reload).
48
49
  - **Multi-language + dual currency**: the ¥/$ switch is bilingual (USD→English, CNY→Chinese, this plugin only); the rate table converts to the selected currency.
49
50
  - **Model health + uncatalogued annotation**: provider connection dots (green / red / grey); a model id not in the catalog is marked "uncatalogued" priced at the fallback, with provider inferred (e.g. `mi-mimo-2.5` → Xiaomi); estimated-price models are marked "estimated".
@@ -152,6 +153,8 @@ The public HTTP endpoints and field definitions are documented in source: `GET /
152
153
  | `monthlyBudget` | unset | Default monthly budget (CNY); sent with usage-stats as the budget bar's initial amount (user UI settings take precedence and persist locally) |
153
154
  | `lowBalanceThreshold` | `50` | Low-balance alert threshold (CNY); sent with usage-stats, alerts once a day when any provider's CNY balance is below it |
154
155
  | `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) |
156
+ | `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` |
157
+ | `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 |
155
158
 
156
159
  ## Development
157
160
 
@@ -189,6 +192,7 @@ None. This plugin is a pure UI surface: it registers no tools, injects no system
189
192
  ## Contributors
190
193
 
191
194
  - [@ciphoo](https://github.com/ciphoo) — MiniMax CN Token Plan quota support (PR #5)
195
+ - [@fabulousyuann-tech](https://github.com/fabulousyuann-tech) — durable ledger that retains usage after session deletion (PR #8)
192
196
 
193
197
  ## License
194
198
 
package/README.md CHANGED
@@ -44,6 +44,7 @@
44
44
 
45
45
  ![明细:厂商计费与订阅(余额、套餐额度、模型用量)](screenshots/3.png)
46
46
  - **自定义 Provider 余额**:配置任意 HTTP 端点查余额(`extract` 支持常量 / 点路径 / add-subtract / divide,请求头 `{{ENV}}` 经凭据 seam);DeepSeek / Kimi / 阶跃星辰 / 硅基流动内置官方余额,余额列按近 7 天日均折算「约可撑 N 天」。
47
+ - **声明端点 + 余额对账**:**声明端点**(`declaredEndpoints`)为内置表没有的供应商自声明余额/额度接口——只写「数字在哪里」的点路径(无表达式),请求由匹配到同源 provider 的 origin 构造,单斜杠绝对路径 / 仅 GET / 拒跨源重定向 / 响应体与超时上限 / 凭据只取匹配 provider 自有 `apiKeyEnv` 等安全边界由 `src/declarative.ts` 强制执行,取错路径在界面标注 `declared` 与 reason;**余额差对账**(`reconcilePath`)用官方(仅 DeepSeek 官方方向)余额当日变动与本地账本当日的官方渠道费用交叉校验,偏差超阈值(0.3 元且 >15%)时提示核对价格表或近期账单,充值 / 授信 / 币种变化重置基准而非告警、余额未减少(走订阅扣费)静默。
47
48
  - **真实用量聚合**:服务端从会话日志实时聚合(增量缓存只重算写过的会话),单会话损坏容错、快照落盘回退;`usage_stats` 工具让模型自查今天 / 本月 / 当前会话 / 累计费用,还可查 `bySite`(按站点归组)与 `relay`(只看中转站)的汇总。
48
49
  - **多语种 + 双币种**:¥ / $ 切换随币种双语(USD→英文、CNY→中文,仅本插件生效);费率表按所选币种换算。
49
50
  - **模型健康 + 未收录标注**:厂商接入状态圆点(绿 / 红 / 灰);模型 id 不在目录时标「未收录」按兜底价估算、厂商自动推断(如 `mi-mimo-2.5` → 小米);估算价模型标注「估算价」。
@@ -154,6 +155,8 @@ cost(CNY)= (missInput × p_input + cacheHit × p_cacheHit + output × p_outp
154
155
  | `monthlyBudget` | 未设置 | 月度预算默认金额(人民币元);随 usage-stats 下发,作为仪表盘预算条的初始金额(用户在界面上的设置优先并本地持久化) |
155
156
  | `lowBalanceThreshold` | `50` | 余额不足告警阈值(人民币元);随 usage-stats 下发,任一厂商余额折算人民币低于此值时每天提醒一次 |
156
157
  | `subscriptionPlans` | 自动识别 | 订阅额度适配器白名单(`{ provider, baseUrl?, region? }`);缺省时自动从 `llm-pi-ai` 设置识别所有订阅类 provider(有额度 API 的查额度,无 API 的仅标识) |
158
+ | `declaredEndpoints` | 未设置 | 声明端点(`{ displayName, origin, path, fields?, windows?, raw? }`):为内置表没有的供应商自声明余额/额度接口,只写「数字在哪里」的点路径、无表达式;请求由匹配到同源 provider 的 origin 构造,安全边界(单斜杠绝对路径、仅 GET、拒绝跨源重定向、响应体/超时上限、凭据只取匹配 provider 自有的 apiKeyEnv)由 `src/declarative.ts` 强制执行 |
159
+ | `reconcilePath` | `~/.dsh/.dsh-usage-reconcile.json` | 余额差对账基准的绝对路径;用官方(仅 DeepSeek 官方方向)余额当日变动与本地账本当日的官方渠道费用做交叉校验,偏差超阈值(0.3 元且 >15%)时提示核对;充值/授信/币种变化重置基准而非告警 |
157
160
 
158
161
  ## 开发
159
162
 
@@ -191,6 +194,7 @@ npm publish --access public
191
194
  ## Contributors
192
195
 
193
196
  - [@ciphoo](https://github.com/ciphoo) — MiniMax 国内域 Token Plan 订阅额度支持(PR #5)
197
+ - [@fabulousyuann-tech](https://github.com/fabulousyuann-tech) — 会话删除后用量保留的持久 ledger 功能(PR #8)
194
198
 
195
199
  ## 许可证
196
200