@air-jam/cli 0.9.3 → 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 (94) 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/package.json +8 -4
  34. package/runtime/local-network.d.mts +4 -6
  35. package/runtime/public-assets.mjs +62 -0
  36. package/runtime/source-fence.mjs +182 -0
  37. package/runtime/vite-config.d.mts +2 -1
  38. package/runtime/vite-config.mjs +6 -2
  39. package/runtime/vite-dev.mjs +18 -0
  40. package/runtime/vite-https.mjs +2 -3
  41. package/template-assets/bootstrap/AGENTS.md +56 -14
  42. package/template-assets/bootstrap/CLAUDE.md +0 -8
  43. package/template-assets/bootstrap/skills/airjam-mcp/SKILL.md +44 -0
  44. package/template-assets/bootstrap/skills/controller-ui/SKILL.md +2 -0
  45. package/template-assets/bootstrap/skills/game-architecture/SKILL.md +47 -3
  46. package/template-assets/bootstrap/skills/index.md +1 -1
  47. package/template-assets/bootstrap/skills/prefab-authoring/SKILL.md +10 -0
  48. package/template-assets/bootstrap/skills/r3f-3d-scene/SKILL.md +10 -0
  49. package/template-assets/documentation/for-agents/controller-ui/page.mdx +41 -2
  50. package/template-assets/documentation/for-agents/page.mdx +24 -2
  51. package/template-assets/documentation/for-agents/project-structure/page.mdx +0 -2
  52. package/template-assets/documentation/for-agents/state-and-rendering/page.mdx +0 -2
  53. package/template-assets/documentation/for-agents/supported-agents/page.mdx +18 -0
  54. package/template-assets/documentation/getting-started/debugging/page.mdx +7 -8
  55. package/template-assets/documentation/getting-started/dev-logs/page.mdx +0 -2
  56. package/template-assets/documentation/getting-started/game-ideas/page.mdx +1 -3
  57. package/template-assets/documentation/getting-started/introduction/page.mdx +71 -54
  58. package/template-assets/documentation/getting-started/migrating-legacy-games/page.mdx +308 -62
  59. package/template-assets/documentation/getting-started/quick-start/page.mdx +56 -79
  60. package/template-assets/documentation/how-it-works/architecture/page.mdx +91 -50
  61. package/template-assets/documentation/how-it-works/host-system/page.mdx +112 -109
  62. package/template-assets/documentation/manifest.json +112 -42
  63. package/template-assets/documentation/sdk/assets-and-theme/page.mdx +185 -0
  64. package/template-assets/documentation/sdk/hooks/page.mdx +106 -171
  65. package/template-assets/documentation/sdk/input-system/page.mdx +201 -231
  66. package/template-assets/documentation/sdk/networked-state/page.mdx +134 -52
  67. package/template-assets/documentation/sdk/settings/page.mdx +155 -0
  68. package/template-assets/documentation/sdk/ui-components/page.mdx +45 -4
  69. package/template-assets/managed/.airjam/ai-pack.json +61 -43
  70. package/template-assets/managed/docs/airjam/agent-gold-path.md +55 -7
  71. package/template-assets/managed/docs/airjam/agent-mcp.md +44 -0
  72. package/template-assets/managed/docs/airjam/debug-and-testing.md +18 -0
  73. package/template-assets/managed/docs/airjam/docs-index.md +18 -12
  74. package/template-assets/managed/docs/airjam/generated/architecture.md +91 -46
  75. package/template-assets/managed/docs/airjam/generated/assets-and-theme.md +188 -0
  76. package/template-assets/managed/docs/airjam/generated/controller-ui.md +41 -0
  77. package/template-assets/managed/docs/airjam/generated/debugging-and-logs.md +7 -6
  78. package/template-assets/managed/docs/airjam/generated/for-agents.md +24 -0
  79. package/template-assets/managed/docs/airjam/generated/game-ideas.md +1 -1
  80. package/template-assets/managed/docs/airjam/generated/host-system.md +112 -102
  81. package/template-assets/managed/docs/airjam/generated/input-system.md +199 -218
  82. package/template-assets/managed/docs/airjam/generated/introduction.md +71 -51
  83. package/template-assets/managed/docs/airjam/generated/migrating-legacy-games.md +308 -60
  84. package/template-assets/managed/docs/airjam/generated/networked-state.md +134 -50
  85. package/template-assets/managed/docs/airjam/generated/quick-start.md +56 -79
  86. package/template-assets/managed/docs/airjam/generated/sdk-hooks.md +106 -166
  87. package/template-assets/managed/docs/airjam/generated/settings.md +158 -0
  88. package/template-assets/managed/docs/airjam/generated/supported-agents.md +21 -0
  89. package/template-assets/managed/docs/airjam/generated/ui-components.md +45 -2
  90. package/template-assets/managed/docs/airjam/prefab-authoring.md +100 -0
  91. package/template-assets/managed/docs/airjam/preview-controllers.md +4 -1
  92. package/template-assets/managed/docs/airjam/r3f-3d-scene.md +66 -0
  93. package/template-assets/managed/docs/airjam/state-lanes-cookbook.md +15 -20
  94. package/dist/chunk-A4V2N4LX.js.map +0 -1
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  # Migrating Legacy Games
4
2
 
