Introduction¶
When developing agents with DeepSeek Harness (DSH), if multiple model backends are connected, checking balance or usage after switching providers usually requires navigating pages or opening a new tab. Balance Panel is designed to solve this problem. It is an extensible balance/usage panel, fixed as a floating card on the right edge of the DSH Web UI. It automatically selects the content to display based on the backend used by the current session, showing only one panel at a time.
Core Features¶
- Floating and Auto-Hide: The panel stays at the right edge. It is displayed when the model in the current session matches a connected backend, and automatically hidden when switching to an unconnected provider.
- Multi-Backend Support: Built-in logic for three backends, adapted to different billing models:
- OpenCode Go: Adapted to subscription quotas, with progress bar and reset countdown.
- Zhipu: Adapted to pay-as-you-go cash balance.
- DeepSeek: Adapted to pay-as-you-go cash balance.
- Extensible Architecture: New provider support can be added by modifying the
BACKENDSarray in the configuration file, without changing client code.
Installation and Activation¶
- Run the installation script in the DSH project directory:
bash install.sh
The script runs `npm pack` and installs it to the default web profile via `dsh plugin add`.
-
Enable the panel:
- Open the DSH Web UI.
- Go to Settings -> Balance Panel.
- Turn the switch on.
- Set the refresh interval (optional: 15/30/60/120s).
-
Upgrade procedure:
- Remove the old package first (for example, via
pnpm --dir ~/.dsh/profiles/web remove @deepseek-ai/dsh-opencode-go-usage). - Run
bash install.sh. - Update the old package name in
dsh.profile.bundlesto@deepseek-ai/dsh-balance-panel. - Restart DSH.
- Remove the old package first (for example, via
Backend Semantics and Display¶
Different backends have different data display logic:
- OpenCode Go: Displays subscription quota. Includes three lines of data: remaining percentage, reset countdown, progress bar. Color thresholds: remaining ≤30% is orange, ≤10% is red.
- Zhipu / DeepSeek: Displays pay-as-you-go cash balance. Includes plain amount lines: available balance (bold), total recharges, total consumption. Gifts and frozen amounts appear only when non-zero. It does not display the progress bar and reset countdown.
Extending to New Providers¶
Add a backend object to the BACKENDS array in lib/index.js. The main logic includes:
- Route Matching: Implement the
matchesProvider(id, node)method to claim the route in the providers dictionary. - Data Parsing: Implement the
resolvePanel(ctx, providerId, node)method to fetch upstream data and normalize it into the panel structure. - Return Structure: Return an object containing a
panelobject.panel.rowsdefines row data (supports abarprogress bar, used only for quota semantics);panel.chipdefines the collapsed badge;panel.footdefines the footer annotation.
Security and Caching¶
- Server-Side Parsing: The API key is parsed only within the DSH server process, and is never sent to the browser or written to logs.
- Independent Caching: Different backends have independent caching strategies (15s for OpenCode Go, 5min for others). Failures are not cached, and the next polling retries.
- Route Protection: Includes same-origin and loopback protection; cross-site read requests return 403.
Use Cases and Notes¶
This plugin is suitable for developers who need to monitor the balance and usage of multiple API backends in real time in the Web UI. Before installing, ensure you have read the source code and checked whether the license (MIT) meets your requirements.