dsh-balance-monitor

DSH PLUGIN通知与集成

仓库 Rainronin/dsh-balance-monitor · npm @rainronin/dsh-balance-monitor

通知与集成 L5 · 运行验证通过 安全审查:低风险 可信度:金 可安装插件
安装这个插件

DSH plugin 余额监视器:官方余额快照、会话内查询、峰谷计价区间与 Matrix/原生双风格侧边栏徽章,实时掌握 DeepSeek 账户余额与成本。

一句话选型结论

按资料字段整理

dsh-balance-monitor 是通知与集成类的 DSH 可安装插件,验证等级 L5 · 运行验证通过,安全审查为低风险,列出 5 项功能,有可直接复制的安装命令。验证通过不等于安全:插件会读写文件、执行命令或联网,装前先到仓库确认它做了什么;涉及密钥或系统权限的,建议先在隔离环境试装。

分类通知与集成 收录类型可安装插件 验证等级L5 · 运行验证通过 安全审查低风险
验证等级 L5 L5 · 运行验证通过
GitHub 星标 2 复刻 0 · 未关闭 issue 0
最近更新 2026-08-31 创建于 2026-08-14
README 14.5 KB 正文体量,越大说明说明书写得越细

安装

可安装插件
在 DSH 里执行,装完用 dsh plugin list 确认已挂上;标了 L4 / L5 的命令已在沙盒里真实跑通
dsh plugin --profile web add @rainronin/dsh-balance-monitor@0.3.0
  1. 1
    确认版本与运行环境

    兼容的 DSH 版本为 0.2.0-rc.2 等 10 个;版本不匹配时安装会报错。

  2. 2
    执行安装命令

    在 DSH 里执行上面的命令;多包仓库要注意区分具体子包名,别装错包。

  3. 3
    确认已挂载

    用 dsh plugin list 查看列表里是否出现这个插件,出现即挂载成功。

  4. 4
    试跑并检查权限

    加载后跑一个最小用例,确认它能正常工作;同时看它申请了哪些文件、命令或网络权限。

兼容 DSH 版本0.2.0-rc.2 等 10 个版本版本不匹配时安装会报错
Node.js 要求未标注来自仓库 package.json 的 engines 字段
前置依赖@deepseek-ai/cordis@^4.0.1、@deepseek-ai/cordis-plugin-timer@^1.1.3 等 11 个需要同时安装的同级依赖
npm 包名@rainronin/dsh-balance-monitor可用 npm view 查看包信息

能做什么

5 项功能
字段来自项目仓库与公开索引,中文说明由本站标注

dsh-balance-monitor:DeepSeek Harness 的余额监视器插件

  • 官方余额快照
  • 会话内查询
  • 峰谷计价区间
  • 双风格侧边栏徽章
  • 会话成本估算

适用场景

通知

上游标签

balancedeepseekdeepseek-harnessdshdsh-desktopdsh-pluginplugin

验证等级与安全审查

L5 · 运行验证通过
自动化流程结论,不是人工审核
验证等级L5 · 运行验证通过在 dsh 沙盒中完成安装与运行冒烟——装得上、跑得起来
安全审查低风险静态分析结论,未标注不代表已通过审查
仓库健康度稳定按仓库活跃度与最近更新时间给出
可信度金综合仓库活跃度与验证结果

上面的结论来自上游最近一次自动化验证(2026-10-08): 同一套检查会在插件发新版后重跑,页面显示的是最新一次的逐项结果。

逐项检查结果

L1 · 已找到 ✓ 通过
  • L1.0_DEFAULTED_FROM_L3 由 L3 推定 默认通过——L3 安装规范已通过(全库 L3 扫描策略)
L2 · 结构化 ✓ 通过
  • L2.0_DEFAULTED_FROM_L3 由 L3 推定 默认通过——L3 安装规范已通过(全库 L3 扫描策略)
L3 · 安装规范 ✓ 通过
  • L3.1_INSTALL_COMMAND_PARSED 安装命令已解析 方式:安装规范解析
  • L3.2_DSH_VERSION_DECLARED DSH 版本已声明 方式:DSH 版本声明
