TheGameBlock is a browser-first framework and studio for deterministic, agent-editable games. A game is an immutable project tree whose GameModule accepts tick-indexed semantic commands and returns serializable state plus declared effects. The same project runs in the isolated preview, through the remote runtime API, and as a standalone offline export.
The repository includes JavaScript, TypeScript, and AssemblyScript/Wasm paths; JSON-RPC and MCP agent surfaces; revision-scoped audit and replay evidence; exact-hash trust promotion; and six genre-neutral example games.
Requires Bun.
bun install --frozen-lockfile
bun run build
bun run serveOpen http://localhost:8787, register an account, and select a starter project. The server stores tenant data under data/ and seeds the built-in examples for a new account.
For development, run the API server and Vite separately:
# Terminal 1: API, WebSocket runtime, and built studio on :8787
bun run serve
# Terminal 2: Vite studio on :5173, proxying /api, /runtime, and /ws to :8787
bun run devThe development fallback secret is intentionally insecure. Set TGB_SECRET to at least 16 characters for a real deployment; production mode refuses to start without it. Set TGB_DATA_DIR to move persistent tenant data outside the repository.
| Command | Purpose |
|---|---|
bun run dev |
Start the Vite development studio on port 5173. |
bun run serve |
Start the Bun API and built studio on port 8787. |
bun run build |
Build the studio, browser runtime artifacts, and all example games. |
bun run build:wasm |
Compile AssemblyScript games to Wasm. |
bun run typecheck |
Run TypeScript without emitting files. |
bun run lint |
Run Biome checks. |
bun run test |
Run the Vitest suite once. |
card-battler: deterministic decks, turns, content data, and rule graphsgrid-tactics: tile movement and tactical statenarrative: branching text and content importsphysics-toy: AssemblyScript/Wasm runtime pathplatformer: fixed-step movement and hazardsreal-time-action: real-time command and rendering path
Each project contains a manifest, an entry module, JSON Schemas, and any rules or content it needs. bun run build validates all six projects against the same contracts used by the studio and server.
Studio / agents
|
v
Hono API + scoped JSON-RPC/MCP
|
v
Tenant project store -> immutable revisions -> audit + replay evidence -> trust
| |
v v
Opaque-origin preview iframe standalone offline ZIP
|
v
Deterministic kernel -> state envelope + effects -> adapters
Key boundaries:
- Kernel: game logic is a pure
init/stepmodule over serializable state. The model clock, command log, migrations, schemas, and effects remain explicit. - Projects: patches name an exact base revision. Successful writes create content-addressed revisions; stale writes return a semantic diff instead of rebasing silently.
- Agents: JSON-RPC and MCP expose allowlisted project, compile, audit, runtime, and export operations. Scoped credentials bind tenant, project, paths, operations, expiry, and nonce.
- Preview: untrusted project code runs in an opaque-origin
sandbox="allow-scripts"iframe over one dedicated transferred, authenticatedMessagePort; the host DOM and bearer token never enter the iframe. - Trust: only an owner can promote an exact revision, and only after a clean accessibility audit and deterministic replay have produced revision-bound evidence.
- Export: the studio builds a self-contained ZIP with the selected revision, browser runtime, license notices, content hashes, version pins, and no external network references.
The implementation plan and requirement trace live in docs/plans/2026-07-22-001-feat-agent-native-web-game-framework-plan.md. Build evidence lives under docs/build/.
The project-owned framework, studio, adapters, and bundled runtime use the Elastic License 2.0. Third-party components retain their upstream licenses; see NOTICE. Creator game code and assets retain the creator's chosen license, and exports preserve the applicable notices.