@air-jam/cli 0.9.3 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +128 -0
  2. package/dist/auth-profile.d.ts +5 -0
  3. package/dist/auth-profile.js +7 -0
  4. package/dist/auth-profile.js.map +1 -0
  5. package/dist/auth-sessions.d.ts +5 -0
  6. package/dist/auth-sessions.js +7 -0
  7. package/dist/auth-sessions.js.map +1 -0
  8. package/dist/chunk-7D4AYBAV.js +64 -0
  9. package/dist/chunk-7D4AYBAV.js.map +1 -0
  10. package/dist/chunk-LH7UO57C.js +23 -0
  11. package/dist/chunk-LH7UO57C.js.map +1 -0
  12. package/dist/chunk-PKTLVQXZ.js +82 -0
  13. package/dist/chunk-PKTLVQXZ.js.map +1 -0
  14. package/dist/chunk-SQE4NPZP.js +31 -0
  15. package/dist/chunk-SQE4NPZP.js.map +1 -0
  16. package/dist/{chunk-A4V2N4LX.js → chunk-U6V3HEBB.js} +6 -5
  17. package/dist/chunk-U6V3HEBB.js.map +1 -0
  18. package/dist/chunk-VEHNFPEO.js +224 -0
  19. package/dist/chunk-VEHNFPEO.js.map +1 -0
  20. package/dist/development.d.ts +4 -0
  21. package/dist/development.js +1 -1
  22. package/dist/game-analytics.d.ts +5 -0
  23. package/dist/game-analytics.js +7 -0
  24. package/dist/game-analytics.js.map +1 -0
  25. package/dist/game-app-id.d.ts +5 -0
  26. package/dist/game-app-id.js +7 -0
  27. package/dist/game-app-id.js.map +1 -0
  28. package/dist/game-media.d.ts +5 -0
  29. package/dist/game-media.js +7 -0
  30. package/dist/game-media.js.map +1 -0
  31. package/dist/index.js +688 -404
  32. package/dist/index.js.map +1 -1
  33. package/dist/scaffold.d.ts +8 -1
  34. package/dist/scaffold.js +6 -1
  35. package/dist/scaffold.js.map +1 -1
  36. package/package.json +8 -4
  37. package/runtime/local-network.d.mts +4 -6
  38. package/runtime/public-assets.mjs +62 -0
  39. package/runtime/source-fence.mjs +182 -0
  40. package/runtime/vite-config.d.mts +2 -1
  41. package/runtime/vite-config.mjs +6 -2
  42. package/runtime/vite-dev.mjs +18 -0
  43. package/runtime/vite-https.mjs +2 -3
  44. package/template-assets/bootstrap/AGENTS.md +56 -14
  45. package/template-assets/bootstrap/CLAUDE.md +0 -8
  46. package/template-assets/bootstrap/skills/airjam-mcp/SKILL.md +44 -0
  47. package/template-assets/bootstrap/skills/controller-ui/SKILL.md +2 -0
  48. package/template-assets/bootstrap/skills/game-architecture/SKILL.md +47 -3
  49. package/template-assets/bootstrap/skills/index.md +1 -1
  50. package/template-assets/bootstrap/skills/prefab-authoring/SKILL.md +10 -0
  51. package/template-assets/bootstrap/skills/r3f-3d-scene/SKILL.md +10 -0
  52. package/template-assets/documentation/for-agents/controller-ui/page.mdx +41 -2
  53. package/template-assets/documentation/for-agents/page.mdx +24 -2
  54. package/template-assets/documentation/for-agents/project-structure/page.mdx +0 -2
  55. package/template-assets/documentation/for-agents/state-and-rendering/page.mdx +0 -2
  56. package/template-assets/documentation/for-agents/supported-agents/page.mdx +18 -0
  57. package/template-assets/documentation/getting-started/debugging/page.mdx +7 -8
  58. package/template-assets/documentation/getting-started/dev-logs/page.mdx +0 -2
  59. package/template-assets/documentation/getting-started/game-ideas/page.mdx +1 -3
  60. package/template-assets/documentation/getting-started/introduction/page.mdx +71 -54
  61. package/template-assets/documentation/getting-started/migrating-legacy-games/page.mdx +308 -62
  62. package/template-assets/documentation/getting-started/quick-start/page.mdx +56 -79
  63. package/template-assets/documentation/how-it-works/architecture/page.mdx +91 -50
  64. package/template-assets/documentation/how-it-works/host-system/page.mdx +112 -109
  65. package/template-assets/documentation/manifest.json +112 -42
  66. package/template-assets/documentation/sdk/assets-and-theme/page.mdx +185 -0
  67. package/template-assets/documentation/sdk/hooks/page.mdx +106 -171
  68. package/template-assets/documentation/sdk/input-system/page.mdx +201 -231
  69. package/template-assets/documentation/sdk/networked-state/page.mdx +134 -52
  70. package/template-assets/documentation/sdk/settings/page.mdx +155 -0
  71. package/template-assets/documentation/sdk/ui-components/page.mdx +45 -4
  72. package/template-assets/managed/.airjam/ai-pack.json +61 -43
  73. package/template-assets/managed/docs/airjam/agent-gold-path.md +55 -7
  74. package/template-assets/managed/docs/airjam/agent-mcp.md +44 -0
  75. package/template-assets/managed/docs/airjam/debug-and-testing.md +18 -0
  76. package/template-assets/managed/docs/airjam/docs-index.md +18 -12
  77. package/template-assets/managed/docs/airjam/generated/architecture.md +91 -46
  78. package/template-assets/managed/docs/airjam/generated/assets-and-theme.md +188 -0
  79. package/template-assets/managed/docs/airjam/generated/controller-ui.md +41 -0
  80. package/template-assets/managed/docs/airjam/generated/debugging-and-logs.md +7 -6
  81. package/template-assets/managed/docs/airjam/generated/for-agents.md +24 -0
  82. package/template-assets/managed/docs/airjam/generated/game-ideas.md +1 -1
  83. package/template-assets/managed/docs/airjam/generated/host-system.md +112 -102
  84. package/template-assets/managed/docs/airjam/generated/input-system.md +199 -218
  85. package/template-assets/managed/docs/airjam/generated/introduction.md +71 -51
  86. package/template-assets/managed/docs/airjam/generated/migrating-legacy-games.md +308 -60
  87. package/template-assets/managed/docs/airjam/generated/networked-state.md +134 -50
  88. package/template-assets/managed/docs/airjam/generated/quick-start.md +56 -79
  89. package/template-assets/managed/docs/airjam/generated/sdk-hooks.md +106 -166
  90. package/template-assets/managed/docs/airjam/generated/settings.md +158 -0
  91. package/template-assets/managed/docs/airjam/generated/supported-agents.md +21 -0
  92. package/template-assets/managed/docs/airjam/generated/ui-components.md +45 -2
  93. package/template-assets/managed/docs/airjam/prefab-authoring.md +100 -0
  94. package/template-assets/managed/docs/airjam/preview-controllers.md +4 -1
  95. package/template-assets/managed/docs/airjam/r3f-3d-scene.md +66 -0
  96. package/template-assets/managed/docs/airjam/state-lanes-cookbook.md +15 -20
  97. package/dist/chunk-A4V2N4LX.js.map +0 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
  Get your first Air Jam game up and running in minutes using our project generator.
