acp
运行与 OpenClaw Gateway 通信的 ACP (Agent Client Protocol) 桥接器。
此命令通过 stdio 与 IDE 进行 ACP 通信,并通过 WebSocket 将提示转发到 Gateway。 它将 ACP 会话映射到 Gateway 会话密钥。
用法
bash
openclaw acp
# Remote Gateway
openclaw acp --url wss://gateway-host:18789 --token <token>
# Attach to an existing session key
openclaw acp --session agent:main:main
# Attach by label (must already exist)
openclaw acp --session-label "support inbox"
# Reset the session key before the first prompt
openclaw acp --session agent:main:main --reset-sessionACP 客户端(调试)
使用内置的 ACP 客户端在没有 IDE 的情况下对桥接器进行完整性检查。 它会生成 ACP 桥接器并允许您以交互方式输入提示。
bash
openclaw acp client
# Point the spawned bridge at a remote Gateway
openclaw acp client --server-args --url wss://gateway-host:18789 --token <token>
# Override the server command (default: openclaw)
openclaw acp client --server "node" --server-args openclaw.mjs acp --url ws://127.0.0.1:19001如何使用
当 IDE(或其他客户端)使用 Agent Client Protocol 并且您希望它驱动 OpenClaw Gateway 会话时,使用 ACP。
- 确保 Gateway 正在运行(本地或远程)。
- 配置 Gateway 目标(配置或标志)。
- 将您的 IDE 指向通过 stdio 运行
openclaw acp。
示例配置(持久化):
bash
openclaw config set gateway.remote.url wss://gateway-host:18789
openclaw config set gateway.remote.token <token>示例直接运行(不写入配置):
bash
openclaw acp --url wss://gateway-host:18789 --token <token>选择代理
ACP 不直接选择代理。它通过 Gateway 会话密钥进行路由。
使用代理范围的会话密钥来指定特定代理:
bash
openclaw acp --session agent:main:main
openclaw acp --session agent:design:main
openclaw acp --session agent:qa:bug-123每个 ACP 会话映射到单个 Gateway 会话密钥。一个代理可以有多个会话;除非您覆盖密钥或标签,否则 ACP 默认使用隔离的 acp:<uuid> 会话。
Zed 编辑器设置
在 ~/.config/zed/settings.json 中添加自定义 ACP 代理(或使用 Zed 的设置 UI):
json
{
"agent_servers": {
"OpenClaw ACP": {
"type": "custom",
"command": "openclaw",
"args": ["acp"],
"env": {}
}
}
}要指定特定的 Gateway 或代理:
json
{
"agent_servers": {
"OpenClaw ACP": {
"type": "custom",
"command": "openclaw",
"args": [
"acp",
"--url",
"wss://gateway-host:18789",
"--token",
"<token>",
"--session",
"agent:design:main"
],
"env": {}
}
}
}在 Zed 中,打开 Agent 面板并选择 "OpenClaw ACP" 以启动线程。
会话映射
默认情况下,ACP 会话使用带有 acp: 前缀的隔离 Gateway 会话密钥。 要重用已知会话,请传递会话密钥或标签:
--session <key>:使用特定的 Gateway 会话密钥。--session-label <label>:通过标签解析现有会话。--reset-session:为该密钥生成新的会话 id(相同密钥,新记录)。
如果您的 ACP 客户端支持元数据,您可以按会话覆盖:
json
{
"_meta": {
"sessionKey": "agent:main:main",
"sessionLabel": "support inbox",
"resetSession": true
}
}在 /concepts/session 了解更多关于会话密钥的信息。
选项
--url <url>:Gateway WebSocket URL(配置后默认为 gateway.remote.url)。--token <token>:Gateway 认证令牌。--password <password>:Gateway 认证密码。--session <key>:默认会话密钥。--session-label <label>:要解析的默认会话标签。--require-existing:如果会话密钥/标签不存在则失败。--reset-session:在首次使用前重置会话密钥。--no-prefix-cwd:不要在提示前添加工作目录前缀。--verbose, -v:详细日志输出到 stderr。
acp client 选项
--cwd <dir>:ACP 会话的工作目录。--server <command>:ACP 服务器命令(默认:openclaw)。--server-args <args...>:传递给 ACP 服务器的额外参数。--server-verbose:在 ACP 服务器上启用详细日志。--verbose, -v:详细客户端日志。