crazywoola/dsh-balance 预览 preview

crazywoola/dsh-balance

Plugin插件 Native原生 ⭐ 26 MIT Usage & Cost用量与计费

Settings页面用的DeepSeek Harness平衡插件

Project Overview项目介绍

dsh-balance is a native plugin built exclusively for DeepSeek Harness (DSH) that tracks DeepSeek API balance and usage costs. To install the plugin, you run the official DSH CLI command dsh plugin --profile web add @pinkbanana/dsh-balance@latest then start DSH with dsh --profile web. Once installed, you can access the plugin’s settings page from the DSH settings menu under the Agent Presets section, and it automatically pulls any saved DeepSeek API key from your DSH configuration. It never sends your API key to any external server, keeping it local to your DSH instance.

After installation, the plugin displays a persistent balance summary at the bottom of every chat window in DSH. It changes the summary indicator to orange during DeepSeek’s peak pricing hours (9AM–12PM and 2PM–6PM Beijing time), to alert users of higher per-token costs. You can view a full breakdown of your balance (total, topped-up, and bonus) and see a full list of models available to your API key. It also caches query results and lets you manually refresh data at any time. This plugin is ideal for any DSH user that connects to DeepSeek’s API directly, helping you avoid unexpected overspending on API calls.

The plugin groups usage data by your browser’s IANA time zone, but always calculates peak pricing based on Beijing time regardless of your local setting. It shows costs in USD by default, but you can add a fixed usdToCny exchange rate to the plugin config to also display costs converted to Chinese yuan. Requests from unknown providers or for unknown models are marked as unpriced, and the plugin does not estimate token counts for these requests. It is released under the permissive MIT open source license, and uses pnpm for dependency management during local development.

dsh-balance 是专门为 DeepSeek Harness 开发的原生插件,核心功能是查询 DeepSeek API 的账户余额、整理当前 API Key 可用的模型列表,并提供多维度的 API 调用消费统计。插件全程仅在本地使用用户的 API Key,不会将密钥发送到浏览器或第三方服务器,最大程度保障用户的密钥安全。用户可以通过 DSH 官方提供的命令行工具完成一键安装,安装后会自动在 DSH 设置界面新增对应的配置入口。

安装完成后,用户可以在 DSH 设置页的「Agent 预设」下方找到「DeepSeek 余额」入口,查看总余额、充值余额和赠送余额,还能按模型、会话和日期维度筛选查看消费记录,当前会话也会新增「消费」标签页展示请求明细。余额摘要会固定显示在每个会话的聊天框下方,还会根据 DeepSeek 的峰谷定价规则在高峰时段变色提示。这款插件适合经常使用 DeepSeek API 通过 DSH 对话的用户实时把控消费成本,避免超预算支出。

插件默认使用美元展示消费金额,用户可以在配置中添加固定汇率 usdToCny,额外显示人民币换算结果。日期默认按照浏览器的 IANA 时区分组,DeepSeek 峰谷价格统一按北京时间计算,不支持对未知模型请求做 token 估算,未知来源的请求会被标记为「未计费」。插件遵循 MIT 开源许可协议免费使用,开发依赖 pnpm 包管理工具,原生支持中英文且可跟随 DSH 系统语言自动切换。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 note1 项提示
  • 26 stars - an early-stage project星标 26,属于早期项目
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add @pinkbanana/dsh-balance@latest

把 crazywoola/dsh-balance 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-balance

简体中文 | English

DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API 余额、各提供方的可用模型和多维消费统计。API Key 仅由本机 Host 使用,不会发送到浏览器。

界面使用 Harness 原生侧栏、主页面和主题变量。侧栏“插件”下方新增“用量统计”,独立查看所有对话的提供方、模型、会话和日期统计;默认显示全部提供方与全部时间,支持提供方和日期范围筛选。活动打卡图按浏览器时区的星期 × 24 小时汇总请求次数,圆点大小随次数变化;悬停或使用方向键可查看请求数与 token 明细。选择器采用主题化浮层菜单,支持方向键、Home/End、Enter、Escape 和按名称检索。设置页支持 DeepSeek / StepFun 切换。运行 pnpm preview 可查看使用示例数据的新版界面。

聊天框底部会跟随当前会话所选的提供方与模型更新余额;设置页可独立切换提供方。

功能

  • DeepSeek:查看总余额、充值余额和赠送余额
  • StepFun:查看可用余额、总充值金额、总赠送金额及预付费 / 后付费账户类型
  • 提供方独立缓存;支持大小写不敏感的 Provider ID
  • 在聊天框下方显示当前 provider、模型和余额,兼容模型选择器与 /model 切换
  • 从当前提供方的 /models 接口读取可用模型、所属组织与创建时间
  • 在设置页按所选 provider、模型、会话和日期查看实际 usage 消费,并在当前会话的“消费”Tab 查看请求明细
  • 缺少 provider usage、未知 provider 或未知模型时标记为“未计费”,不进行 token 估算
  • 日期按浏览器 IANA 时区分组;DeepSeek 峰谷价格始终按北京时间计算
  • DeepSeek 费用显示 USD、StepFun 显示原生 CNY;配置 usdToCny 后显示人民币合计
  • 缓存查询结果并支持手动刷新
  • 依据 DeepSeek 峰谷定价,在高峰时段(北京时间 9:00–12:00、14:00–18:00)将聊天框下方的余额指示灯变为橙色
  • 原生支持简体中文和英文,并跟随 Harness 系统语言切换
  • 支持 Harness 已保存的 DEEPSEEK_API_KEY

会话消费页示例

兼容性

0.10.0 适配 DeepSeek Harness 0.2.0-rc.2(上游提交 639ed01),需要 Node.js 22.19+(22.x)或 24+。本次源码不再兼容 Harness 0.1 的接口。

也可在本地构建并打包源码,再用 dsh plugin --profile web add /absolute/path/to/package.tgz 安装生成的 .tgz 文件,随后重启 Harness:

pnpm install --frozen-lockfile
pnpm pack

消费统计通过新版只读会话句柄读取,以 inheritedEventCount 排除分叉继承的记录;会话页在 token 用量变化或一轮运行结束后刷新;统计页面每 15 秒检查更新,重新聚焦或返回页面时刷新,隐藏页面暂停查询。兼容 assistant/message 和重试/取消请求的 assistant/attempt,读取最后一条 stream usage,并以重试边界区分独立请求,同一次请求的重复结算仅计一次。

全局统计会跳过当前 dsh 无法读取的旧格式或损坏会话,并显示未纳入统计的会话数量;其余会话仍正常统计。部分读取结果不缓存,下次刷新会重试。单个会话无法读取或所有会话都读取失败时,仍明确显示读取错误,不将失败记录当作零消费。

分类明细采用带数量的 Tab 面板,在模型、提供方、会话和日期之间切换;窄屏自动改用主题化选择器。每页默认 10 条,可选择 5 / 10 / 20 条。会话消费页分别查看模型汇总与请求明细,请求支持模型筛选。长名称省略显示,悬停保留完整名称。

分类面板与分页示例

安装

dsh plugin --profile web add @pinkbanana/dsh-balance@latest
dsh --profile web

打开 http://127.0.0.1:3080/,进入“设置 → 模型余额”。该入口位于“Agent 预设”下方,余额摘要也会显示在已有会话的聊天框下方。API Key 可在“设置 → 模型”中保存,或通过 DEEPSEEK_API_KEY 环境变量提供。

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-usage-stats 下一个 Next dsh-diff-viewer →