DeepSeek Harness 的余额与用量可视化插件:监控多账户余额、低余额告警、一键充值,复刻 Miyu 风格用量统计,并提供三方插件管理面板。
- 语言
- JavaScript
- License
- MIT
- 分支
- main
安装
$ dsh plugin --profile web add github:Francis-Xavier-code/dsh-balance-plugin在终端中运行以上命令,通过 dsh CLI 安装此插件。可在右上角切换 Profile。 第一次用 dsh?看这篇新手教程
对话式安装
帮我安装 DeepSeek Harness 插件 Francis-Xavier-code/dsh-balance-plugin:先查看仓库 https://github.com/Francis-Xavier-code/dsh-balance-plugin.git 确认安全性,然后执行安装命令并验证插件加载成功。
把这段指令粘贴给 DSH Web GUI 里的助手,由它代你完成安装与验证。
一句话定位
为 DeepSeek Harness 装上一组财务与统计仪表盘:监控 DeepSeek API 多账户余额、低余额告警、一键跳转官方充值,并复刻 Miyu WebUI 的用量统计视图,附带三方插件管理面板。
核心能力
- 监控 DeepSeek API 多账户余额(CNY / USD 双币池)并按币种独立阈值触发低余额告警(默认 ¥10 / $2,余额条变红、控制台打印警告)
- 一键直达 DeepSeek 官方充值页
platform.deepseek.com/top_up与用量明细页platform.deepseek.com/usage - 提供 Miyu 风格的用量统计页:1天 / 7天 / 30天 / 至今切换、统计瓦片、GitHub 贡献图风格用量日历、三段堆叠趋势柱状图、模型消耗环形图与明细表、最近 50 条调用记录
- 实时性能指标条:轮次、步数、LLM 时长、工具调用时长、首 token 平均延迟、tok/s、缓存命中率
- 三方插件管理:列出 web profile 下非
@deepseek-ai的所有插件(包名、Bundle rev、依赖、本地路径),macOS 上可一键「打开目录」定位源码 - 注册模型工具
query_api_quota,可让 LLM 直接查询 DeepSeek 余额并给出充值提醒
技术实现
- 语言: JavaScript(Node.js + 浏览器端 ES Module / CommonJS bundle)
- 关键依赖:
@deepseek-ai/dsh宿主(cordis 上下文注入timer / webServer / clientModules / credentials / sessionQuery / tools / shell / slots)、浏览器侧react(通过require('react')从宿主 bundle 复用)、curl命令行(由宿主shell服务调用)、window.__ModuleLoader__浏览器 bundle 加载器 - 架构模式: 标准的 DSH 双面(host + client)插件;host 进程通过
ctx.webServer.register注册私有 RPC 路由POST /bmon/api/<name>,client 通过fetch调用;balance 轮询由ctx.interval触发;用量统计通过ctx.on('session/event')实时聚合 +sessionQuery.readSession启动期扫描 90 天历史 - 入口文件:
lib/index.js(host)、lib/client.js(browser,经/plugins/dsh-balance-plugin/client.js加载),通过cordis.patch.yml把自己插入 web profile;仓库根host.js/client.js为动态版同源副本
适用场景
日常用 DeepSeek Harness 大量调用官方 API 的用户:想在主界面一眼看到余额还剩多少、避免被低余额卡住;想看自己过去一周 / 一个月的 token 消耗趋势、各模型占比、缓存命中率;想顺手看到当前装了哪些三方 web 插件并定位源码。普通轻度用户只关心余额条与告警,重度用户会用上用量统计与模型工具。
前置依赖与兼容性
| 依赖 | 最低版本 | 说明 |
|---|---|---|
| DeepSeek Harness | 未声明 | 插件通过 cordis 注入 timer / webServer / clientModules / credentials / sessionQuery / tools / shell / slots,需宿主版本提供这些服务(lib/index.js:5) |
| Node.js | 未声明 | package.json 未声明 engines;宿主 Node 即可 |
| 平台 | 跨平台(macOS) | 余额查询、用量统计、浏览器面板均跨平台;「三方插件打开目录」用 macOS 的 open -R 命令,仅 macOS 可用(lib/index.js:535) |
| 原生模块 | 无 | 无 npm 原生依赖;balance 查询通过宿主 shell 调 curl,不引入额外原生模块 |
安装方式
dsh plugin --profile web add github:Francis-Xavier-code/dsh-balance-plugin
安装完成后重启 DSH,输入框工具行右侧出现三个图标按钮即生效。可选用 DSH_PROFILE=<name> 切换到其他 profile。
配置项
| 配置 | 类型 | 说明 | 默认值 |
|---|---|---|---|
| 账户列表 | 列表 | 「+ 添加账户」可加多个账户,每个账户有名称与 API Key;空 Key 提交表示保持不变,「清除」按钮可清空已配置的 Key | 空(首次启动时自动读取 DSH 凭据 DEEPSEEK_API_KEY 生成一个「自动读取·DSH 凭据」账户) |
| API Key 引用 | 字符串 | 直接填明文 Key,或填 $env:环境变量名(如 $env:DEEPSEEK_API_KEY),由插件调用前从环境变量展开 | 明文 |
| CNY 告警阈值 | 数字 | 对应币种总余额低于此值时触发低余额告警并标红 | 10 |
| USD 告警阈值 | 数字 | 同上 | 2 |
| 刷新间隔 | 选项 | 余额轮询间隔,从下拉中选择;提交后立即触发一次刷新 | 300000(5 分钟,可选 30 秒 / 1 分钟 / 15 分钟 / 30 分钟) |
常见问题
Q:重启后插件还在吗?
A:在。静态插件持久安装,重启后仍生效;通过面板手动配置的账户 Key 会重置,但自动读取的 DEEPSEEK_API_KEY 账户会在启动时自动恢复(lib/index.js:144)。
Q:侧边栏底部看不到入口按钮?
A:DSH 侧边栏底部槽位被官方 Cordis 面板插件独占整行。本插件入口固定在输入框工具行右侧(💰 钱包 / 📊 用量 / 🧩 三方插件)以及输入框下方的常驻余额条,不依赖侧边栏槽位(lib/client.js:799-816)。
Q:API Key 会泄露吗?
A:不会。Key 只保存在本机插件进程的内存对象里,界面只显示掩码(…后 4 位),源码与文档中不含任何凭据,curl 通过 Host shell 转发调用、不写入日志(lib/index.js:33-53)。
Q:余额查询失败怎么办?
A:看面板里账户行的错误提示:未配置 Key 会显示「未配置 API Key」;用 $env: 引用但变量缺失会显示「环境变量名 xxx 未设置」;Key 无效会透出 DeepSeek 返回的 401 / 错误信息(lib/index.js:43-91)。
Q:用量统计为什么看不到 90 天前的历史?
A:插件启动时扫描近 90 天的会话事件按 seq 去重聚合,但单次最多读取 60 个会话(lib/index.js:345)。如果会话数超出,会跳过更早的部分;「首 token 平均延迟」只统计插件运行后实时捕获的流式数据。
Q:为什么不能用 dsh plugin add dsh-balance-plugin?
A:npm 上存在他人同名包(dsh-balance-plugin@0.1.0),裸包名会装错版本。安装命令必须用 github: 源指向本仓库(README.md:163)。
Q:怎么卸载?
A:一键:curl -fsSL https://raw.githubusercontent.com/Francis-Xavier-code/dsh-balance-plugin/main/uninstall.sh | bash;手动:dsh plugin --profile web rm dsh-balance-plugin 并清理 ~/.dsh/cordis.patch.yml 里本插件的 - insert 块,重启生效。
Q:三方插件面板里「打开目录」在 Windows 上能用吗?
A:不能。该功能通过 Host shell 执行 open -R <路径>(lib/index.js:535),这是 macOS Finder 专属命令;Windows / Linux 没有 open,点击会失败,列表展示本身仍正常用。
上手难度
入门 — 装好即默认带一个「自动读取·DSH 凭据」账户,余额条会立刻开始刷新,无需任何额外配置;想加账户或调阈值也是点开面板填两下即可。
已知问题与限制
- 三方插件「打开目录」用 macOS
open -R命令,Windows / Linux 下不可用(lib/index.js:535)。 - 启动期历史扫描最多读取 60 个会话(lib/index.js:345),90 天内会话数超过 60 的用户可能看到历史用量比预期少。
- 「首 token 平均延迟」仅统计插件运行后实时捕获的流式数据,安装前已发生的会话无法贡献(README.md:161)。
- 余额查询依赖 DeepSeek 官方接口
api.deepseek.com/user/balance与本机curl命令;离线环境无余额查询能力。 - 浏览器端 client.js 自身 53 KB,注入的样式表约 100 行 CSS,会随插件一起进入页面 bundle(lib/client.js:37-137)。
💰 DeepSeek Balance Monitor & Usage Stats
A DeepSeek Harness (DSH) plugin — balance monitoring · official top-up link · Miyu-style usage statistics · third-party plugin manager
✨ Features · 🖼 Screenshots · 📥 Install · ⚙️ Configuration · 🎮 Usage · 🗑 Uninstall · 🏗 Architecture · ❓ FAQ
✨ Features
| Module | Capability |
|---|---|
| Balance monitoring | Monitors DeepSeek API balance (CNY / USD dual balance pool) with parallel multi-account queries; auto-reads the DSH credential DEEPSEEK_API_KEY — no manual entry needed |
| Low-balance alerts | Independent CNY / USD thresholds (default ¥10 / $2, configurable); the balance bar turns red when below threshold |
| One-click top-up | Jumps straight to the official DeepSeek top-up page platform.deepseek.com/top_up, plus a usage-details page link |
| Usage statistics | 1:1 recreation of the Miyu WebUI usage page: stat tiles / GitHub-contribution-style usage calendar / three-segment stacked trend bar chart / model consumption donut chart with detail table / recent 50 call records |
| Performance metrics | Turns · steps · LLM duration · tool-call duration · avg first-token latency · tok/s · cache hit rate |
| Third-party plugin manager | Lists unofficial (non-@deepseek-ai) web plugins: package name / local path / Bundle rev / dependencies, with a one-click "Open Directory" to locate source code |
| Model tool | Registers the query_api_quota tool — just ask "How much DeepSeek balance is left?" and get a balance summary |
Charts use Miyu's chart / heat palettes (blue / gold / rose / purple + blue-purple heat scale) and auto-adapt to dark / light themes.
🖼 Screenshots
| Screenshot | Description |
|---|---|
![]() | Three icon entries on the right of the input toolbar (💰 Wallet / 📊 Usage / 🧩 Plugins) plus a persistent balance bar below |
![]() | Balance monitoring panel: balance table, low-balance alerts, account config, thresholds & refresh interval, top-up entry |
![]() | Usage page top: range switcher, stat tiles, live performance metric bar, GitHub-style usage calendar |
![]() | Usage page bottom: trend bar chart, model consumption details, call record details |
![]() | Third-party plugin manager: stat badges, plugin list, "Open Directory" action |
📥 Install
Prerequisites
- DeepSeek Harness installed and running
- (Optional) DeepSeek API Key — get one at platform.deepseek.com; if
DEEPSEEK_API_KEYis already configured on this machine, the plugin auto-reads it at startup — no manual input required
One-click install (recommended)
# Installs automatically (install deps → write compose patch → prompt restart)
curl -fsSL https://raw.githubusercontent.com/Francis-Xavier-code/dsh-balance-plugin/main/install.sh | bash
Restart DeepSeek Harness after installation — three icon buttons appear on the right of the input box. Use DSH_PROFILE=<name> to target another profile.
Manual install (equivalent)
# 1. Install the dependency (use the github: source, not the bare package name — a third party owns a same-named package on npm)
dsh plugin --profile web add github:Francis-Xavier-code/dsh-balance-plugin
# 2. Append the plugin line to ~/.dsh/cordis.patch.yml (skip if already present)
- insert:
- id: dsh-balance-plugin
name: 'dsh-balance-plugin'
# 3. Restart DeepSeek Harness
⚙️ Configuration
Click the wallet icon (💰) on the right of the input toolbar to open the "Balance Monitor" panel:
| Setting | Description |
|---|---|
| Account list | Click "+ Add Account" to add; each account can have a name and API Key |
| API Key input | Enter the plaintext Key, or reference an environment variable like $env:DEEPSEEK_API_KEY; leaving an existing Key empty keeps it unchanged |
| Auto-read account | At startup, if the DSH credential DEEPSEEK_API_KEY is detected, an "Auto-read · DSH credential" account is created automatically |
| CNY / USD alert thresholds | Triggers a low-balance alert when the balance of the corresponding currency drops below the threshold (default ¥10 / $2) |
| Refresh interval | 30 seconds ~ 30 minutes (default 5 minutes); "Save Config" triggers an immediate refresh |
🔒 Key security: API Keys are kept only in the plugin process memory on your machine and are never uploaded to any third party; the UI only shows masked values.
🎮 Usage
| Entry | Location | Description |
|---|---|---|
| 💰 Wallet icon | Right of the input toolbar | Opens the balance monitor panel (config / balance / top-up) |
| 📊 Bar-chart icon | Right of the input toolbar | Opens the usage statistics panel |
| 🧩 Four-grid icon | Right of the input toolbar | Opens the third-party plugin manager panel |
| Persistent balance bar | Below the input box | Real-time balance summary, ↻ refresh, top-up link; turns fully red on low balance |
query_api_quota tool | Model calls | Just ask "How much DeepSeek balance is left?" |
All panels are centered overlays: click the backdrop or "✕ Close" to exit.
🗑 Uninstall
# One-click uninstall (removes dependency + cleans the compose patch)
curl -fsSL https://raw.githubusercontent.com/Francis-Xavier-code/dsh-balance-plugin/main/uninstall.sh | bash
Manual equivalent:
dsh plugin --profile web rm dsh-balance-plugin
# and remove the corresponding two lines from ~/.dsh/cordis.patch.yml
Restart DeepSeek Harness after uninstalling.
🏗 Architecture
Host (Node.js process)
├─ Balance query: shell runs curl → api.deepseek.com/user/balance (Bearer auth)
├─ Usage aggregation: real-time session/event listening + 90-day history scan (deduped by seq)
├─ Third-party plugins: clientModules.graph() + clientPath() + open -R to locate
├─ RPC routes: /bmon/api/get-state · refresh · recharge · set-config ·
│ get-usage · list-plugins · open-plugin-dir
└─ Model tool: query_api_quota
Client (browser)
├─ Entry: 3 SVG icon buttons on the right of the input toolbar
├─ Overlays: self-rendered fixed panels inside the component (no overlay slot dependency)
└─ Charts: Miyu chart/heat palettes, dark/light adaptive
❓ FAQ
Q: Will the plugin still be there after a restart?
A: Yes — static plugins are installed persistently and survive restarts. Manually configured account keys reset (the auto-read DEEPSEEK_API_KEY account needs no reconfiguration and restores automatically after restart).
Q: I can't see the entry button at the bottom of the sidebar? A: The DSH sidebar bottom slot is exclusively occupied by the official Cordis panel plugin. This plugin's entry is fixed on the right of the input toolbar and does not depend on that slot.
Q: Will my Key leak? A: No. Keys are kept only in the plugin process memory on your machine and the UI only shows masked values; neither the source code nor the README contains any secrets.
Q: Balance query fails?
A: Check the error hint in the panel: no Key configured (API Key not configured), missing environment variable (Environment variable xxx not set), invalid Key (401 error message), and handle accordingly.
Q: No historical usage data? A: The plugin scans session events from the last 90 days at startup; "avg first token" only counts streaming data captured in real time after the plugin is running.
Q: Why not use dsh plugin add dsh-balance-plugin?
A: A third party owns a same-named package on npm (dsh-balance-plugin@0.1.0), so the bare name would install the wrong one. Use the one-click script or the github: source (see Install).
💬 QQ Community
📄 License
收录徽章
[](https://deepseek-plugin.org/plugins/Francis-Xavier-code/dsh-balance-plugin)把这段 markdown 粘贴到你的 GitHub README,链接回本插件详情页。徽章只声明已被本站收录,不代表安全认证。




