dsh-usage-balance-v2: Inline display of session consumption, duration, and balance within the DSH bottom usage bar

Preface

When running long sessions in DeepSeek Harness (DSH), the native statistics bar at the bottom typically only displays token usage and context occupancy percentage. Costs, account balances, and peak/valley pricing usually require opening separate pages or manual estimation. Below is an introduction to the community plugin dsh-usage-balance-v2 (maintainer 3493750852). It embeds session consumption, session duration, and remaining balance into the official usage bar, and aggregates totals by workspace in the sidebar. It is classified as a client-side plugin.

What is this

dsh-usage-balance-v2 is a balance/consumption reading plugin located next to the usage bar at the bottom of the DSH Web interface. By default, it is inserted between the token usage and context percentage of the native statistics bar, adhering to the native font size, colors, and separators without increasing the line height. The reading format is as follows (icons are inline SVG):

… 4.8M tok · Cache Hit 98%   [¥] ¥0.77  [⏱] 4m50s  [◉] ¥230.88 Peak ⌄   13%

The three inline readings correspond to: Session Consumption, Total Session Duration, and Remaining Balance. The plugin does not rely on @deepseek-ai/* npm packages and will not trigger DSH’s version compatibility blocking. For source code and documentation, see GitHub. Community directory page: skillhub.cn/plugins/3493750852/dsh-usage-balance-v2. The DSH ecosystem emphasizes “everything is a plugin”; directories like SkillHub are community sites and have no official affiliation with DeepSeek or High-Flyer.

Core Features

Bottom Inline Readings and Detail Card

Clicking the reading area expands a detail card with the following main capabilities:

  1. Session Consumption: Reads the entire session tokens (cache hits/misses/output) from DSH’s official tokenUsage projection and calculates costs based on current peak/valley unit prices. The detail card lists the multiplication formula (e.g., Cache 4.7M × ¥0.04/M + Miss 73k × ¥2/M + Output 54k × ¥8/M). The statistical scope is consistent with the native tok and does not only count turns after the plugin was enabled.
  2. Session Duration: Reads LLM + Tool time from the official sessionStats projection and displays the step count.
  3. Remaining Balance: Prioritizes using the environment variable DEEPSEEK_API_KEY to call the DeepSeek /user/balance endpoint; falls back to the DSH account login state’s balance service (Recharge Wallet + Grant Wallet) if no API key is present. Expand to view the breakdown; failures display the specific reason.
  4. Current Period: Determines peak/valley based on Beijing Time, displaying peak rules and a countdown to the next switch.
  5. Last Turn: Displays the previous turn’s consumption, duration, tokens, model, and peak/valley status.

The plugin does not pop up a window at the end of every turn; details are concentrated in the detail card.

To the right of each workspace title row, the accumulated consumption for all sessions under that workspace is displayed (in small text on one line). Data is provided by the host route built into the main package: it reads $DSH_HOME/.dsh-usage-balance-v2.json and attributes sessions according to DSH’s workspaceRegistry. The browser POSTs the current session’s official tokenUsage / sessionStats to the route, taking max(ledger, official value) per session to prevent single-session consumption from exceeding workspace totals.

Peak/Valley Pricing

Peak: Monday to Friday (excluding statutory holidays) 09:00–12:00, 14:00–18:00. Valley: All other times, including weekends, adjusted working weekends, and all-day statutory holidays. Peak Price = Valley Price × 2.

Price List (RMB / Million tokens, [Valley, Peak]):

Model Cache Hit Miss Input Output
deepseek-flash / deepseek-v4-flash / deepseek-v4-flash-vision-exp 0.02 / 0.04 1 / 2 4 / 8
deepseek-v4-pro 0.15 / 0.3 4.5 / 9 13.5 / 27

Prices and holidays are defined in the repository’s lib/pricing.mjs under PRICING, PEAK_HOURS, and HOLIDAY_VALLEY; for 2027 and beyond, HOLIDAY_VALLEY needs to be updated after the State Council announces the schedule.

Statistical Scope (Current Session)

The cost formula used for external readings and the main value in the detail card is:

Cost = Cache Hit Tokens / 1e6 × Hit Price
     + (Uncached Input + Cache Write) / 1e6 × Miss Price
     + Output Tokens / 1e6 × Output Price

Tokens are taken from the official tokenUsage cumulative total for the entire session; prices are based on the current peak/valley period. reasoningTokens are included in outputTokens. The “Last Turn” is accumulated based on the real usage of each assistant/message step and the peak/valley price at the time the step arrived; turns spanning across 12:00 / 18:00 will have split pricing.

The local ledger file $DSH_HOME/.dsh-usage-balance-v2.json only records turns after the plugin was enabled; totals are cumulative, and today resets daily based on Beijing Time. Deleting this file resets statistics (balance is not affected).

Installation and Activation

Installation via npm is recommended (one package includes both bottom readings and sidebar workspace aggregation):

dsh plugin --profile web add dsh-usage-balance-v2

For the Desktop profile, replace web with desktop.

If using manual links or source code deployment, you must also append the following to the end of the corresponding profile’s cordis.patch.yml:

- insert:
    - id: dsh-usage-balance-v2
      name: dsh-usage-balance-v2

The DSH profile defaults to patchReload: live, so the host hot-reloads upon saving; simply refresh the page. If it still does not display, restart DSH.

Typical Usage and Verification

After installation and refresh, three readings should appear between the token usage and context percentage in the bottom usage bar; click to expand details. The workspace accumulated total should be visible to the right of the workspace title in the sidebar.

You can check if the host route is ready in the browser console:

fetch('/dsh-usage-balance-v2/state.json').then((r) => r.json()).then(console.log)
fetch('/dsh-workspace-usage-v2/state.json').then((r) => r.json()).then(console.log)

The former should return something like { ok: true, totals, balance, pricing, lastTurn, ... }, and the latter { ok: true, workspaces: [...] }.

Use Cases and Notes

Suitable for developers who need to view tokens, RMB consumption, session duration, and account balance in real-time within the DSH interface; long-term users who need to track cumulative costs by workspace or are concerned with peak/valley pricing will also find the sidebar and the period explanations in the detail card useful.

It is recommended to read the repository source code and the MIT license before installing. The plugin runs with the current DSH process permissions; be mindful of the key’s exposure scope when using DEEPSEEK_API_KEY to query balances. Without a key, it relies on the DSH login state, and behavior is subject to the official balance service. Price lists and holiday tables need to be maintained according to official price adjustments and State Council schedules; outdated HOLIDAY_VALLEY entries may affect peak/valley determination.

Conclusion

dsh-usage-balance-v2 integrates session costs, duration, and balance into the native usage bar, complemented by detailed pricing breakdowns in the detail card and workspace aggregation. It is suitable for scenarios requiring long-term conversations in DSH with cost control needs. Directory Page: https://www.skillhub.cn/plugins/3493750852/dsh-usage-balance-v2; Repository: https://github.com/3493750852/dsh-usage-balance-v2.

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

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

Xiaoye