The Web plugin ecosystem of DeepSeek Harness (DSH) allows developers to inject functionality into the chat interface. The dsh-account-quota plugin addresses the difficulty of intuitively checking account status in the Web interface. It adds a persistent line below the input box to display the actual account balance, usage percentage, and today’s consumption, with typography consistent with DSH’s built-in conversation statistics pills.

Plugin Overview

This is a DSH Web plugin maintained by developer shxiaooo and released under the MIT license.

Its core feature is to display the real account balance and usage in a persistent line below the input box. It keeps the same typography and color scheme as the conversation statistics pills on the same line. This line displays two pills: one shows balance and today’s consumption (e.g., ¥12.34 · 今日 -¥0.56), and the other shows usage percentage and reset countdown (e.g., 5 小时 42% · 重置于 1小时29分).

Core Features

Direct Data Sources

Every number on the card comes directly from the provider API, without any local estimation. The plugin supports two adapters:

  • DeepSeek Official: uses kind: tokens to fetch https://api.deepseek.com/user/balance, displaying total balance and today’s consumption.
  • OpenCode Go: uses kind: plan to fetch https://opencode.ai/zen/go/v1/usage, displaying rolling, weekly, and monthly usage percentages.

Today’s Consumption Calculation

“Today’s consumption” is not simply “current balance - starting balance”. The plugin stores a balance series on the Host side and derives the result by calculating the differences between adjacent samples:
* 今日消耗 = Σ max(0, vᵢ₋₁ − vᵢ)
* 今日充值 = Σ max(0, vᵢ − vᵢ₋₁)

This difference-based accumulation method correctly handles top-up operations, and the data is persisted to disk, so it remains readable after a page refresh or process restart.

Detail Panel

Clicking a pill opens the detail panel, which shows a snapshot of all upstream fields. The panel uses the same UI skin as the DSH statistics row (stat-dialog) and includes the reset countdown and sample count information.

Layout Integration

The plugin modifies the layout through CSS selectors so that it displays side by side with the statistics row instead of starting a new line. This involves special handling of data-slot='conversation.composer.dock' to ensure the original layout of the input box card is not broken.

Installation and Configuration

Installation

Run the following command in the terminal:

pnpm dsh plugin --profile web add link:~/dsh-account-quota

After installation, you must restart dsh web so that the browser can assemble it into the boot graph at startup.

Environment Variables

Configure the following environment variables before use:
* DEEPSEEK_API_KEY
* OPENCODEGO_API_KEY

Configuration Example

In the DSH configuration file, you can adjust parameters such as timeout, cache time, and the on-disk path for state:

- id: account-quota
  config:
    # 单次上游请求超时(覆盖响应体读取)
    requestTimeoutMs: 10000
    # 上游响应体上限,边读边判
    maxResponseBytes: 65536
    # 快照新鲜度下限,同时也是 Host 半的采样周期(默认 60000ms)
    cacheMs: 60000
    # 余额序列落盘位置
    statePath: $DSH_HOME/account-quota/state.json
    # 提供方配置
    providers:
      deepseek:
        kind: tokens
        displayName: DeepSeek 官方
        apiKeyEnv: DEEPSEEK_API_KEY
        balanceUrl: https://api.deepseek.com/user/balance
        currency: CNY
      deepseek-go:
        kind: plan
        displayName: OpenCode Go
        apiKeyEnv: OPENCODEGO_API_KEY
        usageUrl: https://opencode.ai/zen/go/v1/usage
        rollingLabel: 5 小时

How It Works

Refresh Cadence

  • Host side: samples the upstream API every cacheMs (default 60 seconds) and fills the cache.
  • Client side: re-reads the snapshot every POLL_MS (default 60 seconds), without calling the upstream API directly.
  • Countdown: the reset countdown is recalculated every 30 seconds, with display precision in minutes.

The numbers on the interface can be up to about 60 seconds older than the upstream values (including one request duration).

Technical Implementation

  • Dependencies: relies on React Hooks in @deepseek-ai/dsh-client-ui-primitives (such as useAnchoredPosition and useDismissOnOutsidePointer) to handle panel positioning and dismissal.
  • Layout Fix: uses the CSS :has() selector to change the display property of conversation.composer.dock to flex, and uses !important to override the host’s display: contents. This allows the plugin row and the statistics row to share the same line while keeping the input box card (width: 100%) unaffected.
  • Data Calculation: the Host side is responsible for reducing the balance series and calculating differences; the Client side only renders the results provided by the Host.

Notes

  • Node.js Version: requires Node.js >= 22.
  • License: MIT.
  • Plugin Permissions: the plugin runs with the permissions of the current DSH process. It is recommended to review the source code before installation.

Conclusion

The dsh-account-quota plugin provides a clean, accurate, and well-integrated way to monitor account balance and usage while blending into the existing UI. By directly reading upstream APIs and using difference-based calculation logic, it avoids data bias that local statistics might introduce.