dsh-rely: Persistently display relay balance above the DSH input box

Preface

When having long conversations in DeepSeek Harness (DSH), the balance of your API relay station often requires opening a separate page or running a manual curl to check. Discovering rate limits or a 402 error only when the balance hits rock bottom is a common experience. The community plugin dsh-rely (maintainer: xiaoming132887, category: client-side) consolidates the “relay station name + balance” into a single status bar above the chat input box, with the number’s color acting as a threshold indicator. The balance is fetched periodically by the host process, so the API key never enters the browser page.

What Is This

dsh-rely is a client-side plugin for DeepSeek Harness: it occupies a dedicated line directly above the chat input box, displaying a hard-coded relay station name (default: “绿萝”) and the current balance. Clicking the status bar opens a bottom settings drawer where you can configure the API key, server-side refresh interval, and green/yellow threshold lines (USD). It does not crowd the input box, nor does it occupy token or context bar space.

Repository: https://github.com/xiaoming132887/dsh-rely
Directory page: https://www.skillhub.cn/plugins/xiaoming132887/dsh-rely
License: MIT (see repository LICENSE); current package version 0.1.0.

Core Features

UI and Interaction

The status bar is minimal: relay station name + balance. The balance number’s color indicates its state (above the green threshold → green, between green and yellow → yellow, below → red). Clicking the status bar expands a drawer with three main inputs: API Key, Server Refresh (seconds), and Green / Yellow Thresholds (USD).

Fetching and Security Model

The balance is requested from the relay station by the host process (Node-side src/index.js) at the configured interval, with results written to a cache. The browser half only reads the cache, so the target site does not need to enable CORS for the page, and the API key never enters the frontend DOM. The relay station’s display name and base URL are hard-coded in the source (default 绿萝 / https://zdxjl.com) and cannot be changed via the UI. Once saved in the drawer, the key is locked and persisted to $DSH_HOME/rely/state.json (permission 0600), surviving restarts.

Supported Balance APIs

Endpoints are probed in order; the first one that returns a parseable number wins. If all fail, “Query failed” is shown — no fake numbers are fabricated. Authentication is always Authorization: Bearer <sk-…>.

Relay Station Type Request Field Extracted
Sub2API GET {base}/v1/usage?start_date=&end_date=&timezone= remaining / quota.remaining (currency from unit)
new-api POST {base}/api/user/self data.available_balance (USD) or data.quota (500000 ≈ $1)
one-api GET {base}/api/user/balance balance
OpenAI-compatible billing GET {base}/v1/dashboard/billing/credit_grants total_available

Note: hard_limit_usd is not a balance, and the plugin will not use it to substitute the real balance.

Key Source Priority

  1. The key saved in the drawer (once locked, an empty save will not clear it);
  2. If not saved, falls back to the DSH credential ZDXJL_API_KEY (refs in $DSH_HOME/.credentials.yaml, or the same-named environment variable).

Installation and Activation

The DeepSeek Harness ecosystem emphasizes “everything is a plugin”. Community directories like SkillHub are independent sites with no official affiliation with DeepSeek or 幻方. Before installing, it is recommended to browse the repository source and the MIT license — the plugin runs with the full permissions of the current DSH process and will hold any API keys you configure.

Install from GitHub

dsh plugin --profile <your profile name> add github:xiaoming132887/dsh-rely

Desktop profiles are usually named desktop, while DSH Web profiles are typically web — check the actual directories under $DSH_HOME/profiles/.

After installation, you must restart DSH once: the host half is loaded only once at process startup, and merely disabling/enabling plugins will not re-import Node modules.

Typical Usage

  1. After installing and restarting DSH, a status bar should appear above the input box on the chat page.
  2. Click the status bar and fill in the API Key (sk-…) in the drawer (or configure ZDXJL_API_KEY in DSH credentials beforehand).
  3. Set the Server Refresh (seconds) (1–60; the documentation recommends at least 30 seconds to avoid rate limits from frequent usage polling).
  4. Set the green threshold and yellow threshold (USD), save, and observe the number’s color change.

To refresh the balance immediately, the browser fetches the cache through the host route. The host provides GET/POST /rely/balances (?force=1 or POST triggers an immediate fetch, throttled at 1.5s). Configuration read/write goes through GET/POST /rely/config (the key is returned only as a masked preview).

If you use a non-default relay station, you need to edit the hard-coded constants in src/index.js and restart:

const RELAY_NAME_LOCKED = '绿萝'
const RELAY_BASE_LOCKED = 'https://zdxjl.com'
const RELAY_KEY_ENV = 'ZDXJL_API_KEY'

RELAY_KEY_ENV should match the key name you stored in DSH credentials.

Use Cases and Notes

Who it’s for: Developers who use a fixed relay station (default: 绿萝 / zdxjl.com) and want to see the balance and threshold alerts at a glance within the DSH conversation interface.

Notes:

  • The station name and URL cannot be changed in the UI; switching stations requires editing the source code and restarting.
  • A locked key must be updated via the “Change Key” flow in the drawer; override requests without unlockKey: true will be ignored.
  • Editing client/client.js requires a page refresh; editing src/index.js requires a DSH restart.
  • Troubleshooting: “Query failed” shows red text in the drawer (401/403 usually indicates a key issue); “Not configured” means no usable key; all /rely/* returning 404 usually means the host did not load — confirm the plugin is enabled and restart DSH.

Conclusion

dsh-rely consolidates the relay station balance into a single line above the input box, using host-side fetching and read-only frontend caching to balance display and security. For installation commands, API tables, and troubleshooting tables, refer to the GitHub README.

  • Directory page: https://www.skillhub.cn/plugins/xiaoming132887/dsh-rely
  • GitHub: https://github.com/xiaoming132887/dsh-rely
羽毛球分组比赛记分
小程序二维码

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

Xiaoye