Introduction¶
DeepSeek Harness (DSH) is a local agent testing tool. The native Web interface lacks an intuitive view of Token consumption and cost. The dsh-token-usage plugin adds a “Usage Statistics” page to DSH’s Web configuration panel, helping developers quantify actual expenditure by converting raw Token consumption into official peak/off-peak rates.
Plugin Overview¶
dsh-token-usage is a plugin for DeepSeek Harness. It does not modify agent runtime logic; it acts only as an observer, reads persisted session logs, and calculates and displays Token usage and estimated cost locally.
Core Features¶
This plugin provides the following core capabilities:
- Summary Card: Displays total Token count, daily average, cache hit rate, and estimated expenditure. Supports toggling between “Today/This Week/This Month.”
- Heatmap: Provides a 3-month GitHub-style horizontal heatmap. Hovering over any date cell displays detailed Token statistics and expenditure (CNY/USD) for that day.
- Real Cost Estimation: Calculates actual costs using official peak/off-peak rates and automatically converts them to CNY and USD.
- Pricing Table Management: Supports editing pricing tables by model, including CNY/USD and peak/off-peak time-period pricing configuration.
- Precise Billing: Bills based on event timestamps. Beijing peak hours (09:00–12:00, 14:00–18:00) use peak rates, while other hours use off-peak rates.
- Pure Observer Mode: Does not modify the Agent loop, does not upload data to external services, and keeps all data stored locally.
Installation and Activation¶
The plugin is installed into DSH’s built-in Web configuration profile.
Install Using npm (Recommended)¶
dsh plugin --profile web add dsh-token-usage
Install Using a Local Path¶
If installing directly from local source code, build it first:
pnpm build
dsh plugin --profile web add /path/to/dsh-token-usage
Start¶
After installation, run it from the DeepSeek Harness checkout directory:
pnpm dsh web
Configuration and Usage¶
Data comes from the usage field in persisted session logs.
Pricing Configuration¶
The plugin supports modifying the pricing table via the Web configuration file or a --patch overlay. The configuration file path is usually $DSH_HOME/profiles/web/cordis.patch.yml.
Define model prices in the configuration, including currency type, peak/off-peak rates, and metrics such as input, output, cache read, and cache write. Models that are not configured use built-in default values.
Index Location¶
The plugin stores data using an incremental index. The index file is located at $DSH_HOME/dsh-token-usage/index.. The system periodically synchronizes to disk, ensuring quick recovery of statistics after restart.