Open Source · MIT · v1.0

Sessions that
never die.

ClawTerm is a session-persistent binary protocol for AI agent terminals. Inspired by X.25 packet switching and IBM SNA. Built in C. Runs as a Kubernetes DaemonSet. Your AI sessions survive network drops, device switches, and reboots — because the session never closes.

View on GitHub → Read the Spec
15B Frame overhead
10K+ Sessions per core
~2MB Container image
0 GC pauses (C)
7220 TCP port (VT220 nod)

Features

What makes ClawTerm different

Every design decision exists because HTTP/WebSocket is the wrong foundation for persistent AI agent sessions.

SUSPEND / RESUME
Sessions survive any network interruption. Disconnect on laptop, reconnect on phone. Full context. Zero re-initialization. The agent never knew you left.
📦
15-Byte Frame Header
Binary wire format inspired by HDLC. FLAG + SESSION_ID + SEQ + TYPE + FLAGS + LEN. No HTTP headers. No WebSocket framing. An order of magnitude leaner.
🔌
Pod-Native IPC
Communicates with agent pods via Unix domain sockets. Zero network hop. inotify-based pod registry — new pods auto-discovered when their socket file appears.
🏗️
K8s DaemonSet
One clawtermd per node. Sessions are node-local. hostPath volume shares socket directory with agent pods. Deploys in seconds with kubectl apply.
♾️
Session Ring Buffer
256KB outbound buffer per session. On RESUME, missed frames are replayed automatically. The client picks up exactly where it left off.
🔒
TLS 1.3 + QUIC
TCP path: TLS 1.3 mandatory. QUIC path (port 7221): connection migration for mobile — change IP without dropping session. Built-in encryption, no add-ons.

Protocol Spec

Wire format

Everything on the wire. 15 bytes of overhead. Big-endian. CRC-16/IBM checksum.

clawterm wire format
// ClawTerm frame — 15 bytes fixed overhead + payload + CRC16
[FLAG:1][SESSION_ID:4BE][SEQ:4BE][TYPE:1][FLAGS:1][LEN:2BE][PAYLOAD:N][CRC16:2BE]

// FLAG is always 0x7E — deliberate HDLC homage
// All multi-byte fields are big-endian (network byte order)
// CRC covers FLAG through end of PAYLOAD
TypeValueDirectionDescription
CT_CONNECT0x01C→SEstablish new session
CT_ACCEPT0x02S→CSession accepted, return session_id
CT_RESUME0x03C→SReconnect to existing session
CT_RESUMED0x04S→CResume ack + replay buffered frames
CT_DATA0x10BothAgent I/O payload
CT_KEEPALIVE0x20BothSession heartbeat (30s interval)
CT_SUSPEND0x30C→SClient going away — session stays warm
CT_DISCONNECT0x40BothClean session teardown

Why ClawTerm

HTTP/WebSocket was never the right answer

HTTP is a stateless document delivery protocol. AI agents need persistent sessions. ClawTerm is built for the problem, not bolted onto a workaround.

Capability WebSocket ClawTerm
Session persistenceApp-layer onlyProtocol-native
Mobile disconnectSession diesSUSPEND / RESUME
Multi-device resumeNew sessionAny device, full context
Frame overheadHTTP headers + framing15 bytes
Concurrency modelThread / goroutine per connepoll, 10K+ / core
Pod IPCNetwork requiredUnix socket, zero-hop
Mobile transportTCP onlyQUIC (connection migration)
GC pausesRuntime-dependentZero (C)

Quick Start

Deploy in minutes

bash
$ git clone https://github.com/lonestar62/clawterm
$ cd clawterm
$ make
# or for ARM64 (Apple Silicon, Raspberry Pi, lobster-1)
$ make arm64

# Deploy on Kubernetes
$ kubectl apply -f k8s/daemonset.yaml

# Or run directly
$ ./clawtermd -p 7220 -s /run/claw/sockets
clawtermd v1 starting (port 7220, sockets: /run/claw/sockets)

Built into ClawForge

ClawTerm is the transport layer powering ClawForge — the customer session layer for AI agents. Deploy AI employees that know your business, with sessions that never drop.

Learn about ClawForge →