@pinkbanana/dsh-balance 0.13.0 → 0.14.0

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 CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API 余额,以及 DeepSeek / StepFun / Tokener 的可用模型和多维消费统计。API Key 仅由本机 Host 使用,不会发送到浏览器。
6
6
 
7
- 界面使用 Harness 原生侧栏、主页面和主题变量。侧栏“插件”下方新增“用量统计”,独立查看所有对话的提供方、模型、会话和日期统计;默认显示全部提供方与全部时间,支持提供方和日期范围筛选。活动打卡图按浏览器时区的星期 × 24 小时汇总请求次数,圆点大小随次数变化;悬停或使用方向键可查看请求数与 token 明细。选择器采用主题化浮层菜单,支持方向键、Home/End、Enter、Escape 和按名称检索。设置页支持 DeepSeek / StepFun / Tokener 切换。运行 `pnpm preview` 可查看使用示例数据的新版界面。
7
+ 界面使用 Harness 原生侧栏、主页面和主题变量。侧栏“插件”下方新增“用量统计”,独立查看所有对话的提供方、模型、会话和日期统计;默认显示全部提供方与全部时间,支持提供方和日期范围筛选。活动打卡图按浏览器时区的星期 × 24 小时汇总请求次数,圆点大小随次数变化;悬停或使用方向键可查看请求数与 token 明细。选择器采用主题化浮层菜单,支持方向键、Home/End、Enter、Escape 和按名称检索。设置页支持 DeepSeek / StepFun / Tokener 切换。统计范围除今日 / 7 天 / 30 天 / 全部时间外,还可自定义起止日期;时区默认跟随浏览器,可切换为 UTC 等常用时区,日期分组、打卡图与月度预测均按所选时区计算。总消费卡片在限定范围时显示与上一同期的对比,并按当月已用天数线性预测本月花费。余额走势仅保留在当前 Harness 进程内(最近 48 次实时查询),重启后重新累积。「会话」分类下点击会话名可下钻查看该会话的完整请求明细(不受范围与提供方筛选影响),随时返回总览;「导出 JSON / CSV」分别导出完整摘要与当前分类表格(会话视图导出请求级记录),汇率输入框可即时换算人民币合计。运行 `pnpm preview` 可查看使用示例数据的新版界面。
8
8
 
9
9
  聊天框底部会跟随当前会话所选的提供方与模型更新余额;设置页可独立切换提供方。
10
10
 
@@ -18,10 +18,19 @@ DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API 余额,以及 De
18
18
  - 从当前提供方的 `/models` 接口读取可用模型、所属组织与创建时间
19
19
  - 在设置页按所选 provider、模型、会话和日期查看实际 usage 消费,并在当前会话的“消费”Tab 查看请求明细
20
20
  - 明确区分已计费、免费(已知价格且费用为 0)与未计费请求;缺少 provider usage、未知 provider 或未知模型时不进行费用估算
21
- - 日期按浏览器 IANA 时区分组;DeepSeek 峰谷价格始终按北京时间计算
21
+ - 日期按浏览器 IANA 时区分组;DeepSeek 峰谷价格始终按北京时间计算,仅周一至周五适用,中国法定节假日全天低谷
22
22
  - DeepSeek 费用显示 USD、StepFun 显示原生 CNY;配置 `usdToCny` 后显示人民币合计
23
23
  - 缓存查询结果并支持手动刷新
