Introduction¶
When developing agents or having daily conversations with DeepSeek Harness (DSH), checking balance and token spending often requires switching to “Settings → Account & Balance” or opening another page. Without numbers visible at a glance in the sidebar, it’s hard to gauge “how much has been spent today and how much is left” during long sessions.
The community plugin @lithane/dsh-account-balance (maintainer Lithane, category: client-side) injects a card at the bottom of the left sidebar in DSH, persistently displaying account balance and today’s spending. Clicking it expands a multi-level cost breakdown, complete with peak/off-peak time hints and a top-up entry. The project is a modification based on version 0.6.3 of the upstream LL-cmyk-so/dsh-balance-widget, has evolved independently since 0.1.0, and the current npm package version is 0.1.3 (MIT).
What Is This¶
dsh-account-balance is a client-side plugin for DSH: the host side (Node) provides HTTP routes and session log parsing, while the browser side (React) mounts the UI at the bottom of the sidebar (above the settings area) via the sidebar.footer.action slot.
The balance is primarily read from DSH’s built-in account service deepseekAccount, which shares the same source as the official “Settings → Account & Balance” page, no separate API key configuration is needed. When not logged in or on an older host version, it falls back to the official GET /user/balance endpoint, using the DEEPSEEK_API_KEY already stored in the credentials service.
The cost figures are derived from local estimates based on session logs under ~/.dsh/sessions/, not from official bills. The README notes that when certain auxiliary calls (such as web_search) lack a usage field, estimates are made using calibrated constants, with an error of approximately ±30%.
Core Features¶
Card & Refresh¶
- Persistent display at the bottom of the sidebar: account balance, today’s spending.
- Auto-refresh every 60 seconds; when you click the card to open the popover, it forces an immediate refresh.
- Color changes when the balance falls below configured thresholds:
lowThreshold(default 5) turns yellow,criticalThreshold(default 1) turns red.
Cost Breakdown (Five Levels)¶
After expanding, you can view:
- Cost of the latest query
- Today · This Session
- Today · This Workspace
- Today · All Workspaces
(The README groups the above together with “account balance” as cost estimation capabilities.)
Peak/Off-Peak & Pricing¶
- Peak/Off-Peak status: Peak hours are determined by Beijing time on weekdays (09:00–12:00, 14:00–18:00), including China’s statutory holiday calendar.
- Official pricing: Fetches the official pricing page at startup and every 12 hours; falls back to the built-in price table on failure.
Model Tool¶
Registers the tool account_balance, allowing you to directly ask the model in conversations “what’s my balance / how much did I spend today”.
Note: In version 0.1.1 and earlier, the tool name was still deepseek_billing. Having the same name as the upstream one causes DSH to report Duplicate tool declaration name. Starting from 0.1.2, it has been renamed to account_balance. Enabling it together with the upstream dsh-balance-widget is not recommended (although the name has been changed since 0.1.2, two similar-looking cards will be stacked in the same slot).
Installation & Activation¶
The DSH ecosystem adopts an “everything is a plugin” approach; the plugin directory is available on community sites such as SkillHub and has no official affiliation with DeepSeek / Hithink. Before installing, it is recommended to review the source code and LICENSE of the GitHub repository yourself. The plugin runs under the permissions of the current DSH process and will access local session directories and account/credential services.
Desktop (DSH Desktop)¶
Settings → Plugins → Add Plugin, fill in the package name or repository address, then restart the application and hard refresh.
Web¶
# Web
dsh plugin --profile web add @lithane/dsh-account-balance
# Or install from repository directly
dsh plugin --profile web add github:Lithane/dsh-account-balance
# Or local development directory (changes take effect immediately, best for development)
dsh plugin --profile web add link:/absolute/path/dsh-account-balance
Peer compatibility: package.json requires the @deepseek-ai/dsh range to be >=0.1.2-rc.1 <0.3.0. DSH compares peer ranges at startup; bundles that do not match and are not exempted will be silently skipped (only logged in skippedBundles), manifesting as the plugin “disappearing out of nowhere” without any errors.
Runtime environment: Session log decompression relies on Node’s built-in zstd, requiring Node ≥ 22.15 (or ≥ 24.0.0).
Configuration¶
Write the plugin block into the profile’s cordis.patch.yml (example for the desktop profile directory: ~/.dsh/profiles/desktop/):
- id: account-balance
name: '@lithane/dsh-account-balance'
config:
balanceBaseURL: https://api.deepseek.com # Balance API endpoint for the fallback path
balanceApiKeyEnv: DEEPSEEK_API_KEY # Reference in the credentials service
requestTimeoutMs: 5000
modelId: deepseek-v4-flash # Pricing model
lowThreshold: 5 # Turns yellow when the balance is below this value
criticalThreshold: 1 # Turns red when the balance is below this value
For more configuration options and pricing details, see docs/upstream/README.md in the repository.
Typical Usage¶
- Install and restart DSH (the host side
lib/index.jsis only loaded at startup); for the web client, after modifying the client side, a hard refresh is usually sufficient. - View the balance and today’s spending at the bottom of the sidebar; click the card to expand the popover when you need details.
- Ask about the balance or today’s spending in conversations, answered by the
account_balancetool. - During development and debugging, you can test the host HTTP interfaces using the current GUI address (the port changes at startup):
(Invoke-WebRequest 'http://127.0.0.1:<port>/api/account-balance/balance' -UseBasicParsing).Content
(Invoke-WebRequest 'http://127.0.0.1:<port>/api/account-balance/active-cost' -UseBasicParsing).Content
(Invoke-WebRequest 'http://127.0.0.1:<port>/api/account-balance/today-cost' -UseBasicParsing).Content
If active-cost returns no session files found, it is mostly a session path resolution issue (on Windows, pay attention to the HOME and DSH_HOME fallback logic, see the “Path Resolution” table in the README).
There is no build step for local code changes: npm run verify only performs syntax checks (node --check lib/index.js && node --check lib/client.js).
Use Cases & Notes¶
Suitable for: Developers or heavy users who run long sessions in DSH, want to see the balance and today’s spending at a glance in the sidebar, and need to roughly estimate token costs by session/workspace.
Position: The card is fixed at sidebar.footer.action; the README states that the slot cannot be changed via configuration. On the macOS desktop version, when the entire left sidebar is collapsed, the card will be hidden along with the sidebar (DSH does not leave an icon rail when data-platform='darwin'), which is not a behavior specific to the plugin.
Relationship with upstream: The routes, tool names, and UI identifiers of this repository and dsh-balance-widget have been differentiated. They can theoretically coexist, but two similar cards will be injected, so enabling both at the same time is generally not recommended.
License: MIT, inheriting from the upstream and retaining the upstream copyright line in the LICENSE.
Conclusion¶
@lithane/dsh-account-balance brings the official account balance view and local session cost estimates to the bottom of the sidebar, reducing the need to switch pages to check balances. Combined with peak/off-peak hints and the account_balance tool, it is ideal for keeping “how much is left, how much has been spent today” within the development interface.
- Plugin directory: https://www.skillhub.cn/plugins/Lithane/dsh-account-balance
- Source code and full documentation: https://github.com/Lithane/dsh-account-balance