introduction
Introduction to AQL
What is AQL?
Agent Query Language (AQL) is a domain-specific language embedded in the Agent Play web UI. It lets operators and integrators:
- Align connection context (server URL, main node id, session id) with scripted steps.
- Inspect the authenticated main node (
GET /api/nodes) and agents resolved from the live world snapshot. - Send intercom traffic (chat / assist / realtime) to a targeted agent after selecting its node id.
- Fetch snapshot slices (occupants, metadata, full snapshot) and show the last HTTP response or headers for debugging.
AQL is not a general-purpose language: there are no loops, branches, or user-defined functions beyond macros.
Mental model
┌─────────────────┐ passphrase ──► nodePasswordMaterial (hex)
│ Connect (UI) │──────────────────────────────────────────────► validated main node
└────────┬────────┘
│ CONNECT SERVER … MAIN_NODE … (optional script step; ensures session)
▼
┌─────────────────┐
│ Session (sid) │◄─── FETCH SNAPSHOT / SEND / …
└────────┬────────┘
│ USE AGENT NODE $targetNode ──► resolves agent from snapshot
▼
┌─────────────────┐
│ targetAgentId │◄─── SEND "…"
└─────────────────┘
- Main node: Identity used for
INSPECT MAIN NODEand for signing intercom calls. The playground derives hashed passphrase material from the 10-word phrase using@agent-play/node-tools/browser(same material as API headers). - Session: Created via
POST /api/agent-play/sessionwhen needed; reused whenCONNECTruns again with an existingsidin state. - Agent context:
USE AGENT NODE <expr>orSHIFT AGENT NODE <expr>setstargetNodeIdandtargetAgentIdfrom the current snapshot.SENDrequires this context.
Design choices
- Line-oriented statements starting with a keyword (
LET,CONNECT,USE, …). - Case-sensitive keywords in the canonical grammar (the lexer recognizes uppercase keywords; see Language reference for
WITHclause flexibility). - Variables with
$name; dotted paths like$agent.nameresolve nested snapshot fields when the value is an object. - Macros (
MACRO/CALL) for reusable fragments without external files. - Comments:
#to end of line.
Relation to the SDK
The @agent-play/sdk RemotePlayWorld client is the primary integration path for Node.js and long-running tools. AQL is complementary: it is browser-first, session-scoped, and optimized for manual and scripted debugging against the same snapshot and intercom stack documented in Events, SSE, and Remote and the world model notes.
Roadmap note
Future commands (for example space management) may be added to AQL and the runtime client; this documentation set will grow with the grammar. Check the language reference against the parser source when in doubt.