DSH (DeepSeek Harness) adopts the “everything is a plugin” philosophy and supports extending Web client features through plugins. When developing or debugging agents in the Web interface, real-time visibility into the DeepSeek API account balance and today’s usage is key to cost control. The dsh-deepseek-balance plugin integrates these two data points directly into the bottom of the left rail, allowing instant viewing without navigating to another page.

This is a Web client plugin maintained by qschen86, used to display a balance badge and usage statistics at the bottom of the DSH interface sidebar.

Core Features

  • Balance Badge: Displayed in the sidebar.rail.footer slot. The content shows the current balance + today’s usage. When the balance is below 5 yuan, the badge color turns red.
  • Detail Panel: Clicking the badge opens a panel that displays balance details (CNY/USD), today’s usage amount and token count, and the 30-day usage curve (calculated from local snapshot deltas).
  • Auto Refresh: Data is refreshed at session start or at the end of a turn. It uses a 60-second cache + single-flight deduplication + server-side throttling mechanism. If a refresh fails, it falls back to the last successfully retrieved snapshot (Stale data).
  • Usage Statistics: Based on incremental scanning of session logs (combined with a watermark and Liveness mechanism); it does not replay the full historical logs, ensuring statistical efficiency.

Installation and Enablement

  1. Install the plugin:
    dsh plugin --profile web add dsh-deepseek-balance
(You can also directly specify the tarball path of a GitHub Release, but the first method is more concise. After installation, you can verify the entry using `dsh --profile web --dump-config`.)
  1. Restart the dsh web service (for some configuration to take effect).
  2. Refresh the browser page (for some configuration to take effect).

Typical Usage

  1. Configure Credentials: Open DSH settings, locate the “Credentials” option, and add a credential named DEEPSEEK_API_KEY with the value set to your DeepSeek open-platform API key.
  2. Verify Display: After refreshing the page, a balance badge should appear at the bottom of the left rail.
  3. View Details: Click the badge to open the detail panel and view balance details and the usage curve.

Notes and Known Limitations

  • Version Compatibility: This plugin was validated on dsh 0.1.0-rc.6. The balance and usage panels are fully based on official slots and service injection, and are typically compatible after upgrades.
  • Manual Patch (Known Issue): In the currently validated version, the “Deep diving…” whale spout animation and the Plugin Inventory tab require manual patching of two client files inside the closure (dsh-client-ui-conversation / dsh-client-ui-settings-plugin-inventory). These patches are lost after a dsh upgrade and must be reapplied, but they do not affect the balance and usage features.
  • Permissions and Privacy: The plugin reads the API key only through ctx.credentials, does not access other storage, and does not read any configuration other than credentials.

The plugin visualizes API usage through official slots and is suitable for developers who frequently call the DeepSeek API locally. The project source code and detailed documentation are available on GitHub.