4
4
 
5
- You need Node.js 22 or newer and pnpm installed. The generator runs `pnpm install`
5
+ You need Node.js 22.15 or newer and pnpm installed. The generator runs `pnpm install`
6
6
  for you unless you explicitly choose `--skip-install`.
7
7
 
8
8
  ## 1. Create a New Project
@@ -78,11 +78,12 @@ This project is "vibecode friendly"—it includes documentation and AI instructi
78
78
 
79
79
  - **Check `AGENTS.md`**: Project-wide coding contract and workflow for AI coding assistants.
80
80
  - **Check `docs/airjam/docs-index.md`**: Canonical local framework references bundled with the template.
81
- - **Modify `src/airjam.config.ts`**: Canonical runtime setup and input wiring.
82
- - **Modify `src/game/input.ts`**: Define your input schema.
81
+ - **Modify `src/airjam.config.ts`**: The game declaration: metadata, controls, stores, settings and simulation.
82
+ - **Modify `src/game/contracts/input.ts`**: Declare the controls each player has.
83
83
  - **Use the starter module map in the template `README.md`**: Follow the current starter structure before creating new homes for code.
84
84
  - **Modify `src/game/stores/`**: Starter location for shared networked state and pure transitions.
85
- - **Modify `src/host/index.tsx`**: Starter host/gameplay surface.
85
+ - **Modify `src/game/engine/`**: Starter simulation the host advances in fixed steps.
86
+ - **Modify `src/host/index.tsx`**: Starter host screen.
86
87
  - **Modify `src/controller/index.tsx`**: Starter mobile controller surface.
