@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
|
@@ -11,17 +11,63 @@
|
|
|
11
11
|
|
|
12
12
|
Use this lane for replicated game state, not per-frame input.
|
|
13
13
|
|
|
14
|
+
A store is a plain object from `@air-jam/sdk/core`, so game logic can use it
|
|
15
|
+
without React. Components read it with `useAirJamStore`.
|
|
16
|
+
|
|
17
|
+
## Private per-player state
|
|
18
|
+
|
|
19
|
+
A store can declare one `privateField`: a map keyed by `controllerId`. Use it for
|
|
20
|
+
hidden hands, roles or shopping lists. The host keeps every entry. The room's
|
|
21
|
+
public state broadcast never contains this field; each phone receives only its
|
|
22
|
+
own entry through targeted delivery, including after a reconnect.
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { createAirJamStore } from "@air-jam/sdk/core";
|
|
26
|
+
import { useAirJamPrivateState } from "@air-jam/sdk";
|
|
27
|
+
|
|
28
|
+
type MarketState = {
|
|
29
|
+
round: number;
|
|
30
|
+
secrets: Record<string, { shoppingList: string[] }>;
|
|
31
|
+
actions: {};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const marketStore = createAirJamStore<MarketState, "secrets">(
|
|
35
|
+
() => ({ round: 1, secrets: {}, actions: {} }),
|
|
36
|
+
{ privateField: "secrets" },
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
function ShoppingList() {
|
|
40
|
+
const ownEntry = useAirJamPrivateState(marketStore);
|
|
41
|
+
return <p>{ownEntry?.shoppingList.join(", ") ?? "Waiting for your list"}</p>;
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
When supplying an explicit state type, name the private field as the second type
|
|
46
|
+
argument so the hook infers that entry even when the store has other maps.
|
|
47
|
+
Declare this store in the game just like a public store. The hook returns
|
|
48
|
+
`undefined` until this controller's entry arrives, and when the host removes it.
|
|
49
|
+
Host actions update the map normally. Only changed entries are sent; public-only
|
|
50
|
+
changes do not resend private data. Embedded controllers use the same private
|
|
51
|
+
lane through their MessagePort bridge.
|
|
52
|
+
|
|
53
|
+
Agent `projectSnapshot` receives the public fields and a private map containing
|
|
54
|
+
only the requested controller's entry (an empty map without a controller).
|
|
55
|
+
Host-authority `rawStores` and host restore retain the whole map. Keep private
|
|
56
|
+
values out of other public fields and explicitly author any end-of-round reveal.
|
|
57
|
+
Private state derives from the replicated store, so headless runs and replays use
|
|
58
|
+
the same authoritative state; it is not a separate RPC or an encrypted channel.
|
|
59
|
+
|
|
14
60
|
## Canonical Action Model
|
|
15
61
|
|
|
16
62
|
Actions always use this shape on the host:
|
|
17
63
|
|
|
18
|
-
1. First argument: `ctx` (identity and
|
|
64
|
+
1. First argument: `ctx` (identity, role, connected players and game time `now`)
|
|
19
65
|
2. Second argument: `payload` (either `undefined` or one typed plain-object payload)
|
|
20
66
|
|
|
21
|
-
|
|
67
|
+
Dispatch always goes through the store's `actions`:
|
|
22
68
|
|
|
23
|
-
1. `
|
|
24
|
-
2. `
|
|
69
|
+
1. `gameStore.actions.someAction()`
|
|
70
|
+
2. `gameStore.actions.someAction({ ...payload })`
|
|
25
71
|
|
|
26
72
|
No trailing `controllerId` arguments and no multi-argument action payloads.
|
|
27
73
|
No primitive, array, or event-like root payloads.
|
|
@@ -32,7 +78,7 @@ This example uses a starter-friendly `stores/` folder shape.
|
|
|
32
78
|
The important contract is the action model and ownership boundary, not the exact filename.
|
|
33
79
|
|
|
34
80
|
```tsx filename="src/game/stores/game-store.ts"
|
|
35
|
-
import { createAirJamStore } from "@air-jam/sdk";
|
|
81
|
+
import { createAirJamStore, type AirJamActionContext } from "@air-jam/sdk/core";
|
|
36
82
|
|
|
37
83
|
type Team = "team1" | "team2";
|
|
38
84
|
|
|
@@ -41,22 +87,16 @@ interface GameState {
|
|
|
41
87
|
teamAssignments: Record<string, Team>;
|
|
42
88
|
scores: { team1: number; team2: number };
|
|
43
89
|
actions: {
|
|
44
|
-
joinTeam: (
|
|
45
|
-
|
|
46
|
-
payload: { team: Team },
|
|
47
|
-
) => void;
|
|
48
|
-
scorePoint: (
|
|
49
|
-
_ctx: { actorId: string; role: "controller" | "host" },
|
|
50
|
-
payload: { team: Team },
|
|
51
|
-
) => void;
|
|
90
|
+
joinTeam: (ctx: AirJamActionContext, payload: { team: Team }) => void;
|
|
91
|
+
scorePoint: (ctx: AirJamActionContext, payload: { team: Team }) => void;
|
|
52
92
|
setPhase: (
|
|
53
|
-
|
|
93
|
+
ctx: AirJamActionContext,
|
|
54
94
|
payload: { phase: "lobby" | "playing" },
|
|
55
95
|
) => void;
|
|
56
96
|
};
|
|
57
97
|
}
|
|
58
98
|
|
|
59
|
-
export const
|
|
99
|
+
export const gameStore = createAirJamStore<GameState>((set) => ({
|
|
60
100
|
phase: "lobby",
|
|
61
101
|
teamAssignments: {},
|
|
62
102
|
scores: { team1: 0, team2: 0 },
|
|
@@ -80,19 +120,51 @@ export const useGameStore = createAirJamStore<GameState>((set) => ({
|
|
|
80
120
|
}));
|
|
81
121
|
```
|
|
82
122
|
|
|
123
|
+
## Declare the Store
|
|
124
|
+
|
|
125
|
+
The host and controllers sync a store only when the app declares it:
|
|
126
|
+
|
|
127
|
+
```ts filename="src/airjam.config.ts"
|
|
128
|
+
import { defineAirJamGame } from "@air-jam/sdk/core";
|
|
129
|
+
import { gameStore } from "./game/stores/game-store";
|
|
130
|
+
|
|
131
|
+
export const airjam = defineAirJamGame({
|
|
132
|
+
metadata: {
|
|
133
|
+
slug: "space-game",
|
|
134
|
+
name: "Space Game",
|
|
135
|
+
tagline: "Fly together and defend the fleet.",
|
|
136
|
+
category: "arcade",
|
|
137
|
+
minPlayers: 1,
|
|
138
|
+
maxPlayers: 4,
|
|
139
|
+
inputModalities: ["buttons", "touch"],
|
|
140
|
+
supportedSdkRange: "^1.0.0",
|
|
141
|
+
maintainer: { name: "Air Jam" },
|
|
142
|
+
version: 1,
|
|
143
|
+
},
|
|
144
|
+
controllerPath: "/controller",
|
|
145
|
+
stores: [gameStore],
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
A declared store syncs for as long as the host or controller runs, whether or
|
|
150
|
+
not any component is reading it. Reading a store the app does not declare
|
|
151
|
+
throws `AJ_STORE_NOT_DECLARED`.
|
|
152
|
+
|
|
83
153
|
## Use on Controller
|
|
84
154
|
|
|
85
155
|
This controller example matches the starter template surface layout.
|
|
86
156
|
It assumes your app has already mounted `airjam.Controller`.
|
|
87
157
|
|
|
88
158
|
```tsx filename="src/controller/index.tsx"
|
|
89
|
-
import { useAirJamController } from "@air-jam/sdk";
|
|
90
|
-
import {
|
|
159
|
+
import { useAirJamController, useAirJamStore } from "@air-jam/sdk";
|
|
160
|
+
import { gameStore } from "../game/stores/game-store";
|
|
91
161
|
|
|
92
162
|
export const ControllerView = () => {
|
|
93
163
|
const controller = useAirJamController();
|
|
94
|
-
const
|
|
95
|
-
|
|
164
|
+
const teamAssignments = useAirJamStore(
|
|
165
|
+
gameStore,
|
|
166
|
+
(state) => state.teamAssignments,
|
|
167
|
+
);
|
|
96
168
|
|
|
97
169
|
const myTeam = controller.controllerId
|
|
98
170
|
? teamAssignments[controller.controllerId]
|
|
@@ -101,7 +173,7 @@ export const ControllerView = () => {
|
|
|
101
173
|
return (
|
|
102
174
|
<div>
|
|
103
175
|
<p>My team: {myTeam ?? "unassigned"}</p>
|
|
104
|
-
<button onClick={() => actions.joinTeam({ team: "team1" })}>
|
|
176
|
+
<button onClick={() => gameStore.actions.joinTeam({ team: "team1" })}>
|
|
105
177
|
Join Team 1
|
|
106
178
|
</button>
|
|
107
179
|
</div>
|
|
@@ -115,12 +187,12 @@ This host example also matches the starter template surface layout.
|
|
|
115
187
|
It assumes your app has already mounted `airjam.Host`.
|
|
116
188
|
|
|
117
189
|
```tsx filename="src/host/index.tsx"
|
|
118
|
-
import {
|
|
190
|
+
import { useAirJamStore } from "@air-jam/sdk";
|
|
191
|
+
import { gameStore } from "../game/stores/game-store";
|
|
119
192
|
|
|
120
193
|
export const HostView = () => {
|
|
121
|
-
const phase =
|
|
122
|
-
const scores =
|
|
123
|
-
const actions = useGameStore.useActions();
|
|
194
|
+
const phase = useAirJamStore(gameStore, (state) => state.phase);
|
|
195
|
+
const scores = useAirJamStore(gameStore, (state) => state.scores);
|
|
124
196
|
|
|
125
197
|
return (
|
|
126
198
|
<div>
|
|
@@ -128,10 +200,10 @@ export const HostView = () => {
|
|
|
128
200
|
<p>
|
|
129
201
|
{scores.team1} - {scores.team2}
|
|
130
202
|
</p>
|
|
131
|
-
<button onClick={() => actions.setPhase({ phase: "playing" })}>
|
|
203
|
+
<button onClick={() => gameStore.actions.setPhase({ phase: "playing" })}>
|
|
132
204
|
Start
|
|
133
205
|
</button>
|
|
134
|
-
<button onClick={() => actions.scorePoint({ team: "team1" })}>
|
|
206
|
+
<button onClick={() => gameStore.actions.scorePoint({ team: "team1" })}>
|
|
135
207
|
Team 1 +1
|
|
136
208
|
</button>
|
|
137
209
|
</div>
|
|
@@ -142,24 +214,29 @@ export const HostView = () => {
|
|
|
142
214
|
## Action Flow
|
|
143
215
|
|
|
144
216
|
1. Controller calls `actions.someAction()` or `actions.someAction({ ...payload })`.
|
|
145
|
-
2.
|
|
146
|
-
3.
|
|
147
|
-
4. Host
|
|
148
|
-
5. Host
|
|
149
|
-
|
|
217
|
+
2. The phone's session sends a request on the store's channel.
|
|
218
|
+
3. The room stamps it with the phone's seat, which becomes `ctx.actorId`.
|
|
219
|
+
4. Host executes action handler `(ctx, payload)`, updates state and answers.
|
|
220
|
+
5. Host publishes what changed; the room keeps the latest copy and sends each
|
|
221
|
+
phone the change, with only its own private entry.
|
|
222
|
+
6. If the phone's connection drops before the answer arrives, the action
|
|
223
|
+
resolves `unconfirmed`: it may or may not have run, and the state the phone
|
|
224
|
+
mirrors shows which.
|
|
150
225
|
|
|
151
226
|
## Rules
|
|
152
227
|
|
|
153
228
|
1. Keep all networked mutations inside `actions`.
|
|
154
|
-
2. Always dispatch via `
|
|
229
|
+
2. Always dispatch via `store.actions`; do not call `store.getState().actions.*` directly.
|
|
155
230
|
3. Use one payload object per action for stable evolution.
|
|
156
231
|
4. Root payloads must be omitted or plain objects.
|
|
157
232
|
5. `T | undefined` payload unions are not valid roots. If an action has no payload, omit it entirely.
|
|
158
233
|
6. Nested values must stay RPC-serializable.
|
|
159
234
|
7. Use `ctx.actorId` for identity-aware actions (team join, ownership, etc.).
|
|
160
|
-
8. `ctx.actorId` is always the dispatcher identity. If host code dispatches through `
|
|
161
|
-
9.
|
|
162
|
-
10.
|
|
235
|
+
8. `ctx.actorId` is always the dispatcher identity. If host code dispatches through `store.actions`, then `ctx.actorId` is the host.
|
|
236
|
+
9. Read time as `ctx.now`, never `Date.now()`: it is game time, the simulation's when the game declares one, so headless runs and replays see the same time. Store deadlines in it and let the simulation act on them; phones show what the host writes to the store, such as whole seconds left, because they cannot read the host's clock.
|
|
237
|
+
10. If the host intentionally needs to run the same semantic player action as controller `X`, use `store.asPlayer("X")` instead of inventing a target payload for an actor-owned action.
|
|
238
|
+
11. Keep per-frame gameplay input in declared controls, read in simulation steps, not in this store.
|
|
239
|
+
12. For a host-only side effect of an action, such as a sound, use `useHostActionListener(store, listener)`.
|
|
163
240
|
|
|
164
241
|
## Accept And Reject Examples
|
|
165
242
|
|
|
@@ -172,21 +249,24 @@ import {
|
|
|
172
249
|
acceptAirJamAction,
|
|
173
250
|
createAirJamStore,
|
|
174
251
|
rejectAirJamAction,
|
|
175
|
-
} from "@air-jam/sdk";
|
|
252
|
+
} from "@air-jam/sdk/core";
|
|
176
253
|
|
|
177
|
-
export const
|
|
254
|
+
export const gameStore = createAirJamStore((set, get) => ({
|
|
178
255
|
aliveByPlayerId: {} as Record<string, boolean>,
|
|
179
256
|
cooldownMsByPlayerId: {} as Record<string, number>,
|
|
180
257
|
actions: {
|
|
181
|
-
fire: ({ actorId }) =>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
258
|
+
fire: ({ actorId }) => {
|
|
259
|
+
if (!actorId || get().aliveByPlayerId[actorId] === false)
|
|
260
|
+
return rejectAirJamAction("player_dead", "Dead players cannot fire.");
|
|
261
|
+
const cooldownMs = 4500;
|
|
262
|
+
set((state) => ({
|
|
263
|
+
cooldownMsByPlayerId: {
|
|
264
|
+
...state.cooldownMsByPlayerId,
|
|
265
|
+
[actorId]: cooldownMs,
|
|
266
|
+
},
|
|
267
|
+
}));
|
|
268
|
+
return acceptAirJamAction({ cooldownMs });
|
|
269
|
+
},
|
|
190
270
|
},
|
|
191
271
|
}));
|
|
192
272
|
```
|
|
@@ -205,10 +285,14 @@ The SDK/runtime automatically resolves the correct replicated store domain from
|
|
|
205
285
|
|
|
206
286
|
## API Summary
|
|
207
287
|
|
|
208
|
-
`createAirJamStore<T>(initializer)` returns
|
|
288
|
+
`createAirJamStore<T>(initializer)` from `@air-jam/sdk/core` returns a store to
|
|
289
|
+
declare in `defineAirJamGame({ stores })`. It provides:
|
|
290
|
+
|
|
291
|
+
1. `actions`, dispatching with `() => Promise` or `(payloadObject) => Promise` signatures.
|
|
292
|
+
2. `getState()` and `subscribe()` for logic outside React.
|
|
293
|
+
3. `asPlayer(controllerId)`, a host-only dispatch map for explicit player impersonation of semantic actions.
|
|
209
294
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
3. `asPlayer(controllerId)` host-only dispatch map for explicit player impersonation of semantic actions.
|
|
295
|
+
React reads it with `useAirJamStore(store, selector)` and listens to host-applied
|
|
296
|
+
actions with `useHostActionListener(store, listener)`.
|
|
213
297
|
|
|
214
298
|
`T` must include an `actions` object with host handlers `(ctx, payload) => void`, where `payload` is `undefined` or a plain object.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
Get your first Air Jam game up and running in minutes using our project generator.
|
|
7
7
|
|
|
8
|
-
You need Node.js 22 or newer and pnpm installed. The generator runs `pnpm install`
|
|
8
|
+
You need Node.js 22.15 or newer and pnpm installed. The generator runs `pnpm install`
|
|
9
9
|
for you unless you explicitly choose `--skip-install`.
|
|
10
10
|
|
|
11
11
|
## 1. Create a New Project
|
|
@@ -81,11 +81,12 @@ This project is "vibecode friendly"—it includes documentation and AI instructi
|
|
|
81
81
|
|
|
82
82
|
- **Check `AGENTS.md`**: Project-wide coding contract and workflow for AI coding assistants.
|
|
83
83
|
- **Check `docs/airjam/docs-index.md`**: Canonical local framework references bundled with the template.
|
|
84
|
-
- **Modify `src/airjam.config.ts`**:
|
|
85
|
-
- **Modify `src/game/input.ts`**:
|
|
84
|
+
- **Modify `src/airjam.config.ts`**: The game declaration: metadata, controls, stores, settings and simulation.
|
|
85
|
+
- **Modify `src/game/contracts/input.ts`**: Declare the controls each player has.
|
|
86
86
|
- **Use the starter module map in the template `README.md`**: Follow the current starter structure before creating new homes for code.
|
|
87
87
|
- **Modify `src/game/stores/`**: Starter location for shared networked state and pure transitions.
|
|
88
|
-
- **Modify `src/
|
|
88
|
+
- **Modify `src/game/engine/`**: Starter simulation the host advances in fixed steps.
|
|
89
|
+
- **Modify `src/host/index.tsx`**: Starter host screen.
|
|
89
90
|
- **Modify `src/controller/index.tsx`**: Starter mobile controller surface.
|
|
90
91
|
- **Use `tests/game/`**: Starter testing pattern for domain, stores, engine, adapters, and shared game UI.
|
|
91
92
|
|
|
@@ -107,7 +108,8 @@ pnpm exec airjam mcp config --profile portable --dir .
|
|
|
107
108
|
The `codex` and `claude-desktop` profiles render their respective registration
|
|
108
109
|
formats. Configuration rendering is read-only: install the rendered entry in
|
|
109
110
|
your client, then check its tool discovery. See [For Agents](./for-agents.md)
|
|
110
|
-
for semantic game control and a CLI-only path
|
|
111
|
+
for semantic game control and a CLI-only path, and
|
|
112
|
+
[Supported Agents](./supported-agents.md) for the clients tested end to end.
|
|
111
113
|
|
|
112
114
|
### Run the Complete Evaluation
|
|
113
115
|
|
|
@@ -157,7 +159,8 @@ pnpm run dev
|
|
|
157
159
|
|
|
158
160
|
1. Ensure `VITE_AIR_JAM_APP_ID` is set in your host platform.
|
|
159
161
|
2. Ensure the server URL points at your real Air Jam backend.
|
|
160
|
-
3.
|
|
162
|
+
3. Ensure your site's exact origin is in the game's allowed origins in Create.
|
|
163
|
+
4. Re-copy the App ID from your game's page in Create if the room is refused.
|
|
161
164
|
|
|
162
165
|
### QR / controller join URL issues
|
|
163
166
|
|
|
@@ -171,12 +174,7 @@ When you're ready to share your game outside local development, first register
|
|
|
171
174
|
it with Air Jam so the runtime has a stable hosted identity.
|
|
172
175
|
|
|
173
176
|
1. **Create a game record**:
|
|
174
|
-
|
|
175
|
-
- Create a game if you do not already have one
|
|
176
|
-
- Copy its **App ID**
|
|
177
|
-
|
|
178
|
-
An agent or terminal user can create the same hosted identity without
|
|
179
|
-
navigating the dashboard after the one-time browser-assisted login:
|
|
177
|
+
Register your game from the terminal after a one-time browser-assisted login:
|
|
180
178
|
|
|
181
179
|
```bash
|
|
182
180
|
pnpm exec airjam auth login
|
|
@@ -184,6 +182,10 @@ it with Air Jam so the runtime has a stable hosted identity.
|
|
|
184
182
|
pnpm exec airjam game inspect --game my-game
|
|
185
183
|
```
|
|
186
184
|
|
|
185
|
+
Copy the **App ID** from the response. Your game also appears in [Create](/studio)
|
|
186
|
+
at `/studio/games/<id>`, with **Releases**, **Media**, **Analytics** and **Security**.
|
|
187
|
+
Studio projects create their game record on the first release.
|
|
188
|
+
|
|
187
189
|
2. **Choose your distribution lane**:
|
|
188
190
|
- Deploy your game to a static hosting provider like Vercel, Netlify, or GitHub Pages.
|
|
189
191
|
- Use that self-hosted URL for normal private review and iteration.
|
|
@@ -192,12 +194,27 @@ it with Air Jam so the runtime has a stable hosted identity.
|
|
|
192
194
|
|
|
193
195
|
```bash
|
|
194
196
|
VITE_AIR_JAM_APP_ID=your_app_id_here
|
|
195
|
-
VITE_AIR_JAM_SERVER_URL=https://
|
|
197
|
+
VITE_AIR_JAM_SERVER_URL=https://rooms.airjam.io
|
|
196
198
|
```
|
|
197
199
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
200
|
+
Add your site's origin (for example `https://my-game.example`) to the
|
|
201
|
+
allowed origins in your game's **Security** section in Create. When your page
|
|
202
|
+
opens a room, the SDK asks Air Jam for a short-lived host grant for your App
|
|
203
|
+
ID. Air Jam signs one only for an active App ID, asked from one of its allowed
|
|
204
|
+
origins exactly, and the grant names that one origin. You do not mint tokens or
|
|
205
|
+
add auth code to your game.
|
|
206
|
+
|
|
207
|
+
The origin check keeps other websites from opening rooms under your App ID in
|
|
208
|
+
players' browsers. It is not a secret: a script outside a browser can claim any
|
|
209
|
+
origin, just as it can claim any App ID. What bounds misuse is admission: each
|
|
210
|
+
game and each account may run 20 hosted rooms at once, inside Air Jam's overall
|
|
211
|
+
limit, so rooms someone else opens under your App ID can crowd yours but never
|
|
212
|
+
grow past those caps.
|
|
213
|
+
|
|
214
|
+
On hosted rooms, a crash your game's error boundary catches is also reported to
|
|
215
|
+
Air Jam, as its error name and a short digest (never its message, stack or any
|
|
216
|
+
player input), so it shows up with your game's other room records. Pass your own
|
|
217
|
+
`reportError` to send reports elsewhere.
|
|
201
218
|
|
|
202
219
|
Before publishing your scaffolded game, run the local checks:
|
|
203
220
|
|
|
@@ -209,62 +226,16 @@ pnpm run build
|
|
|
209
226
|
|
|
210
227
|
If you are self-hosting the client, keep SPA rewrites enabled so `/controller?room=XXXX` resolves to your app entry.
|
|
211
228
|
|
|
212
|
-
###
|
|
213
|
-
|
|
214
|
-
If you want stricter production ownership guarantees, you can keep the game static and add one small backend or edge endpoint that returns a signed host grant.
|
|
215
|
-
|
|
216
|
-
This requires a realtime backend that verifies those grants: the hosted Air Jam
|
|
217
|
-
backend or your own server composed with an `authService` adapter. The standalone
|
|
218
|
-
`air-jam-server` command does not read `AIR_JAM_HOST_GRANT_SECRET` and rejects host
|
|
219
|
-
grants by default. Setting the secret alone does not enable grant verification.
|
|
220
|
-
|
|
221
|
-
Frontend env:
|
|
222
|
-
|
|
223
|
-
```bash
|
|
224
|
-
VITE_AIR_JAM_HOST_GRANT_ENDPOINT=/api/airjam/host-grant
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
Grant issuer and verifying backend env (not the standalone server command):
|
|
228
|
-
|
|
229
|
-
```bash
|
|
230
|
-
AIR_JAM_HOST_GRANT_SECRET=your_signing_secret
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
The SDK will fetch the host grant automatically before `host:bootstrap`. Your game code stays unchanged.
|
|
234
|
-
|
|
235
|
-
Example endpoint shape:
|
|
236
|
-
|
|
237
|
-
```ts
|
|
238
|
-
import { createHostGrant } from "@air-jam/sdk/protocol";
|
|
239
|
-
|
|
240
|
-
export async function POST(request: Request) {
|
|
241
|
-
const { appId } = await request.json();
|
|
242
|
-
const { gameId, creatorId } = await loadTrustedAppIdentity(appId);
|
|
243
|
-
const now = Math.floor(Date.now() / 1000);
|
|
244
|
-
|
|
245
|
-
const hostGrant = await createHostGrant({
|
|
246
|
-
secret: process.env.AIR_JAM_HOST_GRANT_SECRET!,
|
|
247
|
-
claims: {
|
|
248
|
-
jti: crypto.randomUUID(),
|
|
249
|
-
aud: "airjam:realtime",
|
|
250
|
-
appId,
|
|
251
|
-
gameId,
|
|
252
|
-
creatorId,
|
|
253
|
-
iat: now,
|
|
254
|
-
exp: now + 60,
|
|
255
|
-
origins: ["https://your-game.example"],
|
|
256
|
-
sessionKind: "game",
|
|
257
|
-
},
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
return Response.json({ hostGrant });
|
|
261
|
-
}
|
|
262
|
-
```
|
|
229
|
+
### Self-hosted rooms
|
|
263
230
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
231
|
+
Run the open `air-jam-server` yourself and point `VITE_AIR_JAM_SERVER_URL` at
|
|
232
|
+
it. In production it needs a gate of your own: compose it with
|
|
233
|
+
`createRoomServer({ gate })` from `@air-jam/server/room-server`, or set
|
|
234
|
+
`AIR_JAM_AUTH_MODE=disabled` to run it open to any host. Its master key is for
|
|
235
|
+
local development and tests only. The SDK sends whatever
|
|
236
|
+
`VITE_AIR_JAM_HOST_GRANT_ENDPOINT` returns (`{ "hostGrant": "..." }`) as the
|
|
237
|
+
credential when it opens a room, so your gate can verify a token your own
|
|
238
|
+
backend signs. Game code stays unchanged.
|
|
268
239
|
|
|
269
240
|
## 6. Publish A Hosted Arcade Release
|
|
270
241
|
|
|
@@ -290,8 +261,6 @@ That command:
|
|
|
290
261
|
- writes `.airjam/release-manifest.json`
|
|
291
262
|
- creates a hosted release zip under `.airjam/releases/<version>/`
|
|
292
263
|
|
|
293
|
-
The scaffolded `release:bundle` script wraps `airjam release bundle --dir .` for you.
|
|
294
|
-
|
|
295
264
|
The hosted artifact contract is fixed:
|
|
296
265
|
|
|
297
266
|
- host entry at `/`
|
|
@@ -299,8 +268,8 @@ The hosted artifact contract is fixed:
|
|
|
299
268
|
|
|
300
269
|
### Terminal or Agent Publishing
|
|
301
270
|
|
|
302
|
-
The CLI can bundle, upload, and wait for validation
|
|
303
|
-
|
|
271
|
+
The CLI can bundle, upload, and wait for validation. Use the game slug or ID
|
|
272
|
+
created in step 5:
|
|
304
273
|
|
|
305
274
|
```bash
|
|
306
275
|
pnpm exec airjam release submit --game my-game --dir . --wait
|
|
@@ -312,7 +281,9 @@ then explicitly make it live when you are ready:
|
|
|
312
281
|
```bash
|
|
313
282
|
pnpm exec airjam release inspect --release <release-id>
|
|
314
283
|
pnpm exec airjam release publish --release <release-id>
|
|
315
|
-
pnpm exec airjam game media --
|
|
284
|
+
pnpm exec airjam game media list --game my-game --json
|
|
285
|
+
pnpm exec airjam game media assign --game my-game --asset-id <asset-id> --json
|
|
286
|
+
pnpm exec airjam game media archive --game my-game --asset-id <asset-id> --json
|
|
316
287
|
pnpm exec airjam game update --game my-game --arcade-visibility listed
|
|
317
288
|
```
|
|
318
289
|
|
|
@@ -321,14 +292,20 @@ timeout does not cancel the background job: inspect the same release rather
|
|
|
321
292
|
than submitting another copy. CLI responses retain the release and generation
|
|
322
293
|
identities needed to resume work.
|
|
323
294
|
|
|
324
|
-
|
|
295
|
+
`game media list` (also `inspect`) returns existing assets with IDs, kinds,
|
|
296
|
+
status and active selections. `assign` reuses an earlier asset for its kind;
|
|
297
|
+
`archive` retires one by ID and clears its slot if active. These commands use
|
|
298
|
+
the saved machine login and accept `--platform-url` and `--help`. Without
|
|
299
|
+
`--json` they print readable output. Use `game media upload` for new files.
|
|
300
|
+
|
|
301
|
+
### Publish From Create
|
|
325
302
|
|
|
326
303
|
Alternatively, upload the zip produced by `airjam release bundle` above:
|
|
327
304
|
|
|
328
|
-
1.
|
|
305
|
+
1. Open your game in [Create](/studio) and choose **Releases**.
|
|
329
306
|
2. Upload the generated zip artifact.
|
|
330
307
|
3. Make the validated release live.
|
|
331
|
-
4. Upload
|
|
308
|
+
4. Upload thumbnail, cover, and preview media in **Media**.
|
|
332
309
|
5. Set the game's Arcade visibility to listed.
|
|
333
310
|
|
|
334
311
|
Your game is now live in the public Arcade on Air Jam-hosted infrastructure.
|