@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
@@ -15,14 +15,14 @@
15
15
  {
16
16
  "path": "docs/airjam/agent-gold-path.md",
17
17
  "kind": "docs-local",
18
- "size": 5018,
19
- "sha256": "8419951ad3a1e92fed5b7c3714b0908c6e6bed3d661041d5692ee38337888dcd"
18
+ "size": 8394,
19
+ "sha256": "30cc7eb97cf1177dbb56fed6d5ab1b0723809236b65dfd531ed7bf7de2eaa185"
20
20
  },
21
21
  {
22
22
  "path": "docs/airjam/agent-mcp.md",
23
23
  "kind": "docs-local",
24
- "size": 7245,
25
- "sha256": "c878e2eebfbbc927dfce5548c0d7a4163feffd3965a82c8c5dc38a9ec385c42b"
24
+ "size": 9889,
25
+ "sha256": "1e712de9c1e758acf5c0d509726b87c39d18446ef22c718d117d6ff431b29e72"
26
26
  },
27
27
  {
28
28
  "path": "docs/airjam/canvas-2d-gameplay.md",
@@ -39,8 +39,8 @@
39
39
  {
40
40
  "path": "docs/airjam/debug-and-testing.md",
41
41
  "kind": "docs-local",
42
- "size": 2889,
43
- "sha256": "65adf52e5cdcf0648ab56af1c0b639e30cf93495a85e2971b83168b571db97af"
42
+ "size": 3997,
43
+ "sha256": "efe08e5221067069d649605ed64ce7544453ddfcd3055b68c30bd07eb63c6afb"
44
44
  },
45
45
  {
46
46
  "path": "docs/airjam/development-loop.md",
@@ -51,68 +51,74 @@
51
51
  {
52
52
  "path": "docs/airjam/docs-index.md",
53
53
  "kind": "docs-local",
54
- "size": 2392,
55
- "sha256": "35c70672b7401b4f1e14abd8a88d9b50ecb8925b39245072474ac4fa88d27fb2"
54
+ "size": 2716,
55
+ "sha256": "b6c3be3b0aa221adafa4ad8245b5854ab043e8d6d8cd268abd9bb3bbecfbe4a6"
56
56
  },
57
57
  {
58
58
  "path": "docs/airjam/generated/architecture.md",
59
59
  "kind": "docs-generated",
60
- "size": 7115,
61
- "sha256": "1cbd763c55f77bc4bd0fb00605fd718daa63b8638c17313d12a1468f508fdf73"
60
+ "size": 12249,
61
+ "sha256": "6fd0abd0ddbf07ea7e9ae113ef7792cccdfc43c7b78496759fe1ccfb4df1d4ca"
62
+ },
63
+ {
64
+ "path": "docs/airjam/generated/assets-and-theme.md",
65
+ "kind": "docs-generated",
66
+ "size": 7617,
67
+ "sha256": "472c18703bd9a085ba3b0cf5d2726579c7c729070e01894093e49f9f6a5c7e54"
62
68
  },
63
69
  {
64
70
  "path": "docs/airjam/generated/controller-ui.md",
65
71
  "kind": "docs-generated",
66
- "size": 1578,
67
- "sha256": "fd54779b68ecffc359d29fad15a1bf17f965a2f8dd0602fbe3700a3237f906e2"
72
+ "size": 4722,
73
+ "sha256": "3f2c6ae3f7f012974f5eea1fbb0b136450edc86d5eee829b32bbcce858786dc7"
68
74
  },
69
75
  {
70
76
  "path": "docs/airjam/generated/debugging-and-logs.md",
71
77
  "kind": "docs-generated",
72
- "size": 4575,
73
- "sha256": "7998e1427b96d162986c193d32f30a97d35f92346c8d50a0a8b77019fb738897"
78
+ "size": 4698,
79
+ "sha256": "a5f8e4baf46ba5847db7be750d6cd3e9b207dd3b7243960b30a5e649a7a475b5"
74
80
  },
75
81
  {
76
82
  "path": "docs/airjam/generated/for-agents.md",
77
83
  "kind": "docs-generated",
78
- "size": 3916,
79
- "sha256": "fca62f1760b114bc62c6afa981da0107abafce7ce251adc3e38ae4d35b68432e"
84
+ "size": 5338,
85
+ "sha256": "9d856e6e5f4e914ec0c5870a6a31e6ba78916a4a12664a52f3d14f1715a96e67"
80
86
  },
81
87
  {
82
88
  "path": "docs/airjam/generated/game-ideas.md",
83
89
  "kind": "docs-generated",
84
- "size": 3034,
85
- "sha256": "e7ac9abc839ab21544e0cfa0075d353591cb277d5dbd65b121010c965e90f62e"
90
+ "size": 3042,
91
+ "sha256": "19560b89a8f6000855bf24add080983349bce78802e846a17f1b56c6e8c3d010"
86
92
  },
87
93
  {
88
94
  "path": "docs/airjam/generated/host-system.md",
89
95
  "kind": "docs-generated",
90
- "size": 9618,
91
- "sha256": "38561068538f6cd69bd8aa43d022bba6eee1eb6a635933d9d738ff305620ce8a"
96
+ "size": 9945,
97
+ "sha256": "c85a8d05570fbc71cbd7cf5771e75a2f8415b4eb034462a45c30db3ca97ced31"
92
98
  },
93
99
  {
94
100
  "path": "docs/airjam/generated/input-system.md",
95
101
  "kind": "docs-generated",
96
- "size": 6024,
97
- "sha256": "86395f226fc78c13eee4632998f60911d487739a027f82858371c8d233d4932f"
102
+ "size": 10486,
103
+ "sha256": "59076307117a834d830d2c1d7d06d9dd446a4117ccf38883ff9d08adb67e44c4"
98
104
  },
99
105
  {
100
106
  "path": "docs/airjam/generated/introduction.md",
101
107
  "kind": "docs-generated",
102
- "size": 5194,
103
- "sha256": "f6b2220d39b2a72e736f0f757ba01c948f09ae9063c98c202ec5bbe9ec749d58"
108
+ "size": 6004,
109
+ "sha256": "a5330d035f1a2bbc1c51cfe5b9d3ac6efdafc28cda31435b94f64495e962cd48"
104
110
  },
105
111
  {
106
112
  "path": "docs/airjam/generated/migrating-legacy-games.md",
107
113
  "kind": "docs-generated",
108
- "size": 11763,
109
- "sha256": "dadd93324cd6a1543f4d86124b44f6c7eb84333ae476a1d2026318e19ebeacdf"
114
+ "size": 31510,
115
+ "sha256": "63b66676c7578d37635e542f45149cd67dcc42229c1bf9364280ae76583586ec"
110
116
  },
111
117
  {
112
118
  "path": "docs/airjam/generated/networked-state.md",
113
119
  "kind": "docs-generated",
114
- "size": 7057,
115
- "sha256": "f6e8a0d752bc6a2a8bef82e9a4e9552f4f23e46e3d3dedacd4ac03076c4b0cb9"
120
+ "size": 10906,
121
+ "sha256": "5280e52df3cf817e925a613b2c375ab55e09df828011a71f3d6e0b402c57d01e"
116
122
  },
117
123
  {
118
124
  "path": "docs/airjam/generated/project-structure.md",
@@ -123,14 +129,20 @@
123
129
  {
124
130
  "path": "docs/airjam/generated/quick-start.md",
125
131
  "kind": "docs-generated",
126
- "size": 12468,
127
- "sha256": "52b9bdf13249976162d266ed895a606e4ff5df34749cf97c51357f9efdb52d08"
132
+ "size": 12777,
133
+ "sha256": "f8cd52e60a4f40e613f692d6d8f60c0817238c1b44b9db35959bc9f4958521d1"
128
134
  },
129
135
  {
130
136
  "path": "docs/airjam/generated/sdk-hooks.md",
131
137
  "kind": "docs-generated",
132
- "size": 16017,
133
- "sha256": "0697f9d3db87814784ab7919f41d40d2d8b0c399e98e0ac165ef8649052e0362"
138
+ "size": 16136,
139
+ "sha256": "d1182705433599ab958619c1c6607bf2cd353184fb14e715042589d7ad9c9358"
140
+ },
141
+ {
142
+ "path": "docs/airjam/generated/settings.md",
143
+ "kind": "docs-generated",
144
+ "size": 6382,
145
+ "sha256": "7bc2d29c42826085640a503601d6a2b42c9b2c7bdfc38908d58cd82b1ccf5c47"
134
146
  },
135
147
  {
136
148
  "path": "docs/airjam/generated/state-and-rendering.md",
@@ -138,11 +150,17 @@
138
150
  "size": 3176,
139
151
  "sha256": "c9e52a44c5f865db217a5bb538d0ee64b82ef342c78bc85acc830c488e3c8198"
140
152
  },
153
+ {
154
+ "path": "docs/airjam/generated/supported-agents.md",
155
+ "kind": "docs-generated",
156
+ "size": 1492,
157
+ "sha256": "2452bf09b3b75ea9c34437e4df8bac6e58813049600c6a2e036cae312705372d"
158
+ },
141
159
  {
142
160
  "path": "docs/airjam/generated/ui-components.md",
143
161
  "kind": "docs-generated",
144
- "size": 5410,
145
- "sha256": "4f01e900e2a2abdded844b3ba71ff872a277aeff3a425b359496a65bddd1301f"
162
+ "size": 7169,
163
+ "sha256": "87a6e133af6d6ea32b09edd8a731293c4dd99fcbbe8b42c5a6bb79eaa9cdf9f1"
146
164
  },
147
165
  {
148
166
  "path": "docs/airjam/generated/unified-dev-logs.md",
@@ -159,26 +177,26 @@
159
177
  {
160
178
  "path": "docs/airjam/prefab-authoring.md",
161
179
  "kind": "docs-local",
162
- "size": 2887,
163
- "sha256": "0383338b0e68386433bc1847a6e2191fe6ce580625431d6332d11da6241ea92c"
180
+ "size": 6916,
181
+ "sha256": "4abedb9d6241011b115503b26c59579340f954a6d4480069f304b4ff857f501a"
164
182
  },
165
183
  {
166
184
  "path": "docs/airjam/preview-controllers.md",
167
185
  "kind": "docs-local",
168
- "size": 4464,
169
- "sha256": "d1189e966a7891abc265793d264a201b0cf8c56902342697999c70356f18cac5"
186
+ "size": 4813,
187
+ "sha256": "0844ba6b2ebd62250affeae6f3b1c6eabb439d1a8f77145916705b45198f0d16"
170
188
  },
171
189
  {
172
190
  "path": "docs/airjam/r3f-3d-scene.md",
173
191
  "kind": "docs-local",
174
- "size": 2979,
175
- "sha256": "7142a7e1a513f3a43a0838b48daf85cca9780ffca58f34db50c06a24a56176d0"
192
+ "size": 5610,
193
+ "sha256": "1768ec9fe9279081d978f1ce8e146532f7d3ff50b30fdac8c309ead3f9ac48ae"
176
194
  },
177
195
  {
178
196
  "path": "docs/airjam/state-lanes-cookbook.md",
179
197
  "kind": "docs-local",
180
- "size": 3206,
181
- "sha256": "5dde111762f1071ef5e7fc23ffe1adac07454662ad8dced7a42a8d40e4f6150b"
198
+ "size": 3476,
199
+ "sha256": "6d7f8550fa5a80cedd94d8ba4bafd93c0ab4e8ef74b500eaaf44fdaa9052b9e8"
182
200
  },
183
201
  {
184
202
  "path": "docs/airjam/visual-system.md",
@@ -187,5 +205,5 @@
187
205
  "sha256": "0eaa064c38b4568c200fbf5cadb96f16c7c738a29469c4c955fb1ac5f8077edf"
188
206
  }
189
207
  ],
190
- "contentDigest": "d5e870a50333e7ce47e53aad9348a78c0e9bf5a7337ca0287991778cb704c835"
208
+ "contentDigest": "3805c938cca3e8cbdbe75dbe6262703bcc69a34fcfc7f14238a12de06f4be19b"
191
209
  }
@@ -32,7 +32,10 @@ This is the shortest correct workflow for building and testing an Air Jam game.
32
32
  ## Canonical Files
33
33
 
34
34
  `src/airjam.config.ts`
35
- : Declares the runtime, metadata, controller path, and semantic game contract.
35
+ : Exports `airjam = defineAirJamGame(...)` from `@air-jam/sdk/core`: metadata, stores, simulation, input, bindings, controller path, agent and testing path. The entire graph stays free of React, the SDK root, TSX and CSS.
36
+
37
+ `src/app.tsx`
38
+ : Binds the declaration with `createAirJamApp(airjam, { runtime })` and mounts its Host and Controller.
36
39
 
37
40
  `src/game/contracts/agent.ts`
38
41
  : Owns the semantic agent contract. Keep snapshot projection and semantic actions here.
@@ -43,17 +46,18 @@ This is the shortest correct workflow for building and testing an Air Jam game.
43
46
  2. `host:*` actions are deterministic semantic host actions. Define them with `agentAction.host(...)` when the game needs precise host staging or reset verbs for testing, visual proof, or controlled setup.
44
47
  3. Store action dispatch returns an acknowledgement. Check it when outcome matters.
45
48
  4. For `airjam.invoke_game_session_action`, prefer the returned normalized `outcome` over guessing from the raw acknowledgement alone. A missing host acknowledgement with observed committed state change is still a meaningful success signal, not an automatic rejection.
46
- 5. `ctx.actorId` always means the dispatcher. If host code dispatches with `useStore.useActions()`, then `ctx.actorId` is the host.
47
- 6. If host code intentionally needs to run the same semantic player action as controller `X`, use `useStore.asPlayer("X")` explicitly.
48
- 7. If a store action needs a host-only local side effect like audio, sim refs, or one-shot UI effects, use `useStore.useHostActionListener(...)` instead of replicated queue-and-drain state.
49
+ 5. `ctx.actorId` always means the dispatcher. If host code dispatches with `gameStore.actions`, then `ctx.actorId` is the host.
50
+ 6. If host code intentionally needs to run the same semantic player action as controller `X`, use `gameStore.asPlayer("X")` explicitly.
51
+ 7. If a store action needs a host-only local side effect like audio, sim refs, or one-shot UI effects, use `useHostActionListener(gameStore, ...)` instead of replicated queue-and-drain state.
49
52
  8. `resultDescription` is documentation for agents and humans about the expected semantic effect. It does not automatically become runtime result data.
50
53
  9. If an action must return actual runtime result data, return `acceptAirJamAction(result)` from the store action and read the acknowledgement/result separately.
51
- 10. For host gameplay loops, prefer `useHostTick(...)` over hand-rolled `requestAnimationFrame` or `setInterval` loops unless you have a documented reason not to.
54
+ 10. Put per-step gameplay in a declared simulation (`defineAirJamSimulation`, declared with `defineAirJamGame({ simulation })`): step it with game time and `random` from its context, declare what agents see with `observe`, and draw it with `useSimulationFrame`. Never hand-roll `requestAnimationFrame` or `setInterval` gameplay loops.
55
+ 11. Store actions read time as `ctx.now` (game time), never `Date.now()`. Timers and deadlines are checked by the simulation; phones show values the host writes to the store, such as whole seconds left.
52
56
 
53
57
  ## Import Rules
54
58
 
55
- 1. Browser/runtime code imports runtime symbols from the normal Air Jam packages used by the template.
56
- 2. If you need imperative live replicated state in React-owned agent code, use `useStore.useLiveStateRef()`.
59
+ 1. Store definitions and simulations import from `@air-jam/sdk/core`, the framework-free runtime; components and hooks import from `@air-jam/sdk`, its React binding. The core imports no React, so the same game logic runs headless.
60
+ 2. Read live replicated state outside rendering with `gameStore.getState()`.
57
61
 
58
62
  ## Browser + MCP Pairing
59
63
 
@@ -65,3 +69,47 @@ This is the shortest correct workflow for building and testing an Air Jam game.
65
69
  6. Use visible preview controllers for UI smoke proof with real browser click/drag/release gestures.
66
70
  7. Do not synthesize pointer events into controller iframes from parent-page eval; use semantic game actions when reliable gameplay proof matters.
67
71
  8. If the agent environment cannot launch a browser, capture the existing room's canonical host and controller views through `airjam.capture_game_session_visuals`; do not start an unrelated browser or room.
72
+
73
+ ## One game declaration
74
+
75
+ Read `airjam.inspect_game` for the versioned `declaration`, including
76
+ `declaration.agent`, controls, controller path and metadata. The game's
77
+ `src/airjam.config.ts` exports `airjam = defineAirJamGame(...)` from
78
+ `@air-jam/sdk/core`; agent helpers also come from core. Keep React, the SDK
79
+ root, TSX and CSS out of its graph. `app.tsx` alone binds it with
80
+ `createAirJamApp(airjam, { runtime })`.
81
+
82
+ Capacity comes from `metadata.maxPlayers`. The `testing` path names a module
83
+ exporting `testing = defineAirJamTesting({ player, profiles, visual })` from
84
+ `@air-jam/devtools/testing`. Profiles author scripted policies only; a declared
85
+ player is offered as the reserved `model` policy in every profile. Optional
86
+ `visual.scenarios` uses the game's declared agent. A profile's `setup` brings
87
+ the room to where its test starts; its `handBack` returns the creator's room,
88
+ usually with `return_to_lobby`, once the test ends and before its players
89
+ leave, so the game never plays on without them. Profiles that join play already
90
+ under way hand it back too. Declare `handBack: []` only when the game has no
91
+ phase to leave, such as a shared counter; a missing one is reported as
92
+ `undeclared` in the run record. Do not duplicate identity in template flags or read config source with
93
+ regular expressions.
94
+
95
+ ## Declared settings
96
+
97
+ Declare creator tuning values with `defineAirJamSettings` and `setting` from
98
+ `@air-jam/sdk/core`, in the game declaration's `settings` field. Remove the
99
+ constants they replace. Read values in simulation create/step/observe contexts
100
+ and typed action contexts; host rendering uses `useAirJamSettings`. Controllers
101
+ show copies in replicated state. Lobby player choices stay store state.
102
+
103
+ Inspect descriptors in `airjam.inspect_game` → `declaration.settings`.
104
+ Use `airjam.read_game_settings({ gameSessionId })` for live values and revision,
105
+ then `airjam.update_game_settings({ gameSessionId, patch, expectedRevision })`
106
+ under host authority. Only `live: true` values can change; non-live values go
107
+ in `airjam.start_game_run({ settings, ... })` for a fresh room. Stale revisions
108
+ require a fresh read. Input log version 2 records initial values and ordered
109
+ settings updates for replay. See `docs/airjam/generated/settings.md`.
110
+
111
+ Declared assets and theme are read through `airjam.inspect_game` in
112
+ `declaration.assets` and `declaration.theme`. Keep sounds, images and loaded
113
+ files in `defineAirJamAssets`, colours and font families in `defineAirJamTheme`,
114
+ and pass both to `defineAirJamGame`. The React binding owns audio mounts and
115
+ theme CSS variables; games consume the declared objects and never duplicate them.
@@ -133,3 +133,47 @@ Before finishing meaningful work:
133
133
  The MCP config is project-local and scaffolded by default.
134
134
 
135
135
  Do not mutate global client configuration unless you explicitly mean to.
136
+
137
+ ## One game declaration
138
+
139
+ Read `airjam.inspect_game` for the versioned `declaration`, including
140
+ `declaration.agent`, controls, controller path and metadata. The game's
141
+ `src/airjam.config.ts` exports `airjam = defineAirJamGame(...)` from
142
+ `@air-jam/sdk/core`; agent helpers also come from core. Keep React, the SDK
143
+ root, TSX and CSS out of its graph. `app.tsx` alone binds it with
144
+ `createAirJamApp(airjam, { runtime })`.
145
+
146
+ Capacity comes from `metadata.maxPlayers`. The `testing` path names a module
147
+ exporting `testing = defineAirJamTesting({ player, profiles, visual })` from
148
+ `@air-jam/devtools/testing`. Profiles author scripted policies only; a declared
149
+ player is offered as the reserved `model` policy in every profile. Optional
150
+ `visual.scenarios` uses the game's declared agent. A profile's `setup` brings
151
+ the room to where its test starts; its `handBack` returns the creator's room,
152
+ usually with `return_to_lobby`, once the test ends and before its players
153
+ leave, so the game never plays on without them. Profiles that join play already
154
+ under way hand it back too. Declare `handBack: []` only when the game has no
155
+ phase to leave, such as a shared counter; a missing one is reported as
156
+ `undeclared` in the run record. Do not duplicate identity in template flags or read config source with
157
+ regular expressions.
158
+
159
+ ## Declared settings
160
+
161
+ Declare creator tuning values with `defineAirJamSettings` and `setting` from
162
+ `@air-jam/sdk/core`, in the game declaration's `settings` field. Remove the
163
+ constants they replace. Read values in simulation create/step/observe contexts
164
+ and typed action contexts; host rendering uses `useAirJamSettings`. Controllers
165
+ show copies in replicated state. Lobby player choices stay store state.
166
+
167
+ Inspect descriptors in `airjam.inspect_game` → `declaration.settings`.
168
+ Use `airjam.read_game_settings({ gameSessionId })` for live values and revision,
169
+ then `airjam.update_game_settings({ gameSessionId, patch, expectedRevision })`
170
+ under host authority. Only `live: true` values can change; non-live values go
171
+ in `airjam.start_game_run({ settings, ... })` for a fresh room. Stale revisions
172
+ require a fresh read. Input log version 2 records initial values and ordered
173
+ settings updates for replay. See `docs/airjam/generated/settings.md`.
174
+
175
+ Declared assets and theme are read through `airjam.inspect_game` in
176
+ `declaration.assets` and `declaration.theme`. Keep sounds, images and loaded
177
+ files in `defineAirJamAssets`, colours and font families in `defineAirJamTheme`,
178
+ and pass both to `defineAirJamGame`. The React binding owns audio mounts and
179
+ theme CSS variables; games consume the declared objects and never duplicate them.
@@ -65,6 +65,24 @@ Use direct file reads or broader filtering when you need:
65
65
  3. add focused tests when changing real behavior
66
66
  4. prefer observable behavior over implementation details
67
67
 
68
+ ## Decision-model Playtesting
69
+
70
+ Declare an `AirJamPlayerContract` from `@air-jam/devtools/testing` with `brief`
71
+ and `turn`. Return `{ state, question, options }` with 1 to 16 named options,
72
+ each carrying `when` and `control`, or `null` when the seat has nothing to do.
73
+ Zero options is invalid. A single sensible move, such as joining a lobby, is
74
+ allowed: the run owner takes that option's control directly with no model call
75
+ or cost. Do not add a fake alternative. Multiple options ask the model to choose.
76
+ The trace keeps the choice and control with the note `Only option; no model
77
+ asked.`; the seat's optional `answers.automatic` count distinguishes these
78
+ automatic answers in the run record.
79
+
80
+ In Studio, `studio_press_phone` taps, holds or types on one named mounted Studio phone
81
+ and returns its private screen in the same call. Coordinates are fractions 0..1 of
82
+ `studio_observe_current_game`'s `surface=phone` image. Tap a field before typing;
83
+ a hold captures while pressed, then releases. Reuse the requestId UUID for retries.
84
+ Guest/real phones and older runtimes return an explicit unavailable reason.
85
+
68
86
  ## Starter Template Testing Pattern
69
87
 
70
88
  If the project ships the starter testing layout, keep using it:
@@ -12,18 +12,24 @@ For broader public framework docs, use the hosted docs site after checking these
12
12
  ## Generated Canonical Docs
13
13
 
14
14
  1. [For Agents](./generated/for-agents.md)
15
- 2. [Project Structure](./generated/project-structure.md)
16
- 3. [Controller UI](./generated/controller-ui.md)
17
- 4. [State And Rendering](./generated/state-and-rendering.md)
18
- 5. [Introduction](./generated/introduction.md)
19
- 6. [Quick Start](./generated/quick-start.md)
20
- 7. [Architecture](./generated/architecture.md)
21
- 8. [Host System](./generated/host-system.md)
22
- 9. [SDK Hooks](./generated/sdk-hooks.md)
23
- 10. [Input System](./generated/input-system.md)
24
- 11. [Networked State](./generated/networked-state.md)
25
- 12. [Debugging And Logs](./generated/debugging-and-logs.md)
26
- 13. [Unified Dev Logs](./generated/unified-dev-logs.md)
15
+ 2. [Supported Agents](./generated/supported-agents.md)
16
+ 3. [Project Structure](./generated/project-structure.md)
17
+ 4. [Controller UI](./generated/controller-ui.md)
18
+ 5. [State And Rendering](./generated/state-and-rendering.md)
19
+ 6. [Introduction](./generated/introduction.md)
20
+ 7. [Quick Start](./generated/quick-start.md)
21
+ 8. [Architecture](./generated/architecture.md)
22
+ 9. [Host System](./generated/host-system.md)
23
+ 10. [SDK Hooks](./generated/sdk-hooks.md)
24
+ 11. [UI Components](./generated/ui-components.md)
25
+ 12. [Input System](./generated/input-system.md)
26
+ 13. [Networked State](./generated/networked-state.md)
27
+ 14. [Game Settings](./generated/settings.md)
28
+ 15. [Game Assets And Theme](./generated/assets-and-theme.md)
29
+ 16. [Debugging And Logs](./generated/debugging-and-logs.md)
30
+ 17. [Unified Dev Logs](./generated/unified-dev-logs.md)
31
+ 18. [Game Ideas](./generated/game-ideas.md)
32
+ 19. [Migrating Legacy Games](./generated/migrating-legacy-games.md)
27
33
 
28
34
  ## Local Supplements
29
35
 
@@ -18,30 +18,79 @@ product, not an application in this public repository. Their hosted services
18
18
  compose the same open runtime; standalone games need neither that product nor
19
19
  its database. The diagrams include hosted surfaces to show how embedding works.
20
20
 
21
- ### 1. Server (`packages/server`)
21
+ ### 1. Room server (`packages/server`)
22
22
 
23
- **Role:** Real-time communication backbone
23
+ **Role:** Keeps rooms: it seats phones, carries their controls to the game's
24
+ host and the host's state to the phones
24
25
 
25
- **Technology:** Node.js, Express, Socket.IO
26
+ **Technology:** Node.js and `ws`; the room itself is plain synchronous code
27
+ (`@air-jam/server/room`), so the hosted Arcade runs the same rooms elsewhere
26
28
 
27
- **Core Services:**
29
+ Every device holds one WebSocket to its room. A game's host connects to
30
+ `/v1/host` and gets a room code; a phone connects to `/v1/play/CODE` and gets
31
+ a seat (`p1`, `p2`, …). The room speaks the room protocol
32
+ (`@air-jam/sdk/room-protocol`):
28
33
 
29
- **Socket Events:**
34
+ - **Hello and welcome.** Each device sends a key that only it knows; the same
35
+ key gets the same place back after a reload or a dropped network.
36
+ - **Channels.** The host publishes named state documents (the room's
37
+ presentation, each networked store); the room keeps the latest copy and
38
+ sends phones what changed.
39
+ - **Requests and signals.** A phone asks the host to run an action and gets
40
+ one answer; the host sends haptics, toasts and sounds to one seat or all.
41
+ - **Input.** Controls travel in small binary frames; the room delivers the
42
+ latest of each seat's to the host.
30
43
 
31
44
  ### 2. SDK (`packages/sdk`)
32
45
 
33
46
  **Role:** Developer toolkit for building Air Jam games
34
47
 
35
- **Technology:** React, TypeScript, Socket.IO Client, Zustand, Zod
48
+ **Technology:** TypeScript, Zustand, Zod; React for the binding
36
49
 
37
50
  **Architecture:**
38
51
 
39
- **Key Design Decisions:**
40
-
41
- 1. **Provider Pattern** - Single provider for configuration, multiple hooks for access
42
- 2. **Lightweight Hooks** - `useGetInput`, `useSendSignal` don't trigger re-renders
43
- 3. **Input Latching** - Ensures rapid button taps are never missed
44
- 4. **Schema Validation** - Type-safe input with runtime validation
52
+ The SDK is one runtime in two layers:
53
+
54
+ 1. **The core** (`@air-jam/sdk/core`) owns a room: the connection, players,
55
+ input, networked stores and their sync, the game's simulation on the SDK
56
+ clock, signals and the agent contract. It imports no React and no DOM, so
57
+ the same game runs in a browser, in Node without drawing, or faster than
58
+ real time in headless tests.
59
+ 2. **The React binding** (`@air-jam/sdk`) starts the core for a host or a
60
+ controller page and lets components read it: `useAirJamHost`,
61
+ `useAirJamController`, `useAirJamStore`, `useSimulationFrame`. Hooks
62
+ subscribe to the core; they never keep a second copy of the runtime.
63
+
64
+ A game declares metadata, stores, simulation, controls and its agent contract
65
+ once in `src/airjam.config.ts` with `defineAirJamGame` from core.
66
+ `app.tsx` binds it with `createAirJamApp(airjam, { runtime })`. Store
67
+ definitions and simulations import from `@air-jam/sdk/core`; components import
68
+ from `@air-jam/sdk`.
69
+
70
+ **Entry points.** Each import path has one purpose:
71
+
72
+ | Import path | Purpose |
73
+ | ------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
74
+ | `@air-jam/sdk` | React binding: host and controller surfaces and hooks, audio and platform settings |
75
+ | `@air-jam/sdk/core` | Framework-free game declaration, agent helpers, networked stores, simulations and runtimes |
76
+ | `@air-jam/sdk/ui` | Ready-made React components for host and controller shells |
77
+ | `@air-jam/sdk/styles.css` | Styles for those components |
78
+ | `@air-jam/sdk/metadata` | The game's catalog metadata declaration |
79
+ | `@air-jam/sdk/prefabs` | Placeable scene pieces with previews |
80
+ | `@air-jam/sdk/preview` | Preview controllers shown beside a host during development |
81
+ | `@air-jam/sdk/protocol` | Shared schemas: players, actions, leased control, runtime reports |
82
+ | `@air-jam/sdk/room-protocol` | The room protocol: frames, close codes, channels and the input codec |
83
+ | `@air-jam/sdk/room-session` | A host's or phone's session in a room, and connectors for WebSockets and embedded frames |
84
+ | `@air-jam/sdk/runtime-topology` | Where a runtime connects in each run mode |
85
+ | `@air-jam/sdk/runtime-control` | Calling a running host: agent requests, actions and observations |
86
+ | `@air-jam/sdk/runtime-inspection` | Reading what a running host or controller publishes for tools |
87
+ | `@air-jam/sdk/agent-tooling` | Checking and evaluating a game's agent contract |
88
+ | `@air-jam/sdk/controller-bridge` | Serving an embedded controller page its seat from the page around it |
89
+ | `@air-jam/sdk/arcade/*` | Embedding games in the Arcade: `bridge/host`, `bridge/controller`, `bridge/iframe`, `host`, `runtime`, `surface`, `url` |
90
+ | `@air-jam/sdk/release`, `@air-jam/sdk/platform-machine` | Contracts with the hosted platform for releases and the CLI |
91
+
92
+ Games use the first five or six; the rest serve the CLI, MCP server, devtools,
93
+ the server and the hosted platform.
45
94
 
46
95
  ### 3. Creator Harness
47
96
 
@@ -68,7 +117,7 @@ tools do not depend on private application source.
68
117
 
69
118
  Air Jam uses three lanes and they should stay separate:
70
119
 
71
- 1. **Input lane** for high-frequency transient control data via `useInputWriter` and `getInput` / `useGetInput`
120
+ 1. **Input lane** for players' controls: declared with `defineAirJamInput`, filled by phone controls, agents or replays, and read once per simulation step
72
121
  2. **Replicated state lane** for replayable shared state via `createAirJamStore`
73
122
  3. **Signal / command lane** for coarse UX/runtime messages such as haptics, toasts, pause, and exit
74
123
 
@@ -80,7 +129,7 @@ The SDK automatically detects and adapts to different deployment scenarios:
80
129
 
81
130
  ### Standalone Mode
82
131
 
83
- Your game runs independently with direct WebSocket connection.
132
+ Your game connects straight to a room server over a WebSocket.
84
133
 
85
134
  ```
86
135
  ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
@@ -100,8 +149,8 @@ Game runs inside an iframe on the Air Jam Platform.
100
149
  │ Air Jam Platform (Parent) │
101
150
  │ ┌───────────────────────────────────┐ │
102
151
  │ │ Your Game (iframe) │ │
103
- │ │ • Receives launch capability │ │
104
- │ │ • Controlled player routing │ │
152
+ │ │ • Room served by the Arcade │ │
153
+ │ │ • Same room, its own channels │ │
105
154
  │ └───────────────────────────────────┘ │
106
155
  └─────────────────────────────────────────┘
107
156
  ```
@@ -117,7 +166,7 @@ Controller runs inside platform's runtime wrapper (iframe communication).
117
166
  │ Platform Controller Runtime (Parent) │
118
167
  │ ┌───────────────────────────────────┐ │
119
168
  │ │ Your Controller UI (iframe) │ │
120
- │ │ • Input via postMessage │ │
169
+ │ │ • Seat served via MessagePort │ │
121
170
  │ │ • Seamless game switching │ │
122
171
  │ └───────────────────────────────────┘ │
123
172
  └─────────────────────────────────────────┘
@@ -128,15 +177,15 @@ Controller runs inside platform's runtime wrapper (iframe communication).
128
177
  ### Input Path (Controller → Game)
129
178
 
130
179
  ```
131
- 1. Player moves joystick on phone
132
- 2. Controller publishes input via useInputWriter({ vector: {x, y}, action: false })
133
- 3. SDK sends controller:input event to server
134
- 4. Server routes to host socket
135
- 5. Host SDK's InputManager receives input
136
- 6. InputManager validates with Zod schema
137
- 7. InputManager applies configured input behavior (`pulse`, `hold`, `latest`)
138
- 8. Game calls getInput(playerId) in game loop
139
- 9. Returns typed, validated input with behavior semantics applied
180
+ 1. Player holds a stick or button rendered by the SDK's phone controls
181
+ 2. The controller's input lane updates the declared control's state
182
+ 3. Once per display frame, if anything changed, the SDK sends one binary
183
+ input frame
184
+ 4. The room passes each seat's latest frame to the host
185
+ 5. The host's input lane decodes it against the declared controls
186
+ 6. Before each simulation step, the host samples every player's controls and
187
+ applies each kind's meaning (a pressed button reads true for one step)
188
+ 7. The step reads input(playerId)
140
189
  ```
141
190
 
142
191
  ### Signal Path (Game → Controller)
@@ -144,35 +193,31 @@ Controller runs inside platform's runtime wrapper (iframe communication).
144
193
  ```
145
194
  1. Game detects collision
146
195
  2. Host calls sendSignal("HAPTIC", { pattern: "heavy" }, playerId)
147
- 3. SDK sends host:signal event to server
148
- 4. Server routes to target controller(s)
196
+ 3. The host's session sends a signal to that seat
197
+ 4. The room delivers it to the seat's phone
149
198
  5. Controller SDK receives signal
150
199
  6. SDK triggers navigator.vibrate() with pattern
151
200
  7. Player feels haptic feedback
152
201
  ```
153
202
 
154
- ### Host Bootstrap
155
-
156
- - Hosts perform one `host:bootstrap` verification step in production/static mode
157
- - In normal static mode, the server validates the browser-facing `appId` once, then binds host authority to the socket
158
- - Static apps can optionally restrict bootstrap by allowed origin per app identity
159
- - In optional signed mode, the SDK first fetches a short-lived host grant from `hostGrantEndpoint`, then bootstraps with that grant instead of raw `appId`
160
- - Later host lifecycle events rely on socket authority instead of repeated raw auth payloads
161
-
162
- ### Child Launch Capability
203
+ ### Opening a room
163
204
 
164
- - Arcade game launch issues a room/game-scoped `launchCapability`
165
- - Embedded host iframes receive `aj_cap` / `aj_cap_exp` automatically
166
- - Game code does not parse or manage this capability directly
205
+ - A host's hello may carry a credential for the server's gate; a local server
206
+ needs none, and a self-hosted production server composes its own gate
207
+ (`createRoomServer({ gate })`) or runs open to any host
208
+ - A host returning to its room proves itself with its key alone, so a reload
209
+ keeps the room and its players
210
+ - An embedded game never opens a room of its own: the Arcade serves it the
211
+ Arcade's room over a MessagePort, scoped to that game's channels
167
212
 
168
213
  ### Room Isolation
169
214
 
170
- - Each room has unique 4-character code
171
- - Controllers can only join with correct code
172
- - Input is only routed to the designated host
215
+ - Each room has a unique code
216
+ - Phones can only join with the code, and hold their seat by their key
217
+ - Input reaches only the room's host
173
218
 
174
219
  ### Input Validation
175
220
 
176
- - Zod schemas validate all incoming input
177
- - Invalid input is rejected with console warning
178
- - Protects game logic from malformed data
221
+ - Every incoming input is checked against the game's declared controls
222
+ - Invalid input is dropped with an `AJ_INPUT_INVALID` diagnostic
223
+ - Agents' input passes the same check before they take a seat