在 DSH 输入框下方状态行显示 DeepSeek 账户余额(充值 + 赠送),并自动刷新。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:feiniao1933/dsh-token-balance
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
dsh-token-balance

A live DeepSeek account-balance chip in the DeepSeek Harness (DSH) composer dock. 在 DeepSeek Harness 输入框下方实时显示 DeepSeek 账户余额。
English
What it does
dsh-token-balance adds a small balance chip to the composer dock — the status row below the message box, next to the context-usage meter.
- Shows the total credit (recharge balance + bonus balance) and keeps it current.
- Hover for the breakdown: total, recharge, bonus, last update time, and the refresh hint.
- Click the chip to refresh immediately.
- Refreshes automatically on mount, every 30 seconds, when the tab becomes visible or focused, and when the current turn finishes.
- Uses the signed-in DeepSeek account through the Host
account/getBalanceRemote. It never reads, stores, or sends an API key. - Signed out → "Not signed in"; read failure → "Balance unavailable" with up to three automatic retries.
- Follows the host theme tokens and the active UI language (English and Chinese dictionaries included).
Install
The npm release is not published yet. Install from the public Git repository:
dsh plugin --profile web add github:feiniao1933/dsh-token-balance
Or pin a commit (recommended for reproducible installs):
dsh plugin --profile web add git+https://github.com/feiniao1933/dsh-token-balance.git#<commit>
Replace web with your profile name. Once the npm package is published, dsh plugin --profile web add dsh-token-balance works too.
Configuration
Override the row in your profile's cordis.patch.yml:
- id: token-balance
config:
refreshIntervalMs: 30000 # 5000–3600000
How it works
The Client half reads ctx.get('remote.account').getBalance(...) and renders the chip through the conversation.composer.dock slot. The Host half only publishes the refresh interval through webserver/index-inject. There is no Host HTTP route and no extra dependency.
Amounts are formatted with the same rules as the account settings page: truncated to cents, positive sub-cent amounts shown as <¥0.01, and wallets joined with +. The chip displays the sum of recharge and bonus wallets; the tooltip keeps them separate.
Compatibility
Tested with DSH 0.2.2-rc.1 on macOS. The bundle declares dsh.bundle.patch, so it installs with dsh plugin add.
License
MIT. See LICENSE.
中文
功能
dsh-token-balance 在输入框下方的状态行(和上下文占用百分比同一行)加一个余额胶囊。
- 显示 账户可用总额(充值余额 + 赠送余额),并持续刷新。
- 悬停显示明细:总额、充值余额、赠送余额、最后更新时间,以及刷新提示。
- 点击胶囊立即刷新。
- 自动刷新:挂载时、每 30 秒、标签页重新可见/获得焦点、当前会话一轮结束时。
- 数据来自已登录 DeepSeek 账户的 Host
account/getBalanceRemote,不读取、不保存、不外发任何 API Key。 - 未登录显示“未登录”;读取失败显示“余额不可用”,并自动重试最多 3 次。
- 使用宿主主题变量,跟随明暗主题;内置中英文文案。
安装
npm 版本尚未发布。先从公开仓库安装:
dsh plugin --profile web add github:feiniao1933/dsh-token-balance
或固定提交(推荐,安装结果可复现):
dsh plugin --profile web add git+https://github.com/feiniao1933/dsh-token-balance.git#<commit>
把 web 换成你的 profile 名称;按宿主要求重启或刷新页面。npm 包发布后也可以用 dsh plugin --profile web add dsh-token-balance。
配置
在 profile 的 cordis.patch.yml 中覆盖该行:
- id: token-balance
config:
refreshIntervalMs: 30000 # 5000–3600000
实现
Client 半通过 ctx.get('remote.account').getBalance(...) 读取余额,并注册到 conversation.composer.dock;Host 半只通过 webserver/index-inject 下发刷新间隔。没有额外的 Host HTTP 路由,也没有运行时依赖。
金额格式与账户设置页一致:截断到分,正的不足一分显示为 <¥0.01,多币种用 + 连接。胶囊显示充值 + 赠送的合计,悬停时分别列出。
兼容性
在 macOS 的 DSH 0.2.2-rc.1 上测试通过。包内声明了 dsh.bundle.patch,可用 dsh plugin add 安装。
许可证
MIT,见 LICENSE。
链接
同类插件
bowenliang123/dsh-context★ 4797
DSH 上下文洞察面板:Context 仪表盘 + /context命令 + Context 浏览器,查看 Context的分类组成、内容详情、演进趋势、压缩/注入事件、统计等一站式 Context 全生命周期管理。
Han-1413141/dsh-cost-meter★ 661
会话与当日 API 费用统计、预算图框(已用%)、官方余额、历史看板,支持峰谷计价与官方价格一键同步。
wssfk12138/dsh-damage-pulse★ 289
在 DSH Web 界面追踪 DeepSeek Token 用量、单次与会话费用及账户余额,并显示缓存感知的扣费动画。
zh667/TokenLedger★ 203
侧边栏用量面板:把 Token 归属到实际服务该请求的中转站,站点从已有的 provider 配置中读出,无需额外配置;含今日/本月/累计三窗口、按站点与模型下钻、一年活跃度热力图,以及 New API / Sub2API / DeepSeek 余额。
Ychris12138/dsh-usage-stats★ 188
多供应商用量看板:按供应商/模型统计 Token 与日期下钻,统一展示账户余额,并追踪 OpenCode Go / Z.ai 订阅额度。
PolinniZhong/dsh-personal-center★ 115
DeepSeek Harness 个人中心:跨会话用量统计(按供应商/模型分别统计,自动读取已配置模型)、按模型成本估算、全局自定义指令、数据驱动的桌面宠物(位图/矢量皮肤)与会话状态概览,纯本地离线运行。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。