dsh-cost-meter
Manifest validDSH Web GUI plugin: DeepSeek session cost estimate + account balance in the bottom status bar (live official pricing, per-session/per-model billing)
dsh-cost-meter
简体中文: README.zh.md
A DSH Web GUI plugin that shows DeepSeek session cost estimates and account balance in the bottom status bar.
Features
In the bottom status bar below the input box (the conversation.composer.dock slot, same row as the live-stats stats line; actual labels follow the UI locale):
stats row · TPS Flash off-peak 0.05/1.5/4.5 · Today ¥11.52 (5 sessions) · Session ¥0.08 · Balance ¥365.36
- Current model live price: reads the current session's selected model via the
session.modelsRPC and shows its live unit price (order: cache hit / cache miss / output, CNY per 1M tokens, model name bold); peak/off-peak pricing switches automatically — weekends bill at the off-peak (valley) price all day; updates within ~2.5s after switching the model in the composer. - Themed tooltip: hover/focus shows a bubble matching the current theme (
--dsw-alias-tooltip-bg) with a per-session cost breakdown, an aligned Flash/Pro price table (bold model names), and the price source with fetch time. - Today / session cost: prices are fetched live from the official DeepSeek pricing page (
api-docs.deepseek.com/zh-cn/quick_start/pricing, CNY per 1M tokens, 1h cache) and auto-follow official changes, covering both deepseek-v4-flash and deepseek-v4-pro; falls back to built-in constants (kept in sync with the official page) when the fetch fails. Pricing auto-selects by effective date (2026-08-17 00:00 Beijing) and peak/off-peak hours — peak is Beijing Mon-Fri 9-12, 14-18 (rest is off-peak); weekends (Sat/Sun) bill at the off-peak (valley) price all day (announced 2026-08-22, effective 2026-08-23 00:00 Beijing). - Per-model billing: the host detects each session's model from session records (
request/headerevents) and computes cost with the matching price set. - Per-session aggregation: today's cost is aggregated per session (the host scans the zstd multi-frame session files under
~/.dsh/sessions); hover to inspect each session's breakdown. Subagent sessions are auto-merged into their root session viaparentSession(breakdown lines show "含N子任务", and the count only lists root sessions). Breakdown lines show the workspace directory name (derived host-side from the session metadata'scwd, matching the GUI sidebar; DSH does not persist session titles, and the raw id is the fallback). - Cross-session dedup: DSH subagent session files carry full copies of the parent session's events, so the host globally dedupes usage samples by (time, turn, step, counts) fingerprint — the same API requests are billed once even when they appear in several session files (previously this inflated today's cost ~5x; now it closely tracks the platform's deduction records).
- Balance: queried every 60s from the official
GET https://api.deepseek.com/user/balance(cached), CNY preferred. - Balance warning: turns the whole row red when the CNY balance drops below
BALANCE_WARN_CNY(default 50). - Token-type stats: the tooltip shows an estimated breakdown of historical session token consumption by content type (command output / git output / code content / tool outputs / user / assistant / reasoning) plus a per-project distribution — data basis for token optimization (host
/api/token-types, 10 min cache, full history scan).
Install
dsh plugin --profile web add https://github.com/AnakinCao/dsh-cost-meter.git
# restart dsh web
Or no-restart manual mount: put lib + cordis.patch.yml into ~/.dsh/profiles/web/node_modules/dsh-cost-meter/, then append to ~/.dsh/profiles/web/cordis.patch.yml:
- insert:
- id: dsh-cost-meter
name: 'dsh-cost-meter'
Refresh the page once.
Pick ONE method — never mount twice.
API key (required for balance)
Resolved in order (any one suffices):
- Plugin config
config.apiKey(loader entry config); - Environment variable
DEEPSEEK_API_KEY; DEEPSEEK_API_KEYin~/.dsh/.credentials.yaml(the DSH official credentials file — matched by default).
Without a key the status bar shows "balance fetch failed"; costs still display normally.
Tuning
Constants at the top of lib/client.js (changes hot-apply via HMR in ~0.5s):
FALLBACK_PRICES— built-in fallback prices when the official fetch fails (flash/pro × legacy/off-peak/peak)BALANCE_WARN_CNY(default50) — balance warning thresholdMODEL_REFRESH_MS(default2500) — model polling interval (local RPC, negligible cost)REFRESH_MS(default60000) — balance/today/pricing refresh interval
Host cache: env DSH_COST_METER_REFRESH_MS or config.refreshMs (default 60000ms).
Notes
- Costs are estimates (official unit prices × usage); the authoritative bill is the DeepSeek platform.
- Balance/pricing calls run in the host process (the API key never leaves the browser); routes:
/dsh-cost-meter/api/balance,/today,/pricing. - No token consumption: cost reads local session logs; balance/pricing use account/docs endpoints — no model inference, no billing.
- Uninstall: remove the profile patch insert + delete
node_modules/dsh-cost-meter.
License
MIT
Comments
Loading…
From the same category
by ccch1mneyyy
DSH 官方公众号收录的 TUI 补位插件:Claude Code 风,鲸鱼顶栏/实时状态/流式思考/双击 Esc 回滚/上下文进度+TPS。npm 一键装。 DSH official WeChat featured TUI plugin — Claude Code style: whale bar, live status, streaming thoughts, double-Esc rol
★ 4.3k
↓ 10.9k/wk
MIT
TypeScript
Oct 11, 2026
dsh plugin --profile terminal add @deepseek-harness-tui/dsh-tuiby strukto-ai
The World's First Virtual Terminal for AI Agents
★ 3.7k
↓ 355/wk
Apache-2.0
TypeScript
Oct 11, 2026
dsh plugin --profile agent add @struktoai/mirage-dshby bowenliang123
The best DeepSeek Harness plugin for context insight and management, with context dashboard / browser / sidebar and context command, for context statistics, composition, breakdown, evolution details,
★ 2k
↓ 34.4k/wk
Apache-2.0
TypeScript
Oct 11, 2026
dsh plugin --profile web add dsh-contextby huiliyi37
官方 DeepSeek Harness 的交互式终端 UI 插件:自研 ANSI 极简交互渲染、流式 Markdown/工具卡、16+ 主题、slash 命令与选择器、输入历史与本地偏好持久化、LSP 诊断、memory记忆,很丝滑的开发体验。
★ 287
↓ 462/wk
Apache-2.0
TypeScript
Sep 30, 2026
dsh plugin --profile terminal add @huiliyi37/dsh-tianshu-tuiby Hilbert-beinghappy
面向 DeepSeek Harness 的 Claude Code 风格终端界面,支持 Windows、macOS 与 Linux,兼容透明终端、VS Code 主题和自定义配色。
★ 197
↓ 108/wk
MIT
TypeScript
Oct 1, 2026
dsh plugin --profile web add seekttyby T-Auto
deepseek-harness Plugin Access and Implementation Standards / deepseek-harness交互生态插件规范与实施标准
★ 83
MIT
JavaScript
Oct 10, 2026