deepseek-harness
deepseek-ai
DeepSeek Harness: Everything is a Plugin.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:JasonCHTT/dsh-plugin-deepseek-balance
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
English | 中文
A DeepSeek Harness (dsh) Web plugin that shows your DeepSeek balance and how much you have spent since this run right inside the composer stats bar — no need to open the DeepSeek platform.
本次运行已用 ¥0.42 · 余额 ¥10.98
It renders one line directly under the existing token stats line (the 517 / 12.2K · 45.2s … strip). Hover for details (granted / topped-up / last update); click the spent figure to jump straight to the DeepSeek platform usage page for official consumption details, and click the refresh icon at the end of the line to re-poll immediately.
DEEPSEEK_API_KEY credential the harness already has (the one the Web Models page writes); no separate key management.GET https://api.deepseek.com/user/balance endpoint; no scraping, no session tokens.conversation.composer.dock slot), so it always lives together with the token bar.spent this run figure is a real hyperlink that opens the DeepSeek platform usage page (platform.deepseek.com/usage) in a new tab for the official consumption details.The meter is the last line under the composer card:
┌──────────────────────────────────────────────┐
│ 517 / 12.2K · 45.2s · 12 tok/s │ 42% … │ ← existing stats line
│ 本次运行已用 ¥0.42 · 余额 ¥10.98 ⟳ │ ← this plugin (click spent → platform usage; end-of-line icon → refresh)
└──────────────────────────────────────────────┘
Hover tooltip: 赠送 1.23 · 充值 9.75 · 更新于 14:32:05 · 点击已用跳转平台用量明细,点击右侧刷新图标立即刷新 (granted · topped-up · updated at · click spent for the platform usage page, click the refresh icon to re-poll).
Two halves in one package:
Host half (lib/index.js) — a Cordis plugin that:
credentials seam (ctx.credentials), falling back to the process environment;spentThisRun = baseline − current;GET /plugin/deepseek-balance/status (POST forces a refresh). The payload contains numbers only, never the API key.Browser half (lib/client.js) — a dsh.client bundle that registers a component into the conversation.composer.dock slot, right after the shipped stats line, and renders the snapshot. A single shared poll loop serves every mounted session.
The plugin is registered through the profile's cordis.patch.yml (see Installation).
DeepSeek's public API only exposes the current balance — there is no official endpoint for usage/cost details (the platform's usage page runs on private, session-authenticated APIs). The honest approximation without any login state is a delta:
spent = baseline − current.A restart also means spend that happened before dsh was running is not counted. If you keep dsh running across the whole day, the figure effectively tracks your daily spend.
~/.dsh/profiles/web).DEEPSEEK_API_KEY (set via the Web Settings → Models page, or exported in the launching environment). The plugin reads it automatically.node with a built-in fetch (Node 18+) — the harness already runs on one.pnpm only needed at install time (the dsh plugin command forwards to it).Two steps:
# 1) Install the package (link: keeps the sources editable; file: copies instead)
dsh plugin --profile web add link:/path/to/dsh-plugin-deepseek-balance
# 2) Register the plugin row in the profile patch layer:
# edit ~/.dsh/profiles/web/cordis.patch.yml and append:
- insert:
- id: deepseek-balance
name: 'dsh-plugin-deepseek-balance'
Because the shared HMR row is disabled in the Web composition, the patch layer is not hot-reloaded: restart dsh (Ctrl+C, then run dsh web again) and refresh the browser page. The meter appears under the token stats line.
On this machine both steps are already done — a restart + page refresh is all that remains.
The built-in defaults work out of the box. To override, add a config block to the row in cordis.patch.yml:
| Key | Default | Meaning |
|---|---|---|
apiKey |
— | Literal API key. Not recommended — the key lands in a config file in plain text. |
apiKeyEnv |
DEEPSEEK_API_KEY |
Credential reference resolved through the credentials service (fallback: process env). |
baseURL |
https://api.deepseek.com |
Base URL of the balance endpoint. |
currency |
CNY |
Display currency; falls back to the first entry the API returns. |
pollMs |
60000 |
Poll interval (minimum 15 000 ms). |
Example:
- insert:
- id: deepseek-balance
name: 'dsh-plugin-deepseek-balance'
config:
pollMs: 30000
本次运行已用 ¥0.42 · 余额 ¥10.98 under the composer.余额不足 marker when is_available is false, and the last update time.https://platform.deepseek.com/usage) in a new tab with the official consumption details (platform login required).DeepSeek 余额查询中… until the first snapshot arrives.DeepSeek 余额:未配置 API Key with a hint; the plugin retries every 5 seconds and heals as soon as a key becomes available.After a restart and page refresh you should see, in order:
spent this run figure: it starts at 0.00 right after boot, then grows as you chat.You can also check the raw snapshot directly:
curl http://127.0.0.1:3080/plugin/deepseek-balance/status
# {"status":"ready","ok":true,...,"totalBalance":29.36,"spentThisRun":0.3,...}
dsh plugin --profile web remove dsh-plugin-deepseek-balance
Then delete the insert block from ~/.dsh/profiles/web/cordis.patch.yml and restart.
| Symptom | Cause / fix |
|---|---|
Line shows 未配置 API Key |
The credentials seam has no value for apiKeyEnv. Store the key via Settings → Models (or set a literal apiKey in the row config), then wait up to 5 s or click the line. |
Line shows 查询失败 |
Transient network/API failure — click the line or wait for the next poll; check the dsh console for a deepseek-balance warning. |
| Meter not visible after restart | The page may have loaded the old boot manifest — hard-refresh (Ctrl+F5). If still missing, confirm the row exists in cordis.patch.yml and that dsh plugin --profile web list shows the dependency. |
| Spent figure differs from the platform page | Expected: the figure measures this run, not the platform's daily totals (see Why "spent this run"?). |
link:) into the profile, so edits to the sources take effect as follows:lib/client.js): edit → refresh the page (the bundle is re-served from disk with no-cache).lib/index.js): edit → restart dsh.link: install works from any directory.window.__ModuleLoader__.load({ id, factory }) format the harness serves under /plugins/<name>/client.js — no build step required.dsh --profile web --port 3099, then probe /plugin/deepseek-balance/status and /plugins/dsh-plugin-deepseek-balance/client.js.CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: 无有效分类标签。