Overview
The Allternit Cloud Backend is a lightweight WebSocket relay that connects browser extensions, thin clients, and agent runtimes into a single real-time session. It is the glue layer for integrations that need to execute actions inside a browser or exchange messages with a lightweight control surface without running a full agent locally. Built fromcmd/cloud-backend, the service runs as a standalone Node process and exposes:
- A WebSocket endpoint for bidirectional messaging.
- An HTTP health endpoint for load balancers and orchestrators.
- Per-session routing so multiple clients can share a single context.
- Automatic stale-connection cleanup.
The Cloud Backend relays messages between clients in the same session. It does not run model inference itself; reasoning is handled by the agent or runtime that connects as a controlling client.
When to use it
Key concepts
Session
Every WebSocket connection is assigned asessionId when it first connects. Messages that are marked for broadcast are forwarded to all authenticated clients in the same session, so a browser extension and a thin client stay in sync.
Client types
Message envelope
All WebSocket traffic uses the same envelope:Installation
The service is a TypeScript Node project incmd/cloud-backend.
- Node.js 18 or later
- WebSocket clients must be able to reach
ws://<host>:<port>/ws/extension
Configuration
Configure the service with environment variables:
You can run multiple instances behind a load balancer as long as clients that need to share a session land on the same instance. For horizontal scaling, replace the in-memory
clients and sessions maps with a shared store such as Redis.
HTTP endpoints
Health check
WebSocket endpoint
Authentication
After connecting, send anauth message:
Message types
Usage examples
Browser extension + agent
A browser extension connects and authenticates:execute message to the browser extension, which performs the action and sends back an action:complete message. The server broadcasts that completion to every other client in the session:
Request browser tabs
A controlling client asks for the current tab list:tabs message. If no extension is connected, the server replies immediately with an empty array:
Thin client chat
A thin client sends:chat messages to your agent runtime and stream the model response back as one or more chat:response messages.
JavaScript client snippet
Session broadcast
The server automatically broadcasts these message types to all other authenticated clients in the same session:action:completetab:activatedtab:updated
Keepalive and cleanup
Every 30 seconds the server sends a WebSocket ping and checks the time since the last message or pong from each client. Connections that are silent for more than 60 seconds are closed with code1001 and removed from the session.
Clients should respond to application-level ping messages with a pong:
Error handling
Security notes
- Run the Cloud Backend behind a reverse proxy or API gateway that terminates TLS in production.
- Replace the default token acceptance logic with validation against your identity provider.
- For multi-instance deployments, move session state from in-memory maps to a shared store so clients can reconnect to any instance.
- Restrict CORS origins instead of using
*if the service is exposed to the public internet.