AgentRelay is a lightweight, self-hosted orchestration platform for AI coding agents.
AgentRelay uses a reverse-connection architecture where Runners dial the HQ server:
- HQ (Control Plane): Centralized server managing authentication, session state, and web UI
- Runner (Execution Plane): Lightweight daemon executing commands and streaming PTY output
- Protocol: WebSocket-based (binary frames for PTY data, text frames for control)
- Go 1.23+
- Node.js 18+ and pnpm
- Linux/macOS (PTY support required)
make buildOr manually:
go build -o bin/hq ./cmd/hq
go build -o bin/runner ./cmd/runnermake run-hq
# or
./bin/hqHQ will start on port 8080 by default. You can change this with the PORT environment variable.
make run-runner
# or
./bin/runner --runner-id my-runner --token dev-tokenConfiguration options:
--hq-url: WebSocket URL of HQ (default:ws://localhost:8080/ws/runner)--runner-id: Unique identifier for this runner (default: hostname)--token: Authentication token (default: "dev-token")
Environment variables:
HQ_URL: Same as --hq-urlRUNNER_ID: Same as --runner-idRUNNER_TOKEN: Same as --token
cd web
pnpm install
pnpm devFrontend will be available at http://localhost:5173 (or next available port).
docker-compose up- Start HQ:
./bin/hq - Start Runner:
./bin/runner --runner-id test-runner --token dev-token - Start Frontend:
cd web && pnpm dev - Open browser to http://localhost:5173
- Select runner from the list
- Click Connect to start a terminal session
You should see a bash terminal that accepts input and displays output in real-time.
├── cmd/
│ ├── hq/ # HQ server entry point
│ └── runner/ # Runner entry point
├── internal/
│ ├── server/ # HTTP/WS handlers for HQ
│ ├── agent/ # PTY logic for Runner
│ ├── protocol/ # Shared message definitions
│ └── websocket/ # WebSocket utilities
├── web/ # React frontend
│ └── src/
│ ├── components/
│ │ └── Terminal.tsx
│ └── ...
└── specs/ # LeanSpec documentation
- Backend: Go 1.23+
- Web Framework: Gin
- WebSocket: gorilla/websocket
- PTY: creack/pty
- Frontend: React + TypeScript + Vite
- Terminal: xterm.js
Apache 2.0