@air-jam/sdk 0.1.4 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (357) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +627 -57
  3. package/dist/agent-tooling-BSMGBix9.d.cts +123 -0
  4. package/dist/agent-tooling-BSMGBix9.d.ts +123 -0
  5. package/dist/agent-tooling.cjs +83 -0
  6. package/dist/agent-tooling.cjs.map +1 -0
  7. package/dist/agent-tooling.d.cts +2 -0
  8. package/dist/agent-tooling.d.ts +2 -0
  9. package/dist/agent-tooling.js +17 -0
  10. package/dist/agent-tooling.js.map +1 -0
  11. package/dist/arcade/bridge/controller.cjs +749 -0
  12. package/dist/arcade/bridge/controller.cjs.map +1 -0
  13. package/dist/arcade/bridge/controller.d.cts +85 -0
  14. package/dist/arcade/bridge/controller.d.ts +85 -0
  15. package/dist/arcade/bridge/controller.js +33 -0
  16. package/dist/arcade/bridge/controller.js.map +1 -0
  17. package/dist/arcade/bridge/host.cjs +421 -0
  18. package/dist/arcade/bridge/host.cjs.map +1 -0
  19. package/dist/arcade/bridge/host.d.cts +73 -0
  20. package/dist/arcade/bridge/host.d.ts +73 -0
  21. package/dist/arcade/bridge/host.js +25 -0
  22. package/dist/arcade/bridge/host.js.map +1 -0
  23. package/dist/arcade/bridge/iframe.cjs +453 -0
  24. package/dist/arcade/bridge/iframe.cjs.map +1 -0
  25. package/dist/arcade/bridge/iframe.d.cts +80 -0
  26. package/dist/arcade/bridge/iframe.d.ts +80 -0
  27. package/dist/arcade/bridge/iframe.js +28 -0
  28. package/dist/arcade/bridge/iframe.js.map +1 -0
  29. package/dist/arcade/bridge.cjs +1067 -0
  30. package/dist/arcade/bridge.cjs.map +1 -0
  31. package/dist/arcade/bridge.d.cts +11 -0
  32. package/dist/arcade/bridge.d.ts +11 -0
  33. package/dist/arcade/bridge.js +76 -0
  34. package/dist/arcade/bridge.js.map +1 -0
  35. package/dist/arcade/host.cjs +481 -0
  36. package/dist/arcade/host.cjs.map +1 -0
  37. package/dist/arcade/host.d.cts +19 -0
  38. package/dist/arcade/host.d.ts +19 -0
  39. package/dist/arcade/host.js +14 -0
  40. package/dist/arcade/host.js.map +1 -0
  41. package/dist/arcade/surface.cjs +113 -0
  42. package/dist/arcade/surface.cjs.map +1 -0
  43. package/dist/arcade/surface.d.cts +14 -0
  44. package/dist/arcade/surface.d.ts +14 -0
  45. package/dist/arcade/surface.js +27 -0
  46. package/dist/arcade/surface.js.map +1 -0
  47. package/dist/arcade/url.cjs +544 -0
  48. package/dist/arcade/url.cjs.map +1 -0
  49. package/dist/arcade/url.d.cts +68 -0
  50. package/dist/arcade/url.d.ts +68 -0
  51. package/dist/arcade/url.js +29 -0
  52. package/dist/arcade/url.js.map +1 -0
  53. package/dist/arcade-runtime-url-BW-MUAOY.d.cts +28 -0
  54. package/dist/arcade-runtime-url-l8qj01Pg.d.ts +28 -0
  55. package/dist/arcade-surface-identity-CQxDpn_w.d.cts +16 -0
  56. package/dist/arcade-surface-identity-CQxDpn_w.d.ts +16 -0
  57. package/dist/arcade.cjs +1737 -0
  58. package/dist/arcade.cjs.map +1 -0
  59. package/dist/arcade.d.cts +18 -0
  60. package/dist/arcade.d.ts +18 -0
  61. package/dist/arcade.js +123 -0
  62. package/dist/arcade.js.map +1 -0
  63. package/dist/capabilities.cjs +39 -0
  64. package/dist/capabilities.cjs.map +1 -0
  65. package/dist/capabilities.d.cts +31 -0
  66. package/dist/capabilities.d.ts +31 -0
  67. package/dist/capabilities.js +12 -0
  68. package/dist/capabilities.js.map +1 -0
  69. package/dist/chunk-32NYL7XI.js +539 -0
  70. package/dist/chunk-32NYL7XI.js.map +1 -0
  71. package/dist/chunk-3USU7GY2.js +54 -0
  72. package/dist/chunk-3USU7GY2.js.map +1 -0
  73. package/dist/chunk-7UXSWCZZ.js +32 -0
  74. package/dist/chunk-7UXSWCZZ.js.map +1 -0
  75. package/dist/chunk-BE6Z4SIT.js +65 -0
  76. package/dist/chunk-BE6Z4SIT.js.map +1 -0
  77. package/dist/chunk-CABEUV65.js +184 -0
  78. package/dist/chunk-CABEUV65.js.map +1 -0
  79. package/dist/chunk-CEJ5RFSG.js +288 -0
  80. package/dist/chunk-CEJ5RFSG.js.map +1 -0
  81. package/dist/chunk-EDRQIOCV.js +25 -0
  82. package/dist/chunk-EDRQIOCV.js.map +1 -0
  83. package/dist/chunk-EVZJA6RN.js +140 -0
  84. package/dist/chunk-EVZJA6RN.js.map +1 -0
  85. package/dist/chunk-FAT2KJ3K.js +238 -0
  86. package/dist/chunk-FAT2KJ3K.js.map +1 -0
  87. package/dist/chunk-IKKDONQL.js +1 -0
  88. package/dist/chunk-IKKDONQL.js.map +1 -0
  89. package/dist/chunk-JEHV5C2X.js +249 -0
  90. package/dist/chunk-JEHV5C2X.js.map +1 -0
  91. package/dist/chunk-JO2HR5PV.js +43 -0
  92. package/dist/chunk-JO2HR5PV.js.map +1 -0
  93. package/dist/chunk-JTF47B56.js +1 -0
  94. package/dist/chunk-JTF47B56.js.map +1 -0
  95. package/dist/chunk-KXAFI5OP.js +193 -0
  96. package/dist/chunk-KXAFI5OP.js.map +1 -0
  97. package/dist/chunk-LIXPF4P6.js +22 -0
  98. package/dist/chunk-LIXPF4P6.js.map +1 -0
  99. package/dist/chunk-MPDMJIX5.js +1 -0
  100. package/dist/chunk-MPDMJIX5.js.map +1 -0
  101. package/dist/chunk-NCL6WJCL.js +91 -0
  102. package/dist/chunk-NCL6WJCL.js.map +1 -0
  103. package/dist/chunk-NUJBMV3O.js +1435 -0
  104. package/dist/chunk-NUJBMV3O.js.map +1 -0
  105. package/dist/chunk-TGRTEWYV.js +195 -0
  106. package/dist/chunk-TGRTEWYV.js.map +1 -0
  107. package/dist/chunk-UWJOIVON.js +369 -0
  108. package/dist/chunk-UWJOIVON.js.map +1 -0
  109. package/dist/chunk-VKBMZHMQ.js +216 -0
  110. package/dist/chunk-VKBMZHMQ.js.map +1 -0
  111. package/dist/chunk-W2VK36RO.js +11 -0
  112. package/dist/chunk-W2VK36RO.js.map +1 -0
  113. package/dist/chunk-W3YA5BWR.js +126 -0
  114. package/dist/chunk-W3YA5BWR.js.map +1 -0
  115. package/dist/chunk-X24K52DG.js +12 -0
  116. package/dist/chunk-X24K52DG.js.map +1 -0
  117. package/dist/chunk-YXHH3MQT.js +230 -0
  118. package/dist/chunk-YXHH3MQT.js.map +1 -0
  119. package/dist/chunk-ZLPL2R3R.js +183 -0
  120. package/dist/chunk-ZLPL2R3R.js.map +1 -0
  121. package/dist/chunk-ZTQ5SP4H.js +9 -0
  122. package/dist/chunk-ZTQ5SP4H.js.map +1 -0
  123. package/dist/controller-Bod8YYr1.d.cts +172 -0
  124. package/dist/controller-DxVchfiA.d.ts +172 -0
  125. package/dist/dev-log-events-CVAM29hx.d.cts +123 -0
  126. package/dist/dev-log-events-CVAM29hx.d.ts +123 -0
  127. package/dist/handshake-CC_LrK5g.d.cts +31 -0
  128. package/dist/handshake-CC_LrK5g.d.ts +31 -0
  129. package/dist/host-8hmq_Sgc.d.cts +109 -0
  130. package/dist/host-Cw-N6e-5.d.ts +109 -0
  131. package/dist/index.cjs +8730 -3426
  132. package/dist/index.cjs.map +1 -1
  133. package/dist/index.d.cts +676 -1070
  134. package/dist/index.d.ts +676 -1070
  135. package/dist/index.js +4892 -3196
  136. package/dist/index.js.map +1 -1
  137. package/dist/metadata.cjs +114 -0
  138. package/dist/metadata.cjs.map +1 -0
  139. package/dist/metadata.d.cts +95 -0
  140. package/dist/metadata.d.ts +95 -0
  141. package/dist/metadata.js +83 -0
  142. package/dist/metadata.js.map +1 -0
  143. package/dist/notices-CnGaaS8B.d.ts +38 -0
  144. package/dist/notices-NyDM5Mtz.d.cts +38 -0
  145. package/dist/platform-machine.cjs +425 -0
  146. package/dist/platform-machine.cjs.map +1 -0
  147. package/dist/platform-machine.d.cts +1183 -0
  148. package/dist/platform-machine.d.ts +1183 -0
  149. package/dist/platform-machine.js +309 -0
  150. package/dist/platform-machine.js.map +1 -0
  151. package/dist/platform-settings-cuor3i11.d.cts +48 -0
  152. package/dist/platform-settings-cuor3i11.d.ts +48 -0
  153. package/dist/prefabs.cjs +36 -0
  154. package/dist/prefabs.cjs.map +1 -0
  155. package/dist/prefabs.d.cts +49 -0
  156. package/dist/prefabs.d.ts +49 -0
  157. package/dist/prefabs.js +8 -0
  158. package/dist/prefabs.js.map +1 -0
  159. package/dist/preview.cjs +2620 -0
  160. package/dist/preview.cjs.map +1 -0
  161. package/dist/preview.d.cts +155 -0
  162. package/dist/preview.d.ts +155 -0
  163. package/dist/preview.js +1671 -0
  164. package/dist/preview.js.map +1 -0
  165. package/dist/protocol.cjs +621 -54
  166. package/dist/protocol.cjs.map +1 -1
  167. package/dist/protocol.d.cts +76 -240
  168. package/dist/protocol.d.ts +76 -240
  169. package/dist/protocol.js +100 -2
  170. package/dist/protocol.js.map +1 -1
  171. package/dist/realtime-client-Cu8yVJFw.d.cts +15 -0
  172. package/dist/realtime-client-Cu8yVJFw.d.ts +15 -0
  173. package/dist/release.cjs +143 -0
  174. package/dist/release.cjs.map +1 -0
  175. package/dist/release.d.cts +64 -0
  176. package/dist/release.d.ts +64 -0
  177. package/dist/release.js +43 -0
  178. package/dist/release.js.map +1 -0
  179. package/dist/runtime-topology.cjs +405 -0
  180. package/dist/runtime-topology.cjs.map +1 -0
  181. package/dist/runtime-topology.d.cts +59 -0
  182. package/dist/runtime-topology.d.ts +59 -0
  183. package/dist/runtime-topology.js +31 -0
  184. package/dist/runtime-topology.js.map +1 -0
  185. package/dist/standard-match-phase-BucA5dYo.d.ts +44 -0
  186. package/dist/standard-match-phase-U2ra8J-0.d.cts +44 -0
  187. package/dist/sync-B6QsNrXz.d.cts +125 -0
  188. package/dist/sync-B6QsNrXz.d.ts +125 -0
  189. package/dist/ui.cjs +3061 -0
  190. package/dist/ui.cjs.map +1 -0
  191. package/dist/ui.d.cts +320 -0
  192. package/dist/ui.d.ts +320 -0
  193. package/dist/ui.js +1719 -0
  194. package/dist/ui.js.map +1 -0
  195. package/dist/url-policy-C89zxgw9.d.cts +9 -0
  196. package/dist/url-policy-C89zxgw9.d.ts +9 -0
  197. package/package.json +155 -10
  198. package/src/agent/agent-action.ts +304 -0
  199. package/src/agent/agent-contract.ts +180 -0
  200. package/src/agent-tooling.ts +20 -0
  201. package/src/arcade/bridge/controller.ts +15 -0
  202. package/src/arcade/bridge/host.ts +12 -0
  203. package/src/arcade/bridge/iframe.ts +61 -0
  204. package/src/arcade/bridge.ts +3 -0
  205. package/src/arcade/host.ts +1 -0
  206. package/src/arcade/surface.ts +4 -0
  207. package/src/arcade/url.ts +60 -0
  208. package/src/arcade.ts +4 -0
  209. package/src/audio/audio-manager.ts +162 -171
  210. package/src/audio/hooks.tsx +218 -97
  211. package/src/audio/index.ts +1 -1
  212. package/src/audio/music.tsx +139 -0
  213. package/src/capabilities/manifest.ts +71 -0
  214. package/src/capabilities.ts +12 -0
  215. package/src/components/connection-status-pill.tsx +55 -0
  216. package/src/components/controller-player-name-field.tsx +119 -0
  217. package/src/components/controller-primary-action.tsx +58 -0
  218. package/src/components/host-mute-button.tsx +49 -0
  219. package/src/components/join-qr-overlay.tsx +133 -0
  220. package/src/components/join-url-action-buttons.tsx +95 -0
  221. package/src/components/join-url-controls.tsx +58 -0
  222. package/src/components/join-url-field.tsx +52 -0
  223. package/src/components/lifecycle-action-group.tsx +129 -0
  224. package/src/components/player-avatar-strip.tsx +65 -0
  225. package/src/components/player-avatar.tsx +42 -13
  226. package/src/components/room-qr-code.tsx +125 -0
  227. package/src/components/runtime-shell-header.tsx +37 -0
  228. package/src/components/shell-classes.ts +19 -0
  229. package/src/components/surface-orientation-layout.ts +60 -0
  230. package/src/components/surface-viewport-layout.ts +268 -0
  231. package/src/components/surface-viewport.tsx +314 -0
  232. package/src/components/ui/button.tsx +4 -6
  233. package/src/components/ui/slider.tsx +1 -1
  234. package/src/components/volume-controls.tsx +65 -6
  235. package/src/context/air-jam-context.tsx +209 -161
  236. package/src/context/index.ts +2 -2
  237. package/src/context/session-providers.tsx +77 -0
  238. package/src/context/session-scope.ts +64 -0
  239. package/src/context/socket-manager.ts +6 -24
  240. package/src/contracts/v2/bridge.ts +261 -0
  241. package/src/contracts/v2/handshake.ts +40 -0
  242. package/src/contracts/v2/index.ts +2 -0
  243. package/src/dev/browser-log-sink.ts +912 -0
  244. package/src/diagnostics.ts +128 -0
  245. package/src/events.ts +7 -34
  246. package/src/hooks/internal/use-controller-runtime-api.ts +875 -0
  247. package/src/hooks/internal/use-host-runtime-api.ts +1051 -0
  248. package/src/hooks/internal/use-runtime-control-contract.ts +15 -0
  249. package/src/hooks/internal/use-runtime-inspection-contract.ts +16 -0
  250. package/src/hooks/internal/use-runtime-observability-contract.ts +24 -0
  251. package/src/hooks/use-air-jam-controller.ts +155 -475
  252. package/src/hooks/use-air-jam-host.ts +156 -485
  253. package/src/hooks/use-connection-status.ts +8 -0
  254. package/src/hooks/use-controller-lifecycle-intents.ts +27 -0
  255. package/src/hooks/use-controller-lifecycle-permissions.ts +36 -0
  256. package/src/hooks/use-controller-shell-status.ts +40 -0
  257. package/src/hooks/use-controller-tick.ts +65 -0
  258. package/src/hooks/use-controller-toasts.ts +116 -0
  259. package/src/hooks/use-get-input.ts +8 -5
  260. package/src/hooks/use-host-arcade-restore.ts +30 -0
  261. package/src/hooks/use-host-join-controls.ts +152 -0
  262. package/src/hooks/use-host-tick.ts +171 -0
  263. package/src/hooks/use-input-writer.ts +83 -0
  264. package/src/hooks/use-lifecycle-action-group-model.ts +98 -0
  265. package/src/hooks/use-players.ts +12 -0
  266. package/src/hooks/use-room.ts +22 -0
  267. package/src/hooks/use-send-signal.ts +6 -2
  268. package/src/index.ts +205 -31
  269. package/src/internal/input-manager.ts +195 -215
  270. package/src/lifecycle/index.ts +9 -0
  271. package/src/lifecycle/standard-match-phase.ts +32 -0
  272. package/src/metadata/manifest.ts +152 -0
  273. package/src/metadata.ts +12 -0
  274. package/src/platform-machine.ts +475 -0
  275. package/src/prefabs/types.ts +82 -0
  276. package/src/prefabs.ts +12 -0
  277. package/src/preview/host-workspace.tsx +59 -0
  278. package/src/preview/identity.ts +66 -0
  279. package/src/preview/layout.ts +223 -0
  280. package/src/preview/manager.ts +577 -0
  281. package/src/preview/messages.ts +26 -0
  282. package/src/preview/ownership.ts +81 -0
  283. package/src/preview/url.ts +117 -0
  284. package/src/preview/window.tsx +490 -0
  285. package/src/preview/workspace.tsx +678 -0
  286. package/src/preview.ts +42 -0
  287. package/src/protocol/arcade-platform-actions.ts +29 -0
  288. package/src/protocol/controller.ts +187 -0
  289. package/src/protocol/core.ts +23 -0
  290. package/src/protocol/dev-log-events.ts +222 -0
  291. package/src/protocol/errors.ts +21 -0
  292. package/src/protocol/host-grant.ts +185 -0
  293. package/src/protocol/host.ts +138 -0
  294. package/src/protocol/notices.ts +43 -0
  295. package/src/protocol/signals.ts +38 -0
  296. package/src/protocol/socket-events.ts +154 -0
  297. package/src/protocol/sync.ts +121 -0
  298. package/src/protocol/url-policy.ts +63 -0
  299. package/src/protocol.ts +12 -386
  300. package/src/qrcode.d.ts +16 -0
  301. package/src/release.ts +99 -0
  302. package/src/runtime/air-jam-config.ts +287 -0
  303. package/src/runtime/air-jam-error-boundary.tsx +672 -0
  304. package/src/runtime/arcade-bridge-request-surface.ts +15 -0
  305. package/src/runtime/arcade-runtime-url.ts +95 -0
  306. package/src/runtime/arcade-surface-identity.ts +16 -0
  307. package/src/runtime/contracts/control.ts +68 -0
  308. package/src/runtime/contracts/inspection.ts +165 -0
  309. package/src/runtime/contracts/observability.ts +94 -0
  310. package/src/runtime/controller-bridge.ts +451 -0
  311. package/src/runtime/controller-identity.ts +132 -0
  312. package/src/runtime/controller-presentation.ts +24 -0
  313. package/src/runtime/controller-realtime-client.ts +591 -0
  314. package/src/runtime/create-air-jam-app.tsx +260 -0
  315. package/src/runtime/dev-runtime-events.ts +36 -0
  316. package/src/runtime/embedded-runtime-adapters.ts +68 -0
  317. package/src/runtime/host-bridge.ts +388 -0
  318. package/src/runtime/host-realtime-client.ts +550 -0
  319. package/src/runtime/iframe-bridge.ts +135 -0
  320. package/src/runtime/realtime-client.ts +20 -0
  321. package/src/runtime/router-basename.ts +25 -0
  322. package/src/runtime/runtime-owner-contexts.tsx +4 -0
  323. package/src/runtime/runtime-session-params.ts +169 -0
  324. package/src/runtime/sdk-version.ts +6 -0
  325. package/src/runtime/session-runtimes.tsx +188 -0
  326. package/src/runtime/validate-arcade-bridge-attach.ts +14 -0
  327. package/src/runtime-control.ts +10 -0
  328. package/src/runtime-inspection.ts +14 -0
  329. package/src/runtime-observability.ts +9 -0
  330. package/src/runtime-topology.ts +569 -0
  331. package/src/settings/platform-settings-bridge.ts +336 -0
  332. package/src/settings/platform-settings-runtime.tsx +387 -0
  333. package/src/settings/platform-settings.ts +288 -0
  334. package/src/state/connection-store.ts +80 -12
  335. package/src/store/air-jam-store-domain-constants.ts +4 -0
  336. package/src/store/create-air-jam-store.ts +1094 -227
  337. package/src/styles.css +4 -38
  338. package/src/ui.ts +29 -0
  339. package/src/utils/is-rpc-serializable.ts +56 -0
  340. package/src/utils/player-avatar-url.ts +48 -0
  341. package/src/utils/url-builder.ts +7 -0
  342. package/dist/.tsbuildinfo +0 -1
  343. package/dist/chunk-B5DURUWT.js +0 -80
  344. package/dist/chunk-B5DURUWT.js.map +0 -1
  345. package/src/AirJamClient.ts +0 -224
  346. package/src/audio/volume-store.ts +0 -124
  347. package/src/components/controller-shell.tsx +0 -346
  348. package/src/components/host-shell.tsx +0 -520
  349. package/src/components/qr-scanner-dialog.tsx +0 -373
  350. package/src/components/ui/alert.tsx +0 -66
  351. package/src/components/ui/avatar.tsx +0 -46
  352. package/src/components/ui/badge.tsx +0 -47
  353. package/src/components/ui/card.tsx +0 -92
  354. package/src/components/ui/dialog.tsx +0 -122
  355. package/src/components/ui/tabs.tsx +0 -64
  356. package/src/hooks/use-air-jam-shell.ts +0 -379
  357. package/src/hooks/use-fullscreen.ts +0 -108
