Skip to main content
The event bus is a WebSocket server that connects every component of the swarm. The 13 Hive subsystems publish state changes, agents publish lifecycle events, the circuit breaker publishes alerts, the kill chain publishes incident phases. Any client can subscribe to any channel and receive events in real time.

Channels

Usage

Ring Buffers

Each channel keeps the last 1,000 events in a ring buffer. Late-connecting clients can request history:
The server responds with the most recent events from that channel’s buffer.

Client Protocol

Clients connect via WebSocket to ws://host:port. On connect, automatically subscribed to all channels. They can manage subscriptions and send commands:
Commands sent via command are forwarded to the hive channel as HIVE_DIRECTIVE events. The Hive picks them up on its next oversight cycle.

Event Format

Every event follows the SwarmEvent structure:
Over the wire, events are JSON:

Event Types

Thread Safety

The event bus runs as an asyncio WebSocket server. Agents and the Hive publish from the async event loop using await bus.publish(). The circuit breaker and engine callbacks run in threads, so they use bus.publish_sync() which calls asyncio.run_coroutine_threadsafe() to cross the thread/async boundary safely.

Building a Custom Client

Any WebSocket client can connect:
JavaScript/TypeScript, Go, Rust, or any language with WebSocket support works the same way. Plain JSON over WebSocket.