5
3
  This guide is for older Air Jam games that still use the pre-v1 app shape.
@@ -12,6 +10,13 @@ If you are starting fresh, use [Quick Start](/docs/getting-started/quick-start)
12
10
  repo-wide migration work.
13
11
  </Callout>
14
12
 
13
+ ## Node.js Minimum
14
+
15
+ Air Jam 1.0 authoring requires Node.js 22.15 or newer for devtools, the CLI and MCP,
16
+ create-airjam and generated projects. The declaration loader uses synchronous
17
+ module hooks to enforce its framework-free boundary through imports, `require`
18
+ and `createRequire`. The SDK and server retain their Node.js 22.0 minimum.
19
+
15
20
  ## When You Need This Guide
16
21
 
17
22
  You are likely on the old shape if your game still has some of these patterns:
@@ -61,7 +66,7 @@ Not every migrated game must match that exact folder tree.
61
66
 
62
67
  What matters is the boundary model:
63
68
 
64
- 1. `createAirJamApp(...)` defines runtime and input config
69
+ 1. `defineAirJamGame(...)` declares the game in core; `createAirJamApp(game, options)` binds its browser runtime
65
70
  2. `app.tsx` owns route-level `<airjam.Host>` and `<airjam.Controller>` wrappers
66
71
  3. host/controller runtime owner hooks mount only in those route entry files
67
72
  4. replicated state uses the current `createAirJamStore` action contract
