Introduction¶
When developing agents with DeepSeek Harness (DSH), the token consumption and cost for each conversation are often scattered across logs, with no intuitive dashboard to aggregate them. Once off-peak/peak pricing is enabled, costs vary by time of day, making it necessary to track the current rate card and historical price adjustments. This plugin adds a compact usage strip below the DSH Web input box, displaying the total cost for the current session, today’s token count and cost in real time, and provides detailed panels broken down by session, by day, and by model.
What It Is¶
dsh-usage-strip is a client-side plugin that runs within the local DSH process, maintained by eakshelling. It only reads the session logs already persisted by the local DSH instance. It does not connect to the internet, does not upload data, estimates costs based on DeepSeek’s official rate card, and provides off-peak/peak pricing, holiday schedules, and a price adjustment timeline.
Core Features¶
Compact Usage Strip¶
When a session is selected, a single line of compact information appears below the input box. The default format is:
Total≈¥… Today … tok≈¥…
Total: Estimated from DSH’s built-intokenUsagereadings, calculated using the current peak/off-peak rate and model distributionToday: Token count and cost for this conversation on today’s date (Beijing Time)- Each metric is followed by a 7-day mini bar chart
- Auto-refreshes every 30 seconds; refreshes immediately when the page becomes visible again
- When no session is selected, displays today’s statistics for all sessions
Detail Panel¶
Clicking the compact strip expands the detail panel, supporting the following toggles and views:
- Scope toggle: This conversation / All sessions; “This conversation” defaults to “All time”, “All sessions” defaults to “Last 7 days”
- Time range: Today / Last 7 days / Last 30 days / All time
- Two side-by-side sections: Built-in readings (built-in token count + estimated cost at current peak/off-peak rate) and Log-precise (cost calculated per log entry at the event-time rate, request count, cache hit rate)
- KPIs: Estimated cost, total tokens, request count, token-weighted cache hit rate
- Token breakdown: Cache hits / Uncached input / Output
- Daily usage stacked chart + cost / effective average price curve
- Per-model details: Requests, hits, misses, output, total, cost, share
- Price card: Current period and next switch, Flash / Pro off-peak and peak rates, official price adjustment records
Data Scope¶
| Item | Scope |
|---|---|
| Data source | Today’s data, daily/model breakdowns, and the panel’s “Log-precise” section come from assistant/message.usage in locally persisted DSH session logs; the compact strip’s total and the panel’s “Built-in readings” are taken from DSH’s built-in tokenUsage projection |
| Range | Defaults to the current session; the panel can be toggled to all locally saved sessions (including sub-agent sessions); does not include usage from other clients, API keys, or web endpoints |
| Day boundary | Beijing Time (UTC+8) |
| Tokens | The compact strip’s total and the panel’s built-in readings use the built-in projection’s uncachedInputTokens + cacheReadTokens + cacheWriteTokens + outputTokens (reasoning tokens already included, no double counting); “Today” and 7/30-day ranges are calculated per log entries |
| Total / Estimated cost | Built-in token count × current peak/off-peak rate and log-based model distribution; does not retroactively apply historical price changes; the compact strip displays ≈, the log-precise value is in the panel’s second section |
| Precise cost | Each log entry is priced at the official rate card of the event date; this is not an official bill |
| Peak/off-peak | Weekdays 9:00–12:00, 14:00–18:00 are peak (2× rate); effective from 2026-08-17; weekends all off-peak from 2026-08-23; statutory holidays all off-peak from 2026-09-19 |
Installation & Activation¶
The plugin is published on npm:
npm install dsh-usage-strip
# or
pnpm add dsh-usage-strip
The version follows latest on npm. You can also install from a GitHub Release attachment (.tgz) or a local directory.
For local development, you can install directly from the directory using either method:
- Install the directory via DSH’s plugin manager (
plugin_manager’sinstall_bundle, target set to the absolute path of the directory), then enable it in Plugins - In Plugins → Add plugin, select the directory
After installation, refresh the page. If the client bundle has not loaded, restart DSH. The plugin row ID is dsh-usage-strip.
Typical Usage¶
After installation, select a session in the DSH Web interface, and the compact usage strip will appear below the input box. Click the strip to expand the detail panel. In the panel, toggle between “This conversation” and “All sessions”, adjust the time range, and view the daily usage stacked chart, per-model details, and the price card.
Use Cases & Notes¶
This plugin is suited for developers who need to track local session usage, costs, and peak/off-peak pricing. Note:
- Only tracks local DSH sessions; does not cover other clients. Costs are estimates and do not replace platform billing
- The compact strip only appears below the input box of a selected session; it is not shown on a blank home page
- “This conversation” panel defaults to “All time”, meaning the cumulative value from the first persisted message to the present; for a newly created session that has not yet been persisted, it displays “Calculating this conversation…”
- Charts in the “All time” range only plot the last 90 days; KPIs and model totals still cover all data
- As local log volume grows, the first in-process scan may take a moment; subsequent scans only re-read changed sessions
- The service route only listens on loopback and validates same-origin; other local processes can still read the aggregated usage data (no credentials included)
- Does not append session events, does not write to session files, does not alter model-visible content
Diagnostic Logs¶
Each scan, session read, seed truncation, and route request is appended to:
%DSH_HOME%\logs\dsh-usage-strip.log
The default DSH_HOME is C:\Users\<user>\.dsh. The log is in JSONL format, with fields including timestamp, event, sessionId, eventCount, inheritedEventCount, readFrom, eventsRead, seedSeen, collapsed token/cost, and route status. When it reaches approximately 1 MB, it rotates to .log.1, retaining at most two files.
The log does not contain prompts, message bodies, model outputs, or credentials; it can be deleted at any time. If values remain 0 after restart, first check the eventsRead/seedSeen fields in the most recent session lines, then check the route lines.
Troubleshooting¶
- Compact strip not appearing: Refresh the page first. The client bundle registration info can be found in
meta.clientofGET /dsh-usage/api.json(registered: truemeans the Host’s client module graph has included this plugin); if stillfalse, restart DSH - Panel shows “Usage unavailable”: Confirm that the Host-side
sessionPersistenceandwebServerare mounted (both are included by default in Web / Desktop editions) - Numbers are empty or lower than expected: The session log has not yet been persisted (a newly created session needs one persistence cycle after usage is generated), or the session format is not recognized by the current version; the API’s
warningsfield provides counts. When values reset to zero after restart, check thesession/routelines in%DSH_HOME%\logs\dsh-usage-strip.log(readFrom: 0,seedSeen,eventsRead)
Ecosystem Context¶
The philosophy of DeepSeek Harness (DSH) is “everything is a plugin”. The community directory (https://www.skillhub.cn) is independent of the DeepSeek official team and provides plugin discovery and hosting services.