dsh-balance-plugin:在 DSH Web 侧边栏查看 DeepSeek 余额与 token 用量

前言

在 DSH 中调用 DeepSeek API 时,余额和 token 用量通常要另开接口查询,或者去翻会话日志。dsh-balance-plugin 把这两类信息放进 dsh web 侧边栏底部,提供 Today / All-time 切换,并且只统计 deepseek-official,避免把其他厂商的调用混入同一组数据。

这是什么

dsh-balance-plugin 是 DeepSeek Harness (DSH) 的 web 插件。它的主要作用是:在 web 侧边栏底部显示 DeepSeek API 余额和 token 用量,支持今日/全部切换,仅统计 deepseek-official

公开仓库地址:

https://github.com/stevenx65/dsh-balance-plugin

许可证:MIT

核心功能

显示 DeepSeek API 余额

  • 调用 DeepSeek 官方接口 GET /user/balance
  • 复用 dsh 的 credentials:~/.dsh/.credentials.yaml
  • 无需手动输入 API key。

显示 token 用量

  • 读取 dsh session logs:~/.dsh/sessions/<scope>/<session-id>/session.jsonl.zstd
  • 按 provider 聚合:
  • uncached input
  • cache read
  • output
  • model call count
  • 仅统计 provider=deepseek-official,忽略其他厂商。

切换与展示

  • 支持 Today / All-time 切换。
  • Today 范围使用北京时间。
  • All-time 范围为全部历史。
  • 自动适配浅色/深色主题。
  • 注入 web 侧边栏底部按钮和浮动面板,挂载位置为 sidebar.footer.action

安装与启用

1、从插件目录安装

dsh plugin --profile web add dsh-balance-plugin

2、安装后重启 dsh web,然后刷新页面。

侧边栏底部会出现 balance 按钮。

手动安装

需要把以下文件复制到:

~/.dsh/profiles/web/node_modules/dsh-balance-plugin

文件包括:

index.js
client.js
cordis.patch.yml
package.json

然后在 ~/.dsh/profiles/web/cordis.patch.yml 中添加 iddsh-balancenamedsh-balance-plugininsert 条目,例如:

- insert:
    - id: dsh-balance
      name: dsh-balance-plugin

保存后重启 dsh web,再刷新浏览器页面。

典型用法

安装并启用后,打开侧边栏底部的 balance 按钮,可以查看 DeepSeek API 余额和 token 用量,并切换:

Today
All-time

数据接口为:

/dsh-balance/data?scope=today|all

其中 scope 可取 todayall

适用场景与注意

适合经常在 dsh web 中使用 DeepSeek 官方 API,并希望快速查看余额、今日用量或全部历史用量的开发者。

使用前注意:

  • 插件以当前 dsh 进程权限运行,安装前应检查源码与许可证。
  • 该插件仅聚合 provider=deepseek-official,其他厂商不计入。
  • Today 范围使用北京时间。
  • Node 端需要 zstd CLI,用于解压 session logs。
  • 浏览器端 peer dependency 为 @deepseek-ai/dsh-client-ui-primitives 0.1.0-rc.6

链接

  • 目录页:https://www.skillhub.cn/plugins/stevenx65/dsh-balance-plugin
  • GitHub:https://github.com/stevenx65/dsh-balance-plugin
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