Introduction

In the DeepSeek Harness (DSH) development workflow, the official interface usually provides only the total balance and lacks real-time visibility into the consumption of the current session. Local token estimates are often inaccurate and cannot be directly reconciled. dsh-balance-meter provides a permanent annotation at the bottom of the DSH Web interface (below the input box, in the same row as the official statistics capsule), displaying the paid balance and the consumption of the current session in real time.

What It Is

This plugin is maintained by Amo-aibiancheng and follows the MIT License. It is a client-side plugin that directly reads balance data from the official account service (deepseekAccount.getBalance) and measures the consumption of the current session based on changes in account balance, instead of relying on local token estimates.

Core Features

  1. Persistent Annotation
    Displays a line at the bottom of the DSH Web interface, formatted as “Balance ¥XX · This session ¥YY”.

  2. Real-time Data

    • Paid balance: Taken from the official account service and consistent with the official account card; the gift balance is not combined with it.
    • Current session consumption: Measured using the account balance difference; balance increases (recharge/gift/refund) are not counted as consumption.
  3. Detail Expansion
    Click the annotation to expand the detail panel and view information such as paid balance, gift balance, balance sampling time, current session consumption, observation window, recharges during the period, and coefficient verification. Clicking also triggers an immediate balance refresh.

  4. Duplicate Billing Prevention
    The plugin discards duplicate balance reads to prevent the same consumption from being counted multiple times.

  5. Configuration Hot Reload
    All configuration changes take effect without restarting dsh.

Installation and Activation

Use the official command to install the plugin. Replace <profile> with the configuration profile name you actually use (such as desktop or web), and replace /absolute path with the actual plugin directory path.

dsh plugin --profile <profile> add link:/绝对路径/dsh-balance-meter

After installation is complete, restart dsh and refresh the page to see the bottom annotation.

Configuration Options

The configuration is located in the config: field for the corresponding plugin in the profile’s cordis.patch.yml file. All parameters have default values:

  • pollIntervalMs: Balance sampling interval (5000 – 1800000).
  • requestTimeoutMs: Timeout for a single balance query (3000 – 120000).
  • anomalyRatio: If a single balance drop exceeds this ratio of the balance, it is treated as an account event and not counted toward the session.
  • showTokenCrossCheck: Whether to display the token-converted cross-check in the details.
  • price: Unit price configuration used only for cross-checking.

Algorithm and Logic

The calculation logic for current session consumption is based on the observation sequence of the account balance:

本次消费 = Σ max(0, 上一次观测余额 − 这一次观测余额)
  • Increase handling: An observation where the balance increases is not counted as consumption; it is recorded as “recharge during the period” and raises the baseline.
  • Out-of-order handling: When observations arrive out of order, they are inserted into the correct position on the timeline; “current balance” always takes the latest observation.
  • Anomaly handling: If a single drop exceeds 50% of the balance, it is treated as an account event (such as gift expiry), and a new baseline is set.
  • Failure handling: If a balance read fails, it is marked as unreadable and is never treated as 0.

Notes

  1. Sampling Merging: Sampling is polling-based; balance changes between consecutive samples are merged.
  2. Multi-client Sharing: When multiple windows or multiple machines use the same account, “current session consumption” may be larger than expected because a shared accumulator is used.
  3. Token Conversion: Token conversion is used only for cross-checking, not as the primary figure.
  4. Gift Display: The gift balance and paid balance are displayed separately and are not combined.
  • GitHub: https://github.com/Amo-aibiancheng/dsh-balance-meter
  • Ecosystem directory: https://www.skillhub.cn/plugins/Amo-aibiancheng/dsh-balance-meter