DeepSeek account balance in the dsh web sidebar footer with live config hot reload and an editable Settings → Plugins card.
Install
# from npm (prebuilt)
dsh plugin --profile web add @choi-p/dsh-deepseek-balance
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:Choi-Peng/dsh-deepseek-balance
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
A persistent DeepSeek Harness Cordis plugin that shows your DeepSeek account balance in the sidebar footer, right above the Settings button.
[!NOTE] AI-generated disclaimer: This plugin was generated by AI. It may contain errors, security issues, or behave unexpectedly. Please review the code and test it yourself before use; feel free to submit an issue or PR if you find any problems.
[!IMPORTANT] Compatibility: this release targets dsh ≥ 0.1.1-rc.2 (fully supporting
0.1.1-rc.2as well as0.1.2-alpha.3~0.1.2-rc.1and later). The host provides the official two-seam configuration model (@deepseek-ai/dsh-settings) and modular client package injection (locale,ui-renderer,ui-sidebar,ui-settings-plugins).
Features
- Displays your current DeepSeek account balance at the bottom of the left sidebar, above Settings, auto-refreshing every 60 seconds.
- Three display modes: CNY only, USD only, or both; per-currency warning thresholds color the readout red below the threshold and yellow below twice it (0 disables the warning).
- Live config — deployer defaults via
cordis.patch.yml(base layer, HMR), user settings via Settings → Plugins → Balance Monitor (persisted tosettings.yamlthrough the dsh settings service); both apply without restartingdsh web. - Hides automatically when the sidebar is collapsed (rail mode).
- Reads the API key from the
DEEPSEEK_API_KEYenvironment variable.
Architecture
This is a dual-face Cordis plugin:
| Half | File | Role |
|---|---|---|
| Host | lib/index.js |
Registers the deepseek-balance settings namespace on the official ctx.settings seam (the patch-row config becomes the base layer; the Settings → Plugins → Plugin configuration tab dispatches the card), plus /deepseek-balance (proxies the DeepSeek Get User Balance API) and /deepseek-balance/settings (a thin proxy over ctx.settings: GET effective settings + revision; POST saves/resets the user layer with optimistic-concurrency revisions, answering 409 on conflict) |
| Client | lib/client.js |
Registers the balance readout in the sidebar.footer.action slot (60 s poll) and an editable Balance Monitor card in settings.plugin.item keyed deepseek-balance (rendered in the Plugin configuration tab) |
Browser (Client half) --fetch /deepseek-balance--> Host HTTP route --> api.deepseek.com/user/balance
Installation
Via plugin-registry
Settings → Plugins → Install, and set the source to @choi-p/dsh-deepseek-balance or github:Choi-Peng/dsh-deepseek-balance.
Manual Installation
dsh plugin --profile web add "github:Choi-Peng/dsh-deepseek-balance"
The package ships its own cordis.patch.yml (dsh.bundle.patch in package.json), which dsh applies automatically when installing the plugin — no need to hand-edit the profile-level cordis.patch.yml. Restart dsh web for it to take effect (plugin discovery is cached per process).
Uninstalling
dsh plugin --profile web remove @choi-p/dsh-deepseek-balance
The bundle mount disappears with the plugin; if you ever wrote the row into the profile-level patch manually, remove it first.
Configuration
The plugin settings follow the official dsh two-seam configuration model, and all layers apply live, without restarting dsh web (requires a dsh ≥ 0.1.1-rc.2 host, which ships @deepseek-ai/dsh-settings):
| Layer | Source | How it applies |
|---|---|---|
| Defaults | declared in the schema (cny, both thresholds 0) |
— |
| Base (deployer's static config) | the row config in the plugin bundle's own cordis.patch.yml (dsh.bundle.patch, applied automatically on install) |
dsh web watches the patch layer (HMR); editing it restarts this fiber with the new config |
| User (runtime settings) | Save/Reset from Settings → Plugins → Balance Monitor, persisted through ctx.settings into $DSH_HOME/settings.yaml; Reset clears the user layer and falls back to base |
hot-published by the settings service, applies immediately; this plugin never writes cordis.patch.yml |
The base-layer config (what the bundle ships):
- insert:
- id: deepseek-balance
name: '@choi-p/dsh-deepseek-balance'
config:
displayCurrency: cny # cny = CNY only | usd = USD only | both (default: cny)
warningThresholdCny: 0 # CNY warning threshold (0 = disabled); red below it, yellow below 2×
warningThresholdUsd: 0 # USD warning threshold (0 = disabled); red below it, yellow below 2×
The card exposes
displayCurrency (select: CNY only / USD only / both) and both warning
thresholds (number inputs), with Save / Reset-to-defaults. Saves carry the
read revision for optimistic concurrency — if the settings changed elsewhere,
the card reloads the latest values and tells you. The sidebar readout re-polls
every 60 s. Warning rule: balance ≤ threshold turns red, ≤ twice the threshold
turns yellow, and a threshold of 0 disables the warning.
The API key is read from the DEEPSEEK_API_KEY environment variable; it is held only by the host half and sent as a Bearer token, never exposed to the browser.
The balance API returns all of the account's currency balances (usually CNY and USD); the sidebar shows the currencies selected by displayCurrency.
Usage
- Start
dsh webwithDEEPSEEK_API_KEYset in the environment — the sidebar footer shows a balance readout above Settings, refreshed every 60 s. - Settings → Plugins → Balance Monitor card: pick the displayed currency and set warning thresholds, then Save. All changes apply live without restarting
dsh web.
Development
# Validate the host half imports cleanly:
node --input-type=module -e "import('./lib/index.js').then(m => console.log(m.name, m.inject))"
# Syntax-check the client bundle:
node -e "new Function(require('fs').readFileSync('lib/client.js', 'utf8'))"
License
Links
More in this category
bowenliang123/dsh-context★ 1728
DSH context insight panel: Context dashboard + /context command + Context browser — one-stop context lifecycle management with categorized composition, content details, evolution trends, compaction/injection events, and stats.
Han-1413141/dsh-cost-meter★ 361
Per-session and daily API cost, budget with usage %, official balance, history dashboard, and one-click official price sync with peak/off-peak pricing.
wssfk12138/dsh-damage-pulse★ 236
Tracks DeepSeek token usage, per-call and session costs, and account balance with cache-aware charge animations in the DSH Web UI.
zh667/TokenLedger★ 202
Sidebar usage panel that attributes tokens to the relay site that served each request, read from your existing provider config: today/month/all-time totals, per-site and per-model breakdowns, a year activity heatmap, and New API / Sub2API / DeepSeek balances.
Ychris12138/dsh-usage-stats★ 169
Multi-provider usage dashboard with provider/model token breakdowns, calendar drill-downs, account balances, and OpenCode Go / Z.ai subscription quota tracking.
PolinniZhong/dsh-personal-center★ 118
Personal center for DeepSeek Harness: cross-session usage statistics, per-model cost estimation, global custom instructions, a global font-size adjuster, a data-driven desktop pet with bitmap & vector skins, and a conversation status overview, all local and offline.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.