前言¶
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