Balance and Usage (dsh-spend-meter)

Introduction

When developing and debugging agents with DeepSeek Harness (DSH), it’s often essential to keep an eye on the current account balance, today’s spending, and per-session token usage. Checking the official platform alone typically requires switching windows or refreshing pages, which is far from convenient. Below is a plugin that keeps this information always visible in the DSH sidebar and also supports budget control.

What Is This

dsh-spend-meter is a client-side plugin for DeepSeek Harness, developed by maintainer Xigong93. It displays the current account balance, today’s spending, input/output token counts, and peak/off-peak schedule at the bottom of the DSH sidebar at all times. It also provides a daily budget feature: once the budget is exhausted, it automatically intercepts DeepSeek model requests at the invocation layer to prevent spending beyond expectations.

Core Features

  • Sidebar card: Always shows balance, today’s spending, input/output tokens, peak/off-peak schedule, and the next transition time.
  • Today’s spending details: Click to open a popup showing the summary, peak/off-peak distribution, per-session breakdown, and per-model breakdown (the model breakdown only appears when multiple models are used on the same day).
  • Daily budget: Disabled by default. When enabled, it calculates today’s estimated cost recorded by Harness based on the current account’s currency (CNY shown as yuan). At 90%, the UI switches to a warning color and displays a progress bar. Once the limit is reached, DeepSeek model requests are intercepted at the host llm/stream layer with a budget-exhausted message returned; non-DeepSeek providers are called as normal.
  • Peak and off-peak hours: Monday through Friday, 09:00–12:00 and 14:00–18:00 Beijing Time are considered peak hours. All other times and weekends are treated as off-peak (half price). Statutory holidays must be defined via the holidays configuration.
  • Data refresh: Refreshes approximately once per minute (paused when the page is hidden), with a one-time catch-up refresh at transition boundaries. If no new data has been fetched for more than 3 minutes, the card dims and the tooltip notes “possibly stale.”

Installation & Activation

The plugin has no npm dependencies; it requires DSH version ≥ 0.2.2-rc.3 (uses webServer, shell.overlay, and agent/pre-step).

Local directory install (recommended during development):

  1. Place this repository in any directory, e.g., ~/.dsh/plugins-src/dsh-spend-meter;
  2. Open DSH → Plugins → Add Plugin → select that directory;
  3. Or have the Agent execute plugin_manager / install_bundle targeting that directory.

After installation, the UI language is bilingual (English and Chinese).

Typical Usage

  • Always-on sidebar: A balance and usage card automatically appears at the bottom of the sidebar (above Settings) with no additional configuration.
  • View today’s spending: Click the card, or press Tab to focus and then Enter, to open the today’s spending details popup.
  • Set daily budget: Below the “Time-of-day distribution” section in the popup, find “Daily Budget.” Toggle it on and enter the limit amount (default 20 yuan). Click away or press Enter to save.
  • Budget alert & interception: When 90% of the budget is used, both the popup and the sidebar card switch to a warning color and display the percentage. Once the limit is reached, initiating a DeepSeek model request will show a clear error message in the chat interface and pause the call. Service automatically resumes at midnight (Beijing Time) the next day.
  • Custom holidays: Add the optional configuration to the profile’s cordis.patch.yml:
- id: spend-meter
  name: dsh-spend-meter
  config:
    holidays: ['2026-10-01', '2026-10-02', '2026-10-03']
  • View balance & detailed readings: The balance is sourced from the DeepSeek account service (ctx.deepseekAccount). Full readings (balance breakdown, cache hit/miss/output tokens, session count, non-DeepSeek call count) are shown in the native tooltip on hover.

Use Cases & Notes

  • Ideal for developers and agent builders who need real-time visibility into DeepSeek spending during development and want to avoid unexpected overspending.
  • The plugin runs with the permissions of the current DSH process. It is recommended to review the source code and license (MIT) before installing.
  • Today’s spending only counts calls recorded by this Harness instance. Spending generated elsewhere (web console, other tools) using the same API key is not included.
  • Only DeepSeek models (provider name contains deepseek) have costs calculated. Other providers are counted by call count only.

In Short

This plugin brings DeepSeek’s balance and usage information directly into the DSH sidebar, and pairs with a daily budget to automatically “hit the brakes,” making agent development more predictable and controllable. For more details and source code, visit the plugin directory page and the GitHub repository.

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

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

Xiaoye