spoon-man569/dsh-token-price
DSH 实时 Token 花费与账户余额显示插件(每轮花费 · 总花费 · 余额)
项目介绍Project Overview
dsh-token-price 是 DeepSeek Harness Web 聊天界面插件,按历史美元定价规则计算每轮请求步骤与会话累计 token 成本,折成估算人民币显示,并读取官方账户余额。适合需要在对话中查看花费、余额和未定价路由时使用。注意:¥为市场汇率估算,非官方扣费;内部仍以美元核算。
dsh-token-price is a DeepSeek Harness Web chat plugin that calculates per-message and session token costs from versioned historical USD pricing rules, displays an estimated CNY conversion, and reads the official account balance. Use it to inspect spend, balance, and unpriced routes during chats. Caveat: the ¥ figure is a market-rate estimate, not an official charge; USD remains the internal accounting value.
请帮我了解并安装插件:【dsh-token-price】【https://github.com/spoon-man569/dsh-token-price】
把上面这条消息直接发给当前会话里的 DSH,让它帮你了解并安装。安装命令不一定准确,发给 DSH 更稳。Send this message to DSH in your current session. CLI install commands may not be accurate across systems — DSH will figure it out for you.
或使用命令行安装(适合开发者)Or use CLI install (for developers)
命令行安装CLI Install
dsh plugin --profile web add dsh-token-price
把 spoon-man569/dsh-token-price 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-token-price
English | 汉语
Accurate token-cost and account-balance readouts for the DeepSeek Harness Web chat UI.
What it shows
- Per-message cost: the cost for completed request steps in that turn, shown as
¥...after each assistant reply's statistics line on hover. - Session total: the sum of every reported request step, including a cancelled request that emitted usage but no final assistant message.
- Estimated CNY: a market-rate USD/CNY conversion shown as
¥.... USD is not rendered in the UI. This is not an account debit or official per-request CNY charge. - Account balance: the official
GET /user/balanceresult. The plugin prefers the returned CNY balance and otherwise preserves the API's returned currency.
USD remains the internal accounting value. An unknown provider/model route is shown as 未定价, never as a zero-cost amount.
Install
One command (requires pnpm):
dsh plugin --profile web add dsh-token-price
The package declares dsh.bundle and dsh.client, so this activates both the host service and browser readouts.
Configuration
- id: token-price
name: dsh-token-price
config:
balanceBaseURL: https://api.deepseek.com
balanceApiKeyEnv: DEEPSEEK_API_KEY
balanceRefreshIntervalMs: 60000
referenceRateRefreshIntervalMs: 3600000
requestTimeoutMs: 5000
balanceApiKeyEnv names the credential holding the DeepSeek API key used for the balance request. The key remains on the host. A failed refresh keeps the last balance sample.
Pricing and rates
prices.json is the local, versioned source of official USD rates per million tokens. It is an append-only history: each rule has an effectiveFrom timestamp, Beijing peak windows, and explicit prices for each supported route. New official prices must append a rule; past rules must not be changed.
The tokenCost projection snapshots the request route and time at request/header, then calculates each (turn, step) from the matching historical USD rule. Replaying the same session log therefore yields the same USD result. The host never scrapes the official price page at runtime.
USD/CNY is refreshed server-side from public market-rate sources every hour. When that refresh fails, the UI uses the current rule's bundled fallback rate. Both values remain estimates (¥) and never affect USD accounting.
Development
npm install
npm test
npm test builds lib/, emits type declarations, and runs accounting tests. Restart the DSH Web process after rebuilding so it loads the new artifacts.
License
MIT
nexu-io/open-design
freestylefly/awesome-gpt-image-2
anywhere-labs/dsh-desktop
walkinglabs/learn-harness-engineering
awesome-dsh-plugin/awesome-dsh-plugin
MemTensor/MemOS