DeepSeek Harness Balance and Token Usage Monitoring Dashboard (dsh-usage-panel)

DSH (DeepSeek Harness) is an agent development framework, and the Web interface serves as its primary interaction entry point. When debugging or running long-term tasks, developers need to monitor account balances and Token consumption in real-time. Manually querying APIs or checking logs disrupts the workflow. The dsh-usage-panel plugin integrates monitoring capabilities to display this data directly in the session header.

dsh-usage-panel is a client-side plugin maintained by Mysterious Mark. It provides a real-time monitoring panel for DeepSeek account balances and current session Token usage within the DSH Web interface. The data is displayed in the form of colored capsules located on the right side of the session header.

Core Features

  • Balance Display: Calls the official GET /user/balance API to display total balance, topped-up amount, and granted amount.
  • Token Usage: Reads the host tokenUsage projection to display uncached input, cache hits, cache writes, output, total usage, and cache hit rate.
  • Three-Level Balance Alerts: Supports custom thresholds to change the capsule color based on sufficient/warning/insufficient balance states.
  • Recharge Entry: Provides quick access to topping up, usage details, logging into the platform, and copying links. It supports opening in a new tab, the current tab, or copying the link.
  • Query Efficiency Optimization: Polls only when the page is visible and pauses when the page is hidden; supports failure exponential backoff, a 30-second cache on the host side with a single-flight window, and manual refresh.
  • Cross-End Compatibility Strategy:
  • Host Side: Prioritizes ctx.connection.fetch and falls back to ctx.webServer.
  • Browser Side: Prioritizes conversation.session.header.utilities, followed by conversation.session.header.corner.
  • Pure JavaScript Implementation: Contains no platform-specific code.

Installation and Activation

Run the following command in the terminal to install the plugin to the Web profile:

dsh plugin --profile web add dsh-usage-panel

After installation, restart dsh web (or wait for hot reload) and refresh the page to see the effect.

Typical Usage and Configuration

After installation, the panel automatically appears on the right side of the session header. To adjust parameters, you can configure the following fields in the patch:

Field Default Value Description
routePath /api/usage-panel/balance Route on the host side used to receive balance requests
cacheMs 30000 Upstream cache time and single-flight window (milliseconds)
apiKeyEnv DEEPSEEK_API_KEY Environment variable name used to resolve the API key
baseUrl https://api.deepseek.com Provider API address
baseUrlEnv DEEPSEEK_BASE_URL Environment variable name used to override baseUrl

Use Cases and Notes

  • Host Side: Requires Node.js version 18 or above. The plugin runs with the permissions of the current dsh process. Please inspect the source code and license before installation.
  • Browser Side: Relies on built-in React and slots services.
  • Fault Tolerance: If the host side lacks the useProjection projection, balance information will still be displayed normally.

This plugin solves the pain points of balance monitoring and usage tracking through a visual panel, making it suitable for DSH users who need continuous cost monitoring within the Web interface.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye