← 返回列表
未验证
DeepSeek Harness 插件:DeepSeek API 余额实时监测官方 /user/balance 快照…
尚未跑自动兼容性验证,可查看页面内的依赖与入口分析。 · 最近上游提交 2026/8/31 · 已提供中文文档
DeepSeek Harness 插件:DeepSeek API 余额实时监测(官方 /user/balance 快照 + ds_balance 工具 + 峰谷计价状态 + 单会话费用估算 + dsh 原生风格侧边栏徽章)
综合分
29.7
GitHub 分
29.7
用户评分
—
★ Stars
2
周下载量
—
安装插件(需先安装 dsh CLI 引擎:npm install -g @deepseek-ai/dsh)
dsh plugin --profile web add Rainronin/dsh-balance-monitor该插件未发布到 npm,走 GitHub 源安装(pnpm 若拦截 prepare 脚本,按其提示在 pnpm-workspace.yaml 的 allowBuilds 中放行后重跑)
数据截至 2026/9/18(元数据每日更新 · 实装验证按队列轮转,单条结论的验证时间见上方)
依赖的 DSH / Cordis 模块
@deepseek-ai/cordis-plugin-timer@deepseek-ai/dsh-client-store@deepseek-ai/cordis@deepseek-ai/schemastery@deepseek-ai/dsh-credentials@deepseek-ai/dsh-session@deepseek-ai/dsh-tools@deepseek-ai/dsh-llm@deepseek-ai/dsh-typert-protocol@deepseek-ai/dsh-client-ui-slots@deepseek-ai/dsh-client-ui-sidebar用户评分
还没有人投票,来当第一个
订阅周报,不错过优质插件更新
每周一封 · 高评分插件 + 新用户活动
README
dsh-balance-monitor 一个 DeepSeek Harness 插件,用于监控你的 DeepSeek API 账户余额:官方 /user/balance 快照、会话内查询、北京时间高峰/低谷定价状态,以及原生风格的侧边栏徽章。 dsh 原生风格 English 功能特性 | 能力 | 说明 | |---|---| | 💬 会话内查询 | ds_balance 工具:智能体可随时获取官方余额快照(force: true 可绕过缓存) | | 🔄 可选的每轮注入 | 每轮对话前可将最新余额注入模型上下文(默认关闭——徽章 + ds_balance 工具已足够覆盖;仅读缓存,绝不阻塞对话) | | 🖥️ 侧边栏徽章 | 原生 dsh 风格:余额 CNY ¥32.81 · 连接正常,刷新 按钮支持按需刷新,30 秒自动轮询,收起状态折叠为状态指示灯 | | 🔐 零配置密钥 | 复用 dsh 凭据服务中的 DEEPSEEK_API_KEY(绝不写入磁盘,绝不记录日志) | | 💱 多币种 | 同时列出 CNY/USD(CNY 在前,按币种渲染 $/€/£);金额全程以字符串处理,不做浮点运算 | | ⛰️ 高峰/低谷定价 | 在状态栏显示 高峰 HH:MM:SS / 空闲;高峰时段内倒计时至下一个低谷时段(北京时间)。2026-08-17 之前为相同时间窗口的预览,工具提示中显示官方计费起始时间。 | | 💰 会话费用 | 侧边栏徽章还会显示当前对话的预估累计费用(本会话 ¥xx.xx),依据官方 DeepSeek V4 高峰/低谷定价计算;自动跟随当前选中的会话 | | 🛡️ 限流友好 | 30 秒 TTL 缓存 + 请求串行化(最多一个进行中的请求)+ 5 秒超时 | 安装 方式一:从 npm 安装(推荐) Web 配置 dsh plugin --profile web add @rainronin/dsh-balance-monitor DSH Desktop 配置(或在 Desktop 自带终端中运行,无需 --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 方式三:本地克隆并链接安装(开发时可即时重载) git clone https://github.com/Rainronin/dsh-balance-monitor.git cd dsh-balance-monitor dsh plugin --profile web add . dsh plugin --profile desktop add . 宿主侧变更需要重启 dsh web 如果 pnpm 阻止了 git 托管插件的 prepare 构建脚本,请将 打印出的键添加到 $DSH_HOME/profiles//pnpm-workspace.yaml 中的 allowBuilds,然后重新运行。 该插件会自动加入 dsh.profile.bundles。检查组合后的树: dsh --profile web --dump-config dsh --profile desktop --dump-config 使用方法 会话内查询 —— 直接询问智能体: 查一下 DeepSeek 余额 / check my DeepSeek balance 侧边栏徽章 — 位于侧边栏页脚、设置旁边:刷新 会强制刷新并绕过缓存;轮询遵循宿主配置的间隔(默认 30 秒);折叠(轨道)状态显示单个状态灯(绿色 = 连接正常,琥珀色 = 降级)。徽章遵循 dsh 原生主题。当选中某个会话时,徽章还会显示 本会话 ¥xx.xx —— 该会话的预估累计费用,根据 DeepSeek V4 官方高峰/低谷定价计算;切换会话会自动切换费用。 配置 | 键 | 默认值 | 含义 | |---|---|---| | apiKeyEnv | DEEPSEEK_API_KEY | 凭据引用(环境变量名);更换为其他账户时修改 | | cacheTtlMs | 30000 | 缓存生存时间(毫秒) | | pollIntervalMs | 30000 | 后台轮询间隔(毫秒) | | injectEveryTurn | false | 是否每轮都将余额注入上下文(需主动启用;徽章和 ds_balance 工具默认开启) | | requestTimeoutMs | 5000 | 官方 API 请求超时(毫秒) | 在配置文件的 cordis.patch.yml 中覆盖: - id: balance-monitor config: cacheTtlMs: 10000 pollIntervalMs: 10000 错误语义 | 状态 | 行为 | |---|---| | 未配置 API 密钥 | 工具返回中文提示;徽章显示琥珀色 未配置密钥 | | API 失败 + 存在过期缓存 | 返回最后一次快照,并标记“快照已过期 N 秒(上次刷新失败,正在重试)” | | API 失败 + 无缓存 | 暴露真实失败原因(HTTP 状态 / 网络 / 超时 / 响应异常);徽章显示琥珀色 无信号 | | API 密钥无效或被拒绝 | 工具返回真实原因;徽章显示琥珀色 未配置密钥 | | 注入时 API 失败 | 静默降级:不注入任何内容,会话不受影响 | 高峰/低谷定价状态 官方定价页面将高峰时段定义为 北京时间 09:00-12:00 和 14:00-18:00;其他所有时段均为低谷。新定价于 北京时间 2026-08-17 00:00 生效。宿主计算当前阶段,徽章显示: | 阶段 | 状态文本 | |---|---| | 高峰 | 高峰 02:14:23 —— 倒计时至低谷时段 | | 低谷 | 空闲 | | 2026-08-17 之前 | 预览相同时间窗口;工具提示注明 2026-08-17 00:00 为计费开始时间 | 架构 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) 浏览器半部分(client.tsx → lib/client.js,包裹在官方 __ModuleLoader__ 外壳中) ├─ sidebar.footer.action 插槽:原生风格徽章(宽/窄状态) └─ 数据通道:通过官方 RPC 协议直接调用(POST /api/balance/, client-request 信封),宿主配置的轮询 + 刷新 强制刷新 + 阶段转换刷新 第三方 Typert Remote 客户端路径($mount 贡献 → 命名空间 服务)在实践中静默失败,因此徽章直接使用官方 RPC 线路 协议(dsh-host-apiproxy fetch-carrier 信封),而宿主 侧保留官方 TYPERT 严格注册。 开发 sh npm install # 工具链(typescript/pnpm + 类型依赖) npm run build # 清理 + tsc(宿主 ESM/客户端 CJS)+ wrap-client + RPC/typert 自检 node scripts/diagnose.mjs # 本地 cordis 集成诊断(模拟服务) dsh plugin --profile web add . # link 安装 构建说明:npm run build 首先清理 lib/,将宿主半部分编译为 ESM, 将浏览器半部分编译为 CommonJS,用 scripts/wrap-client.mjs 将客户端包裹进 官方 window.__ModuleLoader__.load 外壳(与官方 dsh-client-ui-* 产物形状相同,由 dsh-client-modules 作为 /plugins//client.js 提供),然后运行 scripts/verify-client.mjs(bundle 注册、 插槽挂载、RPC 信封和 rpcId 回显)和 scripts/verify-typert.mjs(严格 编解码器正/反用例)。 中文 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 超时 | 安装 sh 方式一: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 层列表;检查配置树: sh 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): yaml - 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 注册路径。 开发 sh 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 正反例。
扫码进群