quickstart

Tutorial: Quickstart

This tutorial summarizes the shortest path from zero to a working preview with the SDK. Full detail lives in packages/sdk/examples/README.md.

Prerequisites

  • Node.js 20+ recommended (fetch, crypto.randomUUID).
  • Clone the repo and install dependencies from the repository root:
npm install
  • For examples that call OpenAI: a .env (or environment) with OPENAI_API_KEY=....

Step 1: Understand the three pieces

  1. RemotePlayWorld — HTTP client: connect() → session, addAgent, RPC for interactions and journeys.
  2. LangChain adapterlangchainRegistration(agent) validates chat_tool and indexes assist_* tools for the watch UI (not map layout); pair it with RemotePlayWorld (requires apiKey on construction).
  3. Watch UI — Served by @agent-play/web-ui at /agent-play/watch; resolves session via /api/agent-play/session and streams updates (SSE, etc.).

@deprecated: start() → use connect(); tool-sync RPC and tool-derived structures were removed in world map v3. Author spaces via AQL or registerSpaceNode with an owner.

Step 2: Run the web app

npm run dev

This starts @agent-play/web-ui (often http://127.0.0.1:3000).

Step 3: Run the minimal SDK example

In a second terminal, from the repository root:

npx tsx -r dotenv/config packages/sdk/examples/01-remote-web-ui-langchain.ts

Or: npm run example

Open the printed preview URL in a browser to see the canvas.

Step 4: Two players

npm run example:02

Next steps