@@ -108,16 +113,27 @@ export function App() {
108
113
 
109
114
  Target shape:
110
115
 
111
- ```tsx filename="src/airjam.config.ts"
112
- import { createAirJamApp, env } from "@air-jam/sdk";
113
- import { gameInputSchema } from "./game/input";
114
-
115
- export const airjam = createAirJamApp({
116
- runtime: env.vite(import.meta.env),
117
- controllerPath: "/controller",
118
- input: {
119
- schema: gameInputSchema,
116
+ ```ts filename="src/airjam.config.ts"
117
+ import { defineAirJamGame } from "@air-jam/sdk/core";
118
+ import { gameInput } from "./game/input";
119
+ import { simulation } from "./game/simulation";
120
+
121
+ export const airjam = defineAirJamGame({
122
+ metadata: {
123
+ slug: "space-game",
124
+ name: "Space Game",
125
+ tagline: "Fly together and defend the fleet.",
126
+ category: "arcade",
127
+ minPlayers: 1,
128
+ maxPlayers: 4,
129
+ inputModalities: ["buttons", "touch"],
130
+ supportedSdkRange: "^1.0.0",
131
+ maintainer: { name: "Air Jam" },
132
+ version: 1,
120
133
  },
134
+ controllerPath: "/controller",
135
+ simulation,
136
+ input: gameInput,
121
137
  });
122
138
  ```
123
139
 
@@ -138,7 +154,10 @@ Target shape:
138
154
 
139
155
  ```tsx filename="src/app.tsx"
140
156
  import { Route, Routes } from "react-router-dom";
141
- import { airjam } from "./airjam.config";
157
+ import { createAirJamApp, env } from "@air-jam/sdk";
158
+ import { airjam as game } from "./airjam.config";
159
+
160
+ const airjam = createAirJamApp(game, { runtime: env.vite(import.meta.env) });
142
161
 
143
162
  export function App() {
144
163
  return (
@@ -209,10 +228,8 @@ actions: {
209
228
  Controller-side dispatch should always look like:
210
229
 
211
230
  ```tsx filename="src/routes/controller-view.tsx"
212
- const actions = useGameStore.useActions();
213
-
214
- actions.joinTeam({ team: "team1" });
215
- actions.setReady({ ready: true });
231
+ gameStore.actions.joinTeam({ team: "team1" });
232
+ gameStore.actions.setReady({ ready: true });
216
233
  ```
217
234
 
218
235
  Do not keep trailing `playerId` arguments around.
@@ -285,13 +302,14 @@ The migration guide is about boundaries, not folder cosplay.
285
302
 
286
303
  ### Branch C: Host-Simulation-Heavy App
287
304
 
288
- If most of the game logic lives in a host-side hook or engine module, keep that boundary explicit:
305
+ If most of the game logic lives in a host-side hook or `useHostTick` loop, move it into a declared simulation (`defineAirJamSimulation`, declared with `defineAirJamGame({ simulation })`). `useHostTick` is removed.
289
306
 
290
307
  1. replicated store state owns shared, synchronized state
291
- 2. host-local hook/engine owns timers, refs, physics, media loading, and simulation details
292
- 3. only the minimum necessary state should cross between them
308
+ 2. the simulation owns timers, positions, physics and outcomes; it reads input from its step context, uses the step's `random` and game time instead of `Math.random()` and `Date.now()`, and dispatches store actions for outcomes such as scores
309
+ 3. the host view draws with `useSimulationFrame`, plays sounds and toasts from `useSimulationEvents`, and keeps media loading and draw caches
310
+ 4. what agents see moves from `useHostAgentObservation` into the simulation's `observe`
293
311
 
294
- This is usually cleaner than trying to stuff the whole game loop into the replicated store.
312
+ This is usually cleaner than trying to stuff the whole game loop into the replicated store, and it lets the game's tests run headless.
295
313
 
296
314
  ## Step 6: Migrate Input Based On Input Type
297
315
 
@@ -299,46 +317,35 @@ Do not overgeneralize input migration.
299
317
 
300
318
  ### Continuous Input Games
301
319
 
302
- If your controller sends directional or analog-style input every frame, prefer:
320
+ If your controller sends directional or analog-style input, declare those
321
+ controls and let the SDK's phone controls send them:
303
322
 
304
- 1. local refs/state
305
- 2. `useInputWriter()`
306
- 3. `useControllerTick(...)`
323
+ ```tsx filename="src/game/input.ts"
324
+ import { button, defineAirJamInput, stick } from "@air-jam/sdk/core";
307
325
 
308
- Example:
326
+ export const gameInput = defineAirJamInput({
327
+ move: stick(),
328
+ action: button("held"),
329
+ });
330
+ ```
309
331
 
310
- ```tsx filename="src/routes/controller-view.tsx"
311
- import {
312
- useAirJamController,
313
- useControllerTick,
314
- useInputWriter,
315
- } from "@air-jam/sdk";
316
- import { useRef } from "react";
332
+ ```tsx filename="src/controller/index.tsx"
333
+ import { ControlButton, Stick } from "@air-jam/sdk/ui";
334
+ import { gameInput } from "../game/input";
317
335
 
318
336
  export function ControllerView() {
319
- const controller = useAirJamController();
320
- const writeInput = useInputWriter();
321
- const movementRef = useRef({ x: 0, y: 0 });
322
- const actionRef = useRef(false);
323
-
324
- useControllerTick(
325
- () => {
326
- writeInput({
327
- movementX: movementRef.current.x,
328
- movementY: movementRef.current.y,
329
- action: actionRef.current,
330
- });
331
- },
332
- {
333
- enabled:
334
- controller.connectionStatus === "connected" &&
335
- controller.runtimeState === "playing",
336
- intervalMs: 16,
337
- },
337
+ return (
338
+ <div className="grid h-full grid-cols-2 gap-3 p-3">
339
+ <Stick control={gameInput.move} />
340
+ <ControlButton control={gameInput.action}>Action</ControlButton>
341
+ </div>
338
342
  );
339
343
  }
340
344
  ```
341
345
 
346
+ The simulation reads them each step with `input(playerId)`. Remove the old
347
+ send loop, input writer and any timestamp field.
348
+
342
349
  ### Action-Only Or Choice-Driven Games
343
350
 
344
351
  If the controller mainly sends taps, choices, or store actions, do not add per-frame input machinery just because another game needed it.
@@ -347,17 +354,13 @@ Use the simpler model that matches your game.
347
354
 
348
355
  For more input details, see [Input System](/docs/sdk/input-system).
349
356
 
350
- ## Step 7: Clean Up Old `latch` Usage Carefully
351
-
352
- Older games may still configure input through `latch`.
353
-
354
- For most games, the right migration is smaller than you think:
357
+ ## Step 7: Replace `latch` And Input Behavior Lists
355
358
 
356
- - move the schema into `airjam.config.ts`
357
- - remove `latch` entirely
358
- - keep the default input behavior unless you have a real non-default need
359
-
360
- Only add `input.behavior` overrides when the defaults are not enough.
359
+ Older games configure input through `latch` or `input.behavior` lists of
360
+ `pulse`, `hold` and `latest` fields. Both are gone: each control's kind carries
361
+ its meaning. A tap-safe boolean becomes `button("pressed")`, a held boolean
362
+ `button("held")`, a sticky vector `stick({ keepDirection: true })`, and any
363
+ other number an `axis()`.
361
364
 
362
365
  ## Step 8: Remove Legacy Workarounds
363
366
 
@@ -418,6 +421,249 @@ That order usually sharpens the guide fastest:
418
421
  2. second app forces the harder boundary decisions
419
422
  3. third app benefits from the refined guide and should migrate more cleanly
420
423
 
424
+ ## From 0.9 To 1.0
425
+
426
+ Games written against the 0.9 SDK, including agent-made Studio games, move
427
+ mechanically with the mappings below. Each removal fails typecheck, so work
428
+ through the compiler errors with this section open.
429
+
430
+ ### The game is declared in core
431
+
432
+ `src/airjam.config.ts` exports only the named `airjam = defineAirJamGame(...)`
433
+ declaration from `@air-jam/sdk/core`. Move metadata into its `metadata` field;
434
+ remove the separate metadata export. Its entire import graph must stay free of
435
+ React, the SDK root, TSX and CSS. The loader names the importing file with
436
+ `AJ_DECLARATION_NOT_FRAMEWORK_FREE` when that boundary is crossed.
437
+
438
+ Move `createAirJamApp` to `app.tsx` and call
439
+ `createAirJamApp(airjam, { runtime: env.vite(import.meta.env) })`. The binding
440
+ returns `Host`, `Controller`, `paths` and `session`; game data stays on the
441
+ declaration. Passing the former options object as the first argument fails
442
+ with an error naming `defineAirJamGame` as its replacement.
443
+
444
+ Import agent helpers and their types from `@air-jam/sdk/core`. A declared
445
+ `testing` path, relative to the config, names the development module:
446
+
447
+ ```ts
448
+ import { defineAirJamTesting } from "@air-jam/devtools/testing";
449
+ import { gamePlayer } from "./player";
450
+
451
+ export const testing = defineAirJamTesting({
452
+ player: gamePlayer,
453
+ profiles: { scoring, diagnostics },
454
+ // Optional: visual: { scenarios: [...] }, using the game's declared agent.
455
+ });
456
+ ```
457
+
458
+ The declared player is offered as `model` in every profile. Remove each
459
+ profile's manually created model policy; the name is reserved and fails with
460
+ `AJ_TEST_POLICY_RESERVED` when authored. Visual packs no longer declare their
461
+ own agent. Tools read the game through `airjam.inspect_game` and its
462
+ `declaration.agent` field.
463
+
464
+ Remove capacity from runtime options. `metadata.maxPlayers` is the capacity
465
+ for both browser and headless rooms: a four-player game refuses a fifth phone.
466
+ Remove identity fields from `airjam-template.json`; it now holds only scaffold
467
+ and export flags. Regenerate template catalogs after changing declarations.
468
+
469
+ ### Stores Are Plain Objects
470
+
471
+ `createAirJamStore` moved to `@air-jam/sdk/core` and returns a store object,
472
+ not a hook. Declare every store in the app; reading an undeclared store throws
473
+ `AJ_STORE_NOT_DECLARED`.
474
+
475
+ ```ts
476
+ // 0.9
477
+ import { createAirJamStore } from "@air-jam/sdk";
478
+ export const useGameStore = createAirJamStore<GameState>((set) => ({ ... }));
479
+
480
+ // 1.0
481
+ import { createAirJamStore } from "@air-jam/sdk/core";
482
+ export const gameStore = createAirJamStore<GameState>((set) => ({ ... }));
483
+ // airjam.config.ts
484
+ defineAirJamGame({ stores: [gameStore], ... });
485
+ ```
486
+
487
+ | 0.9 | 1.0 |
488
+ | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
489
+ | `useGameStore((s) => s.score)` | `useAirJamStore(gameStore, (s) => s.score)` from `@air-jam/sdk` |
490
+ | `useGameStore.useActions().joinTeam(...)` | `gameStore.actions.joinTeam(...)` |
491
+ | `useGameStore.asPlayer(id)` | `gameStore.asPlayer(id)` |
492
+ | `useGameStore.getState()`, `.subscribe` | `gameStore.getState()`, `gameStore.subscribe` |
493
+ | `useGameStore.useHostActionListener(listener)` | `useHostActionListener(gameStore, listener)` from `@air-jam/sdk` |
494
+ | `useGameStore.useLiveStateRef().current` | `gameStore.getState()`, always current |
495
+ | `acceptAirJamAction`, `rejectAirJamAction`, `AirJamActionContext` and the other store types from `@air-jam/sdk` | the same names from `@air-jam/sdk/core` |
496
+ | `createAirJamStore(init, { storeDomain })` | unchanged, from `@air-jam/sdk/core` |
497
+ | `Date.now()` inside an action | `ctx.now`, the game time the action runs at |
498
+
499
+ Shells that compose runtimes themselves, such as the Arcade, pass their
500
+ stores to `AirJamHostRuntime` and `AirJamControllerRuntime` from
501
+ `@air-jam/sdk/arcade/runtime` with the `stores` prop.
502
+
503
+ ### Settings are declared
504
+
505
+ Move tunable speed, force, damage, health, duration and count constants into
506
+ `defineAirJamSettings` from `@air-jam/sdk/core`, and pass the result as the
507
+ `settings` field of `defineAirJamGame`. Keep a leaf settings module and infer
508
+ its values with `AirJamSettingsValues<typeof gameSettings>`. Delete the old
509
+ constants. Lobby choices remain store state.
510
+
511
+ Read `settings` in simulation create, step and observe contexts, and in
512
+ `AirJamActionContext<GameSettings>`. Supply the fourth simulation type parameter
513
+ for typed values. Host drawing uses `useAirJamSettings(gameSettings)`; copy any
514
+ phone display values into the store rather than reading settings on controllers.
515
+
516
+ Only settings declared `live: true` can change during a host's lifetime.
517
+ `airjam.read_game_settings` returns the current values and revision;
518
+ `airjam.update_game_settings` takes an atomic patch and `expectedRevision`.
519
+ Unknown, invalid, stale and non-live updates fail with `AJ_SETTING_UNKNOWN`,
520
+ `AJ_SETTING_INVALID`, `AJ_SETTING_STALE` and `AJ_SETTING_NOT_LIVE` respectively.
521
+ Start a new room through `airjam.start_game_run({ settings: { ... }, ... })`
522
+ for a non-live value. Input logs now require version 2, resolved initial
523
+ settings and the ordered settings events; version 1 logs must be recorded again.
524
+
525
+ See [Game Settings](/docs/sdk/settings) for declarations, host hooks and CLI
526
+ commands.
527
+
528
+ ### Assets and theme are declared
529
+
530
+ Move sound manifests into `defineAirJamAssets` from `@air-jam/sdk/core` and
531
+ pass the result as `assets` in `defineAirJamGame`. Import `SoundConfig` from
532
+ `@air-jam/sdk/core`. Declare images and other loaded files there too, using
533
+ served paths under `public/`. Read their paths
534
+ from the object and remove old manifests and path imports. Use sound `surface`
535
+ marks for host-only or controller-only audio. Remove game-owned `<AudioRuntime>`
536
+ mounts; the binding supplies it on each surface. Keep playlist and playback
537
+ logic inside that binding.
538
+
539
+ Move colours and font families into `defineAirJamTheme` and pass it as `theme`.
540
+ Map existing Tailwind names to `--airjam-color-*` and `--airjam-font-*` with
541
+ `@theme inline`. Canvas and 3D drawing read the same theme object. Remove
542
+ repeated colour and font literals; shadows and gradients remain CSS.
543
+ Inspection now fails `AJ_ASSET_MISSING` for a declared file that is absent.
544
+
545
+ See [Game Assets and Theme](/docs/sdk/assets-and-theme) for the complete shapes.
546
+
547
+ ### The SDK Owns The Loop
548
+
549
+ `useHostTick` is removed. Per-step game logic moves into a declared
550
+ simulation; components only draw it.
551
+
552
+ ```tsx
553
+ // 0.9
554
+ useHostTick({
555
+ mode: "fixed",
556
+ intervalMs: 16,
557
+ onTick: ({ deltaSeconds }) => stepGame(world, deltaSeconds),
558
+ });
559
+
560
+ // 1.0: src/game/simulation.ts
561
+ export const simulation = defineAirJamSimulation<World, GameInput, GameEvent>({
562
+ stepMs: 16,
563
+ create: ({ random }) => createWorld(random),
564
+ step: (world, { dtSeconds, input, players, random, emit }) =>
565
+ stepGame(world, dtSeconds),
566
+ observe: (world) => ({ score: world.score }),
567
+ });
568
+ // airjam.config.ts
569
+ defineAirJamGame({ simulation, ... });
570
+ ```
571
+
572
+ | 0.9 | 1.0 |
573
+ | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
574
+ | `useHostTick({ onTick })` | the simulation's `step` |
575
+ | `useHostTick({ onFrame })`, `fixedStepAlpha` | `useSimulationFrame(({ sim, alpha }) => draw(sim, alpha))` |
576
+ | `HostTickInfo.deltaSeconds`, `.tick` | the step context's `dtSeconds`, `tick` |
577
+ | `Math.random()` in game logic | the step context's `random` |
578
+ | `useHostAgentObservation({ read, capture })` | `read` becomes the simulation's `observe`; `useHostAgentCapture(draw)` draws into the supplied canvas, and its returned function runs after the game renders |
579
+ | UI state derived from the world | `useSimulationSelector((sim) => value)` |
580
+ | one-off feedback such as sounds | `emit` in `step`, `useSimulationEvents` in a component |
581
+
582
+ ### Input Is Declared
583
+
584
+ The `input: { schema, behavior }` config, controller send loops and the host's
585
+ `getInput` are removed. A game declares its controls, the SDK's phone controls
586
+ send them, and the simulation reads them each step.
587
+
588
+ ```tsx
589
+ // 0.9: src/game/contracts/input.ts
590
+ export const gameInputSchema = z.object({ direction: z.number(), fire: z.boolean() });
591
+ // airjam.config.ts
592
+ createAirJamApp({ input: { schema: gameInputSchema, behavior: { pulse: ["fire"] } }, ... });
593
+ // controller
594
+ const writeInput = useInputWriter();
595
+ useControllerTick(() => writeInput({ direction: directionRef.current, fire: fireRef.current }), {
596
+ intervalMs: 16,
597
+ });
598
+ <button onPointerDown={() => (directionRef.current = -1)} onPointerUp={() => (directionRef.current = 0)}>Up</button>
599
+ // host
600
+ const { direction, fire } = host.getInput(playerId) ?? { direction: 0, fire: false };
601
+
602
+ // 1.0: src/game/contracts/input.ts
603
+ import { axis, button, defineAirJamInput } from "@air-jam/sdk/core";
604
+ export const gameInput = defineAirJamInput({ direction: axis(), fire: button("pressed") });
605
+ // airjam.config.ts
606
+ defineAirJamGame({ input: gameInput, simulation, ... });
607
+ // controller
608
+ import { AxisButton, ControlButton } from "@air-jam/sdk/ui";
609
+ <AxisButton control={gameInput.direction} value={-1}>Up</AxisButton>
610
+ <ControlButton control={gameInput.fire}>Fire</ControlButton>
611
+ // simulation step
612
+ step: (sim, { input, players }) => {
613
+ for (const player of players) {
614
+ const { direction, fire } = input(player.id);
615
+ }
616
+ },
617
+ ```
618
+
619
+ | 0.9 | 1.0 |
620
+ | --------------------------------------------------------- | ------------------------------------------------------------------------------ |
621
+ | a boolean in `behavior.pulse` or `latch` | `button("pressed")`: true for exactly one step per press |
622
+ | any other boolean | `button("held")` |
623
+ | a number from -1 to 1 | `axis()`, sent by `AxisButton` with a `value` |
624
+ | a `{ x, y }` vector | `stick()`, or `stick({ keepDirection: true })` for a vector in `behavior.hold` |
625
+ | a timestamp or sequence field | nothing: the SDK orders input by step |
626
+ | buttons with pointer handlers writing refs | `ControlButton`, `AxisButton` and `Stick`, styled through `data-active` |
627
+ | `useInputWriter` and `useControllerTick` send loops | nothing: the controller runtime sends on change, once per frame |
628
+ | `host.getInput(playerId)` or `useGetInput` in a host tick | `input(playerId)` in the simulation's `step`; it always returns every control |
629
+ | `z.infer<typeof gameInputSchema>` | `AirJamInputValues<typeof gameInput>` from `@air-jam/sdk/core` |
630
+
631
+ Choices, menus and other taps that are not per-step play stay store actions.
632
+
633
+ ### Removed Exports
634
+
635
+ These exports are gone; use the replacement.
636
+
637
+ | Removed | Use instead |
638
+ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
639
+ | `@air-jam/sdk/arcade`, `@air-jam/sdk/arcade/bridge` | the leaf that owns the concept, such as `@air-jam/sdk/arcade/bridge/host` |
640
+ | `useHostTick`, `HostTickInfo`, `HostTickOptions`, `HostFrameInfo` | a declared simulation, above |
641
+ | `useHostAgentObservation` | the simulation's `observe` and `useHostAgentCapture` |
642
+ | `AirJamSyncedStoreHook` | `AirJamStore` from `@air-jam/sdk/core` |
643
+ | `useConnectionStatus()` | `useAirJamHost((s) => s.connectionStatus)` or `useAirJamController((s) => s.connectionStatus)` |
644
+ | `usePlayers()` | `useAirJamHost((s) => s.players)` |
645
+ | `isActiveMatchPhase`, `isEndedMatchPhase`, `isStandardMatchPhase`, `standardMatchPhases` | compare the phase directly; `toShellMatchPhase` stays |
646
+ | `AirJamErrorBoundary`, `PlatformSettingsBoundary` | nothing: `createAirJamApp` and the session runtimes mount both |
647
+ | `getEffectiveAudioVolume`, `useAudioCategoryVolume`, `mergeRoomPlatformSettingsSnapshot` | `useMusicVolume`, `usePlatformAudioSettings` |
648
+ | `parseAirJamGameMetadata` | `airJamGameMetadataSchema.safeParse` |
649
+ | `RoomCode`, `RunMode`, `SignalPayload`, `SignalType`, `ControllerStatePayload`, `ControllerUpdatePlayerProfileAck`, `AirJamActionAccepted`, `AirJamActionRejected` from `@air-jam/sdk` | the same types from `@air-jam/sdk/protocol` |
650
+ | `isInternalActionName`, `resolveControllerJoinSource`, `JoinUrlStatus` from `@air-jam/sdk/core` | internal; `JoinUrlStatus` comes from `@air-jam/sdk` |
651
+ | `buttonVariants`, `getPlayerAvatarImageUrl`, `resolvePlayerAvatarSeed` from `@air-jam/sdk/ui` | `Button`, `PlayerAvatar` |
652
+ | `useInputWriter`, `useControllerTick`, `ControllerTickInfo`, `ControllerTickOptions` | declared controls and the SDK's phone controls, above |
653
+ | `useGetInput`, the host's `getInput` | `input(playerId)` in a simulation step |
654
+
655
+ Tool and platform paths also dropped helpers only the SDK itself used:
656
+ `arcade/bridge/controller` (`AIRJAM_CONTROLLER_BRIDGE_RESPONSE`,
657
+ `AIRJAM_CONTROLLER_PRESENTATION_SYNC`, `createControllerPresentationSyncMessage`,
658
+ `parseControllerBridgeResponseMessage`), `arcade/bridge/host`
659
+ (`AIRJAM_HOST_BRIDGE_RESPONSE`), `arcade/bridge/iframe` (the bridge init and
660
+ settings sync messages), `arcade/surface` (implicit store domain resolution),
661
+ `arcade/url` (`urlBuilder`, `arcadeSurfaceRuntimeUrlParams`, which stays in
662
+ `arcade/surface`), `controller-bridge`, `preview`, `runtime-control`,
663
+ `runtime-inspection`, `agent-tooling` and `metadata`. The
664
+ [architecture guide](/docs/how-it-works/architecture) lists what each path
665
+ keeps.
666
+
421
667
  ## Related Docs
422
668
 
423
669
  1. [Quick Start](/docs/getting-started/quick-start)