Gateway Control Plane Overview
The Gateway is the nerve center of OpenClaw -- a WebSocket-based control plane through which all clients, channels, and services communicate.
Source Location
src/gateway/
├── server.impl.ts # Gateway server main implementation
├── server.ts # Export entry
├── auth.ts # Authentication and authorization
├── client.ts # Client SDK
├── server-methods.ts # Method dispatch center
├── server-methods-list.ts # Method list
├── server-methods/ # 43 handler modules
├── server/ # Server core components
├── protocol/ # Protocol definitions
├── config-reload.ts # Config hot-reload
├── session-utils.ts # Session utilities
├── sessions-patch.ts # Session patching
├── hooks.ts # Gateway Hooks
├── hooks-mapping.ts # Hook mapping
├── call.ts # RPC call wrapper
├── server-http.ts # HTTP server
├── server-startup.ts # Startup sequence
├── server-close.ts # Shutdown sequence
├── server-runtime-state.ts # Runtime state
├── server-runtime-config.ts # Runtime configuration
├── server-broadcast.ts # Broadcast mechanism
├── server-channels.ts # Channel management
├── server-chat.ts # Chat handler
├── server-cron.ts # Cron jobs
├── server-discovery.ts # Service discovery
├── server-plugins.ts # Plugin management
└── ws-log.ts # WebSocket loggingCore Concepts
| Concept | Description | Source File |
|---|---|---|
| RequestFrame | Client request frame | protocol/index.ts |
| ResponseFrame | Server response frame | protocol/index.ts |
| EventFrame | Server push event | protocol/index.ts |
| GatewayServer | Server runtime type | server.impl.ts |
| GatewayClient | Client SDK | client.ts |
| Method Handler | Method handler | server-methods/ |
Default Port
The Gateway listens on ws://127.0.0.1:18789 by default. The port is configurable.
Authentication Modes
The Gateway supports three authentication methods:
| Mode | Description |
|---|---|
| Token | Pre-shared token comparison (timing-safe) |
| Password | Password authentication |
| Tailscale | Device identity verification via Tailscale whois |
Chapter Navigation
- WebSocket Server -- Server implementation, protocol frames, method dispatch
- Session Management -- Session model, state persistence, patching
- Configuration System -- Config loading, hot-reload strategy, reload rules