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 from cmd/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 a sessionId 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 in cmd/cloud-backend.
For local development:
Requirements:
  • 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

Response:

WebSocket endpoint

Connect, authenticate, and then send messages. The server closes the connection if authentication fails.

Authentication

After connecting, send an auth message:
Success response:
Failure response:
The default implementation accepts any non-empty token and derives a user ID from it. Production deployments should validate tokens against your auth service before accepting the connection.

Message types

Usage examples

Browser extension + agent

A browser extension connects and authenticates:
An agent in the same session requests a click:
The server forwards the 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:
If no browser extension is connected, the caller receives:

Request browser tabs

A controlling client asks for the current tab list:
If a browser extension is connected, the message is forwarded to it and the extension returns a tabs message. If no extension is connected, the server replies immediately with an empty array:

Thin client chat

A thin client sends:
The default implementation echoes the message:
In a production deployment, route 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:complete
  • tab:activated
  • tab:updated
This keeps a thin client, browser extension, and agent runtime synchronized without each client tracking the others directly.

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 code 1001 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.