@air-jam/sdk 0.9.1 → 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 (247) hide show
  1. package/README.md +25 -45
  2. package/dist/{agent-tooling-BSMGBix9.d.cts → agent-contract-CD2QnbBJ.d.cts} +1 -1
  3. package/dist/{agent-tooling-BSMGBix9.d.ts → agent-contract-CD2QnbBJ.d.ts} +1 -1
  4. package/dist/agent-tooling.cjs +139 -0
  5. package/dist/agent-tooling.cjs.map +1 -1
  6. package/dist/agent-tooling.d.cts +25 -1
  7. package/dist/agent-tooling.d.ts +25 -1
  8. package/dist/agent-tooling.js +138 -0
  9. package/dist/agent-tooling.js.map +1 -1
  10. package/dist/air-jam-context-BlLPvCup.d.cts +175 -0
  11. package/dist/air-jam-context-DTsxF-tP.d.ts +175 -0
  12. package/dist/arcade/bridge/controller.cjs +214 -194
  13. package/dist/arcade/bridge/controller.cjs.map +1 -1
  14. package/dist/arcade/bridge/controller.d.cts +2 -2
  15. package/dist/arcade/bridge/controller.d.ts +2 -2
  16. package/dist/arcade/bridge/controller.js +6 -4
  17. package/dist/arcade/bridge/host.cjs +1 -1
  18. package/dist/arcade/bridge/host.cjs.map +1 -1
  19. package/dist/arcade/bridge/host.d.cts +3 -3
  20. package/dist/arcade/bridge/host.d.ts +3 -3
  21. package/dist/arcade/bridge/host.js +4 -3
  22. package/dist/arcade/bridge/iframe.cjs +1 -1
  23. package/dist/arcade/bridge/iframe.cjs.map +1 -1
  24. package/dist/arcade/bridge/iframe.d.cts +2 -2
  25. package/dist/arcade/bridge/iframe.d.ts +2 -2
  26. package/dist/arcade/bridge/iframe.js +4 -4
  27. package/dist/arcade/bridge.cjs +251 -231
  28. package/dist/arcade/bridge.cjs.map +1 -1
  29. package/dist/arcade/bridge.d.cts +4 -4
  30. package/dist/arcade/bridge.d.ts +4 -4
  31. package/dist/arcade/bridge.js +9 -7
  32. package/dist/arcade/host.cjs +145 -122
  33. package/dist/arcade/host.cjs.map +1 -1
  34. package/dist/arcade/host.d.cts +5 -4
  35. package/dist/arcade/host.d.ts +5 -4
  36. package/dist/arcade/host.js +6 -5
  37. package/dist/arcade/runtime.cjs +6499 -0
  38. package/dist/arcade/runtime.cjs.map +1 -0
  39. package/dist/arcade/runtime.d.cts +22 -0
  40. package/dist/arcade/runtime.d.ts +22 -0
  41. package/dist/arcade/runtime.js +32 -0
  42. package/dist/arcade/runtime.js.map +1 -0
  43. package/dist/arcade/surface.cjs +9 -0
  44. package/dist/arcade/surface.cjs.map +1 -1
  45. package/dist/arcade/surface.d.cts +6 -1
  46. package/dist/arcade/surface.d.ts +6 -1
  47. package/dist/arcade/surface.js +6 -2
  48. package/dist/arcade/url.d.cts +4 -4
  49. package/dist/arcade/url.d.ts +4 -4
  50. package/dist/arcade/url.js +5 -5
  51. package/dist/arcade.cjs +322 -292
  52. package/dist/arcade.cjs.map +1 -1
  53. package/dist/arcade.d.cts +6 -6
  54. package/dist/arcade.d.ts +6 -6
  55. package/dist/arcade.js +35 -29
  56. package/dist/{chunk-CEJ5RFSG.js → chunk-2SZ2YYGJ.js} +8 -16
  57. package/dist/chunk-2SZ2YYGJ.js.map +1 -0
  58. package/dist/{chunk-VKBMZHMQ.js → chunk-32RSSFSF.js} +10 -12
  59. package/dist/chunk-32RSSFSF.js.map +1 -0
  60. package/dist/chunk-3YMUAKPU.js +10 -0
  61. package/dist/chunk-3YMUAKPU.js.map +1 -0
  62. package/dist/chunk-56DM2KEW.js +14 -0
  63. package/dist/chunk-56DM2KEW.js.map +1 -0
  64. package/dist/chunk-CM53YLT5.js +59 -0
  65. package/dist/chunk-CM53YLT5.js.map +1 -0
  66. package/dist/{chunk-JEHV5C2X.js → chunk-CV3PBXPT.js} +3 -3
  67. package/dist/chunk-D4VDEVTZ.js +80 -0
  68. package/dist/chunk-D4VDEVTZ.js.map +1 -0
  69. package/dist/{chunk-W3YA5BWR.js → chunk-FUA6EMSJ.js} +24 -60
  70. package/dist/chunk-FUA6EMSJ.js.map +1 -0
  71. package/dist/chunk-GMLU7RI5.js +70 -0
  72. package/dist/chunk-GMLU7RI5.js.map +1 -0
  73. package/dist/{chunk-NCL6WJCL.js → chunk-IG6GZZSS.js} +32 -1
  74. package/dist/chunk-IG6GZZSS.js.map +1 -0
  75. package/dist/{chunk-EDRQIOCV.js → chunk-ITMQSBTH.js} +3 -2
  76. package/dist/chunk-ITMQSBTH.js.map +1 -0
  77. package/dist/{chunk-32NYL7XI.js → chunk-J5MCII33.js} +189 -108
  78. package/dist/chunk-J5MCII33.js.map +1 -0
  79. package/dist/{chunk-ZLPL2R3R.js → chunk-K4OZ54UD.js} +7 -34
  80. package/dist/chunk-K4OZ54UD.js.map +1 -0
  81. package/dist/{chunk-KXAFI5OP.js → chunk-LIHEEAVE.js} +9 -11
  82. package/dist/chunk-LIHEEAVE.js.map +1 -0
  83. package/dist/{chunk-FAT2KJ3K.js → chunk-MIMPMB7O.js} +2 -2
  84. package/dist/{chunk-NUJBMV3O.js → chunk-O6X7FJ6N.js} +29 -32
  85. package/dist/chunk-O6X7FJ6N.js.map +1 -0
  86. package/dist/chunk-PSUYTD2L.js +16 -0
  87. package/dist/chunk-PSUYTD2L.js.map +1 -0
  88. package/dist/{chunk-7UXSWCZZ.js → chunk-QO4KFUEI.js} +2 -2
  89. package/dist/chunk-QTLYZADF.js +125 -0
  90. package/dist/chunk-QTLYZADF.js.map +1 -0
  91. package/dist/chunk-TTQDHKXL.js +3017 -0
  92. package/dist/chunk-TTQDHKXL.js.map +1 -0
  93. package/dist/chunk-UCPY7UJC.js +8 -0
  94. package/dist/chunk-UCPY7UJC.js.map +1 -0
  95. package/dist/{chunk-JO2HR5PV.js → chunk-UPV6YWT5.js} +4 -4
  96. package/dist/chunk-X35LLCWV.js +65 -0
  97. package/dist/chunk-X35LLCWV.js.map +1 -0
  98. package/dist/{controller-DxVchfiA.d.ts → controller-PZEM_1cH.d.ts} +6 -2
  99. package/dist/{controller-Bod8YYr1.d.cts → controller-vj82tKm4.d.cts} +6 -2
  100. package/dist/{dev-log-events-CVAM29hx.d.cts → dev-log-events-BCJKmygo.d.cts} +0 -3
  101. package/dist/{dev-log-events-CVAM29hx.d.ts → dev-log-events-BCJKmygo.d.ts} +0 -3
  102. package/dist/{host-8hmq_Sgc.d.cts → host-B9pRy0Aa.d.cts} +20 -7
  103. package/dist/{host-Cw-N6e-5.d.ts → host-DylGsX7p.d.ts} +20 -7
  104. package/dist/index.cjs +4275 -3813
  105. package/dist/index.cjs.map +1 -1
  106. package/dist/index.d.cts +40 -642
  107. package/dist/index.d.ts +40 -642
  108. package/dist/index.js +1032 -3658
  109. package/dist/index.js.map +1 -1
  110. package/dist/metadata.cjs.map +1 -1
  111. package/dist/metadata.d.cts +2 -3
  112. package/dist/metadata.d.ts +2 -3
  113. package/dist/metadata.js.map +1 -1
  114. package/dist/{notices-CnGaaS8B.d.ts → notices-C4bao3oi.d.ts} +1 -1
  115. package/dist/{notices-NyDM5Mtz.d.cts → notices-DNdOjwtj.d.cts} +1 -1
  116. package/dist/platform-machine.cjs +115 -15
  117. package/dist/platform-machine.cjs.map +1 -1
  118. package/dist/platform-machine.d.cts +1338 -65
  119. package/dist/platform-machine.d.ts +1338 -65
  120. package/dist/platform-machine.js +88 -15
  121. package/dist/platform-machine.js.map +1 -1
  122. package/dist/{platform-settings-cuor3i11.d.cts → platform-settings-DUWs4JTy.d.cts} +1 -1
  123. package/dist/{platform-settings-cuor3i11.d.ts → platform-settings-DUWs4JTy.d.ts} +1 -1
  124. package/dist/preview.cjs +301 -253
  125. package/dist/preview.cjs.map +1 -1
  126. package/dist/preview.d.cts +6 -4
  127. package/dist/preview.d.ts +6 -4
  128. package/dist/preview.js +31 -21
  129. package/dist/preview.js.map +1 -1
  130. package/dist/protocol.cjs +282 -167
  131. package/dist/protocol.cjs.map +1 -1
  132. package/dist/protocol.d.cts +74 -21
  133. package/dist/protocol.d.ts +74 -21
  134. package/dist/protocol.js +28 -10
  135. package/dist/release.cjs +37 -0
  136. package/dist/release.cjs.map +1 -1
  137. package/dist/release.d.cts +27 -1
  138. package/dist/release.d.ts +27 -1
  139. package/dist/release.js +13 -1
  140. package/dist/runtime-control.cjs +46 -0
  141. package/dist/runtime-control.cjs.map +1 -0
  142. package/dist/runtime-control.d.cts +17 -0
  143. package/dist/runtime-control.d.ts +17 -0
  144. package/dist/runtime-control.js +8 -0
  145. package/dist/runtime-control.js.map +1 -0
  146. package/dist/runtime-inspection.cjs +655 -0
  147. package/dist/runtime-inspection.cjs.map +1 -0
  148. package/dist/runtime-inspection.d.cts +47 -0
  149. package/dist/runtime-inspection.d.ts +47 -0
  150. package/dist/runtime-inspection.js +30 -0
  151. package/dist/runtime-inspection.js.map +1 -0
  152. package/dist/runtime-reporting-pe-eryVz.d.cts +27 -0
  153. package/dist/runtime-reporting-pe-eryVz.d.ts +27 -0
  154. package/dist/signals-ZHftIKuc.d.cts +33 -0
  155. package/dist/signals-ZHftIKuc.d.ts +33 -0
  156. package/dist/{standard-match-phase-BucA5dYo.d.ts → standard-match-phase-BzSgBYFg.d.ts} +2 -2
  157. package/dist/{standard-match-phase-U2ra8J-0.d.cts → standard-match-phase-CvJUW8Oe.d.cts} +2 -2
  158. package/dist/{sync-B6QsNrXz.d.cts → sync-xtPfWhif.d.cts} +1 -45
  159. package/dist/{sync-B6QsNrXz.d.ts → sync-xtPfWhif.d.ts} +1 -45
  160. package/dist/ui.cjs +689 -629
  161. package/dist/ui.cjs.map +1 -1
  162. package/dist/ui.d.cts +14 -4
  163. package/dist/ui.d.ts +14 -4
  164. package/dist/ui.js +117 -35
  165. package/dist/ui.js.map +1 -1
  166. package/dist/use-air-jam-host-COLy8t4s.d.ts +403 -0
  167. package/dist/use-air-jam-host-DM-ybB3C.d.cts +403 -0
  168. package/package.json +55 -21
  169. package/src/agent/agent-contract-conformance.ts +201 -0
  170. package/src/agent-tooling.ts +5 -0
  171. package/src/arcade/runtime.ts +6 -0
  172. package/src/arcade/surface.ts +1 -0
  173. package/src/components/join-qr-overlay.tsx +115 -31
  174. package/src/context/air-jam-context.tsx +8 -8
  175. package/src/context/socket-manager.ts +0 -7
  176. package/src/dev/browser-log-sink.ts +12 -15
  177. package/src/events.ts +0 -5
  178. package/src/hooks/internal/use-controller-runtime-api.ts +110 -21
  179. package/src/hooks/internal/use-host-runtime-api.ts +306 -49
  180. package/src/hooks/use-air-jam-controller.ts +9 -9
  181. package/src/hooks/use-air-jam-host.ts +7 -7
  182. package/src/hooks/use-get-input.ts +1 -1
  183. package/src/hooks/use-host-arcade-restore.ts +6 -1
  184. package/src/hooks/use-host-audio-mute-preference.ts +99 -0
  185. package/src/index.ts +6 -21
  186. package/src/metadata/manifest.ts +2 -3
  187. package/src/platform-machine.ts +109 -12
  188. package/src/preview/workspace.tsx +48 -29
  189. package/src/protocol/arcade-platform-actions.ts +19 -1
  190. package/src/protocol/controller.ts +8 -2
  191. package/src/protocol/dev-log-events.ts +0 -3
  192. package/src/protocol/host-grant.ts +58 -140
  193. package/src/protocol/host.ts +21 -9
  194. package/src/protocol/runtime-reporting.ts +32 -0
  195. package/src/protocol/signed-envelope.ts +176 -0
  196. package/src/protocol/socket-events.ts +8 -10
  197. package/src/protocol/sync.ts +0 -16
  198. package/src/protocol.ts +2 -0
  199. package/src/release.ts +32 -0
  200. package/src/runtime/admission-retry.ts +62 -0
  201. package/src/runtime/air-jam-config.ts +6 -16
  202. package/src/runtime/air-jam-error-boundary.tsx +46 -2
  203. package/src/runtime/bridge-envelope-args.ts +21 -0
  204. package/src/runtime/connected-runtime-error-boundary.tsx +31 -0
  205. package/src/runtime/contracts/control.ts +107 -59
  206. package/src/runtime/controller-bridge.ts +12 -24
  207. package/src/runtime/controller-identity.ts +55 -27
  208. package/src/runtime/controller-realtime-client.ts +8 -47
  209. package/src/runtime/create-air-jam-app.tsx +21 -13
  210. package/src/runtime/host-bridge.ts +16 -24
  211. package/src/runtime/local-reference-game-identity.ts +13 -0
  212. package/src/runtime/runtime-session-params.ts +4 -64
  213. package/src/runtime-control.ts +3 -8
  214. package/src/settings/platform-settings-runtime.tsx +1 -6
  215. package/src/settings/platform-settings.ts +7 -38
  216. package/src/state/connection-store.ts +13 -6
  217. package/src/store/create-air-jam-store.ts +59 -7
  218. package/src/utils/ids.ts +32 -5
  219. package/dist/capabilities.cjs +0 -39
  220. package/dist/capabilities.cjs.map +0 -1
  221. package/dist/capabilities.d.cts +0 -31
  222. package/dist/capabilities.d.ts +0 -31
  223. package/dist/capabilities.js +0 -12
  224. package/dist/capabilities.js.map +0 -1
  225. package/dist/chunk-32NYL7XI.js.map +0 -1
  226. package/dist/chunk-CABEUV65.js +0 -184
  227. package/dist/chunk-CABEUV65.js.map +0 -1
  228. package/dist/chunk-CEJ5RFSG.js.map +0 -1
  229. package/dist/chunk-EDRQIOCV.js.map +0 -1
  230. package/dist/chunk-KXAFI5OP.js.map +0 -1
  231. package/dist/chunk-NCL6WJCL.js.map +0 -1
  232. package/dist/chunk-NUJBMV3O.js.map +0 -1
  233. package/dist/chunk-VKBMZHMQ.js.map +0 -1
  234. package/dist/chunk-W3YA5BWR.js.map +0 -1
  235. package/dist/chunk-ZLPL2R3R.js.map +0 -1
  236. package/dist/chunk-ZTQ5SP4H.js +0 -9
  237. package/dist/chunk-ZTQ5SP4H.js.map +0 -1
  238. package/src/capabilities/manifest.ts +0 -71
  239. package/src/capabilities.ts +0 -12
  240. package/src/hooks/internal/use-runtime-control-contract.ts +0 -15
  241. package/src/hooks/internal/use-runtime-observability-contract.ts +0 -24
  242. package/src/runtime/contracts/observability.ts +0 -94
  243. package/src/runtime-observability.ts +0 -9
  244. /package/dist/{chunk-JEHV5C2X.js.map → chunk-CV3PBXPT.js.map} +0 -0
  245. /package/dist/{chunk-FAT2KJ3K.js.map → chunk-MIMPMB7O.js.map} +0 -0
  246. /package/dist/{chunk-7UXSWCZZ.js.map → chunk-QO4KFUEI.js.map} +0 -0
  247. /package/dist/{chunk-JO2HR5PV.js.map → chunk-UPV6YWT5.js.map} +0 -0
