Introduction¶
When running long conversations in DeepSeek Harness (DSH), the official interface provides token usage, but it is not easy to directly map this to RMB or account-level consumption. If you care about “how much has been spent cumulatively in this session,” “how much was deducted for this specific reply,” or “the Open Platform balance and total deductions for today,” you often have to switch to a web page or keep your own records.
dsh-session-cost is a client-side DSH plugin published by the maintainer ytftu. It displays consumption and balance in three locations: the bottom bar of the input box, the action bar for each reply, and the top right corner of the window. It also supports clicking to pop up line charts. Session amounts are recalculated turn-by-turn based on DSH’s own session logs and do not depend on other billing plugins.
What is this¶
The plugin’s full name is dsh-session-cost, current version 0.1.0, licensed under MIT. It is categorized as a “Client” plugin in the DSH community directory; the repository has approximately 3 stars on GitHub. Directory page: ytftu/dsh-session-cost.
In terms of implementation, it is a pure Cordis plugin: the host side (lib/index.js) handles pricing, peak/valley logic, log parsing, and read-only HTTP routes; the browser side (lib/client.js) handles UI injection and charts. Node.js ≥ 20 is required (for parsing zstd session logs).
Core Features¶
The documented capabilities are described below based on their interface location.
Bottom Bar of Input Box¶
Displays the total consumption for the current session after the token usage, e.g., Session ¥ 6.42; can be switched to Session 12 credits at the bottom of the panel (requires specific WorkBuddy plugins, see later). Clicking the number in the bottom bar pops up a line chart of consumption per turn.
Each Reply¶
Adds a monetary tag with the same style as the official button to the right of the official “Usage N tok”, e.g., ¥ 0.28; hovering over it reveals the details for that turn. The hover layer is a custom-drawn dark overlay, not a system tooltip.
Top Right Corner¶
Displays peak/valley indicators, balance, and today’s usage, e.g., Valley Balance ¥ 42.00 · Today ¥ 3.21. Clicking pops up a line chart of daily usage for the last seven days and provides a “Enter DeepSeek Open Platform” button (opened via the DSH sidebar browser to facilitate retaining login state).
Pricing and Data Sources (Key Points)¶
Session Amount (Bottom Bar / Per Turn): Parses ~/.dsh/sessions/<workspace-code>/<session-id>/session.v4.jsonl.zstd, selects only assistant/message events, deduplicates by turn:step, and follows the same caliber as the DSH token projection. Unit prices for uncached input, cache reads, and output are multiplied by the pricing list, and peak/valley is determined by the write time of that turn (Peak ×1, Valley ×0.5). Therefore, it includes historical turns prior to plugin activation.
Balance and Today’s Usage (Top Right Corner): If DEEPSEEK_API_KEY is available, it prioritizes requesting GET https://api.deepseek.com/user/balance; otherwise, it uses the DSH account balance. Today’s usage is obtained by sampling the balance every 60 seconds and accumulating the decrease. This has a different caliber from the token × unit price in the bottom bar “Session” total, so they cannot be added together.
Optional: If ~/.dsh/.dshw-api.json exists (from dsh-whale-widget), the plugin read-only reuses the custom unit prices and exchange rates within it. After installing dsh-workbuddy-connect, the bottom bar can be switched to WorkBuddy credit estimation (account-level, not session-based billing).
Peak/Valley Rules (Beijing Time): Peak hours are weekdays 09:00–12:00 and 14:00–18:00; all other times, weekends, and hardcoded statutory holidays are Valley hours (×0.5). The holiday list needs to be updated annually according to State Council announcements.
Installation and Activation¶
The documentation is verified on Windows DSH Desktop 2.0.x, and the statistics lines are compatible with 0.2.0 and 0.2.1. Please review the repository source code and MIT license before installing; the plugin runs with the permissions of the current DSH process.
- Place the repository in the DSH plugin directory. Windows example:
git clone https://github.com/<you>/dsh-session-cost.git "$env:USERPROFILE\.dsh\plugins\dsh-session-cost"
The corresponding directory for macOS / Linux is ~/.dsh/plugins/dsh-session-cost.
- Register it in the profile (
~/.dsh/profiles/desktop/package.json):
{
"dependencies": {
"dsh-session-cost": "link:C:/Users/<you>/.dsh/plugins/dsh-session-cost"
},
"dsh": {
"profile": {
"bundles": [
"dsh-session-cost"
]
}
}
}
Modify the path according to your machine; retain other existing dependencies and bundles in the file.
- Create a link pointing to the plugin directory under
~/.dsh/profiles/desktop/node_modules/(Windows users can use Junction, or runnpm installin the profile directory):
New-Item -ItemType Junction `
-Path "$env:USERPROFILE\.dsh\profiles\desktop\node_modules\dsh-session-cost" `
-Target "$env:USERPROFILE\.dsh\plugins\dsh-session-cost"
- Restart DSH. After disabling or removing the plugin, the three UI locations will disappear immediately without affecting the session itself.
Restarting DSH is required after modifying lib/client.js or lib/index.js; the desktop version does not have a valid page refresh, so Ctrl+R / F5 are ineffective.
Configuration Instructions¶
The host locates the data directory via process.env.DSH_HOME; if not set, it uses ~/.dsh.
Refer to the .dshw-api.json structure mentioned above for custom unit prices; amounts are per million tokens, and if cur is not CNY, the rate is used to convert to RMB.
Typical Usage and Local Interface¶
No extra commands are needed for daily use: simply open a session to see amounts in the bottom bar and per reply; click the top right corner to view balance, today’s usage, and the curve for the last seven days.
Local read-only HTTP (only localhost / 127.x / [::1], otherwise 403):
GET /dsh-session-cost/session-cost.json?session=<session-id>
GET /dsh-session-cost/platform.json[?refresh=1]
Refer to the README for return fields (including turnCosts, days, peak, etc.).
Use Cases and Notes¶
Suitable for developers who want conversation cost visualization within DSH Desktop and scheduling against peak/valley time slots. Known limitations include: the holiday list requires manual maintenance; dependency on the session.v4.jsonl.zstd format; the top-right balance caliber varies with API key or account login method; primarily tested on Windows Desktop; WorkBuddy credits are an account-level cap estimate.
The DSH ecosystem emphasizes “Everything is a plugin”; the SkillHub Directory is a community site and has no official affiliation with DeepSeek / High-Flyer.
Conclusion¶
If you need to see the total session price, per-turn deductions, Open Platform balance, and today’s usage simultaneously within the Harness, you can integrate dsh-session-cost following the steps above. For details and screenshots, see the GitHub Repository; for issues, please submit them via Issues.