@@ -0,0 +1,123 @@
1
+ import { ZodType } from 'zod';
2
+
3
+ type AirJamAgentActionPayloadKind = "none" | "boolean" | "number" | "string" | "enum" | "json";
4
+ type AirJamAgentActionPayloadMetadata = {
5
+ kind: AirJamAgentActionPayloadKind;
6
+ description?: string;
7
+ allowedValues?: string[];
8
+ };
9
+ type AirJamAgentActionMetadata = {
10
+ description?: string;
11
+ payload: AirJamAgentActionPayloadMetadata;
12
+ resultDescription?: string;
13
+ };
14
+ type AirJamAgentActionDescriptor = {
15
+ name: string;
16
+ description: string | null;
17
+ payload: {
18
+ kind: AirJamAgentActionPayloadKind;
19
+ description: string | null;
20
+ allowedValues?: string[];
21
+ };
22
+ resultDescription: string | null;
23
+ };
24
+ type AirJamAgentActionParseMeta = {
25
+ gameId: string;
26
+ actionName: string;
27
+ contractKind?: string;
28
+ };
29
+ type AirJamAgentActionInputDefinition<TPayload = unknown> = {
30
+ parse: (payload: unknown, meta: AirJamAgentActionParseMeta) => TPayload;
31
+ metadata: AirJamAgentActionMetadata;
32
+ };
33
+ type InferAirJamAgentActionInputPayload<TInput> = TInput extends AirJamAgentActionInputDefinition<infer TPayload> ? TPayload : never;
34
+ type AirJamAgentActionOptions = {
35
+ description?: string;
36
+ payloadDescription?: string;
37
+ resultDescription?: string;
38
+ };
39
+ type AirJamAgentActionCustomOptions = AirJamAgentActionOptions & {
40
+ payloadKind?: AirJamAgentActionPayloadKind;
41
+ allowedValues?: string[];
42
+ };
43
+ declare const createAgentActionMetadata: (payload: AirJamAgentActionPayloadMetadata, options?: AirJamAgentActionOptions) => AirJamAgentActionMetadata;
44
+ declare const defineAgentActionInput: <TPayload>(parse: (payload: unknown, meta: AirJamAgentActionParseMeta) => TPayload, metadata: AirJamAgentActionMetadata) => AirJamAgentActionInputDefinition<TPayload>;
45
+ type AirJamAgentActionCustomParser<TPayload> = (payload: unknown, meta: AirJamAgentActionParseMeta) => TPayload;
46
+ type AirJamAgentActionZodSchema<TPayload> = ZodType<TPayload>;
47
+ declare function customInput<TPayload>(parse: AirJamAgentActionCustomParser<TPayload>): AirJamAgentActionInputDefinition<TPayload>;
48
+ declare function customInput<TPayload>(options: AirJamAgentActionCustomOptions, parse: AirJamAgentActionCustomParser<TPayload>): AirJamAgentActionInputDefinition<TPayload>;
49
+ declare const agentActionInput: {
50
+ none: (options?: AirJamAgentActionOptions) => AirJamAgentActionInputDefinition<void>;
51
+ number: (options?: AirJamAgentActionOptions) => AirJamAgentActionInputDefinition<number>;
52
+ string: (options?: AirJamAgentActionOptions) => AirJamAgentActionInputDefinition<string>;
53
+ boolean: (options?: AirJamAgentActionOptions) => AirJamAgentActionInputDefinition<boolean>;
54
+ enum: <const TValues extends readonly string[]>(values: TValues, options?: AirJamAgentActionOptions) => AirJamAgentActionInputDefinition<TValues[number]>;
55
+ json: (options?: AirJamAgentActionOptions) => AirJamAgentActionInputDefinition<unknown>;
56
+ custom: typeof customInput;
57
+ zod: <TPayload>(schema: AirJamAgentActionZodSchema<TPayload>, options?: AirJamAgentActionOptions) => AirJamAgentActionInputDefinition<TPayload>;
58
+ };
59
+ declare const describeAgentActionInputs: <TActions extends Record<string, {
60
+ metadata?: AirJamAgentActionMetadata | undefined;
61
+ }>>(actions: TActions) => AirJamAgentActionDescriptor[];
62
+
63
+ type AirJamAgentJsonObject = Record<string, unknown>;
64
+ type AirJamAgentContractPayloadKind = AirJamAgentActionPayloadKind;
65
+ type AirJamAgentContractPayloadMetadata = AirJamAgentActionPayloadMetadata;
66
+ type AirJamAgentStoreDeclaration<TStore extends object = object> = {
67
+ readonly __store?: TStore;
68
+ };
69
+ type AirJamAgentStoreDeclarations = Record<string, AirJamAgentStoreDeclaration<object>>;
70
+ type AirJamAgentActionTarget = {
71
+ kind: "participant" | "host";
72
+ actionName: string;
73
+ storeDomain?: string;
74
+ };
75
+ type AirJamAgentStores = Record<string, object>;
76
+ type InferAirJamAgentStores<TDeclarations extends AirJamAgentStoreDeclarations> = {
77
+ [TKey in keyof TDeclarations]: TDeclarations[TKey] extends AirJamAgentStoreDeclaration<infer TStore> ? TStore : never;
78
+ };
79
+ type AirJamAgentActionContractBase = {
80
+ target: AirJamAgentActionTarget;
81
+ description?: string;
82
+ availability?: string;
83
+ /**
84
+ * Human and agent-facing description of the expected semantic effect.
85
+ * This does not automatically become runtime result data; return
86
+ * `acceptAirJamAction(result)` from the underlying store action when callers
87
+ * need an actual result payload.
88
+ */
89
+ resultDescription?: string;
90
+ };
91
+ type AirJamAgentResolvedActionContract<TInput = unknown, TPayload = TInput> = AirJamAgentActionContractBase & {
92
+ input: AirJamAgentActionInputDefinition<TInput>;
93
+ toPayload?: (input: TInput) => TPayload;
94
+ };
95
+ type AirJamAgentActionContract = AirJamAgentResolvedActionContract<any, any>;
96
+ type AnyAirJamAgentContract = AirJamAgentContract<any, any>;
97
+ type AirJamAgentContractActionOptions<TInput, TPayload = TInput> = AirJamAgentActionOptions & {
98
+ availability?: string;
99
+ input: AirJamAgentActionInputDefinition<TInput>;
100
+ toPayload?: (input: TInput) => TPayload;
101
+ };
102
+ type AirJamAgentSnapshotContext<TStores extends AirJamAgentStores = AirJamAgentStores> = {
103
+ controllerId: string | null;
104
+ stores: Partial<TStores>;
105
+ };
106
+ type AirJamAgentContract<TSnapshot extends AirJamAgentJsonObject = AirJamAgentJsonObject, TStoreDeclarations extends AirJamAgentStoreDeclarations = AirJamAgentStoreDeclarations> = {
107
+ stores: TStoreDeclarations;
108
+ snapshotDescription?: string;
109
+ projectSnapshot: (context: AirJamAgentSnapshotContext<InferAirJamAgentStores<TStoreDeclarations>>) => TSnapshot | Promise<TSnapshot>;
110
+ actions: Record<string, AirJamAgentActionContract>;
111
+ };
112
+ declare const agentStore: <TStore extends object>() => AirJamAgentStoreDeclaration<TStore>;
113
+ declare const defineAirJamAgentStores: <TDeclarations extends AirJamAgentStoreDeclarations>(stores: TDeclarations) => TDeclarations;
114
+ declare const listAirJamAgentStoreDomains: (contract: AnyAirJamAgentContract) => string[];
115
+ declare const describeAirJamAgentAction: (action: AirJamAgentActionContract) => AirJamAgentActionMetadata;
116
+ declare const resolveAirJamAgentActionPayload: (action: AirJamAgentActionContract, payload: unknown, meta: AirJamAgentActionParseMeta) => unknown;
117
+ declare const agentAction: {
118
+ participant: <TInput, TPayload = TInput>(target: Omit<AirJamAgentActionTarget, "kind">, options: AirJamAgentContractActionOptions<TInput, TPayload>) => AirJamAgentResolvedActionContract<TInput, TPayload>;
119
+ host: <TInput, TPayload = TInput>(target: Omit<AirJamAgentActionTarget, "kind">, options: AirJamAgentContractActionOptions<TInput, TPayload>) => AirJamAgentResolvedActionContract<TInput, TPayload>;
120
+ };
121
+ declare const defineAirJamAgentContract: <TSnapshot extends AirJamAgentJsonObject, TStoreDeclarations extends AirJamAgentStoreDeclarations>(contract: AirJamAgentContract<TSnapshot, TStoreDeclarations>) => AirJamAgentContract<TSnapshot, TStoreDeclarations>;
122
+
123
+ export { type AirJamAgentContract as A, type AirJamAgentActionInputDefinition as B, type AirJamAgentActionMetadata as C, type AirJamAgentActionParseMeta as D, describeAirJamAgentAction as E, listAirJamAgentStoreDomains as F, resolveAirJamAgentActionPayload as G, type InferAirJamAgentActionInputPayload as I, agentActionInput as a, type AirJamAgentActionCustomOptions as b, type AirJamAgentActionOptions as c, type AirJamAgentActionPayloadKind as d, type AirJamAgentActionPayloadMetadata as e, agentAction as f, agentStore as g, defineAirJamAgentContract as h, defineAirJamAgentStores as i, type AirJamAgentActionContract as j, type AirJamAgentActionTarget as k, type AirJamAgentContractActionOptions as l, type AirJamAgentContractPayloadKind as m, type AirJamAgentContractPayloadMetadata as n, type AirJamAgentJsonObject as o, type AirJamAgentResolvedActionContract as p, type AirJamAgentSnapshotContext as q, type AirJamAgentStoreDeclaration as r, type AirJamAgentStoreDeclarations as s, type AirJamAgentStores as t, type AnyAirJamAgentContract as u, type InferAirJamAgentStores as v, createAgentActionMetadata as w, defineAgentActionInput as x, describeAgentActionInputs as y, type AirJamAgentActionDescriptor as z };
@@ -0,0 +1,123 @@
1
+ import { ZodType } from 'zod';
2
+
3
+ type AirJamAgentActionPayloadKind = "none" | "boolean" | "number" | "string" | "enum" | "json";
4
+ type AirJamAgentActionPayloadMetadata = {
5
+ kind: AirJamAgentActionPayloadKind;
6
+ description?: string;
7
+ allowedValues?: string[];
8
+ };
9
+ type AirJamAgentActionMetadata = {
10
+ description?: string;
11
+ payload: AirJamAgentActionPayloadMetadata;
12
+ resultDescription?: string;
13
+ };
14
+ type AirJamAgentActionDescriptor = {
15
+ name: string;
16
+ description: string | null;
17
+ payload: {
18
+ kind: AirJamAgentActionPayloadKind;
19
+ description: string | null;
20
+ allowedValues?: string[];
21
+ };
22
+ resultDescription: string | null;
23
+ };
24
+ type AirJamAgentActionParseMeta = {
25
+ gameId: string;
26
+ actionName: string;
27
+ contractKind?: string;
28
+ };
29
+ type AirJamAgentActionInputDefinition<TPayload = unknown> = {
30
+ parse: (payload: unknown, meta: AirJamAgentActionParseMeta) => TPayload;
31
+ metadata: AirJamAgentActionMetadata;
32
+ };
33
+ type InferAirJamAgentActionInputPayload<TInput> = TInput extends AirJamAgentActionInputDefinition<infer TPayload> ? TPayload : never;
34
+ type AirJamAgentActionOptions = {
35
+ description?: string;
36
+ payloadDescription?: string;
37
+ resultDescription?: string;
38
+ };
39
+ type AirJamAgentActionCustomOptions = AirJamAgentActionOptions & {
40
+ payloadKind?: AirJamAgentActionPayloadKind;
41
+ allowedValues?: string[];
42
+ };
43
+ declare const createAgentActionMetadata: (payload: AirJamAgentActionPayloadMetadata, options?: AirJamAgentActionOptions) => AirJamAgentActionMetadata;
44
+ declare const defineAgentActionInput: <TPayload>(parse: (payload: unknown, meta: AirJamAgentActionParseMeta) => TPayload, metadata: AirJamAgentActionMetadata) => AirJamAgentActionInputDefinition<TPayload>;
45
+ type AirJamAgentActionCustomParser<TPayload> = (payload: unknown, meta: AirJamAgentActionParseMeta) => TPayload;
46
+ type AirJamAgentActionZodSchema<TPayload> = ZodType<TPayload>;
47
+ declare function customInput<TPayload>(parse: AirJamAgentActionCustomParser<TPayload>): AirJamAgentActionInputDefinition<TPayload>;
48
+ declare function customInput<TPayload>(options: AirJamAgentActionCustomOptions, parse: AirJamAgentActionCustomParser<TPayload>): AirJamAgentActionInputDefinition<TPayload>;
49
+ declare const agentActionInput: {
50
+ none: (options?: AirJamAgentActionOptions) => AirJamAgentActionInputDefinition<void>;
51
+ number: (options?: AirJamAgentActionOptions) => AirJamAgentActionInputDefinition<number>;
52
+ string: (options?: AirJamAgentActionOptions) => AirJamAgentActionInputDefinition<string>;
53
+ boolean: (options?: AirJamAgentActionOptions) => AirJamAgentActionInputDefinition<boolean>;
54
+ enum: <const TValues extends readonly string[]>(values: TValues, options?: AirJamAgentActionOptions) => AirJamAgentActionInputDefinition<TValues[number]>;
55
+ json: (options?: AirJamAgentActionOptions) => AirJamAgentActionInputDefinition<unknown>;
56
+ custom: typeof customInput;
57
+ zod: <TPayload>(schema: AirJamAgentActionZodSchema<TPayload>, options?: AirJamAgentActionOptions) => AirJamAgentActionInputDefinition<TPayload>;
58
+ };
59
+ declare const describeAgentActionInputs: <TActions extends Record<string, {
60
+ metadata?: AirJamAgentActionMetadata | undefined;
61
+ }>>(actions: TActions) => AirJamAgentActionDescriptor[];
62
+
63
+ type AirJamAgentJsonObject = Record<string, unknown>;
64
+ type AirJamAgentContractPayloadKind = AirJamAgentActionPayloadKind;
65
+ type AirJamAgentContractPayloadMetadata = AirJamAgentActionPayloadMetadata;
66
+ type AirJamAgentStoreDeclaration<TStore extends object = object> = {
67
+ readonly __store?: TStore;
68
+ };
69
+ type AirJamAgentStoreDeclarations = Record<string, AirJamAgentStoreDeclaration<object>>;
70
+ type AirJamAgentActionTarget = {
71
+ kind: "participant" | "host";
72
+ actionName: string;
73
+ storeDomain?: string;
74
+ };
75
+ type AirJamAgentStores = Record<string, object>;
76
+ type InferAirJamAgentStores<TDeclarations extends AirJamAgentStoreDeclarations> = {
77
+ [TKey in keyof TDeclarations]: TDeclarations[TKey] extends AirJamAgentStoreDeclaration<infer TStore> ? TStore : never;
78
+ };
79
+ type AirJamAgentActionContractBase = {
80
+ target: AirJamAgentActionTarget;
81
+ description?: string;
82
+ availability?: string;
83
+ /**
84
+ * Human and agent-facing description of the expected semantic effect.
85
+ * This does not automatically become runtime result data; return
86
+ * `acceptAirJamAction(result)` from the underlying store action when callers
87
+ * need an actual result payload.
88
+ */
89
+ resultDescription?: string;
90
+ };
91
+ type AirJamAgentResolvedActionContract<TInput = unknown, TPayload = TInput> = AirJamAgentActionContractBase & {
92
+ input: AirJamAgentActionInputDefinition<TInput>;
93
+ toPayload?: (input: TInput) => TPayload;
94
+ };
95
+ type AirJamAgentActionContract = AirJamAgentResolvedActionContract<any, any>;
96
+ type AnyAirJamAgentContract = AirJamAgentContract<any, any>;
97
+ type AirJamAgentContractActionOptions<TInput, TPayload = TInput> = AirJamAgentActionOptions & {
98
+ availability?: string;
99
+ input: AirJamAgentActionInputDefinition<TInput>;
100
+ toPayload?: (input: TInput) => TPayload;
101
+ };
102
+ type AirJamAgentSnapshotContext<TStores extends AirJamAgentStores = AirJamAgentStores> = {
103
+ controllerId: string | null;
104
+ stores: Partial<TStores>;
105
+ };
106
+ type AirJamAgentContract<TSnapshot extends AirJamAgentJsonObject = AirJamAgentJsonObject, TStoreDeclarations extends AirJamAgentStoreDeclarations = AirJamAgentStoreDeclarations> = {
107
+ stores: TStoreDeclarations;
108
+ snapshotDescription?: string;
109
+ projectSnapshot: (context: AirJamAgentSnapshotContext<InferAirJamAgentStores<TStoreDeclarations>>) => TSnapshot | Promise<TSnapshot>;
110
+ actions: Record<string, AirJamAgentActionContract>;
111
+ };
112
+ declare const agentStore: <TStore extends object>() => AirJamAgentStoreDeclaration<TStore>;
113
+ declare const defineAirJamAgentStores: <TDeclarations extends AirJamAgentStoreDeclarations>(stores: TDeclarations) => TDeclarations;
114
+ declare const listAirJamAgentStoreDomains: (contract: AnyAirJamAgentContract) => string[];
115
+ declare const describeAirJamAgentAction: (action: AirJamAgentActionContract) => AirJamAgentActionMetadata;
116
+ declare const resolveAirJamAgentActionPayload: (action: AirJamAgentActionContract, payload: unknown, meta: AirJamAgentActionParseMeta) => unknown;
117
+ declare const agentAction: {
118
+ participant: <TInput, TPayload = TInput>(target: Omit<AirJamAgentActionTarget, "kind">, options: AirJamAgentContractActionOptions<TInput, TPayload>) => AirJamAgentResolvedActionContract<TInput, TPayload>;
119
+ host: <TInput, TPayload = TInput>(target: Omit<AirJamAgentActionTarget, "kind">, options: AirJamAgentContractActionOptions<TInput, TPayload>) => AirJamAgentResolvedActionContract<TInput, TPayload>;
120
+ };
121
+ declare const defineAirJamAgentContract: <TSnapshot extends AirJamAgentJsonObject, TStoreDeclarations extends AirJamAgentStoreDeclarations>(contract: AirJamAgentContract<TSnapshot, TStoreDeclarations>) => AirJamAgentContract<TSnapshot, TStoreDeclarations>;
122
+
123
+ export { type AirJamAgentContract as A, type AirJamAgentActionInputDefinition as B, type AirJamAgentActionMetadata as C, type AirJamAgentActionParseMeta as D, describeAirJamAgentAction as E, listAirJamAgentStoreDomains as F, resolveAirJamAgentActionPayload as G, type InferAirJamAgentActionInputPayload as I, agentActionInput as a, type AirJamAgentActionCustomOptions as b, type AirJamAgentActionOptions as c, type AirJamAgentActionPayloadKind as d, type AirJamAgentActionPayloadMetadata as e, agentAction as f, agentStore as g, defineAirJamAgentContract as h, defineAirJamAgentStores as i, type AirJamAgentActionContract as j, type AirJamAgentActionTarget as k, type AirJamAgentContractActionOptions as l, type AirJamAgentContractPayloadKind as m, type AirJamAgentContractPayloadMetadata as n, type AirJamAgentJsonObject as o, type AirJamAgentResolvedActionContract as p, type AirJamAgentSnapshotContext as q, type AirJamAgentStoreDeclaration as r, type AirJamAgentStoreDeclarations as s, type AirJamAgentStores as t, type AnyAirJamAgentContract as u, type InferAirJamAgentStores as v, createAgentActionMetadata as w, defineAgentActionInput as x, describeAgentActionInputs as y, type AirJamAgentActionDescriptor as z };
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/agent-tooling.ts
21
+ var agent_tooling_exports = {};
22
+ __export(agent_tooling_exports, {
23
+ createAgentActionMetadata: () => createAgentActionMetadata,
24
+ defineAgentActionInput: () => defineAgentActionInput,
25
+ describeAgentActionInputs: () => describeAgentActionInputs,
26
+ describeAirJamAgentAction: () => describeAirJamAgentAction,
27
+ listAirJamAgentStoreDomains: () => listAirJamAgentStoreDomains,
28
+ resolveAirJamAgentActionPayload: () => resolveAirJamAgentActionPayload
29
+ });
30
+ module.exports = __toCommonJS(agent_tooling_exports);
31
+
32
+ // src/agent/agent-action.ts
33
+ var createAgentActionMetadata = (payload, options) => ({
34
+ description: options?.description,
35
+ payload: {
36
+ ...payload,
37
+ description: options?.payloadDescription ?? payload.description
38
+ },
39
+ resultDescription: options?.resultDescription
40
+ });
41
+ var defineAgentActionInput = (parse, metadata) => ({
42
+ parse,
43
+ metadata
44
+ });
45
+ var describeAgentActionInputs = (actions) => Object.entries(actions).map(([name, definition]) => {
46
+ const metadata = definition.metadata;
47
+ return {
48
+ name,
49
+ description: metadata?.description ?? null,
50
+ payload: {
51
+ kind: metadata?.payload.kind ?? "json",
52
+ description: metadata?.payload.description ?? null,
53
+ ...metadata?.payload.allowedValues ? {
54
+ allowedValues: [...metadata.payload.allowedValues]
55
+ } : {}
56
+ },
57
+ resultDescription: metadata?.resultDescription ?? null
58
+ };
59
+ }).sort((left, right) => left.name.localeCompare(right.name));
60
+
61
+ // src/agent/agent-contract.ts
62
+ var listAirJamAgentStoreDomains = (contract) => Object.keys(contract.stores);
63
+ var describeAirJamAgentAction = (action) => ({
64
+ description: action.description ?? action.input.metadata.description,
65
+ payload: {
66
+ ...action.input.metadata.payload
67
+ },
68
+ resultDescription: action.resultDescription ?? action.input.metadata.resultDescription
69
+ });
70
+ var resolveAirJamAgentActionPayload = (action, payload, meta) => {
71
+ const parsedInput = action.input.parse(payload, meta);
72
+ return action.toPayload ? action.toPayload(parsedInput) : parsedInput;
73
+ };
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ createAgentActionMetadata,
77
+ defineAgentActionInput,
78
+ describeAgentActionInputs,
79
+ describeAirJamAgentAction,
80
+ listAirJamAgentStoreDomains,
81
+ resolveAirJamAgentActionPayload
82
+ });
83
+ //# sourceMappingURL=agent-tooling.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/agent-tooling.ts","../src/agent/agent-action.ts","../src/agent/agent-contract.ts"],"sourcesContent":["export {\n createAgentActionMetadata,\n defineAgentActionInput,\n describeAgentActionInputs,\n type AirJamAgentActionDescriptor,\n type AirJamAgentActionInputDefinition,\n type AirJamAgentActionMetadata,\n type AirJamAgentActionOptions,\n type AirJamAgentActionParseMeta,\n type AirJamAgentActionPayloadKind,\n type AirJamAgentActionPayloadMetadata,\n} from \"./agent/agent-action\";\nexport type { AirJamAgentActionCustomOptions } from \"./agent/agent-action\";\nexport {\n describeAirJamAgentAction,\n listAirJamAgentStoreDomains,\n resolveAirJamAgentActionPayload,\n type AirJamAgentActionContract,\n type AirJamAgentContract,\n} from \"./agent/agent-contract\";\n","import type { ZodType } from \"zod\";\n\nexport type AirJamAgentActionPayloadKind =\n | \"none\"\n | \"boolean\"\n | \"number\"\n | \"string\"\n | \"enum\"\n | \"json\";\n\nexport type AirJamAgentActionPayloadMetadata = {\n kind: AirJamAgentActionPayloadKind;\n description?: string;\n allowedValues?: string[];\n};\n\nexport type AirJamAgentActionMetadata = {\n description?: string;\n payload: AirJamAgentActionPayloadMetadata;\n resultDescription?: string;\n};\n\nexport type AirJamAgentActionDescriptor = {\n name: string;\n description: string | null;\n payload: {\n kind: AirJamAgentActionPayloadKind;\n description: string | null;\n allowedValues?: string[];\n };\n resultDescription: string | null;\n};\n\nexport type AirJamAgentActionParseMeta = {\n gameId: string;\n actionName: string;\n contractKind?: string;\n};\n\nexport type AirJamAgentActionInputDefinition<TPayload = unknown> = {\n parse: (payload: unknown, meta: AirJamAgentActionParseMeta) => TPayload;\n metadata: AirJamAgentActionMetadata;\n};\n\nexport type InferAirJamAgentActionInputPayload<TInput> =\n TInput extends AirJamAgentActionInputDefinition<infer TPayload>\n ? TPayload\n : never;\n\nexport type AirJamAgentActionOptions = {\n description?: string;\n payloadDescription?: string;\n resultDescription?: string;\n};\n\nexport type AirJamAgentActionCustomOptions = AirJamAgentActionOptions & {\n payloadKind?: AirJamAgentActionPayloadKind;\n allowedValues?: string[];\n};\n\nconst createActionError = (\n meta: AirJamAgentActionParseMeta,\n message: string,\n): Error =>\n new Error(\n `[${meta.contractKind ?? \"action\"}:${meta.gameId}.${meta.actionName}] ${message}`,\n );\n\nexport const createAgentActionMetadata = (\n payload: AirJamAgentActionPayloadMetadata,\n options?: AirJamAgentActionOptions,\n): AirJamAgentActionMetadata => ({\n description: options?.description,\n payload: {\n ...payload,\n description: options?.payloadDescription ?? payload.description,\n },\n resultDescription: options?.resultDescription,\n});\n\nexport const defineAgentActionInput = <TPayload>(\n parse: (payload: unknown, meta: AirJamAgentActionParseMeta) => TPayload,\n metadata: AirJamAgentActionMetadata,\n): AirJamAgentActionInputDefinition<TPayload> => ({\n parse,\n metadata,\n});\n\nconst parseFiniteNumber = (\n payload: unknown,\n meta: AirJamAgentActionParseMeta,\n): number => {\n const nextValue =\n typeof payload === \"number\" && Number.isFinite(payload)\n ? payload\n : typeof payload === \"string\"\n ? Number(payload)\n : Number.NaN;\n\n if (!Number.isFinite(nextValue)) {\n throw createActionError(meta, \"expected a finite number payload\");\n }\n\n return nextValue;\n};\n\nconst parseStringValue = (\n payload: unknown,\n meta: AirJamAgentActionParseMeta,\n): string => {\n if (typeof payload !== \"string\") {\n throw createActionError(meta, \"expected a string payload\");\n }\n\n return payload;\n};\n\nconst parseBooleanValue = (\n payload: unknown,\n meta: AirJamAgentActionParseMeta,\n): boolean => {\n if (typeof payload === \"boolean\") {\n return payload;\n }\n\n if (payload === \"true\" || payload === \"1\") {\n return true;\n }\n\n if (payload === \"false\" || payload === \"0\") {\n return false;\n }\n\n throw createActionError(meta, \"expected a boolean payload\");\n};\n\nconst parseEnumValue = <const TValues extends readonly string[]>(\n values: TValues,\n payload: unknown,\n meta: AirJamAgentActionParseMeta,\n): TValues[number] => {\n if (typeof payload !== \"string\" || !values.includes(payload)) {\n throw createActionError(meta, `expected one of: ${values.join(\", \")}`);\n }\n\n return payload as TValues[number];\n};\n\ntype AirJamAgentActionCustomParser<TPayload> = (\n payload: unknown,\n meta: AirJamAgentActionParseMeta,\n) => TPayload;\n\ntype AirJamAgentActionZodSchema<TPayload> = ZodType<TPayload>;\n\nconst noneInput = (\n options?: AirJamAgentActionOptions,\n): AirJamAgentActionInputDefinition<void> =>\n defineAgentActionInput(\n () => undefined,\n createAgentActionMetadata({ kind: \"none\" }, options),\n );\n\nconst numberInput = (\n options?: AirJamAgentActionOptions,\n): AirJamAgentActionInputDefinition<number> =>\n defineAgentActionInput(\n parseFiniteNumber,\n createAgentActionMetadata({ kind: \"number\" }, options),\n );\n\nconst stringInput = (\n options?: AirJamAgentActionOptions,\n): AirJamAgentActionInputDefinition<string> =>\n defineAgentActionInput(\n parseStringValue,\n createAgentActionMetadata({ kind: \"string\" }, options),\n );\n\nconst booleanInput = (\n options?: AirJamAgentActionOptions,\n): AirJamAgentActionInputDefinition<boolean> =>\n defineAgentActionInput(\n parseBooleanValue,\n createAgentActionMetadata({ kind: \"boolean\" }, options),\n );\n\nconst enumInput = <const TValues extends readonly string[]>(\n values: TValues,\n options?: AirJamAgentActionOptions,\n): AirJamAgentActionInputDefinition<TValues[number]> =>\n defineAgentActionInput(\n (payload, meta) => parseEnumValue(values, payload, meta),\n createAgentActionMetadata(\n {\n kind: \"enum\",\n allowedValues: [...values],\n },\n options,\n ),\n );\n\nconst jsonInput = (\n options?: AirJamAgentActionOptions,\n): AirJamAgentActionInputDefinition<unknown> =>\n defineAgentActionInput(\n (payload) => payload,\n createAgentActionMetadata({ kind: \"json\" }, options),\n );\n\nfunction customInput<TPayload>(\n parse: AirJamAgentActionCustomParser<TPayload>,\n): AirJamAgentActionInputDefinition<TPayload>;\nfunction customInput<TPayload>(\n options: AirJamAgentActionCustomOptions,\n parse: AirJamAgentActionCustomParser<TPayload>,\n): AirJamAgentActionInputDefinition<TPayload>;\nfunction customInput<TPayload>(\n optionsOrParse:\n | AirJamAgentActionCustomOptions\n | AirJamAgentActionCustomParser<TPayload>,\n maybeParse?: AirJamAgentActionCustomParser<TPayload>,\n): AirJamAgentActionInputDefinition<TPayload> {\n if (typeof optionsOrParse === \"function\") {\n return defineAgentActionInput(\n optionsOrParse,\n createAgentActionMetadata({ kind: \"json\" }),\n );\n }\n\n if (typeof maybeParse === \"function\") {\n return defineAgentActionInput(\n maybeParse,\n createAgentActionMetadata(\n {\n kind: optionsOrParse.payloadKind ?? \"json\",\n allowedValues: optionsOrParse.allowedValues,\n },\n optionsOrParse,\n ),\n );\n }\n\n throw new Error(\"Invalid agent action input definition.\");\n}\n\nconst zodInput = <TPayload>(\n schema: AirJamAgentActionZodSchema<TPayload>,\n options?: AirJamAgentActionOptions,\n): AirJamAgentActionInputDefinition<TPayload> =>\n defineAgentActionInput(\n (payload, meta) => {\n const result = schema.safeParse(payload);\n if (result.success) {\n return result.data;\n }\n\n const firstIssue = result.error.issues[0];\n throw createActionError(\n meta,\n firstIssue?.message ?? \"payload failed schema validation\",\n );\n },\n createAgentActionMetadata({ kind: \"json\" }, options),\n );\n\nexport const agentActionInput = {\n none: noneInput,\n number: numberInput,\n string: stringInput,\n boolean: booleanInput,\n enum: enumInput,\n json: jsonInput,\n custom: customInput,\n zod: zodInput,\n};\n\nexport const describeAgentActionInputs = <\n TActions extends Record<\n string,\n { metadata?: AirJamAgentActionMetadata | undefined }\n >,\n>(\n actions: TActions,\n): AirJamAgentActionDescriptor[] =>\n Object.entries(actions)\n .map(([name, definition]) => {\n const metadata = definition.metadata;\n return {\n name,\n description: metadata?.description ?? null,\n payload: {\n kind: metadata?.payload.kind ?? \"json\",\n description: metadata?.payload.description ?? null,\n ...(metadata?.payload.allowedValues\n ? {\n allowedValues: [...metadata.payload.allowedValues],\n }\n : {}),\n },\n resultDescription: metadata?.resultDescription ?? null,\n };\n })\n .sort((left, right) => left.name.localeCompare(right.name));\n","import {\n type AirJamAgentActionInputDefinition,\n type AirJamAgentActionMetadata,\n type AirJamAgentActionOptions,\n type AirJamAgentActionParseMeta,\n type AirJamAgentActionPayloadKind,\n type AirJamAgentActionPayloadMetadata,\n} from \"./agent-action.js\";\n\nexport type AirJamAgentJsonObject = Record<string, unknown>;\n\nexport type AirJamAgentContractPayloadKind = AirJamAgentActionPayloadKind;\n\nexport type AirJamAgentContractPayloadMetadata =\n AirJamAgentActionPayloadMetadata;\n\nexport type AirJamAgentStoreDeclaration<TStore extends object = object> = {\n readonly __store?: TStore;\n};\n\nexport type AirJamAgentStoreDeclarations = Record<\n string,\n AirJamAgentStoreDeclaration<object>\n>;\n\nexport type AirJamAgentActionTarget = {\n kind: \"participant\" | \"host\";\n actionName: string;\n storeDomain?: string;\n};\n\nexport type AirJamAgentStores = Record<string, object>;\n\nexport type InferAirJamAgentStores<\n TDeclarations extends AirJamAgentStoreDeclarations,\n> = {\n [TKey in keyof TDeclarations]: TDeclarations[TKey] extends AirJamAgentStoreDeclaration<\n infer TStore\n >\n ? TStore\n : never;\n};\n\ntype AirJamAgentActionContractBase = {\n target: AirJamAgentActionTarget;\n description?: string;\n availability?: string;\n /**\n * Human and agent-facing description of the expected semantic effect.\n * This does not automatically become runtime result data; return\n * `acceptAirJamAction(result)` from the underlying store action when callers\n * need an actual result payload.\n */\n resultDescription?: string;\n};\n\nexport type AirJamAgentResolvedActionContract<\n TInput = unknown,\n TPayload = TInput,\n> = AirJamAgentActionContractBase & {\n input: AirJamAgentActionInputDefinition<TInput>;\n toPayload?: (input: TInput) => TPayload;\n};\n\n// Existential wildcard for heterogenous action contracts.\n/* eslint-disable @typescript-eslint/no-explicit-any -- These aliases intentionally erase generic action and store shapes at contract boundaries. */\nexport type AirJamAgentActionContract = AirJamAgentResolvedActionContract<\n any,\n any\n>;\n\n// Existential wildcard for published agent contracts with arbitrary snapshot/store shapes.\nexport type AnyAirJamAgentContract = AirJamAgentContract<any, any>;\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\nexport type AirJamAgentContractActionOptions<\n TInput,\n TPayload = TInput,\n> = AirJamAgentActionOptions & {\n availability?: string;\n input: AirJamAgentActionInputDefinition<TInput>;\n toPayload?: (input: TInput) => TPayload;\n};\n\nexport type AirJamAgentSnapshotContext<\n TStores extends AirJamAgentStores = AirJamAgentStores,\n> = {\n controllerId: string | null;\n stores: Partial<TStores>;\n};\n\nexport type AirJamAgentContract<\n TSnapshot extends AirJamAgentJsonObject = AirJamAgentJsonObject,\n TStoreDeclarations extends AirJamAgentStoreDeclarations =\n AirJamAgentStoreDeclarations,\n> = {\n stores: TStoreDeclarations;\n snapshotDescription?: string;\n projectSnapshot: (\n context: AirJamAgentSnapshotContext<\n InferAirJamAgentStores<TStoreDeclarations>\n >,\n ) => TSnapshot | Promise<TSnapshot>;\n actions: Record<string, AirJamAgentActionContract>;\n};\n\nexport const agentStore = <\n TStore extends object,\n>(): AirJamAgentStoreDeclaration<TStore> =>\n ({}) as AirJamAgentStoreDeclaration<TStore>;\n\nexport const defineAirJamAgentStores = <\n TDeclarations extends AirJamAgentStoreDeclarations,\n>(\n stores: TDeclarations,\n): TDeclarations => stores;\n\nexport const listAirJamAgentStoreDomains = (\n contract: AnyAirJamAgentContract,\n): string[] => Object.keys(contract.stores);\n\nexport const describeAirJamAgentAction = (\n action: AirJamAgentActionContract,\n): AirJamAgentActionMetadata => ({\n description: action.description ?? action.input.metadata.description,\n payload: {\n ...action.input.metadata.payload,\n },\n resultDescription:\n action.resultDescription ?? action.input.metadata.resultDescription,\n});\n\nexport const resolveAirJamAgentActionPayload = (\n action: AirJamAgentActionContract,\n payload: unknown,\n meta: AirJamAgentActionParseMeta,\n): unknown => {\n const parsedInput = action.input.parse(payload, meta);\n return action.toPayload ? action.toPayload(parsedInput) : parsedInput;\n};\n\nexport const agentAction = {\n participant: <TInput, TPayload = TInput>(\n target: Omit<AirJamAgentActionTarget, \"kind\">,\n options: AirJamAgentContractActionOptions<TInput, TPayload>,\n ): AirJamAgentResolvedActionContract<TInput, TPayload> => ({\n target: {\n kind: \"participant\",\n actionName: target.actionName,\n ...(target.storeDomain ? { storeDomain: target.storeDomain } : {}),\n },\n description: options.description,\n availability: options.availability,\n input: options.input,\n toPayload: options.toPayload,\n resultDescription: options.resultDescription,\n }),\n host: <TInput, TPayload = TInput>(\n target: Omit<AirJamAgentActionTarget, \"kind\">,\n options: AirJamAgentContractActionOptions<TInput, TPayload>,\n ): AirJamAgentResolvedActionContract<TInput, TPayload> => ({\n target: {\n kind: \"host\",\n actionName: target.actionName,\n ...(target.storeDomain ? { storeDomain: target.storeDomain } : {}),\n },\n description: options.description,\n availability: options.availability,\n input: options.input,\n toPayload: options.toPayload,\n resultDescription: options.resultDescription,\n }),\n};\n\nexport const defineAirJamAgentContract = <\n TSnapshot extends AirJamAgentJsonObject,\n TStoreDeclarations extends AirJamAgentStoreDeclarations,\n>(\n contract: AirJamAgentContract<TSnapshot, TStoreDeclarations>,\n): AirJamAgentContract<TSnapshot, TStoreDeclarations> => contract;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACoEO,IAAM,4BAA4B,CACvC,SACA,aAC+B;AAAA,EAC/B,aAAa,SAAS;AAAA,EACtB,SAAS;AAAA,IACP,GAAG;AAAA,IACH,aAAa,SAAS,sBAAsB,QAAQ;AAAA,EACtD;AAAA,EACA,mBAAmB,SAAS;AAC9B;AAEO,IAAM,yBAAyB,CACpC,OACA,cACgD;AAAA,EAChD;AAAA,EACA;AACF;AA+LO,IAAM,4BAA4B,CAMvC,YAEA,OAAO,QAAQ,OAAO,EACnB,IAAI,CAAC,CAAC,MAAM,UAAU,MAAM;AAC3B,QAAM,WAAW,WAAW;AAC5B,SAAO;AAAA,IACL;AAAA,IACA,aAAa,UAAU,eAAe;AAAA,IACtC,SAAS;AAAA,MACP,MAAM,UAAU,QAAQ,QAAQ;AAAA,MAChC,aAAa,UAAU,QAAQ,eAAe;AAAA,MAC9C,GAAI,UAAU,QAAQ,gBAClB;AAAA,QACE,eAAe,CAAC,GAAG,SAAS,QAAQ,aAAa;AAAA,MACnD,IACA,CAAC;AAAA,IACP;AAAA,IACA,mBAAmB,UAAU,qBAAqB;AAAA,EACpD;AACF,CAAC,EACA,KAAK,CAAC,MAAM,UAAU,KAAK,KAAK,cAAc,MAAM,IAAI,CAAC;;;AC1LvD,IAAM,8BAA8B,CACzC,aACa,OAAO,KAAK,SAAS,MAAM;AAEnC,IAAM,4BAA4B,CACvC,YAC+B;AAAA,EAC/B,aAAa,OAAO,eAAe,OAAO,MAAM,SAAS;AAAA,EACzD,SAAS;AAAA,IACP,GAAG,OAAO,MAAM,SAAS;AAAA,EAC3B;AAAA,EACA,mBACE,OAAO,qBAAqB,OAAO,MAAM,SAAS;AACtD;AAEO,IAAM,kCAAkC,CAC7C,QACA,SACA,SACY;AACZ,QAAM,cAAc,OAAO,MAAM,MAAM,SAAS,IAAI;AACpD,SAAO,OAAO,YAAY,OAAO,UAAU,WAAW,IAAI;AAC5D;","names":[]}
@@ -0,0 +1,2 @@
1
+ export { j as AirJamAgentActionContract, b as AirJamAgentActionCustomOptions, z as AirJamAgentActionDescriptor, B as AirJamAgentActionInputDefinition, C as AirJamAgentActionMetadata, c as AirJamAgentActionOptions, D as AirJamAgentActionParseMeta, d as AirJamAgentActionPayloadKind, e as AirJamAgentActionPayloadMetadata, A as AirJamAgentContract, w as createAgentActionMetadata, x as defineAgentActionInput, y as describeAgentActionInputs, E as describeAirJamAgentAction, F as listAirJamAgentStoreDomains, G as resolveAirJamAgentActionPayload } from './agent-tooling-BSMGBix9.cjs';
2
+ import 'zod';
@@ -0,0 +1,2 @@
1
+ export { j as AirJamAgentActionContract, b as AirJamAgentActionCustomOptions, z as AirJamAgentActionDescriptor, B as AirJamAgentActionInputDefinition, C as AirJamAgentActionMetadata, c as AirJamAgentActionOptions, D as AirJamAgentActionParseMeta, d as AirJamAgentActionPayloadKind, e as AirJamAgentActionPayloadMetadata, A as AirJamAgentContract, w as createAgentActionMetadata, x as defineAgentActionInput, y as describeAgentActionInputs, E as describeAirJamAgentAction, F as listAirJamAgentStoreDomains, G as resolveAirJamAgentActionPayload } from './agent-tooling-BSMGBix9.js';
2
+ import 'zod';
@@ -0,0 +1,17 @@
1
+ import {
2
+ createAgentActionMetadata,
3
+ defineAgentActionInput,
4
+ describeAgentActionInputs,
5
+ describeAirJamAgentAction,
6
+ listAirJamAgentStoreDomains,
7
+ resolveAirJamAgentActionPayload
8
+ } from "./chunk-TGRTEWYV.js";
9
+ export {
10
+ createAgentActionMetadata,
11
+ defineAgentActionInput,
12
+ describeAgentActionInputs,
13
+ describeAirJamAgentAction,
14
+ listAirJamAgentStoreDomains,
15
+ resolveAirJamAgentActionPayload
16
+ };
17
+ //# sourceMappingURL=agent-tooling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}