@kenz1117/dsh-ui-usage-billing 1.7.0 → 1.7.2
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 +20 -18
- package/README.md +21 -19
- package/lib/client.js +2 -2
- package/lib/index.js +1839 -243
- package/lib/types/client/domain/forecast.d.ts +8 -2
- package/lib/types/client/locales.d.ts +1 -1
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -40,7 +40,7 @@ Most billing plugins stop at "token count × unit price". dsh-ui-usage-billing t
|
|
|
40
40
|
Usage is aggregated live from persisted session logs — never fabricated (an empty snapshot shows until real data arrives); daily official-balance deltas are cross-checked against the local ledger, and deviations beyond the threshold prompt a review — a bill that survives scrutiny.
|
|
41
41
|
|
|
42
42
|
### Live prices, history never rewritten
|
|
43
|
-
A live models.dev catalog + a built-in catalog of
|
|
43
|
+
A live models.dev catalog + a built-in catalog of 241 models across 25 vendors + user-defined prices in the settings panel (bindable per relay origin) mean new models never wait for a release; DeepSeek time-of-day prices are **segmented by official change boundaries** (base price before 08-17, weekend peak hours 08-17~08-23, weekend all-day off-peak from 08-23) and later price changes never rewrite old bills.
|
|
44
44
|
|
|
45
45
|
### Peak/off-peak aware, alerts follow the model
|
|
46
46
|
The billing channel is detected from the current session's model: DeepSeek metered uses time-of-day prices (weekday 9-12 / 14-18 peak ×2, weekend all-day off-peak), Zhipu Coding Plan uses credit windows (weekday 14-18 peak at full rate, off-peak at **50% of base credits**) — the channel layer is extensible for more providers; a popover / system notification fires automatically before each switch, and only sessions whose current model actually involves peak/off-peak get alerted or show the tier section — no watching the clock.
|
|
@@ -184,34 +184,36 @@ cost (CNY) = (missInput × p_input + cacheHit × p_cacheHit + output × p_output
|
|
|
184
184
|
|
|
185
185
|
`input` in the stats is total input (cacheHit + cacheMiss); estimation splits it into hit / miss to avoid double counting. Models with two-band billing are mixed by `DEFAULT_PEAK_SHARE` (default 0.5); weekends (Beijing Sat/Sun) are charged at the off-peak rate all day.
|
|
186
186
|
|
|
187
|
-
|
|
187
|
+
**Month-to-date forecast**: month-to-date spend + last-7-calendar-day pace × the days still left in the month. Only the days that have not happened yet are extrapolated, so a quiet recent week never inflates the number — earlier versions averaged over the month's *recorded* days and multiplied by the whole month length, which inflated sparsely used months several times over.
|
|
188
188
|
|
|
189
|
-
|
|
189
|
+
### Supported models (2026-10 lineup, OpenAI-compatible series, 241 models)
|
|
190
|
+
|
|
191
|
+
The full catalog lives in the Rates tab and in `BUILTIN_MODEL_CATALOG` of `src/builtin-catalog.ts` (240 active + 1 retired model kept for historical repricing); representative models per vendor below.
|
|
190
192
|
|
|
191
193
|
| Provider | Representatives |
|
|
192
194
|
| -------- | -------------------------------------------- |
|
|
193
195
|
| DeepSeek | V4.1 Flash, V4 Pro (3 models; priced per official change boundary: base tier → peak/off-peak v1 → weekend off-peak) |
|
|
194
|
-
| Zhipu AI | GLM-5.3, GLM-5.2 (
|
|
195
|
-
| Aliyun | Qwen3.8 Max, Qwen3-Coder 480B (
|
|
196
|
-
| Doubao | Doubao Seed-2.1 Pro, Doubao Seed-2.0 Pro (
|
|
197
|
-
| Moonshot | Kimi K3, Kimi K2.7 Code (
|
|
198
|
-
| Xiaomi | MiMo V2.6 Pro (
|
|
199
|
-
| MiniMax | MiniMax-M3, MiniMax-M2.7 (
|
|
196
|
+
| Zhipu AI | GLM-5.3, GLM-5.2 (17 models) |
|
|
197
|
+
| Aliyun | Qwen3.8 Max, Qwen3-Coder 480B (27 models) |
|
|
198
|
+
| Doubao | Doubao Seed-2.1 Pro, Doubao Seed-2.0 Pro (13 models) |
|
|
199
|
+
| Moonshot | Kimi K3.1 Pro, Kimi K3.1 Pro Highspeed, Kimi K3, Kimi K2.7 Code (18 models) |
|
|
200
|
+
| Xiaomi | MiMo V2.6 Pro (6 models) |
|
|
201
|
+
| MiniMax | MiniMax-M3, MiniMax-M2.7 (8 models) |
|
|
200
202
|
| Unisound | U2 Flash, Unisound U2 (3 models) |
|
|
201
203
|
| Baidu | ERNIE-5.1, ERNIE-4.5 300B (2 models) |
|
|
202
204
|
| Tencent | Hunyuan Hy3, Hunyuan T1 (3 models) |
|
|
203
|
-
| Anthropic | Claude Opus
|
|
204
|
-
| Mistral AI | Mistral Large 3, Mistral Small 4 (
|
|
205
|
-
| Cohere | Command A, Command R (
|
|
206
|
-
| OpenAI | GPT-6 Astra, GPT-5.6 Sol / Terra / Luna (
|
|
207
|
-
| Google | Gemini 3.1 Pro, Gemini 3.6 Flash (
|
|
208
|
-
| xAI | Grok 4.7, Grok 4.
|
|
209
|
-
| Meta | Llama 4 Maverick (
|
|
205
|
+
| Anthropic | Claude Opus 5, Claude Sonnet 5 (14 models) |
|
|
206
|
+
| Mistral AI | Mistral Large 3, Mistral Small 4 (30 models) |
|
|
207
|
+
| Cohere | Command A, Command R (7 models) |
|
|
208
|
+
| OpenAI | GPT-6 Astra, GPT-5.6 Sol / Terra / Luna (38 models) |
|
|
209
|
+
| Google | Gemini 3.1 Pro, Gemini 3.6 Flash (25 models) |
|
|
210
|
+
| xAI | Grok 4.7, Grok 4.20 (8 models) |
|
|
211
|
+
| Meta | Llama 4 Maverick, Muse Spark 1.3 (8 models) |
|
|
210
212
|
| Meituan | LongCat 2.0 (estimated) |
|
|
211
213
|
| ModelBest | MiniCPM-V 4.5 (estimated) |
|
|
212
214
|
| Xiaohongshu | Dots3-Note Preview (estimated) |
|
|
213
215
|
| 01.AI | Yi-Lightning |
|
|
214
|
-
| StepFun | Step 3.7 Flash |
|
|
216
|
+
| StepFun | Step 3.7 Flash, Step 5 Preview (3 models) |
|
|
215
217
|
| iFlytek | Spark 4.0 Ultra (plan-based)¹ |
|
|
216
218
|
| SenseTime | SenseNova 6.5 (beta)¹ |
|
|
217
219
|
| Baichuan | Baichuan M3-Plus |
|
|
@@ -232,7 +234,7 @@ The public HTTP endpoints and field definitions are documented in source: `GET /
|
|
|
232
234
|
| `statsPath` | unset | Absolute path to a fallback `.dsh-usage-stats.json` (used when `sessionPersistence` is unavailable) |
|
|
233
235
|
| `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) |
|
|
234
236
|
| `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 |
|
|
235
|
-
| `subscriptionProviders` | built-in channel list (incl. `tencent-token-plan`) | Subscription (coding / token plan) provider id list — tokens counted, cost 0; aligned with the subscription-card recognition
|
|
237
|
+
| `subscriptionProviders` | built-in channel list (incl. `tencent-token-plan`) | Subscription (coding / token plan) provider id list — tokens counted, cost 0; aligned with the subscription-card recognition. Note it **replaces** the built-in list rather than appending to it — when customizing, list the built-in entries too, otherwise removed subscription channels fall back to pay-as-you-go |
|
|
236
238
|
| `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" }` |
|
|
237
239
|
| `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" }` |
|
|
238
240
|
| `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) |
|
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
用量从持久化会话日志实时聚合,绝不伪造样本(数据到达前显示空快照);官方余额当日变动与本地账本交叉对账,偏差超阈值主动提示核对——账单经得起质疑。
|
|
41
41
|
|
|
42
42
|
### 价格是活的,历史不重算
|
|
43
|
-
models.dev 实时目录 + 内置 25 厂商
|
|
43
|
+
models.dev 实时目录 + 内置 25 厂商 241 款模型 + 设置面板自定义单价(可按中转站绑定同模型不同价),新模型无需等发版;DeepSeek 分时价按官方变更节点**分段计价**(8-17 前基础价、8-17~8-23 周末计峰、8-23 起周末全谷),价格调整永不回写旧账。
|
|
44
44
|
|
|
45
45
|
### 峰谷全感知,提醒跟着模型走
|
|
46
46
|
计费通道按当前会话使用的模型自动识别:DeepSeek 按量走分时价(工作日 9-12 / 14-18 高峰 ×2、周末全天低谷),智谱 Coding Plan 走积分峰谷(工作日 14-18 高峰全额、非高峰**积分 5 折**),通道层可扩展、更多厂商逐步接入;切档前弹窗 / 系统通知自动提醒,且只有当前模型真正涉及峰谷才会提醒、费用条才显示档位——不用你盯时间表。
|
|
@@ -191,36 +191,38 @@ cost(CNY)= (missInput × p_input + cacheHit × p_cacheHit + output × p_outp
|
|
|
191
191
|
|
|
192
192
|
**联网搜索请求按次估算**(issue #15):DSH 的联网搜索绕过对话通道直连官方 `api.deepseek.com`,会话日志只记请求、无用量事件,而开放平台照常计费。插件对这类 `web/deepseek-search-llm-request` 事件按次估值计入费用(默认 0.02 元/次,配置 `searchCallEstimateCny` 可调整;设 0 关闭),并单独累计 `searchCalls` 供面板提示估算口径。
|
|
193
193
|
|
|
194
|
+
**「本月预计」的口径**:本月已发生 + 近 7 个自然日节奏 × 本月剩余天数。只外推还没发生的天数,近期没花钱就不虚增——早期版本拿「本月有记录的天数」当分母求日均再乘整月天数,稀疏使用的月份会被放大数倍(实测 4 天记录、其余 19 天没用的月份被外推成实际值的 4 倍)。
|
|
195
|
+
|
|
194
196
|
**自定义单价(设置 Tab,issue #16)**:结构化条目表(模型 + 可选来源 + 输入/缓存命中/输出 + 币种),不再手编 JSON。来源(中转站域名)留空 = 该模型默认价;填入中转站域名(如 `https://api.my-relay.com`)= 仅该来源的同名模型用此价(同名模型可同时存在默认价与多个来源价,互不覆盖)。显示层按「模型 × 来源」精确匹配重算,命中不到来源时回落该模型默认价,再无则用内置目录价。
|
|
195
197
|
|
|
196
|
-
### 支持模型(2026-10 主流阵容,OpenAI 兼容系列,共
|
|
198
|
+
### 支持模型(2026-10 主流阵容,OpenAI 兼容系列,共 241 款)
|
|
197
199
|
|
|
198
|
-
完整目录见费率 Tab 及源码 `src/builtin-catalog.ts` 的 `BUILTIN_MODEL_CATALOG`(
|
|
200
|
+
完整目录见费率 Tab 及源码 `src/builtin-catalog.ts` 的 `BUILTIN_MODEL_CATALOG`(240 款在售 + 1 款退役型号保留历史回算),此处每厂商仅列代表型号。
|
|
199
201
|
|
|
200
202
|
| 厂商 | 代表模型 |
|
|
201
203
|
| -------- | -------------------------------------------- |
|
|
202
204
|
| DeepSeek | V4.1 Flash、V4 Pro(等 3 款;按官方变更节点分段计价:基础价 → 峰谷 v1 → 周末全谷) |
|
|
203
|
-
| 智谱 AI | GLM-5.3、GLM-5.2(等
|
|
204
|
-
| 阿里通义 | Qwen3.8 Max、Qwen3-Coder 480B(等
|
|
205
|
-
| 字节豆包 | Doubao Seed-2.1 Pro、Doubao Seed-2.0 Pro(等
|
|
206
|
-
| 月之暗面 | Kimi K3、Kimi K2.7 Code(等
|
|
207
|
-
| 小米 | MiMo V2.6 Pro(等
|
|
208
|
-
| MiniMax | MiniMax-M3、MiniMax-M2.7(等
|
|
205
|
+
| 智谱 AI | GLM-5.3、GLM-5.2(等 17 款) |
|
|
206
|
+
| 阿里通义 | Qwen3.8 Max、Qwen3-Coder 480B(等 27 款) |
|
|
207
|
+
| 字节豆包 | Doubao Seed-2.1 Pro、Doubao Seed-2.0 Pro(等 13 款) |
|
|
208
|
+
| 月之暗面 | Kimi K3.1 Pro、Kimi K3.1 Pro Highspeed、Kimi K3、Kimi K2.7 Code(等 18 款) |
|
|
209
|
+
| 小米 | MiMo V2.6 Pro(等 6 款) |
|
|
210
|
+
| MiniMax | MiniMax-M3、MiniMax-M2.7(等 8 款) |
|
|
209
211
|
| 云知声 | U2 Flash、Unisound U2(等 3 款) |
|
|
210
212
|
| 百度文心 | ERNIE-5.1、ERNIE-4.5 300B(等 2 款) |
|
|
211
213
|
| 腾讯混元 | 混元 Hy3、混元 T1(等 3 款) |
|
|
212
|
-
| Anthropic | Claude Opus
|
|
213
|
-
| Mistral AI | Mistral Large 3、Mistral Small 4(等
|
|
214
|
-
| Cohere | Command A、Command R(等
|
|
215
|
-
| OpenAI | GPT-6 Astra、GPT-5.6 Sol / Terra / Luna(等
|
|
216
|
-
| Google | Gemini 3.1 Pro、Gemini 3.6 Flash(等
|
|
217
|
-
| xAI | Grok 4.7、Grok 4.
|
|
218
|
-
| Meta | Llama 4 Maverick(等
|
|
214
|
+
| Anthropic | Claude Opus 5、Claude Sonnet 5(等 14 款) |
|
|
215
|
+
| Mistral AI | Mistral Large 3、Mistral Small 4(等 30 款) |
|
|
216
|
+
| Cohere | Command A、Command R(等 7 款) |
|
|
217
|
+
| OpenAI | GPT-6 Astra、GPT-5.6 Sol / Terra / Luna(等 38 款) |
|
|
218
|
+
| Google | Gemini 3.1 Pro、Gemini 3.6 Flash(等 25 款) |
|
|
219
|
+
| xAI | Grok 4.7、Grok 4.20(等 8 款) |
|
|
220
|
+
| Meta | Llama 4 Maverick、Muse Spark 1.3(等 8 款) |
|
|
219
221
|
| 美团 | LongCat 2.0(估算价) |
|
|
220
222
|
| 面壁智能 | MiniCPM-V 4.5(估算价) |
|
|
221
223
|
| 小红书 | Dots3-Note Preview(估算价) |
|
|
222
224
|
| 零一万物 | Yi-Lightning |
|
|
223
|
-
| 阶跃星辰 | Step 3.7 Flash |
|
|
225
|
+
| 阶跃星辰 | Step 3.7 Flash、Step 5 Preview(等 3 款) |
|
|
224
226
|
| 科大讯飞 | Spark 4.0 Ultra(套餐制)¹ |
|
|
225
227
|
| 商汤 | SenseNova 6.5(公测中)¹ |
|
|
226
228
|
| 百川智能 | Baichuan M3-Plus |
|
|
@@ -228,7 +230,7 @@ cost(CNY)= (missInput × p_input + cacheHit × p_cacheHit + output × p_outp
|
|
|
228
230
|
|
|
229
231
|
> ¹ 讯飞、商汤及美团 / 面壁智能 / 小红书等未公布官方按量单价的模型,表内为估算价(`estimated`);这些模型走订阅通道(coding / token plan / opencode)时费用记 0。订阅通道与 pi-ai 内置提供方对齐(kimi-coding、zai-coding-cn、opencode、opencode-go、qwen / xiaomi 的 token-plan 各区域变体),可按 `subscriptionProviders` 配置覆盖。
|
|
230
232
|
|
|
231
|
-
新增模型:在 `src/builtin-catalog.ts` 的 `BUILTIN_MODEL_CATALOG` 追加条目(别名表 `BUILTIN_MODEL_KEY_ALIASES` 同文件维护;目录只随 node 半构建,经 `/api/billing/pricing`
|
|
233
|
+
新增模型:在 `src/builtin-catalog.ts` 的 `BUILTIN_MODEL_CATALOG` 追加条目(别名表 `BUILTIN_MODEL_KEY_ALIASES` 同文件维护;目录只随 node 半构建,经 `/api/billing/pricing` 由宿主下发注入客户端)。**价源口径**:海外厂商取 models.dev 实时目录原生 USD;国内厂商优先取官方 CN 价(models.dev 的 `-cn` 目录),该目录缺项时按 USD 价 × 汇率折算并在条目注释标注。存量条目的价格更正走独立的调价节点,不与扩容混在一起。
|
|
232
234
|
|
|
233
235
|
## 🔌 HTTP API
|
|
234
236
|
|
|
@@ -241,7 +243,7 @@ cost(CNY)= (missInput × p_input + cacheHit × p_cacheHit + output × p_outp
|
|
|
241
243
|
| `statsPath` | 未设置 | 回退统计文件 `.dsh-usage-stats.json` 的绝对路径(`sessionPersistence` 不可用时生效) |
|
|
242
244
|
| `ledgerPath` | `<harness home>/.dsh-usage-ledger.json` | 独立持久用量账本的绝对路径;只保存折叠后的统计(不保存消息正文或会话标题),永久删除会话不会删除已记录的费用与 token。**默认根跟随宿主 harness home**(`DSH_HOME` 环境变量优先,回退 `~/.dsh`),自定义 `DSH_HOME` 的多套隔离环境互不污染(issue #52) |
|
|
243
245
|
| `balanceApiKeyEnv` | `DEEPSEEK_API_KEY` | DeepSeek 余额查询的凭据引用;仅在 llm-pi-ai 未配置 deepseek 的 `apiKeyEnv` 时兜底使用 |
|
|
244
|
-
| `subscriptionProviders` | 内置订阅通道清单(含 `tencent-token-plan`) | 订阅制(coding / token 套餐)provider id 列表,照常统计 token、费用记 0
|
|
246
|
+
| `subscriptionProviders` | 内置订阅通道清单(含 `tencent-token-plan`) | 订阅制(coding / token 套餐)provider id 列表,照常统计 token、费用记 0;与订阅卡识别口径对齐。**注意是「替换」默认清单,不是追加**——自定义时要把默认项一并写全,否则被移出的订阅通道会被拉回按量计费 |
|
|
245
247
|
| `routeAliases` | 未设置 | 历史路由别名(旧 provider 路由名 → 当前路由名):改名/删除过的路由,其历史用量原落「未知路由」桶且订阅/官方判定失效;配置后按目标路由归位。例:`{ "deepseek-official": "tencent", "tencent-cloud": "tencent" }` |
|
|
246
248
|
| `modelKeyAliases` | 未设置 | 用户自定义模型别名(真实日志 model id → 计费目录键,值须为 `MODEL_CATALOG` 既有 key):目录外新模型无需等发版,配一条别名即完成识别与计价。例:`{ "hy4-preview": "hunyuan" }` |
|
|
247
249
|
| `monthlyBudget` | 未设置 | 月度预算默认金额(人民币元);随 usage-stats 下发,作为仪表盘预算条的初始金额(用户在界面上的设置优先并本地持久化) |
|