Skip to content

Modes, capabilities, sandbox ​

Generated from docs/standards/hosted-mode.md · npm run docs:gen

Tests: tests/runs.test.ts.

Modes (server/lib/mode.mjs) ​

One switch: --hosted or WORLD_MODE=hosted. No other "cloud" branch outside server/host/ (H1) and client/features/hosted/.

LocalHosted
Listen127.0.0.1WORLD_BIND (the VM's private address)
AuthX-World-Token (random, once by the URL)X-World-Auth signed by the gateway, no token in the browser
Originthe local originWORLD_PUBLIC_ORIGIN (https), and Host must be its host
/api/game.host{ os, arch, mode: "local", has: [gui, audio, keychain, terminal, …], machine }{ os: "linux", mode: "hosted", has: [], machine } (overrides: WORLD_HOST_HAS, WORLD_HOST_MACHINE; machine: resources)

Signature: X-World-Auth: v1.<unix seconds>.<hex HMAC-SHA256(WORLD_HOST_SECRET, "<s>\n<METHOD>\n<path+query>")>, valid ±60 s, on every request. WORLD_HOST_SECRET is at least 32 characters. modeProblems() lists what is missing; the server exits 2 if anything is. Helpers: sign, signedOk, hostOk, originOk, describeHost.

describeHost() adds, in hosted mode only, tier from WORLD_TIER (free or paid; set by the control plane, refreshed by H1 through /api/host) and, in both modes, axis from WORLD_AXIS (^[a-z][a-z0-9-]{0,31}$, else ignored), arm from WORLD_ARM (same shape) and item from WORLD_ITEM (^[a-z0-9][a-z0-9-]{0,47}$). The control plane sets all three when it gives a VM its identity (alta.control/0.2, cloud/control/core/control.ts). A hosted server proves core.arrive (server/checks/proven.mjs).

Routes of a hosted world toward its control plane (server/routes/host.mjs, through the world agent on 127.0.0.1, which adds the VM's own secret; in local mode they send nothing):

RouteWhat
GET /api/host{ mode, tier, endsAt, energy }: the end of a free world and the LLM energy left
POST /api/host/events{ type: quest | first-reply | heard | paywall, value?, detail? }: the funnel, no content
GET /api/host/plansthe paid plans a free world can become (sizes, monthly prices, what each runs)
POST /api/host/checkout{ plan } → { url }: the payment provider's page for this world. The card is typed there only, never in the game; the world becomes paid only by the provider's signed webhook, on the same VM (bigger, no end).

The checkout route needs no capability: it moves no money, it only opens the provider's page (pay stays for executors that would pay from the game).

The client reads ?host=local|hosted|hosted-paid and ?axis=<id> only when the world served is the demo state (or there is no server): they replace the host shown (never the capabilities or the authentication). On a real world they are ignored.

Capabilities (server/lib/caps.mjs) ​

ask, install, setup, forge, pay, turned on by --allow-<cap>. Hosted opens ask and install by default (--no-ask, --no-install to close). pay stays off everywhere until decision P3. /api/game gives caps. A route or executor whose capability is off answers 403 with the flag to use.

Sandbox (server/lib/sandbox.mjs) ​

WORLD_SANDBOX=1 (every test): assertSandbox(home) refuses a home outside the temporary directory or equal to the real home, and bins refuses any program outside tests/fakes/. No test reads the real home or calls the real openclaw.

Alta OS is open source (MIT).