24
- - 依据 DeepSeek 峰谷定价,在高峰时段(北京时间 9:00–12:00、14:00–18:00)将聊天框下方的余额指示灯变为橙色
24
+ - 模型列表标注内置参考价(输入 / 输出每百万 tokens),未收录价格的模型明确标记
25
+ - 统计页「会话」分类中点击任一会话,下钻查看该会话的完整请求明细,可随时返回总览
26
+ - 按本会话近期已计费请求的 token 构成估算下轮费用:当前时段、下个峰谷切换后、新开会话(全部未命中缓存),以及本 Harness 已配置且可计价的其他官方模型;同时给出继续本会话相对新开因缓存节省的费用。这是估算而非官方账单,不会自动换模型,也不会把会话内容送出本机
27
+ - 一键导出当前视图为 JSON 或 CSV(总览导出所选分类或完整摘要,会话导出请求级记录),数据不离开本机
28
+ - 统计页可直接填写 USD→CNY 汇率(存于浏览器 localStorage,无需重启);插件配置 `usdToCny` 优先生效
29
+ - 配置 `pricingOverrides` 可用自定义费率替换内置价格(按 provider + model 匹配,支持生效时间),模型列表与计费估算同步生效
30
+ - 设置页展示近期余额走势(进程内最近 48 次查询),并可按币种配置低额预警(`lowBalance`),聊天框下方同步提示
31
+ - 统计页支持自定义日期范围与 12 个常用时区(默认跟随浏览器),月度按当前节奏预测,限定范围时与上一同期对比
32
+ - 余额与模型查询对 429 / 5xx 自动重试(尊重 `Retry-After`,指数退避,最多 3 次尝试)
33
+ - 依据 DeepSeek 峰谷定价,在高峰时段(北京时间周一至周五 9:00–12:00、14:00–18:00,中国法定节假日除外)将聊天框下方的余额指示灯变为橙色
25
34
  - 原生支持简体中文和英文,并跟随 Harness 系统语言切换
26
35
  - 支持 Harness 已保存的 `DEEPSEEK_API_KEY`
27
36
 
@@ -29,9 +38,9 @@ DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API 余额,以及 De
29
38
 
30
39
  ## 兼容性
31
40
 
