前言¶
在 DSH(DeepSeek Harness)裏跑智能體時,外部系統——CI、Issue 跟蹤、監控告警——往往希望「推一條 HTTP 請求就能觸發一次會話」,而不是爲每個服務單獨寫橋接代碼。常見做法是自建小服務轉發到本地 API,或手工複製粘貼 payload,運維和權限邊界都容易變複雜。
下面介紹社區插件 dsh-webhook-dispatcher(維護者 xuan25,分類:聯網工具):它在 profile 的 webServer 上註冊精確路由,外部調用到達端點後,由插件Admission 並 spawn 一次全新的、隔離的 agent 會話 處理投遞內容。目錄頁:skillhub.cn/plugins/xuan25/dsh-webhook-dispatcher;源碼與說明:github.com/xuan25/dsh-webhook-dispatcher。SkillHub 爲獨立社區目錄,與 DeepSeek / 幻方無官方從屬關係。
這是什麼¶
dsh-webhook-dispatcher 是 DSH 的 out-of-tree 插件(package 版本 0.1.0,許可證 MIT)。一句話定位:爲 dsh 部署提供 inbound webhook dispatch——HTTP 調用方命中插件配置的 endpoint 後,由框架拉起新的 agent session 處理 body 中的內容;CI、Issue 系統、監控工具等可直接驅動 DSH 會話,無需按服務寫專用橋接。
Endpoint 掛在 profile webServer 服務的 精確路徑 上(web profile 由 Web GUI 提供;其他 profile 需自行 compose @deepseek-ai/dsh-host-webserver,見後文)。對外是否可達由操作者的反向代理決定。
核心功能¶
端點與准入¶
每個 endpoint 可單獨配置:id / path / name、token 鑑權(通過環境變量名引用 token 值)、policy 文本、工作目錄 cwd、sandbox、model、reasoning effort、以及 maxConcurrent / maxQueue / maxBodyBytes 等資源與隊列限制。
每次被接納的投遞都會 spawn 新的 agent session;超過併發或隊列容量時返回 429,並帶 Retry-After 做背壓。
配置方式¶
插件 不創建配置文件;endpoint 通過兩條等價通道聲明,字段合併到同一契約,優先級爲:cordis config layer > 環境變量 > 內置默認。
- cordis:在 profile 的
cordis.patch.yml中 targeting 插件 iddsh-webhook-dispatcher(熱更新:patch 變更會重建插件條目並重讀兩路配置)。 - 環境變量:
WEBHOOK_<ENDPOINT_ID>_<FIELD>形式(id 轉大寫、連字符變下劃線,例如ci-run→WEBHOOK_CI_RUN_*)。
缺少 PATH、越界值、或聲明瞭 AUTH 但對應 token 環境變量未設置時,插件在 啓動階段 fail-closed 失敗;未知 config key 會被拒絕(防拼寫錯誤);path 不得與框架自有路由衝突。
觀測:webhook status¶
Agent 側可用工具 webhook { verb: "status" } 查看 live 路由、隊列深度、近期投遞歷史,以及生效的(非密鑰)endpoint 配置。完整參考見插件 bundled 的 dsh-webhook-dispatcher skill。
Session offload¶
Webhook 觸發會在框架 session store 留下磁盤日誌;高頻 endpoint 下 store 可能無限增長。插件按 每分鐘 掃描:對已 settled、且超過該 endpoint sessionRetention 窗口的 trigger session 做歸檔,使 store 有界(只移動、不刪 store;仍在運行的 session 等到 settled 再處理)。offload 相關狀態位於 $DSH_HOME/dsh-webhook-dispatcher/(含 retention-log.jsonl、archived-sessions/ 等)。可選 env WEBHOOK_OFFLOAD_BATCH(默認 50)限制單次 sweep 處理量。
安裝與啓用¶
在目標 profile 上安裝(命令來自官方 README):
dsh plugin --profile <name> add dsh-webhook-dispatcher
安裝後通過 WEBHOOK_* 環境塊 和/或 cordis config layer 配置 endpoints。
非 web profile:掛載 webServer¶
Endpoint 註冊在 profile 的 webServer 上。web profile 自帶 Web GUI 的 webServer;sdk、acp 或自定義 bundle 需在 composition 中插入 webServer 提供方。headless 等一次性 surface 無法常駐監聽,不能託管本插件。
示例(摘自 README,$DSH_HOME/profiles/<name>/cordis.patch.yml):
- insert:
- id: webserver
name: '@deepseek-ai/dsh-host-webserver'
config:
host: <host>
port: <port> # 空閒固定端口;port 0 會在每次重啓時重新解析綁定地址
典型用法:配置一個 endpoint¶
方式一:cordis config layer¶
- id: dsh-webhook-dispatcher
config:
endpoints:
- id: <name>
path: /<path>
policy: "Treat the content as a task description and act on it."
# name: <name> (default: the id)
# cwd: /abs/path (default: $DSH_HOME/dsh-webhook-dispatcher)
# auth: <TOKEN_ENV> (env var NAME holding the token value; empty = open endpoint)
# sandbox: workspace-write (read-only | workspace-write | danger-full-access)
# model: some/model (default: the default selection ladder)
# reasoningEffort: low (closed set off|minimal|low|medium|high|xhigh|max)
# maxConcurrent: 1 (default)
# maxQueue: 100 (default)
# maxBodyBytes: 262144 (default)
# sessionRetention: 24h (absent/0 = retain in the store)
方式二:環境變量¶
與上表字段對應,例如:
WEBHOOK_<NAME>_PATH=/<path>
WEBHOOK_<NAME>_POLICY="Treat the content as a task description and act on it."
WEBHOOK_<NAME>_AUTH=<TOKEN_ENV> # 存放 token 值的環境變量「名稱」
WEBHOOK_<NAME>_MODEL=some/model
WEBHOOK_<NAME>_REASONING_EFFORT=low
<TOKEN_ENV>=...
常用字段默認值(資料原文):cwd 默認 $DSH_HOME/dsh-webhook-dispatcher;maxConcurrent 默認 1;maxQueue 默認 100;maxBodyBytes 默認 262144;auth 爲空則 endpoint 開放;policy 爲空則走 free-policy fallback。
外部系統對 https://<你的反向代理>/<path> 發起 HTTP 請求(需滿足插件的 method gate、鑑權與 body 預算);成功後即進入隊列並由新 session 按 policy 處理 payload。
運行中可在會話裏調用 webhook { verb: "status" } 覈對路由與隊列,而不必猜配置是否生效。
適用場景與注意¶
適合誰:已有 HTTP 出站能力的系統(CI、GitHub/GitLab webhook、監控、工單),希望 一條 webhook 對應一次 DSH 任務,且需要 per-endpoint 的模型、沙箱、併發與隊列策略。
務必注意:
- 插件以 當前 dsh 進程權限 運行;安裝前請閱讀 GitHub 源碼 與 MIT 許可證,自行評估 token、開放 endpoint 與 sandbox 組合的風險。
- 對外暴露 endpoint 前應配置 auth(
AUTH指向已設置的環境變量名)並限制 body 大小;開放 endpoint 僅適合受控網絡。 - 高頻 webhook 建議設置
sessionRetention並關注 offload 相關日誌;無效 retention 會 warn 並按 0(不歸檔)處理,不會導致啓動失敗。 - 需要常駐 HTTP 路由的 profile 必須提供 webServer;僅 headless 的一次性部署無法使用本插件。
結尾¶
dsh-webhook-dispatcher 把「外部 HTTP 事件 → 隔離 agent 會話」收成可聲明的 endpoint 與統一背壓,減少 per-service 橋接代碼。安裝命令爲 dsh plugin --profile <name> add dsh-webhook-dispatcher;配置與行爲以 README 爲準。
- 目錄頁:https://www.skillhub.cn/plugins/xuan25/dsh-webhook-dispatcher
- GitHub:https://github.com/xuan25/dsh-webhook-dispatcher