@1agents/acp-service 0.5.4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +180 -9
  2. package/dist/bin/a2a.d.ts +1 -0
  3. package/dist/bin/a2a.js +52 -0
  4. package/dist/bin/acp-service.js +20 -2
  5. package/dist/src/a2a/automation.d.ts +99 -0
  6. package/dist/src/a2a/automation.js +372 -0
  7. package/dist/src/a2a/executor.d.ts +29 -0
  8. package/dist/src/a2a/executor.js +144 -0
  9. package/dist/src/a2a/gateway.d.ts +151 -0
  10. package/dist/src/a2a/gateway.js +454 -0
  11. package/dist/src/a2a/index.d.ts +9 -0
  12. package/dist/src/a2a/index.js +5 -0
  13. package/dist/src/a2a/server.d.ts +22 -0
  14. package/dist/src/a2a/server.js +339 -0
  15. package/dist/src/a2a/store.d.ts +34 -0
  16. package/dist/src/a2a/store.js +468 -0
  17. package/dist/src/a2a/types.d.ts +26 -0
  18. package/dist/src/a2a/types.js +1 -0
  19. package/dist/src/acp-connection.js +3 -2
  20. package/dist/src/bridge.js +18 -3
  21. package/package.json +15 -8
  22. package/skills/acp-service/SKILL.md +90 -0
  23. package/skills/acp-service/agents/openai.yaml +3 -0
  24. package/skills/acp-service/references/a2a.md +183 -0
  25. package/skills/acp-service/references/acp.md +104 -0
  26. package/skills/acp-service/references/dsh.md +61 -0
  27. package/vendor/dsh/README.md +34 -10
  28. package/vendor/dsh/a2a-executor.d.ts +26 -0
  29. package/vendor/dsh/a2a-executor.js +195 -0
  30. package/vendor/dsh/a2a.d.ts +15 -0
  31. package/vendor/dsh/a2a.js +32 -0
  32. package/vendor/dsh/adapter.js +33 -10
  33. package/vendor/dsh/index.d.ts +5 -1
  34. package/vendor/dsh/index.js +3 -0
  35. package/vendor/runtime/dist/docs-site/output-formats.html +4 -1
  36. package/vendor/runtime/dist/runtime.d.ts +8 -0
  37. package/vendor/runtime/dist/runtime.d.ts.map +1 -1
  38. package/vendor/runtime/dist/runtime.js +3 -1
  39. package/vendor/runtime/dist/runtime.js.map +1 -1
  40. package/vendor/runtime/skills/acpx/SKILL.md +1 -0
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: acp-service
3
+ description: 使用 @1agents/acp-service 的 ACP CLI、HTTP/WebSocket 服务和 DSH 插件,或通过 A2A 向远端 DSH 派发任务、查询进度、继续会话及处理完成收件箱。适用于接入和使用这些能力;不用于一般系统巡检或与该包无关的模型配置。
4
+ ---
5
+
6
+ # ACP Service
7
+
8
+ `@1agents/acp-service` 将 Agent runtime、CLI、ACP 服务、DSH 插件和 A2A 实现打进同一个 npm 包。原生 Agent 的可执行文件、登录凭据和模型配置由执行主机提供。
9
+
10
+ ## 选择调用入口
11
+
12
+ | 用户需求 | 使用入口 | 详细说明 |
13
+ | --- | --- | --- |
14
+ | 在当前主机运行 Codex、Claude 等 Agent,管理命名会话、队列或流程 | `acp-service <agent> ...` | [ACP CLI 与服务](references/acp.md) |
15
+ | 从客户端连接常驻 Agent 服务,使用标准会话与流式交互 | `acp-service serve`,ACP over WebSocket | [ACP CLI 与服务](references/acp.md) |
16
+ | 在 DSH 界面使用外部 Agent、原生模型和模式控制 | DSH 中安装同一个包,选择 `ACP · Agent` 预设 | [DSH 插件](references/dsh.md) |
17
+ | 像远端子任务一样调用 WSL/其他主机上的 DSH,立即取回任务 ID | A2A gateway 的 `remote_agent_*` 工具 | [A2A 调度与收件箱](references/a2a.md) |
18
+ | 为其他 A2A 客户端开放 DSH 能力 | DSH `a2a` 配置、Agent Card、标准 JSON-RPC/SSE | [A2A 调度与收件箱](references/a2a.md) |
19
+
20
+ 先检查现有服务和安装版本;服务已经可用时直接复用。需要哪种入口就读对应引用文件。不要为了派发一次远端任务重新安装或重启正常运行的服务。
21
+
22
+ ACP 管理 Agent 会话、交互与工具权限;A2A 管理跨 Agent 的任务、状态、结果及订阅通知。A2A 指向 DSH 后,DSH 的预设决定由标准 Agent 还是外部 ACP Agent 执行。
23
+
24
+ ## 安装与技能发现
25
+
26
+ 需要 Node.js `>=22.13.0`。安装指定版本或用户提供的构建包;A2A 命令以实际安装版本的帮助输出为准,源码功能不代表 npm 上的旧版本已包含它。
27
+
28
+ ```sh
29
+ npm install -g @1agents/acp-service
30
+ acp-service --version
31
+ acp-service --help
32
+ acp-service a2a --help
33
+ acp-service --skill list
34
+ acp-service --skill show acp-service
35
+ ```
36
+
37
+ 此技能随包保存在 `skills/acp-service/`,可独立导出,包含引用文档和 UI 元数据:
38
+
39
+ ```sh
40
+ acp-service --skill export acp-service > acp-service-skill.tar
41
+ # 用户需要为当前项目安装技能时:
42
+ acp-service --skill install acp-service --agent codex --scope repo
43
+ ```
44
+
45
+ `--skill` 同时保留内嵌 runtime 的 `acpx` 技能。`acp-service` **不带参数会启动 ACP 常驻服务**;查看帮助要显式传 `--help`。
46
+
47
+ ## 远端任务的最短工作流
48
+
49
+ 如果宿主已有 DreamMate 工具,检索服务 `a2a-gateway`,按需查看方法契约,再通过 `dreammate_invoke` 调用。没有 DreamMate 时,使用同名 CLI `a2a invoke`;两者调用同一个 gateway。
50
+
51
+ 1. 取得当前主会话的稳定 ID,作为 `originSessionId`;保留真实会话归属,不使用每次随机生成的 ID。
52
+ 2. 明确远端节点名、远端绝对目录、预设和完整任务说明。远端会话不会自动继承主会话上下文。
53
+ 3. 调用 `remote_agent_spawn`,记录返回的 `taskId`、`contextId`、`sessionId` 和实际 `agentPreset`。取到 ID 只表示已受理;仍要检查状态和结果。
54
+ 4. 查询 `remote_agent_get` 或读取 `remote_agent_inbox`。处理报告或所需输入后,按 `noticeId` 调用 `remote_agent_ack`。读取通知本身不会删除或确认它。
55
+ 5. 要继续同一远端会话,使用 `remote_agent_message`;需要全新上下文则再次 spawn。取消时传入准确的任务 ID。
56
+
57
+ ```json
58
+ {
59
+ "remote": "wsl-dsh",
60
+ "originSessionId": "actual-parent-session-id",
61
+ "cwd": "/home/scott",
62
+ "agentPreset": "standard",
63
+ "prompt": "执行只读系统健康巡检:采集 CPU、内存、磁盘与服务状态,给出时间和证据;不得修改设置、重启、安装或读取凭据。"
64
+ }
65
+ ```
66
+
67
+ 工作目录与预设必须存在于远端部署。需要普通 DSH Agent 时显式传 `standard`;需要外部 Codex 时传 `oneagents-acp-codex`(前提是该预设可用)。省略 `agentPreset` 会用 **A2A 服务端配置的默认预设**,它可能与 DSH 界面默认值不同。
68
+
69
+ ## 会话、模式与模型
70
+
71
+ | 概念 | 当前行为 |
72
+ | --- | --- |
73
+ | `cwd` | gateway 的 spawn 必填;是远端现有绝对路径,不能传本机路径代替 |
74
+ | `agentPreset` | 选择 DSH Agent 的组成;gateway 可省略并使用远端 A2A 默认值 |
75
+ | 标准 DSH 模型 | `standard` 使用该 DSH 部署的默认 provider/model,不固定为某一厂商 |
76
+ | ACP Agent 模型/模式 | 由原生 Agent 提供,通过其公布的配置选项或模式切换 |
77
+ | A2A `modelId` / `modeId` | 当前 spawn 和 `metadata.1agents` **没有这些参数**;不能凭空传入或把模型名称写进 prompt 当作配置 |
78
+
79
+ 例如某部署默认配置为 `minimax-cn / MiniMax-M3` 时,`standard` 会调用它。应读取 DSH 模型目录/配置,并用会话实际请求记录中的 provider/model 核对;Agent 自述身份不足以证明模型路由。
80
+
81
+ ## 可靠性与宿主边界
82
+
83
+ - ACP service session ID、原生 Agent session ID、A2A task ID、A2A context ID、DSH session ID 是不同标识。保存返回值,按各自 API 使用。
84
+ - gateway 重启可恢复任务记录和未确认通知;DSH 执行主机重启会将被中断的非终态任务标为失败,不能承诺自动续跑。
85
+ - 网络离线可能返回缓存与 `stale: true`,不等于远端任务失败。SendMessage 响应不明确时先核对,不盲目重发。
86
+ - DSH 的直接 webhook 为尽力投递;gateway 的持久收件箱和后台查询负责补齐,配置宿主通知接收端后还能重试投递。
87
+ - 完成通知到达收件箱不等于主模型被唤醒。接收宿主须实现去重、路由和会话注入;普通 MCP 连接本身不提供自动新一轮执行。此包没有接管 Codex 原生 `spawn_subagent`。
88
+ - 任务权限取决于用户授权、执行主机、DSH/原生 Agent 策略;“只读”任务应在 prompt 中写明动作边界。不要默认启用 `--approve-all` 或将凭据放进 prompt、结果和工具参数。
89
+
90
+ 报告时说明受理、执行、完成和通知处理各阶段的实际状态,给出真实任务 ID及关键结果;无法验证的硬件或模型能力应明确标注。
@@ -0,0 +1,3 @@
1
+ interface:
2
+ display_name: "ACP Service"
3
+ short_description: "使用统一包管理 ACP 会话、DSH 插件与 A2A 远端任务调度"
@@ -0,0 +1,183 @@
1
+ # A2A 调度、查询与完成通知
2
+
3
+ ## 链路与入口
4
+
5
+ ```text
6
+ 主 Agent / CLI → 本机 a2a-gateway → 远端 DSH /a2a SendMessage
7
+ → 解析远端 cwd 与 preset → 创建或恢复 DSH 会话 → 返回 taskId
8
+ → 独立执行 → GetTask / SSE / webhook → gateway 持久收件箱 → 主会话处理并 ack
9
+ ```
10
+
11
+ 当前为 **A2A 1.0 JSON-RPC**,SDK `@a2a-js/sdk@1.3.0`。执行端挂载于 DSH web server;`acp-service serve` 提供 ACP,不会自动开放 DSH A2A。`a2a gateway` 是调用端工具和收件箱,不是另一个 DSH 执行器。
12
+
13
+ ## 远端 DSH 启用 A2A
14
+
15
+ 在现有 `oneagents-acp` 配置行的 `config` 中添加:
16
+
17
+ ```yaml
18
+ a2a:
19
+ enabled: true
20
+ tokenEnv: DSH_A2A_TOKEN
21
+ publicUrl: http://dsh-host:3080
22
+ defaultCwd: /home/scott
23
+ defaultAgentPreset: standard
24
+ workspaces:
25
+ demo: /home/scott/projects/demo
26
+ # 仅需要 webhook 时设置接收端实际 origin
27
+ pushNotificationOrigins:
28
+ - http://caller-host:36815
29
+ ```
30
+
31
+ 目录和主机为示例,应替换为实际部署值。通过 DSH 进程的受保护环境配置 `DSH_A2A_TOKEN`,然后重启 DSH。不要把真实 token 放在技能文档或对话中;DSH UI 登录凭据不是 A2A bearer token。未配置 A2A 时默认关闭,缺少 token 会拒绝激活。
32
+
33
+ - 公开发现:`GET /.well-known/agent-card.json`。
34
+ - 认证调用:`POST /a2a`,`Authorization: Bearer <A2A-token>`、`A2A-Version: 1.0`、`Content-Type: application/json`。
35
+ - `publicUrl` 必须是调用端能访问的 DSH origin;`path` 可自定义 RPC 路由。
36
+ - `a2a.stateDirectory` 可覆盖默认 `<DSH_HOME>/plugins/1agents-acp/a2a`。
37
+
38
+ ## 调用端 gateway
39
+
40
+ 先复用已有 gateway。新部署时创建受保护的 JSON 配置,例如:
41
+
42
+ ```json
43
+ {
44
+ "stateDirectory": "/absolute/private/a2a-gateway-state",
45
+ "port": 36814,
46
+ "remotes": {
47
+ "wsl-dsh": { "url": "http://dsh-host:3080", "token": "replace-with-protected-A2A-token" }
48
+ }
49
+ }
50
+ ```
51
+
52
+ ```sh
53
+ chmod 600 /absolute/private/gateway.json
54
+ acp-service a2a gateway --config /absolute/private/gateway.json
55
+ curl http://127.0.0.1:36814/health
56
+ ```
57
+
58
+ Unix 上 CLI 校验配置权限。gateway 工具端口固定监听 `127.0.0.1`,默认 `36814`;省略 `--no-report` 会向本机 DreamMate node 注册 `a2a-gateway`。不用 DreamMate 时加 `--no-report`,通过 CLI 使用。凭据仅保存在配置中,不传入任务参数。
59
+
60
+ callback 可选;不配置也会由后台 GetTask 查询补齐状态。需要 push 时增加:
61
+
62
+ ```json
63
+ {
64
+ "callback": {
65
+ "host": "caller-bind-IP",
66
+ "port": 36815,
67
+ "url": "http://caller-host:36815/a2a-events",
68
+ "token": "replace-with-separate-callback-token"
69
+ }
70
+ }
71
+ ```
72
+
73
+ 替换可绑定的 IP 与 DSH 可达的 URL,并将 URL 的精确 origin 加入远端 `pushNotificationOrigins`。回调监听器只开放配置的事件路径,不开放工具 `/invoke`;本地工具端口拒绝浏览器 Origin 调用。`originSessionId` 是可信本地调用端使用的通知路由 ID,不是认证凭据。
74
+
75
+ ## 七个调度工具
76
+
77
+ DreamMate 调用参数为 `service_id: "a2a-gateway"`、`method: 方法名`、`params: 参数对象`;先查询服务和方法契约。CLI 则从 stdin 读取同一参数 JSON:
78
+
79
+ | 方法 | 参数与用途 |
80
+ | --- | --- |
81
+ | `remote_agent_spawn` | 必填 `remote, originSessionId, cwd, prompt`;可选 `agentPreset, title, notificationTarget`;新建远端任务/上下文/DSH 会话 |
82
+ | `remote_agent_get` | `remote, originSessionId, taskId`;当前状态、结果;离线返回缓存与 stale |
83
+ | `remote_agent_message` | 上述任务定位字段加 `prompt`;复用远端会话,创建新 taskId |
84
+ | `remote_agent_cancel` | 任务定位字段;取消这项任务自己的执行 |
85
+ | `remote_agent_list` | `originSessionId`;列出该主会话派发的任务 |
86
+ | `remote_agent_inbox` | `originSessionId`;读取未确认的完成/需要输入通知 |
87
+ | `remote_agent_ack` | `originSessionId, noticeId`;确认已处理,重复确认安全 |
88
+
89
+ ```sh
90
+ acp-service a2a invoke remote_agent_spawn <<'JSON'
91
+ {
92
+ "remote": "wsl-dsh",
93
+ "originSessionId": "actual-parent-session-id",
94
+ "cwd": "/home/scott",
95
+ "agentPreset": "standard",
96
+ "title": "只读系统健康巡检",
97
+ "prompt": "实际采集 CPU、内存、磁盘、服务状态并总结。仅只读;不安装、不修改、不重启、不读取凭据。"
98
+ }
99
+ JSON
100
+ ```
101
+
102
+ CLI 和 DreamMate 都返回业务结果对象;spawn 的 `taskId`、`contextId`、`sessionId`、实际 cwd/preset 位于该对象中,`result` 字段是任务报告文本。受理返回 `TASK_STATE_SUBMITTED` 不等于完成。
103
+
104
+ ```sh
105
+ acp-service a2a invoke remote_agent_get <<'JSON'
106
+ {"remote":"wsl-dsh","originSessionId":"actual-parent-session-id","taskId":"returned-task-id"}
107
+ JSON
108
+ acp-service a2a invoke remote_agent_inbox <<'JSON'
109
+ {"originSessionId":"actual-parent-session-id"}
110
+ JSON
111
+ # 处理通知结果后:
112
+ acp-service a2a invoke remote_agent_ack <<'JSON'
113
+ {"originSessionId":"actual-parent-session-id","noticeId":"returned-notice-id"}
114
+ JSON
115
+ ```
116
+
117
+ 每次 spawn 都创建新会话,即使 cwd 相同。message 复用原 context/cwd/preset,创建新任务;可排队,但不是对当前轮的原生 interrupt/steer。当前 gateway 没有 `modelId`、`modeId` 或显式恢复任意 DSH session ID 的参数。
118
+
119
+ ## 直接使用标准 A2A
120
+
121
+ 请求体示例,认证与版本放在 HTTP headers 中:
122
+
123
+ ```json
124
+ {
125
+ "jsonrpc": "2.0",
126
+ "id": "submit-1",
127
+ "method": "SendMessage",
128
+ "params": {
129
+ "message": {
130
+ "messageId": "unique-message-id",
131
+ "role": "ROLE_USER",
132
+ "parts": [{ "text": "只读检查项目 README 并总结", "mediaType": "text/plain" }]
133
+ },
134
+ "configuration": { "returnImmediately": true },
135
+ "metadata": { "1agents": { "workspace": "demo", "agentPreset": "standard" } }
136
+ }
137
+ }
138
+ ```
139
+
140
+ 响应在 `result.task`,包含 `id`、`contextId`、`metadata.1agents.sessionId/cwd/agentPreset`。`returnImmediately: true` 等待会话准备后返回任务 ID;省略则默认等待终态或需要输入状态。
141
+
142
+ `metadata.1agents` 只接受 `cwd`、`workspace`、`agentPreset`;cwd 和 workspace 不可同时传,cwd 为远端现有绝对目录,workspace 为配置别名。省略位置与预设时按远端 A2A 默认值处理。
143
+
144
+ 同一会话的新任务在 `message.contextId` 传已保存 context ID;保存的 cwd/preset 不能改变。已完成 task 不可重新打开。原 task 为 input-required 时可传 `message.taskId`,配合新的 `messageId` 继续;活跃 task 上的 follow-up 被拒绝。
145
+
146
+ | 标准方法 | 用法 |
147
+ | --- | --- |
148
+ | `GetTask` | `params: { "id": "task-id" }`;查询任务状态/历史/结果 |
149
+ | `ListTasks` | 按协议做作用域过滤与分页 |
150
+ | `SubscribeToTask` | `params: { "id": "task-id" }`;SSE,从当前任务快照开始;终态任务直接查询 |
151
+ | `SendStreamingMessage` | 提交并 SSE 观察;客户端断开不会取消独立执行 |
152
+ | `CancelTask` | `params: { "id": "task-id" }`;取消任务自己的排队或运行 |
153
+ | `Create/Get/DeleteTaskPushNotificationConfig`、`ListTaskPushNotificationConfigs` | webhook 配置生命周期 |
154
+
155
+ 支持文本 prompt;不要发送附件或旧 v0.3 消息结构。终态包括 completed、failed、canceled、rejected;input-required/auth-required 需要继续处理,不是成功完成。
156
+
157
+ ## 通知、持久化与恢复
158
+
159
+ 发送配置里可加入标准 `taskPushNotificationConfig`(URL 的 origin 须被允许):
160
+
161
+ ```json
162
+ {
163
+ "returnImmediately": true,
164
+ "taskPushNotificationConfig": {
165
+ "url": "http://caller-host:36815/a2a-events",
166
+ "authentication": { "scheme": "Bearer", "credentials": "protected-callback-token" }
167
+ }
168
+ }
169
+ ```
170
+
171
+ DSH webhook 发送 A2A `StreamResponse`(`application/a2a+json`),含 task/artifactUpdate/statusUpdate。它按任务排序、超时 5 秒、拒绝重定向,尽力投递且不重试。回调提示不能替代可信的 GetTask 查询。
172
+
173
+ gateway 将状态、任务归属和通知原子落盘;通知有稳定 `noticeId`,读取不会确认。默认每 3 秒后台核对任务,丢失 webhook 或 gateway 重启后仍能补齐。主机离线只导致 `stale`,不会伪造远端 failed。
174
+
175
+ 若要通知主 Agent 宿主,在 gateway 配置中增加 `notificationTargets` 名称映射,每项为 `{ "url": "http://host/notice", "token": "protected-token" }`,spawn 时传 `notificationTarget` 名称。这里接收的是 gateway notice(含 originSessionId/taskId/contextId/state/result),不是原始 A2A StreamResponse。
176
+
177
+ 宿主通知使用 Bearer 与稳定 `Idempotency-Key`;失败或 gateway 重启后重试,直到接收端接受或通知被 ack。宿主须先持久化/去重,再注入对应主会话并触发模型执行。HTTP 成功只代表接收,不证明主模型已运行;当前包没有自动唤醒 Codex 下一轮的宿主适配器。
178
+
179
+ 执行端和 gateway 状态目录各由单个活跃实例拥有,不应手工删除运行中实例的 lock。gateway 重启不取消远端任务;DSH 重启会将中断任务标为 failed,保留已完成结果和 context 映射,新任务可用 context 恢复 DSH 会话,不自动重放中断工作。
180
+
181
+ ## 共享实现
182
+
183
+ `@1agents/acp-service/a2a` 导出 `createA2AServer`、`FileA2AStore`、`RemoteAgentGateway`、`serveA2AGateway` 及类型。server 接收 `A2ABackend`,核心不依赖 DSH,工厂本身不创建网络 listener;DSH 通过公开 session-controller API 提供 backend 并挂载路由,独立入口可复用这套实现。
@@ -0,0 +1,104 @@
1
+ # ACP CLI 与常驻服务
2
+
3
+ ## 能力与前提
4
+
5
+ 统一 CLI 可运行注册的原生 Agent,支持持久命名会话、一次性执行、排队、取消、历史回放、导出/导入、模型/模式控制、结构化输出和 typed flows。注册 Agent 不代表可执行文件与登录已经就绪;先检查实际安装与认证。
6
+
7
+ 常驻服务为这些 Agent 提供 ACP v1 JSON-RPC 2.0 over WebSocket。WebSocket 是本包的自定义 ACP 传输,原生 adapter 仍由内嵌 runtime 管理。支持哪些内容块、模式和配置取决于 Agent。
8
+
9
+ ## 本地 CLI
10
+
11
+ ```sh
12
+ # 一次性任务
13
+ acp-service --cwd /absolute/project codex exec '阅读 README 并总结项目,不修改文件'
14
+
15
+ # 命名持久会话:先确保存在,再发送消息
16
+ acp-service --cwd /absolute/project codex sessions ensure --name review
17
+ acp-service --cwd /absolute/project codex -s review '调查测试失败原因,先不要修改'
18
+ acp-service --cwd /absolute/project codex -s review '根据刚才的证据给出修复方案'
19
+
20
+ # 排队后立即返回;不是等待任务完成
21
+ acp-service --cwd /absolute/project codex -s review --no-wait '完成后列出结论'
22
+ acp-service --cwd /absolute/project codex status -s review
23
+ acp-service --cwd /absolute/project codex sessions history review --limit 20
24
+ acp-service --cwd /absolute/project codex cancel -s review
25
+
26
+ # 结构化事件或最终文本
27
+ acp-service --cwd /absolute/project --format json codex exec '说明项目用途'
28
+ acp-service --cwd /absolute/project --format quiet claude exec '说明项目用途'
29
+ ```
30
+
31
+ 持久 CLI 会话按 Agent 命令、绝对 cwd、可选会话名确定作用域;改变 cwd 会改变会话查找。`prompt` 需要该作用域的会话存在,`exec` 是一次性会话。默认权限模式为 `approve-reads`,非交互场景中仍受权限策略约束。
32
+
33
+ 原生 Agent 提供对应选项时,CLI 可以指定模型或调整已存在会话的配置:
34
+
35
+ ```sh
36
+ # 用实际公布的模型、配置键和值替换尖括号内容
37
+ acp-service --cwd /absolute/project --model <advertised-model-id> codex exec '任务说明'
38
+ acp-service --cwd /absolute/project codex set-mode <advertised-mode-id> -s review
39
+ acp-service --cwd /absolute/project codex set <config-key> <advertised-value> -s review
40
+ ```
41
+
42
+ 这些 CLI 模型/模式选项不等于 A2A spawn 支持同名参数。超时的设置操作可能已经生效,核对后再重试。
43
+
44
+ 更多 runtime 选项以 `acp-service <agent> --help`、`acp-service --skill show acpx` 为准;阅读内嵌 `acpx` 技能中的示例时,此统一包使用 `acp-service` 命令和 `@1agents/acp-service/runtime`、`/flows` 导入路径。
45
+
46
+ ## 常驻 HTTP/WebSocket 服务
47
+
48
+ ```sh
49
+ acp-service serve --host 127.0.0.1 --port 36812 --no-report
50
+ curl http://127.0.0.1:36812/health
51
+ curl http://127.0.0.1:36812/agents
52
+ curl http://127.0.0.1:36812/manifest
53
+ ```
54
+
55
+ 默认端口 `36812`。CLI 未传 host 时默认监听 `0.0.0.0`,本地使用显式选择 `127.0.0.1`。服务当前没有连接认证;需要远程开放时由部署网络或认证代理限制访问。省略 `--no-report` 会向本机 DreamMate node 报备。
56
+
57
+ `GET /agents` 返回服务主机上的 Agent 清单与 `chat_ready`;发现过程不执行 Agent、不下载 adapter,也不验证登录或模型访问。`/manifest` 描述服务契约,不是认证成功证明。`ACP_STATE_DIR` 可覆盖默认 `~/.1agents/acpx-state`。
58
+
59
+ 连接 `ws://127.0.0.1:36812/agents/codex`,或使用清单里的 `/agents/<agent-id>`。每帧是一个 JSON-RPC 对象;客户端要实现通知、工具权限请求和所声明的文件/终端能力。
60
+
61
+ 依次发送:
62
+
63
+ ```json
64
+ {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1,"clientCapabilities":{}}}
65
+ ```
66
+
67
+ ```json
68
+ {"jsonrpc":"2.0","id":2,"method":"session/new","params":{"cwd":"/absolute/project","mcpServers":[]}}
69
+ ```
70
+
71
+ ```json
72
+ {"jsonrpc":"2.0","id":3,"method":"session/prompt","params":{"sessionId":"returned-service-session-id","prompt":[{"type":"text","text":"阅读 README,总结项目用途"}]}}
73
+ ```
74
+
75
+ `session/prompt` 返回时该轮才结束,输出通过 `session/update` 流式到达。`session/request_permission` 是服务向客户端发送的请求,要返回本次公布的 option ID 或取消结果,不能杜撰永久授权。
76
+
77
+ | ACP 方法 | 用途 |
78
+ | --- | --- |
79
+ | `session/new` | 创建服务会话;cwd 是服务执行主机上的绝对目录 |
80
+ | `session/load` | 恢复同一服务会话,并回放记录的 ACP 历史 |
81
+ | `session/resume` | 恢复但不回放历史 |
82
+ | `session/prompt` | 执行一轮;普通重叠请求会被拒绝为 busy |
83
+ | `session/cancel` | 取消当前轮的通知,无 RPC 响应;原 prompt 会结束 |
84
+ | `session/close` | 释放执行资源,保留持久历史 |
85
+ | `session/list` | 查询当前 Agent endpoint 的可恢复会话,可按 cwd 过滤 |
86
+ | `session/delete` | 关闭并使服务会话不可恢复/列出 |
87
+ | `session/set_mode` / `session/set_config_option` | 切换 Agent 实际公布的模式或配置 |
88
+
89
+ 后续请求使用 `session/new` 返回的 **服务 session ID**。`_meta.1agents.agentSessionId` 可能是原生 ID,不能混用。传输断开后的恢复应使用已有身份;不明确的已受理 prompt 不应自动重发。
90
+
91
+ ## 编程入口与流程
92
+
93
+ ```ts
94
+ import { serveAcpService } from '@1agents/acp-service/service';
95
+ const service = await serveAcpService({ host: '127.0.0.1', port: 36812, report: false });
96
+ // 结束时:await service.close();
97
+ ```
98
+
99
+ - `@1agents/acp-service/runtime`:内嵌 runtime API。
100
+ - `@1agents/acp-service/agent-registry`:Agent registry API。
101
+ - `@1agents/acp-service/flows`:`defineFlow`、`acp`、`decision`、`action`、`compute`、`checkpoint` 等流程 API。
102
+ - `acp-service flow run ./task.flow.ts --input-file ./input.json`:运行流程;流程中的动作按用户任务授权执行。
103
+
104
+ 导入包本身不会启动服务。完整协议、配置和恢复说明见随 npm 包分发的顶层 `README.md`。
@@ -0,0 +1,61 @@
1
+ # DSH 插件使用
2
+
3
+ ## 安装与服务生命周期
4
+
5
+ 在兼容当前插件公开 API 的 DSH checkout 中执行:
6
+
7
+ ```sh
8
+ pnpm dsh plugin --profile web add @1agents/acp-service
9
+ # 本地构建也可使用绝对包目录或构建好的 tgz
10
+ ```
11
+
12
+ 安装后按该部署的方式重启 DSH。若使用已安装的 `dsh` 可执行文件,省略 `pnpm`。同一个包还提供 CLI,无需独立安装旧 `@1agents/dsh-acp` 或 runtime 包。
13
+
14
+ 已有旧 bundle 时先停止 DSH,移除旧 bundle,再安装统一包;保留自定义配置和绑定文件。使用 profile 的 `cordis.patch.yml` 配置插件,不修改 DSH 源码或默认 profile。
15
+
16
+ 默认 `serviceMode: auto`:插件复用健康的本地 ACP 服务,未运行时在 `127.0.0.1:36812` 启动内嵌服务。卸载/停止插件时,只关闭自己拥有的服务;远端 URL 或 `serviceMode: external` 不管理服务进程。
17
+
18
+ ## 选择执行 Agent
19
+
20
+ 新建会话时选择工作区与预设:
21
+
22
+ | 预设 | 执行者 | 模型来源 |
23
+ | --- | --- | --- |
24
+ | `standard` | DSH 标准 Agent,使用该部署的工具和模型路由 | DSH 默认 provider/model 或会话模型选择 |
25
+ | `oneagents-acp-codex` | 外部 Codex Agent | Codex 原生配置和公布的模型选项 |
26
+ | `oneagents-acp-<agent-id>` | 对应外部 ACP Agent | 对应 Agent 原生配置 |
27
+
28
+ 插件按 `/agents` 中 `chat_ready` 的条目注册 `ACP · Agent` 预设。显式配置 `agents` 可限制范围;`agents: []` 不注册 ACP 预设,但不会把普通 `standard` 预设变成 ACP。
29
+
30
+ ACP 会话的 prompt 直接交给原生 Agent。原生 Agent 拥有其模型、工具、项目指令与历史;DSH 提供界面、权限/问题交互和本地会话记录。DSH 显示外部工具进度,不会再次执行那些工具。
31
+
32
+ 会话开始后保留工作目录和 Agent;切换执行 Agent 或工作区应新建会话。`standard` 不是 ACP 的 `modeId`:它是 DSH 预设 ID。
33
+
34
+ ## 模型、模式与交互
35
+
36
+ ACP 会话里的 `/model`、模式与“ACP 设置”使用 Agent 公布的选项:模型/思考强度走 `session/set_config_option`,模式走 `session/set_mode`。缺失的选项不会自动生成;执行中拒绝修改配置。
37
+
38
+ 普通 DSH 会话仍选择 DSH provider/model。检查实际模型时,以模型目录和会话请求记录为准;例如部署默认 MiniMax 时标准预设会使用它,换部署不能假定仍是 MiniMax。
39
+
40
+ 需要工具审批、问题回答时,使用 DSH 的现有交互 UI。浏览器刷新不取消 Host 请求;停止 DSH 当前轮会发送 ACP 取消。当前插件接入支持文本 prompt,不能承诺 DSH 附件也已转发给外部 Agent。
41
+
42
+ ## 配置与状态
43
+
44
+ 在已有 `oneagents-acp` 配置行里设置,例如:
45
+
46
+ ```yaml
47
+ config:
48
+ serviceMode: auto
49
+ serviceUrl: http://127.0.0.1:36812
50
+ agents: [codex]
51
+ reconnectAttempts: 5
52
+ reconnectDelayMs: 1000
53
+ ```
54
+
55
+ 删除 `agents` 字段可恢复自动发现。`stateDirectory` 设置 ACP 绑定目录;默认 `<DSH_HOME>/plugins/1agents-acp/sessions`。A2A 的 `a2a.stateDirectory` 是另一份状态,见 [A2A](a2a.md)。
56
+
57
+ 原生 Agent 可执行文件和凭据必须能被服务进程读取。`auto` 子服务继承 DSH 环境,既有外部服务则使用自己的启动环境。安装 CLI 或看见预设都不等于认证成功。
58
+
59
+ 安装配套 `@1agents/session-reader` 后,可在支持的 Claude/Codex/Grok 历史中选择“在 DSH 中继续原会话”。它恢复原生身份并导入历史,不重发旧 prompt;有活跃原生 writer 时保持只读,等待 writer 释放后恢复输入。
60
+
61
+ 完整插件配置、恢复和导入 API 随包位于 `vendor/dsh/README.md`。
@@ -1,35 +1,59 @@
1
1
  # DSH plugin in @1agents/acp-service
