dsh-usage-state: Display balance and plan quota above the DSH input box

Preface

When switching models or engaging in continuous multi-turn conversations within DeepSeek Harness (DSH), checking remaining account balances or usage within Coding Plan 5-hour/7-day windows often requires opening separate browser tabs to visit various provider consoles. The conversation interface itself only displays token statistics; it does not inform you if you are “currently hitting a quota limit” or if the “balance is sufficient.” The dsh-usage-state plugin introduced below is a community plugin maintained by takboo. It adds a status line—matching the width of the input card—above the input box. This line displays the API balance or plan usage percentage and reset countdown for the provider associated with the currently active model, while preserving DSH’s native statistics line and context meter. It does not perform legal cost attribution, maintain price catalogs, or track historical bills; it simply answers the question: “What is the current account reading?”

What is this

dsh-usage-state is a usage state plugin for DSH (npm package name dsh-usage-state, current release version 0.4.8, README confirms compatibility with DSH 0.2.1-rc.2). In terms of categorization, it is often classified under admin-security: it relates to keys and account visibility but does not replace DSH’s built-in credential management.

Example status line (from the repository README):

z.ai / GLM · ◔ 5h 12% (4h0m) · ◔ 7d 59% (3d17h)
DeepSeek · ¥58.13

The plugin is released under the MIT license; please direct issues and attribution suggestions to GitHub Issues.

Core Features

The following capabilities are derived from the repository README. Please verify the source code and license before installation. The plugin runs under the current DSH process permissions and will access credentials and provider endpoints based on configuration.

  • Automatic Credential Reuse: For identified providers, the default is “Automatic,” reusing existing DSH credentials. Configuration is done per provider; the model list is for reference.
  • Reading Display: Balance, usage percentage, reset countdown, SVG progress rings. By default, usage ≥80% is amber and ≥95% is red. Thresholds and the option to hide progress rings can be adjusted in settings.
  • Stale Readings on Failure: Under the same valid account identity, if a source request fails, the last successful reading is retained and marked as stale, showing its age and the reason for failure. RPC transmission failures will also indicate the stale value.
  • Hover Details: Data source, mode, reset time, balance composition, etc. The interface language follows the DSH language settings.
  • Scope Boundaries: Only displays current account readings; no cost attribution, budgeting, or historical billing. May be hidden or omitted if no model is selected; clicking the status line does not open the settings page.

Supported Providers and Data Sources

The plugin selects the query target based on “Source + Mode”; explicit provider overrides take precedence over legacy source defaults. The table below is extracted from the “Data Sources” section of the README.

Source API Reading Coding Plan Reading Primary Credential
DeepSeek Official CNY/USD Balance — DEEPSEEK_API_KEY
z.ai / Zhipu GLM — 5h / 7d Used % ZAI_API_KEY etc.
Kimi / Moonshot RMB Balance Kimi Code Subscription Window MOONSHOT_API_KEY / KIMI_CODING_API_KEY
OpenCode Zen Go — 5h / 7d / 30d Used % OPENCODE_GO_API_KEY / OPENCODE_API_KEY
Sub2API Balance or Key Quota Per Instance Response (e.g., 5h / 1d / 7d / 30d) SUB2API_API_KEY and Instance URL

Supplementary Notes (README): Percentages represent usage. z.ai keys are divided into domestic/international regions; the default is the domestic address, but mirrors can be tried if that fails. Kimi Code related providers and custom providers declaring api.kimi.com / api.kimi.ai will automatically read plan usage. The current cache merges by data source and mode; it cannot treat different keys/instances as supported independent multi-accounts.

Installation and Activation

Environment Requirements (README): DSH version satisfies ^0.2.0-rc.2 || ^0.2.1-rc.1 (Documentation verified for 0.2.0-rc.2, 0.2.1-rc.1, 0.2.1-rc.2); running pre-built plugins requires Node ≥20; install to the active web profile. DSH 0.1 should use historical version 0.3.2 (not compatible with 0.2); 0.4.0 has an RPC mount defect, please upgrade to the latest compatible version.

Install from npm:

dsh plugin --profile web add dsh-usage-state
# Restart DSH after installation; bundle patch is read at startup

Install from GitHub:

dsh plugin --profile web add github:takboo/dsh-usage-state

You can also search for usage state or takboo via dsh-market; verify the actual source and version after installation. The plugin has been added to the community Featured List; catalog page visibility depends on region and build, and there is no official affiliation with DeepSeek / Hithink RoyalFlush.

Typical Usage

  1. Open Settings → Usage State to view providers, models, and detected data sources.
  2. Keep identified providers on “Automatic,” or select between supported API, Coding Plan, or Hidden modes.
  3. If using a self-hosted Sub2API, fill in the instance address in the Advanced section; once configured, the reading for the current model appears above the input box.
  4. Use “Refresh Now” for immediate updates; if an error occurs, first check the reason on the settings page and refer to the repository’s Troubleshooting Guide.

The Advanced section provides entry points for data source, endpoint, credential name, and key writing. Credential priority follows the host: DSH 0.2.1-rc.1/rc.2 Web/Desktop prioritizes saved credentials, falling back to environment variables; 0.2.0-rc.2 prioritizes environment variables. The host schedules a refresh 2 seconds after a turn ends by default, with a 5-minute fallback timer; the browser pulls RPC mirrors every 30 seconds. The default minimum interval for successful requests is 60 seconds; explicit refreshes can bypass this.

Scenarios and Precautions

Who it is for: Users who mix DeepSeek, Zhipu, Kimi, OpenCode, Sub2API, etc., within DSH over long periods and wish to see balance or plan window usage in a single interface, avoiding frequent switching to consoles.

Recommendations before installation: The DSH ecosystem philosophy is “Everything is a plugin”; community directories (like the SkillHub plugin page) are independent sites and are not equivalent to official app stores. The plugin queries balances/quotas and reads the current model and provider directory. The README states that it does not write conversation logs or report these readings to third parties; the host does not return saved key values to the browser.

Known Limitations (README Summary): It still selects a single target by source+mode; configuration identity isolation is not equivalent to parallel multi-account display. It does not save historical readings. npm versions 0.4.4 and earlier have multiple display and credential defects, please upgrade. Some paths (such as Kimi Code monthly quota real accounts, Sub2API real accounts, etc.) are marked in the documentation as still lacking live experience validation. For a complete list, see the Backlog.

Conclusion

dsh-usage-state consolidates “how much is left in the account corresponding to the current model” into the area above the conversation input area. Using automatic credentials and configurable API/Coding Plan modes, it covers the major common domestic providers listed in the README. If you intend to install or contribute to adaptations, refer to the repository README and CHANGELOG.

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

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

Xiaoye