rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:keltanas/dsh-platform-balance
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
A DeepSeek Harness Web GUI plugin. The card and the session-header pill follow the provider selected in the current session and show its balance and spend:
The UI follows the GUI language and ships English, Russian, and Simplified Chinese dictionaries; any other language falls back to English. Errors coming from the host are localized by stable codes, so a language switch needs no reload.
Two pieces of UI appear:
≈ 153 ₽ · session 5,58 ₽ · day 15,25 ₽;
OpenCode Go: ≈ $48.09 · session $0.02 · day $1.20; unsupported: Ollama · qwen3.5:9b.
Clicking it collapses or expands the card. The pill exists only inside a conversation; the card is
visible on every screen.The browser half reads the model selection recorded for the open session
(next, falling back to lastUsed) and sends its provider/model to the host. With no session (home
screen, a fresh session before its first request), the host answers from the deployment default model
(agentDefaultModel.currentSelection()). The host maps the result to one display mode:
| Provider id | Mode |
|---|---|
exactly opencode-go |
OpenCode Go |
contains deepseek (deepseek-official, deepseek-account, …) |
DeepSeek |
| everything else, including an empty/unknown id | Unsupported |
DeepSeek and OpenCode Go are independent sources: when OpenCode Go is selected the DeepSeek wallet
block is hidden, and the card title becomes OpenCode Go · balance.
| What | Where it comes from |
|---|---|
| DeepSeek balance | DSH account service (deepseekAccount.getBalance, browser sign-in, no API key); when the account is signed out — DEEPSEEK_API_KEY via https://api.deepseek.com/user/balance |
| OpenCode Go plan and quota | GET https://opencode.ai/console/api/go/status with the OpenCode Go API key: product (go, go-plus, go-teams), period end, and fiveHour/week/month meters in micro-cents |
| OpenCode Go fallback | GET https://opencode.ai/zen/go/v1/usage (public endpoint, percentages only) when the console API is unavailable |
| OpenCode Go today | GET https://opencode.ai/console/api/usage/summary?range=24h: the account's cost/requests/tokens for the rolling 24 hours, the same figure the Console page shows for Today |
| OpenCode published allowances | Built-in snapshot of the OpenCode Go plan table (docs/console/go#usage-limits): the monthly dollar limit of each model on Go, Go Plus and Go Teams |
| OpenCode prices | GET https://opencode.ai/inference/go/v1/models with the same key: per-model USD prices and peak-hour multipliers |
| CBR rate | Official CBR XML feed https://www.cbr.ru/scripts/XML_daily.asp, USD and CNY against RUB |
| DeepSeek spend | DSH session logs (ctx.sessionPersistence): request token usage × official DeepSeek prices in CNY |
| OpenCode Go spend | The same session logs × the OpenCode model catalog prices in USD |
The OpenCode Go key is resolved from the credential reference of the llm-pi-ai provider route
opencode-go (the profile sets OPENCODE_GO_API_KEY) through the credentials service, with the
environment variable as a fallback. The plugin never reads DEEPSEEK_API_KEY for OpenCode requests:
the DeepSeek key is not accepted by the Go plan. The key never enters a JSON response.
The plugin sends no data anywhere except those requests. Its HTTP routes are loopback-only and same-origin, so another browser tab cannot read the balances.
limitMicroCents/usedMicroCents meters are a single normalized pool per plan (Go: $12 / $30 /
$60), not the per-model dollar limit, so the card converts the percentage into the current model's
published allowance instead: DeepSeek V4.1 Flash has $100/month on Go, so its 5-hour cap is
$20, the weekly cap $50, and the monthly cap $100; the used/remaining money is
percentage × cap (plus the CBR RUB conversion).poolLimitUSD/poolUsedUSD for diagnostics. The subscription price ($10) is not the 100%
amount of the quota.cost.text rates and multipliers, so DeepSeek peak hours ×2 are honored). The catalog is
cached in $DSH_HOME/cache/platform-balance/opencode-models.json for a day; a model missing from the
catalog contributes calls/tokens but no money.OPENCODE_GO_API_KEY).A provider that is neither DeepSeek nor OpenCode Go keeps a compact card: the provider name and model
(best-effort display names from the LLM catalog, falling back to ids), then only the current CBR rates
(USD and CNY), then the localized text This provider is not supported yet. The pill shows
Provider · model. No account is queried and no spend is scanned in this mode.
All UI copy is registered through the DSH locale service as the platform-balance namespace with
complete en, ru, and zh dictionaries (zh is Simplified Chinese). The widget re-renders on a
language switch, <html lang> drives the number/date formatting (ru-RU, zh-CN, en-US), and
English is the fallback chain root for any other language.
Host failures are structured:
{ "ok": false, "error": { "code": "opencodeAuth", "params": { "status": 403 } } }
The browser translates the code with the active dictionary; the optional detail field keeps the
untranslated technical cause for the element tooltip. The API never returns a bare Russian sentence.
$DSH_HOME/cache/platform-balance/cbr.json (default
~/.dsh/cache/platform-balance/cbr.json) and survives restarts.Neither provider reports a request's cost in the session log, so spend is estimated from token counts and prices:
lib/pricing.js): the official DeepSeek CNY price list, taking into account peak and
off-peak hours (peak is 09:00–12:00 and 14:00–18:00 Beijing time, ×2 price); the switch to peak
pricing on 2026-08-17; the Flash price cut on 2026-09-10 (and peak pricing on weekdays only); and
deepseek-v4-pro requests being served at Flash prices from 2026-09-14;lib/opencode-pricing.js): the account's own model catalog fetched from the
inference API, including the per-model peak multipliers (for DeepSeek models: weekdays
09:00–12:00 and 14:00–18:00 Beijing time, ×2).Numbers in the UI are prefixed with ≈: this is an estimate, not a bill. Only routes that actually
spend a connected balance are priced: DeepSeek platform routes (deepseek-account,
deepseek-official, or any provider id containing deepseek) and opencode-go. Sessions on other
providers — a local ollama, a free third-party gateway, another API — never spend either balance, so
their requests are counted separately as otherCalls/otherTokens, add nothing to the money totals,
and the widget notes them as unbilled.
Paid summarization calls (compaction/summary) are included. Forked sessions (subagents with an
inherited history) skip the copied parent prefix in their log, so the daily total is not counted
twice and a forked session reports only its own work.
The "day" is the local calendar day of the machine running DSH (Europe/Moscow, for example). It covers every stored session, including subagent sessions, with inherited fork prefixes excluded. Day totals are cached per session revision, per calendar day, and per OpenCode price-catalog revision, so a repeated request re-reads only changed logs and a midnight rollover re-aggregates the cached day buckets without re-reading the whole session corpus.
The plugin is a regular DSH bundle package:
# from the git repository
dsh plugin --profile web add github:keltanas/dsh-platform-balance
# or from a local checkout
dsh plugin --profile web add ~/projects/dsh-platform-balance
dsh plugin (a pnpm wrapper) adds the dependency and appends the bundle to
~/.dsh/profiles/web/package.json. The profile then reloads itself (patchReload: live) and an
open page picks up the browser half over HMR; a restart of dsh web is not needed for a first
install. If host-half source code changes later, Node caches the imported module, so restart
dsh web (for example systemctl --user restart dsh.service) to apply those changes.
Verify without a browser:
curl -s http://127.0.0.1:3080/api/platform-balance/overview | jq .
curl -s "http://127.0.0.1:3080/api/platform-balance/overview?provider=opencode-go&model=deepseek-v4.1-flash" | jq .
curl -s "http://127.0.0.1:3080/api/platform-balance/session?id=<session-id>" | jq .
Remove:
dsh plugin --profile web remove dsh-platform-balance
If @cassius0924/dsh-usage-dashboard is installed, its floating widget duplicates the balance
card — keep only one of them. Bring that plugin back with
dsh plugin --profile web add @cassius0924/dsh-usage-dashboard@0.9.2.
All routes are GET, loopback-only and same-origin, with cache-control: no-store. The optional
provider/model query parameters carry the current session's model selection; omit them to let the
host use the deployment default model. refresh=1 bypasses every TTL cache.
GET /api/platform-balance/overview[?provider=<id>&model=<id>][&refresh=1]
DeepSeek mode:
{
"ok": true,
"data": {
"generatedAt": 1790000000000,
"mode": "deepseek",
"provider": { "id": "deepseek-official", "name": "DeepSeek" },
"model": { "id": "deepseek-flash", "name": "DeepSeek-Flash" },
"balance": {
"source": "account",
"isAvailable": true,
"wallets": [
{ "currency": "USD", "total": "0.00", "granted": "0.00", "toppedUp": "0.00", "rate": 82.9803, "rub": 0 },
{ "currency": "CNY", "total": "12.34", "granted": "0.00", "toppedUp": "12.34", "rate": 12.4009, "rub": 153.03 }
],
"totalRub": 153.03
},
"cbr": {
"date": "13.11.2026",
"fetchedAt": 1790000000000,
"stale": false,
"rates": { "USD": 82.9803, "CNY": 12.4009 },
"error": null
},
"spend": {
"currency": "CNY",
"estimated": true,
"pricing": { "...": "current DeepSeek price era table" },
"day": { "dayKey": "2026-11-12", "costCNY": 2.5, "rub": 31.0, "calls": 37, "tokens": 1234567, "opencodeCalls": 0, "opencodeTokens": 0, "otherCalls": 5, "otherTokens": 42000 }
}
}
}
OpenCode Go mode:
{
"ok": true,
"data": {
"generatedAt": 1790000000000,
"mode": "opencode-go",
"provider": { "id": "opencode-go", "name": "OpenCode Go" },
"model": { "id": "deepseek-v4.1-flash", "name": "DeepSeek V4.1 Flash" },
"cbr": { "date": "13.11.2026", "fetchedAt": 1790000000000, "stale": false, "rates": { "USD": 82.9803, "CNY": 12.4009 }, "error": null },
"account": {
"ok": true,
"source": "console",
"fetchedAt": 1790000000000,
"plan": { "product": "go", "renewalProduct": "go", "periodEndsAt": "2026-12-04T17:59:17.000Z", "cancelAtPeriodEnd": false, "currency": "usd" },
"allowance": { "planId": "go", "modelId": "deepseek-v4.1-flash", "monthlyUSD": 100, "source": "model" },
"windows": {
"fiveHour": { "limitUSD": 20, "usedUSD": 0.054, "remainingUSD": 19.946, "poolLimitUSD": 12, "poolUsedUSD": 0.032582, "percent": 0.27, "remainingPercent": 99.73, "status": null, "startsAt": "2026-11-14T13:11:13.000Z", "resetsAt": "2026-11-14T18:11:13.000Z", "limitRub": 1659.61, "usedRub": 4.48, "remainingRub": 1655.13 },
"week": { "...": "same shape, limitUSD 50" },
"month": { "...": "same shape, limitUSD 100" }
},
"today": { "costUSD": 1.632624, "costRub": 134.97, "calls": 1085, "inputTokens": 2708643, "outputTokens": 1086965, "cacheReadTokens": 191382784, "cacheWriteTokens": 0 }
},
"spend": {
"currency": "USD",
"estimated": true,
"pricing": { "ok": true, "fetchedAt": 1790000000000, "models": 4 },
"day": { "dayKey": "2026-11-14", "costUSD": 1.2, "rub": 99.58, "calls": 18, "tokens": 456789, "opencodeCalls": 18, "opencodeTokens": 456789, "otherCalls": 2, "otherTokens": 1200 }
}
}
}
Unsupported mode (no balance/spend/account keys):
{
"ok": true,
"data": {
"generatedAt": 1790000000000,
"mode": "unsupported",
"provider": { "id": "ollama", "name": "Ollama" },
"model": { "id": "qwen3.5:9b", "name": "qwen3.5:9b" },
"cbr": { "date": "13.11.2026", "fetchedAt": 1790000000000, "stale": false, "rates": { "USD": 82.9803, "CNY": 12.4009 }, "error": null }
}
}
GET /api/platform-balance/session?id=<sessionId>[&provider=<id>&model=<id>][&refresh=1]
{
"ok": true,
"data": {
"sessionId": "session-...",
"mode": "opencode-go",
"currency": "USD",
"estimated": true,
"costUSD": 0.02,
"rub": 1.66,
"calls": 12,
"tokens": 34567,
"otherCalls": 0,
"otherTokens": 0,
"lastAt": 1790000000000
}
}
DeepSeek mode answers with costCNY instead of costUSD; unsupported mode answers with
currency: null and null counters. Errors always come as
{ "ok": false, "error": { "code": "…", "params": { "…": "…" }, "detail": "…" } }.
lib/index.js host plugin: HTTP routes, three display modes, TTL caches, CBR timer, warm-up
lib/cbr.js CBR XML fetch/parse, on-disk cache, 18:00 MSK schedule
lib/wallet.js DeepSeek account balance with a DEEPSEEK_API_KEY fallback
lib/opencode-go.js OpenCode Go console status / public usage fallback, key resolution, account cache
lib/opencode-allowances.js published per-model monthly allowances of Go/Go Plus/Go Teams
lib/opencode-pricing.js OpenCode model catalog with USD prices and peak multipliers, disk cache
lib/usage.js session-log reading, per-session and per-day cost aggregation (CNY + USD)
lib/pricing.js official DeepSeek prices and peak/off-peak windows
lib/http.js JSON responses and same-origin checks
lib/client.js browser half: localized card and pill for all three modes
cordis.patch.yml bundle layer: one Loader row carrying both halves
test/ node:test — CBR, prices, usage, wallets, HTTP, OpenCode account/catalog, client smoke
The host half uses the webServer, credentials, and sessionPersistence services plus the optional
deepseekAccount, agentDefaultModel, llm, and settings services. The browser half needs no npm
dependencies: React and react/jsx-runtime come from the DSH shared module table, and localization
rides the DSH locale service.
git clone https://github.com/keltanas/dsh-platform-balance.git
cd dsh-platform-balance
node --test # 132 tests, no network required
node --check lib/*.js # syntax check
After editing lib/client.js, refresh the page: HMR rebuilds the bundle from the file's mtime.
Host-half edits are cached by Node after the first import and apply on the next dsh web restart.
/zen/go/v1/usage endpoint, without exact money amounts.deepseek in it is treated as a third
party and is not billed; a custom provider id is never treated as OpenCode Go unless it is exactly
opencode-go.null (— ₽ in the UI).link: install keeps the checkout path as a runtime requirement; a git install is
self-contained.MIT — see LICENSE.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek、deepseek-harness。