@kenz1117/dsh-ui-usage-billing 1.4.2 → 1.4.4
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 +3 -2
- package/README.md +3 -2
- package/lib/client.js +5 -5
- package/lib/index.js +801 -644
- package/lib/types/aggregate.d.ts +3 -2
- package/lib/types/builtin-catalog.d.ts +15 -0
- package/lib/types/client/TrendChart.d.ts +2 -1
- package/lib/types/client/heatmap.d.ts +12 -6
- package/lib/types/client/label-display.d.ts +19 -0
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/client/pricing.d.ts +9 -6
- package/lib/types/client/round-chart.d.ts +1 -1
- package/lib/types/client/usage-billing-settings.d.ts +15 -1
- package/lib/types/index.d.ts +19 -1
- package/package.json +1 -1
- package/lib/types/client/vendor-logos.d.ts +0 -12
package/README.en.md
CHANGED
|
@@ -103,8 +103,8 @@ The billing channel is detected from the current session's model: DeepSeek meter
|
|
|
103
103
|
|
|
104
104
|
- **Real usage aggregation**: incremental server-side aggregation (only written sessions recompute), per-session corruption tolerance, snapshot fallback; the optional `usage_stats` tool queries today / month / current session / cumulative spend, plus `bySite` (relay-attributed) and `relay` (relay-only) summaries.
|
|
105
105
|
- **Model health + uncatalogued annotation**: provider connection dots (green / red / grey); uncatalogued models are marked and priced at the fallback, with the provider inferred (e.g. `mi-mimo-2.5` → Xiaomi); estimated-price models are labeled "estimated".
|
|
106
|
-
- **Multi-language + dual currency**: the ¥/$ switch is bilingual (USD→English, CNY→Chinese, this plugin only); the rate table
|
|
107
|
-
- **Security hardening**: every HTTP endpoint enforces loopback-only access via a dual check of the peer socket address and an exact Host-header match, rejecting `127.0.0.1.evil.com`-style DNS-rebinding names; write paths additionally validate a loopback Origin and Content-Type with a body-size cap against cross-site rewrites; balance / subscription / pricing fetches carry bounded retries with per-upstream circuit breaking (auth failures are config issues and do not trip the breaker).
|
|
106
|
+
- **Multi-language + dual currency**: the ¥/$ switch is bilingual (USD→English, CNY→Chinese, this plugin only — it never leaks into the host UI); the rate table, the sidebar card and the composer capsule all convert to the selected currency, and the choice is persisted locally (it survives reopening the dashboard).
|
|
107
|
+
- **Security hardening**: every HTTP endpoint enforces loopback-only access via a dual check of the peer socket address and an exact Host-header match, rejecting `127.0.0.1.evil.com`-style DNS-rebinding names (reverse-proxy deployments can allow specific names with `trustedHosts`; the peer-socket check stays mandatory); write paths additionally validate a loopback Origin and Content-Type with a body-size cap against cross-site rewrites; balance / subscription / pricing fetches carry bounded retries with per-upstream circuit breaking (auth failures are config issues and do not trip the breaker).
|
|
108
108
|
- **Export injection guard**: CSV cells starting with `=` / `+` / `-` / `@` get a leading single quote and full escaping, so they cannot execute as formulas in Excel / WPS.
|
|
109
109
|
- **Privacy baseline**: a pure UI surface — registers no tools, injects no system prompt, writes no model-visible events; it only aggregates from existing session logs, whose content is owned by other packages.
|
|
110
110
|
|
|
@@ -209,6 +209,7 @@ The public HTTP endpoints and field definitions are documented in source: `GET /
|
|
|
209
209
|
| `modelKeyAliases` | not set | User model aliases (log model id -> billing catalog key, value must be an existing `MODEL_CATALOG` key): bind uncatalogued ids without waiting for a release. Example: `{ "hy4-preview": "hunyuan" }` |
|
|
210
210
|
| `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) |
|
|
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
|
+
| `trustedHosts` | unset | Extra host names allowed through the Host-header check when DSH runs behind a reverse proxy (e.g. `['llm.example.com']`); **empty by default = behaviour identical to previous releases**. Consulted only after the peer-socket loopback check has passed, so it widens only the second, defence-in-depth layer; exact host match, case- and port-insensitive, with no suffix or wildcard semantics |
|
|
212
213
|
| `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
214
|
| `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
215
|
| `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 |
|
package/README.md
CHANGED
|
@@ -103,8 +103,8 @@ DeepSeek / Kimi / 智谱 GLM / 腾讯云 TokenHub 等 7 家官方余额、Coding
|
|
|
103
103
|
|
|
104
104
|
- **真实用量聚合**:服务端增量聚合(只重算写过的会话),单会话损坏容错、快照落盘回退;`usage_stats` 工具让模型自查今天 / 本月 / 当前会话 / 累计费用,还可查 `bySite`(按站点归组)与 `relay`(只看中转站)汇总。
|
|
105
105
|
- **模型健康 + 未收录标注**:厂商接入状态圆点(绿 / 红 / 灰);未收录模型显著标注、按兜底价估算、厂商自动推断(如 `mi-mimo-2.5` → 小米);估算价模型标注「估算价」。
|
|
106
|
-
- **多语种 + 双币种**:¥ / $ 切换随币种双语(USD→英文、CNY
|
|
107
|
-
- **安全加固**:全部 HTTP 端点强制回环访问——peer socket 地址 + Host 头精确匹配双重校验,拒绝 `127.0.0.1.evil.com` 形式的 DNS rebinding
|
|
106
|
+
- **多语种 + 双币种**:¥ / $ 切换随币种双语(USD→英文、CNY→中文,仅本插件生效,不影响宿主全局 UI);费率表、侧边栏卡片与输入框胶囊均按所选币种换算,选择本地持久化(重开仪表盘仍保留)。
|
|
107
|
+
- **安全加固**:全部 HTTP 端点强制回环访问——peer socket 地址 + Host 头精确匹配双重校验,拒绝 `127.0.0.1.evil.com` 形式的 DNS rebinding(反向代理部署可用 `trustedHosts` 显式放行特定主机名,peer socket 校验仍为强制);写操作额外校验 Origin 回环与 Content-Type 并限制 body 上限,杜绝跨站改写;余额 / 订阅 / 定价拉取带有限重试与按上游维度熔断(鉴权失败属配置问题、不计入熔断)。
|
|
108
108
|
- **导出防注入**:CSV 对 `=` / `+` / `-` / `@` 开头单元格前置单引号并完整转义,防止在 Excel / WPS 中被当作公式执行。
|
|
109
109
|
- **隐私底线**:纯 UI surface,不注册工具、不注入系统提示、不向会话日志写模型可见事件;仅从既有会话日志聚合,日志内容由其他包负责。
|
|
110
110
|
|
|
@@ -225,6 +225,7 @@ cost(CNY)= (missInput × p_input + cacheHit × p_cacheHit + output × p_outp
|
|
|
225
225
|
| `declaredEndpoints` | 未设置 | 声明端点(`{ displayName, origin, path, fields?, windows?, raw? }`):为内置表没有的供应商自声明余额/额度接口,只写「数字在哪里」的点路径、无表达式;请求由匹配到同源 provider 的 origin 构造,安全边界(单斜杠绝对路径、仅 GET、拒绝跨源重定向、响应体/超时上限、凭据只取匹配 provider 自有的 apiKeyEnv)由 `src/declarative.ts` 强制执行 |
|
|
226
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
|
+
| `trustedHosts` | 未设置 | 反向代理场景下允许通过 Host 头校验的额外主机名(如 `['llm.example.com']`);**缺省空 = 与历史版本行为完全一致**。仅在 peer socket 回环校验通过后才参考,只放宽「纵深防御」的第二层;精确主机名匹配(忽略大小写与端口),无后缀 / 通配符语义 |
|
|
228
229
|
|
|
229
230
|
## 🛠 开发
|
|
230
231
|
|