dsh-cost-meter 1.8.29 → 1.8.30
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.md +7 -7
- package/README.zh-CN.md +7 -7
- package/docs/custom-model-prices.md +27 -0
- package/docs/idle-performance.md +11 -0
- package/docs/provider-pricing.json +50 -1
- package/docs/update-notes-1.8.30.md +27 -0
- package/lib/billing-history.js +4 -2
- package/lib/client.js +5 -5
- package/lib/client.pricing.js +1 -1
- package/lib/client.statistics.js +6 -6
- package/lib/index.js +3 -3
- package/lib/price-multiplier.js +40 -0
- package/lib/pricing.js +29 -11
- package/lib/provider-prices.js +2 -0
- package/lib/statistics-warmup.js +8 -24
- package/lib/stepfun-prices.js +12 -0
- package/lib/store.js +15 -0
- package/lib/typert.host.js +11 -0
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -10,13 +10,13 @@ Community and feedback: [Join the WeChat group →](#community). The WeChat grou
|
|
|
10
10
|
|
|
11
11
|
Per-conversation cost · daily totals · OpenCode Go subscription quota display · budget with usage percentage · official account balance · custom provider balance · balance progress bar · history · peak/off-peak pricing hours display (peak hours UTC 01:00–04:00, 06:00–10:00; weekends and Chinese public holidays are off-peak all day, with separate labels) · pre-switch popup & system-notification alerts for peak/off-peak changes (position / lead time / alert type configurable) · one-click price sync from the official docs · Codex-style token usage heat grid · multi-vendor model pricing (built-in 170+ model-ID catalog with auto-matching) · mainstream Coding Plan quota queries & display (Anthropic / Z.ai / MiniMax / Kimi / OpenRouter / SiliconFlow / CommandCode / SCNet / Volcano Ark / Qwen / Xiaomi MiMo / Factory Droid) plan/API dual-track billing (subscription quota vs pay-as-you-go money separated, per-1% & full-window token/equivalent-cost estimates with daily/weekly/monthly curves) · · quota strip above the input box (budget / Go / coding-plan usage in one row, toggleable)
|
|
12
12
|
|
|
13
|
-
[](https://github.com/Han-1413141/dsh-cost-meter)
|
|
14
14
|
|
|
15
|
-
**v1.8.
|
|
15
|
+
**v1.8.30** fixes repeated session-cost reads while idle or typing, defers detailed statistics until requested, and preserves saved snapshots and hover prefetch.
|
|
16
16
|
|
|
17
17
|
Desktop users: follow the [Desktop installation instructions](docs/install-troubleshooting.md#desktop-安装与更新) for the application's own CLI and `desktop` Profile.
|
|
18
18
|
|
|
19
|
-
Release notes: [
|
|
19
|
+
Release notes: [Idle and typing performance — v1.8.30](docs/update-notes-1.8.30.md#english). Fully restart DSH after updating.
|
|
20
20
|
|
|
21
21
|
If startup reports **Ledger is busy** and the cost widgets are missing, see [ledger lock recovery](docs/ledger-lock-recovery.md#english).
|
|
22
22
|
|
|
@@ -327,22 +327,22 @@ On Node.js 20, use `npm install -g pnpm@10` instead. See [pnpm installation and
|
|
|
327
327
|
dsh plugin --profile web add dsh-cost-meter
|
|
328
328
|
```
|
|
329
329
|
|
|
330
|
-
**PowerShell one-click script** (copy the whole line, paste, press Enter; pnpm is provisioned automatically, git is auto-detected — no clone needed; the install chain is **pinned to the release tag `v1.8.
|
|
330
|
+
**PowerShell one-click script** (copy the whole line, paste, press Enter; pnpm is provisioned automatically, git is auto-detected — no clone needed; the install chain is **pinned to the release tag `v1.8.30`** — review the script before running):
|
|
331
331
|
|
|
332
332
|
```powershell
|
|
333
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.8.
|
|
333
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.8.30/install.ps1 | iex
|
|
334
334
|
```
|
|
335
335
|
|
|
336
336
|
**Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
|
|
337
337
|
|
|
338
338
|
```sh
|
|
339
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.8.
|
|
339
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.8.30
|
|
340
340
|
```
|
|
341
341
|
|
|
342
342
|
Without git, use the GitHub tag archive:
|
|
343
343
|
|
|
344
344
|
```sh
|
|
345
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.8.
|
|
345
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.8.30.tar.gz
|
|
346
346
|
```
|
|
347
347
|
|
|
348
348
|
After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
|
package/README.zh-CN.md
CHANGED
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
本会话费用 · 当日费用 · OpenCode Go 订阅额度显示 · 预算与已用百分比 · 官方账户余额 · 自定义 Provider 余额查询(可配任意 HTTP 端点) · 余额三段进度条 · 历史记录 · 峰谷计价时段显示(UTC 01:00–04:00、06:00–10:00 为峰时段;周末与中国法定假日全天按谷价,分别标注) · 峰/谷切换前弹窗与系统通知提醒(位置/提前量/提醒类型可配) · 官方价格一键同步 · 类 Codex Token 用量热图 · 多厂商多模型价格计费(内置 170+ 模型 ID 价格目录与自动匹配) · 主流 Coding Plan 额度查询与显示(Anthropic / Z.ai / MiniMax / Kimi / OpenRouter / SiliconFlow / CommandCode / SCNet / 火山方舟 / 千问 / 小米 MiMo 十一家,含 Volcano Ark AK/SK 签名与 MiMo 控制台 Cookie 查询) · Plan/API 双轨计费(订阅额度与按量金额分离统计,每 1% 额度与满窗的 token/等值金额估算及日/周/月曲线) · 输入框上方额度横条(预算/Go/Coding Plan 用量一条横排显示,可开关)
|
|
12
12
|
|
|
13
|
-
[](https://github.com/Han-1413141/dsh-cost-meter)
|
|
14
14
|
|
|
15
|
-
**v1.8.
|
|
15
|
+
**v1.8.30** 修复空闲、打字时重复读取会话费用的问题;明细按需计算,保留缓存与悬停预加载。
|
|
16
16
|
|
|
17
17
|
桌面端用户请按 [Desktop 安装说明](docs/install-troubleshooting.md#desktop-安装与更新),使用应用自带的 CLI 和 `desktop` Profile。
|
|
18
18
|
|
|
19
|
-
更新说明:[v1.8.
|
|
19
|
+
更新说明:[v1.8.30 空闲与输入性能修复](docs/update-notes-1.8.30.md#中文)。更新后完全重启 DSH。
|
|
20
20
|
|
|
21
21
|
启动报 **Ledger is busy** 且费用卡片消失时,参见[账本锁恢复说明](docs/ledger-lock-recovery.md#简体中文)。
|
|
22
22
|
|
|
@@ -327,22 +327,22 @@ Node.js 20 请改用 `npm install -g pnpm@10`。版本要求见 [pnpm 官方安
|
|
|
327
327
|
dsh plugin --profile web add dsh-cost-meter
|
|
328
328
|
```
|
|
329
329
|
|
|
330
|
-
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.8.
|
|
330
|
+
**PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.8.30`**,建议先下载审阅再运行):
|
|
331
331
|
|
|
332
332
|
```powershell
|
|
333
|
-
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.8.
|
|
333
|
+
irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.8.30/install.ps1 | iex
|
|
334
334
|
```
|
|
335
335
|
|
|
336
336
|
**或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
|
|
337
337
|
|
|
338
338
|
```sh
|
|
339
|
-
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.8.
|
|
339
|
+
dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.8.30
|
|
340
340
|
```
|
|
341
341
|
|
|
342
342
|
没有 git 时可用 GitHub tag 打包直链:
|
|
343
343
|
|
|
344
344
|
```sh
|
|
345
|
-
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.8.
|
|
345
|
+
dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.8.30.tar.gz
|
|
346
346
|
```
|
|
347
347
|
|
|
348
348
|
安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# 按渠道设置模型价格
|
|
2
|
+
|
|
3
|
+
在“设置 → 费用 → 价格”的模型匹配列表中,打开对应模型的下拉框,选择“自定义价格(此渠道模型)”。
|
|
4
|
+
|
|
5
|
+
输入、缓存读取、输出价格放在同一组,单位为每百万 Token,可选 USD 或 CNY。缓存写入和单独推理费用放在“更多计费项”中。推理已包含在输出价格中时无需另填;缓存写入留空则使用缓存读取价格。
|
|
6
|
+
|
|
7
|
+
倍率复用价格卡片原来的操作:输入 `2 × 0.8`、`2 * 0.8` 或 `2 x 0.8`,按回车或离开输入框后保存。默认将倍率应用于这个模型的全部单价;勾选“分别设置倍率”后可单独修改各项。实际单价在表单下方显示。
|
|
8
|
+
|
|
9
|
+
例如渠道 A 的输入价格为 `2 × 0.8`,实际为 1.6;渠道 B 的同一模型设置 `2 × 0.5`,实际为 1。原价不会被反复相乘。
|
|
10
|
+
|
|
11
|
+
设置按 DSH 的渠道 ID 和模型 ID 保存。两个接入渠道需要使用不同的渠道 ID。自定义价格不修改公共价格表,也不参与其他渠道的自动匹配。切回自动匹配或价格表条目后,填写过的自定义价格保留,再次选择即可继续使用。
|
|
12
|
+
|
|
13
|
+
价格和倍率只影响后续调用,历史记录继续使用当时的版本。历史重算仍由价格页的独立入口明确触发。
|
|
14
|
+
|
|
15
|
+
## StepFun 价格来源
|
|
16
|
+
|
|
17
|
+
核实日期:2026-10-16。来源:[StepFun 全球开放平台定价](https://platform.stepfun.ai/docs/en/guides/pricing/details)。以下为 USD / 百万 Token,直接 API 价格。
|
|
18
|
+
|
|
19
|
+
| 模型 | 输入 | 缓存读取 | 输出 |
|
|
20
|
+
| --- | ---: | ---: | ---: |
|
|
21
|
+
| step-5-preview | 1 | 0.1 | 2.7 |
|
|
22
|
+
| step-3.7-flash | 0.2 | 0.04 | 1.15 |
|
|
23
|
+
| step-3.5-flash | 0.1 | 0.02 | 0.3 |
|
|
24
|
+
| step-3.5-flash-2603 | 0.1 | 0.02 | 0.3 |
|
|
25
|
+
| step-1o-turbo-vision | 0.36 | 0.07 | 1.15 |
|
|
26
|
+
|
|
27
|
+
地区报价、套餐、搜索及音频和图像生成费用分别计费。其他渠道的折扣或地区报价可通过模型的自定义价格填写。
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# 空闲与输入性能
|
|
2
|
+
|
|
3
|
+
原始反馈:[@KezhiAdore,#284](https://github.com/Han-1413141/dsh-cost-meter/issues/284)。报告提供了同一台 macOS 设备上插件开关的 CPU/GPU 对照,尚未取得该设备的采样栈。
|
|
4
|
+
|
|
5
|
+
已复现的具体路径是会话费用读取依赖投影对象身份。实际用量没有变化,但投影每次渲染都返回新对象时,RPC 回读更新组件,更新后的组件再次读取新对象,形成持续请求。刷新条件现改为实际数值和会话身份;普通徽章不再启动完整明细回放。
|
|
6
|
+
|
|
7
|
+
测试使用真实 React 和实际客户端源码,比较 v1.8.29 与修改版,以 4 倍 CPU 降速运行本地 Chromium。1.2 秒空闲窗口中请求数为 48 → 1,随后连续输入后累计请求数为 127 → 1。实际用量增加时仍刷新一次;隐藏页面暂停,恢复后刷新。测试无外部请求,无浏览器错误。这些数字只说明受控回归中的请求行为,不能换算成报告中 Mac 的 CPU/GPU 百分比。
|
|
8
|
+
|
|
9
|
+
首次打开与缓存恢复分开处理。已有快照立即返回,完整回放在后台进行;鼠标悬停、键盘聚焦明细入口会预加载。首次无缓存的长会话仍需计算。本地 2,880 次调用的服务端样例中,首次轨迹计算约 400ms,已有缓存恢复约 41ms;不包括浏览器布局和绘图,耗时随设备及历史规模变化。
|
|
10
|
+
|
|
11
|
+
明细后台更新只服务实际请求过的会话。启动只读少量近期元数据,不扫描明细;90 秒没有新的查看请求后停止为该会话预计算。费用与用量账本继续正常记录。提示弹窗出现后不再持续等待,长时间刷新使用有限动画,减少空闲合成工作。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generatedAt": "2026-10-
|
|
2
|
+
"generatedAt": "2026-10-16",
|
|
3
3
|
"note": "Auto-generated from lib/pricing.js DEFAULT_PROVIDER_PRICE_TABLE. USD per 1M tokens; unpriced entries have no verified official price.",
|
|
4
4
|
"providers": {
|
|
5
5
|
"openai": {
|
|
@@ -3240,6 +3240,55 @@
|
|
|
3240
3240
|
"notes": "Current published promotional rate; gateway pricing is independent of the direct API."
|
|
3241
3241
|
}
|
|
3242
3242
|
}
|
|
3243
|
+
},
|
|
3244
|
+
"stepfun": {
|
|
3245
|
+
"models": {
|
|
3246
|
+
"step-5-preview": {
|
|
3247
|
+
"input": 1,
|
|
3248
|
+
"cachedInput": 0.1,
|
|
3249
|
+
"output": 2.7,
|
|
3250
|
+
"billingMode": "flat",
|
|
3251
|
+
"sourceUrl": "https://platform.stepfun.ai/docs/en/guides/pricing/details",
|
|
3252
|
+
"checkedAt": "2026-10-16",
|
|
3253
|
+
"notes": "StepFun global API, USD per million tokens. Reasoning is included in output. Regional pricing, Step Plan, search and audio/image generation charges are not included."
|
|
3254
|
+
},
|
|
3255
|
+
"step-3.7-flash": {
|
|
3256
|
+
"input": 0.2,
|
|
3257
|
+
"cachedInput": 0.04,
|
|
3258
|
+
"output": 1.15,
|
|
3259
|
+
"billingMode": "flat",
|
|
3260
|
+
"sourceUrl": "https://platform.stepfun.ai/docs/en/guides/pricing/details",
|
|
3261
|
+
"checkedAt": "2026-10-16",
|
|
3262
|
+
"notes": "StepFun global API, USD per million tokens. Reasoning is included in output. Regional pricing, Step Plan, search and audio/image generation charges are not included."
|
|
3263
|
+
},
|
|
3264
|
+
"step-3.5-flash": {
|
|
3265
|
+
"input": 0.1,
|
|
3266
|
+
"cachedInput": 0.02,
|
|
3267
|
+
"output": 0.3,
|
|
3268
|
+
"billingMode": "flat",
|
|
3269
|
+
"sourceUrl": "https://platform.stepfun.ai/docs/en/guides/pricing/details",
|
|
3270
|
+
"checkedAt": "2026-10-16",
|
|
3271
|
+
"notes": "StepFun global API, USD per million tokens. Reasoning is included in output. Regional pricing, Step Plan, search and audio/image generation charges are not included."
|
|
3272
|
+
},
|
|
3273
|
+
"step-3.5-flash-2603": {
|
|
3274
|
+
"input": 0.1,
|
|
3275
|
+
"cachedInput": 0.02,
|
|
3276
|
+
"output": 0.3,
|
|
3277
|
+
"billingMode": "flat",
|
|
3278
|
+
"sourceUrl": "https://platform.stepfun.ai/docs/en/guides/pricing/details",
|
|
3279
|
+
"checkedAt": "2026-10-16",
|
|
3280
|
+
"notes": "StepFun global API, USD per million tokens. Reasoning is included in output. Regional pricing, Step Plan, search and audio/image generation charges are not included."
|
|
3281
|
+
},
|
|
3282
|
+
"step-1o-turbo-vision": {
|
|
3283
|
+
"input": 0.36,
|
|
3284
|
+
"cachedInput": 0.07,
|
|
3285
|
+
"output": 1.15,
|
|
3286
|
+
"billingMode": "flat",
|
|
3287
|
+
"sourceUrl": "https://platform.stepfun.ai/docs/en/guides/pricing/details",
|
|
3288
|
+
"checkedAt": "2026-10-16",
|
|
3289
|
+
"notes": "StepFun global API, USD per million tokens. Reasoning is included in output. Regional pricing, Step Plan, search and audio/image generation charges are not included."
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3243
3292
|
}
|
|
3244
3293
|
}
|
|
3245
3294
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# v1.8.30
|
|
2
|
+
|
|
3
|
+
## 中文
|
|
4
|
+
|
|
5
|
+
模型匹配下拉新增“自定义价格(此渠道模型)”。按渠道和模型分别保存单价,可选 USD/CNY;常用输入、缓存读取、输出价格直接调整,其他计费项按需展开。复用原价格卡片的倍率输入,支持 `2 × 0.8`、统一与独立倍率,并显示实际单价。切回自动匹配仍保留填写过的价格,历史费用保持原值。
|
|
6
|
+
|
|
7
|
+
补充 StepFun 全球开放平台 5 个模型的官方美元价格。来源:[StepFun 官方定价](https://platform.stepfun.ai/docs/en/guides/pricing/details),核实于 2026-10-16。地区报价和其他渠道折扣可按模型自定义。
|
|
8
|
+
|
|
9
|
+
修复不开费用明细也可能持续读取会话费用的问题。宿主可以在每次渲染时返回内容相同的新投影对象;刷新现在以实际用量、费用、会话身份为条件,避免回读结果引发下一次回读。隐藏页面暂停读取,恢复后刷新。
|
|
10
|
+
|
|
11
|
+
普通徽章只读账本汇总,不预计算完整历史。明细保留本地快照、悬停和键盘聚焦预加载;启动不再重放近期会话,未打开页面不计算整份明细。首次无缓存的长会话仍需计算,已有缓存先返回结果,后台再更新。
|
|
12
|
+
|
|
13
|
+
联动卡片稳定挂载后复用原节点,提示弹窗打开后停止等待轮询,刷新动画限制为两次。详见[性能说明](https://github.com/Han-1413141/dsh-cost-meter/blob/master/docs/idle-performance.md)。
|
|
14
|
+
|
|
15
|
+
感谢 [@KezhiAdore 在 #284](https://github.com/Han-1413141/dsh-cost-meter/issues/284) 提供 macOS 启停对照、CPU/GPU 数据和代码线索。Windows 本地浏览器回归证实并修复了重复请求,原 macOS 设备的 CPU/GPU 百分比仍需该设备复测。
|
|
16
|
+
|
|
17
|
+
## English
|
|
18
|
+
|
|
19
|
+
The model mapping dropdown now offers channel-specific custom prices in USD/CNY. It reuses the existing price input and shared/per-rate multiplier controls, keeps original quotes, previews effective rates, retains inactive custom settings, and preserves historical costs.
|
|
20
|
+
|
|
21
|
+
Five token-priced StepFun models are added from the official global USD pricing page, verified on 2026-10-16.
|
|
22
|
+
|
|
23
|
+
Session-cost refreshes now depend on billing values rather than projection object identity, preventing an RPC/render loop when the host returns fresh but unchanged objects. Hidden pages defer reads.
|
|
24
|
+
|
|
25
|
+
Badges only read aggregates. Detailed statistics retain saved snapshots and hover/focus prefetch, while startup and unopened views no longer replay history. Background refresh interest expires after a view is no longer used. Stable integration cards reuse their mounted target, dialog wait timers stop once opened, and refresh animations run twice.
|
|
26
|
+
|
|
27
|
+
Thanks to @KezhiAdore for issue #284 and the macOS toggle comparison. The repeated-request regression was reproduced and fixed in a controlled Windows browser fixture; its results are not a measurement of the reporter’s Mac CPU/GPU usage.
|
package/lib/billing-history.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { multiplierPath } from './price-multiplier.js'
|
|
1
2
|
/** Immutable pricing versions. Calls share a version instead of copying a catalog per call. */
|
|
2
3
|
import { createHash, randomUUID } from 'node:crypto'
|
|
3
4
|
import { fxRatesOf } from './exchange-rates.js'
|
|
@@ -9,9 +10,9 @@ const fields = ['prices', 'priceMatch', 'priceOverrides', 'exchangeRate', 'peakE
|
|
|
9
10
|
const hash = value => createHash('sha256').update(JSON.stringify(value)).digest('hex')
|
|
10
11
|
const safe = key => !['__proto__', 'constructor', 'prototype'].includes(key)
|
|
11
12
|
const object = value => value && typeof value === 'object' && !Array.isArray(value)
|
|
12
|
-
const rateFields = new Set(['cacheHit', 'cacheMiss', 'cacheWrite', 'input', 'cachedInput', 'output', 'reasoning', 'billingMode', 'unpriced', 'legacy', 'currency', 'aboveInputTokens', 'before', 'offPeak', 'peak', 'longContext', 'legacyBase', 'rateHistory', 'cny'])
|
|
13
|
+
const rateFields = new Set(['cacheHit', 'cacheMiss', 'cacheWrite', 'input', 'cachedInput', 'output', 'reasoning', 'billingMode', 'unpriced', 'legacy', 'currency', 'aboveInputTokens', 'before', 'offPeak', 'peak', 'longContext', 'legacyBase', 'rateHistory', 'cny', 'multiplier', 'separateMultipliers', 'multipliers'])
|
|
13
14
|
const ratesOnly = value => Array.isArray(value) ? value.map(ratesOnly) : object(value)
|
|
14
|
-
? Object.fromEntries(Object.entries(value).filter(([key]) => rateFields.has(key)).map(([key, child]) => [key, ratesOnly(child)])) : value
|
|
15
|
+
? Object.fromEntries(Object.entries(value).filter(([key]) => rateFields.has(key) || multiplierPath.test(key)).map(([key, child]) => [key, ratesOnly(child)])) : value
|
|
15
16
|
const modelsOnly = models => Object.fromEntries(Object.entries(models ?? {}).filter(([key]) => safe(key)).map(([key, entry]) => [key, ratesOnly(entry)]))
|
|
16
17
|
const runFields = ['at', 'before', 'after', 'days', 'sessions', 'skipped']
|
|
17
18
|
const compare = (a, b) => a.at - b.at || (a.sequence ?? 0) - (b.sequence ?? 0) || a.version.localeCompare(b.version)
|
|
@@ -33,6 +34,7 @@ export function pricingSnapshot(config) {
|
|
|
33
34
|
const snapshot = structuredClone(Object.fromEntries(fields.filter(key => key !== 'prices' && config?.[key] !== undefined).map(key => [key, config[key]])))
|
|
34
35
|
const prices = config?.prices ?? {}
|
|
35
36
|
snapshot.prices = { ...(prices.currency ? { currency: prices.currency } : {}), default: ratesOnly(prices.default), models: modelsOnly(prices.models),
|
|
37
|
+
...(prices.custom ? { custom: modelsOnly(prices.custom) } : {}),
|
|
36
38
|
providers: Object.fromEntries(Object.entries(prices.providers ?? {}).filter(([key]) => safe(key)).map(([key, table]) => [key, {
|
|
37
39
|
...(table.currency ? { currency: table.currency } : {}), ...(table.default ? { default: ratesOnly(table.default) } : {}), models: modelsOnly(table.models),
|
|
38
40
|
}])) }
|