Gateway architecture
기준일: 2026-07-26
공식 기준: Gateway architecture
Gateway architecture 문서는 OpenClaw 공식 문서(concepts/architecture)를 한국어로 정리한 가이드입니다. WebSocket gateway architecture, components, and client flows 명령·설정 키·코드 예시는 공식 문서를 그대로 보존하며, 해석과 절차 안내는 한국어로 제공합니다. 최종 동작은 설치된 CLI 버전과 공식 원문을 확인하세요.
핵심 요약
WebSocket gateway architecture, components, and client flows
한국어 가이드 범위: concepts/architecture 경로의 설정·명령·제약·예시를 학습용으로 재구성합니다.
문서 구성
공식 문서의 주요 섹션은 다음과 같습니다.
- 개요
- Components and flows
- Gateway (daemon)
- Clients (mac app / CLI / web admin)
- Nodes (macOS / iOS / Android / headless)
- WebChat
- Connection lifecycle (single client)
- Wire protocol (summary)
- Pairing and local trust
- Protocol typing and codegen
- Remote access
- Operations snapshot
- Invariants
- 관련 문서
상세 내용
개요
Baileys, Telegram via grammY, Slack, Discord, Signal, iMessage, WebChat).
위 내용은 공식 문서의 해당 섹션 요지입니다. 세부 플래그·기본값은 원문과
--help를 확인하세요.
주요 항목:
- A single long-lived Gateway owns all messaging surfaces (WhatsApp via
- Control-plane clients (macOS app, CLI, web UI, automations) connect to the
- Nodes (macOS/iOS/Android/headless) also connect over WebSocket, but
- One Gateway per host; it is the only place that opens a WhatsApp session.
- The canvas host is served by the Gateway HTTP server under:
/__openclaw__/canvas/(agent-editable HTML/CSS/JS)/__openclaw__/a2ui/(A2UI host)
Components and flows
이 섹션의 세부 항목은 공식 문서 Components and flows를 참고하세요.
Gateway (daemon)
주요 항목:
- Maintains provider connections.
- Exposes a typed WS API (requests, responses, server-push events).
- Validates inbound frames against JSON Schema.
- Emits events like
agent,chat,presence,health,heartbeat,cron.
Clients (mac app / CLI / web admin)
주요 항목:
- One WS connection per client.
- Send requests (
health,status,send,agent,system-presence). - Subscribe to events (
tick,agent,presence,shutdown).
Nodes (macOS / iOS / Android / headless)
approval lives in the device pairing store.
위 내용은 공식 문서의 해당 섹션 요지입니다. 세부 플래그·기본값은 원문과
--help를 확인하세요.
주요 항목:
- Connect to the same WS server with
role: node. - Provide a device identity in
connect; pairing is device-based (rolenode) and - Expose commands like
canvas.*,camera.*,screen.record,location.get.
WebChat
주요 항목:
- Static UI that uses the Gateway WS API for chat history and sends.
- In remote setups, connects through the same SSH/Tailscale tunnel as other
Connection lifecycle (single client)
sequenceDiagram
participant Client
participant Gateway
Client->>Gateway: req:connect
Gateway-->>Client: res (ok)
Note right of Gateway: or res error + close
Note left of Client: payload=hello-ok<br>snapshot: presence + health
Gateway-->>Client: event:presence
Gateway-->>Client: event:tick
Client->>Gateway: req:agent
Gateway-->>Client: res:agent<br>ack {runId, status:"accepted"}
Gateway-->>Client: event:agent<br>(streaming)
Gateway-->>Client: res:agent<br>final {runId, status, summary}
Wire protocol (summary)
generated dump of every callable helper route.
위 내용은 공식 문서의 해당 섹션 요지입니다. 세부 플래그·기본값은 원문과
--help를 확인하세요.
주요 항목:
- Transport: WebSocket, text frames with JSON payloads.
- First frame must be
connect. - After handshake:
- Requests:
{type:"req", id, method, params}→{type:"res", id, ok, payload|error} - Events:
{type:"event", event, payload, seq?, stateVersion?} hello-ok.features.methods/eventsare discovery metadata, not a- Shared-secret auth uses
connect.params.auth.tokenor - Identity-bearing modes such as Tailscale Serve
- Private-ingress
gateway.auth.mode: "none"disables shared-secret auth - Idempotency keys are required for side-effecting methods (
send,agent) to - Nodes must include
role: "node"plus caps/commands/permissions inconnect.
Pairing and local trust
also binds platform and deviceFamily; the gateway pins paired metadata on reconnect and requires repair pairing for metadata changes.
위 내용은 공식 문서의 해당 섹션 요지입니다. 세부 플래그·기본값은 원문과
--help를 확인하세요.
주요 항목:
- All WS clients (operators + nodes) include a device identity on
connect. - New device IDs require pairing approval; the Gateway issues a device token
- Direct local loopback connects can be auto-approved to keep same-host UX
- OpenClaw also has a narrow backend/container-local self-connect path for
- Tailnet and LAN connects, including same-host tailnet binds, still require
- All connects must sign the
connect.challengenonce. Signature payloadv3 - Non-local connects still require explicit approval.
- Gateway auth (
gateway.auth.*) still applies to all connections, local or
Protocol typing and codegen
주요 항목:
- TypeBox schemas define the protocol.
- JSON Schema is generated from those schemas.
- Swift models are generated from the JSON Schema.
Remote access
주요 항목:
- Preferred: Tailscale or VPN.
- Alternative: SSH tunnel
- The same handshake + auth token apply over the tunnel.
- TLS + optional pinning can be enabled for WS in remote setups.
ssh -N -L 18789:127.0.0.1:18789 user@gateway-host
Operations snapshot
주요 항목:
- Start:
openclaw gateway(foreground, logs to stdout). - Health:
healthover WS (also included inhello-ok). - Supervision: launchd/systemd for auto-restart.
Invariants
주요 항목:
- Exactly one Gateway controls a single Baileys session per host.
- Handshake is mandatory; any non-JSON or non-connect first frame is a hard close.
- Events are not replayed; clients must refresh on gaps.
관련 문서
주요 항목:
- Agent Loop — detailed agent execution cycle
- Gateway Protocol — WebSocket protocol contract
- Queue — command queue and concurrency
- Security — trust model and hardening
실습 체크리스트
- 공식 문서와 로컬 버전을 대조합니다:
https://docs.openclaw.ai/concepts/architecture - 관련 CLI는
openclaw --help및 하위 명령--help로 옵션을 확인합니다. - 설정 변경 시
openclaw config/openclaw doctor로 유효성을 검사합니다. - Gateway·채널·플러그인 변경 후에는 필요 시 Gateway를 재시작합니다.
자주 쓰는 명령·설정 예시
sequenceDiagram
participant Client
participant Gateway
Client->>Gateway: req:connect
Gateway-->>Client: res (ok)
Note right of Gateway: or res error + close
Note left of Client: payload=hello-ok<br>snapshot: presence + health
Gateway-->>Client: event:presence
Gateway-->>Client: event:tick
Client->>Gateway: req:agent
Gateway-->>Client: res:agent<br>ack {runId, status:"accepted"}
Gateway-->>Client: event:agent<br>(streaming)
Gateway-->>Client: res:agent<br>final {runId, status, summary}
ssh -N -L 18789:127.0.0.1:18789 user@gateway-host
관련 링크
이 가이드는 공식 문서를 한국어 학습용으로 재구성한 것입니다. 옵션 기본값·플래그 이름은 설치 버전에 따라 달라질 수 있습니다.