Gateway 运行时
OpenClaw Gateway 运行时学习地图:理解 Gateway、配置、Agent、Channel、安全远程访问和自动化边界。
这一组进入 OpenClaw 的运行时核心:Gateway 为什么是长期进程,配置为什么必须严格校验,Agent 和 Channel 如何分层,远程访问怎样不暴露控制面,以及 cron、tasks、hooks、heartbeat 应该各自负责什么。
适合从这里继续的人:你已经能安装 OpenClaw、完成 onboarding、打开 Dashboard、发第一条消息。现在要理解它为什么能常驻、怎么接消息渠道、怎么控安全、怎么开始自动化。
1. 这一组包含什么
Gateway 运行时一共 6 章:
- Gateway 架构:理解长驻进程、WebSocket 控制面、nodes、pairing 和本机默认入口。
- Gateway 配置:理解 strict schema、reload mode、health、doctor、Config RPC 和重启边界。
- Agent 配置:理解 workspace、repoRoot、skills、bootstrap、模型目录、session 和多 Agent 路由。
- Channel 配置:理解 DM policy、group policy、mention gating、多账号和模型覆盖。
- 安全与远程访问:理解个人助手信任模型、security audit、Control UI、Tailscale 和 SSH tunnel。
- 自动化:理解 cron、tasks、task flow、standing orders、hooks 和 heartbeat 的选择边界。
flowchart TD
Architecture["Gateway 架构"]
Config["Gateway 配置"]
Agent["Agent 配置"]
Channel["Channel 配置"]
Security["安全与远程访问"]
Automation["自动化"]
Next["渠道专项 / CLI reference"]
Architecture --> Config
Config --> Agent
Agent --> Channel
Channel --> Security
Security --> Automation
Automation --> Next
style Architecture fill:#e0f2fe,stroke:#0284c7,stroke-width:2px
style Agent fill:#dcfce7,stroke:#22c55e,stroke-width:2px
style Security fill:#fee2e2,stroke:#ef4444,stroke-width:2px
style Automation fill:#fef3c7,stroke:#f59e0b,stroke-width:2px
2. 章节入口
Gateway 架构
长驻 Gateway、WebSocket 控制面、nodes、pairing、远程访问和运行不变量。
Gateway 配置
配置文件、schema、热加载、RPC 更新、health、doctor 和排障顺序。
Agent 配置
workspace、repoRoot、skills、bootstrap、模型目录、session 和多 Agent 路由。
Channel 配置
Telegram、Discord、Slack、WhatsApp 等渠道的 DM、群组、mention 和模型覆盖。
安全与远程访问
个人助手信任模型、allowlist、pairing、security audit、Tailscale 和 SSH tunnel。
自动化
cron、tasks、task flow、standing orders、hooks 和 heartbeat 的选择边界。
3. 推荐阅读顺序
- 先看 Gateway 架构,确认 OpenClaw 不是一次性 CLI,而是一个长期运行的控制面。
- 再看 Gateway 配置,理解
openclaw.json、严格 schema、热加载和重启边界。 - 接着看 Agent 配置,把 workspace、skills、模型、session 和多 Agent 路由分清。
- 然后配置 Channel,先用 pairing 或 allowlist 小范围接入,再扩到群组和多账号。
- 远程访问放在安全之后做,不要先把端口公开到公网。
- 最后加自动化,把周期任务、事件 hooks 和长期授权分开。
如果你按问题跳读:
- Gateway 为什么必须常驻:看 Gateway 架构。
- 改配置后为什么没有生效:看 Gateway 配置。
- 同一个入口为什么会路由到不同 Agent:看 Agent 配置和 Channel 配置。
- 陌生人能不能给 Agent 发消息:看 Channel 配置和安全远程访问。
- 定时任务、事件触发、心跳老是混:看自动化。
跳读时先判断问题入口:Gateway 不稳定先看架构和配置;回复错 Agent 先看 bindings;陌生输入能触发工具先看 Channel 和安全;定时任务混乱才看自动化。
4. 先不要做什么
运行时阶段最危险的不是“不会配置”,而是过早开放边界:
- 不要先把 Gateway 端口公开到公网。
- 不要把
dmPolicy设成open后忘记访问控制。 - 不要让群聊默认所有消息都触发 Agent。
- 不要把个人 workspace 给 shared Agent 复用。
- 不要把 standing orders 当成一次性任务清单。
- 不要用 hooks 接未知来源请求后直接开放工具权限。
安全顺序不要反过来:先明确谁能进来、能触发哪个 Agent、能用哪些 tools,再考虑远程访问和自动化。
5. 完成后的验收标准
读完这一组,你应该能做到:
- 能解释 Gateway、Agent、Channel、Workspace 的分工。
- 能判断一个配置改动是热加载、自动重启,还是需要手动重启。
- 能为个人 DM、群聊、共享入口选择合适的访问策略。
- 能说明为什么 OpenClaw 是个人助手信任模型,不是多租户安全边界。
- 能安全选择 Control UI、Tailscale、SSH tunnel 或本机访问。
- 能分清 cron、tasks、task flow、standing orders、hooks、heartbeat。
这一组的结束状态:你能解释每个入口如何进入 Gateway、如何选中 Agent、如何隔离 session,以及为什么远程访问不能绕过 auth 和 pairing。