Introduction¶
When running DeepSeek Harness locally, we often need to keep an eye on two things: how much the current session is likely to cost, and whether the account balance is sufficient. Looking at raw token usage on the interface makes it hard to quickly estimate the actual cost, and checking the official pricing page requires an extra trip. This makes cost control feel imprecise, especially during multi-turn conversations or extended debugging sessions.
DSH’s plugin system supports this kind of fine-grained UI enhancement. What follows is a walkthrough of jinquan-leung/dsh-billing-hud — a plugin that simultaneously provides session cost estimation, account balance display, and a peak/off-peak pricing calendar. All data sources can be toggled on or off in the settings.
Plugin Overview¶
Billing HUD is a client-side plugin developed and maintained by Jinquan-Leung. It hooks into DSH’s internal conversation.composer.dock and sidebar.footer.action slots to display cost below the input box and balance above the sidebar avatar. The plugin does not read, store, or upload any account credentials — it only renders UI data for the locally logged-in account. Once the balance display is turned off, no further account API requests are made.
Core Features¶
The plugin surfaces readouts in three locations, all toggleable under Settings → Plugins → Billing HUD.
Below the Input Box: Estimated Session Cost¶
Below the input box, the estimated cost for the current session is displayed, e.g. ¥0.42. Hovering over it reveals a breakdown across the four buckets: cache hit / cache miss / cache write / output. The cost is calculated from the ctx.tokenUsage projection and the modelSelection projection, multiplied against the applicable peak or off-peak tier in the pricing table. Cache writes are billed at the cache-miss input rate.
Above the Sidebar Avatar: Account Balance¶
Above the sidebar avatar, the account balance is shown along with a peak/off-peak status indicator and a top-up shortcut. Balance data is fetched via getState and getBalance on ctx.remote.account, polled at a configurable refresh interval. Display only — no writes.
Pricing Calendar & priceBand Service¶
The plugin ships with a built-in calendar of “Beijing-time peak/off-peak + Chinese statutory holidays.” Monday–Friday 09:00–12:00 and 14:00–18:00 are peak; weekends and Chinese statutory holidays are off-peak all day; off-peak rates are half of peak. The 2026 official schedule is built in, and the calendar is refreshed yearly from NateScarlet/holiday-cn (a machine-readable mirror of the State Council’s holiday announcement, fetched via jsDelivr → GitHub raw as two sources), with a 24-hour cache. On failure, it silently falls back to the built-in table.
The plugin exposes a priceBand client service: any other plugin can reuse this calendar via ctx.get('priceBand'), avoiding duplicated logic. The service includes methods such as resolveBand, isHoliday, getSnapshot, subscribe, and refresh.
Installation¶
Requires DeepSeek Harness 0.2.2 or later (with the dsh.client dual-bundle mechanism).
Option 1: Install via the UI¶
- Clone or download this repository into your DSH workspace, e.g.
<workspace>/dsh-billing-hud:
git clone https://github.com/Jinquan-Leung/dsh-billing-hud.git
-
Open DSH → Settings → Plugins → Add Plugin, and select the directory.
-
Billing HUD appears in the plugin list. A confirmation that it has been applied means it is active (refresh the page if necessary).
Option 2: Let the Agent Install It¶
In DSH, tell the Agent:
Install the local plugin at
<path>/dsh-billing-hudinto the current profile
The Agent will complete the same operation using plugin_manager’s install_bundle.
Option 3: Release Archive¶
Download the latest dsh-billing-hud-<version>.tgz from Releases, extract it, and add the directory following Option 1.
Configuration¶
Open Settings → Plugins → Billing HUD to configure the following options:
| Option | Default | Description |
|---|---|---|
| Show session cost | On | When off, no amount is shown below the input box |
| Show account balance | On | When off, the balance is hidden in the sidebar and no further account requests are made |
| Fetch Chinese statutory holidays yearly | On | When off, only the built-in 2026 schedule is used for peak/off-peak determination |
| Time-band override | Auto | Can be pinned to “peak” or “off-peak” for auditing or screenshots |
| Currency symbol | ¥ |
Symbol used for cost readouts (max 4 characters) |
| Balance refresh interval | 60 s | Range 15–3600 s; polling pauses when the window is unfocused |
| Pricing table (JSON) | {} |
Overrides the built-in rates; see below |
Settings are stored in the local browser (localStorage, key dsh.billing-hud.settings.v1) — they are not written to DSH config, not synced, and not shared.
Pricing Table¶
The built-in table is hard-coded from DeepSeek’s published prices (CNY / million tokens), with peak and off-peak tiers:
{
"models": {
"deepseek-flash": {
"peak": { "cacheRead": 0.04, "cacheMiss": 2, "output": 8 },
"offPeak": { "cacheRead": 0.02, "cacheMiss": 1, "output": 4 }
},
"deepseek-v4-pro": {
"peak": { "cacheRead": 0.3, "cacheMiss": 9, "output": 27 },
"offPeak": { "cacheRead": 0.15, "cacheMiss": 4.5, "output": 13.5 }
}
},
"aliases": { "deepseek-v4-flash": "deepseek-flash" },
"fallback": "deepseek-flash",
"unitTokens": 1000000
}
Override only the parts you want to change; everything else inherits from the built-in table:
{ "models": { "deepseek-flash": { "peak": { "output": 9 } } } }
Model keys also support provider/model exact matching (highest priority); if no match is found, it falls back to fallback. Set {} or click “Restore built-in table” to revert to defaults.
How It Works¶
- Time band: Beijing time, Monday–Friday 09:00–12:00 and 14:00–18:00 are peak; weekends and Chinese statutory holidays are off-peak all day; off-peak rates are half of peak. The 2026 official schedule is built in, and the calendar is refreshed yearly from
NateScarlet/holiday-cn(a machine-readable mirror of the State Council’s holiday announcement, fetched via jsDelivr → GitHub raw as two sources), with a 24-hour cache. On failure, it silently falls back to the built-in table. - Cost: Reads the session’s
tokenUsageprojection (four buckets: cache hit / cache miss / cache write / output) and themodelSelectionprojection (lastUsedtakes priority), then multiplies against the pricing table. Cache writes are billed at the cache-miss input rate. - Balance: Reads
getState+getBalanceonctx.remote.account, polled at the configured interval; display only, no writes.
Compatibility¶
- Slots consumed:
conversation.composer.dock,sidebar.footer.action,settings.plugins.tab - Services provided:
priceBand(resolveBand/isHoliday/getSnapshot/subscribe/refresh) - Verified on: DSH
0.2.2-rc.5, Windows 11, Electron Web GUI - When the plugin is disabled, other consumers fall back to their own “day-of-week + time-window” approximation and will not throw errors
File Structure¶
package.json dsh.bundle.patch + dsh.client declarations
cordis.patch.yml Single line: inserts this bundle (Host side is empty)
index.js Host side: export function apply() {}
client.js All logic: priceBand service + two readouts + settings page
locale/ Plugin title and description (Chinese / English)
icon.svg Plugin icon
Development¶
node --check client.js # syntax self-check
After editing client.js, simply restart the plugin under Settings → Plugins — no build step required (plain browser ES5+ syntax; React is pulled from the host module registry).
Use Cases¶
Ideal for DSH users who need fine-grained cost control, especially those who frequently engage in multi-turn conversations, debugging, or long-running agent sessions. The plugin performs all calculations locally to avoid frequent calls to official APIs, while the pricing calendar helps determine the current billing tier at a glance.
Note: The plugin runs with the privileges of the current DSH process. Review the source code and license before installing.
Conclusion¶
Billing HUD makes cost control intuitive by embedding cost and balance readouts directly into the interface and providing the priceBand service for other plugins. All configuration is stored in the local browser and involves no uploading or storing of account credentials. For more information or to file issues, visit the GitHub repository: https://github.com/Jinquan-Leung/dsh-billing-hud