macOS VM 上的 Moltbot(沙箱隔离)

macOS VM 上的 Moltbot(沙箱隔离)

适用范围

在以下情况使用此页面:

  • 你希望 Moltbot 与主 macOS 环境隔离
  • 你希望在沙箱中使用 iMessage 集成(BlueBubbles)
  • 你想要一个可以克隆的可重置 macOS 环境
  • 你想比较本地与托管的 macOS VM 选项

推荐的默认选项(大多数用户)

  • 小型 Linux VPS 用于常驻网关和低成本。请参阅 VPS 托管
  • 专用硬件(Mac mini 或 Linux 主机),如果你想完全控制并为浏览器自动化使用住宅 IP。许多站点阻止数据中心 IP,因此本地浏览通常效果更好。
  • 混合: 将网关保留在便宜的 VPS 上,并在需要浏览器/UI 自动化时将 Mac 连接为节点。请参阅 节点网关远程访问

当你特别需要仅 macOS 的功能(iMessage/BlueBubbles)或想要与日常 Mac 严格隔离时,请使用 macOS VM。

macOS VM 选项

在 Apple Silicon Mac 上使用本地 VM(Lume)

使用 Lume 在现有的 Apple Silicon Mac 上在隔离的 macOS VM 中运行 Moltbot。

这为你提供:

  • 完全隔离的 macOS 环境(你的主机保持清洁)
  • 通过 BlueBubbles 支持 iMessage(在 Linux/Windows 上不可能)
  • 通过克隆 VM 即时重置
  • 无需额外硬件或云成本

托管 Mac 提供商(云端)

如果你想要云中的 macOS,托管 Mac 提供商也可以工作:

  • MacStadium(托管 Mac)
  • 其他托管 Mac 供应商也可以工作;遵循他们的 VM + SSH 文档

一旦你有 macOS VM 的 SSH 访问权限,请从下面的步骤 6 继续。


快速路径(Lume,有经验的用户)

  1. 安装 Lume
  2. lume create moltbot --os macos --ipsw latest
  3. 完成设置助手,启用远程登录(SSH)
  4. lume run moltbot --no-display
  5. 通过 SSH 登录,安装 Moltbot,配置频道
  6. 完成

你需要什么(Lume)

  • Apple Silicon Mac(M1/M2/M3/M4)
  • 主机上的 macOS Sequoia 或更高版本
  • 每个 VM 约 60 GB 可用磁盘空间
  • 大约 20 分钟

1) 安装 Lume

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)"

如果 ~/.local/bin 不在你的 PATH 中:

echo 'export PATH="$PATH:$HOME/.local/bin"' >> ~/.zshrc && source ~/.zshrc

验证:

lume --version

文档:Lume 安装


2) 创建 macOS VM

lume create moltbot --os macos --ipsw latest

这将下载 macOS 并创建 VM。VNC 窗口会自动打开。

注意:根据你的连接情况,下载可能需要一些时间。


3) 完成设置助手

在 VNC 窗口中:

  1. 选择语言和地区
  2. 跳过 Apple ID(或者如果你想稍后使用 iMessage,请登录)
  3. 创建用户账户(记住用户名和密码)
  4. 跳过所有可选功能

设置完成后,启用 SSH:

  1. 打开系统设置 → 通用 → 共享
  2. 启用"远程登录"

4) 获取 VM 的 IP 地址

lume get moltbot

查找 IP 地址(通常是 192.168.64.x)。


5) 通过 SSH 登录 VM

youruser 替换为你创建的账户,将 IP 替换为你的 VM 的 IP。


6) 安装 Moltbot

在 VM 内部:

npm install -g moltbot@latest
moltbot onboard --install-daemon

按照入门提示设置你的模型提供商(Anthropic、OpenAI 等)。


7) 配置频道

编辑配置文件:

nano ~/.moltbot/moltbot.json

添加你的频道:

{
  "channels": {
    "whatsapp": {
      "dmPolicy": "allowlist",
      "allowFrom": ["+15551234567"]
    },
    "telegram": {
      "botToken": "YOUR_BOT_TOKEN"
    }
  }
}

然后登录 WhatsApp(扫描 QR):

moltbot channels login

8) 无头运行 VM

停止 VM 并在没有显示器的情况下重启:

lume stop moltbot
lume run moltbot --no-display

VM 在后台运行。Moltbot 的守护进程保持网关运行。

要检查状态:

ssh [email protected] "moltbot status"

额外功能:iMessage 集成

这是在 macOS 上运行的杀手级功能。使用 BlueBubbles 将 iMessage 添加到 Moltbot。

在 VM 内部:

  1. 从 bluebubbles.app 下载 BlueBubbles
  2. 使用你的 Apple ID 登录
  3. 启用 Web API 并设置密码
  4. 将 BlueBubbles webhook 指向你的网关(示例:https://your-gateway-host:3000/bluebubbles-webhook?password=<password>

添加到你的 Moltbot 配置:

{
  "channels": {
    "bluebubbles": {
      "serverUrl": "http://localhost:1234",
      "password": "your-api-password",
      "webhookPath": "/bluebubbles-webhook"
    }
  }
}

重启网关。现在你的代理可以发送和接收 iMessage。

完整设置详细信息:BlueBubbles 频道


保存黄金镜像

在进一步自定义之前,快照你的清洁状态:

lume stop moltbot
lume clone moltbot moltbot-golden

随时重置:

lume stop moltbot && lume delete moltbot
lume clone moltbot-golden moltbot
lume run moltbot --no-display

24/7 运行

通过以下方式保持 VM 运行:

  • 保持 Mac 插入电源
  • 在系统设置 → 能源节省器中禁用睡眠
  • 如果需要,使用 caffeinate

对于真正的常驻运行,请考虑专用的 Mac mini 或小型 VPS。请参阅 VPS 托管


故障排除

问题解决方案
无法通过 SSH 登录 VM检查 VM 的系统设置中是否启用了"远程登录"
未显示 VM IP等待 VM 完全启动,再次运行 lume get moltbot
未找到 Lume 命令~/.local/bin 添加到你的 PATH
WhatsApp QR 未扫描确保你在运行 moltbot channels login 时登录到 VM(而不是主机)

相关文档