返回目录
模型与 MCP 插件

dsh-account-balance

octisfall/dsh-account-balance

DeepSeek account balance and per-model spending under the composer in DeepSeek Harness

Stars
0
Forks
0
Issues
0
更新
11 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:octisfall/dsh-account-balance

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-account-balance

Your DeepSeek account balance, and what your sessions spent, right under the composer in DeepSeek Harness.

status license

The widget sits in the composer dock, beside the context meter:

  • Balance of the signed-in DeepSeek account, refreshed on mount, on window focus, and every two minutes.
  • Hover for the breakdown between topped-up funds and granted bonus credit.
  • Click for a panel with spending per model for today, the last 7 days, and the last 30 days, plus a button that opens the Platform usage page.
  • If dsh-oh-my-claude is installed, a Claude row joins the same three periods, totalled across every one of its sessions on this machine — not only the one open right now, which is all dsh-oh-my-claude's own cost line shows.
  • Each spending row carries a small mark before its cost — blue for DeepSeek, terracotta for Claude — so the two ledgers are tellable apart at a glance.
  • In the dock itself, only one trigger shows at a time: a session whose model picker is on dsh-oh-my-claude (claude-code, or a second configured instance's claude-code-<suffix>) shows the Claude $spent / $dailyLimit trigger instead of the DeepSeek balance; any other session shows the DeepSeek balance instead. Both show together only while the picker's choice for that session cannot be read.
  • Honest states: Balance — with a reason when the account is signed out, the wallet read fails, or the usage route is unavailable.

Install

Through the Plugins settings page — Settings → Plugins → Add — or through the CLI's plugin command, which forwards to pnpm inside the profile directory:

dsh plugin --profile <profile> add github:octisfall/dsh-account-balance

The package declares a Cordis bundle patch and a web Client entry, so it appears in the profile's plugin list and starts rendering after the page loads.

How it works

Two halves in one package, as DSH bundles expect:

Half File Role
Host index.js Registers one read-only route, GET /plugin/account-balance/usage. It folds every recent session log through ctx.sessionQuery, attributes each assistant/message to the model in force, prices the step, folds in dsh-oh-my-claude's own turns.json ledger when present, and caches the answer for 60 seconds.
Client client.js Registers a conversation.composer.dock entry. Reads the wallet through the account Remote namespace (getBalance) and the Platform usage link through getState, and fetches the Host route when the panel opens.

Everything the Client shows comes through the Harness itself: no separate server, no polling of Platform. Copy goes through the Client locale service (English and Chinese), colors through --dsw-alias-* theme tokens, so the widget follows the app theme and language.

What the money figure is, and is not

The session log stores tokens, not invoices. The panel therefore shows an estimate: token counters from your local sessions multiplied by the rates in prices.json.

  • Rates shipped here are the published DeepSeek API rates for deepseek-flash and deepseek-v4-pro from https://api-docs.deepseek.com/quick_start/pricing, in USD per million tokens.
  • Peak windows (01:00–04:00 and 06:00–10:00 UTC, Monday–Friday) bill at the peak rate and everything else at half, decided per step from the event time. Chinese public holidays are not tracked, so a holiday step is priced as an ordinary weekday.
  • Cache reads, cache writes, and fresh input are counted separately, each at its own rate; a cache write bills at the cache-miss rate.
  • An unknown model shows tokens and — for money, and its period total stays unpriced rather than silently understating it.

Edit prices.json to correct a rate; the next read of the panel picks it up. The authoritative numbers always live in the Platform usage page the panel links to.

The Claude row is different: dsh-oh-my-claude already prices each turn in USD at the time it runs (Claude's CLI reports its own total_cost_usd), so this plugin only sums what is already in ~/.local/state/dsh-oh-my-claude/turns.json — no price table of its own, and no re-pricing. A turn the CLI routed to a non-Anthropic model (via set) is skipped, same as dsh-oh-my-claude's own cost line skips it. The Claude cost folds into the period total only when the DeepSeek price table's currency is also USD; otherwise the row still shows on its own, in USD, just not summed into a CNY (or other currency) total.

Privacy

  • The route reads token counters from the local session logs already on this machine. Nothing is uploaded.
  • The Claude row reads ~/.local/state/dsh-oh-my-claude/turns.json, the same local, per-turn cost ledger dsh-oh-my-claude already keeps for its own cost line. Nothing is uploaded, and the file is absent entirely when that plugin is not installed, so the row simply does not appear.
  • The route answers on the local Harness HTTP server. Like other plugin routes it sits outside the /api bridge, so it carries no browser-session authentication: keep the server bound to loopback, which is the DSH default. It exposes aggregate token counts and costs only — never prompts, messages, file paths, or credentials.
  • The plugin never reads or stores the account token; the balance comes from the account namespace the Harness already owns.

Compatibility

Built and verified against DeepSeek Harness 0.2.1-rc.5. It depends on conversation.composer.dock, the account Remote namespace, sessionQuery, and webServer; a Harness release that renames any of them will need a matching change here.

Development

The plugin is a plain npm package with dsh.bundle.patch and dsh.client; there is no build step, and index.js and client.js are the shipped artifacts.

  • Edit index.js or client.js, then let the profile recompose (or reload it) so the new module generation is imported.
  • Edit prices.json without touching code; the next read of the panel picks the new rates up.
  • Check the Host fold without opening the UI: curl http://127.0.0.1:<port>/plugin/account-balance/usage.

License

MIT

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类模型与 MCP
规则置信度高

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek、deepseek-harness。