@air-jam/cli 0.9.3 → 1.0.0-beta.10
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/dist/scaffold.d.ts +8 -1
- package/dist/scaffold.js +6 -1
- package/dist/scaffold.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 +19 -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 +108 -172
- 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 +166 -0
- package/template-assets/documentation/sdk/ui-components/page.mdx +38 -27
- package/template-assets/managed/.airjam/ai-pack.json +65 -47
- 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/composition-shell-contract.md +4 -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 +108 -167
- package/template-assets/managed/docs/airjam/generated/settings.md +169 -0
- package/template-assets/managed/docs/airjam/generated/state-and-rendering.md +19 -0
- package/template-assets/managed/docs/airjam/generated/supported-agents.md +21 -0
- package/template-assets/managed/docs/airjam/generated/ui-components.md +38 -25
- package/template-assets/managed/docs/airjam/prefab-authoring.md +100 -0
- package/template-assets/managed/docs/airjam/preview-controllers.md +5 -2
- 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
|
@@ -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
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
<!-- Generated from content/docs/sdk/assets-and-theme/page.mdx. Do not edit directly. -->
|
|
2
|
+
<!-- Canonical public doc: https://airjam.io/docs/sdk/assets-and-theme -->
|
|
3
|
+
|
|
4
|
+
# Game Assets and Theme
|
|
5
|
+
|
|
6
|
+
Declare a game's sounds, images, other loaded files, colours and fonts in its
|
|
7
|
+
React-free game declaration. Tools read them through `airjam.inspect_game` in
|
|
8
|
+
`declaration.assets` and `declaration.theme`.
|
|
9
|
+
|
|
10
|
+
## Declare loaded files
|
|
11
|
+
|
|
12
|
+
Keep the assets in a leaf module so rendering and audio code can import them
|
|
13
|
+
without importing the config back again.
|
|
14
|
+
|
|
15
|
+
```ts filename="src/game/assets.ts"
|
|
16
|
+
import { defineAirJamAssets } from "@air-jam/sdk/core";
|
|
17
|
+
|
|
18
|
+
export const gameAssets = defineAirJamAssets({
|
|
19
|
+
sounds: {
|
|
20
|
+
hit: { src: ["/sounds/hit.wav"], volume: 0.55 },
|
|
21
|
+
music: {
|
|
22
|
+
src: ["/music/theme.mp3"],
|
|
23
|
+
category: "music",
|
|
24
|
+
html5: true,
|
|
25
|
+
surface: "host",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
images: { player: { src: "/images/player.png" } },
|
|
29
|
+
files: { animation: { src: "/animations/fire.json" } },
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Pass it as `defineAirJamGame({ assets: gameAssets, ... })`. Every source is a
|
|
34
|
+
served path under the game's `public/` directory: it starts with `/` and has no
|
|
35
|
+
parent segments, query or hash. A sound takes a nonempty `src` array and optional
|
|
36
|
+
`volume` (0 to 1), `loop`, `html5`, `sprite` and `category` (`music` or `sfx`).
|
|
37
|
+
A sprite maps its name to `[offsetMilliseconds, durationMilliseconds]`.
|
|
38
|
+
`surface` selects `host` or `controller`; omitting it makes the sound available
|
|
39
|
+
on both. Images and files each take `{ src }`.
|
|
40
|
+
|
|
41
|
+
The React binding mounts audio for each surface automatically. Remove your
|
|
42
|
+
own `<AudioRuntime>` wrappers. Existing `useAudio` calls and `MusicPlaylist`
|
|
43
|
+
components use the binding's runtime. Host-only music never loads on a phone.
|
|
44
|
+
Read image and file paths from the object, for example
|
|
45
|
+
`gameAssets.images.player.src`, rather than repeating URL strings.
|
|
46
|
+
|
|
47
|
+
Inspection checks every declared source exists and fails with
|
|
48
|
+
`AJ_ASSET_MISSING`, naming the game, entry and missing path. This checks file
|
|
49
|
+
presence, not whether code loads an undeclared URL. Arcade cover, thumbnail and
|
|
50
|
+
preview media remain outside this declaration.
|
|
51
|
+
|
|
52
|
+
## Declare colours and fonts
|
|
53
|
+
|
|
54
|
+
```ts filename="src/game/theme.ts"
|
|
55
|
+
import { defineAirJamTheme } from "@air-jam/sdk/core";
|
|
56
|
+
|
|
57
|
+
export const gameTheme = defineAirJamTheme({
|
|
58
|
+
colors: { background: "#050816", team1: "#f97316", team2: "#38bdf8" },
|
|
59
|
+
fonts: { display: '"Avenir Next", "Trebuchet MS", sans-serif' },
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Pass it as `defineAirJamGame({ theme: gameTheme, ... })`. Keys are lower camel
|
|
64
|
+
case. Colours use hex, `rgb()`, `rgba()`, `hsl()` or `oklch()`; fonts are CSS
|
|
65
|
+
font-family lists. Font files still load through your existing CSS imports or
|
|
66
|
+
declared file paths.
|
|
67
|
+
|
|
68
|
+
The binding renders a `<style>` with each surface on its first render. It
|
|
69
|
+
exposes `--airjam-color-background`, `--airjam-color-team1` and
|
|
70
|
+
`--airjam-font-display`; camel case keys become kebab case. No generation step
|
|
71
|
+
or effect is needed. Map the variables to existing Tailwind names:
|
|
72
|
+
|
|
73
|
+
```css filename="src/index.css"
|
|
74
|
+
@import "tailwindcss";
|
|
75
|
+
|
|
76
|
+
@theme inline {
|
|
77
|
+
--color-game-bg: var(--airjam-color-background);
|
|
78
|
+
--color-game-orange: var(--airjam-color-team1);
|
|
79
|
+
--font-game: var(--airjam-font-display);
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Existing classes such as `bg-game-bg` keep their names. Canvas and 3D code read
|
|
84
|
+
`gameTheme.colors.team1` and `gameTheme.fonts.display` directly. Remove the
|
|
85
|
+
literals they replace. Shadows, gradients and layout remain handwritten CSS.
|
|
86
|
+
|
|
87
|
+
Both fields are optional; an omitted field is described as empty maps.
|
|
88
|
+
The declaration graph must remain free of React, the DOM and CSS imports.
|
|
89
|
+
|
|
90
|
+
## Isolated assets and states
|
|
91
|
+
|
|
92
|
+
Prefabs are the catalog identity. Declare `space` and, for animated assets, named
|
|
93
|
+
`states`. `space` is optional: it defaults to `"3d"` when `preview.camera` is set,
|
|
94
|
+
otherwise `"2d"`. A rendered `PrefabDefinition` requires `render`; a renderer-free
|
|
95
|
+
`PrefabDeclaration` omits it. Omitting states creates one static state (`static`). State time is in
|
|
96
|
+
seconds; the SDK owns playback and seeking, while the game draws that exact time.
|
|
97
|
+
A state without `seconds` is a static pose. `loop: true` wraps a timed state;
|
|
98
|
+
otherwise it pauses at the end.
|
|
99
|
+
|
|
100
|
+
```ts filename="src/airjam.config.ts"
|
|
101
|
+
import { defineAirJamGame } from "@air-jam/sdk/core";
|
|
102
|
+
import { createPrefabCatalog, definePrefab } from "@air-jam/sdk/prefabs";
|
|
103
|
+
import { z } from "zod";
|
|
104
|
+
|
|
105
|
+
export const dotProps = z.object({ radius: z.number().positive() });
|
|
106
|
+
export const dot = definePrefab({
|
|
107
|
+
id: "dot",
|
|
108
|
+
label: "Dot",
|
|
109
|
+
category: "effect",
|
|
110
|
+
description: "Pulsing circle",
|
|
111
|
+
tags: ["effect"],
|
|
112
|
+
space: "2d",
|
|
113
|
+
configSchema: dotProps,
|
|
114
|
+
defaultProps: { radius: 40 },
|
|
115
|
+
states: [{ id: "pulse", label: "Pulse", seconds: 1, loop: true }],
|
|
116
|
+
});
|
|
117
|
+
// Add to your existing definition, retaining its metadata and other declarations:
|
|
118
|
+
export const game = defineAirJamGame({
|
|
119
|
+
metadata,
|
|
120
|
+
prefabs: createPrefabCatalog([dot]),
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Keep this declaration module free of React and renderer imports. In the host
|
|
125
|
+
application, the stage selects the renderer for the declared prefab:
|
|
126
|
+
|
|
127
|
+
```tsx filename="src/prefab-stage.tsx"
|
|
128
|
+
import {
|
|
129
|
+
createAirJamApp,
|
|
130
|
+
drawAgentCanvas,
|
|
131
|
+
useHostAgentCapture,
|
|
132
|
+
usePrefabInspection,
|
|
133
|
+
} from "@air-jam/sdk";
|
|
134
|
+
import { resolvePrefab2DTransform } from "@air-jam/sdk/prefabs";
|
|
135
|
+
import { useLayoutEffect, useRef } from "react";
|
|
136
|
+
import { dot, dotProps, game } from "./airjam.config";
|
|
137
|
+
|
|
138
|
+
function Stage() {
|
|
139
|
+
const canvas = useRef<HTMLCanvasElement>(null);
|
|
140
|
+
const { prefab, props, time, view } = usePrefabInspection();
|
|
141
|
+
if (prefab.id !== dot.id) throw new Error(`Unknown prefab: ${prefab.id}`);
|
|
142
|
+
const { radius } = dotProps.parse(props);
|
|
143
|
+
useHostAgentCapture((image, options) =>
|
|
144
|
+
drawAgentCanvas(canvas.current, image, options),
|
|
145
|
+
);
|
|
146
|
+
useLayoutEffect(() => {
|
|
147
|
+
const context = canvas.current?.getContext("2d");
|
|
148
|
+
if (!context) return;
|
|
149
|
+
const { scale, translate } = resolvePrefab2DTransform(view, 512);
|
|
150
|
+
context.resetTransform();
|
|
151
|
+
context.clearRect(0, 0, 512, 512);
|
|
152
|
+
context.translate(256 + translate[0], 256 + translate[1]);
|
|
153
|
+
context.scale(scale, scale);
|
|
154
|
+
context.beginPath();
|
|
155
|
+
context.arc(
|
|
156
|
+
0,
|
|
157
|
+
0,
|
|
158
|
+
radius * (1 + 0.2 * Math.sin(time * Math.PI * 2)),
|
|
159
|
+
0,
|
|
160
|
+
Math.PI * 2,
|
|
161
|
+
);
|
|
162
|
+
context.fillStyle = "#ff6a35";
|
|
163
|
+
context.fill();
|
|
164
|
+
}, [radius, time, view]);
|
|
165
|
+
return <canvas ref={canvas} width={512} height={512} />;
|
|
166
|
+
}
|
|
167
|
+
const app = createAirJamApp(game);
|
|
168
|
+
// In the existing host route (LiveGame is your game's live component):
|
|
169
|
+
<app.Host prefabStage={Stage}>
|
|
170
|
+
<LiveGame />
|
|
171
|
+
</app.Host>;
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
For R3F, use `resolvePrefabOrbitCamera(prefab.preview?.camera, view)` and apply its
|
|
175
|
+
`position`, `target` and `fov` to the game's camera. Capture through
|
|
176
|
+
`useHostAgentCapture`: render the R3F scene immediately before copying `gl.domElement`
|
|
177
|
+
with `drawAgentCanvas`, because WebGL drawing buffers need not survive a frame.
|
|
178
|
+
The helper has no Three dependency. Zoom 1 keeps default framing; yaw/pitch use
|
|
179
|
+
degrees relative to the preview camera. Pan uses fractions of view height, right/up
|
|
180
|
+
positive. The 2D helper returns pixel translation and scale around default framing;
|
|
181
|
+
yaw and pitch have no effect in 2D.
|
|
182
|
+
|
|
183
|
+
Open `?airjamInspect=1&prefab=dot&state=pulse&time=0.3` for a paused isolated frame.
|
|
184
|
+
Stages read parsed default props, state, time, playing and view from
|
|
185
|
+
`usePrefabInspection()`. They must draw only that prefab, without reading live room
|
|
186
|
+
stores, starting physics or advancing their own animation clock. The SDK reports
|
|
187
|
+
missing catalogs, missing stages and rendering errors. `@air-jam/sdk/prefab-inspection`
|
|
188
|
+
exports the validated parent client for lists, selection and batch canvas captures.
|
|
@@ -9,6 +9,8 @@ The main failure mode is borrowing desktop web-app patterns for active gameplay
|
|
|
9
9
|
|
|
10
10
|
## Gameplay Controller Rules
|
|
11
11
|
|
|
12
|
+
A game whose `inputModalities` include `'joystick'` always gets a landscape controller; the SDK applies it, so do not set orientation; lay it out with `GamepadLayout` from `@air-jam/sdk/ui`: the stick under the left thumb, the actions under the right in a square the same size, and only short status between them.
|
|
13
|
+
|
|
12
14
|
For active gameplay:
|
|
13
15
|
|
|
14
16
|
1. use an absolute `inset-0` root
|
|
@@ -18,6 +20,35 @@ For active gameplay:
|
|
|
18
20
|
5. keep controls visually obvious and single-purpose
|
|
19
21
|
6. minimize text and dense hierarchy
|
|
20
22
|
|
|
23
|
+
## Sideways Controllers
|
|
24
|
+
|
|
25
|
+
A sideways phone is held like a gamepad, so its controls use the screen like one. Compose them in `GamepadLayout`:
|
|
26
|
+
|
|
27
|
+
1. the stick goes in `left` and the actions in `right`; both get the same square, so they carry the same weight and mirror each other about the centre, each centred in its thumb zone on one line
|
|
28
|
+
2. a single action fills its square; several actions share it as one cluster, as phone action games do, rather than starting a third column: the main action sits at the square's centre under the resting thumb at about half the square's width, each other action is about two thirds of the main one's size on a tight arc around its inner side (below, toward the centre, above) with the most used nearest, a rarely used utility goes smaller on the outer side, and every button stays inside the thumb zone
|
|
29
|
+
3. a button with a cooldown shows it on itself: a dark sweep over the icon that shrinks as it recovers, the seconds left when the wait is over a second, and full colour once it is ready again
|
|
30
|
+
4. buttons show icons, not words, drawn as one family: the same grid, the same stroke width with round caps and joins (or all filled), the same optical size of about half the button, one simple silhouette each and no detail finer than the stroke; judge them at real size on a phone
|
|
31
|
+
5. `center` holds only what a player reads at a glance: a round, a number, a word, a few icons; it never wraps into squeezed lines
|
|
32
|
+
6. a longer message goes in the header bar above the layout, or stays on the TV
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { ControlButton, GamepadLayout, Stick } from "@air-jam/sdk/ui";
|
|
36
|
+
|
|
37
|
+
// Before: a big stick, a small button pushed to the edge, a sentence wrapping between them.
|
|
38
|
+
<div className="flex h-full items-center justify-between px-6">
|
|
39
|
+
<Stick control={gameInput.move} className="size-56" />
|
|
40
|
+
<p className="max-w-48 text-2xl">Splash! Back next round</p>
|
|
41
|
+
<ControlButton control={gameInput.dash} className="size-28">Dash</ControlButton>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
// After: equal mirrored thumbs, a glanceable centre, the sentence in the header.
|
|
45
|
+
<GamepadLayout
|
|
46
|
+
left={<Stick control={gameInput.move} className="rounded-full bg-white/10" />}
|
|
47
|
+
center={<span className="text-xs uppercase">Round 1</span>}
|
|
48
|
+
right={<ControlButton control={gameInput.dash} className="rounded-full bg-sky-400">Dash</ControlButton>}
|
|
49
|
+
/>
|
|
50
|
+
```
|
|
51
|
+
|
|
21
52
|
## Lobby Rules
|
|
22
53
|
|
|
23
54
|
Lobby screens can be slightly more flexible, but should still prefer:
|
|
@@ -59,3 +90,13 @@ For template and starter work, a practical split is:
|
|
|
59
90
|
2. a gameplay-oriented icon set for abilities, pickups, and status effects
|
|
60
91
|
|
|
61
92
|
Keep icon usage behind local wrappers where practical so the project can curate or replace icons later.
|
|
93
|
+
|
|
94
|
+
## Private player screens and word games
|
|
95
|
+
|
|
96
|
+
Keep secret words or cards in a per-controller map declared with
|
|
97
|
+
`createAirJamStore`'s `privateField`; read that phone's entry with
|
|
98
|
+
`useAirJamPrivateState`. The public store excludes this field and each phone
|
|
99
|
+
receives only its own entry. Test a reveal with `studio_press_phone`'s hold action.
|
|
100
|
+
|
|
101
|
+
A decision-model seat (Jev) answers choice questions only. Give model seats authored
|
|
102
|
+
candidate clues or answers as options; people can type freely into phone fields.
|
|
@@ -63,7 +63,7 @@ Use the right browser console for the right problem:
|
|
|
63
63
|
|
|
64
64
|
1. **Host tab** for room creation, host bootstrap, input consumption, and gameplay errors
|
|
65
65
|
2. **Controller tab/phone remote inspector** for join failures, input publishing, haptics, and controller UI state
|
|
66
|
-
3. **Server terminal** for room lifecycle,
|
|
66
|
+
3. **Server terminal** for room lifecycle, dropped connections, refused hosts and phones
|
|
67
67
|
|
|
68
68
|
Do not debug everything from only one surface.
|
|
69
69
|
|
|
@@ -95,16 +95,17 @@ pnpm run dev -- --secure
|
|
|
95
95
|
|
|
96
96
|
Check:
|
|
97
97
|
|
|
98
|
-
1.
|
|
99
|
-
2.
|
|
100
|
-
3.
|
|
101
|
-
4.
|
|
98
|
+
1. the game declares its controls with `defineAirJamGame({ input })`
|
|
99
|
+
2. the controller renders the SDK's phone controls bound to those controls
|
|
100
|
+
3. the simulation reads them in its step with `input(playerId)`
|
|
101
|
+
4. you are not trying to send per-frame input through store actions
|
|
102
|
+
5. the dev log shows no `AJ_INPUT_INVALID` diagnostic
|
|
102
103
|
|
|
103
104
|
### Store actions do nothing
|
|
104
105
|
|
|
105
106
|
Check:
|
|
106
107
|
|
|
107
|
-
1. actions are dispatched via `
|
|
108
|
+
1. actions are dispatched via `gameStore.actions` and the store is declared in `defineAirJamGame({ stores })`
|
|
108
109
|
2. payloads are plain serializable objects
|
|
109
110
|
3. your controller is connected before dispatching
|
|
110
111
|
4. identity-dependent actions use `ctx.actorId` on the host side
|
|
@@ -44,6 +44,8 @@ the server. `mcp doctor` distinguishes project declarations from detected client
|
|
|
44
44
|
registrations. Confirm that the connected client discovers Air Jam's tools before
|
|
45
45
|
treating the connection as working.
|
|
46
46
|
|
|
47
|
+
[Supported Agents](./supported-agents.md) lists the clients tested end to end.
|
|
48
|
+
|
|
47
49
|
## Operate and Evaluate
|
|
48
50
|
|
|
49
51
|
For gameplay assertions, use `airjam.open_game_session`,
|
|
@@ -52,6 +54,12 @@ For gameplay assertions, use `airjam.open_game_session`,
|
|
|
52
54
|
do not guess game-specific action IDs. `airjam.capture_game_session_visuals`
|
|
53
55
|
adds host and phone-controller screenshots to the same session.
|
|
54
56
|
|
|
57
|
+
In Studio, `studio_press_phone` taps, holds or types on one named mounted Studio phone
|
|
58
|
+
and returns its private screen in the same call. Coordinates are fractions 0..1 of
|
|
59
|
+
`studio_observe_current_game`'s `surface=phone` image. Tap a field before typing;
|
|
60
|
+
a hold captures while pressed, then releases. Reuse the requestId UUID for retries.
|
|
61
|
+
Guest/real phones and older runtimes return an explicit unavailable reason.
|
|
62
|
+
|
|
55
63
|
MCP is optional. A terminal agent can use the same services:
|
|
56
64
|
|
|
57
65
|
```bash
|
|
@@ -73,6 +81,22 @@ The [Quick Start publishing guide](https://airjam.io/docs/getting-started/quick-
|
|
|
73
81
|
covers CLI authentication, hosted release submission, inspection, and explicit
|
|
74
82
|
publication. Local development and evaluation do not require hosted publishing.
|
|
75
83
|
|
|
84
|
+
## Decision-model Players
|
|
85
|
+
|
|
86
|
+
An `AirJamPlayerContract` from `@air-jam/devtools/testing` describes play with
|
|
87
|
+
`brief` and `turn`. A turn returns `{ state, question, options }` or `null` when
|
|
88
|
+
the seat has nothing to do. Offer 1 to 16 named options, each with a plain-language
|
|
89
|
+
`when` and its `control`. Zero options is invalid; use `null` to wait.
|
|
90
|
+
|
|
91
|
+
A single sensible move is allowed: for example, a lobby turn can offer only
|
|
92
|
+
`join` with `control: { kind: "action", actionId: "join_match" }`. The run owner
|
|
93
|
+
takes that control directly without calling a decision model or incurring model
|
|
94
|
+
cost. Do not invent a second option to satisfy validation. Multiple options ask
|
|
95
|
+
the run's model to choose. Automatic answers retain the choice and control in the
|
|
96
|
+
trace, marked `Only option; no model asked.`, and count toward the seat's optional
|
|
97
|
+
`answers.automatic` summary. The policy receives the choice just like a model
|
|
98
|
+
answer on its next step.
|
|
99
|
+
|
|
76
100
|
## Read These First
|
|
77
101
|
|
|
78
102
|
1. [Introduction](./introduction.md)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# Game Ideas for Air Jam
|
|
5
5
|
|
|
6
|
-
A collection of game concepts that leverage Air Jam's unique architecture: **High-Frequency Input Streams** (
|
|
6
|
+
A collection of game concepts that leverage Air Jam's unique architecture: **High-Frequency Input Streams** (declared controls) + **Reliable Shared State** (AirJam Store).
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|