2
2
 
3
- An out-of-tree DeepSeek Harness plugin for persistent external ACP Agent sessions. It requires the local DSH plugin and preset APIs available in 0.1.7-rc.2 and is embedded with the runtime and service in the single public `@1agents/acp-service` 0.5 package. This directory is a private source module, not a separately installable npm package. No DSH source files are modified.
3
+ Use persistent native Codex, Claude Code, Grok Build and other locally discovered ACP Agent sessions inside DeepSeek Harness. Choose native models and settings, use advertised commands, and answer tool permissions in DSH. The plugin is embedded with the runtime and service in the single public **`@1agents/acp-service`** package. This directory is its private source module.
4
4
 
5
- ## Use
5
+ The CI API baseline is **DSH 0.1.7-rc.2**, commit `21638c56315ae6a2b552d6091945d3144c9af32e`. Additional installed-package and interactive checks used an isolated profile on a locally modified DSH build labeled `0.2.0-rc.1`; see the [verification record](https://github.com/scottzx/1acp/blob/main/docs/marketplaces/verification-2026-10-09.md) for the exact scope. Other DSH releases require checking their plugin and preset APIs.
6
6
 
7
- For an existing `@1agents/dsh-acp` installation, stop DSH, remove that bundle and add `@1agents/acp-service`. Keep existing binding files and copy any custom row configuration. The same plugin and preset IDs preserve session identity. Custom preset rows now load `@1agents/acp-service/dsh/preset`.
7
+ The same host supports opt-in A2A 1.0 delegation, disabled by default: remote text messages create or restore DSH sessions, return task IDs, and continue execution independently of HTTP clients. Configure `a2a` on the existing plugin row, set the host's `DSH_A2A_TOKEN`, and choose its public origin, default cwd and preset. Query and subscribe through the official A2A interfaces; allowed webhook origins enable completion callbacks. Waking a caller's main Agent requires its receiving host adapter. See the [service README's DSH A2A section](https://github.com/scottzx/1acp/blob/main/packages/service/README.md#dsh-a2a) for configuration, metadata and recovery behavior. The shared server is exported as `@1agents/acp-service/a2a` and remains independent of DSH imports.
8
8
 
9
- Install the published bundles from your DSH checkout:
9
+ ## Install and start a session
10
+
11
+ Requires **Node.js 22.13+**, a working DSH installation, and each selected native Agent's CLI and authentication on the DSH host. Adapter-backed Agents require their ACP adapter as well; the native Codex CLI does not replace `@agentclientprotocol/codex-acp`. Ensure these executables and credentials are available to the DSH process.
12
+
13
+ Install the one public package:
10
14
 
11
15
  ```sh
12
- pnpm dsh plugin --profile web add @1agents/acp-service @1agents/session-reader
16
+ dsh plugin --profile web add @1agents/acp-service@^0.7.0
13
17
  ```
14
18
 
15
- If pnpm pauses the first install for the transitive `esbuild` build script, set `allowBuilds: { esbuild: false }` in that profile's `pnpm-workspace.yaml` and repeat the install. Automatic ACP startup uses published JavaScript and works without running that install script.
19
+ If pnpm pauses or fails with an ignored transitive `esbuild` build script, follow its prompt or configure that individual package's approval in the profile's `pnpm-workspace.yaml`, then repeat the install. Approve or deny it according to your policy. A successful isolated package smoke used `--ignore-scripts`; the interactive pnpm 11 profile check approved only `esbuild`. A partial install can leave the bundle disabled, so check the Plugins page afterward.
20
+
21
+ Restart DSH after updating packages, confirm **`@1agents/acp-service`** is enabled on its Plugins page, and choose a discovered **ACP · Agent** preset for a new session. Select an existing workspace, then send a text prompt. Replace `web` with your profile name, such as `desktop`; from a DSH source checkout, use `pnpm dsh` in place of `dsh`.
22
+
23
+ For a pinned fallback, install the identical npm artifact from [GitHub Release 0.6.0](https://github.com/scottzx/1acp/releases/tag/acp-service-v0.6.0):
24
+
25
+ ```sh
26
+ dsh plugin --profile web add https://github.com/scottzx/1acp/releases/download/acp-service-v0.6.0/1agents-acp-service-0.6.0.tgz
27
+ ```
16
28
 
17
- The package declares `dsh.bundle.patch` and its browser entry, so installation selects the bundle automatically. Restart `pnpm dsh web` after updating packages. If you use an installed `dsh` executable, omit the leading `pnpm`. Replace `web` with `desktop` for the desktop profile.
29
+ The package declares `dsh.bundle.patch` and its browser entry, so installation selects the bundle automatically.
18
30
 
19
31
  The plugin starts its bundled ACP service on `127.0.0.1:36812` when no service is listening. An existing healthy ACP service is reused. Start DSH normally; no separate service command is needed. To manage the service yourself, set `serviceMode: external` and run:
20
32
 
21
33
  ```sh
22
- npx --yes @1agents/acp-service@^0.5.0 serve --host 127.0.0.1 --port 36812 --no-report
34
+ npx --yes @1agents/acp-service@^0.7.0 serve --host 127.0.0.1 --port 36812 --no-report
23
35
  ```
24
36
 
25
- The service requires each native Agent’s CLI and credentials. Installing the package alone starts no process; activating the plugin starts the service. For local development, install the built checkout with `pnpm dsh plugin --profile web add /absolute/path/1acp/packages/service`.
37
+ Installing the package alone starts no process; activating the plugin starts the service. For local development, install the built checkout with `pnpm dsh plugin --profile web add /absolute/path/1acp/packages/service`.
26
38
 
27
- Choose a discovered **ACP · Agent** in the new-session Agent preset picker, choose a workspace, then send a message. ACP routes are not listed as ordinary DSH models, and the adapter rejects requests from ordinary presets, including previously saved ACP routes. Before the first turn, switching the Agent preset replaces the discovery connection and its native commands. Once a turn starts, the session keeps its remote Agent and workspace; start a new session to change Agent. Native Agent binaries and authentication belong to acp-service.
39
+ ACP routes are not listed as ordinary DSH models, and the adapter rejects requests from ordinary presets, including previously saved ACP routes. Before the first turn, switching the Agent preset replaces the discovery connection and its native commands. Once a turn starts, the session keeps its remote Agent and workspace; start a new session to change Agent. Native Agent binaries and authentication belong to acp-service.
40
+
41
+ ### Migrate an older installation
42
+
43
+ For an existing `@1agents/dsh-acp` installation, stop DSH, remove that bundle and add `@1agents/acp-service`. Keep existing binding files and copy any custom row configuration. The same plugin and preset IDs preserve session identity. Custom preset rows now load `@1agents/acp-service/dsh/preset`. Enable only the unified bundle.
44
+
45
+ ## Session behavior
28
46
 
29
47
  The bundle registers an ACP adapter through DSH's public streaming extension and routes the ACP presets to it. It sends newly admitted messages whose source is `user` to `session/prompt`, not to `subagent-acp`; there is no coordinating DeepSeek model call. DSH-generated workspace instructions and runtime-context messages are excluded. The external Agent owns its model, prompt, tools and native history, including any project instructions it discovers itself. DSH owns its UI and local user/assistant transcript. External tool progress is preserved as display metadata on empty text blocks in DSH's existing assistant stream records and projected onto collapsed groups of peer tool cards, separated by native prose and reasoning. ACP updates retain previously supplied fields, and replay is deduplicated by the managed turn sequence. These snapshots contain no visible text and never dispatch local tools; they use the existing persisted session format so conversations can reopen normally. Only Agent thought chunks enter the thinking stream.
30
48
 
31
49
  ## Continue imported native sessions
32
50
 
51
+ History import is optional. Install the separate history browser only when needed:
52
+
53
+ ```sh
54
+ dsh plugin --profile web add @1agents/session-reader
55
+ ```
56
+
33
57
  With `@1agents/session-reader` installed, choose **在 DSH 中继续原会话** on a Claude, Codex or Grok history. The original workspace must still exist. The plugin restores the native session through acp-service's `_1agents/session/import`, creates DSH history under the matching ACP preset, and attaches it to that workspace. Importing sends no prompt. Subsequent messages go to the original Agent; imported messages are never resent, including an unfinished trailing user message. Unsupported sources stay readable in session-reader.
34
58
 
35
59
  Imported bindings use `session/resume` because the service does not own a complete ACP replay of earlier native history. Existing ordinary ACP bindings continue using `session/load`. Endpoint, source provider and native ID identify an import; repeated admission reuses its DSH session without refreshing or replacing history. Old history-only DSH copies are not adopted. Original Agent history can continue changing outside DSH; the imported DSH history is a snapshot.
@@ -0,0 +1,26 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { A2ABackend, A2APrepareInput, A2ARunResult, A2ATarget } from '@1agents/acp-service/a2a';
3
+ /** Uses public session-controller and inbox events to account for one A2A prompt's exact DSH turn. */
4
+ export declare class DshA2ABackend implements A2ABackend {
5
+ private readonly ctx;
6
+ private readonly executions;
7
+ /** @param ctx DSH plugin context that owns session-controller and execution event registrations. */
8
+ constructor(ctx: Context);
9
+ /** Create a new session or restore an explicitly addressed session without changing its workspace or preset.
10
+ * @param input Remote host directory, preset, and optional existing DSH session identity.
11
+ * @returns The resolved DSH session and its durable workspace and preset.
12
+ */
13
+ prepare(input: A2APrepareInput): Promise<A2ATarget>;
14
+ /** Admit one identified queued prompt and wait only for its own turn, independent of the HTTP connection.
15
+ * @param target Previously prepared DSH session.
16
+ * @param prompt Plain-text A2A message content.
17
+ * @param options Task-owned request identity and cancellation signal.
18
+ * @returns The exact turn's ending and its final assistant text.
19
+ */
20
+ run(target: A2ATarget, prompt: string, options: {
21
+ requestId: string;
22
+ signal: AbortSignal;
23
+ }): Promise<A2ARunResult>;
24
+ private execute;
25
+ private agent;
26
+ }