OpenClaw 安装、部署及使用详细全解
项目地址:https://github.com/openclaw/openclaw 官方文档:https://docs.openclaw.ai 官方网站:https://openclaw.ai
目录
1. 项目概述
1.1 什么是 OpenClaw
OpenClaw 是一个个人 AI 助手框架,运行在你自己的设备上。它通过你已有的消息通道(微信、飞书、WebChat 等)与你交互,支持语音输入输出,并可以渲染实时画布(Canvas)。
核心理念:Local-first(本地优先) —— 你的上下文和技能存储在你自己的计算机上,而不是某个围墙花园里。
1.2 项目基本信息
| 作者 | Peter Steinberger (@steipete) 及社区 |
| GitHub 仓库 | openclaw/openclaw |
| 许可证 | MIT |
| Stars | 376k+ |
| Forks | 78.5k+ |
| 主要语言 | TypeScript |
| 运行环境 | Node.js 24(推荐)/ Node 22.19+ |
| 开发频道 | stable / beta / dev |
| 赞助方 | OpenAI, GitHub, NVIDIA, Vercel, Blacksmith, Convex |
1.3 核心特性
- 本地优先 Gateway:单一控制平面,管理会话、通道、工具和事件
- 多通道收件箱:支持 WhatsApp、Telegram、飞书、微信、WebChat 等 25+ 通道
- 多 Agent 路由:将不同通道/账户/用户路由到隔离的 Agent(工作区 + 每个 Agent 独立会话)
- 语音唤醒 + 语音模式:macOS/iOS 唤醒词,Android 连续语音(支持 ElevenLabs + 系统 TTS)
- 实时画布(Live Canvas):Agent 驱动的可视化工作空间
- 一流工具支持:浏览器、画布、节点、定时任务、会话等
- 伴侣应用:macOS 菜单栏 + iOS/Android 节点
- 技能系统:引导式设置 + 内置/托管/工作区技能
- 自动化:Cron 定时任务、Webhook、后台任务
- 持久记忆:上下文和记忆 24/7 持续存在
2. 系统架构
2.1 架构概览
OpenClaw 采用 Gateway 中心化架构:
┌─────────────────────────────────────────────────────┐
│ Gateway (Daemon) │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌────────┐ │
│ │ Channels │ │ Agent │ │ Tools │ │ Cron │ │
│ │ (25+) │ │ Engine │ │ Engine │ │ Jobs │ │
│ └──────────┘ └──────────┘ └──────────┘ └────────┘ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌────────┐ │
│ │ Memory │ │ Sessions │ │ Sandbox │ │ Web │ │
│ │ Engine │ │ Manager │ │ Engine │ │Hooks │ │
│ └──────────┘ └──────────┘ └──────────┘ └────────┘ │
│ WebSocket API: 127.0.0.1:18789 │
└─────────────────────────────────────────────────────┘
▲ ▲ ▲
│ │ │
┌─────────┐ ┌─────────┐ ┌─────────┐
│ CLI │ │ macOS │ │ Web │
│ Client │ │ App │ │ UI │
└─────────┘ └─────────┘ └─────────┘
▲ ▲ ▲
│ │ │
┌─────────┐ ┌─────────┐ ┌─────────┐
│ iOS │ │ Android │ │ Nodes │
│ Node │ │ Node │ │(headless)│
└─────────┘ └─────────┘ └─────────┘
2.2 核心组件
Gateway(守护进程)
- 维护所有外部连接(消息通道、模型提供商)
- 暴露类型化的 WebSocket API(请求、响应、服务端推送事件)
- 对输入帧进行 JSON Schema 验证
- 发出事件:agent、chat、presence、health、heartbeat、cron 等
- 每个主机一个 Gateway,是唯一打开 WhatsApp 会话的地方
- 提供 Canvas host 服务(Gateway HTTP 服务器)
Clients(客户端)
- macOS App / CLI / Web Admin
- 每个客户端一个 WebSocket 连接
- 发送请求:health、status、send、agent、system-presence
- 订阅事件:tick、agent、presence、shutdown
Nodes(节点)
- macOS / iOS / Android / headless 节点
- 通过相同 WebSocket 服务器连接,声明 role: node
- 基于设备的身份配对
3. 环境要求
- Node.js:Node 24(推荐)或 Node 22.19+
- 操作系统:macOS、Linux、Windows(WSL2 推荐)
- API 密钥:需要模型提供商的 API 密钥(Anthropic、OpenAI、Google 等)
- Docker:可选,仅在需要容器化部署或沙箱时
- Git:仅在从源码构建时需要
4. 安装步骤
4.1 方法一:一键安装脚本(推荐)
macOS / Linux / WSL2:
curl -fsSL https://openclaw.ai/install.sh | bash
该脚本会自动检测操作系统、安装 Node.js(如需要)、安装 OpenClaw 并启动引导向导。
Windows(PowerShell):
irm https://openclaw.ai/install.ps1 | iex
不带引导的安装:
# macOS / Linux
curl -fsSL https://openclaw.ai/install.sh | bash -s — –skip-onboard
# Windows
irm https://openclaw.ai/install.ps1 | iex -SkipOnboard
4.2 方法二:npm / pnpm / bun
如果已管理 Node.js:
# npm
npm install -g openclaw@latest
openclaw onboard –install-daemon
# pnpm
pnpm add -g openclaw@latest
openclaw onboard –install-daemon
# bun
bun install -g openclaw@latest
openclaw onboard –install-daemon
4.3 方法三:本地前缀安装
将 OpenClaw 和 Node 保留在本地前缀(如 ~/.openclaw)下,不依赖系统级 Node:
curl -fsSL https://openclaw.ai/install-cli.sh | bash
4.4 方法四:Docker 容器
# 方式一:使用设置脚本
git clone https://github.com/openclaw/openclaw.git
cd openclaw
./deploy/scripts/docker-setup.sh
# 方式二:手动构建
docker build -t openclaw:local -f Dockerfile .
docker-compose up -d
# 方式三:使用预构建镜像
docker pull ghcr.io/openclaw/openclaw:latest
docker run -d –name openclaw ghcr.io/openclaw/openclaw:latest
4.5 方法五:从源码构建
git clone https://github.com/openclaw/openclaw.git
cd openclaw
pnpm install
pnpm openclaw setup # 首次运行或重置配置后
pnpm ui:build # 可选:预构建 Control UI
pnpm gateway:watch # 开发循环(源码/配置变更时自动重载)
4.6 方法六:Nix 包管理
nix-shell -p openclaw
# 或使用官方 Nix flake
nix profile install github:openclaw/nix-openclaw
4.7 安装后检查
# 检查版本
openclaw –version
# 检查 Gateway 状态
openclaw gateway status
# 运行诊断
openclaw doctor
5. 初始配置
5.1 交互式引导(推荐)
openclaw onboard –install-daemon
引导向导会逐步引导你:
5.2 配置文件
配置文件位置:~/.openclaw/openclaw.json
最小配置示例:
// ~/.openclaw/openclaw.json
{
agents: {
defaults: {
workspace: "~/.openclaw/workspace"
}
},
channels: {
weixin: {
allowFrom: ["+86138xxxxxxxx"]
}
}
}
完整配置示例(带飞书 + 微信):
{
// Agent 配置
agents: {
defaults: {
model: "anthropic/claude-sonnet-4",
workspace: "~/.openclaw/workspace",
sandbox: {
mode: "non-main" // 非主会话运行在沙箱中
}
}
},
// 模型配置
models: {
defaults: {
provider: "anthropic",
model: "claude-sonnet-4"
}
},
// 通道配置
channels: {
feishu: {
enabled: true,
appId: "your_feishu_app_id",
appSecret: "your_feishu_app_secret",
dmPolicy: "pairing",
groupPolicy: "allowlist",
requireMention: true
},
weixin: {
enabled: true,
allowFrom: ["+86138xxxxxxxx"]
},
webchat: {
enabled: true,
port: 18790
}
},
// 工具配置
tools: {
exec: {
enabled: true,
timeout: 300
},
browser: {
enabled: true
},
webSearch: {
enabled: true
}
}
}
5.3 通过 CLI 设置配置
# 设置单个配置项
openclaw config set agents.defaults.model "anthropic/claude-sonnet-4"
openclaw config set plugins.entries.openclaw-weixin.enabled true
openclaw config set channels.feishu.dmPolicy "pairing"
# 查看当前配置
openclaw config get
openclaw config get channels.feishu
# 导出配置
openclaw config export > my-config.json
5.4 环境变量
# 自定义配置路径
export OPENCLAW_CONFIG_PATH=/path/to/custom/openclaw.json
# 自定义状态目录
export OPENCLAW_STATE_DIR=/path/to/custom/state
# 自定义日志级别
export OPENCLAW_LOG_LEVEL=debug
6. Gateway 管理
6.1 启动与停止
# 守护进程模式(推荐)
openclaw onboard –install-daemon
# Gateway 作为 launchd(macOS)或 systemd(Linux)用户服务运行
# 前台调试模式
openclaw gateway stop # 先停止守护进程
openclaw gateway –port 18789 –verbose
# 重启
openclaw gateway restart
# 状态检查
openclaw gateway status
6.2 访问 Control UI
# 获取 Control UI 地址
openclaw ui
# 默认地址:http://127.0.0.1:18789
打开浏览器访问 Control UI,在设置中粘贴共享密钥(shared secret)。设置脚本默认将令牌写入 ~/.openclaw/token。
6.3 健康检查
# 诊断检查
openclaw doctor
# 自动修复问题
openclaw doctor –fix
# 健康状态
openclaw health
6.4 日志
# 查看日志
openclaw logs
# 实时日志
openclaw logs –follow
7. 消息通道
7.1 支持的通道总览
主流消息平台: WhatsApp、Telegram、Slack、Discord、Signal、Microsoft Teams、Google Chat、iMessage、Matrix
国内/区域平台:
- 微信(WeChat):通过腾讯外部插件 @tencent-weixin/openclaw-weixin
- 飞书(Feishu):生产就绪,WebSocket 默认模式
- QQ Bot:支持
- 元宝(Yuanbao):支持
- LINE:支持
开发者/自托管: IRC、Mattermost、Nextcloud Talk、Nostr、Tlon、Synology Chat、Twitch
Web:
- WebChat:内置 Web 聊天界面
7.2 微信(WeChat)配置
安装:
# 快速安装
npx -y @tencent-weixin/openclaw-weixin-cli install
# 手动安装
openclaw plugins install "@tencent-weixin/openclaw-weixin"
openclaw config set plugins.entries.openclaw-weixin.enabled true
openclaw gateway restart
登录:
# 运行 QR 登录(在与 Gateway 相同的机器上)
openclaw channels login –channel openclaw-weixin
# 用微信扫描二维码确认登录
# 插件将账户令牌保存到本地
多账户:
# 添加另一个微信账户
openclaw channels login –channel openclaw-weixin
# 按账户、通道和发送者隔离会话
openclaw config set channels.weixin.sessionIsolation "account-channel-sender"
配置:
{
channels: {
weixin: {
enabled: true,
allowFrom: ["+86138xxxxxxxx"], // 允许的联系人
dmPolicy: "pairing" // DM 策略
}
}
}
注意: 微信当前支持直接聊天和媒体消息,群聊支持取决于插件能力元数据。
7.3 飞书(Feishu)配置
前提: OpenClaw 2026.5.29 或更高版本
安装与配置:
# 运行通道设置向导
openclaw channels setup –channel feishu
# 选择:
# – 手动设置:粘贴飞书开放平台的 App ID 和 App Secret
# – QR 设置:自动创建机器人
# 重启 Gateway
openclaw gateway restart
访问控制:
# DM 策略
# pairing:未知用户收到配对码,通过 CLI 批准
# allowlist:仅 allowFrom 中的用户可以聊天
# open:公开 DM(需 allowFrom 包含 "*")
# disabled:禁用所有 DM
openclaw config set channels.feishu.dmPolicy "pairing"
openclaw config set channels.feishu.allowFrom ["owner_id"]
# 批准配对请求
openclaw pairing list feishu
openclaw pairing approve feishu <CODE>
群聊配置:
{
channels: {
feishu: {
enabled: true,
appId: "cli_xxxxxxxxxxxx",
appSecret: "xxxxxxxxxxxxxxxx",
dmPolicy: "pairing",
groupPolicy: "allowlist", // open / allowlist / disabled
requireMention: true, // 群组中需要 @提及
groupAllowFrom: ["chat_xxx"] // 允许的群组
}
}
}
WebSocket vs Webhook 模式:
{
channels: {
feishu: {
// WebSocket 模式(默认,推荐)
mode: "websocket",
eventStreamUrl: "https://open.feishu.cn/open-apis/im/v1/messages/",
// Webhook 模式(可选)
// mode: "webhook",
// webhookUrl: "/webhook/feishu",
// verifyToken: "your_verify_token",
// encryptKey: "your_encrypt_key"
}
}
}
消息卡片支持: 飞书支持丰富的消息卡片(message cards),包括:
- 标题和操作按钮
- 折叠面板
- 多列布局
- 代码块
- 列表和表格
7.4 WebChat 配置
WebChat 是内置的 Web 聊天界面,无需额外安装:
{
web: {
webchat: {
enabled: true,
port: 18790, // WebChat 端口
allowFrom: ["*"], // 访问控制
requireAuth: true // 是否需要认证
}
}
}
访问:http://127.0.0.1:18790
7.5 QQ Bot 配置
QQ 作为支持的通道之一,通过插件系统集成。配置方式与其他通道类似:
{
channels: {
qq: {
enabled: true,
appId: "your_qq_app_id",
appSecret: "your_qq_app_secret"
}
}
}
7.6 元宝(Yuanbao)配置
{
channels: {
yuanbao: {
enabled: true,
appId: "your_yuanbao_app_id",
appSecret: "your_yuanbao_app_secret"
}
}
}
7.7 通道通用配置
# 设置通道
openclaw channels setup –channel <channel_name>
# 登录通道
openclaw channels login –channel <channel_name>
# 查看通道状态
openclaw channels status
# 列出通道
openclaw channels list
# 发送测试消息
openclaw message send –target <channel_id> –message "Hello from OpenClaw"
7.8 配对与安全
所有通道默认使用配对策略(pairing):
# 查看待配对请求
openclaw pairing list <channel>
# 批准配对
openclaw pairing approve <channel> <CODE>
# 查看已批准的配对
openclaw pairing list <channel> –approved
8. Agent 工作区
8.1 工作区结构
~/.openclaw/workspace/
├── AGENTS.md # 注入的提示文件(Agent 指令)
├── SOUL.md # 人格指南
├── TOOLS.md # 工具文档
└── skills/ # 自定义技能
└── <skill>/
└── SKILL.md # 技能定义
8.2 AGENTS.md
定义 Agent 的行为准则和工作流程:
# Agent Instructions
You are a helpful assistant that…
## Workflow
1. First, understand the user's request
2. Then, use appropriate tools
3. Finally, deliver results
## Constraints
– Always respond in Chinese unless asked otherwise
– Use markdown formatting for code
8.3 SOUL.md
定义 Agent 的人格和风格:
# Personality Guide
## Tone
– Professional but friendly
– Direct and concise
## Style
– Use bullet points for lists
– Provide examples when explaining
– Be proactive in suggesting improvements
## Language
– Default to Chinese
– Switch to English when discussing technical terms
8.4 多 Agent 路由
{
agents: {
defaults: {
model: "anthropic/claude-sonnet-4",
workspace: "~/.openclaw/workspace"
},
// 为不同通道/用户配置不同 Agent
routes: [
{
channel: "feishu",
agent: "work-agent",
model: "anthropic/claude-sonnet-4",
workspace: "~/.openclaw/workspace-work"
},
{
channel: "weixin",
agent: "personal-agent",
model: "openai/gpt-4",
workspace: "~/.openclaw/workspace-personal"
}
]
}
}
9. 技能系统
9.1 什么是技能
技能(Skills)是教导 Agent 如何工作的可复用指令集。每个技能是一个 SKILL.md 文件。
9.2 技能类型
- 内置技能:随 OpenClaw 分发的预装技能
- 托管技能:通过 ClawHub(技能注册表)管理的技能
- 工作区技能:用户自定义的技能
9.3 创建自定义技能
# 创建技能
mkdir -p ~/.openclaw/workspace/skills/my-skill
cat > ~/.openclaw/workspace/skills/my-skill/SKILL.md << 'EOF'
# My Custom Skill
## Trigger
When the user asks about…
## Steps
1. First, do this
2. Then, do that
3. Finally, deliver results
## Examples
– User: "Do X"
Agent: Uses this skill to accomplish X
EOF
9.4 技能管理
# 列出技能
openclaw skills list
# 安装技能
openclaw skills install <skill-name>
# 卸载技能
openclaw skills uninstall <skill-name>
# 搜索技能(ClawHub)
openclaw skills search <keyword>
9.5 ClawHub 技能注册表
在线技能市场:https://clawhub.ai
# 从 ClawHub 安装
openclaw skills install clawhub:<skill-name>
9.6 斜杠命令
技能可以定义斜杠命令:
# Skill with Slash Commands
## Commands
– `/mycommand [args]` – Description of command
## Implementation
When `/mycommand` is received…
10. 插件系统
10.1 插件类型
- 工具插件:添加工具能力
- 通道插件:添加消息通道
- 提供商插件:添加模型提供商
- CLI 后端插件:添加 CLI 功能
- 钩子插件:生命周期钩子
10.2 插件管理
# 安装插件
openclaw plugins install <plugin-name>
# 启用插件
openclaw config set plugins.entries.<plugin-name>.enabled true
# 禁用插件
openclaw config set plugins.entries.<plugin-name>.enabled false
# 卸载插件
openclaw plugins uninstall <plugin-name>
# 列出已安装插件
openclaw plugins list
# 社区插件
openclaw plugins search <keyword>
10.3 内置插件
| Codex Harness | Claude Code 集成 |
| Codex Computer Use | 计算机使用能力 |
| Google Meet | Google 会议集成 |
| Workboard | 工作板 |
| Webhooks | Webhook 支持 |
| Admin HTTP RPC | 管理 HTTP API |
| Voice Call | 语音通话 |
| Memory Wiki | 记忆维基 |
| Memory LanceDB | LanceDB 记忆存储 |
| OC Path | 路径工具 |
| Zalo Personal | Zalo 个人账号 |
10.4 构建自定义插件
插件入口文件示例:
// my-plugin.ts
export default function myPlugin() {
return {
name: "my-plugin",
version: "1.0.0",
tools: [
{
name: "my_tool",
description: "Does something useful",
parameters: { /* JSON Schema */ },
handler: async (params) => {
// Tool implementation
return { result: "success" };
}
}
]
};
}
11. 自动化工具
11.1 Cron 定时任务
# 创建一次性提醒
openclaw cron create "2026-06-01T16:00:00Z" \\
–name "Reminder" \\
–session main \\
–system-event "Reminder: check the docs draft" \\
–wake now \\
–delete-after-run
# 创建重复任务
openclaw cron create "every 2h" \\
–name "Daily Summary" \\
–prompt "Summarize today's important events" \\
–deliver origin
# 列出任务
openclaw cron list
# 查看任务详情
openclaw cron get <job-id>
openclaw cron show <job-id>
# 查看运行历史
openclaw cron runs –id <job-id>
# 暂停/恢复/删除任务
openclaw cron pause <job-id>
openclaw cron resume <job-id>
openclaw cron remove <job-id>
# 立即运行任务
openclaw cron run <job-id>
Cron 表达式支持:
# 每天上午 9 点
openclaw cron create "0 9 * * *" –name "Morning Briefing" –prompt "…"
# 每 30 分钟
openclaw cron create "30m" –name "Health Check" –prompt "…"
# 每 2 小时
openclaw cron create "every 2h" –name "Status Update" –prompt "…"
11.2 Webhook
# 创建 Webhook
openclaw webhook create –name "GitHub" \\
–url "https://api.github.com/repos/…" \\
–method GET \\
–schedule "every 1h"
11.3 后台任务
在 Agent 对话中直接创建后台任务,不需要退出当前会话。
11.4 持久指令(Standing Orders)
定义 Agent 始终遵循的持久指令,存储在配置或工作区中。
11.5 钩子(Hooks)
生命周期钩子,在特定事件触发时执行:
{
hooks: {
onMessage: {
script: "~/.openclaw/hooks/on-message.sh"
},
onSessionStart: {
script: "~/.openclaw/hooks/on-session-start.sh"
}
}
}
12. 内置工具
12.1 工具类别
| 执行 | exec | 执行系统命令 |
| 文件 | read / write / edit | 读写编辑文件 |
| 进程 | process | 管理后台进程 |
| 搜索 | search_files | 文件内容/名称搜索 |
| 浏览器 | browser | 浏览器控制(CDP) |
| 网页 | web_fetch / web_search | 网页抓取/搜索 |
| 代码 | code_execution | Python 代码执行 |
| 图片 | image_generation | AI 图片生成 |
| 视频 | video_generation | AI 视频生成 |
| 音乐 | music_generation | AI 音乐生成 |
| 语音 | text_to_speech | 文本转语音 |
| 补丁 | apply_patch | 应用代码补丁 |
| 差异 | diffs | 代码差异查看 |
| pdf_tool | PDF 处理 | |
| 画布 | canvas | 可视化画布 |
| 子 Agent | sub_agents | 派生子任务 |
| 记忆 | memory | 持久记忆 |
| 会话 | sessions_* | 会话管理 |
12.2 工具策略
{
tools: {
// 默认启用的工具
defaults: {
enabled: ["exec", "read", "write", "search_files", "browser", "web_search"]
},
// 权限模式
permission: {
exec: "approve", // 需要批准
browser: "allow", // 自动允许
write: "allow", // 自动允许
memory: "allow" // 自动允许
},
// 沙箱工具(非主会话)
sandbox: {
allow: ["bash", "process", "read", "write", "edit", "sessions_list"],
deny: ["browser", "canvas", "nodes", "cron", "discord", "gateway"]
}
}
}
12.3 浏览器工具
{
tools: {
browser: {
enabled: true,
// 使用本地 Chrome CDP
cdpEndpoint: "ws://127.0.0.1:9222",
// 或使用 OpenClaw 管理的浏览器
managed: true,
viewport: {
width: 1920,
height: 1080
}
}
}
}
12.4 搜索工具
支持多种搜索引擎:
- Brave Search
- DuckDuckGo
- Exa
- Firecrawl
- Gemini Search
- Grok Search
- Kimi Search
- MiniMax Search
- Ollama Web Search
- Perplexity
- SearXNG
- Tavily
{
tools: {
webSearch: {
enabled: true,
provider: "brave", // brave / duckduckgo / exa / …
apiKey: "your_api_key"
}
}
}
12.5 思考级别
# 在对话中设置思考级别
/think low # 快速回答
/think medium # 标准思考
/think high # 深度思考
# 通过 CLI
openclaw agent –message "Ship checklist" –thinking high
13. 模型配置
13.1 支持的提供商
- Anthropic:Claude 系列(Claude Opus、Sonnet、Haiku)
- OpenAI:GPT-4、GPT-4o、o1 系列
- Google:Gemini 系列
- xAI:Grok
- 本地模型:通过 Ollama、vLLM 等
13.2 模型配置
{
models: {
defaults: {
provider: "anthropic",
model: "claude-sonnet-4",
apiKey: "sk-ant-xxxxx",
// 或从环境变量读取
// apiKeyEnv: "ANTHROPIC_API_KEY"
},
// 多提供商回退
providers: [
{
name: "anthropic",
apiKey: "sk-ant-xxxxx",
models: ["claude-sonnet-4", "claude-opus-4"]
},
{
name: "openai",
apiKey: "sk-proj-xxxxx",
models: ["gpt-4o", "o1"]
}
],
// 模型回退策略
failover: {
enabled: true,
maxRetries: 3,
retryDelay: 5000
}
}
}
13.3 OAuth 订阅
OpenClaw 支持 OAuth 订阅:
# 通过 OAuth 登录 OpenAI
openclaw auth login openai
13.4 本地模型
{
models: {
defaults: {
provider: "ollama",
model: "llama3.1:70b",
baseUrl: "http://127.0.0.1:11434"
}
}
}
13.5 模型选择建议
官方建议:“虽然支持许多提供商和模型,但优先选择你信任且已使用的提供商的旗舰模型。”
14. 安全机制
14.1 DM 访问策略
pairing(默认)→ 未知发送者收到配对码,Bot 不处理其消息
allowlist → 仅 allowFrom 列表中的用户可以聊天
open → 公开 DM(需显式 opt-in)
disabled → 禁用所有 DM
14.2 配对流程
# 查看配对请求
openclaw pairing list <channel>
# 批准配对
openclaw pairing approve <channel> <CODE>
# 发送者被添加到本地白名单存储
14.3 沙箱模式
{
agents: {
defaults: {
sandbox: {
mode: "non-main", // 非主会话运行在沙箱中
backend: "docker", // docker / ssh / openshell
tools: {
allow: ["bash", "process", "read", "write", "edit"],
deny: ["browser", "canvas", "nodes", "cron", "gateway"]
}
}
}
}
}
14.4 网络暴露安全
公开暴露 Gateway 前,必读:
- Security
- Gateway exposure runbook
- Sandboxing
14.5 安全审计
# 检查安全风险
openclaw doctor
openclaw doctor –fix
# 安全审计检查
openclaw security audit
15. 平台应用
15.1 macOS App(OpenClaw.app)
功能:
- 菜单栏控制 Gateway 和健康状态
- 语音唤醒 + 推送对讲覆盖层
- WebChat + 调试工具
- 通过 SSH 远程控制 Gateway
注意: 需要签名的构建以在 macOS 权限中持久化。
15.2 iOS 节点
功能:
- 通过 Gateway WebSocket 配对(设备配对)
- 语音触发转发 + Canvas 表面
- 通过 openclaw nodes … 控制
15.3 Android 节点
功能:
- 通过设备配对作为 WS 节点
- 暴露 Connect/Chat/Voice 标签页
- Canvas、相机、屏幕捕获
- Android 设备命令族
15.4 节点管理
# 列出节点
openclaw nodes list
# 设备配对
openclaw devices pair
# 设备管理
openclaw devices list
openclaw devices unpair <device-id>
16. 开发模式
16.1 开发循环
git clone https://github.com/openclaw/openclaw.git
cd openclaw
pnpm install
# 首次运行
pnpm openclaw setup
# 预构建 Control UI
pnpm ui:build
# 开发循环(自动重载)
pnpm gateway:watch
16.2 构建发布版本
pnpm build
pnpm ui:build
16.3 开发频道
# 切换到开发频道
openclaw update –channel dev
# 切换到稳定频道
openclaw update –channel stable
# 切换到 Beta 频道
openclaw update –channel beta
16.4 版本命名
- stable:标签发布(vYYYY.M.D 或 vYYYY.M.D-<patch>),npm dist-tag latest
- beta:预发布标签(vYYYY.M.D-beta.N),npm dist-tag beta
- dev:main 分支移动头,npm dist-tag dev
17. Docker 部署
17.1 快速开始
# 方式一:使用设置脚本
git clone https://github.com/openclaw/openclaw.git
cd openclaw
./deploy/scripts/docker-setup.sh
# 方式二:Docker Compose
docker-compose up -d
# 方式三:CLI 容器
docker run –rm -v ~/.openclaw:/root/.openclaw ghcr.io/openclaw/openclaw:latest openclaw onboard
17.2 Docker Compose 示例
version: '3.8'
services:
openclaw:
image: ghcr.io/openclaw/openclaw:latest
container_name: openclaw
restart: unless–stopped
ports:
– "18789:18789" # Gateway WebSocket
– "18790:18790" # WebChat
volumes:
– ~/.openclaw:/root/.openclaw
environment:
– OPENCLAW_CONFIG_PATH=/root/.openclaw/openclaw.json
– ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
17.3 容器 CLI
# 通过容器运行 CLI 命令
docker compose exec openclaw openclaw gateway status
docker compose exec openclaw openclaw doctor
docker compose exec openclaw openclaw config get
17.4 预构建镜像
# GitHub Container Registry
docker pull ghcr.io/openclaw/openclaw:latest
docker pull ghcr.io/openclaw/openclaw:beta
docker pull ghcr.io/openclaw/openclaw:dev
# 或按版本
docker pull ghcr.io/openclaw/openclaw:v2026.6.2
17.5 前提条件
- Docker Desktop 或 Docker Engine + Docker Compose v2
- 至少 2 GB RAM 用于镜像构建(1 GB 主机可能 OOM 被杀)
- 足够的磁盘空间用于镜像和日志
18. 更新与维护
18.1 更新
# 更新到最新版本
openclaw update
# 更新到特定版本
openclaw update –version v2026.6.2
# 更新到开发频道
openclaw update –channel dev
# 更新后运行诊断
openclaw doctor
18.2 诊断
# 全面诊断
openclaw doctor
# 自动修复
openclaw doctor –fix
# 查看 Gateway 状态
openclaw gateway status
# 查看日志
openclaw logs
openclaw logs –follow
18.3 迁移
- 从 Claude Code 迁移:openclaw migrate from-claude
- 从 Hermes 迁移:openclaw migrate from-hermes
18.4 卸载
# 停止并卸载守护进程
openclaw onboard –uninstall-daemon
# 卸载 npm 包
npm uninstall -g openclaw
# 删除数据
rm -rf ~/.openclaw
19. 评价与总结
19.1 优势
19.2 适用场景
- 个人 AI 助手:日常任务自动化、信息检索、日程管理
- 工作助手:代码审查、项目管理、文档生成
- 家庭助手:智能家居控制、提醒、监控
- 团队工具:多渠道消息统一处理
- 开发工具:自动化测试、CI/CD 集成
19.3 注意事项
19.4 资源链接
| GitHub | https://github.com/openclaw/openclaw |
| 官方文档 | https://docs.openclaw.ai |
| 官方网站 | https://openclaw.ai |
| 技能市场 | https://clawhub.ai |
| 入门指南 | https://docs.openclaw.ai/start/getting-started |
| Docker 部署 | https://docs.openclaw.ai/install/docker |
| 配置参考 | https://docs.openclaw.ai/gateway/configuration |
| 安全指南 | https://docs.openclaw.ai/gateway/security |
| 架构文档 | https://docs.openclaw.ai/concepts/architecture |
| FAQ | https://docs.openclaw.ai/help/faq |
| Discord 社区 | https://discord.gg/clawd |
报告生成时间:2026-06-02 基于 OpenClaw 官方文档和 GitHub 仓库调研



