在输入框底栏显示当前会话的预估花费,每一步都按其自身时间戳采用 DeepSeek 的峰时或非峰时单价计价。
安装
# npm 包(预构建)
dsh plugin --profile web add dsh-plugin-session-cost-pill
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:vegerot/deepseek-harness-session-cost-pill
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
该插件的 README 只有英文版本。
Live session spend, right in the composer dock.

DeepSeek tells you how many tokens you burned. It does not tell you what that cost. This plugin does — live, per session, without a single line of patched harness source.
What you get
The composer dock already tracks turns, speed, tokens, and context. The cost pill joins that row:
| Pill | Shows |
|---|---|
| ⏱ activity | turns · steps · decode speed |
| 💾 usage | total tokens · cache-hit rate |
| 💸 cost | estimated spend for this session |
| 🪫 context | context-window pressure |
The glyph climbs with the session total, so the row reads at a glance before the number does:
| 💸 | 💵 | 💰 | 🔥 | 🚨 |
|---|---|---|---|---|
| under $1 | under $5 | under $20 | under $100 | $100 and up |
Click it and the breakdown opens: uncached input, cache reads, and output, each priced separately, plus how much of the total was charged at peak rates and how many steps that covered. It closes on Escape, on a click outside, or on a second click — the browser's own popover behaviour, so the plugin ships no dialog state, listeners, or positioning code of its own.

Install
dsh plugin --profile web add ~/code/github.com/vegerot/deepseek-harness-session-cost-pill
dsh plugin --profile desktop add ~/code/github.com/vegerot/deepseek-harness-session-cost-pill
That is the whole install. No build, no bundler, no dependencies. Restart the profile and refresh.
Why the number is right
Most cost trackers multiply a session's tokens by one flat rate. That is wrong for DeepSeek twice over.
1. DeepSeek has peak pricing
Prices double during peak hours, so a single rate per model cannot price a session.
| Model | Tier | Cache hit input | Cache miss input | Output |
|---|---|---|---|---|
deepseek-flash |
off-peak | 0.003 | 0.15 | 0.60 |
deepseek-flash |
peak | 0.006 | 0.30 | 1.20 |
deepseek-v4-pro |
off-peak | 0.022 | 0.66 | 1.98 |
deepseek-v4-pro |
peak | 0.044 | 1.32 | 3.96 |
USD per 1M tokens, transcribed from Models & Pricing.
Peak is 01:00–04:00 and 06:00–10:00 UTC, Monday–Friday. Everything else — all weekend — is off-peak.
So this plugin prices every assistant step at the rate in effect for that step's own timestamp. A session that crosses a peak boundary gets a correctly blended total instead of a guess.
2. Cache hits dominate, and they are ~50× cheaper
A cache hit costs a fraction of a cache miss. A tracker that folds all prompt tokens into one bucket will miss the mark badly on a long agent session — exactly the kind that reads 96% cache-hit.
Verified against real billing
DeepSeek publishes no pricing API, but its Platform console reports authoritative cost. Checking this plugin's table
against one real account's October deepseek-flash usage:
tokens: hit 140.56512M miss 2.828971M out 0.758458M
published all-off-peak total = $1.301116
platform's own billed total = $0.453778 + ¥6.0056894
= $1.301116 at FX 7.0877 CNY/USD
A 0.11% match. The table is right, and that month's usage was effectively all off-peak — assuming peak would have doubled the estimate.
How it works
It is an ordinary Cordis client plugin. Nothing in the harness is patched, forked, or monkey-patched.
ctx.slots.inject('conversation.composer.dock', () => ctx.slots.register({
name: 'conversation.composer.dock',
id: 'cost-pill',
order: 2, // joins the activity (0) and usage (1) pills
}, CostPill));
The pill reads the chat snapshot through the session standard kit and folds it:
useChat→ every settled assistant step, each carrying its owntimeand providerusageuseProjection('modelSelection')→ the session's model
total = Σ over steps costOfUsage(step.usage, model, isPeak(step.time))
isPeak classifies one request from its UTC weekday and hour, so pricing is per-request rather than per-session.
Known limits
Honest ones, not footnotes:
- Chinese public holidays are off-peak in full, and this is not modelled. That needs a PRC holiday calendar, so weekday windows falling inside a holiday week are priced as peak — slightly overstating those days.
- The model is priced at session level. Chat assistant nodes carry
timeandusagebut not the model, so a session that switched models mid-way prices every step at the most recently used model's rates. - Account-level spend is not shown. DeepSeek's Platform console does expose real billed cost through private
endpoints that authenticate with
x-dsh-auth-token(notAuthorization: Bearer), and DSH already holds that grant viagetPlatformSession(). It is deferred here because the browser half of a Remote needs generated zod codecs.
Development
pnpm test # tsc --noEmit && node --test test.ts
pnpm typecheck # the type check alone
Types without a build step. client.js ships as plain JavaScript on purpose: the harness injects plugin
bundles into the page as a classic script (<script src>, no type="module"), so the file reaches
the JS engine verbatim. There is no build step and no runtime type stripping on the browser side.
Types therefore live in JSDoc annotations, verified by tsc --checkJs. Real, CI-visible checking with no
toolchain. test.ts is different — Node strips its types natively.
The suite pins the behaviour that matters:
- peak windows, both edges, the mid-day gap, and weekends
- published rates for both models, off-peak and peak
- one off-peak plus one peak step in a single session, asserting the summed per-step rates — the case a session-wide total provably cannot produce
- an unpriced model renders no pill rather than a wrong number
License
MIT — see LICENSE.
链接
同类插件
bowenliang123/dsh-context★ 5628
DSH 上下文洞察面板:Context 仪表盘 + /context命令 + Context 浏览器,查看 Context的分类组成、内容详情、演进趋势、压缩/注入事件、统计等一站式 Context 全生命周期管理。
Han-1413141/dsh-cost-meter★ 774
会话与当日 API 费用统计、预算图框(已用%)、官方余额、历史看板,支持峰谷计价与官方价格一键同步。
wssfk12138/dsh-damage-pulse★ 291
在 DSH Web 界面追踪 DeepSeek Token 用量、单次与会话费用及账户余额,并显示缓存感知的扣费动画。
zh667/TokenLedger★ 207
侧边栏用量面板:把 Token 归属到实际服务该请求的中转站,站点从已有的 provider 配置中读出,无需额外配置;含今日/本月/累计三窗口、按站点与模型下钻、一年活跃度热力图,以及 New API / Sub2API / DeepSeek 余额。
Ychris12138/dsh-usage-stats★ 193
多供应商用量看板:按供应商/模型统计 Token 与日期下钻,统一展示账户余额,并追踪 OpenCode Go / Z.ai 订阅额度。
PolinniZhong/dsh-personal-center★ 114
DeepSeek Harness 个人中心:跨会话用量统计(按供应商/模型分别统计,自动读取已配置模型)、按模型成本估算、全局自定义指令、数据驱动的桌面宠物(位图/矢量皮肤)与会话状态概览,纯本地离线运行。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。