Turbo-Harry/dsh-status-balance ↗★ 0
dsh-status-balance
DSH host+client plugin: shows the DeepSeek API account balance as a floating badge in the bottom-right corner.
安装
此插件尚未提供可验证的 bundle,或兼容性检查未通过。请先阅读仓库说明。 阅读完整 README ↗
说明文档
阅读完整 README ↗dsh-status-balance
DeepSeek Harness 的树外(out-of-tree)双面插件:在 右下角 显示 DeepSeek API 账户余额。
- host 半身(
lib/index.js):读取DEEPSEEK_API_KEY,调GET https://api.deepseek.com/user/balance,缓存结果;一方面ctx.emit("balance/updated", …)推给所有客户端,另一方面注册只读的/status-balance拉取端点。 - client 半身(
lib/client.js):往 frame 级shell.overlay槽注册一个小角标;挂载时先fetch("/status-balance")秒出首屏,再订阅balance/updated实时刷新。
架构要点(为什么是这样)
- 密钥只在 host 侧:余额接口要
Bearer密钥,浏览器绝不能碰。host 半身零 import(credentialRef运行时是恒等函数,直接用字符串"DEEPSEEK_API_KEY")。 - 推送 + 拉取双通道:实时更新走 forwarded-event(host
ctx.emit("balance/updated")→dsh-host-apiproxy转发循环 → 客户端ctx.remote.$on,需第 1 步的 allowlist);首屏秒出走只读 HTTP 端点/status-balance(host 用ctx.webServer.register注册,client 挂载时fetch一次)。 - 右下角 =
shell.overlay槽:dsh-client-ui-layout把它渲染进一个position:absolute; inset:0; z-index:20的浮层,角标用绝对定位钉在right:16px; bottom:16px。
安装(4 步)
1. 把 balance/updated 加进转发 allowlist
编辑 @deepseek-ai/dsh-api-remotes/lib/index.js,在 API_REMOTE_FORWARDED_EVENTS 数组里加一行:
const API_REMOTE_FORWARDED_EVENTS = [
"agent-preset/selected",
// ...
"settings/document-updated",
"balance/updated" // ← 新增
];
该文件位于(本机):
/Users/wuhai/.nvm/versions/node/v22.19.0/lib/node_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai/dsh-api-remotes/lib/index.js
注:这是对第一方包的单点改动,重装 DSH 会被覆盖;客户端
$on无运行时 allowlist 校验,所以只改这一处 host 文件即可。
2. 把本包装进 web profile
dsh plugin --profile web add "file:/Users/wuhai/Desktop/untitled folder/dsh-status-balance"
(等价于在 ~/.dsh/profiles/web 里 pnpm add file:...。)
3. 注册到 ~/.dsh/profiles/web/cordis.patch.yml
把 [] 替换为:
- insert:
- id: status-balance
name: 'dsh-status-balance'