- Home
- Plugins
- Usage & Billing
- dsh-plugin-token-stat
C
dsh-plugin-token-stat
chenllsu/dsh-plugin-token-stat
DSH plugin: append each answer's token usage to the conversation
Install
dsh plugin --profile web add github:chenllsu/dsh-plugin-token-statREADME
dsh-plugin-token-stat
DeepSeek Harness 插件:在每一条 AI 回答上显示本次对话消耗的 token 数。
Show the provider-reported token usage of every assistant answer inside DeepSeek Harness's web UI.
功能 / Features
- 每条 assistant 回答的操作区显示:
⚡ in 12.2K · out 456(含缓存 token 时显示cache 1.1K) - 数据来自 LLM 提供方上报的
usage字段(DeepSeek 等适配器支持时自动生效) - 服务端监听
session/event的assistant/message事件,维护每会话 token 统计 - 客户端在
conversation.chat.assistant-actions插槽渲染,不修改消息内容,不影响模型上下文
安装 / Install
dsh plugin --profile web add @choate/dsh-plugin-token-stat
或从源码 link 安装:
dsh plugin --profile web add "dsh-plugin-token-stat@link:/absolute/path/to/dsh-plugin-token-stat"
安装后重启 dsh web,然后随便发一条消息,回答右下角即显示 token 统计。
原理 / How it works
DSH 的事件溯源会话日志中,assistant/message 事件携带 usage: TokenUsage(inputTokens / outputTokens / cacheReadTokens)。本插件:
- 服务端(
src/index.ts):监听session/event,捕获每条assistant/message的 usage 并做会话级汇总(附totals()自省接口)。 - 客户端(
client/index.tsx):注册conversation.chat.assistant-actions插槽条目,从会话快照的 assistant 节点读取usage,渲染 token 标注。
开发 / Development
npm install
npm run build # tsc 编译服务端 + tsdown 打包客户端
npm run typecheck
产物:
lib/index.js— 服务端插件(cordis patch 加载)client/client.js— 客户端插件(web ModuleLoader 格式)
发布 / Publish
# 发布到 npm
npm publish
# 提交到 awesome-dsh-plugin 上架插件市场
# https://github.com/awesome-dsh-plugin/awesome-dsh-plugin
许可 / License
MIT
Related plugins
B
dsh-context
bowenliang123/dsh-context
62315 hours agoUsage & BillingApache-2.0
M
deepseek-balance-whale-widget
meteornox/deepseek-balance-whale-widget
2382 hours agoUsage & Billing
H
dsh-cost-meter
han-1413141/dsh-cost-meter
1372 hours agoUsage & BillingMIT
Z
TokenLedger
zh667/tokenledger
1194 days agoUsage & BillingMIT