dsh-tok-qty
中文输入框状态栏上的 DeepSeek 余额 + token 用量统计。 DeepSeek balance and token-usage stats in the DSH composer status bar.
能做什么
输入框右下角那排状态信息里,多一个钱包图标和你的总余额(如 总余额 ¥31.99)。点它展开一块面板:
- 今日 / 本周 / 本月切换,总量跟着标签走
- 面板顶部是当前范围的总量(只统计 DeepSeek 的调用)
- 分时段面积图:今天按 24 小时分桶,本周按 7 天,本月按当月每天;鼠标移上去有竖线、圆点和该时段的数值浮签
- 横向柱状图:同一时间段里,本地模型和其他厂商(Anthropic、OpenAI、OpenRouter……)各用了多少,一眼看出 DeepSeek 占多大比例
- 明细行:缓存读取 / 未缓存输入 / 输出 / 缓存命中率
- 右上角刷新按钮即时重算,旁边的齿轮打开设置:面积图峰谷两色可用拾色盘拖拽选取、柱状图每个分组单独配色、五类字段逐个显示或隐藏,底部「恢复默认」一键还原
设置存在浏览器 localStorage 里,关掉面板再打开回到统计界面,不会又跳进设置。
数据从哪来:余额走 DeepSeek 官方 GET /user/balance;用量读本机里的 assistant/message 事件。全部在本机算,不上传任何东西,浏览器侧也永远看不到 API key(由宿主进程代发请求)。
余额怎么读到 key:依次尝试 DSH 的凭据服务 → DEEPSEEK_API_KEY 。所以只要 DSH 本身能用 DeepSeek,这里就能显示余额。
安装
dsh plugin --profile web add dsh-tok-qty
装完重启 DSH。插件自带 bundle patch,不需要再改 cordis.patch.yml。
兼容性
- 需要能在
conversation.composer.dock注册的 DSH 客户端(@deepseek-ai/dsh-client-ui-conversation) - 用量统计依赖多帧 zstd 解压(Node 20+ 的
zlib.zstdDecompressSync;旧版本 Node 会退化成只读到第一帧,面板显示 0)
已知边界
- dock 只在已有会话里渲染,新建会话的欢迎页没有这个药丸
- 「其他模型」的分组只按 provider 前缀判断:能认出 WorkBuddy、本地模型(lm-*/omlx/local)和常见厂商,认不出的归到「其他」
- 只统计会话日志里写下来的调用;在 DSH 之外用同一个 API key 花的钱不进这个统计(余额本身是全账户的)
What it does
A wallet icon and your total balance (e.g. 总余额 ¥31.99) join the status row at the bottom right of the composer. Click it to open a panel with:
- Today / This week / This month tabs — the headline total follows the selected tab
- The total for the selected range at the top of the panel (DeepSeek calls only)
- An area chart over time: 24 hourly buckets for today, 7 days for this week, one bucket per day for this month; hovering shows a vertical guide, a dot and a tooltip with that bucket's value
- A horizontal bar chart: how much the local models and the other vendors (Anthropic, OpenAI, OpenRouter, …) used over that same period, so you can see at a glance what share DeepSeek takes
- Detail rows: cache reads, uncached input, output, cache-hit rate
- A refresh button in the top right recomputes on the spot; the gear beside it opens settings: drag a picker to choose the area chart's peak and valley colours, colour each bar group separately, show or hide each of the five items, and restore everything with reset to defaults at the bottom
Settings live in the browser's localStorage; close the panel and open it again and you are back on the stats view, never dropped into settings.
Where the numbers come from: the balance comes from DeepSeek's official GET /user/balance; usage comes from the assistant/message events in the session logs on this machine. Everything is computed locally, nothing is uploaded, and the browser never sees the API key — the host process sends the request on its behalf.
How the key is found: the DSH credential service first, then DEEPSEEK_API_KEY. So as long as DSH itself can use DeepSeek, a balance shows up here.
Install
dsh plugin --profile web add dsh-tok-qty
Restart DSH afterwards. The package ships its own bundle patch, so there is nothing to edit in cordis.patch.yml.
Compatibility
- A DSH client that can register into
conversation.composer.dock(@deepseek-ai/dsh-client-ui-conversation) - Usage stats rely on multi-frame zstd decompression (
zlib.zstdDecompressSync, Node 20+; on older Node builds only the first frame is read and the panel shows 0)
Known limits
- The dock only renders inside an existing session; the welcome screen of a new session has no pill
- Bar grouping is decided by provider prefix: WorkBuddy, local models (
lm-*,omlx,local) and the common vendors are recognised, anything else lands in "Other" - Only calls written to the session logs are counted; spending with the same API key outside DSH never enters these numbers (the balance itself is account-wide)
No comments yet. Be the first to write one.