@@ -2,11 +2,15 @@ import { useStore } from "zustand";
2
2
  import { useShallow } from "zustand/react/shallow";
3
3
  import { useAirJamContext } from "../context/air-jam-context";
4
4
  import { useAssertSessionScope } from "../context/session-scope";
5
- import type { HostArcadeSessionSnapshot } from "../protocol";
5
+ import type {
6
+ HostArcadeSessionSnapshot,
7
+ HostArcadeSurfaceCheckpoint,
8
+ } from "../protocol";
6
9
 
7
10
  export interface HostArcadeRestoreStateView {
8
11
  phase: "idle" | "awaiting_ack" | "pending_restore";
9
12
  session: HostArcadeSessionSnapshot | null;
13
+ surfaceCheckpoint: HostArcadeSurfaceCheckpoint | null;
10
14
  clear: () => void;
11
15
  }
12
16
 
@@ -24,6 +28,7 @@ export const useHostArcadeRestore = (): HostArcadeRestoreStateView => {
24
28
  useShallow((s) => ({
25
29
  phase: s.hostArcadeRestore.phase,
26
30
  session: s.hostArcadeRestore.session,
31
+ surfaceCheckpoint: s.hostArcadeRestore.surfaceCheckpoint,
27
32
  clear: s.clearHostArcadeRestore,
28
33
  })),
29
34
  );
