kkbsgg/dsh-balance
Project Overview项目介绍
dsh-balance is a DeepSeek Harness plugin that shows the account balance of the selected model provider next to the model selector in the composer. The host registers a loopback HTTP route that resolves credentials and probes the balance, while the client subscribes to the active session's model selection, polls every 60 seconds, and refreshes on click. Use it when tracking DeepSeek or custom OpenAI-compatible route balances in real time. Note: balance lookups depend on each provider's endpoint and a missing API key returns an error.
dsh-balance 是 DeepSeek Harness 插件,在对话输入框的模型选择器旁实时显示所选模型提供商的账户余额。核心机制为宿主端通过本地回路 HTTP 路由获取凭据并探测余额,客户端订阅当前会话的模型选择,每 60 秒刷新一次,点击立即更新。适用于需要随时掌握 DeepSeek 或自定义 OpenAI 兼容路由余额的场景。注意事项:余额调用依赖提供商的对应接口,若无 API Key 或接口字段变更会返回错误。
请帮我了解并安装插件:【dsh-balance】【https://github.com/kkbsgg/dsh-balance】
Send this message to DSH in your current session. CLI install commands may not be accurate across systems — DSH will figure it out for you.把上面这条消息直接发给当前会话里的 DSH,让它帮你了解并安装。安装命令不一定准确,发给 DSH 更稳。
Or use CLI install (for developers)或使用命令行安装(适合开发者)
CLI Install命令行安装
dsh plugin add @kkbsgg/dsh-balance
把 kkbsgg/dsh-balance 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-balance
DeepSeek Harness plugin that displays the selected model provider's account balance as a small text next to the composer's model seat, once a model (and its reasoning effort) is selected for the active conversation.
How it works
- Host half (
lib/index.js, a Cordis plugin) mounts one loopback HTTP route —GET /dsh-balance/balance?provider=<route>— on the webserver. The route resolves the selected provider's own API key through the standard credentials service (thellm-deepseeksection for the DeepSeek official route, thellm-pi-aiproviders table for custom/other routes), then probes the provider's balance: DeepSeek-styleGET <baseURL>/user/balancefirst, falling back to the OpenAI-styleGET <baseURL>/v1/dashboard/billing/credit_grants. The key never crosses the wire boundary. - Client half (
client/client.js, a web client plugin) registers a seat into theconversation.input.rightslot (immediately beside the model selector). It subscribes to the active session's model-selection directory (modelDirectories), passes the selected provider to the route, and only renders after a model with a non-empty id is selected — an empty selection hides the text instead of retaining a stale balance. Polls every 60s; clicking the text refreshes immediately.
Installation
From source (any DSH profile)
The package declares a dsh.bundle manifest, so it installs through the
standard plugin command once the repo is resolvable:
dsh plugin add @kkbsgg/dsh-balance
Manual (packaged DSH Desktop)
With the package resolvable from the profile's node_modules, add one loader
row to the profile patch ($DSH_HOME/profiles/<profile>/cordis.patch.yml):
- insert:
- id: balance
name: 'dsh-balance'
and restart the application so the loader composes the new row. Subsequent edits to the client bundle hot-reload through the client HMR channel.
For the packaged DSH Desktop app, the package lives in the app's unpacked
node_modules and is linked into $DSH_HOME/profiles/node_modules as a
junction, so the profile loader resolves it exactly like the in-box plugins.
Note: the package is installed by hand into the pnpm-managed hoisted store. A future
pnpm installin the profile may prune it; re-create the link if the balance text disappears after a plugin-market install.
Repository layout
dsh-balance/ (@kkbsgg/dsh-balance)
├── lib/index.js # host half (Cordis plugin + balance route)
├── client/client.js # client half (web client plugin bundle)
├── test/smoke.test.mjs # host-half smoke test (run: node test/smoke.test.mjs)
├── cordis.patch.yml # dsh.bundle patch (market installability)
├── package.json # dsh.bundle + dsh.client manifest
├── CHANGELOG.md
├── .editorconfig
└── README.md
The live copy currently installed in the DSH Desktop app lives under the app's
unpacked node_modules; this repository is the source of truth. After
changing code here, re-sync the files into the installed copy (or install the
package from this repo and re-create the profile link).
Response shape
{ "ok": true, "isAvailable": true,
"balanceInfos": [{ "currency": "CNY", "totalBalance": "110.00", "grantedBalance": "10.00", "toppedUpBalance": "100.00" }],
"fetchedAt": "2026-01-01T00:00:00.000Z" }
{ "ok": false, "code": "no-api-key", "message": "no credential configured for DEEPSEEK_API_KEY" }
MeteorNOX/DeepSeek-Balance-Whale-Widget
Han-1413141/dsh-cost-meter
zh667/TokenLedger
wssfk12138/dsh-damage-pulse
Ychris12138/dsh-usage-stats
Aisland-SJL/dsh-usage
yxxbc/dsh-balance-plugin
slywalker2006/dsh-passwords