87
88
  - **Use `tests/game/`**: Starter testing pattern for domain, stores, engine, adapters, and shared game UI.
88
89
 
@@ -104,7 +105,8 @@ pnpm exec airjam mcp config --profile portable --dir .
104
105
  The `codex` and `claude-desktop` profiles render their respective registration
105
106
  formats. Configuration rendering is read-only: install the rendered entry in
106
107
  your client, then check its tool discovery. See [For Agents](/docs/for-agents)
107
- for semantic game control and a CLI-only path.
108
+ for semantic game control and a CLI-only path, and
109
+ [Supported Agents](/docs/for-agents/supported-agents) for the clients tested end to end.
108
110
 
109
111
  ### Run the Complete Evaluation
110
112
 
@@ -156,7 +158,8 @@ pnpm run dev
156
158
 
157
159
  1. Ensure `VITE_AIR_JAM_APP_ID` is set in your host platform.
158
160
  2. Ensure the server URL points at your real Air Jam backend.
159
- 3. Re-copy the App ID from your game's dashboard settings if bootstrap fails.
161
+ 3. Ensure your site's exact origin is in the game's allowed origins in Create.
162
+ 4. Re-copy the App ID from your game's page in Create if the room is refused.
160
163
 
161
164
  ### QR / controller join URL issues
162
165
 
@@ -170,12 +173,7 @@ When you're ready to share your game outside local development, first register
170
173
  it with Air Jam so the runtime has a stable hosted identity.
171
174
 
172
175
  1. **Create a game record**:
173
- - Go to the [Platform Dashboard](/dashboard)
174
- - Create a game if you do not already have one
175
- - Copy its **App ID**
176
-
177
- An agent or terminal user can create the same hosted identity without
178
- navigating the dashboard after the one-time browser-assisted login:
176
+ Register your game from the terminal after a one-time browser-assisted login:
179
177
 
180
178
  ```bash
181
179
  pnpm exec airjam auth login
@@ -183,6 +181,10 @@ it with Air Jam so the runtime has a stable hosted identity.
183
181
  pnpm exec airjam game inspect --game my-game
184
182
  ```
185
183
 
184
+ Copy the **App ID** from the response. Your game also appears in [Create](/studio)
185
+ at `/studio/games/<id>`, with **Releases**, **Media**, **Analytics** and **Security**.
186
+ Studio projects create their game record on the first release.
187
+
186
188
  2. **Choose your distribution lane**:
187
189
  - Deploy your game to a static hosting provider like Vercel, Netlify, or GitHub Pages.
188
190
  - Use that self-hosted URL for normal private review and iteration.
@@ -191,12 +193,27 @@ it with Air Jam so the runtime has a stable hosted identity.
191
193
 
192
194
  ```bash
193
195
  VITE_AIR_JAM_APP_ID=your_app_id_here
194
- VITE_AIR_JAM_SERVER_URL=https://api.airjam.io # or your own Air Jam backend
196
+ VITE_AIR_JAM_SERVER_URL=https://rooms.airjam.io
195
197
  ```
