@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.
- package/README.md +128 -0
- package/dist/auth-profile.d.ts +5 -0
- package/dist/auth-profile.js +7 -0
- package/dist/auth-profile.js.map +1 -0
- package/dist/auth-sessions.d.ts +5 -0
- package/dist/auth-sessions.js +7 -0
- package/dist/auth-sessions.js.map +1 -0
- package/dist/chunk-7D4AYBAV.js +64 -0
- package/dist/chunk-7D4AYBAV.js.map +1 -0
- package/dist/chunk-LH7UO57C.js +23 -0
- package/dist/chunk-LH7UO57C.js.map +1 -0
- package/dist/chunk-PKTLVQXZ.js +82 -0
- package/dist/chunk-PKTLVQXZ.js.map +1 -0
- package/dist/chunk-SQE4NPZP.js +31 -0
- package/dist/chunk-SQE4NPZP.js.map +1 -0
- package/dist/{chunk-A4V2N4LX.js → chunk-U6V3HEBB.js} +6 -5
- package/dist/chunk-U6V3HEBB.js.map +1 -0
- package/dist/chunk-VEHNFPEO.js +224 -0
- package/dist/chunk-VEHNFPEO.js.map +1 -0
- package/dist/development.d.ts +4 -0
- package/dist/development.js +1 -1
- package/dist/game-analytics.d.ts +5 -0
- package/dist/game-analytics.js +7 -0
- package/dist/game-analytics.js.map +1 -0
- package/dist/game-app-id.d.ts +5 -0
- package/dist/game-app-id.js +7 -0
- package/dist/game-app-id.js.map +1 -0
- package/dist/game-media.d.ts +5 -0
- package/dist/game-media.js +7 -0
- package/dist/game-media.js.map +1 -0
- package/dist/index.js +688 -404
- package/dist/index.js.map +1 -1
- package/package.json +8 -4
- package/runtime/local-network.d.mts +4 -6
- package/runtime/public-assets.mjs +62 -0
- package/runtime/source-fence.mjs +182 -0
- package/runtime/vite-config.d.mts +2 -1
- package/runtime/vite-config.mjs +6 -2
- package/runtime/vite-dev.mjs +18 -0
- package/runtime/vite-https.mjs +2 -3
- package/template-assets/bootstrap/AGENTS.md +56 -14
- package/template-assets/bootstrap/CLAUDE.md +0 -8
- package/template-assets/bootstrap/skills/airjam-mcp/SKILL.md +44 -0
- package/template-assets/bootstrap/skills/controller-ui/SKILL.md +2 -0
- package/template-assets/bootstrap/skills/game-architecture/SKILL.md +47 -3
- package/template-assets/bootstrap/skills/index.md +1 -1
- package/template-assets/bootstrap/skills/prefab-authoring/SKILL.md +10 -0
- package/template-assets/bootstrap/skills/r3f-3d-scene/SKILL.md +10 -0
- package/template-assets/documentation/for-agents/controller-ui/page.mdx +41 -2
- package/template-assets/documentation/for-agents/page.mdx +24 -2
- package/template-assets/documentation/for-agents/project-structure/page.mdx +0 -2
- package/template-assets/documentation/for-agents/state-and-rendering/page.mdx +0 -2
- package/template-assets/documentation/for-agents/supported-agents/page.mdx +18 -0
- package/template-assets/documentation/getting-started/debugging/page.mdx +7 -8
- package/template-assets/documentation/getting-started/dev-logs/page.mdx +0 -2
- package/template-assets/documentation/getting-started/game-ideas/page.mdx +1 -3
- package/template-assets/documentation/getting-started/introduction/page.mdx +71 -54
- package/template-assets/documentation/getting-started/migrating-legacy-games/page.mdx +308 -62
- package/template-assets/documentation/getting-started/quick-start/page.mdx +56 -79
- package/template-assets/documentation/how-it-works/architecture/page.mdx +91 -50
- package/template-assets/documentation/how-it-works/host-system/page.mdx +112 -109
- package/template-assets/documentation/manifest.json +112 -42
- package/template-assets/documentation/sdk/assets-and-theme/page.mdx +185 -0
- package/template-assets/documentation/sdk/hooks/page.mdx +106 -171
- package/template-assets/documentation/sdk/input-system/page.mdx +201 -231
- package/template-assets/documentation/sdk/networked-state/page.mdx +134 -52
- package/template-assets/documentation/sdk/settings/page.mdx +155 -0
- package/template-assets/documentation/sdk/ui-components/page.mdx +45 -4
- package/template-assets/managed/.airjam/ai-pack.json +61 -43
- package/template-assets/managed/docs/airjam/agent-gold-path.md +55 -7
- package/template-assets/managed/docs/airjam/agent-mcp.md +44 -0
- package/template-assets/managed/docs/airjam/debug-and-testing.md +18 -0
- package/template-assets/managed/docs/airjam/docs-index.md +18 -12
- package/template-assets/managed/docs/airjam/generated/architecture.md +91 -46
- package/template-assets/managed/docs/airjam/generated/assets-and-theme.md +188 -0
- package/template-assets/managed/docs/airjam/generated/controller-ui.md +41 -0
- package/template-assets/managed/docs/airjam/generated/debugging-and-logs.md +7 -6
- package/template-assets/managed/docs/airjam/generated/for-agents.md +24 -0
- package/template-assets/managed/docs/airjam/generated/game-ideas.md +1 -1
- package/template-assets/managed/docs/airjam/generated/host-system.md +112 -102
- package/template-assets/managed/docs/airjam/generated/input-system.md +199 -218
- package/template-assets/managed/docs/airjam/generated/introduction.md +71 -51
- package/template-assets/managed/docs/airjam/generated/migrating-legacy-games.md +308 -60
- package/template-assets/managed/docs/airjam/generated/networked-state.md +134 -50
- package/template-assets/managed/docs/airjam/generated/quick-start.md +56 -79
- package/template-assets/managed/docs/airjam/generated/sdk-hooks.md +106 -166
- package/template-assets/managed/docs/airjam/generated/settings.md +158 -0
- package/template-assets/managed/docs/airjam/generated/supported-agents.md +21 -0
- package/template-assets/managed/docs/airjam/generated/ui-components.md +45 -2
- package/template-assets/managed/docs/airjam/prefab-authoring.md +100 -0
- package/template-assets/managed/docs/airjam/preview-controllers.md +4 -1
- package/template-assets/managed/docs/airjam/r3f-3d-scene.md +66 -0
- package/template-assets/managed/docs/airjam/state-lanes-cookbook.md +15 -20
- 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":
|
|
19
|
-
"sha256": "
|
|
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":
|
|
25
|
-
"sha256": "
|
|
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":
|
|
43
|
-
"sha256": "
|
|
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":
|
|
55
|
-
"sha256": "
|
|
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":
|
|
61
|
-
"sha256": "
|
|
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":
|
|
67
|
-
"sha256": "
|
|
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":
|
|
73
|
-
"sha256": "
|
|
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":
|
|
79
|
-
"sha256": "
|
|
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":
|
|
85
|
-
"sha256": "
|
|
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":
|
|
91
|
-
"sha256": "
|
|
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":
|
|
97
|
-
"sha256": "
|
|
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":
|
|
103
|
-
"sha256": "
|
|
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":
|
|
109
|
-
"sha256": "
|
|
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":
|
|
115
|
-
"sha256": "
|
|
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":
|
|
127
|
-
"sha256": "
|
|
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":
|
|
133
|
-
"sha256": "
|
|
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":
|
|
145
|
-
"sha256": "
|
|
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":
|
|
163
|
-
"sha256": "
|
|
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":
|
|
169
|
-
"sha256": "
|
|
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":
|
|
175
|
-
"sha256": "
|
|
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":
|
|
181
|
-
"sha256": "
|
|
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": "
|
|
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
|
-
:
|
|
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 `
|
|
47
|
-
6. If host code intentionally needs to run the same semantic player action as controller `X`, use `
|
|
48
|
-
7. If a store action needs a host-only local side effect like audio, sim refs, or one-shot UI effects, use `
|
|
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.
|
|
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.
|
|
56
|
-
2.
|
|
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. [
|
|
16
|
-
3. [
|
|
17
|
-
4. [
|
|
18
|
-
5. [
|
|
19
|
-
6. [
|
|
20
|
-
7. [
|
|
21
|
-
8. [
|
|
22
|
-
9. [
|
|
23
|
-
10. [
|
|
24
|
-
11. [
|
|
25
|
-
12. [
|
|
26
|
-
13. [
|
|
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.
|
|
21
|
+
### 1. Room server (`packages/server`)
|
|
22
22
|
|
|
23
|
-
**Role:**
|
|
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
|
|
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
|
-
|
|
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
|
-
**
|
|
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:**
|
|
48
|
+
**Technology:** TypeScript, Zustand, Zod; React for the binding
|
|
36
49
|
|
|
37
50
|
**Architecture:**
|
|
38
51
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
1. **
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
|
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
|
|
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
|
-
│ │ •
|
|
104
|
-
│ │ •
|
|
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
|
-
│ │ •
|
|
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
|
|
132
|
-
2.
|
|
133
|
-
3. SDK sends
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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.
|
|
148
|
-
4.
|
|
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
|
-
###
|
|
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
|
-
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
|
171
|
-
-
|
|
172
|
-
- Input
|
|
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
|
-
-
|
|
177
|
-
- Invalid input is
|
|
178
|
-
-
|
|
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
|