Overview

The Allternit Agent Daemon (@allternit/agent-daemon) is a TypeScript/Node daemon that runs on a self-hosted or managed runtime. It pairs the box with the Allternit Cloud API using the runtime pairing protocol, then maintains an outbound WebSocket relay so the browser can proxy requests to the local Gizzi Runtime without exposing any inbound ports. The daemon is bundled into the Allternit Hosted Runtime container and can also be installed directly on a VPS, desktop, or CI worker.

What the daemon does

  1. Loads an existing runtime identity from ~/.config/allternit/runtime-identity.json.
  2. If no identity exists, performs first-party runtime pairing with the cloud API.
  3. Sends periodic heartbeats and rotates the device credential before expiry.
  4. Opens an outbound WebSocket to the cloud runtime relay.
  5. Proxies relayed requests from the browser into the local Gizzi gateway.
  6. Bridges WebSocket connections for streaming endpoints such as terminals, event streams, and panes.

Configuration

The daemon is configured through environment variables:

Identity file

The identity file stores the Ed25519 keypair and device token. It must be readable only by the owner:
The daemon creates the parent directory with mode 0700 and the file with mode 0600. If the file is malformed, it is renamed with a .invalid-<timestamp> suffix and pairing restarts.

Pairing flow

Standard pairing

  1. Generate an Ed25519 keypair.
  2. POST /api/v1/runtime-pairings with the public key and capabilities.
  3. Display the userCode and verificationUrl to the user.
  4. Poll POST /api/v1/runtime-pairings/exchange with a signature over allternit-runtime-pairing:<pairingId>:<challenge>.
  5. Store the returned identity.

Hosted auto-pairing

When ALLTERNIT_PAIRING_MODE=hosted_auto, the daemon uses the hosted bootstrap token to create an already-approved pairing and exchanges it in one step.

Relay protocol

After pairing, the daemon connects to:
It authenticates with:
Relay message types handled by the daemon: The daemon validates that every proxied path starts with an allowed gateway prefix such as /api, /terminal, /cowork, /rails, /ws, /panes, or /v1.

Heartbeat and credential rotation

  • Heartbeat interval: 30 seconds.
  • Device credentials expire after 90 days.
  • Rotation begins 7 days before expiry (ROTATION_SKEW_MS).
  • A 15-minute grace window allows multiple components sharing the same token to self-heal after rotation.
If the cloud API responds with 401 or 403 during heartbeat, the daemon exits with an error indicating the runtime was revoked.

Running the daemon

Or with environment overrides:
In development you can run from source:

Error codes and log messages

Security properties

  • The runtime never receives or stores the human’s Clerk JWT.
  • Pairing exchange requires proof of possession of the Ed25519 private key.
  • Outbound-only relay: no public inbound port is required.
  • Provider credentials and platform encryption keys never leave the runtime.