32
- 0.13.0 适配 DeepSeek Harness **0.2.2-rc.1**([上游版本](https://github.com/deepseek-ai/deepseek-harness/releases/tag/dsh-v0.2.2-rc.1)),需要 Node.js **24.9+**。所有 DSH peer 依赖和开发依赖均锁定为 `0.2.2-rc.1`,Cordis 使用 `~4.1.0`。Harness `0.2.0-rc.2` 用户请继续使用插件 `0.10.2`;本次源码不再兼容 Harness 0.1 的接口。
41
+ 插件 `0.14.0` 支持 DSH **`>=0.2.1-rc.3 <1.0.0-0`**,需要 Node.js **24.9+**。DSH 的安装和启动检查将预发布版本纳入匹配,范围内无需添加版本豁免。DSH peer 依赖也显式涵盖 `0.2.2-rc.1` 起的 `0.2.2` 预发布版,以便包管理器使用标准 semver 规则解析这些版本。Cordis peer 范围为 `^4.0.5`。开发依赖固定在 DSH `0.2.2-rc.1` 和 Cordis `~4.1.0`,以保持构建可复现。
33
42
 
34
- 新版 dsh 会在安装及启动时校验插件兼容版本。插件 `0.12.1` 锁定 `0.2.1-rc.5`,会被 dsh `0.2.2-rc.1` 拒绝加载;请升级到插件 `0.13.0` 并重启 Harness,无需添加版本豁免。仍使用 dsh `0.2.1-rc.5` 的用户请保留插件 `0.12.1`;dsh `0.2.1-rc.2` 用户请保留插件 `0.11.0`。
43
+ 已在 DSH `0.2.1-rc.3` 和 `0.2.2-rc.5` 的 Web profile 验证安装和启动。仍使用 DSH `0.2.1-rc.2` 的用户可使用插件 `0.11.0`,DSH `0.2.0-rc.2` 的用户可使用插件 `0.10.2`。
35
44
 
36
45
  也可在本地构建并打包源码,再用 `dsh plugin --profile web add /absolute/path/to/package.tgz` 安装生成的 `.tgz` 文件,随后重启 Harness:
37
46
 
@@ -66,7 +75,36 @@ dsh --profile web
66
75
  usdToCny: 7.2
67
76
  ```
68
77
 
69
- 官方提供方 ID `deepseek-official` 与旧 ID `deepseek` 均受支持(大小写不敏感),共享 DeepSeek 凭据、余额及模型缓存。底部保留实际模型 ID,例如 `deepseek-flash`;价格未知的新模型仍标为“未计费”。
78
+ 也可按币种配置低额预警阈值(币种大小写不敏感,低于阈值时设置页与聊天框下方会出现提示):
79
+
80
+ ```yaml
81
+ lowBalance:
82
+ - currency: CNY
83
+ amount: 20
84
+ - currency: USD
85
+ amount: 5
86
+ ```
87
+
88
+ 还可用自定义费率替换内置价格(需完整的 USD 或 CNY 三项费率,`effectiveFrom` 可省略,默认立即生效;修改后需重启 Harness):
89
+
90
+ ```yaml
91
+ pricingOverrides:
92
+ - provider: deepseek
93
+ model: deepseek-v4-flash
94
+ cacheMissUsdPerMillion: 0.10
95
+ cacheHitUsdPerMillion: 0.01
96
+ outputUsdPerMillion: 0.30
97
+ - provider: stepfun
98
+ model: step-5-preview
99
+ effectiveFrom: "2026-11-01T00:00:00Z"
100
+ cacheMissCnyPerMillion: 6
101
+ cacheHitCnyPerMillion: 0.3
102
+ outputCnyPerMillion: 18
103
+ ```
104
+
105
+ 自定义价格同时作用于设置页模型列表标注与消费统计估算;未覆盖的模型仍按内置价格计算。汇率除配置 `usdToCny` 外,也可在统计页直接填写(仅保存在本浏览器,插件配置优先生效)。
106
+
107
+ 官方提供方 ID `deepseek-official` 与旧 ID `deepseek` 均受支持(大小写不敏感),共享 DeepSeek 凭据、余额及模型缓存。底部保留实际模型 ID;请使用 `deepseek-flash`(遗留名 `deepseek-v4-flash`、`deepseek-v4-flash-vision-exp` 以及 `deepseek-chat` / `deepseek-reasoner` 同样按现行 Flash 官方价计费)。价格未知的新模型仍标为“未计费”。
70
108
 
71
109
  ## StepFun 配置
72
110
 
@@ -108,14 +146,26 @@ providers:
108
146
 
109
147
  每条请求按实际返回消息的 provider / model 归属,兼容旧日志的请求头;日期和峰谷价格按该次请求时间计算。Token 总量包括未缓存输入、输出、缓存读取与缓存写入。设置页默认筛选所选 provider,也可选择“全部提供方”;会话页保留混用模型的完整历史。
110
148
 
111
- 内置 DeepSeek 美元定价,以及 2026-09-30 核验的 [StepFun 官方人民币标准价](https://platform.stepfun.com/docs/zh/guides/pricing/details):`step-5-preview`、`step-3.7-flash`、`step-3.5-flash` 和 `step-3.5-flash-2603`。StepFun 未缓存输入(含缓存写入)、缓存读取、输出分别计价,不套用 DeepSeek 峰谷倍率。费用是公开标准价估算,不代表账户实际账单;套餐、折扣和未保存的历史调价不包含在内。
149
+ 内置 [DeepSeek 官方美元定价](https://api-docs.deepseek.com/quick_start/pricing/):现行 Flash 低谷价为每百万 tokens 缓存命中 $0.003 / 未命中 $0.15 / 输出 $0.60,高峰为 2 倍;高峰为北京时间周一至周五 09:00–12:00、14:00–18:00(UTC 01:00–04:00、06:00–10:00),周末及中国法定节假日全天低谷。法定节假日按 [国办发明电〔2025〕7号](https://www.gov.cn/zhengce/zhengceku/202511/content_7047091.htm) 的 2026 年放假日期。现行 Flash 价自 2026-09-10 04:00 UTC 起生效,此前仍使用 2026-08-17 历史档(当前官网已不再列出该档数字,无法复核)。
150
+
151
+ [StepFun 官方人民币标准价](https://platform.stepfun.com/docs/zh/guides/pricing/details) 于 2026-11-10 复核:`step-5-preview`、`step-3.7-flash`、`step-3.5-flash`、`step-3.5-flash-2603` 和 `step-1o-turbo-vision`。`step-5-preview` 缓存命中标准价自北京时间 2026-10-14 00:30 起由 0.35 元/百万调整为 0.70 元/百万;该时间之前已通过按量付费 API 调用过该模型的账户可能仍适用 0.35 元,插件无法识别账户是否享受此保留价,因此一律按标准生效时间计价。StepFun 未缓存输入(含缓存写入)、缓存读取、输出分别计价,不套用 DeepSeek 峰谷倍率。费用是公开标准价估算,不代表账户实际账单;套餐、折扣和未保存的历史调价不包含在内。
112
152
 
113
153
  美元和原生人民币费用分别展示;设置 `usdToCny` 后,人民币合计才会包含美元折算金额,并明确标为固定汇率换算。未设置汇率时,原生人民币金额不会被表述为包含美元费用的完整人民币合计。已知价格且费用为 0 的请求单列为“免费”;未知 provider / model 和缺失 usage 的请求保留请求数与 token,显示“未计费”。账户余额是实时查询值,与本地用量估算独立;赠送余额与充值余额分别展示,StepFun 的总充值/总赠送为累计值而非剩余余额。会话消费页采用居中内容宽度、响应式外边距,并为底部输入框保留空间。
114
154
 
155
+
156
+ ## 下轮费用估算
157
+
158
+ 会话「消费」页会展示下轮费用估算卡片;聊天框下方的余额摘要可按需展开同一估算,默认收起以免占用空间。估算使用本会话最近若干次已计费请求各 token 桶(未缓存输入 / 缓存读取 / 缓存写入 / 输出)的中位数,通过现有计价引擎计算,不另建第二套价格路径。下轮实际用量可能不同,例如上下文压缩、大段粘贴或视觉输入。
159
+
160
+ 返回结果包括当前时段、下一次峰谷切换时间、样本数量、token 构成,以及当前模型此刻、切换后、新开会话的估算,还有其他已配置且可计价官方模型的对照。无法定价的模型会被省略,不会显示为 $0。美元与原生人民币分别展示;只有配置了 `usdToCny` 才会给出人民币合计。接口为 `GET /dsh-balance/api/advice?session=…`,仅本机可访问,响应不含 prompt 或会话正文。
161
+
162
+ 这些数字是公开标准价估算,不是官方账单。StepFun `step-5-preview` 在使用 2026-10-14 之后的标准缓存命中价时,会注明账户可能仍享受 0.35 元/百万的保留价,插件无法识别。Tokener 按 2026-11-03 目录快照计价,不套用原厂价格或 DeepSeek 峰谷倍率。
163
+
115
164
  ## 扩展与设计
116
165
 
117
166
  - `src/providers.ts` 保存可在前后端共享的 provider 元数据;`src/balance.ts` 的 adapter 表只负责端点与响应解析,传输、错误分类和缓存由公共逻辑处理。
118
167
  - `GET /dsh-balance/api/balance?provider=StepFun` 查询 StepFun;省略 provider 保持 DeepSeek 兼容,`refresh=1` 绕过对应缓存。不支持的 provider 返回 `UNSUPPORTED_PROVIDER`。
168
+ - `GET /dsh-balance/api/advice?session=…` 返回当前会话的下轮费用估算(也可用 `sessionId`);可选 `provider`、`model` 与重复的 `compare=provider:model`。响应不含 prompt 内容。
119
169
  - 通过原生 `sidebar.panellist` 与 `main` 插槽接入侧栏和主页面,菜单、选中态、侧栏折叠和页面导航由 Harness 管理;插件使用 Harness 的颜色、圆角和布局变量,支持深浅色主题与窄屏。
120
170
 
121
171
  ## 开发
package/README_EN.md CHANGED
@@ -18,16 +18,27 @@ The composer readout follows the current session’s provider and model. The Set
18
18
  - Fetch available models, owners, and creation dates from the selected provider’s `/models` API
19
19
  - View actual usage costs by selected provider, model, session, and day in Settings, plus request details in the current session's Usage tab
20
20
  - Mark missing usage, unknown providers, and unknown models as unpriced without estimating tokens
21
- - Group dates in the browser's IANA timezone while applying DeepSeek peak pricing in Beijing time
21
+ - Group dates in the browser's IANA timezone while applying DeepSeek peak pricing in Beijing time, Monday–Friday only, with Chinese public holidays all-day off-peak
22
22
  - Show native USD and CNY costs separately; `usdToCny` enables a combined CNY total
23
23
  - Cache query results with manual refresh support
24
- - Follows DeepSeek peak/off-peak pricing: the balance indicator below the composer turns orange during peak hours (09:00–12:00, 14:00–18:00 Beijing time)
24
+ - Annotate the model list with catalogued reference rates (input/output per million tokens); models without published pricing are marked explicitly
25
+ - Drill from the Sessions category into any session's full request breakdown and back to the overview
26
+ - Estimate the next turn from this session’s recent priced token mix: the current period, after the next peak change, a fresh session (all cache-miss), and other official models already configured in this Harness that can actually be priced, plus how much cache saves by continuing versus starting over. These are estimates, not an official bill; the plugin never auto-switches models and never sends session text off the machine
27
+ - Export the current view as JSON or CSV (overview: full summary or the visible category; session: request-level records) — data never leaves the machine
28
+ - Enter a display-only USD→CNY rate on the usage page (kept in browser localStorage, no restart); the plugin's `usdToCny` config still takes precedence
29
+ - Replace built-in prices with `pricingOverrides` (matched by provider + model, optional `effectiveFrom`); the model list and usage estimates follow
30
+ - Show a recent balance trend (the last 48 in-process observations) in Settings and optional per-currency low-balance warnings (`lowBalance`), mirrored below the composer
31
+ - Custom date ranges and twelve common time zones (browser default); month-to-date projection at the current pace, plus a comparison with the immediately preceding period for bounded ranges
32
+ - Retry balance and model queries on 429 / 5xx (honoring `Retry-After`, exponential backoff, at most three attempts)
33
+ - Follows DeepSeek peak/off-peak pricing: the balance indicator below the composer turns orange during peak hours (09:00–12:00 and 14:00–18:00 Beijing time, Monday–Friday, excluding Chinese public holidays)
25
34
  - Native Simplified Chinese and English that follows the Harness system language
26
35
  - Use the `DEEPSEEK_API_KEY` saved by Harness
27
36
 
28
37
  ## Compatibility
29
38
 
30
- Version 0.13.0 targets DeepSeek Harness **0.2.2-rc.1** ([upstream release](https://github.com/deepseek-ai/deepseek-harness/releases/tag/dsh-v0.2.2-rc.1)). Use Node.js **24.9+**. All DSH peer and development dependencies are pinned to `0.2.2-rc.1`, with Cordis `~4.1.0`. Harness `0.2.0-rc.2` users should keep plugin `0.10.2`; Harness 0.1 APIs are no longer supported by this checkout.
39
+ Plugin `0.14.0` supports DSH **`>=0.2.1-rc.3 <1.0.0-0`** and requires Node.js **24.9+**. DSH includes prereleases in its install and startup checks. Versions in this range require no exemption. The DSH peer ranges explicitly include `0.2.2` prereleases starting at `0.2.2-rc.1` so package managers can resolve them under standard semver rules. The Cordis peer range is `^4.0.5`. Development dependencies are pinned to DSH `0.2.2-rc.1` and Cordis `~4.1.0` for reproducible builds.
40
+
41
+ Installation and startup were verified with the web profile on DSH `0.2.1-rc.3` and `0.2.2-rc.5`. For DSH `0.2.1-rc.2`, use plugin `0.11.0`. For DSH `0.2.0-rc.2`, use plugin `0.10.2`.
31
42
 
32
43
  To install from source, build and pack it locally, then pass the generated `.tgz` path to `dsh plugin --profile web add /absolute/path/to/package.tgz` and restart Harness:
33
44
 
@@ -62,7 +73,36 @@ Usage statistics read persisted session logs, including writes visible from acti
62
73
  usdToCny: 7.2
63
74
  ```
64
75
 
65
- Both the official provider ID `deepseek-official` and legacy `deepseek` are supported case-insensitively and share DeepSeek credentials, balance caches, and model caches. The composer retains the actual model ID, such as `deepseek-flash`; new models with unknown pricing remain unpriced.
76
+ Per-currency low-balance thresholds (case-insensitive currency) surface warnings in Settings and below the composer:
77
+
78
+ ```yaml
79
+ lowBalance:
80
+ - currency: CNY
81
+ amount: 20
82
+ - currency: USD
83
+ amount: 5
84
+ ```
85
+
86
+ Replace built-in prices with custom rates (a complete USD or CNY triple is required; `effectiveFrom` is optional and defaults to immediate; restart Harness after changing them):
87
+
88
+ ```yaml
89
+ pricingOverrides:
90
+ - provider: deepseek
91
+ model: deepseek-v4-flash
92
+ cacheMissUsdPerMillion: 0.10
93
+ cacheHitUsdPerMillion: 0.01
94
+ outputUsdPerMillion: 0.30
95
+ - provider: stepfun
96
+ model: step-5-preview
97
+ effectiveFrom: "2026-11-01T00:00:00Z"
98
+ cacheMissCnyPerMillion: 6
99
+ cacheHitCnyPerMillion: 0.3
100
+ outputCnyPerMillion: 18
101
+ ```
102
+
103
+ Overrides apply to both the model-list annotations and usage estimates; models without an override keep their built-in rates. Besides `usdToCny`, the usage page also accepts a display-only rate stored in this browser; the plugin configuration wins when present.
104
+
105
+ Both the official provider ID `deepseek-official` and legacy `deepseek` are supported case-insensitively and share DeepSeek credentials, balance caches, and model caches. The composer retains the actual model ID; use `deepseek-flash` (legacy names `deepseek-v4-flash` and `deepseek-v4-flash-vision-exp`, as well as `deepseek-chat` / `deepseek-reasoner`, are billed at the current official Flash rates). New models with unknown pricing remain unpriced.
66
106
 
67
107
  ## Tokener configuration and usage
68
108
 
@@ -81,8 +121,6 @@ Statistics cover locally saved dsh sessions only, not other clients or organizat
81
121
 
82
122
  Conversation/reasoning model estimates use the [Tokener model catalog](https://www.tokener.ai/zh/models) USD reference snapshot checked on 2026-11-03, matching exact model IDs without vendor rates or DeepSeek peak multipliers. This snapshot also estimates older records; it does not reconstruct historical charges. Unknown models, missing usage, and requests with unpublished cache-write pricing retain their requests/tokens but stay unpriced. Account balances and actual bills remain in the [Tokener console](https://console.tokener.ai).
83
123
 
84
- New dsh versions validate compatibility before installation and startup. Plugin `0.12.1` declares `0.2.1-rc.5` peers and is rejected on dsh `0.2.2-rc.1`; upgrade to plugin `0.13.0` and restart Harness. No version exemption is required. Keep plugin `0.12.1` on dsh `0.2.1-rc.5`, or plugin `0.11.0` on dsh `0.2.1-rc.2`.
85
-
86
124
  ## StepFun setup
87
125
 
88
126
  Add a custom provider in Settings → Models with Provider ID `StepFun` (`stepfun`, `STEPFUN`, and other case variants work) and save its API key. Harness derives the credential reference `STEPFUN_API_KEY`; setting that environment variable also works. Select StepFun in Settings → Model Balances.
@@ -106,12 +144,24 @@ Model lists use the [StepFun list API](https://platform.stepfun.com/docs/zh/api-
106
144
 
107
145
  Each request is attributed to its actual message source, with request headers as a fallback for older logs. Request time determines date grouping and peak pricing. Token totals include uncached input, output, cache reads, and cache writes. Settings defaults to the selected provider, with an All providers option; the session view keeps mixed-provider history.
108
146
 
109
- Built-in estimates cover official DeepSeek USD rates and verified StepFun mainland CNY reference rates. Requests without supported pricing keep their token and request counts and show as unpriced. A similarly named DeepSeek model does not inherit official DeepSeek pricing on another provider. Entirely unpriced totals do not show $0; mixed totals include only known charges and carry a partial-cost label. Live account balances are separate from local usage estimates.
147
+ Built-in estimates use [official DeepSeek USD rates](https://api-docs.deepseek.com/quick_start/pricing/): current Flash off-peak prices are $0.003 / $0.15 / $0.60 per million tokens (cache hit / miss / output), and peak is 2x. Peak hours are 09:00–12:00 and 14:00–18:00 Beijing time (UTC 01:00–04:00 and 06:00–10:00), Monday–Friday only; weekends and Chinese public holidays are all-day off-peak. Holiday dates follow the 2026 arrangements in [State Council General Office notice 国办发明电〔2025〕7号](https://www.gov.cn/zhengce/zhengceku/202511/content_7047091.htm). Current Flash prices take effect from 2026-09-10 04:00 UTC; earlier usage keeps the 2026-08-17 historical tier (the current official page no longer lists those figures, so they cannot be re-verified).
148
+
149
+ [StepFun mainland CNY reference rates](https://platform.stepfun.com/docs/zh/guides/pricing/details) were re-checked on 2026-11-10 for `step-5-preview`, `step-3.7-flash`, `step-3.5-flash`, `step-3.5-flash-2603`, and `step-1o-turbo-vision`. The standard `step-5-preview` cache-hit price changed from 0.35 to 0.70 CNY per million tokens at 2026-10-14 00:30 Beijing time. Accounts that had already used the pay-as-you-go API before that time may keep 0.35; the plugin cannot detect that grandfathering, so it applies the standard effective-from date. Requests without supported pricing keep their token and request counts and show as unpriced. A similarly named DeepSeek model does not inherit official DeepSeek pricing on another provider. Entirely unpriced totals do not show $0; mixed totals include only known charges and carry a partial-cost label. Live account balances are separate from local usage estimates.
150
+
151
+
152
+ ## Next-turn estimates
153
+
154
+ The session Usage tab shows a next-turn estimate card. The composer balance dock can expand the same estimate on demand; it stays collapsed by default so it does not clutter the row. The token shape is the per-bucket median of the session’s most recent priced requests (uncached input, cache read, cache write, output), priced through the existing billing engines rather than a second pricing path. The next turn may not match, for example after compaction, a large paste, or vision input.
155
+
156
+ The response includes the current period, the next peak-change time, the sample size, the token shape, estimates for the current model now, after the change, and as a fresh session, plus other configured official models that can be priced. Unpriced models are omitted rather than shown as $0. Native USD and CNY are shown separately; a combined CNY total appears only when `usdToCny` is set. The Host route is `GET /dsh-balance/api/advice?session=…`, loopback-only, and the payload never includes prompt or session text.
157
+
158
+ These figures are published-rate estimates, not an official bill. When the post-2026-10-14 standard StepFun `step-5-preview` cache-hit rate is used, the UI notes that some accounts may still be grandfathered at 0.35 CNY per million tokens; the plugin cannot detect that. Tokener estimates use the 2026-11-03 catalog snapshot, without vendor rates or the DeepSeek peak multiplier.
110
159
 
111
160
  ## Extension and design
112
161
 
113
162
  - `src/providers.ts` holds shared provider metadata. The adapter table in `src/balance.ts` defines endpoints and response parsers; transport, errors, and caching are shared.
114
163
  - `GET /dsh-balance/api/balance?provider=StepFun` selects StepFun. Omitting provider preserves DeepSeek compatibility; `refresh=1` bypasses that provider's cache. Unknown providers return `UNSUPPORTED_PROVIDER`.
164
+ - `GET /dsh-balance/api/advice?session=…` returns the next-turn estimate for a session (`sessionId` is also accepted), with optional `provider`, `model`, and repeated `compare=provider:model`. The response never includes prompt text.
115
165
  - The layout draws on [Codrops' Kononenko case study](https://tympanus.net/codrops/2026/09/18/kononenko-architectural-bureau/): oversized type, negative space, architectural grids, and geometric linework, implemented in original CSS with light/dark themes, narrow layouts, and reduced-motion support.
116
166
 
117
167
  ## Development
@@ -144,4 +194,4 @@ The activity punchcard groups requests by weekday and hour in the selected brows
144
194
 
145
195
  The conversation usage view has centered content, responsive padding and space for the composer. Cache input is counted once; duplicate settlements replace the previous sample, retries remain separate, and fork prefixes are excluded.
146
196
 
147
- StepFun mainland API estimates use [official standard CNY rates](https://platform.stepfun.com/docs/zh/guides/pricing/details), verified on 2026-09-30, for `step-5-preview`, `step-3.7-flash`, `step-3.5-flash` and `step-3.5-flash-2603`. These reference estimates do not account for plans, discounts or unrecorded historical rate changes. USD and native CNY are shown separately; only an explicitly configured `usdToCny` rate enables a combined CNY total. Unknown rates remain unpriced. `?page=session` previews the conversation view with 124 StepFun requests.
197
+ StepFun mainland API estimates use [official standard CNY rates](https://platform.stepfun.com/docs/zh/guides/pricing/details), re-checked on 2026-11-10, for `step-5-preview`, `step-3.7-flash`, `step-3.5-flash`, `step-3.5-flash-2603`, and `step-1o-turbo-vision`. The standard `step-5-preview` cache-hit rate is 0.70 CNY per million from 2026-10-14 00:30 Beijing time; earlier records use 0.35. These reference estimates do not account for plans, discounts, grandfathered account rates, or unrecorded historical rate changes. USD and native CNY are shown separately; only an explicitly configured `usdToCny` rate enables a combined CNY total. Unknown rates remain unpriced. `?page=session` previews the conversation view with 124 StepFun requests.