dsh-api-balance-plugin
Resident DeepSeek API balance pill and detail popover under the composer, plus a /balance command and an api_balance agent tool.
這個插件適合誰
- 想找、想管插件的人
安装
dsh plugin --profile web add dsh-api-balance-plugin
沙箱测试结果
| 阶段 | 结果 |
|---|---|
| T0 静态检查 | — |
| T1 安装 | ✓ |
| T2 列装 | ✓ |
| T3 挂载 | ✓ |
| T4 启动 | — |
四阶段在隔离沙箱里跑:安装(有网)→ 列装 → 挂载 → 启动(后三步断网)。
README
dsh-api-balance
DeepSeek Harness 内置余额显示 · npm package: dsh-api-balance-plugin
A DeepSeek Harness plugin bundle that keeps your DeepSeek
API balance in sight: a resident pill under the composer, a click-through detail popover, a /balance command,
and an api_balance tool the agent can call on its own.
This is a Harness plugin (a Host half + a browser half + a bundle patch), not a model-facing skill.
Installing it adds real UI and a real tool to the Harness; a skill only adds instructions to the prompt.
[中文说明](#中文说明) · [Install](#install) · [Configuration](#configuration) · [How it works](#how-it-works) · [Privacy](#data--privacy) · [Limitations](#limitations)
Features
- Resident pill in the composer dock, beside the built-in activity and usage entries:
¥128.40. It refreshes on
its own and never needs a click to stay current.
- Detail popover on click: total balance, topped-up credit, granted credit, the update time, and links to the
Platform pages for usage detail and top-up.
/balancecommand: type it in the composer and the balance lands in the conversation as a plain text row.
Nothing is sent to the model and no tokens are spent.
api_balancetool: ask the agent “how much credit is left?” and it reads the same values.- Both credential styles: a signed-in DeepSeek account (wallet balances from the account grant) or a plain
DEEPSEEK_API_KEY. It picks whichever you actually have.
- Theme- and locale-aware: only
--dsw-alias-*tokens are used, and the copy follows the active UI language
(English and Chinese are bundled).
Requirements
Requirement · Notes
DeepSeek Harness >= 0.2.1-rc.2 · Tested against 0.2.1-rc.2 (desktop and web).
A credential · A signed-in DeepSeek account in the app, or the DEEPSEEK_API_KEY credential reference.
A DeepSeek account · Other providers do not expose a balance endpoint; see [Limitations](#limitations).
Install
From this repository (works today) — clone it, then install the directory:
git clone https://github.com/Muzi1015/dsh-api-balance.git
Then tell your agent:
Install the plugin bundle at <absolute path>/dsh-api-balance.
From npm (once dsh-api-balance-plugin is published) — ask your agent:
Install the dsh-api-balance-plugin plugin bundle.
Either route runs Plugin Manager's install_bundle, links the package into your profile, and enables it. You can also
install by package name from the app's Settings → Plugins area. Both survive restarts because the bundle is recorded
in your profile, not in a session.
Configuration
Two knobs, both with safe defaults. Override them by targeting the row id api-balance in your profile patch layer
(~/.dsh/profiles/<profile>/cordis.patch.yml). A matching override replaces the whole config, so repeat every
key you still want:
- id: api-balance
name: 'dsh-api-balance-plugin'
config:
refreshSeconds: 120
lowBalance: 20
Key · Default · Meaning
refreshSeconds · 60 · How often the Host re-reads the balance (clamped to 15–3600). The pill polls the Host at the same rate.
lowBalance · 5 · Below this amount the pill switches to the warning tone and the popover adds a low-balance note. 0 disables it.
Usage
Surface · What happens
Composer dock · ¥128.40 with a state dot. Green = available, amber = low balance or a failed read, grey = unavailable.
Click the pill · Popover with 总余额 / 充值 / 赠送, update time, 用量明细 and 去充值 links, plus an Esc-to-close dialog and a manual refresh button.
/balance · A command row with the same numbers; errors (no credential, 401, timeout) print their reason.
Agent tool · api_balance with an optional fresh flag to bypass the Host cache.
The popover reads through the Host, so the API key never reaches the browser: the page only ever sees amounts.
Data & privacy
- The Host reads
ctx.deepseekAccount.getBalance()when an account grant is stored; otherwise it resolves the
DEEPSEEK_API_KEY credential reference (provider store first, then the ambient environment) and calls
GET https://api.deepseek.com/user/balance.
- The browser receives a JSON snapshot of amounts only — no token, no key, no profile.
- The snapshot route is
GET /plugin/api-balance/snapshot, same-origin guarded (a cross-sitesec-fetch-site
is answered with 403; other methods get 405). It is registered on the local Harness web server only.
- The Host caches one snapshot for
refreshSecondsso several surfaces never multiply upstream calls. - Nothing is written to disk by this plugin; it keeps no history and sends no telemetry.
Limitations
- DeepSeek only. The plugin reads the DeepSeek Platform wallet. OpenAI, Anthropic and most other providers do not
publish a balance endpoint, so a generic “balance” panel is not something one adapter can cover.
- Balance, not itemized usage. The public API exposes the wallet, not a usage ledger, so “usage detail” is a link
into the Platform page where you are already signed in.
- Sign-in happens in the app. If you use an API key, that is all the plugin needs. Account wallets only appear when
the Harness account sign-in is complete.
- The pill needs a Web-surface client (the composer dock is a browser slot);
/balanceand the tool are Host-side and
work wherever a composer or an agent exists.
How it works
File · Role
index.js · Host half: one read() shared by the HTTP route, the /balance command and the api_balance tool, with a TTL cache and upstream failure reporting.
client.js · Browser half: a conversation.composer.dock entry that renders the pill and a fixed-position popover, polls the route, and follows ctx.locale.
cordis.patch.yml · Bundle patch: inserts row api-balance with its default confi
…(truncated)
以上内容来自 npm 上的 README,我们只做格式化,不改内容。
嵌入徽章
两个徽章各用自己站的标识:左边是**标准**(DSHIO 发布),右边是**检测机构**(deepseekbase 检测)。每次展示都指向标准原文和检验报告。
Markdown(推荐,两个一起)
[](https://dshio.org/10/) [](https://deepseekbase.com/zh/plugins/dsh-api-balance-plugin/)
注意:这不是认证。DSHIO/T 32 认证规则尚未启用。
版本
npm 上共发布:2,最后更新 2026-10-20
链接
常見問題
dsh plugin --profile web add dsh-api-balance-plugin。如果你用的是 DSH Desktop,也可以在插件頁面直接貼套件名。dsh --version),再看上面測試結果區的第一條錯誤。還不行就到 GitHub 倉庫提 issue。dsh plugin --profile web remove dsh-api-balance-plugin。同类插件
同類插件對比
| 插件 | 下載 | 沙箱判定 | 體積 |
|---|---|---|---|
| dsh-image-gen | 56.2K | ✅ 通過 | 35.73 MB |
| @nanmicoder/dsh-agent-teams | 51.7K | ✅ 通過 | 3.32 MB |
| @michengai/dsh-automation | 37.5K | ✅ 通過 | 26.32 MB |
| @morehao/dsh-github-trending | 11.0K | ✅ 通過 | 2.39 MB |
| dsh-speak-up | 10.9K | ✅ 通過 | 0.2 MB |
| @goodandready/dsh-cron | 8.8K | ✅ 通過 | 1.69 MB |
| dsh-openwrite | 8.1K | ❌ 裝不上 | — |
| dsh-novel-forge | 8.0K | ✅ 通過 | 1.79 MB |