状态:传统外部 CLI 集成。Gateway 会启动Documentation Index
Fetch the complete documentation index at: https://openclaw.zhcndoc.com/llms.txt
Use this file to discover all available pages before exploring further.
imsg rpc,并通过 stdio 上的 JSON-RPC 进行通信(没有单独的守护进程/端口)。
BlueBubbles(推荐)
新部署首选的 iMessage 路径。
配对
iMessage 私信默认使用配对模式。
配置参考
完整的 iMessage 字段参考。
快速设置
要求和权限(macOS)
- 运行
imsg的 Mac 上必须已登录 Messages。 - 运行 OpenClaw/
imsg的进程上下文需要完整磁盘访问权限(用于访问 Messages 数据库)。 - 通过 Messages.app 发送消息需要 Automation 权限。
访问控制和路由
- DM 策略
- 群组策略 + 提及
- 会话和确定性回复
channels.imessage.dmPolicy 控制私信:pairing(默认)allowlistopen(要求allowFrom包含"*")disabled
channels.imessage.allowFrom。允许列表条目可以是 handle 或聊天目标(chat_id:*、chat_guid:*、chat_identifier:*)。ACP 会话绑定
传统 iMessage 聊天也可以绑定到 ACP 会话。 快速操作流程:- 在该私信或允许的群聊中运行
/acp spawn codex --bind here。 - 之后同一 iMessage 会话中的消息会路由到生成的 ACP 会话。
/new和/reset会就地重置同一个已绑定的 ACP 会话。/acp close会关闭 ACP 会话并移除绑定。
bindings[] 条目支持已配置的持久绑定,使用 type: "acp" 和 match.channel: "imessage"。
match.peer.id 可以使用:
- 规范化的 DM handle,例如
+15555550123或user@example.com chat_id:<id>(推荐用于稳定的群组绑定)chat_guid:<guid>chat_identifier:<identifier>
部署模式
专用 bot macOS 用户(独立 iMessage 身份)
专用 bot macOS 用户(独立 iMessage 身份)
使用专用 Apple ID 和 macOS 用户,这样 bot 流量就会与个人 Messages 配置文件隔离开来。典型流程:
- 创建/登录一个专用的 macOS 用户。
- 在该用户中使用 bot Apple ID 登录 Messages。
- 在该用户中安装
imsg。 - 创建 SSH 包装脚本,以便 OpenClaw 可以在该用户上下文中运行
imsg。 - 将
channels.imessage.accounts.<id>.cliPath和.dbPath指向该用户配置文件。
通过 Tailscale 连接远程 Mac(示例)
通过 Tailscale 连接远程 Mac(示例)
常见拓扑:使用 SSH 密钥,以便 SSH 和 SCP 都是非交互式的。
先确保主机密钥是受信任的(例如
- gateway 运行在 Linux/VM 上
- iMessage +
imsg运行在你 tailnet 中的一台 Mac 上 cliPath包装脚本使用 SSH 运行imsgremoteHost启用通过 SCP 拉取附件
ssh bot@mac-mini.tailnet-1234.ts.net),以便填充 known_hosts。多账号模式
多账号模式
iMessage 支持在
channels.imessage.accounts 下为每个账号进行配置。每个账号都可以覆盖诸如 cliPath、dbPath、allowFrom、groupPolicy、mediaMaxMb、历史设置以及附件根目录允许列表等字段。媒体、分块和投递目标
附件和媒体
附件和媒体
- 入站附件导入是可选的:
channels.imessage.includeAttachments - 当设置了
remoteHost时,可以通过 SCP 获取远程附件路径 - 附件路径必须匹配允许的根目录:
channels.imessage.attachmentRoots(本地)channels.imessage.remoteAttachmentRoots(远程 SCP 模式)- 默认根目录模式:
/Users/*/Library/Messages/Attachments
- SCP 使用严格的 host key 检查(
StrictHostKeyChecking=yes) - 出站媒体大小使用
channels.imessage.mediaMaxMb(默认 16 MB)
出站分块
出站分块
- 文本分块限制:
channels.imessage.textChunkLimit(默认 4000) - 分块模式:
channels.imessage.chunkModelength(默认)newline(优先按段落拆分)
寻址格式
寻址格式
推荐的显式目标:
chat_id:123(推荐用于稳定路由)chat_guid:...chat_identifier:...
imessage:+1555...sms:+1555...user@example.com
配置写入
iMessage 默认允许由频道发起的配置写入(用于/config set|unset,当 commands.config: true 时)。
禁用:
故障排查
未找到 imsg 或不支持 RPC
未找到 imsg 或不支持 RPC
验证二进制文件和 RPC 支持:如果探测报告不支持 RPC,请更新
imsg。DM 被忽略
DM 被忽略
检查:
channels.imessage.dmPolicychannels.imessage.allowFrom- 配对批准(
openclaw pairing list imessage)
群消息被忽略
群消息被忽略
检查:
channels.imessage.groupPolicychannels.imessage.groupAllowFromchannels.imessage.groups白名单行为- 提及模式配置(
agents.list[].groupChat.mentionPatterns)
远程附件失败
远程附件失败
检查:
channels.imessage.remoteHostchannels.imessage.remoteAttachmentRoots- 网关主机上的 SSH/SCP 密钥认证
- 网关主机的
~/.ssh/known_hosts中是否存在主机密钥 - 运行 Messages 的 Mac 上远程路径是否可读
macOS 权限提示被错过
macOS 权限提示被错过
在相同用户/会话上下文中的交互式 GUI 终端里重新运行并批准提示:确认运行 OpenClaw/
imsg 的进程上下文已授予完全磁盘访问和自动化权限。