dsh-web
zhu1090093659/dsh-webDeepSeek Harness(DSH)Web 插件聚合生态包 · 一切皆插件,创意工坊分发(dsh-market.com)
DSH plugin: show DeepSeek API pricing, token usage/cost and account balance inside DeepSeek Harness
English | 简体中文
A DeepSeek Harness (DSH) plugin that shows DeepSeek API official pricing, session token usage/cost, cumulative cost, and account balance directly inside DSH.
Screenshots are rendered from the real DSH web page (Playwright driving a local Chrome); only the plugin endpoints are stubbed with demo data, so the UI structure, plugin DOM and styles are genuine while the balance, usage figures and session name are demo values.
GET https://api.deepseek.com/user/balance and shows total, topped-up, and granted balance. Cached for 60 seconds by default with manual refresh.deepseek-flash and deepseek-v4-pro prices with automatic peak/off-peak tier selection.@deepseek-ai/dsh;web profile;~/.dsh/.credentials.yaml or supplied via the DEEPSEEK_API_KEY environment variable.dsh plugin --profile web add github:liyiersan/dsh-usage-monitor
You can also install from a local checkout:
dsh plugin --profile web add /path/to/dsh-usage-monitor
This repository declares dsh.bundle.patch. On DSH versions that support the manifest, the install command applies cordis.patch.yml automatically and inserts the plugin into the profile composition, so you normally do not need to edit the profile patch by hand.
If your DSH version does not apply the bundle patch automatically, edit $DSH_HOME/profiles/web/cordis.patch.yml (default: ~/.dsh/profiles/web/cordis.patch.yml) and add:
- insert:
- id: usage-monitor
name: '@local/dsh-usage-monitor'
The plugin never stores the key itself. It resolves DEEPSEEK_API_KEY through the DSH credentials service, falling back to the process environment.
dsh web
Open any conversation. You should see the Usage tab in the conversation view and the usage dock above the input box.
dsh plugin --profile web remove @local/dsh-usage-monitor
If you added the insert entry manually, remove it from cordis.patch.yml; a bundle install is normally cleaned up by dsh plugin remove. Optionally delete the local ledger:
rm -rf "$DSH_HOME/usage-monitor"
Unit: CNY / million tokens. Peak hours are Beijing time Monday-Friday 09:00-12:00 and 14:00-18:00; off-peak prices are half of peak prices.
| Model | Tier | Cache hit | Cache miss | Output |
|---|---|---|---|---|
| DeepSeek-V4.1-Flash | Off-peak | 0.02 | 1 | 4 |
| DeepSeek-V4.1-Flash | Peak | 0.04 | 2 | 8 |
| DeepSeek-V4-Pro | Off-peak | 0.15 | 4.5 | 13.5 |
| DeepSeek-V4-Pro | Peak | 0.3 | 9 | 27 |
Billing rules:
cacheRead (cache-hit input) uses the cache-hit price;uncachedInput (cache-miss input) uses the cache-miss price;output uses the output price;cacheWrite is not listed separately by the official docs, so this project conservatively charges it at the cache-miss price;pro, chat, or reasoner are normalized to V4-Pro; names containing flash are normalized to Flash; unknown models fall back to Flash and are marked as an estimate in the UI.Token counts come from the provider's exact usage; costs are derived by the local ledger with incremental pricing, matching the official billing model with only tiny rounding differences (tier attribution uses the moment of each report). DeepSeek prices may change; when updating, keep
lib/pricing.jsand the inline pricing copy inlib/client.jsin sync.
DSH Host (Node)
lib/index.js ── GET /user/balance ──> api.deepseek.com
│
├─ GET /usage-monitor/data ──> browser client
└─ POST /usage-monitor/report <── browser client
│
├─ conversation.view "Usage" tab
└─ conversation.input.dock bar
lib/index.js: host half. Resolves credentials, queries balance, maintains the local ledger, and exposes local HTTP endpoints.lib/client.js: browser bundle. Registers the conversation.view and conversation.input.dock slots and reads/reports data.lib/pricing.js: pure pricing engine used by the host and tests.dsh-usage-monitor/
├── lib/
│ ├── client.js # browser bundle
│ ├── index.js # host plugin
│ └── pricing.js # pricing engine
├── scripts/
│ ├── client-check.mjs
│ ├── inspect-session.mjs
│ └── smoke.mjs
├── test/
│ └── pricing.test.mjs
├── docs/screenshots/
├── package.json
├── README.md
├── README.en.md
└── LICENSE
npm test # pricing engine unit tests
npm run test:client # offline client bundle checks
node scripts/smoke.mjs # host smoke test (queries the real balance API)
scripts/smoke.mjs uses a temporary DSH_HOME, so it does not pollute your real ledger. It reads the key from the local DSH credentials file or the environment, but only prints the key length, never the key itself.
Restart DSH after changing the client half:
/plugins/<id>/client.jsis served from DSH's client module table, which is built and cached at startup — a browser refresh alone returns the copy from the last start. After editinglib/client.js, restart DSH before verifying, or you will misread a cached build as "the change did not work".
This version was verified against DSH 0.1.5-rc.1 with the web profile (September 2026) and also works on 0.1.1-rc.2 (client slots and model-resolution APIs are unchanged). DSH client APIs may still evolve; if slots or model-resolution APIs change after a DSH upgrade, please open an issue or a PR.
https://api.deepseek.com/user/balance.$DSH_HOME/usage-monitor/ledger.json and records only session IDs, token usage, and per-model cost buckets; it is not committed to this repository./usage-monitor/* endpoints are served by the DSH web server on loopback. /usage-monitor/report requires Content-Type: application/json to reduce CSRF risk.Issues and PRs are welcome. Before opening a PR, please run:
npm test
npm run test:client