Skip to content

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 logging

Core Concepts

ConceptDescriptionSource File
RequestFrameClient request frameprotocol/index.ts
ResponseFrameServer response frameprotocol/index.ts
EventFrameServer push eventprotocol/index.ts
GatewayServerServer runtime typeserver.impl.ts
GatewayClientClient SDKclient.ts
Method HandlerMethod handlerserver-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:

ModeDescription
TokenPre-shared token comparison (timing-safe)
PasswordPassword authentication
TailscaleDevice identity verification via Tailscale whois

Chapter Navigation

  1. WebSocket Server -- Server implementation, protocol frames, method dispatch
  2. Session Management -- Session model, state persistence, patching
  3. Configuration System -- Config loading, hot-reload strategy, reload rules

OpenClaw Source Code Tutorial