L4 · 安装已测 ✓ 通过
  • L4.1_INSTALL_EXECUTED_CONFINED 受限沙盒内执行安装 方式:沙盒安装执行
  • L4.2_INSTALL_SUCCESS 沙盒安装成功 方式:沙盒安装执行
  • L4.3_ARTIFACT_CONFIRMED 安装产物已确认 方式:沙盒安装执行
  • L4.4_RESOLVED_ARTIFACT 安装版本已解析 方式:沙盒安装执行
L5 · 运行已测 ✓ 通过
  • L5.1_INSTALL_PASSED_SANDBOXED 沙盒安装通过 方式:沙盒安装执行
  • L5.2_WEB_BOOT_READY Web 启动就绪 方式:Web 启动
  • L5.3_HTTP_SERVED HTTP 服务响应 方式:HTTP 请求
  • L5.4_PLUGIN_INVENTORY_ACTIVE 插件清单中已激活 方式:插件清单查询

风险详情

  • 审查结论 通过
  • 结论说明 vet 静态分析未发现可疑行为,判定为干净(clean)。
  • 风险计数 严重 0 / 高 0 / 中 0
  • 风险详情 未发现严重或警告级问题。

选择建议

装之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 验证等级 L5:安装和运行都在沙盒里跑通过,装完能直接用的概率高。
  • 静态安全审查为低风险,没有发现明显可疑行为。
  • 有可直接复制的安装命令,不用自己翻文档找入口。
  • 标注了兼容的 DSH 版本(0.2.0-rc.2 等 10 个),按版本装不容易报错。
  • 列出了 5 项功能,能直接看出它解决什么问题。

先想清楚的地方

  • 需要同时装好同级依赖,漏装会启动失败。
  • 没有声明 Node.js 版本要求,版本不匹配可能装不上。
  • 验证通过不等于安全:插件会读写文件、执行命令或联网,装前先到仓库确认它做了什么。

更适合

  • 需要在通知与集成场景里给 DSH 补能力的人。
  • 想装完就能用、不想自己排依赖的人。
  • 能接受在本地装依赖、愿意自己确认权限的人。

不太适合

  • 只使用 DSH 官方内置能力、不接受第三方插件的人。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
插件验证等级安全审查星标兼容版本安装命令
dsh-balance-monitor当前 L5 · 运行验证通过 低风险 2 0.2.0-rc.2 等 10 个 有
treg L3 · 安装规范通过 低风险 4,976 未标注 无
dsh-purge 未做沙盒验证 未标注 3,412 未标注 有
dsh-im L5 · 运行验证通过 低风险 1,837 0.1.7-rc.2 等 10 个 有
dsh-dafeiyu L5 · 运行验证通过 低风险 425 0.1.7-rc.2 等 10 个 有
dsh-trading L3 · 安装规范通过 低风险 235 未标注 无

仓库档案

通知与集成
字段来自项目仓库与公开索引,中文说明由本站标注
作者 / 维护方Rainronin仓库 dsh-balance-monitor · 默认分支 master
分类通知与集成notify
收录类型可安装插件声明了 dsh.bundle、可用 dsh plugin add 安装的条目
开发语言JavaScript仓库主语言
许可证MIT商用或二次分发前请确认条款原文
星标 / 复刻 / issue2 / 0 / 0收录时的数值,非实时
创建 / 更新2026-08-14 · 2026-08-31最后推送 2026-08-31
本站收录2026-08-21首次进入本站目录的时间

README 全文

14.5 KB
作者原文,中文版优先;只做安全转义,不改内容

dsh-balance-monitor

English | 中文

A DeepSeek Harness plugin that monitors your DeepSeek API account balance: official /user/balance snapshots, in-session queries, Beijing-time peak/off-peak pricing status, and a native-style sidebar badge.


English

Features

