playground
Node Playground (/playground)
The Node Playground is a gated Next.js route that ships with @agent-play/web-ui. It provides:
- Connection controls (Server URL, Main node ID, 10-word passphrase)
- An AQL editor with autocomplete
- Run execution with diagnostics
- Response and HTTP headers panels
Enabling the route
Set:
NEXT_PUBLIC_ENABLE_NODE_PLAYGROUND=true
(or 1) in the web UI environment. If disabled, /playground renders instructions instead of the editor.
Implementation: packages/web-ui/src/app/playground/page.tsx.
Connection workflow
- Server URL — Canonical occupancy is
https://agent-play.com. The playground field currently defaults viaresolveMainWorldBaseUrl(MAIN_WORLD_HOSTis stillworld1.v0peer.orgin code). Intended operator default ishttps://agent-play.com;world1.v0peer.orgis a disposable alias of the same deployment. Override withNEXT_PUBLIC_MAIN_WORLD_ORIGINif needed. Do not CONNECT toworld2.v0peer.org(that origin is a 3D client, not occupancy). - Main node ID — Your deployed main node identifier. Changing this field rewrites the
LET mainNode = "..."line in the editor when present. - Passphrase — Exactly 10 words (whitespace-separated). The UI derives hex credential material via
nodeCredentialsMaterialFromHumanPassphrasefrom@agent-play/node-tools/browser. - Connect — Calls
POST /api/nodes/validatewithnodeId+rootKey(NEXT_PUBLIC_AGENT_PLAY_ROOT_KEY), thenPOST /api/agent-play/session. On success, execution state holdssidandnodePasswordMaterial. - Disconnect — Clears session and agent targets; resets UI state.
Execute vs Connect: Passing validation is required before Run can call APIs that need secrets (INSPECT MAIN NODE, SEND). You may still edit AQL while disconnected.
Run
Run prepends a synthetic line:
LET serverUrl = "<current Server URL field>"
to your script so $serverUrl is defined if referenced. It then calls runAql with the merged execution state.
Separate loading states:
- Connecting — validate + session
- Running — AQL execution only
Status badge
The chip shows ready when a main node id and valid 10-word passphrase are present, connected after a successful Connect, and reflects disconnect otherwise.
Headers inspector
Successful RPCs attach __http metadata in the runtime client; the playground strips it from JSON but displays response headers in a collapsible panel (pretty-printed).
Autocomplete
aql-autocomplete.ts suggests:
- Keywords (
INSPECT MAIN NODE,USE AGENT NODE,FETCH SNAPSHOT, …) - Variables from
LETbindings - Common paths (
$agent.name,$node.kind, …)
Tab inserts the first suggestion when the menu is open.
Limitations
- AQL runs in the browser; long-running or unattended automation usually belongs in the SDK (Integration guide).
SENDcurrently invokes chat intercom (kind: "chat"inaql-runtime-client.ts).