Introduction¶
DeepSeek Harness (DSH) shows token statistics for the current turn and session within a single conversation, but usage is often scattered across dozens of sessions: how much was spent this month, which day saw a sudden spike, how much came from cache reads, and how much was consumed by parent sessions versus sub-agents—the Host’s built-in interface has no cross-session summary table.
The community plugin dsh-token-bi (maintainer 361533652) adds a global panel “Token Billing” to the DSH Desktop / Web client, folding provider-reported usage from session logs and aligning it with the daily and Host tokenUsage projections (@deepseek-ai/dsh-token-meter) to avoid mismatches with in-session numbers. It is categorized as a client-side plugin; currently 0 GitHub stars, MIT license (package.json version 0.1.0).
The following covers what it does, how to install it, how to use the interface, and its data sources and limitations.
What This Is¶
dsh-token-bi is a token consumption dashboard for DSH: it aggregates usage scattered across sessions into daily bar charts, hourly rhythms, model and workspace breakdowns, parent-child session call trees, and per-turn timelines for individual sessions.
- Directory page: skillhub.cn/plugins/361533652/dsh-token-bi
- Source code: github.com/361533652/dsh-token-bi
The plugin only reads DSH session events and persistent logs; it does not write to the database or modify sessions. It depends on the Host’s webServer to provide HTTP interfaces and will not activate under a pure TUI profile.
Core Features¶
The entry point is in the left sidebar’s global panel (at the same level as “Plugins” and “Automation Tasks”), not bound to any single session.
Top Metrics¶
| Metric | Meaning |
|---|---|
| Cumulative tokens | Sum of all four token types within the current time window |
| Today’s consumption | Total for the current day in the local timezone |
| Sessions | Number of sessions within the window; subtitle shows how many are running |
| Turns | Number of deduplicated turns |
| Cache hit ratio | cacheRead / total, typically high, reflecting context reuse |
The four buckets are: inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens; the total is the sum of all four.
Charts and Session Table¶
- Daily consumption: Stacked bar chart (input, cache read, cache write, output).
- Last 7 days rhythm: Hourly-aggregated line chart.
- Model distribution: Split by
provider/model. - Workspace distribution: Grouped by session
cwd; when there are more than 8, they are collapsed with the total of the collapsed portion shown. - Session details: The main table; expanding a row fetches that session’s per-turn timeline (a three-segment bar per turn; extremely long sessions display at most the last 60 turns, without affecting totals).
- Call tree: Parent sessions with child sessions nested; light/dark colors distinguish “self-use in this session” versus “sum of child sessions.” Parent session numbers do not include child sessions; the entire subtree must be viewed by overlaying them.
The time window in the top-right corner: 7 days / 30 days / All. Switching re-fetches data from the Host and recomputes by day, not merely filtering existing frontend data.
Export CSV: Exports the session list within the current window, UTF-8 BOM, for easy opening in Excel.
Installation and Activation¶
Prerequisites¶
- DSH Desktop or
dshCLI (Web interface) - Node.js ≥ 22.15 (session logs are zstd-compressed, requiring Node
zlibzstd support)
Install from a Local Directory (the currently available method documented in the README)¶
First clone the repository locally, then install via link: soft link (modifying the repository code does not require reinstallation):
git clone https://github.com/361533652/dsh-token-bi.git
dsh plugin --profile desktop add "link:/absolute/path/dsh-token-bi"
Windows example:
dsh plugin --profile desktop add "link:E:\gitbub-project\dsh-token-bi"
After installation, fully exit and restart DSH Desktop (not a page refresh); the client bundle path table is built once at process startup.
Verification¶
After restarting, “Token Billing” should appear in the left sidebar, right next to “Plugins.” If it does not appear, check in order:
- Whether “Token Billing” exists under Settings → Plugins → Installed Plugins and its toggle is on
- Whether the
dsh --profile desktop --dump-configoutput containsid: token-bi - Search for
token-biin the Host logs (Windows:%APPDATA%\DSH Desktop\logs\host\) for any activation failures
During loading, the browser console (via Host logs) may show [token-bi] factory, [token-bi] apply, [token-bi] slot:xxx, which help distinguish between not downloaded, not activated, or not successfully registered.
Configuration¶
No configuration options. Time windows and filters are all operated in the interface. The profile only contains the plugin entry insertion:
- insert:
- id: token-bi
name: dsh-token-bi
Typical Usage¶
- After installing and restarting Desktop, open Token Billing in the left sidebar.
- Select 7 days / 30 days / All in the top-right corner, and observe the top cumulative and today’s consumption, as well as the cache hit ratio.
- Use the daily bar chart to locate dates with usage spikes, and the “Last 7 days rhythm” to see peak hours.
- Check “Model distribution” and “Workspace distribution” to see which model line or which
cwddominates. - Expand a row in the session details to view per-turn
input / output / cacheRead / cacheWrite; when sub-agents exist, switch to the Call tree to compare parent-child layers. - For tabular analysis, click Export CSV to export the session list for the current window.
For programmatic data retrieval, the plugin registers same-origin routes on the Host (default in the browser; parameters include timezone offset and window):
GET /api/dsh-token-bi/report?offset=<minutes>&days=<window>&refresh=1
GET /api/dsh-token-bi/session?id=<session id>&offset=<minutes>
days of 0 or all means all; refresh=1 bypasses the 10-second report cache.
Data Sources and Calculation¶
Data sources are merged by session id, with active sessions taking priority:
| Source | Role |
|---|---|
ctx.sessions |
Currently open sessions, in-memory events, the latest |
ctx.sessionQuery |
Cold-start persistent logs, historical sessions not currently open |
It does not directly read .jsonl.zstd files; it uses DSH’s public services.
Metering rules align with the Host:
- Only counts provider-reported usage (
usageinassistant/message, or the lasttype: 'usage'chunk in a stream), without estimation. - Later samples for the same
(turn, step)replace earlier ones, avoiding duplicate accumulation from retries. - The four buckets are recorded separately; the total is the sum of all four.
Event times are mapped to local timezone dates using getTimezoneOffset() passed in by the browser. Individual sessions are cached by (session id, revision); the entire report is cached for 10 seconds.
Use Cases and Notes¶
Who it’s for: Developers who use DSH long-term for agent development, parallel sub-agents, and multi-workspace switching, and need to answer questions like “what’s the total this month,” “which day got expensive,” “is cache read dominant,” or “which directory is burning tokens.”
Runtime and trust: The plugin reads local session storage with the permissions of the current DSH process; data only covers the local machine. Before installing, please review the source code and the MIT license yourself. The community directory SkillHub and DeepSeek / Hithink have no official affiliation. The ecosystem philosophy is “everything is a plugin.”
Known limitations (excerpted from the README):
- Only counts steps that reported usage; providers without usage are invisible.
- Statistics are log-based; compressed historical messages still count toward session totals.
- Child sessions are billed independently; parent session totals do not include child sessions.
- Requires the Web interface and
webServer; no cost/amount estimation is performed.
Conclusion¶
dsh-token-bi fills a gap in DSH: a cross-session, Host-reconcilable token dashboard—daily bars, hourly rhythms, model and workspace breakdowns, call trees, and per-turn timelines. After installation, it is available from the left sidebar under “Token Billing.”
- Plugin directory: https://www.skillhub.cn/plugins/361533652/dsh-token-bi
- GitHub: https://github.com/361533652/dsh-token-bi