Skip to main content

Documentation Index

Fetch the complete documentation index at: https://openturn.io/docs/llms.txt

Use this file to discover all available pages before exploring further.

Openturn is split across eighteen packages. This page is the decision tree: “I want to do X, which one do I import.”

Authoring

PackageRuntimeWhy
@openturn/coreworkerThe engine. defineGame, definePlayerIDs, events, states, transitions, createLocalSession.
@openturn/gamekitworkerMove-first sugar over core: defineGame, moves, phases, outcomes. Use this unless you need the core escape hatch.
@openturn/jsonworkerJsonValue types, JsonValueSchema, and validators. Re-exported by most packages; you will import it directly for explicit JSON validation.
@openturn/botworkerPlug-and-play AI bots over a game. defineBot({ decide }), attachLocalBot / attachLocalBots / attachHostedBot, simulate. Same bot shape for random, heuristic, and MCTS players.

Hosting and transport

PackageRuntimeWhy
@openturn/protocolworkerWire protocol: ClientAction, BatchApplied, lobby messages, Zod schemas. Shared between client and server.
@openturn/serverworkerAuthoritative RoomRuntime, LobbyRuntime, createGameWorker factory for Cloudflare, room tokens, persistence.
@openturn/clientworkerWebSocket client. createHostedClient handles connect, dispatch, and state synchronization.
@openturn/bridgebrowserIframe↔shell wire. createGameBridge on the iframe, createBridgeHost on the shell, plus the shell-controls registry the host renders save / load / reset / lobby chrome from.
@openturn/manifestworkerDeployment manifest schema + HTML generator. Shared by @openturn/deploy (writer) and the cloud shell (reader). Owns SHELL_CONTROL_IDS.

UI and tooling

PackageRuntimeWhy
@openturn/reactbrowserReact hooks: createOpenturnBindings, <OpenturnProvider>, useMatch, useRoom, useInspector, Lobby.
@openturn/lobbymixedUnified lobby surface — protocol extensions, runtime helpers, React UI, bot registry, and bot supervisors. Five subpath exports; only ./react touches the DOM.
@openturn/replayworkerSaved replay envelopes, timeline materialization, cursor-based playback, branching.
@openturn/inspectorworkerNon-UI inspector logic: buildInspectorTimelineFromSource (unified replay/hosted entry), diffs, graph highlights.
@openturn/inspector-uibrowserReady-made React inspector components: createInspector returns { Inspector, ReplayInspector, HostedInspector }.
@openturn/deployBunBuild pipeline: discoverOpenturnProject, buildOpenturnProject, manifest, Worker bundle generation.
@openturn/cliBunThe openturn binary: create, dev, build, deploy, login.

Plugins

PackageRuntimeWhy
@openturn/pluginsworkerPlugin authoring + composition: definePlugin, definePluginMove, withPlugins. Compose cross-cutting features (chat, votes, emotes) into a gamekit game without forking the host.
@openturn/plugin-chatmixedFirst-party in-room chat plugin: chatPlugin (worker-safe) plus a <ChatBubble /> React widget under ./react.

Quick recipes

“I want to author a game.” — Start with @openturn/gamekit. Drop to @openturn/core if gamekit doesn’t fit. “I want to run a game in my React app.”@openturn/react’s createOpenturnBindings(game, { runtime, match? }) returns a zero-prop <OpenturnProvider> that auto-resolves transport (in-process for local, bridge fragment for multiplayer — same provider in dev and prod). Read state with useMatch (just the game) or useRoom (full room with lobby, bridge, invite URL). “I want multiplayer.”@openturn/server on the server, @openturn/client (via React) on the client, @openturn/protocol as the wire format, @openturn/bridge to connect an embedded iframe to its hosting shell. “I want replays.”@openturn/replay for capture and load, @openturn/inspector-ui for the inspector UI. “I want to deploy.”openturn build and openturn deploy from @openturn/cli; the build pipeline is @openturn/deploy. “I want a player to play vs the computer.”@openturn/bot. defineBot({ decide }) writes the bot, attachLocalBot / attachLocalBots binds it to a seat, the runner dispatches autonomously. Same bot works in CLI and over WebSocket via attachHostedBot.

Dependency layering

Packages fan out from @openturn/core. A short dependency map (arrows point “depends on”):
@openturn/core ──┬── @openturn/gamekit
                 ├── @openturn/server ──── @openturn/protocol ── @openturn/json
                 ├── @openturn/client ────┘
                 ├── @openturn/bot ───────┘
                 ├── @openturn/replay
                 ├── @openturn/lobby (depends on core/protocol/server/client/bot)
                 ├── @openturn/plugins ── @openturn/plugin-chat
                 └── @openturn/inspector ── @openturn/inspector-ui
                                           └── @openturn/react ── @openturn/bridge ── @openturn/manifest
                                                                 └── @openturn/deploy ── @openturn/cli
Everything downstream of core treats GameSnapshot and GameDefinition as the canonical interface. You can drop any downstream package from your app and still have a working authored game.

When to reach for the uncommon packages

I need a custom transport (not WebSocket). Implement HostedTransport in @openturn/client — pass it as transport to createHostedClient. The @openturn/protocol message types let you serialize over any duplex channel (BroadcastChannel, Web Transport, an RPC bus for tests). I’m building my own inspector UI (not React). Use @openturn/inspector directly — buildInspectorTimelineFromSource produces a replay-safe timeline of steps from snapshots, batches, and (optionally) a compiled graph. It returns plain data you can render with any UI framework. I’m writing a CLI tool that runs games outside openturn-cloud. Bun-only tools can depend on @openturn/deploy (build pipeline) and @openturn/server (local room runtime) together. See scripts/ for examples. I want to render a saved replay without connecting to any live match. Import @openturn/replay for the envelope schema and @openturn/inspector-ui’s createInspector(bindings).ReplayInspector. No server, no client, no bridge. I’m embedding a game iframe into a non-openturn host. @openturn/bridge is the whole wire. createGameBridge inside the iframe, createBridgeHost on your shell — no dependency on openturn-cloud itself.

Runtime boundaries

Worker-target packages cannot import Node or Bun APIs. Browser packages cannot import Node. Bun packages can import anything. See concepts: runtime boundaries for why and how the checker enforces it.