前言¶
DeepSeek Harness(DSH)在進程內互操作上主要走 ACP 與 MCP:前者適合程序化驅動 agent,後者適合掛載外部工具與資源。若要把 DSH 裏的 agent 接到 Google ADK、a2a-python / a2ajava SDK 或各類 A2A 網關,需要標準 Agent2Agent(A2A)協議面,而不是再包一層私有 RPC。
下面介紹社區插件 @zyfgood/dsh-a2a(維護者 zyfgood,分類:工作流)。它在 DSH 側同時提供入站 A2A 服務器與出站 a2a_* 工具,零額外 npm 運行時依賴(Node ≥20 標準庫 + 全局 fetch),與同一作者體系的 dsh-feishu-bot 等插件安裝方式一致。
這是什麼¶
一句話:@zyfgood/dsh-a2a 是 DSH 的 A2A 協議插件——把 DSH agent 暴露爲標準 A2A 服務器,並註冊模型工具讓任意 DSH agent 呼叫遠端 A2A agent。
當前 npm 版本爲 0.2.1(MIT)。社區目錄頁:skillhub.cn/plugins/zyfgood/dsh-a2a;源碼與文檔:github.com/zyfgood/dsh-a2a。SkillHub 爲獨立社區目錄,與 DeepSeek / 幻方無官方從屬關係。
核心功能¶
入站:DSH agent 作爲 A2A 服務器¶
- Agent Card:
/.well-known/agent-card.json(0.3.x)與/.well-known/agent.json(0.2.x 兼容)。 - JSON-RPC 2.0:
message/send(同步)、message/stream(SSE)、tasks/get、tasks/cancel、tasks/resubscribe(斷線續訂)、agent/authenticatedExtendedCard。 - 任務生命週期:
submitted → working → completed/failed/canceled;支持input-required暫停與同一taskId多輪續答。 - 運維相關:版本協商(
A2A-Version/X-A2A-Version)、可選 Bearer 鑑權、CORS、單輪超時、任務 TTL 回收。
出站:agent 調用遠端 A2A¶
默認註冊四個模型工具(配置 tools: false 可關閉):
| 工具 | 協議 | 用途 |
|---|---|---|
a2a_discover |
拉取 Agent Card | 能力 / 技能 / 鑑權 |
a2a_send |
message/stream(可降級 send + 輪詢) |
發消息並等待最終回覆 |
a2a_task_status |
tasks/get |
查詢遠端任務 |
a2a_cancel |
tasks/cancel |
取消遠端任務 |
出站目標由 clientAllowPatterns 白名單約束。
可視化運維(v0.2.0 起)¶
在 DSH Web 客戶端:Plugins → @zyfgood/dsh-a2a 配置卡,以及 Settings → Plugins 分區的 A2A 標籤頁。面板讀取插件自帶的 /admin/status、/admin/tasks(Bearer 與 JSON-RPC 同門禁),展示服務器狀態、最近任務板、常用遠端 Agent Card 目錄等。
安裝與啓用¶
安裝前請自行審閱倉庫源碼與 MIT 許可證;插件隨當前 DSH profile 進程權限運行,公網暴露需配合 bearerToken 與網絡策略。
npm 裸名
dsh-a2a指向無關項目(TtTRz/dsh-a2a),本插件發佈在@zyfgoodscope 下,安裝時必須帶 scope。
# 官方 CLI 一鍵安裝(npm 渠道,推薦;bundle patch 自動掛載)
dsh plugin --profile <name> add @zyfgood/dsh-a2a
# 或 GitHub
dsh plugin --profile <name> add github:zyfgood/dsh-a2a
# 或本地路徑
dsh plugin --profile <name> add file:D:/DSHProjects/dsh-a2a
重啓 profile 後生效。默認監聽 127.0.0.1:7310。倉庫隨包發佈預構建 lib/,無需本地構建。
profile 的 cordis.patch.yml 中典型片段:
- id: a2a
name: '@zyfgood/dsh-a2a'
config:
port: 7310
mode: agent
常用配置項(完整表見 README)包括:host、publicUrl(反代 / TLS 必填外部 URL)、bearerToken、mode(agent / llm / echo)、provider / model、persistSessions、turnTimeoutMs、clientAllowPatterns 等。
典型用法¶
快速驗證 Agent Card 與同步消息¶
先確認服務已啓動,再在本機執行:
# 1) Agent Card(0.3 路徑)
curl http://127.0.0.1:7310/.well-known/agent-card.json
# 2) 發一條消息(同步)
curl -X POST http://127.0.0.1:7310/ -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "message/send",
"params": {
"message": {
"kind": "message",
"role": "user",
"parts": [{"kind": "text", "text": "你好,介紹一下你自己"}],
"messageId": "m-1",
"contextId": "ctx-demo"
}
}
}'
成功時 result 爲 A2A Task:status.state === "completed",回覆文本在 artifacts[0].parts[0].text。同一 contextId 再次調用會複用同一 DSH agent 會話(多輪記憶)。
流式 message/stream¶
curl -N -X POST http://127.0.0.1:7310/ \
-H "Content-Type: application/json" -H "Accept: text/event-stream" -d '{
"jsonrpc": "2.0", "id": 2, "method": "message/stream",
"params": {"message": {"kind": "message", "role": "user",
"parts": [{"kind": "text", "text": "流式演示"}], "messageId": "m-2", "contextId": "ctx-demo"}}
}'
SSE 會依次推送 status-update(working) → artifact-update → status-update(completed, final=true) 後結束。
入站三種模式¶
agent(默認):每個 A2AcontextId對應持久 DSH agent 會話(工具、技能、工作目錄完整);映射可落盤到$DSH_HOME/a2a/,重啓可恢復。llm:經ctx.llm直答,不建 agent 會話,短期記憶由maxHistory控制。echo:回顯原文,用於鏈路驗證。
agent 模式需要可用模型:插件會解析配置的 provider / model,否則回退 profile 默認模型;兩者皆無時任務會明確失敗而非空回覆。
出站對話示例¶
在 DSH agent 對話中可自然表述,例如:用 a2a_send 呼叫 http://其它機器:7310/ 的 agent,詢問其技能並彙總結果。實際可達地址須落在 clientAllowPatterns 內。
與 DSH 內置能力如何選型¶
| 需求 | 建議 |
|---|---|
| 進程外程序化驅動 DSH agent | 內置 ACP(dsh-acp) |
| 掛載外部工具 / 資源 | 內置 MCP 客戶端 |
| 與 A2A 生態(ADK、A2A SDK、網關)互操作 | @zyfgood/dsh-a2a |
結尾¶
若你的 workflow 需要標準 A2A 入站暴露或多 agent 經協議互聯,可在 profile 安裝 @zyfgood/dsh-a2a,用 curl 或 Web 面板驗證後再接外部客戶端。詳情與配置表以 GitHub README 爲準:https://github.com/zyfgood/dsh-a2a;目錄入口:https://www.skillhub.cn/plugins/zyfgood/dsh-a2a。