@@ -0,0 +1,99 @@
1
+ import { useCallback, useEffect, useMemo, useState } from "react";
2
+
3
+ const HOST_AUDIO_MUTE_STORAGE_KEY_PREFIX = "air-jam-host-audio-muted:";
4
+
5
+ const getHostAudioMuteStorageKey = (scope: string): string =>
6
+ `${HOST_AUDIO_MUTE_STORAGE_KEY_PREFIX}${scope}`;
7
+
8
+ const readHostAudioMutePreference = (
9
+ storageKey: string,
10
+ fallback: boolean,
11
+ ): boolean => {
12
+ if (typeof window === "undefined") {
13
+ return fallback;
14
+ }
15
+
16
+ const raw = window.localStorage.getItem(storageKey);
17
+ if (raw === "true") {
18
+ return true;
19
+ }
20
+ if (raw === "false") {
21
+ return false;
22
+ }
23
+ return fallback;
24
+ };
25
+
26
+ const persistHostAudioMutePreference = (
27
+ storageKey: string,
28
+ muted: boolean,
29
+ ): void => {
30
+ if (typeof window === "undefined") {
31
+ return;
32
+ }
33
+
34
+ window.localStorage.setItem(storageKey, muted ? "true" : "false");
35
+ };
36
+
37
+ export interface HostAudioMutePreference {
38
+ muted: boolean;
39
+ setMuted: (muted: boolean) => void;
40
+ toggleMuted: () => void;
41
+ }
42
+
43
+ export const useHostAudioMutePreference = (
44
+ scope: string,
45
+ defaultMuted = false,
46
+ ): HostAudioMutePreference => {
47
+ const storageKey = useMemo(() => getHostAudioMuteStorageKey(scope), [scope]);
48
+ const [muted, setMutedState] = useState<boolean>(() =>
49
+ readHostAudioMutePreference(storageKey, defaultMuted),
50
+ );
51
+
52
+ useEffect(() => {
53
+ setMutedState(readHostAudioMutePreference(storageKey, defaultMuted));
54
+ }, [defaultMuted, storageKey]);
55
+
56
+ useEffect(() => {
57
+ if (typeof window === "undefined") {
58
+ return;
59
+ }
60
+
61
+ const handleStorage = (event: StorageEvent) => {
62
+ if (event.storageArea !== window.localStorage) {
63
+ return;
64
+ }
65
+ if (event.key !== storageKey) {
66
+ return;
67
+ }
68
+
69
+ setMutedState(readHostAudioMutePreference(storageKey, defaultMuted));
70
+ };
71
+
72
+ window.addEventListener("storage", handleStorage);
73
+ return () => {
74
+ window.removeEventListener("storage", handleStorage);
75
+ };
76
+ }, [defaultMuted, storageKey]);
77
+
78
+ const setMuted = useCallback(
79
+ (nextMuted: boolean) => {
80
+ setMutedState(nextMuted);
81
+ persistHostAudioMutePreference(storageKey, nextMuted);
82
+ },
83
+ [storageKey],
84
+ );
85
+
86
+ const toggleMuted = useCallback(() => {
87
+ setMutedState((current) => {
88
+ const nextMuted = !current;
89
+ persistHostAudioMutePreference(storageKey, nextMuted);
90
+ return nextMuted;
91
+ });
92
+ }, [storageKey]);
93
+
94
+ return {
95
+ muted,
96
+ setMuted,
97
+ toggleMuted,
98
+ };
99
+ };
package/src/index.ts CHANGED
@@ -22,18 +22,18 @@ export {
22
22
  type MusicPlaylistProps,
23
23
  } from "./audio/music";
