Preface¶
When running long tasks with DSH (DeepSeek Harness), the cost is the hardest part to estimate: deepseek-v4-flash, deepseek-v4-pro have different prices, the official RMB pricing is split into peak and valley hours, input is bucketed based on cache hits, and the usage of parallel sub-sessions under the agent team needs to be merged. It is hard to estimate how much a current turn has cost halfway through streaming output, and manually reconciling against token details afterward is also quite a hassle.
DSH’s philosophy is “Everything is a plugin,” and the information display in the Web UI can also be left to plugins to complete. dsh-better-stats does exactly that: placing a status bar directly below the composer to display spending, balance, timing, and token statistics in real-time, with pricing directly aligned with the DeepSeek official price list.
What is this¶
dsh-better-stats is a DSH Web UI plugin maintained by null5069, MIT licensed, version 0.1.16, with no runtime dependencies, requiring Node >= 18. After installation, it appears as a status bar located directly below the composer. The example from the README looks like this:
DeepSeek Official | Balance ¥8.67 | Turn ¥0.1676 · Session ¥29.49 | 20 turns · 345 steps | LLM 1h 12m · Tool 5m 6s | TTFT avg 3.88s · 111.72tok/s | Cache 103.98M · hit 98.64% | In 1.44M · Out 336.53K
From left to right: price source, account balance, turn/session amount, turns and steps, LLM and tool duration, overall tree TTFT and tok/s, cache usage and hit rate, input and output tokens.
Pricing¶
Official Price List¶
Prices are not hardcoded in the plugin. The host re-synchronizes RMB prices from the official pricing page api-docs.deepseek.com/zh-cn/quick_start/pricing every 6 hours, mapping the official model table headers, and includes a built-in fallback. The popover will display the source and the timestamp of the fetch.
Peak and Valley Time-based Pricing¶
Peak hours are Monday to Friday Beijing Time 09:00–12:00 / 14:00–18:00, with prices ×2; weekends are treated as valley hours. Pricing is determined based on the timestamp of each event; the popover shows a countdown until the next peak/valley switch, skipping weekends.
Bucketing by Model and Cache¶
Each message is priced using the model that generated it: deepseek-v4-flash / deepseek-v4-pro / deepseek-v4-flash-vision-exp each apply their respective official tables. Unknown models are explicitly marked as Unpriced; tokens are counted in the total but the price is 0, and no default price is silently applied.
Cache is bucketed into three: uncached input, cache read (low price), and cache write are priced separately; the status bar also displays cache hit rate.
Real-time Turn Settlement and Streaming Estimation¶
The amount for a turn comes from two parts: settled steps are priced based on event-level aggregation; in-progress steps are estimated character-by-character using streaming, with the estimation density self-calibrated via EMA and priced according to the current peak/valley hours.
Agent Team Tree Merging¶
When starting an agent team, the host publishes a consistent tree snapshot via the /live route every second, keyed by session ID and event revision, merging the usage of sub-sessions into the statistics of the selected session. The merging has clear boundaries: only sessions with origin: subagent are added to the tree; normal forks are not merged.
Balance Lookup and Alerts¶
Balance is queried directly by the host from api.deepseek.com/user/balance. DEEPSEEK_API_KEY is passed through the DSH credentials seam, not via the browser. Query results are cached for 15 seconds; clicking the balance group on the status bar forces a refresh, with a 2-second flood control cooldown on the host side. The popover shows the split of granted/topped-up, estimated remaining days (EWMA), and the top-up link.
Balance alerts have two tiers: default warn ≤¥20 turns yellow, critical ≤¥5 turns red; they can be adjusted using balanceWarnCny / balanceCriticalCny, or set to 0 to disable that tier.
Budget Alerts (Optional, Disabled by Default)¶
Budget alerts are disabled by default. They are enabled by writing dailyBudgetCny / monthlyBudgetCny in the plugin config:
config: {
dailyBudgetCny: 20,
monthlyBudgetCny: 100
}
When spending exceeds 80% of the budget, the amount group turns yellow; over-spending turns red with a ⚠. The popover will provide details like Today ¥x · daily budget ¥20 (85%) / Month ¥y · monthly budget ¥100 (30%), rolling and resetting based on Asia/Shanghai midnight and the start of the month.
Other Details¶
- Real-time Timer: LLM/Tool duration is only counted for the selected session; parallel sub-sessions are not accumulated repeatedly; overall tree TTFT and tok/s are displayed in real-time.
- New Session Placeholder Bar: The first frame of a new window/new conversation renders all groups; empty values show valid 0 or
-. - Live Popover: When an agent team is running, turn/session amount, tokens, model rows, cache, active count, TTFT, and tok/s update in real-time.
- Layout: Aligned with the composer monospaced, max two lines, orphan separators at line boundaries are dropped, and overflow is truncated with a trailing
⋯(based on natural width of cache, no flickering). - i18n: UI strings follow the browser language, supporting Simplified Chinese/English.
- Precision Rules: Calculated amounts (turn/session/today) use 4 decimal places; external amounts (balance) use the provider’s precision; config amounts use 2 decimal places; popover details retain 6 decimal places.
- Basis of Billing:
outputTokensalready includesreasoningTokens; reasoning tokens are only for display and are not billed again. - Abnormal Disposal: On abnormal disposal, the host tree duration is frozen and temporary output is cleared; temporary edges expire 5 seconds without a new
/livesnapshot, and interrupted sub-sessions do not count time permanently.
Installation and Activation¶
One-command npm method:
cd ~/.dsh/profiles/web
pnpm add dsh-better-stats
After installation, you must register the package as a bundle: add dsh-better-stats to the dsh.profile.bundles array in the profile’s package.json, then restart dsh web and hard refresh the browser. The package comes with an internal cordis.patch.yml that mounts the plugin row automatically; no manual YAML modification is required.
Default values: Balance alerts are enabled for both tiers (warn ¥20 / critical ¥5), daily/monthly budgets are disabled. To customize, set balanceWarnCny / balanceCriticalCny (set to 0 to disable that tier) or dailyBudgetCny / monthlyBudgetCny (writing them enables them) in the plugin config.
GitHub clone method:
git clone https://github.com/null5069/dsh-better-stats.git
cd dsh-better-stats
This plugin has no runtime dependencies; after cloning, no npm install is needed. The next step is to symlink the directory into the profile—the README is truncated at this step, so please refer to the documentation inside the repository for specific commands.
Use Cases and Notes¶
Suitable for users running long tasks in the DSH Web UI who need to monitor costs and balance, especially those who open agent teams and run parallel sub-sessions—the tree merging and real-time settlement are designed to work precisely here.
Two notes. Firstly, the plugin runs with the permissions of the current dsh process; it is recommended to check the source code and license (MIT) before installing. Secondly, balance queries rely on DEEPSEEK_API_KEY; this key is passed through the DSH credentials seam and does not go through the browser, but it is still recommended to confirm trust in the author before enabling.
Conclusion¶
dsh-better-stats turns the two most opaque items in the DSH Web UI—how much was spent and how much is left—into a permanent visible status bar, with pricing, time-of-day, and bucketing all aligned with official standards. Code and documentation can be found on the GitHub repository: https://github.com/null5069/dsh-better-stats. For more DSH plugins, the community-maintained plugin directory is a separate site with no official affiliation to DeepSeek or Hypothesis.