@air-jam/cli 0.0.0-stage → 1.0.0-beta.1

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 (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +273 -2
  3. package/bin/airjam.mjs +66 -0
  4. package/dist/ai-pack.d.ts +44 -0
  5. package/dist/ai-pack.js +15 -0
  6. package/dist/ai-pack.js.map +1 -0
  7. package/dist/auth-profile.d.ts +5 -0
  8. package/dist/auth-profile.js +7 -0
  9. package/dist/auth-profile.js.map +1 -0
  10. package/dist/auth-sessions.d.ts +5 -0
  11. package/dist/auth-sessions.js +7 -0
  12. package/dist/auth-sessions.js.map +1 -0
  13. package/dist/chunk-7D4AYBAV.js +64 -0
  14. package/dist/chunk-7D4AYBAV.js.map +1 -0
  15. package/dist/chunk-J5MAU4QZ.js +102 -0
  16. package/dist/chunk-J5MAU4QZ.js.map +1 -0
  17. package/dist/chunk-LH7UO57C.js +23 -0
  18. package/dist/chunk-LH7UO57C.js.map +1 -0
  19. package/dist/chunk-N7AI7HZK.js +529 -0
  20. package/dist/chunk-N7AI7HZK.js.map +1 -0
  21. package/dist/chunk-PKTLVQXZ.js +82 -0
  22. package/dist/chunk-PKTLVQXZ.js.map +1 -0
  23. package/dist/chunk-SQE4NPZP.js +31 -0
  24. package/dist/chunk-SQE4NPZP.js.map +1 -0
  25. package/dist/chunk-U6V3HEBB.js +939 -0
  26. package/dist/chunk-U6V3HEBB.js.map +1 -0
  27. package/dist/chunk-VEHNFPEO.js +224 -0
  28. package/dist/chunk-VEHNFPEO.js.map +1 -0
  29. package/dist/development.d.ts +102 -0
  30. package/dist/development.js +33 -0
  31. package/dist/development.js.map +1 -0
  32. package/dist/documentation.d.ts +27 -0
  33. package/dist/documentation.js +7 -0
  34. package/dist/documentation.js.map +1 -0
  35. package/dist/game-analytics.d.ts +5 -0
  36. package/dist/game-analytics.js +7 -0
  37. package/dist/game-analytics.js.map +1 -0
  38. package/dist/game-app-id.d.ts +5 -0
  39. package/dist/game-app-id.js +7 -0
  40. package/dist/game-app-id.js.map +1 -0
  41. package/dist/game-media.d.ts +5 -0
  42. package/dist/game-media.js +7 -0
  43. package/dist/game-media.js.map +1 -0
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +2468 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/scaffold.d.ts +6 -0
  48. package/dist/scaffold.js +20 -0
  49. package/dist/scaffold.js.map +1 -0
  50. package/package.json +82 -3
  51. package/runtime/local-network.d.mts +6 -0
  52. package/runtime/local-network.mjs +9 -0
  53. package/runtime/public-assets.mjs +62 -0
  54. package/runtime/source-fence.mjs +182 -0
  55. package/runtime/vite-config.d.mts +43 -0
  56. package/runtime/vite-config.mjs +134 -0
  57. package/runtime/vite-dev.mjs +18 -0
  58. package/runtime/vite-https.d.mts +11 -0
  59. package/runtime/vite-https.mjs +40 -0
  60. package/template-assets/bootstrap/.claude/launch.json +12 -0
  61. package/template-assets/bootstrap/AGENTS.md +290 -0
  62. package/template-assets/bootstrap/CLAUDE.md +55 -0
  63. package/template-assets/bootstrap/_gitignore +6 -0
  64. package/template-assets/bootstrap/skills/airjam-docs-workflow/SKILL.md +49 -0
  65. package/template-assets/bootstrap/skills/airjam-mcp/SKILL.md +100 -0
  66. package/template-assets/bootstrap/skills/canvas-2d-gameplay/SKILL.md +47 -0
  67. package/template-assets/bootstrap/skills/controller-ui/SKILL.md +71 -0
  68. package/template-assets/bootstrap/skills/debug-and-test/SKILL.md +72 -0
  69. package/template-assets/bootstrap/skills/game-architecture/SKILL.md +102 -0
  70. package/template-assets/bootstrap/skills/game-state-and-rendering/SKILL.md +44 -0
  71. package/template-assets/bootstrap/skills/host-surface/SKILL.md +52 -0
  72. package/template-assets/bootstrap/skills/index.md +36 -0
  73. package/template-assets/bootstrap/skills/prefab-authoring/SKILL.md +58 -0
  74. package/template-assets/bootstrap/skills/r3f-3d-scene/SKILL.md +61 -0
  75. package/template-assets/documentation/for-agents/controller-ui/page.mdx +99 -0
  76. package/template-assets/documentation/for-agents/page.mdx +120 -0
  77. package/template-assets/documentation/for-agents/project-structure/page.mdx +170 -0
  78. package/template-assets/documentation/for-agents/state-and-rendering/page.mdx +77 -0
  79. package/template-assets/documentation/for-agents/supported-agents/page.mdx +18 -0
  80. package/template-assets/documentation/getting-started/debugging/page.mdx +164 -0
  81. package/template-assets/documentation/getting-started/dev-logs/page.mdx +169 -0
  82. package/template-assets/documentation/getting-started/game-ideas/page.mdx +114 -0
  83. package/template-assets/documentation/getting-started/introduction/page.mdx +200 -0
  84. package/template-assets/documentation/getting-started/migrating-legacy-games/page.mdx +673 -0
  85. package/template-assets/documentation/getting-started/quick-start/page.mdx +310 -0
  86. package/template-assets/documentation/how-it-works/architecture/page.mdx +230 -0
  87. package/template-assets/documentation/how-it-works/host-system/page.mdx +270 -0
  88. package/template-assets/documentation/manifest.json +500 -0
  89. package/template-assets/documentation/sdk/assets-and-theme/page.mdx +185 -0
  90. package/template-assets/documentation/sdk/hooks/page.mdx +435 -0
  91. package/template-assets/documentation/sdk/input-system/page.mdx +240 -0
  92. package/template-assets/documentation/sdk/networked-state/page.mdx +295 -0
  93. package/template-assets/documentation/sdk/settings/page.mdx +155 -0
  94. package/template-assets/documentation/sdk/ui-components/page.mdx +268 -0
  95. package/template-assets/managed/.airjam/ai-pack.json +209 -0
  96. package/template-assets/managed/docs/airjam/agent-gold-path.md +115 -0
  97. package/template-assets/managed/docs/airjam/agent-mcp.md +179 -0
  98. package/template-assets/managed/docs/airjam/canvas-2d-gameplay.md +82 -0
  99. package/template-assets/managed/docs/airjam/composition-shell-contract.md +87 -0
  100. package/template-assets/managed/docs/airjam/debug-and-testing.md +104 -0
  101. package/template-assets/managed/docs/airjam/development-loop.md +51 -0
  102. package/template-assets/managed/docs/airjam/docs-index.md +64 -0
  103. package/template-assets/managed/docs/airjam/generated/architecture.md +223 -0
  104. package/template-assets/managed/docs/airjam/generated/assets-and-theme.md +188 -0
  105. package/template-assets/managed/docs/airjam/generated/controller-ui.md +102 -0
  106. package/template-assets/managed/docs/airjam/generated/debugging-and-logs.md +165 -0
  107. package/template-assets/managed/docs/airjam/generated/for-agents.md +123 -0
  108. package/template-assets/managed/docs/airjam/generated/game-ideas.md +107 -0
  109. package/template-assets/managed/docs/airjam/generated/host-system.md +261 -0
  110. package/template-assets/managed/docs/airjam/generated/input-system.md +241 -0
  111. package/template-assets/managed/docs/airjam/generated/introduction.md +195 -0
  112. package/template-assets/managed/docs/airjam/generated/migrating-legacy-games.md +674 -0
  113. package/template-assets/managed/docs/airjam/generated/networked-state.md +298 -0
  114. package/template-assets/managed/docs/airjam/generated/project-structure.md +171 -0
  115. package/template-assets/managed/docs/airjam/generated/quick-start.md +311 -0
  116. package/template-assets/managed/docs/airjam/generated/sdk-hooks.md +430 -0
  117. package/template-assets/managed/docs/airjam/generated/settings.md +158 -0
  118. package/template-assets/managed/docs/airjam/generated/state-and-rendering.md +80 -0
  119. package/template-assets/managed/docs/airjam/generated/supported-agents.md +21 -0
  120. package/template-assets/managed/docs/airjam/generated/ui-components.md +265 -0
  121. package/template-assets/managed/docs/airjam/generated/unified-dev-logs.md +170 -0
  122. package/template-assets/managed/docs/airjam/iconography.md +55 -0
  123. package/template-assets/managed/docs/airjam/prefab-authoring.md +212 -0
  124. package/template-assets/managed/docs/airjam/preview-controllers.md +129 -0
  125. package/template-assets/managed/docs/airjam/r3f-3d-scene.md +163 -0
  126. package/template-assets/managed/docs/airjam/state-lanes-cookbook.md +101 -0
  127. package/template-assets/managed/docs/airjam/visual-system.md +103 -0
@@ -0,0 +1,241 @@
1
+ <!-- Generated from content/docs/sdk/input-system/page.mdx. Do not edit directly. -->
2
+ <!-- Canonical public doc: https://airjam.io/docs/sdk/input-system -->
3
+
4
+ # Input System
5
+
6
+ A game declares the controls each player has. Phones, agents and replays fill
7
+ those controls; the host reads them once per simulation step, with a fixed
8
+ meaning for each kind of control.
9
+
10
+ ## Declare Controls
11
+
12
+ ```ts
13
+ // src/game/contracts/input.ts
14
+ import {
15
+ button,
16
+ defineAirJamInput,
17
+ stick,
18
+ type AirJamInputValues,
19
+ } from "@air-jam/sdk/core";
20
+
21
+ export const shipInput = defineAirJamInput({
22
+ move: stick(),
23
+ fire: button("pressed"),
24
+ boost: button("held"),
25
+ });
26
+
27
+ export type ShipInput = AirJamInputValues<typeof shipInput>;
28
+ ```
29
+
30
+ Declare them once in `src/airjam.config.ts` with `defineAirJamGame` from `@air-jam/sdk/core`:
31
+
32
+ ```ts
33
+ export const airjam = defineAirJamGame({
34
+ // ...
35
+ simulation: shipSimulation,
36
+ input: shipInput,
37
+ });
38
+ ```
39
+
40
+ ## Control Kinds
41
+
42
+ | Kind | Declared as | A step reads |
43
+ | ------------------------------ | -------------------------------- | ------------------------------------------------------------------------------------------ |
44
+ | Held button | `button("held")` | `true` while the button is down, and for at least one step after a tap shorter than a step |
45
+ | Pressed button | `button("pressed")` | `true` for exactly one step per press |
46
+ | Axis | `axis()` | a number from -1 to 1 |
47
+ | Stick | `stick()` | `{ x, y }`, each from -1 to 1; `y` is down, like screen space |
48
+ | Stick that keeps its direction | `stick({ keepDirection: true })` | the last direction while the stick is centred, as in snake |
49
+
50
+ Presses travel as a counter, so a tap between two network packets or two
51
+ simulation steps is never lost or doubled. Games never debounce or latch input
52
+ themselves.
53
+
54
+ ## Read Controls In The Simulation
55
+
56
+ Input reaches a game only in its simulation steps:
57
+
58
+ ```ts
59
+ export const shipSimulation = defineAirJamSimulation<Sim, ShipInput>({
60
+ stepMs: 1000 / 60,
61
+ create: () => createSim(),
62
+ step: (sim, { input, players, dtSeconds }) => {
63
+ for (const player of players) {
64
+ const { move, fire, boost } = input(player.id);
65
+ steer(sim, player.id, move, boost, dtSeconds);
66
+ if (fire) shoot(sim, player.id);
67
+ }
68
+ },
69
+ });
70
+ ```
71
+
72
+ `input(playerId)` always returns every control. A player who has sent nothing
73
+ yet reads as released and centred.
74
+
75
+ ## Phone Controls
76
+
77
+ The SDK's phone controls fill the declared controls and send them; a game
78
+ never runs its own send loop.
79
+
80
+ ```tsx
81
+ import { AxisButton, ControlButton, Stick } from "@air-jam/sdk/ui";
82
+
83
+ <Stick control={shipInput.move} className="size-48 rounded-full bg-zinc-900" />
84
+ <ControlButton control={shipInput.fire} className="bg-red-500 data-[active=true]:ring-2">
85
+ Fire
86
+ </ControlButton>
87
+ ```
88
+
89
+ 1. `ControlButton` binds a button. Each touch, or Space and Enter while it has
90
+ focus, is one press.
91
+ 2. `AxisButton` holds an axis at a value while held, such as a paddle's up and
92
+ down buttons. The latest held button wins.
93
+ 3. `Stick` reads a drag anywhere inside it. `directions="4-way"` snaps it to a
94
+ pad, `deadzone` keeps small offsets centred, and a function child draws the
95
+ whole stick. It stays correct however the controller surface is rotated.
96
+
97
+ Every control sets `data-active` while held, so games style the held state
98
+ with their own classes. Controls release when the phone page loses focus.
99
+
100
+ The controller sends its controls once per display frame when they change, again
101
+ after joining, and on a slow keepalive. Nothing stamps input with a device
102
+ clock.
103
+
104
+ ## Keyboards And Gamepads
105
+
106
+ Declare bindings for the controls and every keyboard layout and gamepad plays
107
+ as a local player, with no phone:
108
+
109
+ ```ts
110
+ import {
111
+ arrows,
112
+ button,
113
+ defineAirJamInput,
114
+ defineAirJamInputBindings,
115
+ stick,
116
+ wasd,
117
+ } from "@air-jam/sdk/core";
118
+
119
+ export const shipInput = defineAirJamInput({
120
+ move: stick(),
121
+ fire: button("pressed"),
122
+ boost: button("held"),
123
+ });
124
+
125
+ export const shipInputBindings = defineAirJamInputBindings(shipInput, {
126
+ keyboard: [
127
+ { move: wasd(), fire: "Space", boost: "ShiftLeft" },
128
+ { move: arrows(), fire: "Enter", boost: "ShiftRight" },
129
+ ],
130
+ gamepad: { move: "leftStick", fire: "south", boost: "rightTrigger" },
131
+ });
132
+
133
+ // airjam.config.ts
134
+ defineAirJamGame({ input: shipInput, inputBindings: shipInputBindings, ... });
135
+ ```
136
+
137
+ 1. Each keyboard layout is one player; every connected gamepad is one more.
138
+ Keys are `KeyboardEvent.code` values. A button binds one or more keys, an
139
+ axis binds `keyAxis(negative, positive)`, and a stick binds `wasd()`,
140
+ `arrows()` or `keyStick({ up, left, down, right })`. A binding for a
141
+ control that isn't declared, or of the wrong kind, throws when declared.
142
+ 2. Gamepad names follow the standard layout: `south`, `east`, `west`,
143
+ `north`, `leftBumper`, `rightBumper`, `leftTrigger`, `rightTrigger`,
144
+ `select`, `start`, stick presses and the d-pad for buttons;
145
+ `leftStickX`/`Y` and `rightStickX`/`Y` for axes; `leftStick`, `rightStick`
146
+ or `dpad` for sticks. Sticks get a small deadzone and stay y down.
147
+ 3. A layout's first key, or a gamepad's first button or stick push, opens a
148
+ seat: a preview phone named "Keyboard 1" or "Gamepad 1" that joins like any
149
+ phone. Its own screen answers menus and lobby buttons; the keys or buttons
150
+ drive play. Minimizing that phone keeps it playing; removing it frees the
151
+ seat, and the next key opens a new one.
152
+ 4. Keys and gamepads count only while the game page has focus, key repeats
153
+ never press, and losing focus or unplugging a gamepad releases what it
154
+ held. Keys aimed at the page's own buttons and fields stay theirs.
155
+
156
+ Local development's preview phones and Studio provide these seats; a page
157
+ with nobody to provide them leaves keys and gamepads alone. Game code never
158
+ listens to keys or polls gamepads itself.
159
+
160
+ A product framing a game offers its preview workspace's phones as that
161
+ game's seats by passing the game frame to `PreviewControllerWorkspace` as
162
+ `localPlayersGame`; `localPlayers={false}` offers none and closes the seats
163
+ it opened. The Arcade offers them only once a player turns keyboard and
164
+ gamepad players on.
165
+
166
+ A product framing its own phones launches each with
167
+ `createPreviewControllerLaunch` from `@air-jam/sdk/preview`, passing its
168
+ page's origin as `parentOrigin` and, for a seat, its label as `localSeat`. A
169
+ phone takes seat input and close requests only from its direct parent at that
170
+ origin, and answers only there; without `parentOrigin` that is the phone's own
171
+ origin, as the preview workspace launches it.
172
+
173
+ ## Agents
174
+
175
+ Agents fill the same controls through leased participant control. They send
176
+ values: a button is `true` or `false`, an axis a number and a stick an
177
+ `{ x, y }`. A button going from `false` to `true` is one press; to press again,
178
+ send `false` and then `true`. The input description agents read comes from the
179
+ declaration.
180
+
181
+ ## Input Log And Replays
182
+
183
+ Every host whose game declares a simulation keeps a version 2 input log,
184
+ from construction, in the browser as well as headless. It contains the real
185
+ seed, resolved initial settings, players joining and leaving, room state,
186
+ store actions applied between steps, controls when they change and accepted
187
+ settings updates. Each event carries the step it reached the game before.
188
+ Actions a step causes replay with the simulation and are not logged again.
189
+ `runtime.inputLog()` reads it locally; it throws while the simulation is
190
+ loading or when the game declares none.
191
+
192
+ The recorder retains the start of the match. It freezes before a step would
193
+ exceed 30 minutes of played game time or 16 MiB (the sum of each entry's JSON
194
+ length). A full log ends at the last whole step and excludes pending events.
195
+ `runtime.inputLogFull` reports this without changing the version 2 format.
196
+ Reload the game to start a new recording.
197
+
198
+ Agents use `readHostInputLog(request, observation.identity)` from
199
+ `@air-jam/sdk/runtime-control` through the existing host-agent channel. It
200
+ returns `{ status: "recorded", log, full }`, or `{ status: "not-replayable",
201
+ reason, message }`. Reasons are `no-simulation`, `loading`, `runtime-replaced`
202
+ and `host-unavailable`. A game without a simulation says:
203
+ "This game has no simulation, so its matches cannot be replayed; record a clip instead."
204
+ Reading needs no room grant. The first `input-log-read` request fixes a cut;
205
+ later pages read the same prefix while the match keeps playing.
206
+
207
+ Headless runs keep the log in their evidence. Running
208
+
209
+ ```bash
210
+ airjam session run replay <run-id>
211
+ ```
212
+
213
+ plays it on a fresh copy of the game, with no server or page, and reports
214
+ whether the replay ends where the run ended.
215
+ `replayAirJamInputLog(airjam.createHostRuntime, log)` from
216
+ `@air-jam/sdk/core` remains the run-to-completion form.
217
+
218
+ For playback, `await openAirJamReplay(airjam.createHostRuntime, log)` returns
219
+ `{ runtime, roomId, agent, stop, stepMs, ticks, tick, done, advance }`.
220
+ It stays paused between calls. `advance({ steps: 10 })` runs whole steps;
221
+ `advance({ ms: elapsed * speed })` carries fractions between calls, so a
222
+ caller can drive any speed per animation frame. Both return the current tick
223
+ and clamp at `ticks`. Reaching the end applies events after the final step
224
+ once, including on a recording with zero steps. Call `stop()` when finished.
225
+
226
+ There is no backward seek. Open a new replay and advance to the desired tick.
227
+ Each replay needs a fresh load of the same game source, in its own page or
228
+ headless process: game stores are module singletons and cannot share the load
229
+ with the live game or another replay. Exact replay also requires game code to
230
+ draw randomness from the step's seeded `random`.
231
+
232
+ ### A Control Does Nothing
233
+
234
+ 1. Check the control is declared and passed to `defineAirJamGame({ input })`.
235
+ 2. Read it in the simulation step; the host has no other way to read input.
236
+ 3. Render phone controls inside `<airjam.Controller>`.
237
+
238
+ ### A Tap Fires Twice Or Not At All
239
+
240
+ Use `button("pressed")` for one-shot actions, which then read `true` once per
241
+ press, and `button("held")` for actions that last while held.
@@ -0,0 +1,195 @@
1
+ <!-- Generated from content/docs/getting-started/introduction/page.mdx. Do not edit directly. -->
2
+ <!-- Canonical public doc: https://airjam.io/docs/getting-started/introduction -->
3
+
4
+ # Introduction
5
+
6
+ Air Jam is an open **AI-native framework for multiplayer games controlled by
7
+ phones**. A computer or TV acts as the host display, smartphones become the
8
+ controllers, and both humans and coding agents build against the same runtime,
9
+ input, state, and release model.
10
+
11
+ ## Key Features
12
+
13
+ - **Zero App Download**: Players join by scanning a QR code—no app store required
14
+ - **Instant Multiplayer**: Connect smartphones up to the game’s declared player capacity
15
+ - **Developer Friendly**: Built with modern web technologies (React, TypeScript)
16
+ - **AI-Native By Design**: Humans and agents share explicit contracts for runtime, input, logs, and release workflows
17
+ - **Type Safe**: End-to-end type safety with Zod schema validation
18
+ - **Performance Optimized**: Tap-safe button input with fixed tick cadence
19
+ - **Haptic Feedback**: Send vibration patterns to controllers for game events
20
+
21
+ ### 1. Install the SDK
22
+
23
+ ```bash
24
+ pnpm add @air-jam/sdk
25
+ ```
26
+
27
+ ### 2. Wrap Your App
28
+
29
+ ```tsx filename="src/app.tsx"
30
+ import { createAirJamApp, env } from "@air-jam/sdk";
31
+ import { airjam as game } from "./airjam.config";
32
+
33
+ const airjam = createAirJamApp(game, { runtime: env.vite(import.meta.env) });
34
+
35
+ export const App = () => (
36
+ <Routes>
37
+ <Route
38
+ path="/"
39
+ element={
40
+ <airjam.Host
41
+ onPlayerJoin={(player) => {
42
+ console.log(`${player.label} joined!`);
43
+ }}
44
+ onPlayerLeave={(id) => {
45
+ console.log(`Player ${id} left`);
46
+ }}
47
+ >
48
+ <HostView />
49
+ </airjam.Host>
50
+ }
51
+ />
52
+ <Route
53
+ path={airjam.paths.controller}
54
+ element={
55
+ <airjam.Controller>
56
+ <ControllerView />
57
+ </airjam.Controller>
58
+ }
59
+ />
60
+ </Routes>
61
+ );
62
+ ```
63
+
64
+ ```ts filename="src/airjam.config.ts"
65
+ import { defineAirJamGame } from "@air-jam/sdk/core";
66
+ import {
67
+ axis,
68
+ button,
69
+ defineAirJamInput,
70
+ defineAirJamSimulation,
71
+ type AirJamInputValues,
72
+ } from "@air-jam/sdk/core";
73
+
74
+ export const gameInput = defineAirJamInput({
75
+ direction: axis(),
76
+ fire: button("pressed"),
77
+ });
78
+
79
+ const simulation = defineAirJamSimulation<
80
+ World,
81
+ AirJamInputValues<typeof gameInput>
82
+ >({
83
+ stepMs: 1000 / 60,
84
+ create: () => createWorld(),
85
+ step: (world, { input, players, dtSeconds }) => {
86
+ for (const player of players) {
87
+ const { direction, fire } = input(player.id);
88
+ movePaddle(world, player.id, direction * SPEED * dtSeconds);
89
+ if (fire) fireLaser(world, player.id);
90
+ }
91
+ },
92
+ });
93
+
94
+ export const airjam = defineAirJamGame({
95
+ metadata: {
96
+ slug: "space-game",
97
+ name: "Space Game",
98
+ tagline: "Fly together and defend the fleet.",
99
+ category: "arcade",
100
+ minPlayers: 1,
101
+ maxPlayers: 4,
102
+ inputModalities: ["buttons", "touch"],
103
+ supportedSdkRange: "^1.0.0",
104
+ maintainer: { name: "Air Jam" },
105
+ version: 1,
106
+ },
107
+ controllerPath: "/controller",
108
+ simulation,
109
+ input: gameInput,
110
+ });
111
+ ```
112
+
113
+ ### 3. Create Your Host View
114
+
115
+ The path below matches the current starter template layout.
116
+ It is a good default, not a required framework filename.
117
+
118
+ ```tsx filename="src/host/index.tsx"
119
+ import { useAirJamHost } from "@air-jam/sdk";
120
+
121
+ const HostView = () => {
122
+ const host = useAirJamHost();
123
+ // The simulation moves the game; this view draws it with useSimulationFrame.
124
+
125
+ return (
126
+ <div className="relative min-h-screen bg-black text-white">
127
+ <header className="absolute top-0 right-0 left-0 z-10 flex items-center justify-between border-b border-white/10 bg-black/70 px-4 py-2 backdrop-blur">
128
+ <span>Room {host.roomId}</span>
129
+ <button
130
+ onClick={
131
+ host.runtimeState === "playing"
132
+ ? host.pauseRuntime
133
+ : host.resumeRuntime
134
+ }
135
+ >
136
+ {host.runtimeState === "playing" ? "Pause" : "Resume"}
137
+ </button>
138
+ </header>
139
+ <GameCanvas />
140
+ </div>
141
+ );
142
+ };
143
+ ```
144
+
145
+ Mount host ownership once at `<airjam.Host ...>`, then use `useAirJamHost()` only as a consumer hook inside that boundary.
146
+
147
+ ### 4. Create Your Controller View
148
+
149
+ The path below also matches the current starter template layout.
150
+ If your project uses a different file shape, keep the same ownership boundary even if the filename changes.
151
+
152
+ ```tsx filename="src/controller/index.tsx"
153
+ import { AxisButton, ControlButton } from "@air-jam/sdk/ui";
154
+ import { gameInput } from "../airjam.config";
155
+
156
+ const ControllerView = () => (
157
+ <div className="grid h-full grid-cols-2 gap-3 p-3">
158
+ <AxisButton control={gameInput.direction} value={-1}>
159
+ Up
160
+ </AxisButton>
161
+ <AxisButton control={gameInput.direction} value={1}>
162
+ Down
163
+ </AxisButton>
164
+ <ControlButton control={gameInput.fire} className="col-span-2">
165
+ Fire
166
+ </ControlButton>
167
+ </div>
168
+ );
169
+ ```
170
+
171
+ The SDK's phone controls fill the declared controls and send them; the
172
+ controller runs no send loop.
173
+
174
+ ## Canonical Architecture: Three Lanes
175
+
176
+ Use one lane per concern:
177
+
178
+ 1. **Input lane**: controls declared with `defineAirJamInput`, filled by the SDK's phone controls, read in simulation steps with `input(playerId)`.
179
+ 2. **State lane**: `createAirJamStore` with host-owned actions, dispatched through `store.actions`.
180
+ 3. **Signal lane**: `sendSignal` / system commands for out-of-band UX and runtime commands.
181
+
182
+ Arcade does not replace this model. Arcade is an Air Jam app around another
183
+ Air Jam app, so the same lane rules still apply in embedded runtime mode.
184
+
185
+ Avoid cross-lane misuse:
186
+
187
+ 1. Don’t stream per-frame movement through store actions.
188
+ 2. Don’t encode authoritative gameplay state in signals.
189
+ 3. Don’t call `state.actions.*`; dispatch through `gameStore.actions`.
190
+
191
+ ## Next Steps
192
+
193
+ - [Architecture](./architecture.md) - Understand the system design
194
+ - [Hooks Reference](./sdk-hooks.md) - Complete API documentation
195
+ - [Input System](./input-system.md) - Declare controls and read them each step