Capability Description
💬 In-session query ds_balance tool: the agent can fetch the official balance snapshot anytime (force: true bypasses the cache)
🔄 Optional per-turn injection Fresh balance can be injected into the model context before every turn (off by default — the badge + ds_balance tool already cover it; cache-only read, never blocks the conversation)
🖥️ Sidebar badge Native dsh style: 余额 CNY ¥32.81 · 连接正常, 刷新 button for on-demand refresh, 30s auto polling, rail state collapses into a status lamp
🔐 Zero-config key Reuses DEEPSEEK_API_KEY from dsh's credential service (never written to disk, never logged)
💱 Multi-currency CNY/USD both listed (CNY first, $/€/£ rendered per currency); amounts stay strings end-to-end, no float math
⛰️ Peak/off-peak pricing Shows 高峰 HH:MM:SS / 空闲 in the status bar; during peak hours it counts down to the next off-peak period (Beijing time). Before 2026-08-17 the same windows are previewed, with the official billing start shown in the tooltip.
💰 Session cost The sidebar badge also shows the current conversation's estimated cumulative cost (本会话 ¥xx.xx), calculated from official DeepSeek V4 peak/off-peak pricing; it follows the currently selected session automatically
🛡️ Rate-limit friendly 30s TTL cache + request serialization (at most one in-flight request) + 5s timeout

Installation

# Option 1: install from npm (recommended)
# Web profile
dsh plugin --profile web add @rainronin/dsh-balance-monitor
# DSH Desktop profile (or run inside Desktop's own terminal without --profile)
dsh plugin --profile desktop add @rainronin/dsh-balance-monitor

# Option 2: install straight from GitHub
dsh plugin --profile web add github:Rainronin/dsh-balance-monitor
dsh plugin --profile desktop add github:Rainronin/dsh-balance-monitor

# Option 3: clone and link-install locally (instant reload while developing)
git clone https://github.com/Rainronin/dsh-balance-monitor.git
cd dsh-balance-monitor
dsh plugin --profile web add .
dsh plugin --profile desktop add .

# host-side changes require a restart
dsh web

> If pnpm blocks the prepare build script of a git-hosted plugin, add the
> printed key to allowBuilds in $DSH_HOME/profiles//pnpm-workspace.yaml
> and re-run.

The plugin joins dsh.profile.bundles automatically. Inspect the composed tree:

dsh --profile web --dump-config
dsh --profile desktop --dump-config

Usage

In-session query — just ask the agent:

查一下 DeepSeek 余额 / check my DeepSeek balance

Sidebar badge — at the sidebar footer next to Settings: 刷新 force-refreshes
past the cache; polling follows the host-configured interval (30s by default);
the collapsed (rail) state shows a single status lamp (green = 连接正常,
amber = degraded). The badge follows the dsh native theme. When a conversation is
selected, the badge also shows 本会话 ¥xx.xx — the estimated cumulative cost of
that conversation, calculated from official DeepSeek V4 peak/off-peak pricing;
switching conversations switches the cost automatically.

Configuration

Key Default Meaning
apiKeyEnv DEEPSEEK_API_KEY Credential reference (env var name); change for a different account
cacheTtlMs 30000 Cache lifetime in ms
pollIntervalMs 30000 Background polling interval in ms
injectEveryTurn false Whether to inject the balance into context every turn (opt-in; the badge and ds_balance tool are on by default)
requestTimeoutMs 5000 Official-API request timeout in ms

Override in the profile's cordis.patch.yml:

- id: balance-monitor
config:
cacheTtlMs: 10000
pollIntervalMs: 10000

Error semantics

State Behavior
No API key configured Tool returns a Chinese hint; badge shows amber 未配置密钥
API failure + stale cache Last snapshot is returned, marked "snapshot expired Ns (last refresh failed, retrying)"
API failure + no cache The real failure (HTTP status / network / timeout / bad response) is surfaced; badge shows amber 无信号
Invalid or rejected API key Tool returns the real reason; badge shows amber 未配置密钥
Injection-time API failure Silent degradation: nothing injected, conversation unaffected

Peak/off-peak pricing status

The official pricing page defines peak hours as Beijing time 09:00-12:00 and
14:00-18:00
; all other hours are off-peak. The new pricing takes effect at
2026-08-17 00:00 Beijing time. The host computes the current phase and the
badge shows:

Phase Status text
Peak 高峰 02:14:23 — counts down to the off-peak period
Off-peak 空闲
Before 2026-08-17 Same windows are previewed; the tooltip notes 2026-08-17 00:00 as the billing start

Architecture

