TokenLedger
zh667
Relay-site attributed token usage for DeepSeek Harness — zero config, no credentials
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:null5069/dsh-better-stats
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
DSH Web 输入框下方的增强统计条:官方人民币计价(峰谷时段、官方价目自动同步)、多模型分账、实时计时、子代理树合并、余额直连、预算预警、流式成本估算。
DeepSeek 官方 | 余额 ¥8.67 | 本轮 ¥0.1676 · 会话 ¥29.49 | 20 轮 · 345 步 | LLM 1h 12m · 工具 5m 6s | 首token平均 3.88s · 111.72tok/s | 缓存 103.98M · 命中 98.64% | 输入 1.44M · 输出 336.53K
api.deepseek.com/user/balance(DEEPSEEK_API_KEY 走 DSH credentials seam,key 不进入浏览器),15s 缓存刷新;点击余额组可强制刷新(切换模型/API 后余额不会自动更新,点击即穿透缓存直查,host 端 2s 冷却防刷);悬浮层显示赠送/充值拆分(字段缺失时优雅降级为总额)、可用天数估算(按今日消耗与历史日均 EWMA 平滑)与低余额时的充值链接价源 DeepSeek 官方 2026-08-18 14:16);峰谷分时段(高峰 = 北京 9:00-12:00 / 14:00-18:00,价格两倍),按每条消息的 model 分账(deepseek-v4-flash / deepseek-v4-pro 各用各的价目)≈,悬浮层注明「含 N 步未定价 · 模型未知」config: { dailyBudgetCny: 20, monthlyBudgetCny: 100 }——花费组超 80% 变琥珀色、超支变红加 ⚠;悬浮层显示 今日 ¥x · 日预算 ¥20 (85%) / 本月 ¥y · 月预算 ¥100 (30%)(今日/本月按北京时区午夜/月初滚动,host 60s 缓存折叠全会话);不配置即不显示⚠,悬浮层提示,红色档附充值链接(跳官方充值页);config: { balanceWarnCny, balanceCriticalCny } 调整阈值,对应档设 0 关闭高峰中 · 空闲 14:00 开始),悬浮层显示详情(高峰中(价格×2) · 空闲 14:00 开始(3h 20m 后),每秒随 /live 轮询刷新)⋯(latex \cdots 样式);省略决策基于缓存的自然宽度,与渲染状态无关,不会闪烁振荡;Token 组拆为「缓存命中」「输入输出」两组本轮 ¥0.0364(精确 ¥0.0364 + 估算 ¥0.0000),步间估算为 0 也不闪);会话为单一数字(历史+本轮一起跳动,无分账括号);峰谷行内仅 高峰中/空闲中,详情在浮窗# 1. 在 profile 目录安装包(等价于 dsh plugin --profile web add dsh-better-stats)
cd ~/.dsh/profiles/web
pnpm add dsh-better-stats
# 2. 把它登记为 bundle(让包内 cordis.patch.yml 自动注册 better-stats 行):
# package.json 的 dsh.profile.bundles 数组里加一行 "dsh-better-stats"
# 3. 重启 dsh web,硬刷新浏览器
包内自带 cordis.patch.yml(dsh.bundle.patch),登记为 bundle 后无需手改任何配置;默认行为 = 余额告警两档(≤¥20 琥珀 / ≤¥5 红)、无日/月预算。如需自定义,在 cordis.patch.yml 的 config 里设置(均可省略):balanceWarnCny / balanceCriticalCny(余额两档阈值,对应档 0 关闭)、dailyBudgetCny / monthlyBudgetCny(日/月预算,配置即启用)。
git clone https://github.com/null5069/dsh-better-stats.git
cd dsh-better-stats # 无运行时依赖,不需要 npm install
ln -s "$PWD" ~/.dsh/profiles/web/node_modules/dsh-better-stats
# profile package.json 加依赖: "dsh-better-stats": "link:/绝对路径/dsh-better-stats",
# 再按方式一的第 2、3 步登记 bundle 并重启
| 部分 | 文件 | 说明 |
|---|---|---|
| host 半身 | lib/index.js |
/plugins/better-stats/balance(余额+赠送/充值拆分,15s 缓存,?force=1 绕过缓存且带 2s 冷却)、/plugins/better-stats/cost(整树用量+分模型 CNY 结算,10s 缓存)、/plugins/better-stats/live(实时计时状态 + 每秒成本结算 + 价目/预算载荷)、/plugins/better-stats/today(北京时区今日/本月全会话汇总,60s 缓存);官方价目 6h 抓取同步 |
| client 半身 | lib/client.js |
conversation.composer.dock 槽位统计条;本轮增量计价 + 流式估算;/live 每秒轮询;预算/峰谷倒计时悬浮层;分隔符换行自适应;余额点击刷新(闪烁反馈);可用天数估算;i18n(中/英) |
| 测试 | test/client-regression.test.mjs、test/host-apply.test.mjs、test/host-fold.test.mjs |
无依赖 Node 测试:node test/client-regression.test.mjs、node test/host-apply.test.mjs、node test/host-fold.test.mjs |
所有路由响应统一携带 pricing: { source: "official"|"builtin"|"stale", fetchedAt, tables } 与可选 budget,客户端不再硬编码价目数字。
*-delta 事件仅为抽样,完整流式文本取自 reasoning-chunks / text-chunks / tool-call-chunks 批量事件MIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: billing、cost-tracking、monitoring、token-usage、web-ui。