跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.openclaw.ai/llms.txt

Use this file to discover all available pages before exploring further.

对于新的 iMessage 部署,请使用 BlueBubblesimsg 集成是旧版集成,可能会在未来版本中移除。
Status:旧版外部 CLI 集成。Gateway 网关会启动 imsg rpc,并通过 stdio 上的 JSON-RPC 通信(没有独立守护进程或端口)。

BlueBubbles(推荐)

新设置首选的 iMessage 路径。

配对

iMessage 私信默认使用配对模式。

配置参考

完整的 iMessage 字段参考。

快速设置

1

安装并验证 imsg

brew install steipete/tap/imsg
imsg rpc --help
2

配置 OpenClaw

{
  channels: {
    imessage: {
      enabled: true,
      cliPath: "/usr/local/bin/imsg",
      dbPath: "/Users/user/Library/Messages/chat.db",
    },
  },
}
3

启动 Gateway 网关

openclaw gateway
4

批准首次私信配对(默认 dmPolicy)

openclaw pairing list imessage
openclaw pairing approve imessage <CODE>
配对请求会在 1 小时后过期。

要求和权限(macOS)

  • Messages 必须已在运行 imsg 的 Mac 上登录。
  • 运行 OpenClaw/imsg 的进程上下文需要 Full Disk Access(用于访问 Messages 数据库)。
  • 通过 Messages.app 发送消息需要 Automation 权限。
权限按进程上下文授予。如果 Gateway 网关以无头方式运行(LaunchAgent/SSH),请在同一上下文中运行一次性交互式命令以触发提示:
imsg chats --limit 1
# or
imsg send <handle> "test"

访问控制和路由

channels.imessage.dmPolicy 控制直接消息:
  • pairing(默认)
  • allowlist
  • open(要求 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 可以使用:
  • 规范化的私信 handle,例如 +15555550123user@example.com
  • chat_id:<id>(推荐用于稳定的群组绑定)
  • chat_guid:<guid>
  • chat_identifier:<identifier>
示例:
{
  agents: {
    list: [
      {
        id: "codex",
        runtime: {
          type: "acp",
          acp: { agent: "codex", backend: "acpx", mode: "persistent" },
        },
      },
    ],
  },
  bindings: [
    {
      type: "acp",
      agentId: "codex",
      match: {
        channel: "imessage",
        accountId: "default",
        peer: { kind: "group", id: "chat_id:123" },
      },
      acp: { label: "codex-group" },
    },
  ],
}
有关共享 ACP 绑定行为,请参阅 ACP Agents

部署模式

使用专用 Apple ID 和 macOS 用户,使机器人流量与你的个人 Messages 配置隔离。典型流程:
  1. 创建/登录专用 macOS 用户。
  2. 在该用户中使用机器人 Apple ID 登录 Messages。
  3. 在该用户中安装 imsg
  4. 创建 SSH 包装脚本,使 OpenClaw 可以在该用户上下文中运行 imsg
  5. channels.imessage.accounts.<id>.cliPath.dbPath 指向该用户配置。
首次运行可能需要在该机器人用户会话中进行 GUI 批准(Automation + Full Disk Access)。
常见拓扑:
  • Gateway 网关运行在 Linux/VM 上
  • iMessage + imsg 运行在你 tailnet 中的一台 Mac 上
  • cliPath 包装脚本使用 SSH 运行 imsg
  • remoteHost 启用 SCP 附件拉取
示例:
{
  channels: {
    imessage: {
      enabled: true,
      cliPath: "~/.openclaw/scripts/imsg-ssh",
      remoteHost: "bot@mac-mini.tailnet-1234.ts.net",
      includeAttachments: true,
      dbPath: "/Users/bot/Library/Messages/chat.db",
    },
  },
}
#!/usr/bin/env bash
exec ssh -T bot@mac-mini.tailnet-1234.ts.net imsg "$@"
使用 SSH 密钥,使 SSH 和 SCP 都无需交互。 先确保主机密钥受信任(例如 ssh bot@mac-mini.tailnet-1234.ts.net),从而填充 known_hosts
iMessage 支持在 channels.imessage.accounts 下按账号配置。每个账号都可以覆盖 cliPathdbPathallowFromgroupPolicymediaMaxMb、历史设置和附件根目录允许名单等字段。

媒体、分块和投递目标

  • 入站附件摄取是可选的:channels.imessage.includeAttachments
  • 设置 remoteHost 后,可以通过 SCP 获取远程附件路径
  • 附件路径必须匹配允许的根目录:
    • channels.imessage.attachmentRoots(本地)
    • channels.imessage.remoteAttachmentRoots(远程 SCP 模式)
    • 默认根目录模式:/Users/*/Library/Messages/Attachments
  • SCP 使用严格的主机密钥检查(StrictHostKeyChecking=yes
  • 出站媒体大小使用 channels.imessage.mediaMaxMb(默认 16 MB)
  • 文本分块限制:channels.imessage.textChunkLimit(默认 4000)
  • 分块模式:channels.imessage.chunkMode
    • length(默认)
    • newline(优先按段落拆分)
首选显式目标:
  • chat_id:123(推荐用于稳定路由)
  • chat_guid:...
  • chat_identifier:...
也支持 handle 目标:
  • imessage:+1555...
  • sms:+1555...
  • user@example.com
imsg chats --limit 20

配置写入

iMessage 默认允许由渠道发起配置写入(适用于 commands.config: true 时的 /config set|unset)。 禁用:
{
  channels: {
    imessage: {
      configWrites: false,
    },
  },
}

故障排除

验证二进制文件和 RPC 支持:
imsg rpc --help
openclaw channels status --probe
如果探测报告不支持 RPC,请更新 imsg
检查:
  • channels.imessage.dmPolicy
  • channels.imessage.allowFrom
  • 配对批准(openclaw pairing list imessage
检查:
  • channels.imessage.groupPolicy
  • channels.imessage.groupAllowFrom
  • channels.imessage.groups 允许名单行为
  • 提及模式配置(agents.list[].groupChat.mentionPatterns
检查:
  • channels.imessage.remoteHost
  • channels.imessage.remoteAttachmentRoots
  • 来自 Gateway 网关主机的 SSH/SCP 密钥认证
  • 主机密钥是否存在于 Gateway 网关主机上的 ~/.ssh/known_hosts
  • 运行 Messages 的 Mac 上远程路径的可读性
在相同用户/会话上下文中的交互式 GUI 终端里重新运行,并批准提示:
imsg chats --limit 1
imsg send <handle> "test"
确认运行 OpenClaw/imsg 的进程上下文已获得 Full Disk Access + Automation。

配置参考指针

相关内容