CN-Leo/dsh-deepseek-balance

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

deepseek-harness 插件,实时查询 DeepSeek 账号余额。

Project Overview项目介绍

This is a native plugin built exclusively for DeepSeek Harness (DSH), designed to display real-time DeepSeek account balance and session consumption directly on the DSH web interface. The balance widget is permanently docked below the conversation composer input box, and refreshes automatically every 15 seconds. It pulls balance data from DeepSeek's official GET /user/balance API endpoint, and your DeepSeek API key is resolved locally by DSH's credential service, never being exposed to the browser frontend to keep your key secure. To install the plugin, run dsh plugin add <repository-url or local-path> via the DSH CLI, then restart the DSH web process to activate it, since DSH does not currently support hot-loading new plugins.

After installation, you must configure your DeepSeek API key before the plugin can work properly. The plugin checks for the key in two locations: first the DEEPSEEK_API_KEY environment variable, then the $DSH_HOME/.credentials.yaml file, and it re-reads the key on every request so you do not need to restart the plugin after updating the configuration. The plugin calculates consumption per model in your current session, extracting token usage directly from the session log and applying DeepSeek's official pricing. It automatically differentiates between peak and off-peak Beijing time pricing for DeepSeek models, and ignores non-DeepSeek models for consumption calculation.

When you hover your cursor over the balance widget, you can view a full breakdown of your account balance and session usage. The breakdown shows total, granted, and top-up balance, your account status, token usage split by model, and current time period for pricing. The plugin relies on core DSH services including credentials, subprocess, webServer, and the React framework provided by DSH's web module. It also requires curl to be available on your system path, which is pre-installed by default on Windows and most Linux distributions. The plugin is released under the open MIT license, so you can modify or redistribute it freely per the license terms.

这是一款专为DeepSeek Harness(DSH)开发的原生插件,核心功能是在DSH的Web界面中实时显示DeepSeek账户余额。插件将余额信息常驻展示在会话输入框下方,每15秒自动刷新一次,同时还能根据DeepSeek官方最新定价,实时计算当前对话已经产生的消费金额。数据调用官方接口获取,API密钥由DSH主机端凭据库解析,绝不会传递到浏览器端,保证密钥安全。

安装插件可以通过DSH CLI执行dsh plugin add命令,填写GitHub仓库地址或本地插件路径即可完成安装,安装后需要重启DSH Web服务才能完成加载,当前DSH不支持热加载新插件。配置时需要在环境变量或$DSH_HOME/.credentials.yaml中填写DeepSeek API密钥,插件每次请求都会重新解析凭据,配置后无需再次重启服务。这款工具适合经常通过DSH使用DeepSeek API对话的用户,方便随时掌握账户余额和会话消费。

插件支持分模型计算当前会话的token用量和消费,自动区分北京时段的峰谷定价,仅对DeepSeek官方模型计价,第三方模型不会计入本次会话消费。悬停在余额条上可以查看完整明细,包括各类型余额、分模型token用量、当前时段等信息。插件依赖DSH基础服务和系统自带的curl工具,使用MIT开源协议,完全免费供用户使用,可自行按需修改源码。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 2 stars - very few users, little community feedback星标只有 2,几乎没人在用,遇到问题缺少社区反馈
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 github:CN-Leo/dsh-deepseek-balance

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

READMEREADME

dsh-deepseek-balance

DeepSeek 账户余额实时显示插件(DeepSeek Harness / DSH)。

在 DSH Web 界面的输入框下方(conversation.composer.dock)常驻显示 DeepSeek 官方账户余额,每 15 秒自动刷新;同时按官网最新定价实时计算本次会话消费金额。数据来自官方接口 GET https://api.deepseek.com/user/balance,API Key 由 Host 端从 DSH 凭据库解析,绝不会进入浏览器。

安装

# 从 Git 仓库(发布后)
dsh plugin add https://github.com/<你的用户名>/dsh-deepseek-balance

# 或从本地目录
dsh plugin add /path/to/dsh-deepseek-balance

安装后重启 dsh web(当前进程不会热加载新插件)。

配置(必需)

插件通过 credentials 服务解析 DEEPSEEK_API_KEY,按以下顺序查找(任选其一):

  1. 环境变量 DEEPSEEK_API_KEY

  2. $DSH_HOME/.credentials.yaml:

    DEEPSEEK_API_KEY: sk-xxxxxxxxxxxxxxxx
    

配置后无需重启插件:每次请求都会重新解析凭据。

使用

  • 余额条显示在会话输入框下方:● DeepSeek 余额 ¥71.33 | 本会话 ¥4.85
    • 绿点 = 正常,黄点 = 加载中,红点 = 获取失败
    • 「本会话消费」按会话实际使用的模型分模型计价(从会话日志逐次提取每个模型调用的 token 用量),仅 deepseek-v4-flash / deepseek-v4-pro 套用官网价格,自动区分高峰/空闲时段(北京时间 9:00-12:00、14:00-18:00 为高峰,其余空闲),每 15 秒与余额一同刷新
  • 悬停(hover)余额条可查看完整明细:
    • 各币种余额:总额 / 赠送 / 充值 / 账户可用状态
    • 本次会话按模型分列的 token 用量:输入(未命中/命中/写入)、输出
    • 当前时段、本次会话消费金额
  • 说明:非 DeepSeek 模型(如第三方 "…-pro")不套用 DeepSeek 价格表、不计入消费金额;缓存写入按缓存未命中输入价计(官方价格表仅区分命中/未命中)

原理

端 职责
Host credentials.resolve('DEEPSEEK_API_KEY') → subprocess 调用 curl 请求官方余额接口;同时读取本会话日志(sessionQuery.readSession),按 request/header 的模型与 assistant/message 的 usage 逐次配对、按模型聚合 token → 通过 webServer 暴露 GET /api/deepseek-balance?session=<id>
Client 浏览器 fetch('/api/deepseek-balance?session=<id>') 每 15s 轮询余额与分模型用量 → 按官网定价表 + 北京时间峰谷时段本地计价(非 DeepSeek 模型跳过)

API Key 只存在于 Host 进程的 curl 子进程参数中,浏览器端只能拿到余额 JSON。

卸载

dsh plugin remove dsh-deepseek-balance

依赖

  • Host:credentials、subprocess、sandboxPolicy、webServer(DSH 基础服务,Web 模式均有)
  • Client:slots 服务,react(由 DSH Web 模块表提供)
  • 系统:curl(Windows 自带 curl.exe;其他平台需 PATH 中有 curl)

License

MIT

← 上一个 Prev dsh-gb 下一个 Next dsh-ops-health →