@air-jam/cli 0.0.0-stage → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +145 -2
  3. package/bin/airjam.mjs +66 -0
  4. package/dist/ai-pack.d.ts +44 -0
  5. package/dist/ai-pack.js +15 -0
  6. package/dist/ai-pack.js.map +1 -0
  7. package/dist/chunk-A4V2N4LX.js +938 -0
  8. package/dist/chunk-A4V2N4LX.js.map +1 -0
  9. package/dist/chunk-J5MAU4QZ.js +102 -0
  10. package/dist/chunk-J5MAU4QZ.js.map +1 -0
  11. package/dist/chunk-N7AI7HZK.js +529 -0
  12. package/dist/chunk-N7AI7HZK.js.map +1 -0
  13. package/dist/development.d.ts +98 -0
  14. package/dist/development.js +33 -0
  15. package/dist/development.js.map +1 -0
  16. package/dist/documentation.d.ts +27 -0
  17. package/dist/documentation.js +7 -0
  18. package/dist/documentation.js.map +1 -0
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.js +2184 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/scaffold.d.ts +6 -0
  23. package/dist/scaffold.js +20 -0
  24. package/dist/scaffold.js.map +1 -0
  25. package/package.json +78 -3
  26. package/runtime/local-network.d.mts +8 -0
  27. package/runtime/local-network.mjs +9 -0
  28. package/runtime/vite-config.d.mts +42 -0
  29. package/runtime/vite-config.mjs +130 -0
  30. package/runtime/vite-https.d.mts +11 -0
  31. package/runtime/vite-https.mjs +41 -0
  32. package/template-assets/bootstrap/.claude/launch.json +12 -0
  33. package/template-assets/bootstrap/AGENTS.md +248 -0
  34. package/template-assets/bootstrap/CLAUDE.md +63 -0
  35. package/template-assets/bootstrap/_gitignore +6 -0
  36. package/template-assets/bootstrap/skills/airjam-docs-workflow/SKILL.md +49 -0
  37. package/template-assets/bootstrap/skills/airjam-mcp/SKILL.md +56 -0
  38. package/template-assets/bootstrap/skills/canvas-2d-gameplay/SKILL.md +47 -0
  39. package/template-assets/bootstrap/skills/controller-ui/SKILL.md +69 -0
  40. package/template-assets/bootstrap/skills/debug-and-test/SKILL.md +72 -0
  41. package/template-assets/bootstrap/skills/game-architecture/SKILL.md +58 -0
  42. package/template-assets/bootstrap/skills/game-state-and-rendering/SKILL.md +44 -0
  43. package/template-assets/bootstrap/skills/host-surface/SKILL.md +52 -0
  44. package/template-assets/bootstrap/skills/index.md +36 -0
  45. package/template-assets/bootstrap/skills/prefab-authoring/SKILL.md +48 -0
  46. package/template-assets/bootstrap/skills/r3f-3d-scene/SKILL.md +51 -0
  47. package/template-assets/documentation/for-agents/controller-ui/page.mdx +60 -0
  48. package/template-assets/documentation/for-agents/page.mdx +98 -0
  49. package/template-assets/documentation/for-agents/project-structure/page.mdx +172 -0
  50. package/template-assets/documentation/for-agents/state-and-rendering/page.mdx +79 -0
  51. package/template-assets/documentation/getting-started/debugging/page.mdx +165 -0
  52. package/template-assets/documentation/getting-started/dev-logs/page.mdx +171 -0
  53. package/template-assets/documentation/getting-started/game-ideas/page.mdx +116 -0
  54. package/template-assets/documentation/getting-started/introduction/page.mdx +183 -0
  55. package/template-assets/documentation/getting-started/migrating-legacy-games/page.mdx +427 -0
  56. package/template-assets/documentation/getting-started/quick-start/page.mdx +333 -0
  57. package/template-assets/documentation/how-it-works/architecture/page.mdx +189 -0
  58. package/template-assets/documentation/how-it-works/host-system/page.mdx +267 -0
  59. package/template-assets/documentation/manifest.json +430 -0
  60. package/template-assets/documentation/sdk/hooks/page.mdx +500 -0
  61. package/template-assets/documentation/sdk/input-system/page.mdx +270 -0
  62. package/template-assets/documentation/sdk/networked-state/page.mdx +213 -0
  63. package/template-assets/documentation/sdk/ui-components/page.mdx +227 -0
  64. package/template-assets/managed/.airjam/ai-pack.json +191 -0
  65. package/template-assets/managed/docs/airjam/agent-gold-path.md +67 -0
  66. package/template-assets/managed/docs/airjam/agent-mcp.md +135 -0
  67. package/template-assets/managed/docs/airjam/canvas-2d-gameplay.md +82 -0
  68. package/template-assets/managed/docs/airjam/composition-shell-contract.md +87 -0
  69. package/template-assets/managed/docs/airjam/debug-and-testing.md +86 -0
  70. package/template-assets/managed/docs/airjam/development-loop.md +51 -0
  71. package/template-assets/managed/docs/airjam/docs-index.md +58 -0
  72. package/template-assets/managed/docs/airjam/generated/architecture.md +178 -0
  73. package/template-assets/managed/docs/airjam/generated/controller-ui.md +61 -0
  74. package/template-assets/managed/docs/airjam/generated/debugging-and-logs.md +164 -0
  75. package/template-assets/managed/docs/airjam/generated/for-agents.md +99 -0
  76. package/template-assets/managed/docs/airjam/generated/game-ideas.md +107 -0
  77. package/template-assets/managed/docs/airjam/generated/host-system.md +251 -0
  78. package/template-assets/managed/docs/airjam/generated/input-system.md +260 -0
  79. package/template-assets/managed/docs/airjam/generated/introduction.md +175 -0
  80. package/template-assets/managed/docs/airjam/generated/migrating-legacy-games.md +426 -0
  81. package/template-assets/managed/docs/airjam/generated/networked-state.md +214 -0
  82. package/template-assets/managed/docs/airjam/generated/project-structure.md +171 -0
  83. package/template-assets/managed/docs/airjam/generated/quick-start.md +334 -0
  84. package/template-assets/managed/docs/airjam/generated/sdk-hooks.md +490 -0
  85. package/template-assets/managed/docs/airjam/generated/state-and-rendering.md +80 -0
  86. package/template-assets/managed/docs/airjam/generated/ui-components.md +222 -0
  87. package/template-assets/managed/docs/airjam/generated/unified-dev-logs.md +170 -0
  88. package/template-assets/managed/docs/airjam/iconography.md +55 -0
  89. package/template-assets/managed/docs/airjam/prefab-authoring.md +112 -0
  90. package/template-assets/managed/docs/airjam/preview-controllers.md +126 -0
  91. package/template-assets/managed/docs/airjam/r3f-3d-scene.md +97 -0
  92. package/template-assets/managed/docs/airjam/state-lanes-cookbook.md +106 -0
  93. package/template-assets/managed/docs/airjam/visual-system.md +103 -0
