@angelyeye/dsh-cost-tracker 1.8.14 → 1.9.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/CHANGELOG.md +237 -0
- package/README.en.md +101 -1
- package/README.md +106 -3
- package/client.js +837 -160
- package/config.js +132 -1
- package/credstore.js +248 -0
- package/docs/THIRD-PARTY-NOTICES.md +60 -0
- package/docs/provider-pricing.json +777 -0
- package/import.js +363 -0
- package/index.js +703 -97
- package/package.json +11 -3
- package/price-sync.js +216 -0
- package/pricing.js +111 -8
- package/schema.js +4 -0
- package/sync.js +25 -4
- package/vendor-catalog.js +198 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,243 @@
|
|
|
2
2
|
|
|
3
3
|
本文件用中文记录 dsh-cost-tracker 的版本变更。
|
|
4
4
|
|
|
5
|
+
## v1.9.1(2026-09-20)
|
|
6
|
+
|
|
7
|
+
**修复:云端同步全面失败(405「方法不允许」)+ 明文迁移在凭据服务晚就绪时不再重试**
|
|
8
|
+
|
|
9
|
+
### 一、修复:safeFetch 丢掉 fetch 原生签名 → POST 退化成 GET(真实故障)
|
|
10
|
+
|
|
11
|
+
- **现场**:升级到 v1.9.0 后云端同步一直失败,界面显示「最近错误:方法不允许」,
|
|
12
|
+
水位卡在 4013、待上报条数只增不减,`pendingFailures` 持续累加并退避到 5 分钟。
|
|
13
|
+
反代访问日志给出铁证:插件实际发出的是
|
|
14
|
+
`GET /api/v1/ingest/records` → **405**(`{"code":"METHOD_NOT_ALLOWED","error":"方法不允许"}`),
|
|
15
|
+
而同路径的 `POST` 是 200 —— 也就是**请求方法与正文都丢了**。
|
|
16
|
+
- **根因**:`index.js` 把 `safeFetch` 当作 `<typeof fetch>` 传给同步引擎 ——
|
|
17
|
+
`fetchFn: (url, init) => safeFetch(url, Object.assign({}, init, { allowHosts }))`,
|
|
18
|
+
而 `safeFetch` 当时**只读 `opts.init`**,于是 `method` / `body` / 部分头全落到 `undefined`:
|
|
19
|
+
fetch 按默认语义发 **GET**、无正文、无 `content-type`,云端按方法不匹配回 405。
|
|
20
|
+
- **修复**:`safeFetch` 同时接受两种入参形状 —— 文档形状 `{ init: {...} }` 与
|
|
21
|
+
**fetch 原生签名**(`method`/`body`/`headers`/`signal` 等在顶层),`opts.init` 优先。
|
|
22
|
+
安全策略不因入参形状变化:顶层签名同样强制 `redirect:'manual'`,跨主机重定向照样拒绝。
|
|
23
|
+
- **回归护栏(两层,专治「组合起来才错」)**:
|
|
24
|
+
· `test/credstore.test.js` 新增 [4b]:照抄 index.js 的接线方式,断言实际发出的是
|
|
25
|
+
**POST**、正文与 `content-type` 完整、`redirect` 被强制 manual、跨主机仍被拒;
|
|
26
|
+
· `test/sync.test.js` 新增集成用例:用同一接线形态跑完整 `runOnce`,断言首个请求是
|
|
27
|
+
`POST /api/v1/ingest/records` 且正文含 `syncVer`、授权头带令牌。
|
|
28
|
+
只测 `safeFetch` 或只测引擎都拦不住这个缺陷 —— 必须测两者的**组合**。
|
|
29
|
+
|
|
30
|
+
### 二、修复:凭据服务晚就绪时,明文迁移不再重试
|
|
31
|
+
|
|
32
|
+
- 现象:升级后 `secretsMigrated` 一直是 `false`,配置里仍留着明文令牌与 SK。
|
|
33
|
+
- 原因:迁移只在启动时跑一次;若那一刻 `ctx.get('credentials')` 还拿不到(凭据服务
|
|
34
|
+
晚于本插件注册),按安全边界会**保留明文**并报告「有悬而未决的明文」,但之后**再没重试**。
|
|
35
|
+
- 修复:`runSecretMigration()` 返回 `pending`;为真时用 `ctx.inject(['credentials'], …)`
|
|
36
|
+
等凭据服务就绪后**自动再迁一次** —— 既不丢凭据,也不让「配置文件零明文」永远停在未完成。
|
|
37
|
+
|
|
38
|
+
### 三、安装方式的坑(已写进 README)
|
|
39
|
+
|
|
40
|
+
- DSH 的 profile 用 pnpm 管理插件(`profiles/web/package.json` 里写着
|
|
41
|
+
`"@angelyeye/dsh-cost-tracker": "^1.8.15"`)。**手动把新版本文件拷进
|
|
42
|
+
`profiles/web/node_modules/…` 会在下次启动时被市场对账重装回旧版**(真实踩坑:
|
|
43
|
+
拷完 v1.9.0、重启后目录又变回 v1.8.15,只有运行中的进程还带着新代码)。
|
|
44
|
+
- 开发/自测请用官方 dev 流程(profile 记成 `link:`,重启不丢):
|
|
45
|
+
`dsh plugin --profile web add link:<仓库路径>`
|
|
46
|
+
|
|
47
|
+
## v1.9.0(2026-09-27)
|
|
48
|
+
|
|
49
|
+
**历史导入 + 凭据外带防护 + 官方价格同步 + 多厂商目录 + Plan/按量双轨开关;
|
|
50
|
+
全部设置集中进「插件配置 → 花费统计」并重设计该卡片(配套云端 v1.4.0)**
|
|
51
|
+
|
|
52
|
+
### 一、新增模块(各自带独立测试,纯逻辑、可单独跑)
|
|
53
|
+
|
|
54
|
+
| 模块 | 职责 |
|
|
55
|
+
| --- | --- |
|
|
56
|
+
| `import.js` | 回放宿主会话日志(多 zstd frame 逐帧解压 + 逐帧切片,防大日志 OOM),重建逐次调用 |
|
|
57
|
+
| `price-sync.js` | 官方定价页解析器(转置价格表:列 = 模型、行 = 指标 × 时段)→ 计费时代 |
|
|
58
|
+
| `vendor-catalog.js` + `docs/provider-pricing.json` | 多厂商价格目录(14 家厂商 / 90 个条目,USD/1M tokens) |
|
|
59
|
+
| `credstore.js` | 凭据库封套(`ctx.credentials`)+ 旧明文迁移 + 出站白名单与 `safeFetch` |
|
|
60
|
+
|
|
61
|
+
### 二、历史导入(`import.js` + 宿主接线)
|
|
62
|
+
|
|
63
|
+
- **只补「插件不可能记到」的调用**:早于本机最早一条**实时**记录(`source!=='import'`),
|
|
64
|
+
或所在日完全没有实时覆盖(明细 + 日汇总都没有 → 停机缺口);
|
|
65
|
+
- **跨安装点会话按切割线截断**:`min(该会话首条实时记录时刻)` 之后一律不导入,
|
|
66
|
+
与全局安装点取「更早者」,从而既补全安装前那段、又不与实时记录重复;
|
|
67
|
+
- **幂等三保险**:① 清单(`cost-tracker-import.json`)按 mtime+size 快跳未变化日志;
|
|
68
|
+
② 逐调用键 `(sessionId, 事件时刻, 五桶 tokens)` 与已导入明细比对
|
|
69
|
+
——**刻意不含模型名**,因为入账时模型会被路由改写(`deepseek-v4-pro → deepseek-flash`),
|
|
70
|
+
含模型名会导致重跑重复导入;③ 已被实时覆盖的日子宁可不导入也不重复计数;
|
|
71
|
+
- **解析对齐宿主真实格式**:`usage` 取 `assistant/message.data.usage`(按 `(turn, step)`
|
|
72
|
+
去重、最终 message 覆盖流式样本、全零用量即失败尝试不产出);provider/model 取
|
|
73
|
+
`data.message.source`,回落 `request/header.data.header.config`(实测的嵌套形状)
|
|
74
|
+
与 `request/context`;fork 种子段(`time < createdAt`)跳过;标题生成等辅路请求不计;
|
|
75
|
+
- 导入记录标记 `source:'import'`(实时记录 `source:'live'`),覆盖判定只看 live;
|
|
76
|
+
- 默认**开机自动导入**(延迟 8s,`ctx.timer` 缺失时用 unref 的原生定时器,不阻塞退出),
|
|
77
|
+
配置卡可关;新增 Agent 工具 `cost_import`(`run: true` 执行一轮)。
|
|
78
|
+
|
|
79
|
+
### 三、凭据外带防护(`credstore.js` + 全链路接线)
|
|
80
|
+
|
|
81
|
+
- **密钥零落盘**:新增 `CRED_REFS`(`COST_TRACKER_CLOUD_TOKEN` / `COST_TRACKER_VOLCENGINE_SK`),
|
|
82
|
+
云端令牌与火山 SK 只写 DSH 凭据库;`createCredSeam` 在凭据服务缺席时退化为**内存态**
|
|
83
|
+
并如实标注(UI 显示「仅进程内暂存」),绝不为兼容把明文写回配置文件;
|
|
84
|
+
- **启动迁移**:`migrateLegacySecrets()` 把 v1.8.x 明文(含 base64 混淆的 SK)搬进凭据库、
|
|
85
|
+
从配置对象清除并回写净化配置;幂等,凭据库已有值时不覆盖(只提示);
|
|
86
|
+
- **迁移的安全边界**:`save()` 的返回值区分「已持久化」与「只写进了内存」——
|
|
87
|
+
只有凭据库确实可写时才清除配置里的明文;宿主没有凭据服务或凭据只读时,
|
|
88
|
+
明文**原样保留**并在启动日志里说明原因(密钥若只留在内存里,重启后就永久丢了,
|
|
89
|
+
「配置文件零明文」不能以丢凭据为代价),`secretsMigrated` 也只在没有悬而未决的明文时才置位;
|
|
90
|
+
- **状态只给布尔**:`sync` / `volcengine-config` 响应只含 `cloudTokenConfigured` /
|
|
91
|
+
`volcengineHasSecret` / `*Backend` / `secretsMigrated`,**永不回显密钥**;
|
|
92
|
+
- **出站防护**:`safeFetch` 强制 `redirect:'manual'`(3xx 一律失败并点名去向主机,
|
|
93
|
+
防重定向把 `Authorization` 带去别处)、非 loopback 强制 https、携带凭据的请求必须命中
|
|
94
|
+
主机白名单(DeepSeek / Kimi / 火山管控面 / 配置的云端地址 / 定价页主机),
|
|
95
|
+
且白名单校验在**发请求之前**完成;`httpJson`、云端只读聚合、`sync.js`、火山签名请求
|
|
96
|
+
全部改走它(`sync.js` 顺带支持异步 `getToken` 依赖)。
|
|
97
|
+
|
|
98
|
+
### 四、官方价格同步(`price-sync.js` + `pricing.js` 时代注入)
|
|
99
|
+
|
|
100
|
+
- `parsePricingPage`:模型列(`模型` 与 `BASE URL` 之间)× {缓存命中 / 缓存未命中 / 输出}
|
|
101
|
+
× {空闲 / 高峰} 状态机;**校验六组取齐、个数等于模型列数、数值合理、空闲价 ≈ 高峰一半**,
|
|
102
|
+
任一不满足即抛错 —— 页面改版时宁可不同步,也绝不把错价写进账本;
|
|
103
|
+
- 脚注解析「旧模型名 … 仍可调用」得到**路由**(旧名 → 现役名),同时支持脚注分行与整行两种排版;
|
|
104
|
+
- `buildSyncedEra` → `pricing.setSyncedEras()`:同步时代与内置时代按 `since` 取最近生效者
|
|
105
|
+
(同时刻同步时代优先);应用时刻 = 生效时刻,**历史记录按自身时间戳选版,口径不回改**;
|
|
106
|
+
- 产物存 `storages/cost-tracker-prices.json`;每日自动核对(`priceSyncAutoCheck`,默认开)
|
|
107
|
+
只记录差异,应用始终需手动确认(`prices-sync` 传 `apply:true`);
|
|
108
|
+
- 实测价值:内置 `v41pro` 时代把 `deepseek-v4-pro` 路由到 Flash,而官方页已恢复 V4-Pro
|
|
109
|
+
独立牌价(9.0/27.0/0.30 高峰)—— 同步一次即可修正,且不影响历史记录。
|
|
110
|
+
|
|
111
|
+
### 五、多厂商目录与手动覆盖价(`vendor-catalog.js` + `pricing.priceFor` 扩展)
|
|
112
|
+
|
|
113
|
+
- 目录数据改编自 `dsh-cost-meter`(MIT)的已核对官方目录,保留 `sourceUrl` / `checkedAt` 溯源;
|
|
114
|
+
provider 别名归一(`gpt→openai`、`claude→anthropic`、`gemini→google`、`kimi→moonshot`、
|
|
115
|
+
`zhipu/glm/bigmodel→z-ai`、`qwen/dashscope→alibaba` …);
|
|
116
|
+
- 匹配模式 `fuzzy`(默认,归一化包含匹配,长度 ≥4 才参与)| `exact`;跨厂商同名仅在**唯一**时命中;
|
|
117
|
+
- USD→CNY 按 `catalogFxRate`(默认 7.2)折算;缓存写入价 = 缓存命中价(官方口径);
|
|
118
|
+
- `priceFor(np, model, ts, opts)` 新增可选第 4 参(保持 3 参兼容):
|
|
119
|
+
**覆盖价 > 订阅归类 > 内置/同步时代精确价 > 目录 > provider 兜底 > 通用兜底**,
|
|
120
|
+
返回值新增 `source` 字段(`override|plan|synced|exact|catalog|provider|generic`);
|
|
121
|
+
- 订阅归类覆盖(`planOverrides`:`provider/*` 或 `provider/model` → `plan|api`)解决
|
|
122
|
+
「模型 id 带日期后缀、套餐白名单永远追不上」的误标问题。
|
|
123
|
+
|
|
124
|
+
### 六、Plan 与按量双轨 + 「含 Plan 总额」开关(前后端)
|
|
125
|
+
|
|
126
|
+
- 服务端 `buildDashboard` 的 `byDay` 新增每天 `sub`(订阅等值)金额,且**不再跳过订阅记录**;
|
|
127
|
+
- 客户端工具栏新增「含 Plan 总额」开关:关闭(默认)金额卡只显示按量、订阅以附注展示;
|
|
128
|
+
打开则金额 = 按量 + 订阅等值,图表按天并入「订阅等值」段(峰谷图第 4 段、模型图带「(订阅)」后缀);
|
|
129
|
+
- 取值优先级:本机 `localStorage` → 服务端配置;改一次同时写两处(跨设备一致);
|
|
130
|
+
**修掉一个真实缺陷**:原先每次 `sync` 轮询都会用服务端值覆盖用户刚切的口径
|
|
131
|
+
(`localStorage` 被禁用时尤其明显),现在用 state 记录「用户已手动改过」后不再覆盖。
|
|
132
|
+
|
|
133
|
+
### 七、设置集中 + 配置卡片重设计(`client.js`)
|
|
134
|
+
|
|
135
|
+
- `设置 → 插件 → 插件配置 → 花费统计` 成为**唯一**设置入口,七个折叠分组
|
|
136
|
+
(多机汇总 / 峰谷计价与提示 / 订阅套餐与配额 / 计价与价格目录 / 历史导入 / 数据与界面 / 安全与凭据)
|
|
137
|
+
+ 顶部状态摘要条(云端同步 / 已记账 / 待上报 / 上次同步 / 计价时代 / 历史导入 / 金额口径);
|
|
138
|
+
- 约定:**只有「界面显示」三开关勾选即刻生效**,其余分组「改草稿 → 点该组保存」,
|
|
139
|
+
避免误触即写盘;分组折叠只切 CSS 显隐、不卸载内容(展开不重新取数、不丢草稿),
|
|
140
|
+
且不依赖 React 的 `props.children` 注入(配置卡是自绘的,普通函数 + 显式参数更稳);
|
|
141
|
+
- 看板上的「峰谷计价与提示」面板改为**只读**(回显档位与生效配置,保留弹窗预览),
|
|
142
|
+
避免两处都能改造成口径不一致;
|
|
143
|
+
- 新增路由:`billing-config`、`import-config`、`import-status`、`import-run`、
|
|
144
|
+
`prices-config`、`prices-sync`、`reset`;`prices` 回显目录、同步状态与覆盖价;
|
|
145
|
+
`sync` 回显计费/导入/同步配置与凭据布尔。
|
|
146
|
+
|
|
147
|
+
### 八、测试与文档
|
|
148
|
+
|
|
149
|
+
- 新增 4 个测试文件:
|
|
150
|
+
- `test/import.test.js`:用 `zstdCompressSync` 合成**多帧**会话日志,覆盖帧边界扫描、
|
|
151
|
+
截断尾帧、跨帧残行拼接、`(turn,step)` 去重、全零用量丢弃、fork 种子段跳过、
|
|
152
|
+
覆盖判定(安装前 / 跨安装点 / 缺口日 / 已覆盖日)、幂等重跑、日志追加后只补新增,
|
|
153
|
+
以及宿主面 `import-run` / `import-status` 端到端(落库标记、seq、看板读数);
|
|
154
|
+
- `test/price-sync.test.js`:解析正确性(含同行标签、脚注分行、三列对齐)、
|
|
155
|
+
六类脏数据必须抛错、时代生效与历史隔离、差异比对、抓取入口,
|
|
156
|
+
并在本机留存真实抓取页时额外跑一遍真实数据;
|
|
157
|
+
- `test/vendor-catalog.test.js`:目录数据、别名归一、匹配模式、汇率、跨厂商唯一命中、
|
|
158
|
+
以及目录接入 `priceFor` 的优先级与异常回退;
|
|
159
|
+
- `test/credstore.test.js`:封套后端选择、旧明文迁移(含幂等与不覆盖)、
|
|
160
|
+
出站白名单、`safeFetch` 的 3xx 拒绝与头合并;
|
|
161
|
+
- `test/client-render.test.js` 新增「金额口径开关」一节(默认仅按量 → 打开含 Plan → 关回),
|
|
162
|
+
并继续守住「只有 3 个即时提交 checkbox」与卡片分组文案;
|
|
163
|
+
- `test/volcengine-host.test.js` 两处断言按新语义更新:SK 不再落配置文件(改落凭据库)、
|
|
164
|
+
来源标记为 `credentials`;
|
|
165
|
+
- README(中/英)与 CHANGELOG 增补上述能力;`package.json` 登记 4 个新模块与
|
|
166
|
+
`docs/provider-pricing.json`、版本升到 1.9.0。
|
|
167
|
+
|
|
168
|
+
## v1.8.15(2026-09-26)
|
|
169
|
+
|
|
170
|
+
**修复:火山方舟配额面板「没有配置入口」+「拿推理 Key 当 AK」+ 两个失败路径缺陷**
|
|
171
|
+
|
|
172
|
+
真机现场:用户装了 v1.8.14 后,设置页出现「订阅套餐用量 · 火山方舟 Coding Plan」面板,
|
|
173
|
+
但显示 `配额查询不可用:火山方舟凭据无效或无权限访问 GetPersonalPlan(HTTP 401)`,
|
|
174
|
+
且面板上**没有任何可填写凭据的地方** —— 只有一句「需要 AK/SK」,无从下手。
|
|
175
|
+
|
|
176
|
+
### 一、面板自带凭据输入框(用户直接提出的问题)
|
|
177
|
+
|
|
178
|
+
- 面板内新增一行输入:`AccessKeyID`(明文回显,控制台里本就可见)+ `SecretAccessKey`
|
|
179
|
+
(`type=password`,**从不回显**;已保存过时 placeholder 变为「已保存,留空则不改」)。
|
|
180
|
+
- 三个动作:
|
|
181
|
+
- **查询** —— 用输入框里的值直接查一次,**不落盘**,便于先验证凭据对不对;
|
|
182
|
+
- **保存** —— 写入 `~/.dsh/storages/cost-tracker-config.json`,重启不丢;
|
|
183
|
+
- **清除凭据** —— 显式清空(仅在有凭据时出现)。
|
|
184
|
+
- 工具栏新增**「火山方舟配额」按钮**作为入口。此前面板只在「存在火山订阅调用」时渲染,
|
|
185
|
+
新用户既看不到面板、也没有入口 —— 等于功能不存在。
|
|
186
|
+
- 面板标题旁新增来源徽标:`已保存凭据` / `临时凭据` / `环境变量`,一眼看出当前用的是哪套。
|
|
187
|
+
|
|
188
|
+
### 二、修复:推理 API Key 被当成 AccessKeyID(401 的真正根因)
|
|
189
|
+
|
|
190
|
+
配了 baseURL 指向 `ark.cn-beijing.volces.com/api/coding/v3` 的 provider 时,其 `apiKeyEnv`
|
|
191
|
+
(如 `BYTEBLUS_CODING_PLAN_CN_API_KEY`)是**推理用的 API Key**,而配额查询要的是 IAM 的
|
|
192
|
+
`AccessKeyID + SecretAccessKey` —— 两套完全不同的凭据。
|
|
193
|
+
|
|
194
|
+
早先 `volcengineEnvCandidates()` 把这个 apiKeyEnv 也塞进 AK 候选,于是出现跨来源拼凑:
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
AK = BYTEBLUS_CODING_PLAN_CN_API_KEY(推理 Key,UUID 形态)
|
|
198
|
+
SK = VOLC_SECRETKEY(凭据库里的真 SK)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
用这对假凭据去签名,服务端必然 401;而 401 在本插件里是「软失败」,只报「凭据无效或
|
|
202
|
+
无权限」,**根因完全查不出来**(真机上就表现为那一行误导性报错)。
|
|
203
|
+
|
|
204
|
+
现在:
|
|
205
|
+
- AK 与 SK 必须**同源配对** —— 先按候选名取到 AK,再用**同名推导出的** SECRET 变体取 SK,
|
|
206
|
+
绝不跨来源拼接;
|
|
207
|
+
- 用命名识别推理 Key(含 `API_KEY`/`APIKEY`/`TOKEN` 且不含 `ACCESSKEY`/`SECRETKEY`/
|
|
208
|
+
`SECRET`),把这类候选**排除**在 AK 之外,并在提示里点名:
|
|
209
|
+
「你配置的 X 是推理用的 ARK API Key,不是配额凭据,插件不会拿它去签名」;
|
|
210
|
+
- 缺凭据时明确区分「都缺 / 缺 AK / 缺 SK」。
|
|
211
|
+
|
|
212
|
+
### 三、修复:两个失败路径缺陷
|
|
213
|
+
|
|
214
|
+
- **`ReferenceError`(TDZ)把软失败变成 500**:`keyEnv` 原先声明在 `try` 内却在 `catch`
|
|
215
|
+
里引用。任何一次查询失败(401 / 网络异常 / 结构变化)都会在错误处理里再抛一次
|
|
216
|
+
`keyEnv is not defined`,被路由层兜成 **HTTP 500** —— 恰好把所有失败路径都打穿了。
|
|
217
|
+
现声明在 `try` 之外。(由新增的失败路径断言抓到。)
|
|
218
|
+
- **`keyEnv` 永远显示「未知」**:`resolveApiKey()` 只返回 `{ value, source }`,`env` 是
|
|
219
|
+
`resolveAnyEnv()` 才加的字段;误取 `rid.env` 得到 `undefined`,于是面板从不显示
|
|
220
|
+
「该去改哪个环境变量」。现直接用循环变量名。
|
|
221
|
+
|
|
222
|
+
### 四、防呆:空串不等于清空
|
|
223
|
+
|
|
224
|
+
因为 SK 从不回显,跨浏览器 / 重开面板时 SK 输入框**必然是空的**。若把空串当作「清空」,
|
|
225
|
+
用户只改一下 AK 就会把已存好的 SK 一起写空 —— 静默丢凭据。现在:
|
|
226
|
+
|
|
227
|
+
| 请求 | 行为 |
|
|
228
|
+
| --- | --- |
|
|
229
|
+
| `{volcengineAccessKeyId:'新AK'}` | 只改 AK,**SK 原样保留** |
|
|
230
|
+
| `{volcengineSecretAccessKey:'新SK'}` | 只改 SK |
|
|
231
|
+
| `{volcengineAccessKeyId:'', volcengineSecretAccessKey:''}` | **不动**(空串不是指令) |
|
|
232
|
+
| `{clear:true}` | 显式清空两者 |
|
|
233
|
+
|
|
234
|
+
响应回显 `volcengineAccessKeyId`(非敏感)与 `volcengineHasKeys`,**永不回显 SK**。
|
|
235
|
+
|
|
236
|
+
### 五、测试
|
|
237
|
+
|
|
238
|
+
`test/volcengine-host.test.js` 从 36 条扩到 **48 条**,新增四组:
|
|
239
|
+
推理 Key 不得被当作 AK(真实故障回归,复刻用户的 provider 配置)/ 空串不覆盖已存 SK /
|
|
240
|
+
只改 AK 后仍可用 / `clear` 才清空。全量测试通过。
|
|
241
|
+
|
|
5
242
|
## v1.8.14(2026-09-26)
|
|
6
243
|
|
|
7
244
|
**新增:火山方舟 Coding Plan 订阅支持(配额监控 + 等效费用);并修掉两个此前静默存在的缺陷**
|
package/README.en.md
CHANGED
|
@@ -42,6 +42,11 @@
|
|
|
42
42
|
| 🔻 | **Status line** | A live line under the chat input: **session cost** (segmented pills: session / subscription plan / per-model), split by the models actually used in the session; multi-model collapses to top2 by default, click to expand. Subscription shows the plan name; no quota or call-count clutter |
|
|
43
43
|
| 🔥 | **Usage heatmap** | A "Token Usage" panel in Settings: a Codex-style **26-week daily-usage grid**, colored per-day by input / cache / output / cost with hover details and a today outline; all-time totals shown on top |
|
|
44
44
|
| 💾 | **Local persistence** | Data lives in `~/.dsh/storages/cost-tracker-records.json`; survives restarts, never leaves your machine. **Details are kept for the last 180 days; older records are auto-compressed into permanent daily rollups, so all-time stats stay exact with bounded memory/disk** |
|
|
45
|
+
| 🕰️ | **History import (v1.9.0)** | Replays host session logs to **backfill calls made before you installed the plugin** (each priced by its own timestamp); only calls the plugin could not have recorded (pre-install / downtime gaps); idempotent, and imported records are tagged `source=import` |
|
|
46
|
+
| 🔄 | **Official price sync (v1.9.0)** | Fetches the official pricing page, parses each model's peak price and shows the diff; applying builds a **new pricing era** that only affects later records (history never shifts). The daily check only reports diffs and never auto-applies; a restructured page aborts instead of writing a wrong price |
|
|
47
|
+
| 🌐 | **Multi-vendor price catalog (v1.9.0)** | 14 vendors / 90 entries (USD→CNY at a configurable rate), so models outside the built-in table (OpenAI / Anthropic / Gemini / Qwen …) get **exact** prices; fuzzy or exact matching plus manual price overrides |
|
|
48
|
+
| ⚖️ | **Plan vs metered dual basis (v1.9.0)** | One "Include Plan total" switch changes the basis: off = metered spend only, with subscriptions shown as a footnote; on = metered + subscription equivalent, merged into the charts as its own segment |
|
|
49
|
+
| 🔐 | **No plaintext secrets (v1.9.0)** | The cloud token and the Volcengine secret live only in the DSH credential store (legacy plaintext migrates on startup); responses only report booleans; every outbound request goes through a host allowlist with forced https and no cross-host redirects |
|
|
45
50
|
| 📤 | **CSV export** | One-click export of details + daily rollups (`purpose=rollup`) for further analysis in Excel / Numbers |
|
|
46
51
|
|
|
47
52
|
## Screenshots
|
|
@@ -120,6 +125,20 @@ dsh web
|
|
|
120
125
|
|
|
121
126
|
> ⚠️ If `~/.dsh/profiles/web/cordis.patch.yml` already contains entries, keep them and only append the block above; the file's top level must remain a YAML array.
|
|
122
127
|
|
|
128
|
+
> ⚠️ **On a machine where this plugin was installed from the marketplace, never upgrade by copying files by hand** (a real trap hit in v1.9.1):
|
|
129
|
+
> DSH profiles manage plugins with pnpm (`~/.dsh/profiles/web/package.json` records
|
|
130
|
+
> `"@angelyeye/dsh-cost-tracker": "^1.8.15"`), so on the next start the marketplace
|
|
131
|
+
> reconciliation **reinstalls the pinned older version and overwrites your files** — the
|
|
132
|
+
> symptom is "upgraded, restarted, and it is the old version again".
|
|
133
|
+
> For those machines, link the checkout into the profile instead (survives restarts, and a
|
|
134
|
+
> restart picks up your edits):
|
|
135
|
+
>
|
|
136
|
+
> ```bash
|
|
137
|
+
> dsh plugin --profile web add link:/path/to/dsh-cost-tracker
|
|
138
|
+
> ```
|
|
139
|
+
>
|
|
140
|
+
> For released versions just upgrade normally: `dsh plugin --profile web update` (or the marketplace's update button).
|
|
141
|
+
|
|
123
142
|
### Migrating from the old package name (only installs of v1.6.0 or older)
|
|
124
143
|
|
|
125
144
|
As of v1.7.0 the package name changed from `dsh-cost-tracker` to `@angelyeye/dsh-cost-tracker` — the old name is held on npm by an unrelated package, and the marketplace's npm mapping requires the published name to equal the repository's `package.json` `name`.
|
|
@@ -171,6 +190,7 @@ rm -rf ~/.dsh/profiles/node_modules/dsh-cost-tracker
|
|
|
171
190
|
| `cost_prices` | Show the built-in price table & peak rules | "What does deepseek-v4-flash cost right now?" |
|
|
172
191
|
| `cost_peak` | Show the current peak tier & next-switch countdown | "Is it peak hour right now?" |
|
|
173
192
|
| `cost_recompute` | **Re-price stored records by pricing era (one-off backfill)**, dry-run by default | "Re-price the records from before the price change" |
|
|
193
|
+
| `cost_import` | **History import**: show status / run one backfill pass (calls from before the plugin was installed) | "Include what I spent before I installed the plugin" |
|
|
174
194
|
| `cost_sync` | **Cloud sync**: status / sync now / test connection / update config | "Sync my usage to the cloud" · "Is cloud sync healthy?" |
|
|
175
195
|
| `cost_reset` | **Erase ALL statistics (irreversible)** | "Reset my cost statistics" |
|
|
176
196
|
|
|
@@ -228,6 +248,46 @@ Don't want the plugin in your face? **Settings → Plugins → Plugin configurat
|
|
|
228
248
|
- Truth value is "hidden only on an explicit `false`", so a missing key means visible: **an existing config file looks exactly the same after upgrading**;
|
|
229
249
|
- All three keys live in the same `~/.dsh/storages/cost-tracker-config.json` (`uiDockEnabled` / `uiPeakEnabled` / `uiDashboardEnabled`) and never overwrite the peak/cloud fields.
|
|
230
250
|
|
|
251
|
+
### Plugin configuration card (v1.9.0 redesign: the single place for every setting)
|
|
252
|
+
|
|
253
|
+
**Settings → Plugins → Plugin configuration → Cost Tracker** now carries **all** settings, laid out as collapsible groups under a status strip (cloud sync / records stored / pending / last sync / pricing era / history import / amount basis):
|
|
254
|
+
|
|
255
|
+
| Group | Contents |
|
|
256
|
+
| --- | --- |
|
|
257
|
+
| **Multi-machine aggregation (cloud sync)** | device name, enable switch, service URL, shared token, interval, batch size, session masking, purpose, rollup upload, backfill window, default view + Save / Test / Sync now / Full re-send + device id / watermark / last error |
|
|
258
|
+
| **Peak/off-peak pricing & notices** | peak switch, prominent notice, strip style (compact / dial), tick labels / two-line compact, switch alerts (lead time / target / position / web notification) + **live preview** while editing |
|
|
259
|
+
| **Subscriptions & quotas** | Volcengine Ark `AccessKeyID` / `SecretAccessKey` (the secret goes to the credential store only), quota query with percentage bars, **subscription classification overrides** (`provider/*` or `provider/model` → plan / pay-as-you-go) |
|
|
260
|
+
| **Pricing & price catalog** | "Include Plan total" switch, catalog match mode (fuzzy / exact), USD→CNY rate, **manual price overrides**, **official price sync** (check / apply / last diff / current era / synced eras), **multi-vendor catalog overview** (vendors, entries, data date, fingerprint) |
|
|
261
|
+
| **History import** | auto-import switch, import now, totals and processed log count, the three coverage rules |
|
|
262
|
+
| **Data & interface** | the three interface-visibility switches (instant), CSV export, cost recompute (dry-run / write back), clear data (two-step confirm) |
|
|
263
|
+
| **Security & credentials** | "configured + storage location" badges for the cloud token and Volcengine secret, legacy plaintext migration state, clear buttons, egress-protection notes |
|
|
264
|
+
|
|
265
|
+
Only the three interface switches apply instantly; every other group is "edit draft → save that group", so a stray click can never write to disk. Collapsing a group only toggles CSS visibility (nothing unmounts), so opening one never refetches data or loses your draft.
|
|
266
|
+
|
|
267
|
+
### History import (v1.9.0)
|
|
268
|
+
|
|
269
|
+
Conversations from **before you installed the plugin** can be backfilled: the plugin replays the host session logs (`$DSH_HOME/sessions/<project>/<session>/session.v3.jsonl.zstd`, decompressed frame by frame — the host appends one zstd frame per batch) and books each model call at the price era of **its own timestamp**.
|
|
270
|
+
|
|
271
|
+
- **Auto-import on startup** by default (8 s delay, never blocks the boot), with an "Import now" button and an `autoImport` switch;
|
|
272
|
+
- **Only calls the plugin could not have recorded**: earlier than this machine's first live record, or on a day with no live coverage at all (downtime gaps);
|
|
273
|
+
- Sessions straddling the install point are cut at that session's first live record: the earlier part is backfilled, the later part stays live-recorded;
|
|
274
|
+
- **Idempotent three ways**: a manifest fast-skips unchanged logs by mtime+size; every call is deduped by `(sessionId, timestamp, five token buckets)`; days already covered by live data are skipped rather than double-counted;
|
|
275
|
+
- Imported records are tagged `source=import` (live ones are `source=live`); forked sessions only count events after `createdAt`, and auxiliary requests (title generation) never produce records.
|
|
276
|
+
|
|
277
|
+
### Official price sync & multi-vendor catalog (v1.9.0)
|
|
278
|
+
|
|
279
|
+
- **Official price sync**: "Check official prices" fetches the official pricing page (the Chinese page gives CNY directly), parses each model's peak price and diffs it against the currently effective table; "Apply new prices" turns the result into a **new pricing era** that only affects records at or after the apply moment — history keeps its own era, so past numbers never shift. A daily automatic check (on by default) only reports diffs and **never auto-applies**. The parser refuses to write anything on page restructures, missing numbers, or an off-peak price that is not exactly half the peak price;
|
|
280
|
+
- **Multi-vendor price catalog**: 14 vendors / 90 model entries (OpenAI, Anthropic, Google, Moonshot, z-ai, xAI, Alibaba, MiniMax, Tencent, Xiaomi, Upstage, NVIDIA, Mistral, OpenCode; data adapted from `dsh-cost-meter`'s verified catalog, MIT), converted with a configurable USD→CNY rate (default 7.2). Models outside the built-in table are billed as **exact** prices instead of "estimated"; fuzzy (normalized containment) or exact matching;
|
|
281
|
+
- **Manual price overrides** per `provider/model` (input / output / cache) take the highest priority — for self-hosted endpoints or negotiated deals;
|
|
282
|
+
- **Resolution order**: manual override > subscription classification > built-in / synced era > catalog > provider fallback > generic fallback. `cost_prices` and `/api/cost-tracker/prices` report the current era, synced eras, catalog fingerprint and overrides;
|
|
283
|
+
- The cloud service (`dsh-cost-cloud ≥ v1.4.0`) implements the same rules with its own admin endpoints, and `/api/v1/protocol` reports which price version the cloud is actually using.
|
|
284
|
+
|
|
285
|
+
### Credential safety (v1.9.0)
|
|
286
|
+
|
|
287
|
+
- **No secrets on disk**: the cloud shared token and the Volcengine `SecretAccessKey` live only in the DSH credential store (`~/.dsh/.credentials.yaml`); the config file keeps nothing but a boolean. Plaintext left behind by v1.8.x (including the base64-obfuscated secret) is **migrated automatically** on startup and removed from the config (idempotent; an existing credential-store value is never overwritten). **Safety boundary**: plaintext is only removed when the credential store is actually writable — if the host exposes no credential service (or a read-only one), the plaintext is **kept as is** with a startup notice, because a secret that only lives in memory is gone after a restart;
|
|
288
|
+
- **No response ever echoes a secret**: status endpoints return only booleans plus the storage location (credential store / process memory). `AccessKeyID` is a non-sensitive identifier and is echoed so the form can be pre-filled;
|
|
289
|
+
- **Egress protection**: any request carrying credentials must match the host allowlist (DeepSeek / Kimi / Volcengine control plane / your configured cloud URL / the pricing page host), non-loopback hosts must use https, and `redirect: 'manual'` is forced — any 3xx is treated as a failure so a redirect can never carry the `Authorization` header elsewhere.
|
|
290
|
+
|
|
231
291
|
### HTTP API (for other tools)
|
|
232
292
|
|
|
233
293
|
All endpoints are `POST` + JSON and listen on the loopback address:
|
|
@@ -248,8 +308,15 @@ POST /api/cost-tracker/kimi-usage Kimi subscription quota
|
|
|
248
308
|
POST /api/cost-tracker/volcengine-usage Volcengine Ark Coding Plan quota (5-hour / weekly / monthly windows)
|
|
249
309
|
POST /api/cost-tracker/volcengine-config Save Volcengine AK/SK (reports only whether keys are configured, never the keys)
|
|
250
310
|
POST /api/cost-tracker/balance Account balance
|
|
251
|
-
POST /api/cost-tracker/prices Price table (
|
|
311
|
+
POST /api/cost-tracker/prices Price table (by pricing era + synced eras + multi-vendor catalog + overrides)
|
|
252
312
|
POST /api/cost-tracker/recompute Re-price stored records by era (dry-run unless {"apply":true})
|
|
313
|
+
POST /api/cost-tracker/billing-config Billing basis & catalog config (amount basis / plan overrides / match & fx / price overrides)
|
|
314
|
+
POST /api/cost-tracker/prices-sync Official price sync (dry-run unless {"apply":true})
|
|
315
|
+
POST /api/cost-tracker/prices-config Price-sync settings (pricing page URL / daily auto-check)
|
|
316
|
+
POST /api/cost-tracker/import-status History-import status
|
|
317
|
+
POST /api/cost-tracker/import-run Run one history-import pass (idempotent)
|
|
318
|
+
POST /api/cost-tracker/import-config History-import settings (auto-import on startup)
|
|
319
|
+
POST /api/cost-tracker/reset Clear every record (called after the card's two-step confirm)
|
|
253
320
|
POST /api/cost-tracker/export CSV export
|
|
254
321
|
```
|
|
255
322
|
|
|
@@ -261,6 +328,39 @@ Example: `curl -X POST http://127.0.0.1:3080/api/cost-tracker/summary -d '{}'`
|
|
|
261
328
|
|
|
262
329
|
> Highlights only — the full version-by-version history lives in [`CHANGELOG.md`](./CHANGELOG.md) (Chinese).
|
|
263
330
|
|
|
331
|
+
### v1.9.1 (2026-09-20)
|
|
332
|
+
|
|
333
|
+
**Fixed: cloud sync failed with "method not allowed" (405) — `safeFetch` dropped the native fetch signature, turning every POST into a GET**
|
|
334
|
+
|
|
335
|
+
- The reverse-proxy log showed the plugin sending `GET /api/v1/ingest/records` (it must be POST) → the cloud answered 405, so sync was dead and the watermark never advanced;
|
|
336
|
+
- Root cause: `index.js` passed `safeFetch` where a `<typeof fetch>` was expected — `(url, init) => safeFetch(url, {...init})` — while `safeFetch` only read `opts.init`, so `method` / `body` / `content-type` were all dropped. It now accepts **both shapes** (`opts.init` wins), with the security policy unchanged;
|
|
337
|
+
- Two regression guards, because neither unit-testing `safeFetch` nor unit-testing the engine catches a composition bug: a unit case that reproduces index.js's exact wiring, and an integration case that runs a full `runOnce` through it and asserts a real POST;
|
|
338
|
+
- Also fixed: when the credential service becomes available *after* the plugin (so the first migration attempt safely kept the plaintext), a `ctx.inject(['credentials'])` retry now completes the migration instead of leaving `secretsMigrated` false forever;
|
|
339
|
+
- Install note: see the warning under "Verify it works" — copying files into a pnpm-managed profile gets reverted on restart; use `dsh plugin --profile web add link:<checkout>` for development.
|
|
340
|
+
|
|
341
|
+
### v1.9.0 (2026-09-27)
|
|
342
|
+
|
|
343
|
+
**Five new capabilities, all settings unified into the plugin-config card, and zero plaintext secrets (pairs with `dsh-cost-cloud` v1.4.0)**
|
|
344
|
+
|
|
345
|
+
- **History import** — replays the host session logs (many appended zstd frames, decompressed frame by frame) to backfill calls from **before the plugin was installed**. Idempotent three ways (manifest fast-skip, per-call dedup key, coverage rule), sessions straddling the install point are cut at the first live record, and imported records are tagged `source=import`. Auto-runs on startup (8 s delay, never blocks the boot); new agent tool `cost_import`;
|
|
346
|
+
- **Credential-egress protection** — the cloud token and the Volcengine secret are written only to the DSH credential store (the config file keeps a boolean), legacy plaintext is migrated automatically on startup, and every outbound request goes through an allowlist with forced https and `redirect:'manual'` (3xx is a failure, so a redirect can never carry the `Authorization` header away). No response ever echoes a secret;
|
|
347
|
+
- **Official price sync** — parses the official pricing page (a transposed table: columns are models, rows are metric × time band) into a new pricing era that only affects records at or after the apply moment, so history never shifts. Page restructures, missing numbers or an off-peak price that is not half the peak price all abort the sync instead of writing a wrong price. The daily automatic check only reports diffs;
|
|
348
|
+
- **Multi-vendor price catalog** — 14 vendors / 90 entries (USD per 1M tokens, converted at a configurable rate), so models outside the built-in table get **exact** prices instead of "estimated"; fuzzy/exact matching plus a manual price-override table;
|
|
349
|
+
- **Plan vs metered dual basis + "Include Plan total" switch** — one toolbar switch decides whether the money cards and charts show metered spend only (subscriptions shown as a footnote) or metered + subscription equivalent (a dedicated "subscription equivalent" chart segment). The choice is stored locally and written back to the server config;
|
|
350
|
+
- **Settings unified + card redesign** — **Settings → Plugins → Plugin configuration → Cost Tracker** is now the single entry point, with seven collapsible groups (multi-machine aggregation / peak pricing & notices / subscriptions & quotas / pricing & catalog / history import / data & interface / security & credentials) under a status strip; the dashboard's peak panel became read-only;
|
|
351
|
+
- **Tests** — four new files (`test/import.test.js` synthesises multi-frame zstd logs, `test/price-sync.test.js` also runs against a real fetched page, `test/vendor-catalog.test.js`, `test/credstore.test.js`), plus new client-render assertions for the amount-basis switch and the card groups: 17 test files, all green.
|
|
352
|
+
|
|
353
|
+
### v1.8.15 (2026-09-26)
|
|
354
|
+
|
|
355
|
+
**Fixed: the Volcengine quota panel had no place to enter credentials, and an inference API key was being used as the AccessKeyID**
|
|
356
|
+
|
|
357
|
+
- **The panel now has its own credential inputs (the main fix).** Previously credentials could only be set through the plugin-config card or by hand-writing environment variables — the panel itself offered **nowhere to type**, so users saw only "credentials invalid" with no way forward. It now provides `AccessKeyID` / `SecretAccessKey` fields plus three actions: **Query** (verifies without persisting), **Save** (persists to disk) and **Clear**. The AccessKeyID is echoed back for confirmation; the SecretAccessKey is never echoed (when one is stored, the field hints "leave blank to keep"). A **"Volcengine quota"** button was added to the toolbar as an entry point — otherwise the panel stays hidden by default and users can never reach it.
|
|
358
|
+
- **Fixed: an inference API key was being used as the AccessKeyID — the real cause of the 401s.** When a provider's baseURL points at the Ark coding endpoint, its `apiKeyEnv` is an **inference** API key, while quota queries need an IAM `AccessKeyID + SecretAccessKey`. The old discovery chain fed that value into the AK candidates, producing a cross-source Frankenstein pair (inference key as AK + an unrelated SK from the credential file). Signing with it always returns 401, and a 401 is a *soft failure* here, so the plugin only reported "credentials invalid or no permission" — the root cause was undiagnosable. Now AK and SK must come from the **same source**; inference keys are recognised by name (`API_KEY`/`TOKEN` without `ACCESSKEY`/`SECRETKEY`) and excluded; and the message explicitly names the offending variable as an inference key.
|
|
359
|
+
- **Fixed: a `ReferenceError` (TDZ) turned soft failures into HTTP 500.** `keyEnv` was declared inside `try` but referenced in `catch`, so *every* failure path (401 / network error / changed shape) threw again during error handling and surfaced as a 500. It is now declared outside.
|
|
360
|
+
- **Fixed: `keyEnv` always showed "unknown"** — `resolveApiKey()` returns `{value, source}` only, and `env` is added by `resolveAnyEnv()`, so the panel never told you which environment variable to fix.
|
|
361
|
+
- **Safety: an empty string no longer clears a stored secret.** Because the secret is never echoed, its field is necessarily blank whenever the panel is reopened; treating that as "clear" would silently wipe a stored secret the moment someone edited only the AK. Only a **non-empty** secret overwrites, and clearing requires an explicit `clear:true`.
|
|
362
|
+
- Tests: `test/volcengine-host.test.js` grew to **48 assertions**, adding four groups: inference keys must not be treated as AKs (a regression test replicating the real provider config), an empty string must not overwrite a stored secret, editing only the AK still works, and only `clear` clears.
|
|
363
|
+
|
|
264
364
|
### v1.8.14 (2026-09-26)
|
|
265
365
|
|
|
266
366
|
**New: Volcengine Ark Coding Plan support (quota monitoring + equivalent cost)**
|
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
| --- | --- | --- |
|
|
31
31
|
| 💰 | **花费统计** | 每一次 API 调用自动记账:输入 / 输出 / 缓存命中 / 缓存写入 Tokens 与费用(缓存写入按缓存命中价计),按天、按模型聚合 |
|
|
32
32
|
| ⏰ | **峰谷定价** | 内置单价表,高峰时段(北京时间周一至周五 9:00–12:00、14:00–18:00)与闲时半价自动区分,**周末全天计为闲时**,本地模型(ollama 等)计 0;**单价表按「计费时代」分版**,北京时间 2026-09-10 12:00 起自动切换为 V4.1 Flash 新价(2.0 / 0.04 / 8.0 高峰),并按官方规则把旧 V4-Flash 系请求路由到 V4.1 Flash 计费;**V4-Pro 自 2026-09-14 12:00 起才路由**(此前仍按自有牌价 9.0 / 27.0 / 0.30) |
|
|
33
|
-
| 🔔 | **峰谷计价提示** |
|
|
33
|
+
| 🔔 | **峰谷计价提示** | **设置 → 插件 → 插件配置 → 花费统计 → 峰谷计价与提示**(v1.9.0 起设置集中在此,改完即可预览):当前档位/距下次切换倒计时时段条、样式切换(**简洁单行·按24h比例** / **环形表盘·相位色点**)、简洁样式可选**双行紧凑**(上下布局,条上文下/文上条下)、「显示时间」开关、峰/谷切换前弹窗提醒与浏览器系统通知、提前提醒分钟、弹窗位置(右下角/屏幕中心)、提醒类型;侧边栏底部常驻显示时段条(窄栏/展开自适应)。看板上的同名面板改为只读回显 |
|
|
34
34
|
| 📌 | **六组概览卡** | 设置页顶部六张卡:今日费用 / 本月费用 / 总花费 / API 请求次数 / Tokens / **总余额**。前三个金额卡**不含订阅会员等效费用**,订阅以附注展示 |
|
|
35
35
|
| 👁️ | **视觉模型** | 支持 `deepseek-v4-flash-vision-exp`:legacy 时代单价与 flash 一致,2026-09-10 12:00 起随 V4.1 Flash 新价计费(该旧名已下线,请求由 V4.1 Flash 提供);图片按官方规则换算 token(每张上限 384 个,以接口用量计费) |
|
|
36
36
|
| 🏷️ | **官方模型名对齐** | 计费支持**官方现役名 `deepseek-flash`**(价格卡脚注 (1):「模型名请使用 `deepseek-flash`」),旧写法 `deepseek-v4.1-flash` 等归一化后命中同一档价,避免因官方改名而落入兜底估算 |
|
|
@@ -43,6 +43,11 @@
|
|
|
43
43
|
| 🔻 | **状态栏** | 聊天输入框下方实时显示:**本会话花费**(胶囊分段:本会话 / 订阅套餐 / 分模型),按会话实际用到的模型与订阅拆分,**多模型默认折叠只显示 top2,点击展开全部明细**;订阅显示具体套餐名,不再展示配额与调用次数 |
|
|
44
44
|
| 👁️ | **界面显示开关** | 输入框上方的花费胶囊、侧边栏峰谷时段条、设置页「花费统计」看板**三个落点各自可关**(设置 → 插件 → 插件配置 → 花费统计 → 界面显示),勾选即刻生效;**只影响显示**,记账、云端同步与 Agent 工具照常,配置卡片本身不受开关控制 |
|
|
45
45
|
| 💾 | **本地持久化** | 数据存本机 `~/.dsh/storages/cost-tracker-records.json`,重启不丢、不上传;**明细保留最近 180 天,更早自动压缩为永久日汇总,全时段统计永远精确且内存/磁盘有界** |
|
|
46
|
+
| 🕰️ | **历史导入(v1.9.0)** | 回放宿主会话日志,**把装插件之前的对话调用补录进账本**(按各自时间戳的旧价计费);只补插件不可能记到的部分(安装前 / 停机缺口),幂等可重复执行,导入记录标记 `source=import` 以便区分 |
|
|
47
|
+
| 🔄 | **官方价格同步(v1.9.0)** | 一键抓取官方定价页、解析各模型峰价并对比差异,应用后构建**新的计费时代**(只影响之后,历史口径不回改);每日可自动核对(只提示、不自动应用),页面改版时宁可不同步也绝不写错价 |
|
|
48
|
+
| 🌐 | **多厂商价格目录(v1.9.0)** | 内置 14 家厂商 / 90 个模型条目(USD→CNY 按可配汇率折算),OpenAI / Anthropic / Gemini / Qwen 等内置表之外的模型也能按**精确价**入账;支持宽松/严格匹配与**手动覆盖价** |
|
|
49
|
+
| ⚖️ | **Plan 与按量双轨(v1.9.0)** | 工具栏「含 Plan 总额」开关一键切换口径:关闭只算按量真金白银、订阅以附注展示;打开则金额 = 按量 + 订阅等值,图表按天并入「订阅等值」段 |
|
|
50
|
+
| 🔐 | **凭据零落盘(v1.9.0)** | 云端令牌与火山 SecretAccessKey 只写 DSH 凭据库(配置文件零明文,旧版明文启动时自动迁移);任何响应只回显布尔;出站请求白名单 + 强制 https + 拒绝跟随重定向(防凭据外带) |
|
|
46
51
|
| 📤 | **CSV 导出** | 一键导出明细 + 日汇总(purpose=rollup),方便用 Excel / Numbers 做进一步分析 |
|
|
47
52
|
|
|
48
53
|
## 界面展示
|
|
@@ -59,6 +64,8 @@
|
|
|
59
64
|
|
|
60
65
|

|
|
61
66
|
|
|
67
|
+
> 📸 截图取自 v1.8.x 的看板;v1.9.0 起工具栏多了「含 Plan 总额」开关、插件配置卡片改为七个折叠分组(见「插件配置卡片」一节),概览卡与图表本身不变。
|
|
68
|
+
|
|
62
69
|
---
|
|
63
70
|
|
|
64
71
|
## 安装(三选一)
|
|
@@ -121,6 +128,18 @@ dsh web
|
|
|
121
128
|
|
|
122
129
|
> ⚠️ 如果 `~/.dsh/profiles/web/cordis.patch.yml` 里已有其他内容,请保留原有行,只追加上面那段;该文件顶层必须是 YAML 数组(每行以 `- ` 开头)。
|
|
123
130
|
|
|
131
|
+
> ⚠️ **插件市场安装过本插件的机器,不要用「手动拷文件」升级**(v1.9.1 的真实踩坑):
|
|
132
|
+
> profile 用 pnpm 管理插件(`~/.dsh/profiles/web/package.json` 里记着
|
|
133
|
+
> `"@angelyeye/dsh-cost-tracker": "^1.8.15"`),下次启动时市场对账会**按依赖重装回旧版**,
|
|
134
|
+
> 你拷进去的新文件会被覆盖 —— 现象是"升级了、重启后又变回旧版本"。
|
|
135
|
+
> 这类机器请用官方 dev 流程把目录**链接**进 profile(重启不会丢,改代码重启即生效):
|
|
136
|
+
>
|
|
137
|
+
> ```bash
|
|
138
|
+
> dsh plugin --profile web add link:/path/to/dsh-cost-tracker
|
|
139
|
+
> ```
|
|
140
|
+
>
|
|
141
|
+
> 发布版本则走正常升级:`dsh plugin --profile web update`(或市场里点更新)。
|
|
142
|
+
|
|
124
143
|
### 从旧包名迁移(仅 v1.6.0 及更早的安装需要)
|
|
125
144
|
|
|
126
145
|
v1.7.0 起包名由 `dsh-cost-tracker` 改为 `@angelyeye/dsh-cost-tracker` —— 因为 npm 上原名已被他人占用,而市场的 npm 映射要求「已发布的包名 = 仓库 `package.json` 的 `name`」。
|
|
@@ -161,7 +180,8 @@ rm -rf ~/.dsh/profiles/node_modules/dsh-cost-tracker
|
|
|
161
180
|
- **配色切换**:「按模型」视图下,消费金额标题旁有三套装色款条(橙→黄 / 蓝→紫 / 蓝→浅蓝)可切换;模型按总消费降序排名取色(第 1 名最深夜底、逐级变浅,不循环不撞色),选择保存在浏览器本地;
|
|
162
181
|
- **分模型区块**:每个模型一张请求次数图 + 一张 Tokens 构成图(输入/缓存写入/输出/缓存命中);
|
|
163
182
|
- **Token 用量统计热力图**:类 Codex 的 26 周每日用量方格,颜色深浅按当日 token 相对最大值分档;悬停任一格看该日明细(输入 / 缓存 / 输出 / 费用),今天高亮描边;**口径跟随三态开关**:「本机」只统计本机,「本机+云端」把云端按天用量并入(与上方卡片同一并集口径、不重复计数),「仅云端」只看云端,标题右侧标注当前口径。云端按天明细需要 `dsh-cost-cloud ≥ v1.3.2`,旧云端下自动退回本机口径;
|
|
164
|
-
- **峰谷计价与提示**:时段条样式可选(**简洁单行·按 24h 比例**(白色实时进度线) / **环形表盘·相位色点**),简洁样式可选**双行紧凑**(条上文下 / 文上条下),可开关「显示时间」刻度(00:00–21:00),设置峰/谷切换前的弹窗提醒提前量(1–30 分钟)、提醒类型(两者 / 进入高峰 / 进入闲时)、弹窗位置(右下角 / 屏幕中心)
|
|
183
|
+
- **峰谷计价与提示**:时段条样式可选(**简洁单行·按 24h 比例**(白色实时进度线) / **环形表盘·相位色点**),简洁样式可选**双行紧凑**(条上文下 / 文上条下),可开关「显示时间」刻度(00:00–21:00),设置峰/谷切换前的弹窗提醒提前量(1–30 分钟)、提醒类型(两者 / 进入高峰 / 进入闲时)、弹窗位置(右下角 / 屏幕中心)与浏览器系统通知。**v1.9.0 起这些设置统一在「设置 → 插件 → 插件配置 → 花费统计 → 峰谷计价与提示」里改**(看板上的同名面板改为只读回显,只保留弹窗预览);侧边栏底部常驻时段条显示当前档位与下次切换倒计时;
|
|
184
|
+
- **含 Plan 总额开关(v1.9.0)**:工具栏右侧一个开关,决定金额卡与图表的口径 —— 关闭(默认)只算按量真金白银、订阅以附注展示;打开则金额 = 按量 + 订阅等值,图表按天并入「订阅等值」一段。选择存浏览器本地并回写服务端配置(跨设备一致);
|
|
165
185
|
- **导出 CSV**:导出明细记录(近 180 天)+ 日汇总行(`purpose=rollup`)。
|
|
166
186
|
|
|
167
187
|
### 对话中的 Agent 工具
|
|
@@ -172,6 +192,7 @@ rm -rf ~/.dsh/profiles/node_modules/dsh-cost-tracker
|
|
|
172
192
|
| `cost_prices` | 查看内置单价表与峰谷规则 | "现在 deepseek-v4-flash 什么价?" |
|
|
173
193
|
| `cost_peak` | 查询当前峰谷档位与下次切换倒计时 | "现在是不是高峰时段?" |
|
|
174
194
|
| `cost_recompute` | **按计费时代重算已入库记录的费用(一次性补账)**,默认只试算 | "把价格调整前的记录按新价重算一下" |
|
|
195
|
+
| `cost_import` | **历史导入**:查看导入状态 / 执行一轮(补录装插件之前的对话) | "把装插件之前的花费也统计进来" |
|
|
175
196
|
| `cost_sync` | **云端同步**:查看状态 / 立即同步 / 测试连接 / 改配置 | "把花费同步到云端" · "云端同步正常吗?" |
|
|
176
197
|
| `cost_reset` | **清空全部统计数据(不可恢复)** | "把花费统计清零" |
|
|
177
198
|
|
|
@@ -229,6 +250,46 @@ docker compose up -d # 打开 http://<服务器>:8787 ,在「设置」页
|
|
|
229
250
|
- 取值为「只有显式 `false` 才隐藏」,缺省即显示。老配置文件里没有这几个键,**升级后界面与升级前一致**;
|
|
230
251
|
- 落盘在同一份 `~/.dsh/storages/cost-tracker-config.json`(键名 `uiDockEnabled` / `uiPeakEnabled` / `uiDashboardEnabled`),与峰谷、云端字段互不覆盖。
|
|
231
252
|
|
|
253
|
+
### 插件配置卡片(v1.9.0 重设计:全部设置的唯一入口)
|
|
254
|
+
|
|
255
|
+
**设置 → 插件 → 插件配置 → 花费统计** 现在承载**全部**设置,按折叠分组排列,顶部一条状态摘要(云端同步 / 已记账条数 / 待上报 / 上次同步 / 计价时代 / 历史导入 / 金额口径):
|
|
256
|
+
|
|
257
|
+
| 分组 | 内容 |
|
|
258
|
+
| --- | --- |
|
|
259
|
+
| **多机汇总(云端同步)** | 设备名、启用开关、服务地址、共享令牌、同步间隔、单批条数、会话脱敏、上报 purpose、上报日汇总、补传窗口、默认视图 + 保存 / 测试连接 / 立即同步 / 全量补传 + 设备 ID / 水位 / 最近错误 |
|
|
260
|
+
| **峰谷计价与提示** | 峰谷开关、显著提示、时段条样式(简洁 / 环形表盘)、时间刻度 / 双行紧凑、切换提醒(提前量 / 类型 / 位置 / 系统通知)+ **改完即可预览**(时段条与弹窗预览) |
|
|
261
|
+
| **订阅套餐与配额** | 火山方舟 `AccessKeyID` / `SecretAccessKey`(后者只进凭据库)、配额查询与百分比条、**订阅归类覆盖**表(`provider/*` 或 `provider/model` → 订阅 / 按量) |
|
|
262
|
+
| **计价与价格目录** | 「含 Plan 总额」、目录匹配模式(宽松 / 严格)、USD→CNY 汇率、**手动覆盖价**表、**官方价格同步**(核对 / 应用 / 上次差异 / 当前时代 / 已同步时代)、**多厂商目录概览**(厂商与条目数、数据日期、指纹) |
|
|
263
|
+
| **历史导入** | 自动导入开关、立即导入、累计导入条数与已处理日志数、三条口径说明 |
|
|
264
|
+
| **数据与界面** | 界面显示三开关(勾选即刻生效)、导出 CSV、重算费用(试算 / 写回)、清空数据(两步确认) |
|
|
265
|
+
| **安全与凭据** | 云端令牌 / 火山 SK 的「是否已配置 + 存储位置」徽章、旧版明文迁移状态、清除按钮与出站防护说明 |
|
|
266
|
+
|
|
267
|
+
约定:**只有「界面显示」三开关是勾选即刻生效**(要立刻看到显隐结果),其余分组都是「改草稿 → 点该组保存」,避免误触即写盘;分组折叠只切显隐、不卸载内容,展开任一分组都不会重新取数或丢草稿。
|
|
268
|
+
|
|
269
|
+
### 历史导入(v1.9.0)
|
|
270
|
+
|
|
271
|
+
装上插件之前的对话也能补进账本:插件回放宿主会话日志(`$DSH_HOME/sessions/<项目>/<会话>/session.v3.jsonl.zstd`,多 zstd frame 逐帧解压、逐帧切片),把其中的模型调用按**当时时间戳**的计费口径入账。
|
|
272
|
+
|
|
273
|
+
- 默认**开机自动导入**(延迟 8 秒,不阻塞启动),也可在配置卡点「立即导入」或关掉自动(`autoImport`);
|
|
274
|
+
- **只补「插件不可能记到」的调用**:早于本机最早一条实时记录,或所在日完全没有实时覆盖(停机缺口);
|
|
275
|
+
- 跨安装点的会话按切割线截断:安装前那段补录,安装后那段以实时记录为准;
|
|
276
|
+
- **幂等三保险**:清单按文件 mtime + size 快跳、逐调用键 `(sessionId, 时间戳, 五桶 tokens)` 去重、已被实时覆盖的日子宁可不导入也不重复计数;
|
|
277
|
+
- 导入记录标记 `source=import`(实时记录 `source=live`);fork 出的子会话只计 `createdAt` 之后的部分,标题生成等辅路请求不计。
|
|
278
|
+
|
|
279
|
+
### 官方价格同步与多厂商目录(v1.9.0)
|
|
280
|
+
|
|
281
|
+
- **官方价格同步**:配置卡里点「核对官方价」抓取官方定价页(中文页直接给出人民币价),解析出各模型峰价并与当前生效价对比;点「应用新价」把结果构建为**新的计费时代** —— 只对生效时刻**之后**的记录生效,历史记录按各自时间戳选版,口径不回改。每日可自动核对(默认开,只提示差异,**绝不自动应用**)。解析器对页面改版 / 数字缺失 / 「空闲价 ≠ 高峰一半」一律抛错,宁可不同步也绝不写错价;
|
|
282
|
+
- **多厂商模型价格目录**:内置 14 家厂商 / 90 个模型条目(OpenAI / Anthropic / Google / Moonshot / z-ai / xAI / Alibaba / MiniMax / Tencent / Xiaomi / Upstage / NVIDIA / Mistral / OpenCode;数据改编自 `dsh-cost-meter` 的已核对官方目录,MIT),按 USD→CNY 汇率(默认 7.2,可改)折算。内置表之外的模型命中目录即记**精确价**(不再标「估算」);匹配模式可选宽松(归一化包含)或严格(名称全等);
|
|
283
|
+
- **手动覆盖价**:`provider/model` → 输入 / 输出 / 缓存价,优先级最高,用于自建端点或议价套餐;
|
|
284
|
+
- **计费优先级**:手动覆盖价 > 订阅归类(Plan)> 内置 / 同步时代精确价 > 多厂商目录 > provider 兜底 > 通用兜底。`cost_prices` 工具与 `/api/cost-tracker/prices` 会一并回显当前时代、同步时代、目录指纹与覆盖价;
|
|
285
|
+
- 云端(`dsh-cost-cloud ≥ v1.4.0`)有同源实现与对应的管理端点,两边口径可对照(`/api/v1/protocol` 回显云端实际使用的价格版本与目录指纹)。
|
|
286
|
+
|
|
287
|
+
### 凭据安全(v1.9.0)
|
|
288
|
+
|
|
289
|
+
- **密钥零落盘**:云端共享令牌与火山 `SecretAccessKey` 只写入 DSH 凭据库(`~/.dsh/.credentials.yaml`,由宿主凭据服务托管),配置文件里只保留「是否已配置」。老版本(≤ v1.8.15)写在 `cost-tracker-config.json` 里的明文会在启动时**自动迁移**进凭据库并从配置清除(幂等;凭据库已有值时不覆盖)。**安全边界**:只有凭据库确实可写时才清除配置里的明文 —— 宿主没有凭据服务、或凭据服务只读时,明文会**原样保留**并在启动日志里提示,因为密钥若只留在内存里,重启后就永久丢了;
|
|
290
|
+
- **任何响应都不回显密钥**:状态接口只给布尔与「存储位置」(凭据库 / 进程内存),`AccessKeyID` 属非敏感标识才会回显以便预填;
|
|
291
|
+
- **出站防护**:携带凭据的请求必须命中主机白名单(DeepSeek / Kimi / 火山管控面 / 配置的云端地址 / 定价页主机),非本机地址强制 https,`redirect: 'manual'` —— 3xx 一律按失败处理,防止重定向把 `Authorization` 头带去别处。
|
|
292
|
+
|
|
232
293
|
### HTTP API(供其他工具调用)
|
|
233
294
|
|
|
234
295
|
全部为 `POST` + JSON,监听本机地址:
|
|
@@ -249,8 +310,15 @@ POST /api/cost-tracker/kimi-usage Kimi 订阅配额
|
|
|
249
310
|
POST /api/cost-tracker/volcengine-usage 火山方舟 Coding Plan 配额(5 小时/周/月窗口)
|
|
250
311
|
POST /api/cost-tracker/volcengine-config 保存火山方舟 AK/SK(只回显「是否已配置」,不回显密钥)
|
|
251
312
|
POST /api/cost-tracker/balance 账户余额
|
|
252
|
-
POST /api/cost-tracker/prices 单价表(按计费时代分版)
|
|
313
|
+
POST /api/cost-tracker/prices 单价表(按计费时代分版 + 同步时代 + 多厂商目录 + 覆盖价)
|
|
253
314
|
POST /api/cost-tracker/recompute 按计费时代重算已入库记录(默认只试算,传 {"apply":true} 落盘)
|
|
315
|
+
POST /api/cost-tracker/billing-config 双轨计费与目录配置(金额口径/订阅归类/匹配与汇率/覆盖价)
|
|
316
|
+
POST /api/cost-tracker/prices-sync 官方价格同步(默认只核对,传 {"apply":true} 应用新价)
|
|
317
|
+
POST /api/cost-tracker/prices-config 价格同步设置(定价页地址 / 每日自动核对开关)
|
|
318
|
+
POST /api/cost-tracker/import-status 历史导入状态
|
|
319
|
+
POST /api/cost-tracker/import-run 执行一轮历史导入(幂等)
|
|
320
|
+
POST /api/cost-tracker/import-config 历史导入设置(开机自动开关)
|
|
321
|
+
POST /api/cost-tracker/reset 清空全部记录(配置卡两步确认后调用)
|
|
254
322
|
POST /api/cost-tracker/export 导出 CSV
|
|
255
323
|
```
|
|
256
324
|
|
|
@@ -262,6 +330,39 @@ POST /api/cost-tracker/export 导出 CSV
|
|
|
262
330
|
|
|
263
331
|
> 这里只列重要版本;逐版完整记录见 [`CHANGELOG.md`](./CHANGELOG.md)。
|
|
264
332
|
|
|
333
|
+
### v1.9.1(2026-09-20)
|
|
334
|
+
|
|
335
|
+
**修复:云端同步报「方法不允许」(405)—— `safeFetch` 丢掉 fetch 原生签名,POST 退化成 GET**
|
|
336
|
+
|
|
337
|
+
- 反代日志显示插件发出的是 `GET /api/v1/ingest/records`(应为 POST)→ 云端 405,同步全废、水位不前进;
|
|
338
|
+
- 根因:`index.js` 以 **fetch 原生签名**接线 `(url, init) => safeFetch(url, {...init})`,而 `safeFetch` 只读 `opts.init`,`method` / `body` 全部丢失;
|
|
339
|
+
- 修复:`safeFetch` 同时接受两种入参形状(`opts.init` 优先),安全策略不变;并补两层回归护栏(单测接线形状 + 引擎集成 `runOnce` 断言真的发出 POST);
|
|
340
|
+
- 另修:凭据服务晚就绪时明文迁移不再只试一次 —— 用 `ctx.inject(['credentials'])` 等它就绪后自动重迁,`secretsMigrated` 不会永远停在 false;
|
|
341
|
+
- **安装提醒**:DSH 的 profile 用 pnpm 管理插件,**手动拷文件会在下次启动被市场对账重装回旧版**(真实现场)。开发/自测请用 `dsh plugin --profile web add link:<仓库路径>`(详见「安装」一节)。
|
|
342
|
+
|
|
343
|
+
### v1.9.0(2026-09-27)
|
|
344
|
+
|
|
345
|
+
**五个新能力 + 设置集中到插件配置卡 + 凭据零落盘(配套云端 `dsh-cost-cloud` v1.4.0)**
|
|
346
|
+
|
|
347
|
+
- **历史导入**:回放宿主会话日志(多 zstd frame 逐帧解压),补录「装插件之前」的调用。幂等三保险(清单快跳 + 逐调用键去重 + 覆盖判定),跨安装点会话按切割线截断,导入记录标记 `source=import`。默认开机自动执行(延迟 8 秒,不阻塞启动),新 Agent 工具 `cost_import`;
|
|
348
|
+
- **凭据外带防护**:令牌与火山 SK 只写 DSH 凭据库(配置文件零明文),启动时自动迁移旧版明文;所有出站请求走白名单 + 强制 https + `redirect:'manual'`(拒绝跟随 3xx,防重定向把 `Authorization` 带走);任何响应只回显布尔与存储位置;
|
|
349
|
+
- **价格同步**:解析官方定价页(转置价格表:列 = 模型、行 = 指标 × 时段)→ 构建新计费时代,只影响生效时刻之后的记录,历史口径不回改;页面改版 / 数字不齐 / 空闲价非半价一律抛错。每日自动核对只提示差异,应用需手动确认;
|
|
350
|
+
- **多厂商模型价格目录**:14 家厂商 / 90 个模型条目(USD/1M tokens → 按汇率折 CNY),内置表之外的模型命中即记精确价;匹配模式宽松 / 严格可选;另有手动覆盖价表;
|
|
351
|
+
- **Plan 与按量双轨 + 「含 Plan 总额」开关**:金额卡与图表口径一键切换(关闭只算按量、订阅以附注展示;打开则按量 + 订阅等值并入,图表出现「订阅等值」段),选择存浏览器并回写服务端;
|
|
352
|
+
- **设置集中 + 卡片重设计**:`设置 → 插件 → 插件配置 → 花费统计` 成为唯一设置入口,按「多机汇总 / 峰谷计价与提示 / 订阅套餐与配额 / 计价与价格目录 / 历史导入 / 数据与界面 / 安全与凭据」七个折叠分组排列,顶部状态摘要条;看板上的峰谷面板改为只读回显;
|
|
353
|
+
- **测试**:新增 `test/import.test.js`(合成多帧 zstd 会话日志,37 条断言)、`test/price-sync.test.js`(含真实页面回归)、`test/vendor-catalog.test.js`、`test/credstore.test.js`,`client-render` 增加金额口径开关与卡片分组断言 —— 共 17 个测试文件全绿。
|
|
354
|
+
|
|
355
|
+
### v1.8.15(2026-09-26)
|
|
356
|
+
|
|
357
|
+
**修复:火山方舟配额面板「没有配置入口」与「拿推理 Key 当 AK」两个缺陷**
|
|
358
|
+
|
|
359
|
+
- **面板自带凭据输入框(主要修复)**:此前只能去「设置 → 插件 → 插件配置」卡片或手写环境变量,面板上**根本没有填写的地方** —— 用户看到的只有一句「凭据无效」,无从下手。现在面板内直接提供 `AccessKeyID` / `SecretAccessKey` 输入框与「查询」(先验证、不落盘)/「保存」(落盘持久化)/「清除凭据」三个动作;AK 明文回显便于确认,SK 从不回显(已保存时输入框提示「留空则不改」)。工具栏另加「火山方舟配额」按钮作为入口 —— 否则面板默认不显示,用户永远找不到。
|
|
360
|
+
- **修复:把「推理 API Key」当成 AccessKeyID 去签名(静默 401 的真正原因)**。配了 baseURL 指向方舟 coding 端点的 provider 时,其 `apiKeyEnv` 是**推理用** API Key,而配额查询要的是 IAM 的 AK/SK。早先的候选链把它也塞进 AK 候选,于是出现「推理 Key 当 AK + 凭据库里的 SK」这种**跨来源拼凑**的假凭据:签名必然 401,报错却只说「凭据无效或无权限」,根因完全查不出来。现在 AK 与 SK 必须**同源配对**,且按命名识别推理 Key(含 `API_KEY`/`TOKEN` 且不含 `ACCESSKEY`/`SECRETKEY`)并明确提示「这条是推理 Key,不是配额凭据」。
|
|
361
|
+
- **修复:失败路径抛 `ReferenceError`(TDZ)导致 500**。`keyEnv` 原先声明在 `try` 内却在 `catch` 里引用,任何一次查询失败(401 / 网络异常 / 结构变化)都会把「软失败」升级成 HTTP 500。现声明在 `try` 之外。
|
|
362
|
+
- **修复:`keyEnv` 永远显示「未知」**。`resolveApiKey()` 只返回 `{value, source}`,误取了 `rid.env`(那是 `resolveAnyEnv` 才加的字段),于是面板从不显示该去改哪个环境变量。现正确回传真实变量名。
|
|
363
|
+
- **防呆:空串不等于清空**。因为从不回显 SK,重开面板时 SK 输入框必然是空的;若把空串当作「清空」,用户只改一下 AK 就会把已存好的 SK 一起抹掉(静默丢凭据)。现在只有 **非空** SK 才覆盖,清空必须显式传 `clear:true`。
|
|
364
|
+
- 测试:`test/volcengine-host.test.js` 扩到 48 条断言,新增「推理 Key 不得被当作 AK(真实故障回归)」「空串不覆盖已存 SecretAccessKey」「只改 AK 后仍可用」「clear 才清空」四组。
|
|
365
|
+
|
|
265
366
|
### v1.8.14(2026-09-26)
|
|
266
367
|
|
|
267
368
|
**新增:火山方舟 Coding Plan 订阅支持(配额监控 + 等效费用)**
|
|
@@ -524,3 +625,5 @@ POST /api/cost-tracker/export 导出 CSV
|
|
|
524
625
|
## License
|
|
525
626
|
|
|
526
627
|
[MIT](./LICENSE) · 欢迎 Issue 与 PR
|
|
628
|
+
|
|
629
|
+
第三方成果与数据来源声明见 [`docs/THIRD-PARTY-NOTICES.md`](./docs/THIRD-PARTY-NOTICES.md)(多厂商价格目录数据改编自 `dsh-cost-meter`,MIT)。
|