dsh-balance-peek: Balance and Peak-to-Valley Readings at the Sidebar Bottom

---
title: "dsh-balance-peek"
truncated: true
---

# Prelude

When calling models or running agents in DeepSeek Harness (DSH), verifying your balance and which pricing period is in effect usually requires switching to the DeepSeek web console or opening another page. There are already community plugins that estimate costs per session, but “today’s spending” is hard to reconcile with official figures when the same API Key is shared across processes and clients.

Here we introduce **dsh-balance-peek**: it displays, as two lines of plain text at the bottom of the sidebar, the top-up-related total returned by the official balance API, plus the current peak/off-peak status and the countdown to the next switch as calculated per DeepSeek’s pricing page rules. Starting from 2.0.0 it no longer shows today’s spending; for cost tracking, use [dsh-cost-meter](https://github.com/Han-1413141/dsh-cost-meter) or the console usage page instead.

# What This Is

**dsh-balance-peek** is a DSH **client** plugin published by the maintainer [QWHYQ114514-cell](https://github.com/QWHYQ114514-cell) (npm package name `dsh-balance-peek`, current version **2.0.0**, MIT license). It mounts a read-only UI at the bottom of the DSH sidebar (slot `sidebar.footer.action`): one line for balance, one line for peak/off-peak status. In a wide sidebar you see both lines in full; when collapsed into a ~56px narrow rail it degrades to two cells: “amount / off-peak or peak”. The Host fetches the official balance, and the browser updates the time period and countdown every second using the local clock, without making additional pricing-related requests.

# UI and Behavior

Example in a wide sidebar (from the README):

Balance ¥5.43
Off-peak switches to peak in 2h14m

- **Minimal**: plain text only—no icons, charts, or animations.
- **Read-only balance**: the number comes from the official `GET /user/balance` API (full URL: `https://api.deepseek.com/user/balance`) and matches the “top-up balance” shown in the DeepSeek console. The plugin reads the total from `balance_infos[0]` (top-up + promotional wallet combined). If your account also has promotional credits, this may differ slightly from the “top-up balance” viewed separately in the console.
- **Zero configuration**: reuses the `DEEPSEEK_API_KEY` already saved in DSH; if no key is configured, it falls back to the wallet of the signed-in DeepSeek account (`deepseekAccount.getBalance()`). In the expanded details, the “Source” line shows which type of credential was used.
- **Refreshing**: the balance auto-refreshes every minute by default (plus a ~25-second Host-side cache); peak/off-peak status and countdown are computed in the browser every second. Clicking either line forces an immediate balance refresh and expands the details (current time period, last balance update time, number source).
- **No persistence**: no files are written, no ledger is kept; the plugin is stateless across restarts.

# Peak/Off-Peak Rules

Based on DeepSeek’s official pricing page ([Models & Pricing](https://api-docs.deepseek.com/zh-cn/quick_start/pricing/)):

| Period | Rule |
| --- | --- |
| Peak | **Monday–Friday** (Beijing time), excluding China statutory holidays, **9:00–12:00 and 14:00–18:00** |
| Off-peak | All other times, including **weekends**, **makeup workday weekends**, and **statutory holidays all day** |

Peak pricing is 2× the off-peak unit price. The plugin only shows the current time period and the time remaining until the next switch; it does not perform billing. The statutory holiday list is stored in the `HOLIDAY_VALLEY` constant in `lib/index.js` and `lib/client.js`; per its notes it currently covers **2026**. After the State Council announces next year’s schedule each November, the maintainer needs to update the list; otherwise next year’s statutory holidays may be treated as ordinary workdays (this affects display only).

# Installation and Enablement

The plugin is mounted via the current DSH profile’s dependencies and bundles. Before installing, it is recommended to read the source code and the MIT license in the GitHub repository and confirm it meets your expectations regarding process permissions and outbound data transmission.

Installing from npm is recommended (replace `desktop` with your profile name; the Web version is usually `web`):
```sh
dsh plugin --profile desktop add dsh-balance-peek

You can also install from GitHub or a local directory:

dsh plugin --profile desktop add github:QWHYQ114514-cell/dsh-balance-peek

dsh plugin --profile desktop add link:/path/to/dsh-balance-peek

Adding the package to dependencies alone is not enough. DSH decides which plugins to mount through the profile’s dsh.profile.bundles; this package declares dsh.bundle.patch in its package.json, so it is mounted only when present in the bundles list. dsh plugin add adds it automatically; if you edited package.json manually, confirm that the list includes dsh-balance-peek. After installation, refresh the page to see the component at the bottom of the sidebar.

Uninstall:

dsh plugin --profile desktop remove dsh-balance-peek

Typical Usage and Host API

No configuration is needed for everyday use: open DSH and ensure your credentials or DeepSeek login are available. To immediately align with the official balance, click the two bottom lines to trigger a forced refresh.

The Host side provides a read-only JSON endpoint (for UI or debugging):

GET /dsh-balance/state.json[?refresh=1]

?refresh=1 bypasses the short Host-side cache to fetch the latest balance. The API Key is used only inside the Host process to call the official API; it is not sent to the browser. Only the balance number and time-period status are returned externally. To access from another Host name (reverse proxy/LAN), set the environment variable DSH_BALANCE_TRUSTED_HOSTS (comma-separated host:port); requests still pass through loopback/same-origin checks and DSH’s connection.requestRejection (including browser session authentication).

Architecture Notes

The repository has no build step: lib/index.js (Host, ~280 lines) handles balance retrieval and the read-only routes; lib/client.js registers a React component via a hand-written window.__ModuleLoader__.load({ id, factory }), consistent with the lazy-loading form used by @deepseek-ai/dsh-client-modules under /plugins. The development and validation environment is DeepSeek Harness 0.2.0-rc.2 (desktop profile), Node ≥ 20. After modifying lib/, refresh the page (the client half supports HMR).

Use Cases and Caveats

Suitable for: developers who work long-term in the DSH sidebar and want to see the official balance and the current peak/off-peak switch time at a glance; users who don’t want to open a separate console just for “two lines of readings”.

Notes:

  • The plugin runs under the permissions of the current DSH process and will request your balance from DeepSeek on your behalf; please review the GitHub source before installing.
  • It does not track today’s API spending; for precise costs, use dsh-cost-meter or the DeepSeek console usage page.
  • The community directory SkillHub plugin page is not officially affiliated with DeepSeek or Hunyuan; it is only a community listing.

Troubleshooting

Symptom Cause / Fix
No content at the bottom of the sidebar The package name is not in the profile’s dsh.profile.bundles in package.json; add it and refresh.
Shows DEEPSEEK_API_KEY not configured… No key in credentials and DeepSeek account not signed in; go to Settings → Models to configure an API Key.
Balance shows — API call failed; expand the details to view HTTP status, timeout, etc.
The number doesn’t refresh Default polling is every minute; click the two lines to force a refresh.
Doesn’t match the console “top-up balance” The API returns the total (including promotional credits); expand to view “Source”, or use ?refresh=1.

Closing

dsh-balance-peek brings the official balance and peak/off-peak readings into two lines of text at the bottom of the sidebar. It is zero-configuration, read-only, and leaves no ledger files—a good persistent reminder within your DSH workflow. See the directory and details at SkillHub: dsh-balance-peek, and the source and installation instructions at GitHub: QWHYQ114514-cell/dsh-balance-peek.
```

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

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

Xiaoye