@@ -0,0 +1,500 @@
1
+
2
+
3
+ # SDK Hooks
4
+
5
+ The Air Jam SDK provides React hooks for building multiplayer games. This page documents all available hooks and their usage.
6
+
7
+ ## Runtime Boundaries
8
+
9
+ ### `createAirJamApp`
10
+
11
+ Use `createAirJamApp` as the canonical runtime setup. It wires scoped providers, route paths, and typed input schema in one place.
12
+
13
+ ```tsx
14
+ import { createAirJamApp, env } from "@air-jam/sdk";
15
+ import { z } from "zod";
16
+
17
+ const inputSchema = z.object({
18
+ vector: z.object({ x: z.number(), y: z.number() }),
19
+ timestamp: z.number(),
20
+ });
21
+
22
+ const airjam = createAirJamApp({
23
+ runtime: env.vite(import.meta.env),
24
+ controllerPath: "/controller",
25
+ input: { schema: inputSchema },
26
+ });
27
+
28
+ <Routes>
29
+ <Route
30
+ path="/"
31
+ element={
32
+ <airjam.Host>
33
+ <HostView />
34
+ </airjam.Host>
35
+ }
36
+ />
37
+ <Route
38
+ path={airjam.paths.controller}
39
+ element={
40
+ <airjam.Controller>
41
+ <ControllerView />
42
+ </airjam.Controller>
43
+ }
44
+ />
45
+ </Routes>;
46
+ ```
47
+
48
+ **Environment Variables:**
49
+
50
+ The provider automatically reads from these environment variables if props aren't provided:
51
+
52
+ - `VITE_AIR_JAM_SERVER_URL` / `NEXT_PUBLIC_AIR_JAM_SERVER_URL` - WebSocket server URL
53
+ - `VITE_AIR_JAM_APP_ID` / `NEXT_PUBLIC_AIR_JAM_APP_ID` - Public app ID
54
+
55
+ ---
56
+
57
+ ## Host Hooks
58
+
59
+ ### `useAirJamHost`
60
+
61
+ Consumer hook for host runtime state and actions. Mount `airjam.Host` once at the boundary, then call `useAirJamHost()` anywhere below it.
62
+
63
+ Call `useAirJamHost(selector)` when a component only needs a narrow slice of
64
+ host session state and you want to avoid rerendering on unrelated runtime
65
+ fields.
66
+ Selectors receive state fields only; call `useAirJamHost()` when a component
67
+ also needs runtime controls such as `joinUrl`, `sendSignal`, or `getInput`.
68
+
69
+ ```tsx
70
+ import { useAirJamHost } from "@air-jam/sdk";
71
+ import { airjam } from "../airjam.config";
72
+
73
+ const HostShell = () => (
74
+ <airjam.Host
75
+ roomId="GAME"
76
+ onPlayerJoin={(player) => {
77
+ console.log(`${player.label} joined with color ${player.color}`);
78
+ }}
79
+ onPlayerLeave={(controllerId) => {
80
+ console.log(`Player ${controllerId} left`);
81
+ }}
82
+ >
83
+ <HostView />
84
+ </airjam.Host>
85
+ );
86
+
87
+ const HostView = () => {
88
+ const host = useAirJamHost();
89
+
90
+ // Return values
91
+ const {
92
+ roomId, // "ABCD" - The room code
93
+ joinUrl, // Full URL for controllers to join
94
+ joinUrlStatus, // "loading" | "ready" | "unavailable"
95
+ connectionStatus, // "connected" | "connecting" | "disconnected" | "idle"
96
+ players, // Array of PlayerProfile
97
+ controllers, // Rich controller-session roster with source + lease state
98
+ runtimeState, // "playing" | "paused"
99
+ lastError, // Error message if any
100
+ mode, // "standalone" | "platform"
101
+
102
+ // Functions
103
+ getInput, // (controllerId: string) => Input | undefined
104
+ sendSignal, // Send haptics/toasts to controllers
105
+ sendState, // Publish lightweight controller presentation state
106
+ pauseRuntime, // Set runtimeState to "paused"
107
+ resumeRuntime, // Set runtimeState to "playing"
108
+ setRuntimeState, // Explicitly set "playing" | "paused"
109
+ reconnect, // Force reconnection
110
+ } = host;
111
+
112
+ return (
113
+ <div className="relative min-h-screen bg-black text-white">
114
+ <header className="absolute top-0 right-0 left-0 z-10 flex items-center justify-between border-b border-white/10 bg-black/70 px-4 py-2 backdrop-blur">
115
+ <span>Room {roomId}</span>
116
+ <button
117
+ onClick={runtimeState === "playing" ? pauseRuntime : resumeRuntime}
118
+ >
119
+ {runtimeState === "playing" ? "Pause" : "Resume"}
120
+ </button>
121
+ </header>
122
+ <GameCanvas />
123
+ </div>
124
+ );
125
+ };
126
+ ```
127
+
128
+ Use `players` for normal gameplay-facing iteration. Use `controllers` when you
129
+ need controller provenance or local recovery tooling.
130
+
131
+ **Reading Input in Game Loops:**
132
+
133
+ ```tsx
134
+ // In a React Three Fiber component
135
+ useFrame(() => {
136
+ host.players.forEach((player) => {
137
+ const input = host.getInput(player.id);
138
+ if (!input) return;
139
+
140
+ // Move player based on joystick
141
+ movePlayer(player.id, input.vector);
142
+
143
+ // Handle button press (tap-safe pulse by default)
144
+ if (input.action) {
145
+ playerShoot(player.id);
146
+ }
147
+ });
148
+ });
149
+ ```
150
+
151
+ `sendState` is only for lightweight controller presentation metadata such as
152
+ orientation, pause/play status, or short UI messages. It is not the primary
153
+ gameplay sync channel. Authoritative multiplayer state should live in the
154
+ networked stores and flow automatically through those boundaries.
155
+
156
+ **Sending Haptic Feedback:**
157
+
158
+ ```tsx
159
+ // Vibrate a specific player's phone
160
+ host.sendSignal("HAPTIC", { pattern: "heavy" }, playerId);
161
+
162
+ // Available patterns: "light", "medium", "heavy", "success", "failure", "custom"
163
+ host.sendSignal(
164
+ "HAPTIC",
165
+ {
166
+ pattern: "custom",
167
+ sequence: [50, 100, 50], // Vibrate 50ms, pause 100ms, vibrate 50ms
168
+ },
169
+ playerId,
170
+ );
171
+ ```
172
+
173
+ **Sending Toast Notifications:**
174
+
175
+ ```tsx
176
+ // Show notification on a player's controller
177
+ host.sendSignal(
178
+ "TOAST",
179
+ {
180
+ message: "Achievement unlocked: First blood",
181
+ color: "#22c55e", // Optional accent color
182
+ duration: 2000, // Optional duration in ms
183
+ },
184
+ playerId,
185
+ );
186
+
187
+ // Broadcast to all players (omit targetId)
188
+ host.sendSignal("TOAST", {
189
+ message: "Round start! Get ready to fight.",
190
+ });
191
+ ```
192
+
193
+ ---
194
+
195
+ ### `useGetInput`
196
+
197
+ Lightweight hook for accessing input without triggering re-renders. Use in performance-critical components.
198
+
199
+ ```tsx
200
+ import { useGetInput } from "@air-jam/sdk";
201
+
202
+ const Ship = ({ playerId }: { playerId: string }) => {
203
+ const getInput = useGetInput();
204
+
205
+ // This component won't re-render when connection state changes
206
+ useFrame(() => {
207
+ const input = getInput(playerId);
208
+ if (!input) return;
209
+
210
+ // Update ship position
211
+ shipRef.current.position.x += input.vector.x * SPEED;
212
+ shipRef.current.position.y += input.vector.y * SPEED;
213
+ });
214
+
215
+ return <mesh ref={shipRef}>...</mesh>;
216
+ };
217
+ ```
218
+
219
+ **When to use `useGetInput` vs `useAirJamHost().getInput`:**
220
+
221
+
222
+ <HooksComparisonTable />
223
+
224
+ ---
225
+
226
+ ### `useSendSignal`
227
+
228
+ Lightweight hook for sending signals without triggering re-renders. Use in collision handlers.
229
+
230
+ ```tsx
231
+ import { useSendSignal } from "@air-jam/sdk";
232
+
233
+ const Laser = ({ ownerId }: { ownerId: string }) => {
234
+ const sendSignal = useSendSignal();
235
+
236
+ const handleHit = (targetId: string) => {
237
+ // Vibrate the player who got hit
238
+ sendSignal("HAPTIC", { pattern: "heavy" }, targetId);
239
+
240
+ // Light feedback for the shooter
241
+ sendSignal("HAPTIC", { pattern: "light" }, ownerId);
242
+ };
243
+
244
+ // Collision detection...
245
+ };
246
+ ```
247
+
248
+ ---
249
+
250
+ ## Controller Hooks
251
+
252
+ ### `useAirJamController`
253
+
254
+ Consumer hook for controller runtime state and actions. Mount `airjam.Controller` once at the boundary, then call `useAirJamController()` below it.
255
+
256
+ Call `useAirJamController(selector)` when a component only needs a narrow slice
257
+ of controller session state and should not rerender on unrelated runtime
258
+ updates.
259
+ Selectors receive state fields only; call `useAirJamController()` when a
260
+ component also needs controls such as `sendSystemCommand`.
261
+
262
+ Standalone controller runtimes also keep one stable local device identity and
263
+ automatically attempt same-device resume when reconnecting to the same room.
264
+
265
+ ```tsx
266
+ import {
267
+ useAirJamController,
268
+ useControllerTick,
269
+ useInputWriter,
270
+ } from "@air-jam/sdk";
271
+ import { useRef } from "react";
272
+ import { airjam } from "../airjam.config";
273
+
274
+ const ControllerShell = () => (
275
+ <airjam.Controller
276
+ roomId="ABCD"
277
+ nickname="Player1"
278
+ onState={(state) => {
279
+ if (state.message) {
280
+ showNotification(state.message);
281
+ }
282
+ }}
283
+ >
284
+ <ControllerView />
285
+ </airjam.Controller>
286
+ );
287
+
288
+ const ControllerView = () => {
289
+ const controller = useAirJamController();
290
+ const writeInput = useInputWriter();
291
+ const vectorRef = useRef({ x: 0, y: 0 });
292
+ const actionRef = useRef(false);
293
+
294
+ const {
295
+ roomId, // Room code (from URL or props)
296
+ controllerId, // This controller's unique ID
297
+ connectionStatus, // Connection state
298
+ runtimeState, // "playing" | "paused"
299
+ controllerOrientation, // "portrait" | "landscape"
300
+ stateMessage, // Optional message from host
301
+
302
+ // Functions
303
+ sendSystemCommand, // "exit" | "pause" | "resume"
304
+ setNickname, // Update nickname
305
+ setAvatarId, // Update avatar selection draft
306
+ updatePlayerProfile, // Patch live label/avatar when connected
307
+ selfPlayer, // This controller's player profile when known
308
+ reconnect, // Force reconnection
309
+ } = controller;
310
+
311
+ // Canonical cadence for continuous controls:
312
+ // publish at a fixed tick with useControllerTick + useInputWriter.
313
+ useControllerTick(
314
+ () => {
315
+ writeInput({
316
+ vector: vectorRef.current,
317
+ action: actionRef.current,
318
+ timestamp: Date.now(),
319
+ });
320
+ },
321
+ {
322
+ enabled: connectionStatus === "connected" && runtimeState === "playing",
323
+ intervalMs: 16,
324
+ },
325
+ );
326
+
327
+ if (connectionStatus === "connecting") {
328
+ return <div>Connecting to room {roomId}...</div>;
329
+ }
330
+
331
+ if (connectionStatus === "disconnected") {
332
+ return (
333
+ <div>
334
+ Disconnected. <button onClick={reconnect}>Retry</button>
335
+ </div>
336
+ );
337
+ }
338
+
339
+ return (
340
+ <div className="flex h-dvh flex-col bg-zinc-950 p-4 text-white">
341
+ <div className="mb-2 text-xs uppercase">Room {roomId}</div>
342
+ <div className="mb-2 text-xs uppercase">
343
+ Layout {controllerOrientation}
344
+ </div>
345
+ <Joystick
346
+ onMove={(x, y) => {
347
+ vectorRef.current = { x, y };
348
+ }}
349
+ />
350
+ <FireButton
351
+ onPress={() => (actionRef.current = true)}
352
+ onRelease={() => (actionRef.current = false)}
353
+ />
354
+ </div>
355
+ );
356
+ };
357
+ ```
358
+
359
+ ### `useControllerTick`
360
+
361
+ Fixed-cadence helper for controller loops. Use it with `useInputWriter` instead of hand-rolled `setInterval` loops.
362
+
363
+ ### `useHostTick`
364
+
365
+ Canonical host loop helper. Pass a named options object with `onTick` plus
366
+ the loop mode/options.
367
+
368
+ - `mode: "raf"` (default) for render-aligned loops.
369
+ - `mode: "interval"` for fixed-cadence polling loops.
370
+ - `mode: "fixed"` for deterministic fixed-step simulation loops.
371
+
372
+ In fixed mode, pass `onFrame` when rendering should happen every animation
373
+ frame while simulation still advances at the fixed cadence. The frame info
374
+ includes `fixedStepAlpha`, which games can use to interpolate between previous
375
+ and current simulation state.
376
+
377
+ ```tsx
378
+ useHostTick({
379
+ mode: "fixed",
380
+ intervalMs: 16,
381
+ onTick: ({ deltaSeconds }) => {
382
+ stepSimulation(deltaSeconds);
383
+ },
384
+ onFrame: ({ fixedStepAlpha }) => {
385
+ renderInterpolatedFrame(fixedStepAlpha);
386
+ },
387
+ });
388
+ ```
389
+
390
+ **Auto Room Join from URL:**
391
+
392
+ Controllers automatically join rooms from URL query parameters:
393
+
394
+ ```
395
+ https://yourgame.com/controller?room=ABCD
396
+ ```
397
+
398
+ This is how QR code scanning works—the host generates a URL with the room code embedded.
399
+
400
+ ---
401
+
402
+ ## Advanced (Non-default)
403
+
404
+ Use these only when integrating platform-specific runtime behavior.
405
+
406
+ ### Raw socket access (escape hatch)
407
+
408
+ ```tsx
409
+ const host = useAirJamHost();
410
+ host.socket.emit("custom:event", { value: 1 });
411
+ ```
412
+
413
+ ### Internal context hooks
414
+
415
+ `useAirJamContext`, `useAirJamConfig`, `useAirJamState`, and `useAirJamSocket` are intentionally internal and are not part of the root public SDK surface.
416
+
417
+ ---
418
+
419
+ ## Diagnostics
420
+
421
+ Air Jam emits structured diagnostics for common misuse paths in development builds.
422
+
423
+ ```tsx
424
+ import { onAirJamDiagnostic, setAirJamDiagnosticsEnabled } from "@air-jam/sdk";
425
+
426
+ setAirJamDiagnosticsEnabled(true);
427
+
428
+ const unsubscribe = onAirJamDiagnostic((diagnostic) => {
429
+ console.log(diagnostic.code, diagnostic.message, diagnostic.details);
430
+ });
431
+ ```
432
+
433
+ ### Diagnostics Reference
434
+
435
+ | Code | Meaning | Expected Fix |
436
+ | ------------------------------------------ | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
437
+ | `AJ_SCOPE_MISMATCH` | A host/controller hook was used in the wrong scoped provider tree. | Use the correct scoped wrapper (`airjam.Host` / `airjam.Controller`) or the matching session provider. |
438
+ | `AJ_MISSING_SESSION_PROVIDER` | SDK context was read outside Air Jam session providers. | Wrap the route/root with `airjam.Host`, `airjam.Controller`, or the matching low-level session provider. |
439
+ | `AJ_CONFIG_MISSING_RUNTIME_TOPOLOGY` | Runtime config cannot resolve the complete topology contract. | Provide `topology` directly or enable environment resolution for a supported runtime mode. |
440
+ | `AJ_CONFIG_MISSING_APP_ID` | Production runtime started without canonical app ID config. | Set `VITE_AIR_JAM_APP_ID` / `NEXT_PUBLIC_AIR_JAM_APP_ID` or pass `appId` explicitly. |
441
+ | `AJ_STORE_ACTION_SESSION_NOT_READY` | Controller action dispatch attempted before role/room was ready. | Wait until room/session is established before dispatching store actions. |
442
+ | `AJ_STORE_ACTION_SOCKET_DISCONNECTED` | Controller state action dispatch attempted while socket disconnected. | Reconnect before dispatching action. |
443
+ | `AJ_STORE_ACTION_PAYLOAD_INVALID_SHAPE` | State action payload root was not omitted or a plain object. | Dispatch no payload or one plain object payload only. |
444
+ | `AJ_STORE_ACTION_PAYLOAD_NOT_SERIALIZABLE` | State action payload contained non-serializable values. | Use JSON-safe payload objects only (no functions/symbols/cycles). |
445
+ | `AJ_INPUT_WRITER_INVALID_SHAPE` | `useInputWriter` payload was not an object. | Send plain object payloads only. |
446
+ | `AJ_INPUT_WRITER_NOT_SERIALIZABLE` | Input payload contained non-serializable values. | Keep input payload JSON-safe. |
447
+ | `AJ_INPUT_WRITER_SESSION_NOT_READY` | Input writer called before room/controller identity was ready. | Start publish loop after controller connection/session is ready. |
448
+ | `AJ_INPUT_WRITER_SOCKET_DISCONNECTED` | Input writer called while controller socket was disconnected. | Reconnect before sending input. |
449
+ | `AJ_INPUT_WRITER_SCHEMA_INVALID` | Input payload failed runtime schema validation. | Match payload shape to configured input schema. |
450
+
451
+ ---
452
+
453
+ ## Types
454
+
455
+ ### `PlayerProfile`
456
+
457
+ ```typescript
458
+ interface PlayerProfile {
459
+ id: string; // Unique controller ID
460
+ label: string; // Display name (e.g., "Player 1")
461
+ color?: string; // Assigned color (e.g., "#FF5733")
462
+ avatarId?: string; // Preset avatar id chosen by the player
463
+ }
464
+ ```
465
+
466
+ ### `ConnectionStatus`
467
+
468
+ ```typescript
469
+ type ConnectionStatus =
470
+ | "idle" // Not yet connected
471
+ | "connecting" // Connection in progress
472
+ | "connected" // Successfully connected
473
+ | "disconnected" // Connection lost
474
+ | "reconnecting"; // Attempting to reconnect
475
+ ```
476
+
477
+ ### `RuntimeState`
478
+
479
+ ```typescript
480
+ type RuntimeState = "playing" | "paused";
481
+ ```
482
+
483
+ ### `HapticSignalPayload`
484
+
485
+ ```typescript
486
+ interface HapticSignalPayload {
487
+ pattern: "light" | "medium" | "heavy" | "success" | "failure" | "custom";
488
+ sequence?: number | number[]; // For "custom" pattern
489
+ }
490
+ ```
491
+
492
+ ### `ToastSignalPayload`
493
+
494
+ ```typescript
495
+ interface ToastSignalPayload {
496
+ message: string;
497
+ color?: string; // Optional accent color (e.g., "#22c55e")
498
+ duration?: number; // Optional duration in ms
499
+ }
500
+ ```