24
24
  export {
25
- DEFAULT_ROOM_PLATFORM_SETTINGS,
26
25
  DEFAULT_PLATFORM_SETTINGS,
26
+ DEFAULT_ROOM_PLATFORM_SETTINGS,
27
27
  getEffectiveAudioVolume,
28
28
  mergeRoomPlatformSettingsSnapshot,
29
29
  toRoomPlatformSettingsSnapshot,
30
30
  } from "./settings/platform-settings";
31
31
  export type {
32
+ PartialRoomPlatformSettingsPatch,
32
33
  PlatformAccessibilitySettings,
33
34
  PlatformAudioSettings,
34
35
  PlatformFeedbackSettings,
35
36
  PlatformPreviewControllerSettings,
36
- PartialRoomPlatformSettingsPatch,
37
37
  PlatformSettings,
38
38
  PlatformSettingsPersistence,
39
39
  PlatformSettingsSnapshot,
@@ -84,6 +84,10 @@ export {
84
84
  type UseControllerToastsOptions,
85
85
  } from "./hooks/use-controller-toasts";
86
86
  export { useGetInput } from "./hooks/use-get-input";
87
+ export {
88
+ useHostAudioMutePreference,
89
+ type HostAudioMutePreference,
90
+ } from "./hooks/use-host-audio-mute-preference";
87
91
  export {
88
92
  useHostTick,
89
93
  type HostFrameInfo,
@@ -94,25 +98,6 @@ export { useInputWriter } from "./hooks/use-input-writer";
94
98
  export { usePlayers } from "./hooks/use-players";
95
99
  export { useRoom, type RoomState } from "./hooks/use-room";
96
100
  export { useSendSignal, type SendSignalFn } from "./hooks/use-send-signal";
97
- export {
98
- AIR_JAM_RUNTIME_INSPECTION_KEY,
99
- createControllerRuntimeInspectionContract,
100
- createHostRuntimeInspectionContract,
101
- publishRuntimeInspectionContract,
102
- readRuntimeInspectionContract,
103
- useControllerRuntimeInspectionContract,
104
- useHostRuntimeInspectionContract,
105
- type ControllerRuntimeInspectionContract,
106
- type HostRuntimeInspectionContract,
107
- type RuntimeInspectionContract,
108
- } from "./runtime-inspection";
109
- export {
110
- AirJamControllerRuntime,
111
- AirJamHostRuntime,
112
- type AirJamControllerRuntimeProps,
113
- type AirJamHostRuntimeProps,
114
- } from "./runtime/session-runtimes";
115
-
116
101
  export {
117
102
  isActiveMatchPhase,
118
103
  isEndedMatchPhase,
@@ -11,9 +11,8 @@ import { z } from "zod";
11
11
  * consumers can keep assuming the shape is stable. External creators should be
12
12
  * able to target this contract before the first third-party catalog submission.
13
13
  *
14
- * This contract is distinct from `@air-jam/sdk/capabilities` — capabilities
15
- * describe what a game exposes at runtime (actions, state, evaluation seams);
16
- * metadata describes what the catalog needs to present the game.
14
+ * Runtime behavior belongs to the semantic agent contract; metadata describes
15
+ * only what the catalog needs to present the game.
17
16
  */
18
17
 
19
18
  /** Broad taxonomy for catalog filtering and landing-page grouping. */
@@ -4,6 +4,9 @@ import {
4
4
  gameReleaseStatusSchema,
5
5
  releaseCheckKindSchema,
6
6
  releaseCheckStatusSchema,
7
+ releaseGenerationStatusSchema,
8
+ releaseJobKindSchema,
9
+ releaseJobStatusSchema,
7
10
  releaseReportSourceSchema,
8
11
  releaseReportStatusSchema,
9
12
  } from "./release";
@@ -33,6 +36,8 @@ export type PlatformMachineErrorCode = z.infer<
33
36
  export const platformMachineApiErrorSchema = z.object({
34
37
  error: platformMachineErrorCodeSchema,
35
38
  message: z.string().min(1),
39
+ retryAfterSeconds: z.number().int().positive().nullable().optional(),
40
+ details: z.record(z.string(), z.unknown()).optional(),
36
41
  });
37
42
 
38
43
  export type PlatformMachineApiError = z.infer<
@@ -225,30 +230,65 @@ export type PlatformMachineRequestOwnedGameMediaUploadTargetInput = z.infer<
225
230
  typeof platformMachineRequestOwnedGameMediaUploadTargetInputSchema
226
231
  >;
227
232
 
228
- export const platformMachineReleaseArtifactSchema = z.object({
233
+ export const platformMachineReleaseStorageRetentionStateValues = [
234
+ "active",
235
+ "warned",
236
+ "reclaimable",
237
+ "deleting",
238
+ "tombstoned",
239
+ ] as const;
240
+
241
+ export const platformMachineReleaseStorageRetentionStateSchema = z.enum(
242
+ platformMachineReleaseStorageRetentionStateValues,
243
+ );
244
+
245
+ export type PlatformMachineReleaseStorageRetentionState = z.infer<
246
+ typeof platformMachineReleaseStorageRetentionStateSchema
247
+ >;
248
+
249
+ export const platformMachineReleaseGenerationSchema = z.object({
229
250
  id: z.string().min(1),
230
251
  releaseId: z.string().min(1),
252
+ sequence: z.number().int().positive(),
253
+ status: releaseGenerationStatusSchema,
231
254
  originalFilename: z.string().min(1),
232
255
  contentType: z.string().min(1),
233
- sizeBytes: z.number().int().nonnegative(),
256
+ declaredSizeBytes: z.number().int().positive(),
257
+ observedSizeBytes: z.number().int().positive().nullable(),
258
+ observedContentType: z.string().min(1).nullable(),
259
+ observedEtag: z.string().min(1).nullable(),
260
+ observedLastModifiedAt: z.string().min(1).nullable(),
234
261
  extractedSizeBytes: z.number().int().nonnegative().nullable(),
235
- fileCount: z.number().int().nonnegative().nullable(),
236
- entryPath: z.string().min(1),
262
+ fileCount: z.number().int().positive().nullable(),
263
+ entryPath: z.string().min(1).nullable(),
237
264
  contentHash: z.string().min(1).nullable(),
238
265
  createdAt: z.string().min(1),
266
+ uploadObservedAt: z.string().min(1).nullable(),
267
+ processingStartedAt: z.string().min(1).nullable(),
268
+ readyAt: z.string().min(1).nullable(),
269
+ failedAt: z.string().min(1).nullable(),
270
+ abandonedAt: z.string().min(1).nullable(),
271
+ storageRetention: z.object({
272
+ state: platformMachineReleaseStorageRetentionStateSchema,
273
+ inactiveAt: z.string().min(1).nullable(),
274
+ warnedAt: z.string().min(1).nullable(),
275
+ eligibleAt: z.string().min(1).nullable(),
276
+ cleanupStartedAt: z.string().min(1).nullable(),
277
+ deletedAt: z.string().min(1).nullable(),
278
+ }),
239
279
  });
240
280
 
241
- export type PlatformMachineReleaseArtifact = z.infer<
242
- typeof platformMachineReleaseArtifactSchema
281
+ export type PlatformMachineReleaseGeneration = z.infer<
282
+ typeof platformMachineReleaseGenerationSchema
243
283
  >;
244
284
 
245
285
  export const platformMachineReleaseCheckSchema = z.object({
246
286
  id: z.string().min(1),
247
287
  releaseId: z.string().min(1),
288
+ generationId: z.string().min(1),
248
289
  kind: releaseCheckKindSchema,
249
290
  status: releaseCheckStatusSchema,
250
291
  summary: z.string().nullable(),
251
- payload: z.record(z.string(), z.unknown()),
252
292
  createdAt: z.string().min(1),
253
293
  });
254
294
 
@@ -256,14 +296,37 @@ export type PlatformMachineReleaseCheck = z.infer<
256
296
  typeof platformMachineReleaseCheckSchema
257
297
  >;
258
298
 
299
+ export const platformMachineReleaseJobSchema = z.object({
300
+ id: z.string().min(1),
301
+ kind: releaseJobKindSchema,
302
+ status: releaseJobStatusSchema,
303
+ releaseId: z.string().min(1),
304
+ generationId: z.string().min(1),
305
+ correlationId: z.string().min(1),
306
+ attemptCount: z.number().int().nonnegative(),
307
+ maxAttempts: z.number().int().positive(),
308
+ progressStage: z.string().min(1).nullable(),
309
+ progressMessage: z.string().min(1).nullable(),
310
+ lastErrorCode: z.string().min(1).nullable(),
311
+ lastErrorRetryable: z.boolean().nullable(),
312
+ availableAt: z.string().min(1),
313
+ deadlineAt: z.string().min(1),
314
+ createdAt: z.string().min(1),
315
+ startedAt: z.string().min(1).nullable(),
316
+ finishedAt: z.string().min(1).nullable(),
317
+ updatedAt: z.string().min(1),
318
+ });
319
+
320
+ export type PlatformMachineReleaseJob = z.infer<
321
+ typeof platformMachineReleaseJobSchema
322
+ >;
323
+
324
+ // Creator-visible status only. Report text and contact stay ops-confidential.
259
325
  export const platformMachineReleaseReportSchema = z.object({
260
326
  id: z.string().min(1),
261
327
  releaseId: z.string().min(1),
262
328
  status: releaseReportStatusSchema,
263
329
  source: releaseReportSourceSchema,
264
- reason: z.string().min(1),
265
- details: z.string().nullable(),
266
- reporterEmail: z.string().nullable(),
267
330
  createdAt: z.string().min(1),
268
331
  reviewedAt: z.string().nullable(),
269
332
  });
@@ -277,6 +340,8 @@ export const platformMachineReleaseSummarySchema = z.object({
277
340
  gameId: z.string().min(1),
278
341
  sourceKind: gameReleaseSourceKindSchema,
279
342
  status: gameReleaseStatusSchema,
343
+ candidateGenerationId: z.string().min(1).nullable(),
344
+ promotedGenerationId: z.string().min(1).nullable(),
280
345
  versionLabel: z.string().nullable(),
281
346
  createdAt: z.string().min(1),
282
347
  uploadedAt: z.string().nullable(),
@@ -285,8 +350,11 @@ export const platformMachineReleaseSummarySchema = z.object({
285
350
  quarantinedAt: z.string().nullable(),
286
351
  archivedAt: z.string().nullable(),
287
352
  game: platformMachineOwnedGameSummarySchema,
288
- artifact: platformMachineReleaseArtifactSchema.nullable(),
353
+ candidateGeneration: platformMachineReleaseGenerationSchema.nullable(),
354
+ promotedGeneration: platformMachineReleaseGenerationSchema.nullable(),
355
+ generations: z.array(platformMachineReleaseGenerationSchema),
289
356
  checks: z.array(platformMachineReleaseCheckSchema),
357
+ jobs: z.array(platformMachineReleaseJobSchema),
290
358
  reports: z.array(platformMachineReleaseReportSchema),
291
359
  hostUrl: z.string().url().nullable(),
292
360
  controllerUrl: z.string().url().nullable(),
@@ -417,7 +485,6 @@ export type PlatformMachineRequestReleaseUploadTargetInput = z.infer<
417
485
  >;
418
486
 
419
487
  export const platformMachineReleaseUploadTargetSchema = z.object({
420
- key: z.string().min(1),
421
488
  method: z.literal("PUT"),
422
489
  url: z.string().url(),
423
490
  headers: z.record(z.string(), z.string()),
@@ -428,8 +495,36 @@ export type PlatformMachineReleaseUploadTarget = z.infer<
428
495
  typeof platformMachineReleaseUploadTargetSchema
429
496
  >;
430
497
 
498
+ export const platformMachineReleaseDownloadTargetSchema = z.object({
499
+ method: z.literal("GET"),
500
+ url: z.string().url(),
501
+ filename: z
502
+ .string()
503
+ .trim()
504
+ .min(1)
505
+ .max(255)
506
+ .regex(/^[^/\\\r\n]+$/u)
507
+ .refine((value) => value !== "." && value !== ".."),
508
+ expiresAt: z.string().min(1),
509
+ });
510
+
511
+ export type PlatformMachineReleaseDownloadTarget = z.infer<
512
+ typeof platformMachineReleaseDownloadTargetSchema
513
+ >;
514
+
515
+ export const platformMachineRequestReleaseGenerationExportResultSchema =
516
+ z.object({
517
+ generation: platformMachineReleaseGenerationSchema,
518
+ download: platformMachineReleaseDownloadTargetSchema,
519
+ });
520
+
521
+ export type PlatformMachineRequestReleaseGenerationExportResult = z.infer<
522
+ typeof platformMachineRequestReleaseGenerationExportResultSchema
523
+ >;
524
+
431
525
  export const platformMachineRequestReleaseUploadTargetResultSchema = z.object({
432
526
  release: platformMachineReleaseSummarySchema,
527
+ generation: platformMachineReleaseGenerationSchema,
433
528
  upload: platformMachineReleaseUploadTargetSchema,
434
529
  });
435
530
 
@@ -460,6 +555,8 @@ export type PlatformMachineMutateOwnedGameMediaAssetResult = z.infer<
460
555
 
461
556
  export const platformMachineFinalizeReleaseUploadResultSchema = z.object({
462
557
  release: platformMachineReleaseSummarySchema,
558
+ generation: platformMachineReleaseGenerationSchema,
559
+ job: platformMachineReleaseJobSchema,
463
560
  });
464
561
 
465
562
  export type PlatformMachineFinalizeReleaseUploadResult = z.infer<
@@ -46,6 +46,8 @@ export interface PreviewControllerWorkspaceProps {
46
46
  dockAccessory?: ReactNode;
47
47
  maxControllers?: number;
48
48
  launcherLabel?: string;
49
+ launcherVariant?: "full" | "compact";
50
+ showLauncherWhenIdle?: boolean;
49
51
  waitingLabel?: string;
50
52
  }
51
53
 
@@ -110,6 +112,8 @@ export const PreviewControllerWorkspace = ({
110
112
  dockAccessory,
111
113
  maxControllers = 2,
112
114
  launcherLabel = "Controllers",
115
+ launcherVariant = "full",
116
+ showLauncherWhenIdle = true,
113
117
  waitingLabel = "Waiting for room",
114
118
  }: PreviewControllerWorkspaceProps) => {
115
119
  const [mounted, setMounted] = useState(false);
@@ -199,6 +203,8 @@ export const PreviewControllerWorkspace = ({
199
203
  () => sessions.filter((session) => !session.minimized),
200
204
  [sessions],
201
205
  );
206
+ const launcherVisible =
207
+ showLauncherWhenIdle || launcherOpen || sessions.length > 0;
202
208
  const sortedControllers = useMemo(
203
209
  () =>
204
210
  [...controllers].sort((left, right) =>
@@ -417,35 +423,48 @@ export const PreviewControllerWorkspace = ({
417
423
  style={{ pointerEvents: "auto" }}
418
424
  >
419
425
  {dockAccessory}
420
- <Button
421
- type="button"
422
- variant="ghost"
423
- size="sm"
424
- className={cn(
425
- "rounded-full border border-white/25 bg-black/35 px-3 text-white backdrop-blur-sm hover:bg-black/55 disabled:border-white/10 disabled:bg-black/25 disabled:text-white/40",
426
- )}
427
- aria-expanded={launcherOpen}
428
- aria-label={
429
- launcherOpen
430
- ? "Hide preview controllers"
431
- : "Show preview controllers"
432
- }
433
- title={!joinUrl ? waitingLabel : launcherLabel}
434
- onClick={() => setLauncherOpen((current) => !current)}
435
- >
436
- <MonitorSmartphone className="h-4 w-4" />
437
- <span className="text-[11px] font-semibold tracking-[0.16em] uppercase">
438
- {launcherLabel}
439
- </span>
440
- <span className="rounded-full border border-white/12 bg-white/6 px-1.5 py-0.5 text-[10px] leading-none font-semibold text-white/88">
441
- {sessions.length}
442
- </span>
443
- {launcherOpen ? (
444
- <ChevronUp className="h-4 w-4 text-white/60" />
445
- ) : (
446
- <ChevronDown className="h-4 w-4 text-white/60" />
447
- )}
448
- </Button>
426
+ {launcherVisible ? (
427
+ <Button
428
+ type="button"
429
+ variant="ghost"
430
+ size={launcherVariant === "compact" ? "icon-sm" : "sm"}
431
+ className={cn(
432
+ "relative rounded-full border border-white/25 bg-black/35 text-white backdrop-blur-sm hover:bg-black/55 disabled:border-white/10 disabled:bg-black/25 disabled:text-white/40",
433
+ launcherVariant === "compact" ? "h-9 w-9 p-0" : "gap-2 px-3",
434
+ )}
435
+ aria-expanded={launcherOpen}
436
+ aria-label={
437
+ launcherOpen
438
+ ? `Hide ${launcherLabel.toLowerCase()}`
439
+ : `Show ${launcherLabel.toLowerCase()}`
440
+ }
441
+ title={!joinUrl ? waitingLabel : launcherLabel}
442
+ onClick={() => setLauncherOpen((current) => !current)}
443
+ >
444
+ <MonitorSmartphone className="h-4 w-4" />
445
+ {launcherVariant === "full" ? (
446
+ <>
447
+ <span className="text-[11px] font-semibold tracking-[0.16em] uppercase">
448
+ {launcherLabel}
449
+ </span>
450
+ {sessions.length > 0 ? (
451
+ <span className="rounded-full border border-white/12 bg-white/6 px-1.5 py-0.5 text-[10px] leading-none font-semibold text-white/88">
452
+ {sessions.length}
453
+ </span>
454
+ ) : null}
455
+ {launcherOpen ? (
456
+ <ChevronUp className="h-4 w-4 text-white/60" />
457
+ ) : (
458
+ <ChevronDown className="h-4 w-4 text-white/60" />
459
+ )}
460
+ </>
461
+ ) : sessions.length > 0 ? (
462
+ <span className="absolute -top-1 -right-1 flex h-4 min-w-4 items-center justify-center rounded-full border border-white/25 bg-slate-950 px-1 text-[9px] leading-none font-semibold text-white">
463
+ {sessions.length}
464
+ </span>
465
+ ) : null}
466
+ </Button>
467
+ ) : null}
449
468
  </div>
450
469
 
451
470
  {launcherOpen ? (
@@ -1,3 +1,5 @@
1
+ import { z } from "zod";
2
+
1
3
  /**
2
4
  * Platform (Arcade shell) commands sent as `controller:action_rpc` / `airjam:action_rpc` with
3
5
  * `storeDomain: arcade.surface`. The server routes these to the **master** host socket so they
@@ -7,8 +9,10 @@
7
9
  */
8
10
  export const AIRJAM_ARCADE_PLATFORM_ACTION_PREFIX = "airjam.arcade." as const;
9
11
 
10
- /** Canonical action names for QR overlay and game exit from the controller shell. */
12
+ /** Canonical commands owned by the Arcade shell, never an embedded game. */
11
13
  export const airJamArcadePlatformActions = {
14
+ navigate: "airjam.arcade.navigate",
15
+ confirm: "airjam.arcade.confirm",
12
16
  ping: "airjam.arcade.ping",
13
17
  toggleQr: "airjam.arcade.toggle_qr",
14
18
  showQr: "airjam.arcade.show_qr",
@@ -17,6 +21,20 @@ export const airJamArcadePlatformActions = {
17
21
  updateRoomSettings: "airjam.arcade.update_room_settings",
18
22
  } as const;
19
23
 
24
+ /** Menu commands refer to the exact browser surface on which the gesture began. */
25
+ export const arcadeBrowserConfirmPayloadSchema = z
26
+ .object({ epoch: z.number().int().positive().safe() })
27
+ .strict();
28
+
29
+ export const arcadeBrowserNavigatePayloadSchema =
30
+ arcadeBrowserConfirmPayloadSchema.extend({
31
+ direction: z.enum(["up", "down", "left", "right"]),
32
+ });
33
+
34
+ export type ArcadeBrowserDirection = z.infer<
35
+ typeof arcadeBrowserNavigatePayloadSchema
36
+ >["direction"];
37
+
20
38
  export type AirJamArcadePlatformActionName =
21
39
  (typeof airJamArcadePlatformActions)[keyof typeof airJamArcadePlatformActions];
22
40
 
@@ -3,6 +3,8 @@ import type { RoomPlatformSettingsSnapshot } from "../settings/platform-settings
3
3
  import { roomCodeSchema, type RoomCode } from "./core";
4
4
  import type { ErrorCode } from "./errors";
5
5
 
6
+ export { DEFAULT_ROOM_PLATFORM_SETTINGS } from "../settings/platform-settings";
7
+
6
8
  export const controllerInputSchema = z.object({
7
9
  roomId: roomCodeSchema,
8
10
  controllerId: z.string().min(3),
@@ -77,14 +79,15 @@ export const controllerJoinSchema = z.object({
77
79
  roomId: roomCodeSchema,
78
80
  controllerId: z.string().min(3),
79
81
  /**
80
- * Stable local controller device identity used as a reconnect hint.
81
- * Older clients may omit this and fall back to controllerId-only behavior.
82
+ * Local device/source hint, never authority to resume a controller slot.
82
83
  */
83
84
  deviceId: z.string().min(8).max(128).optional(),
84
85
  nickname: z.string().trim().min(1).max(24).optional(),
85
86
  /** Preset avatar key (platform-defined); optional at join. */
86
87
  avatarId: z.string().trim().min(1).max(48).optional(),
87
88
  capabilityToken: z.string().min(1).optional(),
89
+ /** Private server-issued proof required to resume an existing controller. */
90
+ resumeCapabilityToken: z.string().min(1).max(128).optional(),
88
91
  });
89
92
 
90
93
  export type ControllerJoinPayload = z.infer<typeof controllerJoinSchema>;
@@ -154,8 +157,11 @@ export interface ControllerJoinAck {
154
157
  controllerId?: string;
155
158
  roomId?: RoomCode;
156
159
  resumed?: boolean;
160
+ /** Private to the joining client; never publish in presence or bridge state. */
161
+ resumeCapabilityToken?: string;
157
162
  message?: string;
158
163
  code?: ErrorCode | string;
164
+ retryAfterSeconds?: number;
159
165
  }
160
166
 
161
167
  export const controllerPrivilegedGrantSchema = z.enum([
@@ -100,7 +100,6 @@ export const AIRJAM_DEV_LOG_EVENTS = {
100
100
  modeMasterKey: "auth.mode.master_key",
101
101
  modeDatabaseAndHostGrant: "auth.mode.database_and_host_grant",
102
102
  modeDatabase: "auth.mode.database",
103
- modeHostGrantOnly: "auth.mode.host_grant_only",
104
103
  backendMissing: "auth.backend.missing",
105
104
  appIdLastUsedAtUpdateFailed: "auth.app_id_last_used_at_update.failed",
106
105
  appIdVerificationDatabaseError: "auth.app_id_verification.database_error",
@@ -144,8 +143,6 @@ export const AIRJAM_DEV_LOG_EVENTS = {
144
143
  bootstrapRejected: "host.bootstrap.rejected",
145
144
  disconnectPendingRoomClose: "host.disconnect.pending_room_close",
146
145
  disconnectRoomClosed: "host.disconnect.room_closed",
147
- registerSystemAccepted: "host.register_system.accepted",
148
- registerSystemRejected: "host.register_system.rejected",
149
146
  createRoomAccepted: "host.create_room.accepted",
150
147
  createRoomRejected: "host.create_room.rejected",
151
148
  reconnectAccepted: "host.reconnect.accepted",