196
198
 
197
- The SDK handles production bootstrap automatically from that `appId`. You do not need to mint tokens or add auth code in your game.
198
- If you want to lock production bootstrap to your deployed site only, set the
199
- optional allowed-origin list for the App ID in the dashboard settings.
199
+ Add your site's origin (for example `https://my-game.example`) to the
200
+ allowed origins in your game's **Security** section in Create. When your page
201
+ opens a room, the SDK asks Air Jam for a short-lived host grant for your App
202
+ ID. Air Jam signs one only for an active App ID, asked from one of its allowed
203
+ origins exactly, and the grant names that one origin. You do not mint tokens or
204
+ add auth code to your game.
205
+
206
+ The origin check keeps other websites from opening rooms under your App ID in
207
+ players' browsers. It is not a secret: a script outside a browser can claim any
208
+ origin, just as it can claim any App ID. What bounds misuse is admission: each
209
+ game and each account may run 20 hosted rooms at once, inside Air Jam's overall
210
+ limit, so rooms someone else opens under your App ID can crowd yours but never
211
+ grow past those caps.
212
+
213
+ On hosted rooms, a crash your game's error boundary catches is also reported to
214
+ Air Jam, as its error name and a short digest (never its message, stack or any
215
+ player input), so it shows up with your game's other room records. Pass your own
216
+ `reportError` to send reports elsewhere.
200
217
 
201
218
  Before publishing your scaffolded game, run the local checks:
202
219
 
@@ -208,62 +225,16 @@ pnpm run build
208
225
 
209
226
  If you are self-hosting the client, keep SPA rewrites enabled so `/controller?room=XXXX` resolves to your app entry.
210
227
 
211
- ### Optional: Stronger Signed Host Bootstrap
212
-
213
- If you want stricter production ownership guarantees, you can keep the game static and add one small backend or edge endpoint that returns a signed host grant.
214
-
215
- This requires a realtime backend that verifies those grants: the hosted Air Jam
216
- backend or your own server composed with an `authService` adapter. The standalone
217
- `air-jam-server` command does not read `AIR_JAM_HOST_GRANT_SECRET` and rejects host
218
- grants by default. Setting the secret alone does not enable grant verification.
219
-
220
- Frontend env:
221
-
222
- ```bash
223
- VITE_AIR_JAM_HOST_GRANT_ENDPOINT=/api/airjam/host-grant
224
- ```
225
-
226
- Grant issuer and verifying backend env (not the standalone server command):
227
-
228
- ```bash
229
- AIR_JAM_HOST_GRANT_SECRET=your_signing_secret
230
- ```
231
-
232
- The SDK will fetch the host grant automatically before `host:bootstrap`. Your game code stays unchanged.
233
-
234
- Example endpoint shape:
235
-
236
- ```ts
237
- import { createHostGrant } from "@air-jam/sdk/protocol";
238
-
239
- export async function POST(request: Request) {
240
- const { appId } = await request.json();
241
- const { gameId, creatorId } = await loadTrustedAppIdentity(appId);
242
- const now = Math.floor(Date.now() / 1000);
243
-
244
- const hostGrant = await createHostGrant({
245
- secret: process.env.AIR_JAM_HOST_GRANT_SECRET!,
246
- claims: {
247
- jti: crypto.randomUUID(),
248
- aud: "airjam:realtime",
249
- appId,
250
- gameId,
251
- creatorId,
252
- iat: now,
253
- exp: now + 60,
254
- origins: ["https://your-game.example"],
255
- sessionKind: "game",
256
- },
257
- });
258
-
259
- return Response.json({ hostGrant });
260
- }
261
- ```
228
+ ### Self-hosted rooms
262
229
 
