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
- Loads an existing runtime identity from
~/.config/allternit/runtime-identity.json. - If no identity exists, performs first-party runtime pairing with the cloud API.
- Sends periodic heartbeats and rotates the device credential before expiry.
- Opens an outbound WebSocket to the cloud runtime relay.
- Proxies relayed requests from the browser into the local Gizzi gateway.
- 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: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
- Generate an Ed25519 keypair.
- POST
/api/v1/runtime-pairingswith the public key and capabilities. - Display the
userCodeandverificationUrlto the user. - Poll
POST /api/v1/runtime-pairings/exchangewith a signature overallternit-runtime-pairing:<pairingId>:<challenge>. - Store the returned identity.
Hosted auto-pairing
WhenALLTERNIT_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:
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.
401 or 403 during heartbeat, the daemon exits with an error indicating the runtime was revoked.
Running the daemon
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.