Skip to main content
L

dsh-token-budget-live

lonerjq/dsh-token-budget-live

Shows token spend and money cost in a strip under the composer, with account balance, daily and monthly budgets, and per-workspace, per-session and per-model statistics; every request is priced at the peak or off-peak rate that applied when it ran. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.

Install

dsh plugin --profile web add github:lonerjq/dsh-token-budget-live

README

Token 预算 · dsh-token-budget-live

DeepSeek Harness 插件:在输入框下方显示实时 token 用量与对应花费、账户余额、每日与每月预算,并按工作区、会话和模型统计用量。预算只影响显示(超额标红),不限制任何会话、任务或请求。

输入框下方的状态条与展开后的用量面板

功能

  • 状态条:会话页输入框下方一行,显示当前时段(高峰/空闲)、今日 token、今日花费、本月花费、账户余额。
  • 面板:点状态条展开,五个页签——概览 / 工作区 / 会话 / 价格 / 预算。
  • 按请求计价:每条请求按它发生时的峰谷价计入花费(工作日 09:00–12:00、14:00–18:00 为高峰,其余为空闲半价),而不是按打开页面时的价格。
  • 预算:每日/每月 token 预算与每日/每月金额预算,留空或 0 表示不设。
  • 余额提醒:可用余额低于阈值(默认 ¥3)时展开面板并显示充值二维码。
  • 消耗异常提醒:最近 5 分钟花费达到此前一小时平均水平的 20 倍时闪红灯;停止消耗满 2 分钟自动熄灭。

安装

在插件市场(dshmarket)里搜索「Token 预算」一键安装,或在终端:

dsh plugin --profile <profile> add github:lonerJQ/dsh-token-budget-live

安装后刷新页面。状态条只在会话页渲染,首页的新会话空状态不显示。

配置

预算与阈值都在面板的「预算」页签里改,保存在该机器自己的 profile 配置中(不跟着插件走),默认全不设预算、余额阈值 ¥3。

数据与资源

  • 用量来自本机已有的会话日志(宿主接口只读),不会写会话日志,也不会把历史迁到别处。
  • 余额读取当前登录的 DeepSeek 账号;插件自身不发起任何网络请求。
  • 插件唯一的落盘是这个插件自己的配置行。
  • 关掉或移除插件即全部停止,不留后台进程。

兼容性

在 DeepSeek Harness 0.2.2-rc.1 至 0.2.2-rc.5 上使用验证。插件只使用宿主的 webServer、sessionQuery、deepseekAccount、configEditor 服务,不依赖其它 npm 包——二维码编码器已内置在 vendor/(MIT,见 vendor/README.md)。

卸载

在「设置 → 插件」里停用并移除「Token 预算」,或:

dsh plugin --profile <profile> remove dsh-token-budget-live

License

MIT


Token budget (English)

Shows token spend and money cost in a strip under the composer, plus account balance, daily and monthly budgets and per-workspace, per-session and per-model usage. Budgets only colour the numbers (red when over) — they never block a session, task or request.

  • Strip: peak/off-peak badge, today's tokens, today's cost, this month's cost, account balance.
  • Panel: overview, workspaces, sessions, price sheet, budgets.
  • Cost is priced per event at the peak or off-peak rate that applied when the request ran.
  • Low balance opens the panel once and shows a top-up QR code; the threshold defaults to ¥3.
  • A burst warning blinks when the last 5 minutes cost at least 20× the previous hour's average, and clears itself after 2 minutes without new spend.

Install from the dshmarket plugin market, or dsh plugin --profile <profile> add github:lonerJQ/dsh-token-budget-live. Usage is read from this machine's session logs; the balance comes from the DeepSeek account already signed in here. The plugin makes no network requests of its own and writes nothing except its own config row. Used on DeepSeek Harness 0.2.2-rc.1 through 0.2.2-rc.5. MIT licensed.

Related plugins