host half (Node)
BalanceRemoteService (service key `balance`; loader mounts the default-exported class)
├─ credential lookup → GET https://api.deepseek.com/user/balance → 30s TTL cache + serialization
├─ ds_balance tool + optional agent/pre-step injection + configurable polling
├─ peak/off-peak pricing state computed on Beijing time (09:00-12:00, 14:00-18:00 peak)
├─ balance/sessionCost: scans the selected session's event log and estimates cumulative
│   cost using official DeepSeek V4 peak/off-peak prices
└─ typert/typert-host.js: hand-written TYPERT strict manifest (exported as ./typert,
registered by typert-loader; api-gateway claims /api/balance/* via the strict definition)

browser half (client.tsx → lib/client.js, wrapped in the official __ModuleLoader__ shell)
├─ sidebar.footer.action slot: native-style badge (wide/rail states)
└─ data channel: direct calls over the official RPC protocol (POST /api/balance/,
client-request envelope), host-configured polling + `刷新` force refresh + phase-transition refresh

The third-party Typert Remote client path ($mount contribution → namespace
service) failed silently in practice, so the badge talks the official RPC wire
protocol directly (dsh-host-apiproxy fetch-carrier envelope), while the host
side keeps the official TYPERT strict registration.

Development

npm install            # toolchain (typescript/pnpm + type deps)
npm run build          # clean + tsc (host ESM/client CJS) + wrap-client + RPC/typert self-checks
node scripts/diagnose.mjs # local cordis integration diagnosis (mock services)
dsh plugin --profile web add .   # link install

Build notes: npm run build cleans lib/ first, compiles the host half as ESM
and the browser half as CommonJS, wraps the client with scripts/wrap-client.mjs into
the official window.__ModuleLoader__.load shell (same shape as official
dsh-client-ui-* artifacts, served by dsh-client-modules as
/plugins//client.js), then runs scripts/verify-client.mjs (bundle registration,
slot mounting, RPC envelope and rpcId echo) and scripts/verify-typert.mjs (strict
codec positive/negative cases).


中文

DeepSeek Harness 插件:DeepSeek API 账户余额监测——官方 /user/balance 接口快照 + 会话内查询 + 北京时间峰谷计价状态 + dsh 原生风格侧边栏徽章。

功能

能力 说明
💬 会话内查询 ds_balance 工具:agent 随时可查官方余额快照(force: true 穿透缓存)
🔄 每轮注入(可选) 默认关闭。开启后每轮对话前自动把最新余额放进模型上下文(只读缓存,绝不阻塞对话)——徽章与工具已默认覆盖该信息
🖥️ 侧边栏徽章 dsh 原生风格:余额 CNY ¥32.81 · 连接正常,刷新 按钮手动穿透刷新,30s 自动轮询,折叠态退化为状态灯
🔐 零配置密钥 复用 dsh 凭证服务里的 DEEPSEEK_API_KEY(不落盘、不打印、不缓存)
💱 多币种 CNY/USD 全列(CNY 优先,USD/EUR/GBP 显示对应货币符号),金额全程字符串透传,无浮点运算
⛰️ 峰谷计价状态 状态栏显示 高峰 HH:MM:SS / 空闲;高峰期实时倒计时到空闲阶段(北京时间)。2026-08-17 前按同一窗口预览,tooltip 标注正式计费生效时间
💰 单会话费用 侧边栏徽章额外显示当前会话累计估算费用(本会话 ¥xx.xx),按 DeepSeek 官方 V4 峰谷价格计算,切换会话时自动跟随当前会话
🛡️ 限流友好 30s TTL 缓存 + 请求串行化(同一时刻最多一个在途请求)+ 5s 超时

安装

# 方式一:npm 直装(推荐)
# Web profile
dsh plugin --profile web add @rainronin/dsh-balance-monitor
# DSH Desktop profile(或在 Desktop 专用终端里直接 dsh plugin add,无需 --profile)
dsh plugin --profile desktop add @rainronin/dsh-balance-monitor

# 方式二:GitHub 直装
dsh plugin --profile web add github:Rainronin/dsh-balance-monitor
dsh plugin --profile desktop add github:Rainronin/dsh-balance-monitor

# 方式三:本地 clone 后 link 安装(改代码即时生效,适合二次开发)
git clone https://github.com/Rainronin/dsh-balance-monitor.git
cd dsh-balance-monitor
dsh plugin --profile web add .
dsh plugin --profile desktop add .

# host 半改动后重启生效
dsh web

> git 托管插件若被 pnpm 拦截 prepare 构建脚本,按提示把键加进
> $DSH_HOME/profiles//pnpm-workspace.yaml 的 allowBuilds 再重跑。

安装后插件自动进入 dsh.profile.bundles 层列表;检查配置树:

dsh --profile web --dump-config
dsh --profile desktop --dump-config

使用

会话内查询——直接让 agent 查:

帮我查一下 DeepSeek 余额

侧边栏徽章——侧边栏底部(Settings 旁):刷新 按钮穿透缓存立即刷新;
轮询间隔跟随 host 配置(默认 30s);折叠态(rail)显示单色状态灯(绿 = 连接正常,
琥珀 = 异常)。徽章跟随 dsh 原生主题。选中某个会话时,徽章还会显示 本会话 ¥xx.xx——
按 DeepSeek 官方 V4 峰谷价格估算的当前会话累计费用;切换会话时会自动跟随当前会话。

配置

键 默认值 说明
apiKeyEnv DEEPSEEK_API_KEY 凭证引用名(环境变量名),多账号时改这里
cacheTtlMs 30000 缓存有效期(毫秒)
pollIntervalMs 30000 后台轮询间隔(毫秒)
injectEveryTurn false 是否每轮注入余额到模型上下文(默认关闭,按需开启)
requestTimeoutMs 5000 官方接口请求超时(毫秒)

覆盖示例(profile 的 cordis.patch.yml):

- id: balance-monitor
config:
cacheTtlMs: 10000
pollIntervalMs: 10000

错误语义

状态 表现
未配置 key 工具返回中文提示;徽章显示琥珀 未配置密钥
接口失败 + 有旧缓存 返回最后一次快照并标注"快照已过期 Ns(最近一次刷新失败,自动重试中)"
接口失败 + 无缓存 返回真实失败原因(HTTP 状态码 / 网络 / 超时 / 响应格式);徽章显示琥珀 无信号
key 无效或未授权 返回真实原因;徽章显示琥珀 未配置密钥
每轮注入时接口失败 静默降级:不注入、不打断对话

峰谷计价状态

官方价格页定义高峰时段为北京时间 09:00-12:00、14:00-18:00,其余为空闲;
新计价于 2026-08-17 00:00 北京时间生效。host 计算当前阶段,徽章显示:

阶段 状态栏
高峰 高峰 02:14:23——倒计时到进入空闲阶段
空闲 空闲
2026-08-17 前 按同一窗口预览;tooltip 标注 2026-08-17 00:00 为正式计费起点

架构

host 半(Node)
BalanceRemoteService(服务键 balance,loader 行直接挂载 default 导出类)
├─ 凭证解析 → GET https://api.deepseek.com/user/balance → 30s TTL 缓存 + 串行化
├─ ds_balance 工具 + 可配置轮询(每轮注入为可选项,默认关闭)
├─ 峰谷计价状态:按北京时间 09:00-12:00、14:00-18:00 计算高峰
├─ balance/sessionCost:扫描所选会话事件日志,按官方 DeepSeek V4 峰谷价格估算累计费用
└─ typert/typert-host.js:手写 TYPERT strict 元数据(./typert 导出,typert-loader 注册,
api-gateway 按 strict 定义认领 /api/balance/* 端点)

browser 半(client.tsx → lib/client.js,__ModuleLoader__ 注册壳)
├─ sidebar.footer.action slot:dsh 原生风格徽章(wide/rail 双态)
└─ 数据通道:官方 RPC 公开协议直调(POST /api/balance/,
client-request 信封),host 配置轮询 + `刷新` 穿透刷新 + 阶段切换即时刷新

第三方 Typert Remote 客户端链路($mount 贡献 → 命名空间服务)在本机环境实测
静默失效,故徽章改用官方 RPC 公开协议直调(dsh-host-apiproxy fetch carrier 信封),
host 端严格保留官方 TYPERT strict 注册路径。

开发

npm install            # 装工具链(typescript/pnpm,含类型依赖)
npm run build          # clean + tsc(host ESM/client CJS)+ wrap-client 包壳 + RPC/typert 自检
node scripts/diagnose.mjs # 本地 cordis 集成诊断(mock 服务验证工具注册与服务可见性)
dsh plugin --profile web add .   # link 安装

构建说明:npm run build 先清空 lib/,host 半编译为 ESM、browser 半编译为
CommonJS,再经 scripts/wrap-client.mjs 包进官方 window.__ModuleLoader__.load 注册壳
(与官方 dsh-client-ui-* 产物同构,由 dsh-client-modules 服务为
/plugins//client.js);随后 scripts/verify-client.mjs 验证 bundle 注册、slot
挂载、RPC 信封与 rpcId 回显,scripts/verify-typert.mjs 验证 strict codec 正反例。

常见问题

9 问
答案由本站依据条目字段整理,不引用上游原文
dsh-balance-monitor 怎么安装?

在 DSH 里执行 `dsh plugin --profile web add @rainronin/dsh-balance-monitor@0.3.0` 即可。对应的 npm 包名是 `@rainronin/dsh-balance-monitor`。

dsh-balance-monitor 的验证等级是什么意思?

L5 · 运行验证通过。在 dsh 沙盒中完成安装与运行冒烟——装得上、跑得起来

dsh-balance-monitor 安全吗?

低风险。vet 静态分析未发现可疑行为,判定为干净(clean)。

dsh-balance-monitor 装之前要先确认什么?

先看它会读写哪些文件、执行哪些命令、连接哪些网络地址;验证等级只说明装得上、跑得起来,不等于安全。涉及密钥或系统权限的,建议先在隔离环境试装。

dsh-balance-monitor 支持哪些 DSH 版本?

上游记录的兼容版本包括 0.2.0-rc.2、0.1.7-rc.2、0.1.7-rc.1、0.1.6-alpha.2、0.1.6-alpha.1、0.1.5-rc.2、0.1.3-alpha.2、0.1.3-alpha.1。版本较多,只列出前 8 个。

dsh-balance-monitor 需要什么运行环境?

需要同时安装 @deepseek-ai/cordis@^4.0.1、@deepseek-ai/cordis-plugin-timer@^1.1.3、@deepseek-ai/dsh-client-ui-sidebar@^0.1.2-alpha.1、@deepseek-ai/dsh-client-ui-slots@^0.1.2-alpha.1、@deepseek-ai/dsh-credentials@^0.1.2-alpha.1。环境不满足时安装会失败,建议先确认本机版本。

dsh-balance-monitor 用的是什么许可证?

上游标注为 MIT。商用或二次分发前请到仓库确认许可证原文。

dsh-balance-monitor 有哪些功能?

官方余额快照、会话内查询、峰谷计价区间、双风格侧边栏徽章、会话成本估算。

这条记录的数据可靠吗?

本站按仓库名去重后合并整理,字段以作者仓库与 npm 元数据为准;安装命令、仓库地址与 README 保持原文,带 L4 / L5 标记的安装命令已在隔离沙盒里真实跑通。

同名或近似条目

4 条
不同作者的仓库分开列,请确认你要装的是哪一个
通知与集成
按星标排序,可作替代方案

treg

treg

Treg 是面向 Agent 工具的 OpenRouter,聚合 60 个提供商的 2896 个端点,按调用计费,统一令牌访问,无需注册各供

L3 · 安装规范通过 4,976 星

dsh-purge

dsh-purge

dsh-purge Community · DeepSeek Harness 社区维护版:宿主兼容、状态诊断、提示词管理、更新与本机备份回滚

未标注验证等级 3,412 星

dsh-im

dsh-im

将IM机器人接入DeepSeek Harness,支持飞书、微信、钉钉等九种渠道,通过扫码或凭据配置,统一管理多机器人连接。

L5 · 运行验证通过 1,837 星

dsh-dafeiyu

dsh-dafeiyu

DSH 大肥鱼是一款由 DeepSeek Harness 真实工作状态驱动的桌面伴侣插件,以始终置顶的透明窗口实时展示 Agent 的思考、

L5 · 运行验证通过 425 星

dsh-trading

dsh-trading

L3 · 安装规范通过 235 星

插件的元信息来自作者仓库;分类、验证等级与安全结论的中文说明为中文整理,最近核验 2026-10-08。