263
- `loadTrustedAppIdentity` represents your server-side lookup; never copy game or
264
- creator identity from the browser request. That endpoint is also where you can
265
- add your own rules, for example checking the signed-in user or limiting which
266
- app IDs they are allowed to bootstrap.
230
+ Run the open `air-jam-server` yourself and point `VITE_AIR_JAM_SERVER_URL` at
231
+ it. In production it needs a gate of your own: compose it with
232
+ `createRoomServer({ gate })` from `@air-jam/server/room-server`, or set
233
+ `AIR_JAM_AUTH_MODE=disabled` to run it open to any host. Its master key is for
234
+ local development and tests only. The SDK sends whatever
235
+ `VITE_AIR_JAM_HOST_GRANT_ENDPOINT` returns (`{ "hostGrant": "..." }`) as the
236
+ credential when it opens a room, so your gate can verify a token your own
237
+ backend signs. Game code stays unchanged.
267
238
 
268
239
  ## 6. Publish A Hosted Arcade Release
269
240
 
@@ -289,8 +260,6 @@ That command:
289
260
  - writes `.airjam/release-manifest.json`
290
261
  - creates a hosted release zip under `.airjam/releases/<version>/`
291
262
 
292
- The scaffolded `release:bundle` script wraps `airjam release bundle --dir .` for you.
293
-
294
263
  The hosted artifact contract is fixed:
295
264
 
296
265
  - host entry at `/`
@@ -298,8 +267,8 @@ The hosted artifact contract is fixed:
298
267
 
299
268
  ### Terminal or Agent Publishing
300
269
 
301
- The CLI can bundle, upload, and wait for validation using the same release
302
- services as the dashboard. Use the game slug or ID created in step 5:
270
+ The CLI can bundle, upload, and wait for validation. Use the game slug or ID
271
+ created in step 5:
303
272
 
304
273
  ```bash
305
274
  pnpm exec airjam release submit --game my-game --dir . --wait
@@ -311,7 +280,9 @@ then explicitly make it live when you are ready:
311
280
  ```bash
312
281
  pnpm exec airjam release inspect --release <release-id>
313
282
  pnpm exec airjam release publish --release <release-id>
314
- pnpm exec airjam game media --help
283
+ pnpm exec airjam game media list --game my-game --json
284
+ pnpm exec airjam game media assign --game my-game --asset-id <asset-id> --json
285
+ pnpm exec airjam game media archive --game my-game --asset-id <asset-id> --json
315
286
  pnpm exec airjam game update --game my-game --arcade-visibility listed
