前言¶
DeepSeek Harness(DSH)的扩展能力通常以插件形式接入。dsh-monitor 面向其中一类具体需求:外部消息、通知或日志在 agent 空闲期间到达时,让 agent 能被及时唤醒。
如果希望在 DSH 中实现类似 Claude Code Monitor 的能力,dsh-monitor 提供了一个插件化路径:为消息源建立持续后台 watcher,在新内容到达时唤醒 owning agent。
这是什么¶
dsh-monitor 是 AbnerAI 维护的 DeepSeek Harness 插件,许可证为 MIT。
它把“监视消息源并唤醒 agent”做成 DSH 插件能力。插件提供 monitor、monitor_list 和 monitor_stop 三个工具,用于创建、查看和停止 watcher。
支持两类消息源:
source: file:监视一个 append-only NDJSON inbox;source: command:按间隔重跑 shell command,并投递输出差量。
核心功能¶
持续监视消息源¶
插件可以在消息源上建立 persistent, background watchers。
watcher 在会话内持续有效,可以在需要时手动停止,也会在插件卸载时自动清理。
新内容到达时唤醒 agent¶
当有新内容到达时,插件会唤醒 owning agent。
根据 agent 当前状态,唤醒方式不同:
- idle agent 使用
agent.followup(); - busy agent 使用
agent.inject()。
这意味着新消息不只是被记录,而是进入当前会话并触发 agent 后续处理。
支持 NDJSON inbox¶
使用 source: file 时,插件监视一个 append-only NDJSON inbox。
写入新的一行后,插件会把新内容交给 agent,用于触发后续处理。
支持命令输出差量¶
使用 source: command 时,插件按 poll_interval_ms 间隔重跑 shell command,并投递自上次运行以来的输出差量。
安装与启用¶
先确认运行环境满足要求:需要 DeepSeek Harness(dsh),并且具备 Cordis-based plugin loader,支持 bundles / cordis.patch.yml。
插件的 peer dependencies 包括:
dsh-agent
dsh-llm
dsh-tools
cordis
这些依赖由 harness runtime 满足。
从 npm 安装时,可以执行:
npx @deepseek-ai/dsh@latest plugin --profile web add dsh-monitor
如果从 git 地址安装,可以执行:
npx @deepseek-ai/dsh@latest plugin --profile web add https://github.com/AbnerAI/dsh-monitor
如果从本地目录安装,先在该包目录内执行:
pnpm install
再执行:
npx @deepseek-ai/dsh@latest plugin --profile web add /path/to/dsh-monitor
本地目录安装方式适用于已经在本机准备 dsh-monitor 包的情况。前面的 pnpm install 用于先解决包自身依赖。
典型用法¶
监视 NDJSON inbox¶
告诉 agent 对一个 inbox 文件建立 watcher:
monitor(source="file",
path="/absolute/path/to/inbox.ndjson",
name="my-inbox",
poll_interval_ms=1000)
这里 source 指定为 file。path 必须是绝对路径,或以 ~ 开头。poll_interval_ms 默认是 2000。
工具会返回一个 watcher id,例如 monitor-1。之后每有新行写入该文件,插件都会唤醒 agent。
NDJSON 示例行:
{"content":"hello","ts":1712345678}
查看和停止 watcher¶
查看当前已建立的 watcher:
monitor_list
按 id 停止一个 watcher:
monitor_stop(id="monitor-1")
监视命令输出¶
如果目标不是文件,而是命令每次重跑后变化的输出,可以使用:
monitor(source="command", command="tail -n 5 /var/log/app.log", poll_interval_ms=5000)
这里 source 指定为 command,插件按 5000ms 间隔重跑命令,并投递输出差量。
适用场景与注意¶
dsh-monitor 适合需要让 DSH agent 对外部入站消息保持响应的场景,例如:
- 消息或通知 broker 向 append-only NDJSON 文件写入记录;
- 日志文件持续增长,需要按间隔检查命令输出变化;
- agent 在等待外部输入时,希望新消息能直接唤醒它。
使用前需要特别注意:插件运行在当前 dsh 进程权限内,安装前应检查源码、依赖和许可证。
已核实信息中的许可证为 MIT。path 参数必须可解析为绝对路径;poll_interval_ms 决定轮询频率,默认值是 2000。
结尾¶
dsh-monitor 的价值,是把“持续监视消息源”变成 DSH 会话中可建立、可查看、可停止的能力,并在新消息到达时唤醒 agent。
插件目录页:https://www.skillhub.cn/plugins/AbnerAI/dsh-monitor
GitHub:https://github.com/AbnerAI/dsh-monitor