@pinkbanana/dsh-balance 0.16.0 → 0.18.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 +11 -8
- package/README_EN.md +13 -10
- package/docs/estimates.en.md +8 -4
- package/docs/estimates.md +8 -4
- package/lib/client.js +312 -75
- package/lib/client.js.map +1 -1
- package/lib/index.js +130 -23
- package/lib/index.js.map +1 -1
- package/lib/types/advice.d.ts +10 -1
- package/lib/types/cache-breaks.d.ts +33 -0
- package/lib/types/client/AdviceCard.d.ts +11 -2
- package/lib/types/client/BalanceDock.d.ts +4 -0
- package/lib/types/client/locales.d.ts +18 -0
- package/lib/types/client/styles.d.ts +1 -1
- package/lib/types/pricing.d.ts +2 -0
- package/package.json +18 -15
package/README.md
CHANGED
|
@@ -38,9 +38,9 @@ DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API 余额,以及 De
|
|
|
38
38
|
|
|
39
39
|
## 兼容性
|
|
40
40
|
|
|
41
|
-
插件 `0.
|
|
41
|
+
插件 `0.16.1` 支持 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` 预发布版,以及 `0.2.3` 预发布版(`0.2.3-alpha.1` 起,已确认包含 `0.2.3-alpha.3`),以便包管理器使用标准 semver 规则解析这些版本。Cordis peer 范围为 `^4.0.5`。React / React DOM peer 范围为 `^18.2.0 || ^19.0.0`,以同时支持 DSH 0.2.2(React 18)和 0.2.3(React 19)。开发依赖仍固定在 DSH `0.2.2-rc.1`、Cordis `~4.1.0` 和 React 18,以保持构建可复现,且不中断对 React 18 宿主的支持。
|
|
42
42
|
|
|
43
|
-
已在 DSH `0.2.1-rc.3` 和 `0.2.2-rc.5` 的 Web profile
|
|
43
|
+
已在 DSH `0.2.1-rc.3` 和 `0.2.2-rc.5` 的 Web profile 验证安装和启动。对 DSH `0.2.3-alpha.3`,本版本通过 peer/semver 测试、API 兼容检查和会话计费夹具验证(完整 GUI 启动未在本环境执行)。仍使用 DSH `0.2.1-rc.2` 的用户可使用插件 `0.11.0`,DSH `0.2.0-rc.2` 的用户可使用插件 `0.10.2`。
|
|
44
44
|
|
|
45
45
|
也可在本地构建并打包源码,再用 `dsh plugin --profile web add /absolute/path/to/package.tgz` 安装生成的 `.tgz` 文件,随后重启 Harness:
|
|
46
46
|
|
|
@@ -49,7 +49,7 @@ pnpm install --frozen-lockfile
|
|
|
49
49
|
pnpm pack
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
消费统计通过 `SessionPersistence` 的只读会话句柄读取(包括官方 SQLite 存储,以及闲置归档后再次打开的会话),以 `inheritedEventCount` 排除分叉、子智能体和 `/side` 侧栏会话从父会话继承的记录,避免与父会话重复计费;会话页在 token 用量变化或一轮运行结束后刷新;统计页面每 15 秒检查更新,重新聚焦或返回页面时刷新,隐藏页面暂停查询。兼容 `assistant/message` 和重试/取消请求的 `assistant/attempt`,读取最后一条 stream usage,并以重试边界区分独立请求,同一次请求的重复结算仅计一次。
|
|
53
53
|
|
|
54
54
|
全局统计会跳过当前 dsh 无法读取的旧格式或损坏会话,并显示未纳入统计的会话数量;其余会话仍正常统计。部分汇总结果不缓存,下次刷新会重试失败会话;已成功读取且 revision 未变化的会话复用精简用量记录。单个会话无法读取或所有会话都读取失败时,仍明确显示读取错误,不将失败记录当作零消费。
|
|
55
55
|
|
|
@@ -148,18 +148,18 @@ providers:
|
|
|
148
148
|
|
|
149
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
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 峰谷倍率。费用是公开标准价估算,不代表账户实际账单;套餐、折扣和未保存的历史调价不包含在内。
|
|
151
|
+
[StepFun 官方人民币标准价](https://platform.stepfun.com/docs/zh/guides/pricing/details) 于 2026-11-10 复核:`step-5`、`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 峰谷倍率。费用是公开标准价估算,不代表账户实际账单;套餐、折扣和未保存的历史调价不包含在内。
|
|
152
152
|
|
|
153
153
|
美元和原生人民币费用分别展示;设置 `usdToCny` 后,人民币合计才会包含美元折算金额,并明确标为固定汇率换算。未设置汇率时,原生人民币金额不会被表述为包含美元费用的完整人民币合计。已知价格且费用为 0 的请求单列为“免费”;未知 provider / model 和缺失 usage 的请求保留请求数与 token,显示“未计费”。账户余额是实时查询值,与本地用量估算独立;赠送余额与充值余额分别展示,StepFun 的总充值/总赠送为累计值而非剩余余额。会话消费页采用居中内容宽度、响应式外边距,并为底部输入框保留空间。
|
|
154
154
|
|
|
155
155
|
|
|
156
156
|
## 下轮费用估算
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
会话「消费」页会展示下轮费用估算卡片;在用量统计里点击会话名下钻时也会看到同一卡片。聊天框下方的余额摘要可按需展开该估算,默认收起以免占用空间;收起时开关会直接写出最省的下一步(例如「下轮估算 · 等待切换最省」),无需展开即可参考。同一标签页内的导航(包括切换会话或模型)会记住展开或收起;刷新或关闭标签页后仍默认收起。
|
|
159
159
|
|
|
160
|
-
卡片对照四种下一步的费用:当前时段继续、等待下个峰谷切换、现在 `/compact`(摘要请求 + 压缩后首轮;摘要约 4,000 tokens,至多历史的四分之一),以及新开会话(全部未命中缓存),并显示继续本会话相对新开因缓存可节省的费用。也可对照本 Harness
|
|
160
|
+
卡片对照四种下一步的费用:当前时段继续、等待下个峰谷切换、现在 `/compact`(摘要请求 + 压缩后首轮;摘要约 4,000 tokens,至多历史的四分之一),以及新开会话(全部未命中缓存),并显示继续本会话相对新开因缓存可节省的费用。也可对照本 Harness 已配置且可计价的其他官方模型。当前模型下最便宜的一步会标上“最便宜”(按单轮费用比较,因此 `/compact` 很少在单轮胜出)。仅为估算,不会自动压缩或换模型。
|
|
161
161
|
|
|
162
|
-
估算使用本会话最近 8 次已计费请求各 token 桶(未缓存输入 / 缓存读取 / 缓存写入 /
|
|
162
|
+
估算使用本会话最近 8 次已计费请求各 token 桶(未缓存输入 / 缓存读取 / 缓存写入 / 输出)的中位数,通过与用量统计相同的计价引擎计算。下轮实际用量可能不同,例如上下文压缩、大段粘贴或视觉输入。卡片还会在检测到缓存命中率骤降(例如换模型、前缀变化或上下文被压缩)时列出最近 3 次「缓存断层」及估算多花的费用,帮助定位缓存为何失效。没有已计价样本或估算加载失败时,卡片会说明原因,并提示重新估算或打开用量统计。完整计算说明、峰谷规则和局限见 [估算是怎么算的](./docs/estimates.md)。
|
|
163
163
|
|
|
164
164
|

|
|
165
165
|
|
|
@@ -176,7 +176,7 @@ providers:
|
|
|
176
176
|
|
|
177
177
|
- `src/providers.ts` 保存可在前后端共享的 provider 元数据;`src/balance.ts` 的 adapter 表只负责端点与响应解析,传输、错误分类和缓存由公共逻辑处理。
|
|
178
178
|
- `GET /dsh-balance/api/balance?provider=StepFun` 查询 StepFun;省略 provider 保持 DeepSeek 兼容,`refresh=1` 绕过对应缓存。不支持的 provider 返回 `UNSUPPORTED_PROVIDER`。
|
|
179
|
-
- `GET /dsh-balance/api/advice?session=…` 返回当前会话的下轮费用估算(也可用 `sessionId`);可选 `provider`、`model` 与重复的 `compare=provider:model`。响应不含 prompt 内容。
|
|
179
|
+
- `GET /dsh-balance/api/advice?session=…` 返回当前会话的下轮费用估算(也可用 `sessionId`);可选 `provider`、`model`、`refresh=1` 与重复的 `compare=provider:model`。响应不含 prompt 内容。
|
|
180
180
|
- 通过原生 `sidebar.panellist` 与 `main` 插槽接入侧栏和主页面,菜单、选中态、侧栏折叠和页面导航由 Harness 管理;插件使用 Harness 的颜色、圆角和布局变量,支持深浅色主题与窄屏。
|
|
181
181
|
|
|
182
182
|
## 开发
|
|
@@ -184,9 +184,12 @@ providers:
|
|
|
184
184
|
```bash
|
|
185
185
|
pnpm install
|
|
186
186
|
pnpm check
|
|
187
|
+
pnpm check-prices
|
|
187
188
|
pnpm preview
|
|
188
189
|
```
|
|
189
190
|
|
|
191
|
+
`pnpm check-prices` 会抓取 DeepSeek(中/英)、StepFun 官方定价页和 Tokener 公开目录,与内置费率表比对;不在 `pnpm check` 里运行,以免依赖外网。工作日定时工作流发现模型、费率、低谷窗口或节假日日历有实质差异时会开 issue;仅 Tokener `catalogRevision` 哈希变化不会判失败。
|
|
192
|
+
|
|
190
193
|
预览不使用真实密钥。可使用 `?page=session` 检查会话消费页与下轮估算卡片(124 次 StepFun 请求、7,161,128 tokens;预览夹具含现在 /compact),使用 `?page=usage` 查看独立统计页并下钻会话,使用 `?page=usage&lang=en&theme=dark` 或 `?lang=zh-tw` 检查英文、繁体中文与深色主题,`?state=missing` / `error` / `empty` / `loading` 检查不同状态。顶部示例模型选择器可验证底部 provider / 模型切换与可展开的估算。估算计算说明见 [估算是怎么算的](./docs/estimates.md)。StepFun 余额与模型查询、新版账户页面自 `0.6.0` 起提供。实时模型余额和统计修复自 `0.7.0` 起提供。
|
|
191
194
|
|
|
192
195
|
## License
|
package/README_EN.md
CHANGED
|
@@ -36,9 +36,9 @@ The composer readout follows the current session’s provider and model. The Set
|
|
|
36
36
|
|
|
37
37
|
## Compatibility
|
|
38
38
|
|
|
39
|
-
Plugin `0.
|
|
39
|
+
Plugin `0.16.1` 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` and `0.2.3` prereleases starting at `0.2.3-alpha.1` (confirmed to admit `0.2.3-alpha.3`), so package managers can resolve them under standard semver rules. The Cordis peer range is `^4.0.5`. The React / React DOM peer range is `^18.2.0 || ^19.0.0`, so the plugin can load on DSH 0.2.2 (React 18) and DSH 0.2.3 (React 19). Development dependencies remain pinned to DSH `0.2.2-rc.1`, Cordis `~4.1.0`, and React 18 for reproducible builds, without dropping React 18 hosts.
|
|
40
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`.
|
|
41
|
+
Installation and startup were verified with the web profile on DSH `0.2.1-rc.3` and `0.2.2-rc.5`. Compatibility with DSH `0.2.3-alpha.3` is covered by peer/semver tests, API checks, and session-billing fixtures (a full GUI start was not run in this environment). For DSH `0.2.1-rc.2`, use plugin `0.11.0`. For DSH `0.2.0-rc.2`, use plugin `0.10.2`.
|
|
42
42
|
|
|
43
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:
|
|
44
44
|
|
|
@@ -47,7 +47,7 @@ pnpm install --frozen-lockfile
|
|
|
47
47
|
pnpm pack
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
Usage reads
|
|
50
|
+
Usage reads current read-only `SessionPersistence` handles — including the official SQLite session store and idle-archived sessions after they are reopened — and uses `inheritedEventCount` to exclude events a fork, subagent, or `/side` sidebar branch inherited from its parent, so that usage is not double-counted. The conversation tab refreshes when token usage changes or a turn finishes.
|
|
51
51
|
|
|
52
52
|
Global statistics skip sessions that the current dsh cannot read, such as unsupported historical formats or damaged logs, and show how many sessions were excluded. Partial summaries are retried on the next refresh; unchanged successful sessions reuse compact usage records while failed sessions are retried. An unreadable selected session, or a collection where every session fails to read, still reports an error instead of showing zero usage.
|
|
53
53
|
|
|
@@ -146,16 +146,16 @@ Each request is attributed to its actual message source, with request headers as
|
|
|
146
146
|
|
|
147
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
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.
|
|
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` (same rates as `step-5-preview`), `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
150
|
|
|
151
151
|
|
|
152
152
|
## Next-turn estimates
|
|
153
153
|
|
|
154
|
-
The session Usage tab shows a next-turn estimate card; the same card appears when you drill into a session from Usage Statistics. The composer balance dock can expand the estimate on demand; it stays collapsed by default so it does not clutter the row.
|
|
154
|
+
The session Usage tab shows a next-turn estimate card; the same card appears when you drill into a session from Usage Statistics. The composer balance dock can expand the estimate on demand; it stays collapsed by default so it does not clutter the row, and the collapsed toggle names the cheapest next step (for example “Next-turn estimate · waiting is cheapest”) so it is useful without opening. The tab remembers whether you left it open or closed while you navigate (including session or model switches); a refresh or closing the tab returns to the default collapsed state.
|
|
155
155
|
|
|
156
|
-
The card compares four next steps: continue in the current period, wait for the next peak change, **`/compact` now** (summarizer request plus the first post-compact turn; about 4,000 summary tokens, at most a quarter of the history), and a fresh session (all cache-miss), plus how much cache saves by continuing versus starting over. It can also compare other official models already configured in this Harness that can be priced. These are estimates only; nothing is compacted or switched automatically.
|
|
156
|
+
The card compares four next steps: continue in the current period, wait for the next peak change, **`/compact` now** (summarizer request plus the first post-compact turn; about 4,000 summary tokens, at most a quarter of the history), and a fresh session (all cache-miss), plus how much cache saves by continuing versus starting over. It can also compare other official models already configured in this Harness that can be priced. The cheapest of these four steps for the current model gets a “Cheapest” badge (single-turn cost, so `/compact` rarely wins one turn). These are estimates only; nothing is compacted or switched automatically.
|
|
157
157
|
|
|
158
|
-
The token shape is the per-bucket median of the session’s most recent 8 priced requests (uncached input, cache read, cache write, output), priced through the same billing engines as usage totals rather than a second pricing path. The next turn may not match, for example after compaction, a large paste, or vision input. The full method, peak-hour rules, and limitations are in [How estimates are computed](./docs/estimates.en.md).
|
|
158
|
+
The token shape is the per-bucket median of the session’s most recent 8 priced requests (uncached input, cache read, cache write, output), priced through the same billing engines as usage totals rather than a second pricing path. The next turn may not match, for example after compaction, a large paste, or vision input. The card also lists the latest three **cache breaks** — turns where the cache-hit share collapsed (model switch, changed prefix, or a much shorter context after compaction) — with the estimated extra cost versus keeping the prefix. When there is no priced sample or the estimate fails to load, the card explains why and suggests refreshing or opening Usage. The full method, peak-hour rules, and limitations are in [How estimates are computed](./docs/estimates.en.md).
|
|
159
159
|
|
|
160
160
|

|
|
161
161
|
|
|
@@ -174,7 +174,7 @@ The local read-only route is `GET /dsh-balance/api/advice?session=…` (`session
|
|
|
174
174
|
|
|
175
175
|
- `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.
|
|
176
176
|
- `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`.
|
|
177
|
-
- `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.
|
|
177
|
+
- `GET /dsh-balance/api/advice?session=…` returns the next-turn estimate for a session (`sessionId` is also accepted), with optional `provider`, `model`, `refresh=1`, and repeated `compare=provider:model`. The response never includes prompt text.
|
|
178
178
|
- 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.
|
|
179
179
|
|
|
180
180
|
## Development
|
|
@@ -182,9 +182,12 @@ The local read-only route is `GET /dsh-balance/api/advice?session=…` (`session
|
|
|
182
182
|
```bash
|
|
183
183
|
pnpm install
|
|
184
184
|
pnpm check
|
|
185
|
+
pnpm check-prices
|
|
185
186
|
pnpm preview
|
|
186
187
|
```
|
|
187
188
|
|
|
189
|
+
`pnpm check-prices` fetches the official DeepSeek (zh/en) and StepFun pricing pages plus Tokener's public catalog and diffs them against the built-in tables. It is not part of `pnpm check`, so CI does not depend on those sites. A weekday workflow opens an issue when models, rates, off-peak windows or holiday dates drift; a Tokener `catalogRevision` hash change alone does not fail the check.
|
|
190
|
+
|
|
188
191
|
The preview uses no real credentials. Use `?page=session` for the conversation usage view and next-turn estimate card (the fixture includes compact now), or `?page=usage` for the statistics overview and session drill-down. Add `?lang=en&theme=dark` or `?lang=zh-tw` for English, Traditional Chinese, and dark mode, or `?state=missing`, `error`, `empty`, or `loading` to inspect those states. The sample model selector also exercises the composer readout and the expandable estimate. See [How estimates are computed](./docs/estimates.en.md) for the method. StepFun balance and model queries and the redesigned account page are available starting with `0.6.0`. Live model balances, and usage accounting fixes are available starting with `0.7.0`.
|
|
189
192
|
|
|
190
193
|
## License
|
|
@@ -197,7 +200,7 @@ The preview uses no real credentials. Use `?page=session` for the conversation u
|
|
|
197
200
|
|
|
198
201
|
A **Usage Statistics** entry below **Plugins** in the native sidebar opens a standalone page. It defaults to all providers and all time, with provider/date-range filters and breakdowns by provider, model, session, and day. Native `sidebar.panellist` and `main` slots keep navigation, collapsed sidebar behavior, and active styling consistent with Harness. Plugin surfaces use Harness theme colors and radii.
|
|
199
202
|
|
|
200
|
-
Usage includes completed messages and failed, retried, or cancelled attempts with a reported stream usage sample. The final sample wins within an attempt; retry boundaries count separate calls. Inherited fork events are excluded. Open statistics refresh every 15 seconds and on focus/visibility return, without polling hidden pages. Manual refresh also populates the normal revision cache. Unknown prices remain unpriced.
|
|
203
|
+
Usage includes completed messages and failed, retried, or cancelled attempts with a reported stream usage sample. The final sample wins within an attempt; retry boundaries count separate calls. Inherited fork, subagent, and `/side` branch events are excluded. Open statistics refresh every 15 seconds and on focus/visibility return, without polling hidden pages. Manual refresh also populates the normal revision cache. Unknown prices remain unpriced.
|
|
201
204
|
|
|
202
205
|
Run `pnpm preview` and open `?page=usage` (or `?page=usage&lang=en&theme=dark`) to inspect the fixture page.
|
|
203
206
|
|
|
@@ -207,4 +210,4 @@ The activity punchcard groups requests by weekday and hour in the selected brows
|
|
|
207
210
|
|
|
208
211
|
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.
|
|
209
212
|
|
|
210
|
-
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.
|
|
213
|
+
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` (same rates as `step-5-preview`), `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.
|
package/docs/estimates.en.md
CHANGED
|
@@ -15,7 +15,7 @@ Estimates use only this session’s **most recent 8 priced requests** (or all of
|
|
|
15
15
|
|
|
16
16
|
The four medians are independent, so the synthetic “typical turn” may not match any single historical request. The next turn may also differ after compaction, a large paste, or vision input.
|
|
17
17
|
|
|
18
|
-
If the session has no priced requests, the card
|
|
18
|
+
If the session has no priced requests, the current model cannot be priced, or the estimate fails to load, the card and the composer dock explain why and suggest refreshing or opening Usage. They do not show $0.
|
|
19
19
|
|
|
20
20
|
## The four next steps
|
|
21
21
|
|
|
@@ -40,8 +40,12 @@ Plans, discounts, account-specific rates, or unrecorded historical price changes
|
|
|
40
40
|
## Where to find it
|
|
41
41
|
|
|
42
42
|
- The current session’s Usage tab, and the usage-page drill-down after you click a session name, both show the full estimate card.
|
|
43
|
-
- The balance dock under the composer can expand the same estimate on demand; it stays collapsed by default.
|
|
44
|
-
- Local read-only API: `GET /dsh-balance/api/advice?session=…` (`sessionId` is also accepted; optional `provider`, `model`, and repeated `compare=provider:model`). Loopback only; the payload never includes prompt or session text.
|
|
43
|
+
- The balance dock under the composer can expand the same estimate on demand; it stays collapsed by default. The tab remembers the open/closed state while you navigate; a refresh or closing the tab returns to the default.
|
|
44
|
+
- Local read-only API: `GET /dsh-balance/api/advice?session=…` (`sessionId` is also accepted; optional `provider`, `model`, `refresh=1`, and repeated `compare=provider:model`). Loopback only; the payload never includes prompt or session text.
|
|
45
|
+
|
|
46
|
+
## Cache breaks
|
|
47
|
+
|
|
48
|
+
The card compares each priced request with the previous one. When the previous request hit at least 50% of its prompt, this prompt has at least 2,000 tokens, and the hit share fell by at least 40 percentage points, it is recorded as a **cache break**; the latest three are shown. The cause is a heuristic: a different model or provider → model switched; a prompt under 60% of the previous size → context shrank (possibly a compaction); anything else → prefix changed. Extra cost is the difference between this request's actual usage and a counterfactual that keeps the previous hit share — still an estimate.
|
|
45
49
|
|
|
46
50
|
This version has **no** agent tool the model can call. A read-only `dsh_balance_advise` tool is still on the [roadmap](../ROADMAP.md). Until then, use the UI or the local HTTP route above.
|
|
47
51
|
|
|
@@ -51,4 +55,4 @@ Local preview (no credentials):
|
|
|
51
55
|
pnpm preview
|
|
52
56
|
```
|
|
53
57
|
|
|
54
|
-
Then open `?page=session` for the conversation usage view and advisor card, or `?page=usage` for the statistics overview and session drill-down. Add `&lang=en`, `&lang=zh-tw`, or `&theme=dark` as needed.
|
|
58
|
+
Then open `?page=session` for the conversation usage view and advisor card, or `?page=usage` for the statistics overview and session drill-down. Add `&lang=en`, `&lang=zh-tw`, or `&theme=dark` as needed. Empty and error guidance: `&advice=empty`, `&advice=unpriced`, or `&advice=error`.
|
package/docs/estimates.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
四个桶的中位数是独立计算的,因此合成的「典型一轮」可能与任何单次历史请求都不完全相同。下轮实际用量也可能不同,例如上下文压缩、大段粘贴或视觉输入。
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
没有已计费请求、当前模型无法计价,或估算暂时加载失败时,卡片和余额条会说明原因,并提示重新估算或打开用量统计查看请求,而不会把费用显示为 $0。
|
|
19
19
|
|
|
20
20
|
## 四种下一步
|
|
21
21
|
|
|
@@ -40,8 +40,12 @@
|
|
|
40
40
|
## 在哪里查看
|
|
41
41
|
|
|
42
42
|
- 当前会话的「消费」页,以及用量统计里点击会话名后的下钻页,都会显示完整估算卡片。
|
|
43
|
-
-
|
|
44
|
-
- 本机只读接口:`GET /dsh-balance/api/advice?session=…`(也可用 `sessionId`;可选 `provider`、`model` 与重复的 `compare=provider:model`)。仅本机可访问,响应不含 prompt 或会话正文。
|
|
43
|
+
- 聊天框下方的余额条可按需展开同一估算,默认收起;同一标签页内会记住展开或收起,刷新或关闭标签页后恢复默认收起。
|
|
44
|
+
- 本机只读接口:`GET /dsh-balance/api/advice?session=…`(也可用 `sessionId`;可选 `provider`、`model`、`refresh=1` 与重复的 `compare=provider:model`)。仅本机可访问,响应不含 prompt 或会话正文。
|
|
45
|
+
|
|
46
|
+
## 缓存断层
|
|
47
|
+
|
|
48
|
+
卡片会比较相邻两次已计价请求:若上一次缓存命中率不低于 50%、本次提示至少 2,000 tokens,且命中率下降至少 40 个百分点,就记为一次「缓存断层」,最多显示最近 3 次。原因是启发式判断:换了模型或 provider → 切换了模型;提示长度不足上一次的 60% → 上下文大幅变短,可能刚压缩过;其余 → 前缀发生变化。多花的费用按本次请求的实际用量与「保持上一次命中率」的反事实用量之差估算,仍然只是估算。
|
|
45
49
|
|
|
46
50
|
本版本**没有**可供模型调用的 agent tool。只读的 `dsh_balance_advise` 仍在[路线图](../ROADMAP.md)中;在此之前,请使用上面的界面或本机 HTTP 接口。
|
|
47
51
|
|
|
@@ -51,4 +55,4 @@
|
|
|
51
55
|
pnpm preview
|
|
52
56
|
```
|
|
53
57
|
|
|
54
|
-
然后打开 `?page=session` 查看会话消费页与估算卡片,或 `?page=usage` 查看统计总览并下钻到某个会话。可加 `&lang=en`、`&lang=zh-tw`、`&theme=dark`。
|
|
58
|
+
然后打开 `?page=session` 查看会话消费页与估算卡片,或 `?page=usage` 查看统计总览并下钻到某个会话。可加 `&lang=en`、`&lang=zh-tw`、`&theme=dark`。空态与失败引导可用 `&advice=empty`、`&advice=unpriced`、`&advice=error`。
|