316
287
  ```
317
288
 
@@ -320,14 +291,20 @@ timeout does not cancel the background job: inspect the same release rather
320
291
  than submitting another copy. CLI responses retain the release and generation
321
292
  identities needed to resume work.
322
293
 
323
- ### Dashboard Publishing
294
+ `game media list` (also `inspect`) returns existing assets with IDs, kinds,
295
+ status and active selections. `assign` reuses an earlier asset for its kind;
296
+ `archive` retires one by ID and clears its slot if active. These commands use
297
+ the saved machine login and accept `--platform-url` and `--help`. Without
298
+ `--json` they print readable output. Use `game media upload` for new files.
299
+
300
+ ### Publish From Create
324
301
 
325
302
  Alternatively, upload the zip produced by `airjam release bundle` above:
326
303
 
327
- 1. Go to your game's **Releases** page in the [Dashboard](/dashboard).
304
+ 1. Open your game in [Create](/studio) and choose **Releases**.
328
305
  2. Upload the generated zip artifact.
329
306
  3. Make the validated release live.
330
- 4. Upload managed thumbnail, cover, and preview media in the Dashboard.
307
+ 4. Upload thumbnail, cover, and preview media in **Media**.
331
308
  5. Set the game's Arcade visibility to listed.
332
309
 
333
310
  Your game is now live in the public Arcade on Air Jam-hosted infrastructure.
@@ -19,36 +19,81 @@ product, not an application in this public repository. Their hosted services
19
19
  compose the same open runtime; standalone games need neither that product nor
20
20
  its database. The diagrams include hosted surfaces to show how embedding works.
21
21
 
22
- ### 1. Server (`packages/server`)
22
+ ### 1. Room server (`packages/server`)
23
23
 
24
- **Role:** Real-time communication backbone
24
+ **Role:** Keeps rooms: it seats phones, carries their controls to the game's
25
+ host and the host's state to the phones
25
26
 
26
- **Technology:** Node.js, Express, Socket.IO
27
+ **Technology:** Node.js and `ws`; the room itself is plain synchronous code
28
+ (`@air-jam/server/room`), so the hosted Arcade runs the same rooms elsewhere
27
29
 
28
- **Core Services:**
30
+ Every device holds one WebSocket to its room. A game's host connects to
31
+ `/v1/host` and gets a room code; a phone connects to `/v1/play/CODE` and gets
32
+ a seat (`p1`, `p2`, …). The room speaks the room protocol
33
+ (`@air-jam/sdk/room-protocol`):
29
34
 
30
- <CoreServicesDiagram />
31
-
32
- **Socket Events:**
33
-
34
- <SocketEventsDiagram />
35
+ - **Hello and welcome.** Each device sends a key that only it knows; the same
36
+ key gets the same place back after a reload or a dropped network.
37
+ - **Channels.** The host publishes named state documents (the room's
38
+ presentation, each networked store); the room keeps the latest copy and
39
+ sends phones what changed.
40
+ - **Requests and signals.** A phone asks the host to run an action and gets
41
+ one answer; the host sends haptics, toasts and sounds to one seat or all.
42
+ - **Input.** Controls travel in small binary frames; the room delivers the
43
+ latest of each seat's to the host.
35
44
 
36
45
  ### 2. SDK (`packages/sdk`)
37
46
 
38
47
  **Role:** Developer toolkit for building Air Jam games
39
48
 
40
- **Technology:** React, TypeScript, Socket.IO Client, Zustand, Zod
49
+ **Technology:** TypeScript, Zustand, Zod; React for the binding
41
50
 
42
51
  **Architecture:**
43
52
 
44
53
  <SdkArchitectureDiagram />
45
54
 
46
- **Key Design Decisions:**
47
-
48
- 1. **Provider Pattern** - Single provider for configuration, multiple hooks for access
49
- 2. **Lightweight Hooks** - `useGetInput`, `useSendSignal` don't trigger re-renders
50
- 3. **Input Latching** - Ensures rapid button taps are never missed
51
- 4. **Schema Validation** - Type-safe input with runtime validation
55
+ The SDK is one runtime in two layers:
56
+
57
+ 1. **The core** (`@air-jam/sdk/core`) owns a room: the connection, players,
58
+ input, networked stores and their sync, the game's simulation on the SDK
59
+ clock, signals and the agent contract. It imports no React and no DOM, so
60
+ the same game runs in a browser, in Node without drawing, or faster than
61
+ real time in headless tests.
62
+ 2. **The React binding** (`@air-jam/sdk`) starts the core for a host or a
63
+ controller page and lets components read it: `useAirJamHost`,
64
+ `useAirJamController`, `useAirJamStore`, `useSimulationFrame`. Hooks
65
+ subscribe to the core; they never keep a second copy of the runtime.
66
+
67
+ A game declares metadata, stores, simulation, controls and its agent contract
68
+ once in `src/airjam.config.ts` with `defineAirJamGame` from core.
69
+ `app.tsx` binds it with `createAirJamApp(airjam, { runtime })`. Store
70
+ definitions and simulations import from `@air-jam/sdk/core`; components import
71
+ from `@air-jam/sdk`.
72
+
73
+ **Entry points.** Each import path has one purpose:
74
+
75
+ | Import path | Purpose |
76
+ | ------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
77
+ | `@air-jam/sdk` | React binding: host and controller surfaces and hooks, audio and platform settings |
78
+ | `@air-jam/sdk/core` | Framework-free game declaration, agent helpers, networked stores, simulations and runtimes |
79
+ | `@air-jam/sdk/ui` | Ready-made React components for host and controller shells |
80
+ | `@air-jam/sdk/styles.css` | Styles for those components |
81
+ | `@air-jam/sdk/metadata` | The game's catalog metadata declaration |
82
+ | `@air-jam/sdk/prefabs` | Placeable scene pieces with previews |
83
+ | `@air-jam/sdk/preview` | Preview controllers shown beside a host during development |
84
+ | `@air-jam/sdk/protocol` | Shared schemas: players, actions, leased control, runtime reports |
85
+ | `@air-jam/sdk/room-protocol` | The room protocol: frames, close codes, channels and the input codec |
86
+ | `@air-jam/sdk/room-session` | A host's or phone's session in a room, and connectors for WebSockets and embedded frames |
87
+ | `@air-jam/sdk/runtime-topology` | Where a runtime connects in each run mode |
88
+ | `@air-jam/sdk/runtime-control` | Calling a running host: agent requests, actions and observations |
89
+ | `@air-jam/sdk/runtime-inspection` | Reading what a running host or controller publishes for tools |
90
+ | `@air-jam/sdk/agent-tooling` | Checking and evaluating a game's agent contract |
91
+ | `@air-jam/sdk/controller-bridge` | Serving an embedded controller page its seat from the page around it |
92
+ | `@air-jam/sdk/arcade/*` | Embedding games in the Arcade: `bridge/host`, `bridge/controller`, `bridge/iframe`, `host`, `runtime`, `surface`, `url` |
93
+ | `@air-jam/sdk/release`, `@air-jam/sdk/platform-machine` | Contracts with the hosted platform for releases and the CLI |
94
+
95
+ Games use the first five or six; the rest serve the CLI, MCP server, devtools,
96
+ the server and the hosted platform.
52
97
 
53
98
  ### 3. Creator Harness
54
99
 
@@ -75,7 +120,7 @@ tools do not depend on private application source.
75
120
 
76
121
  Air Jam uses three lanes and they should stay separate:
77
122
 
78
- 1. **Input lane** for high-frequency transient control data via `useInputWriter` and `getInput` / `useGetInput`
123
+ 1. **Input lane** for players' controls: declared with `defineAirJamInput`, filled by phone controls, agents or replays, and read once per simulation step
79
124
  2. **Replicated state lane** for replayable shared state via `createAirJamStore`
80
125
  3. **Signal / command lane** for coarse UX/runtime messages such as haptics, toasts, pause, and exit
81
126
 
@@ -87,7 +132,7 @@ The SDK automatically detects and adapts to different deployment scenarios:
87
132
 
88
133
  ### Standalone Mode
89
134
 
90
- Your game runs independently with direct WebSocket connection.
135
+ Your game connects straight to a room server over a WebSocket.
91
136
 
92
137
  ```
93
138
  ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
@@ -107,8 +152,8 @@ Game runs inside an iframe on the Air Jam Platform.
107
152
  │ Air Jam Platform (Parent) │
108
153
  │ ┌───────────────────────────────────┐ │
109
154
  │ │ Your Game (iframe) │ │
110
- │ │ • Receives launch capability │ │
111
- │ │ • Controlled player routing │ │
155
+ │ │ • Room served by the Arcade │ │
156
+ │ │ • Same room, its own channels │ │
112
157
  │ └───────────────────────────────────┘ │
113
158
  └─────────────────────────────────────────┘
114
159
  ```
@@ -124,7 +169,7 @@ Controller runs inside platform's runtime wrapper (iframe communication).
124
169
  │ Platform Controller Runtime (Parent) │
125
170
  │ ┌───────────────────────────────────┐ │
126
171
  │ │ Your Controller UI (iframe) │ │
127
- │ │ • Input via postMessage │ │
172
+ │ │ • Seat served via MessagePort │ │
128
173
  │ │ • Seamless game switching │ │
129
174
  │ └───────────────────────────────────┘ │
130
175
  └─────────────────────────────────────────┘
@@ -137,15 +182,15 @@ Controller runs inside platform's runtime wrapper (iframe communication).
137
182
  ### Input Path (Controller → Game)
138
183
 
139
184
  ```
140
- 1. Player moves joystick on phone
141
- 2. Controller publishes input via useInputWriter({ vector: {x, y}, action: false })
142
- 3. SDK sends controller:input event to server
143
- 4. Server routes to host socket
144
- 5. Host SDK's InputManager receives input
145
- 6. InputManager validates with Zod schema
146
- 7. InputManager applies configured input behavior (`pulse`, `hold`, `latest`)
147
- 8. Game calls getInput(playerId) in game loop
148
- 9. Returns typed, validated input with behavior semantics applied
185
+ 1. Player holds a stick or button rendered by the SDK's phone controls
186
+ 2. The controller's input lane updates the declared control's state
187
+ 3. Once per display frame, if anything changed, the SDK sends one binary
188
+ input frame
189
+ 4. The room passes each seat's latest frame to the host
190
+ 5. The host's input lane decodes it against the declared controls
191
+ 6. Before each simulation step, the host samples every player's controls and
192
+ applies each kind's meaning (a pressed button reads true for one step)
193
+ 7. The step reads input(playerId)
149
194
  ```
150
195
 
151
196
  ### Signal Path (Game → Controller)
@@ -153,8 +198,8 @@ Controller runs inside platform's runtime wrapper (iframe communication).
153
198
  ```
154
199
  1. Game detects collision
155
200
  2. Host calls sendSignal("HAPTIC", { pattern: "heavy" }, playerId)
156
- 3. SDK sends host:signal event to server
157
- 4. Server routes to target controller(s)
201
+ 3. The host's session sends a signal to that seat
202
+ 4. The room delivers it to the seat's phone
158
203
  5. Controller SDK receives signal
159
204
  6. SDK triggers navigator.vibrate() with pattern
160
205
  7. Player feels haptic feedback
@@ -162,28 +207,24 @@ Controller runs inside platform's runtime wrapper (iframe communication).
162
207
 
163
208
  ## Security
164
209
 
165
- ### Host Bootstrap
166
-
167
- - Hosts perform one `host:bootstrap` verification step in production/static mode
168
- - In normal static mode, the server validates the browser-facing `appId` once, then binds host authority to the socket
169
- - Static apps can optionally restrict bootstrap by allowed origin per app identity
170
- - In optional signed mode, the SDK first fetches a short-lived host grant from `hostGrantEndpoint`, then bootstraps with that grant instead of raw `appId`
171
- - Later host lifecycle events rely on socket authority instead of repeated raw auth payloads
172
-
173
- ### Child Launch Capability
210
+ ### Opening a room
174
211
 
175
- - Arcade game launch issues a room/game-scoped `launchCapability`
176
- - Embedded host iframes receive `aj_cap` / `aj_cap_exp` automatically
177
- - Game code does not parse or manage this capability directly
212
+ - A host's hello may carry a credential for the server's gate; a local server
213
+ needs none, and a self-hosted production server composes its own gate
214
+ (`createRoomServer({ gate })`) or runs open to any host
215
+ - A host returning to its room proves itself with its key alone, so a reload
216
+ keeps the room and its players
217
+ - An embedded game never opens a room of its own: the Arcade serves it the
218
+ Arcade's room over a MessagePort, scoped to that game's channels
178
219
 
179
220
  ### Room Isolation
180
221
 
181
- - Each room has unique 4-character code
182
- - Controllers can only join with correct code
183
- - Input is only routed to the designated host
222
+ - Each room has a unique code
223
+ - Phones can only join with the code, and hold their seat by their key
224
+ - Input reaches only the room's host
184
225
 
185
226
  ### Input Validation
186
227
 
187
- - Zod schemas validate all incoming input
188
- - Invalid input is rejected with console warning
189
- - Protects game logic from malformed data
228
+ - Every incoming input is checked against the game's declared controls
229
+ - Invalid input is dropped with an `AJ_INPUT_INVALID` diagnostic
230
+ - Agents' input passes the same check before they take a seat