Usage and cost view for DeepSeek Harness: aggregates real token usage from existing session logs, locks each cost at the price of its event time, and shows month and today spend against a budget from a sidebar card or an input-bar pill.
Install
# from npm (prebuilt)
dsh plugin --profile web add @zzerx/dsh-plugin-usage-billing
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:0x7A7A6572/dsh-forge-studio#path:/packages/plugin-usage-billing
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
This plugin publishes its README in Chinese only.
从既有会话日志聚合真实 token 用量,按事件发生时刻的价格写时锁定费用。入口可以放在侧栏底部或输入框下方,点开就能看到本月花了多少、离预算还有多远。不伪造样本:没有数据就显示空快照,未收录的模型绝不静默计 0。
安装
dsh plugin --profile <你的 profile 名> add @zzerx/dsh-plugin-usage-billing
用量视图在设置 → 计费里。
怎么用
- 两个计费入口,各自开关(设置 → 计费 →「计费入口位置」):侧栏底部是一张卡,显示本月 / 今日金额与预算进度,卡的左侧并着一条 75×35 的 mini 峰谷图(只在侧栏宽态画);输入框下方是一粒小胶囊,显示当前会话金额与预算饼图。两处都关掉也能从设置页看用量。
- 点入口弹出详情:本月已用 / 预算、累计(会话 / 项目)、今日消耗分布(本项目 / 其他项目),以及未收录模型的提示。点面板外或按 Esc 关闭。面板顶部的峰谷时段图与侧栏卡左侧的 mini 图可以在设置里一起关掉(设置 → 计费 →「显示峰谷时段图」,默认开)。
- 设置里的用量视图分三页:概览(累计与今日的 Token 和金额、活跃度热力图、分模型消耗)、趋势、明细(逐日 / 按模型 / 生效价目三张表,可过滤、排序、分页)。
- 月度预算:设置里填金额(默认 ¥100),跨 50% / 80% / 100% 各提醒一次,进度条 ≥80% 转琥珀、超支转红。
- 峰谷分时:北京工作日 09:00–12:00 与 14:00–18:00 按高峰价,其余时段(含周末与法定节假日全天)按空闲价 = 高峰价 × 0.5。判档按事件发生时刻定,写进账本后不再随改价变动。
- 价表:内置表 + models.dev 联网投影(联网优先、内置兜底),汇率取 open.er-api.com,默认每 6 小时后台刷新,也可在设置里手动刷新。联网失败会降级为内置价并标明,不假装是实时价。
- 自定义单价与别名:可以给某个 provider / model(也支持
<provider>/*、*/*)配自定义价;未收录或已改名的模型可以手工绑到标准模型上,只在同一个 provider 内合并展示,不改动账本。
计费口径
- 写时锁定:每条助手回复的 token 用量按该事件发生时刻的价格计价并写入账本,之后改价不影响历史。只有「未计价」的行可以按当前价表重算。
- 为什么会显示「—」:价表里没有这个模型,或命中了美元价但当时没有可用汇率 —— 这两种情况都不写金额,宁可标成不可计价,也不猜一个 0 记进账本。
- 安装前的历史:插件装上之前的记录没有真实价格,按安装时的价表估算,并在三处标明是估算(设置页顶部提示条、概览 / 趋势 / 明细里的「估算」角标、常驻的口径说明)。
- 统计维度:provider / 模型 / 天 / 会话 / 工作区,按本机时区归天。子代理会话默认计入,可在设置里筛选。
- 不占用模型额度:本插件不注册任何模型工具,也不注入系统提示段。
已知边界
- 目录刷新(含它的网络请求)期间会占用写锁,此时改自定义价要等它结束。
- 改了刷新间隔要等当前缓存过期才生效。
- 会话维度的数据由「按工作区」的分组结果带回,在明细页展开工作区时才看得到。
- 热力图的单格明细只在悬停 / 触摸提示里;键盘用户读到的是上方的活跃天数与区间合计。
开发
pnpm --filter @zzerx/dsh-plugin-usage-billing build # lib/index.js + lib/client.js + lib/types
pnpm --filter @zzerx/dsh-plugin-usage-billing typecheck
License
MIT
Links
More in this category
bowenliang123/dsh-context★ 4288
DSH context insight panel: Context dashboard + /context command + Context browser — one-stop context lifecycle management with categorized composition, content details, evolution trends, compaction/injection events, and stats.
Han-1413141/dsh-cost-meter★ 635
Per-session and daily API cost, budget with usage %, official balance, history dashboard, and one-click official price sync with peak/off-peak pricing.
wssfk12138/dsh-damage-pulse★ 289
Tracks DeepSeek token usage, per-call and session costs, and account balance with cache-aware charge animations in the DSH Web UI.
zh667/TokenLedger★ 201
Sidebar usage panel that attributes tokens to the relay site that served each request, read from your existing provider config: today/month/all-time totals, per-site and per-model breakdowns, a year activity heatmap, and New API / Sub2API / DeepSeek balances.
Ychris12138/dsh-usage-stats★ 188
Multi-provider usage dashboard with provider/model token breakdowns, calendar drill-downs, account balances, and OpenCode Go / Z.ai subscription quota tracking.
PolinniZhong/dsh-personal-center★ 115
Personal center for DeepSeek Harness: cross-session usage statistics with per-provider and per-model breakdown (auto-discovers configured models), per-model cost estimation, global custom instructions, a data-driven desktop pet with bitmap & vector skins, and a conversation status overview, all local and offline.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.