dsh-token-ledger
其他 活跃维护

dsh-token-ledger

wakeup595626-cmyk/dsh-token-ledger

提供Provider无关的累积token统计,实时捕获调用数据并支持历史回填。内置悬浮面板直观查看用量,同时开放HTTP API便于集成监控,让模型消耗一目了然。

0
Stars 标星
0
Forks 分支
0
Watchers 关注
0
Open Issues
JavaScript
主要语言
BSD-3-Clause
开源协议
58 KB
仓库大小
1 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:wakeup595626-cmyk/dsh-token-ledger
git clone https://github.com/wakeup595626-cmyk/dsh-token-ledger.git
git clone git@github.com:wakeup595626-cmyk/dsh-token-ledger.git
README.md main

@dsh-external/dsh-token-ledger

中文 | English

为 DeepSeek Harness 提供跨提供商的全局累积 token 用量账本:实时捕获、历史回填、可拖拽悬浮面板与 HTTP API。

账本采用与官方 dsh-token-meter 相同的 usage 事件契约,因此与具体 API 提供商无关。

  • 实时:订阅 session/event,增量消费所有活跃会话。同一 (turn, step) 的重复样本会被替换而非累加,llm/retry-started 用于关闭当前样本窗口。
  • 历史:启动时异步回填 sessions 根目录下所有 session.jsonl.zstd——拼接 zstd 帧、逐帧解压、按 seq 去重。因此安装插件之前产生的用量同样会被计入。
  • 面板:左下角 FAB 打开悬浮面板,可拖拽且位置持久化在 localStorage,每 5 秒轮询一次 API;统计以「亿」(1e8 tokens)为单位展示。
  • 持久化:~/.dsh/token-ledger/ledger.json,采用 tmp + rename 原子写与定时防抖。
  • 失败自闭合:全部路径都有 try/catch,统计异常绝不影响会话主流程。

安装

dsh plugin --profile web add github:wakeup595626-cmyk/dsh-token-ledger

使用

点击左下角 FAB 打开面板。HTTP API 位于 /@dsh-external/dsh-token-ledger/api。

环境要求

第三方声明

无第三方运行时依赖,zstd 解压交由 host 运行时完成。

详见 THIRD_PARTY_NOTICES.zh.md(English)。

社区与支持

参与贡献

参见 CONTRIBUTING.zh.md(English)。

引用

@misc{dsh-token-ledger,
  title={dsh-token-ledger},
  author={wakeUp595626-cmyk},
  year={2026},
  publisher={GitHub},
  howpublished={\url{https://github.com/wakeup595626-cmyk/dsh-token-ledger}},
}

许可证

BSD-3-Clause