DeepSeek Harness plugin

dsh-balance-plugin-luhaifen

显示当前 DeepSeek API Key 对应账号的账户余额(/balance 命令 + 输入框上方常驻面板,支持轮询 / 对话后 / 手动刷新)

Jump to install

Source facts

Repository
luhaifeng666/dsh-balance-plugin
Latest update
Aug 18, 2026
Category
Models & Providers
GitHub stars
0
Format
plugin
Catalog evidence
Upstream dsh.bundle evidence
Evidence path
package.json#dsh.bundle
Checked against
0.1.0-rc.8
Upstream check date
2026-08-20

This evidence comes from the upstream catalog. This site has not installed, run, or security-reviewed the plugin.

Install

Start with a prompt that asks an agent to review the GitHub repository and source. Switch to the command if you want to install it yourself.

Copy this prompt into DSH, Codex, or another agent and ask it to review the GitHub repository and source first.

Do not install or run any commands yet. Read this plugin's GitHub repository, README, and relevant source code. Then answer the questions below clearly and directly so I can decide whether it fits my needs:

1. What is this plugin, and what problem does it solve?
2. Who is it for, and what are its typical use cases?
3. How is it used after installation? Include one minimal example.
4. What known limitations or privacy, security, compatibility, or maintenance risks does it have?
5. Give a clear recommendation: recommend, conditionally recommend, or do not recommend, with reasons.

Distinguish statements documented by the repository, inferences from source code, and unknowns. If evidence is insufficient, say so explicitly. Do not guess or simply repeat the README.

GitHub: https://github.com/luhaifeng666/dsh-balance-plugin
Plugin: dsh-balance-plugin-luhaifen
Author: luhaifeng666

Check the source files

Read the README and other files from this plugin directory before installing.

File explorer3 files
README.mdSource · read only

dsh-balance-view

一个 DeepSeek Harness(dsh) 插件:查询当前 DeepSeek API Key 对应账号的账户余额,并在输入框上方以常驻面板展示,保持实时更新

面板的余额会在以下时机刷新:

  • 面板出现时:会话中面板首次挂载即查询一次。
  • 每轮对话结束后:一个对话回合(turn)结束时自动刷新——此时扣费已基本结算,余额最贴近真实。
  • 定时轮询:面板可见期间每 5 分钟兜底刷新,避免长时间无对话时余额过期。
  • 手动刷新:面板右侧的 ⟳ 按钮随时手动刷新,刷新中图标会旋转。

× 可手动关闭面板。

效果

账户余额  CNY 34.53(赠送 0.00 / 充值 34.53)  ⟳  ×

安装

# 从 npm 安装(推荐)
dsh plugin --profile web add dsh-balance-view

# 或从 GitHub 安装
dsh plugin --profile web add github:luhaifeng666/dsh-balance-plugin

# 或从本地目录安装
dsh plugin --profile web add ./dsh-balance

> 也可替换成你自己的 profile 名(如 desktop)。安装后重启 dsh 生效。

使用

  • 输入 /balance 回车,会在对话流中显示当前余额(命令结果节点)。
  • 输入框上方的常驻面板会自动查询并实时更新;也可点 ⟳ 手动刷新。

实现

  • host 侧(index.js:注册 /balance 命令,handler 读取凭据服务中的 DEEPSEEK_API_KEY,请求 https://api.deepseek.com/user/balance,把结果作为命令文本返回。不写会话日志、不注册投影
  • client 侧(client.js:向 conversation.input.dock 槽位注入面板,余额由组件本地 state 持有。三种自动刷新(挂载 / 回合结束 / 轮询)与手动刷新都通过 ctx.remote.commands.execute(sessionId, "/balance") 触发 host 查询并读取返回文本。

设计说明:为何不写会话日志

原版把余额经 session.append("balance/change", …) 写入会话日志并驱动投影。但 DSH 的持久化层(session-persistence-jsonl,所有 profile 默认启用)在恢复会话时,会拒绝日志里不在已知事件表中的类型——balance/change 是插件自定义事件、不在该表内且 Session.append 无法标记 ignorable,会导致凡收到过余额刷新的会话重启后无法恢复。加上轮询 / 每轮刷新会高频写入,几乎每个会话都会被污染。

因此本插件改为「命令返回文本 + 面板本地 state」:余额只做一次性查询、不进会话日志,彻底规避该恢复风险。代价是自动刷新会以 /balance 命令节点的形式出现在对话流中(command/run / command/done 为 log-only 事件,不进模型上下文、不影响 KV cache)。

License

MIT