- Início
- Plugins
- Uso e cobrança
- dsh-whale-ds-token-bank
dsh-whale-ds-token-bank
karsuness/dsh-whale-ds-token-bank
Automatically captures DeepSeek Harness session token usage, converts it to JY at a fixed rate, and stores the ledger locally in SQLite.
Instalar
dsh plugin --profile web add github:karsuness/dsh-whale-ds-token-bankREADME
鲸元银行 · dsh-whale-ds-token-bank
自动采集 DeepSeek Harness(DSH)会话的 Token 用量,按固定汇率折算成「鲸元(JY)」。数据只保存在本机的 SQLite 文件里,不连接任何远程服务,也没有第三方依赖。
功能
- 自动采集:监听会话事件,只处理带 provider usage 的
assistant/message;每个 turn + step 只记最后一次,模型重试另计一笔。 - 折算鲸元:默认 1,000,000 Token = 1 JY,输入、输出汇率可分别配置;缓存读写的 Token 计入输入侧。
- 本地账本:Node 内置
node:sqlite,一张流水表 + 账户 / 按日 / 按小时 / 按模型四张汇总表,同一事务写入,页面不做全表聚合。 - 侧边栏页面:券面显示累计金额,下方是累计 / 输入 / 输出 / 笔数、趋势图(当天按小时、本周、本月、本年)、模型构成、记账明细,每 15 秒刷新。
- Agent 工具:
dsh-whale-ds-token-bank,在对话里查询账本或手工补录。
安装
dsh plugin add karsuness/dsh-whale-ds-token-bank
(等价写法:dsh plugin add github:karsuness/dsh-whale-ds-token-bank。)也可以在 DSH 的插件管理里选择「添加插件」,选中本仓库的本地目录。
要求 Node.js 22.13+ 或 23.4+,即内置 node:sqlite 不再需要 --experimental-sqlite 的版本。
配置
在插件配置(cordis.patch.yml 里该行的 config)中填写:
| 字段 | 默认值 | 说明 |
|---|---|---|
captureMode | auto | auto 自动采集;manual 关闭自动采集,只保留手工补录 |
inputTokensPerJY | 1000000 | 多少输入 Token 折 1 鲸元,正数 |
outputTokensPerJY | 1000000 | 多少输出 Token 折 1 鲸元,正数 |
dataDir | 空 | 账本目录;留空时为 $DSH_HOME/data/dsh-whale-ds-token-bank |
Agent 工具
工具名 dsh-whale-ds-token-bank,必填参数 action:
| action | 用途 | 其他参数 |
|---|---|---|
summary | 累计 Token、累计鲸元、笔数、会话数 | — |
recent | 分页查看流水 | page、pageSize(1–100) |
status | 采集状态、账本文件位置、最近一次错误 | — |
record | 自动采集不可用时手工补录一条 | inputTokens、outputTokens、model、sessionId、totalTokens(默认输入 + 输出) |
数据存储
账本文件:$DSH_HOME/data/dsh-whale-ds-token-bank/ledger.sqlite(DSH_HOME 未设置时为 ~/.dsh)。
表结构、去重规则与换算细节见 docs/DETAIL.md。鲸元只是本地记账单位,不代表任何真实货币或计费金额。
可选:页面两侧的人像
仓库默认不附带页面两侧的人像图,没有这两张图时两侧留白。想显示的话,把 assets/side-left.webp 和 assets/side-right.webp 放进插件目录即可(透明背景,画布 640×857,人像底部对齐)。
English
dsh-whale-ds-token-bank captures DeepSeek Harness session token usage, converts it to a virtual unit "JY" (鲸元) at a fixed rate, and stores everything in a local SQLite file — no network requests, no third-party dependencies. It adds a sidebar page (banknote with the cumulative amount, totals, trend chart, per-model breakdown, ledger) and an agent tool with four actions (summary, recent, status, record). Requires Node.js 22.13+ or 23.4+ for the built-in node:sqlite.
Plugins relacionados
DeepSeek-Balance-Whale-Widget
meteornox/deepseek-balance-whale-widget
dsh-context
bowenliang123/dsh-context
dsh-cost-meter
han-1413141/dsh-cost-meter
dsh-damage-pulse
wssfk12138/dsh-damage-pulse