@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.
- package/LICENSE +21 -0
- package/README.md +627 -57
- package/dist/agent-tooling-BSMGBix9.d.cts +123 -0
- package/dist/agent-tooling-BSMGBix9.d.ts +123 -0
- package/dist/agent-tooling.cjs +83 -0
- package/dist/agent-tooling.cjs.map +1 -0
- package/dist/agent-tooling.d.cts +2 -0
- package/dist/agent-tooling.d.ts +2 -0
- package/dist/agent-tooling.js +17 -0
- package/dist/agent-tooling.js.map +1 -0
- package/dist/arcade/bridge/controller.cjs +749 -0
- package/dist/arcade/bridge/controller.cjs.map +1 -0
- package/dist/arcade/bridge/controller.d.cts +85 -0
- package/dist/arcade/bridge/controller.d.ts +85 -0
- package/dist/arcade/bridge/controller.js +33 -0
- package/dist/arcade/bridge/controller.js.map +1 -0
- package/dist/arcade/bridge/host.cjs +421 -0
- package/dist/arcade/bridge/host.cjs.map +1 -0
- package/dist/arcade/bridge/host.d.cts +73 -0
- package/dist/arcade/bridge/host.d.ts +73 -0
- package/dist/arcade/bridge/host.js +25 -0
- package/dist/arcade/bridge/host.js.map +1 -0
- package/dist/arcade/bridge/iframe.cjs +453 -0
- package/dist/arcade/bridge/iframe.cjs.map +1 -0
- package/dist/arcade/bridge/iframe.d.cts +80 -0
- package/dist/arcade/bridge/iframe.d.ts +80 -0
- package/dist/arcade/bridge/iframe.js +28 -0
- package/dist/arcade/bridge/iframe.js.map +1 -0
- package/dist/arcade/bridge.cjs +1067 -0
- package/dist/arcade/bridge.cjs.map +1 -0
- package/dist/arcade/bridge.d.cts +11 -0
- package/dist/arcade/bridge.d.ts +11 -0
- package/dist/arcade/bridge.js +76 -0
- package/dist/arcade/bridge.js.map +1 -0
- package/dist/arcade/host.cjs +481 -0
- package/dist/arcade/host.cjs.map +1 -0
- package/dist/arcade/host.d.cts +19 -0
- package/dist/arcade/host.d.ts +19 -0
- package/dist/arcade/host.js +14 -0
- package/dist/arcade/host.js.map +1 -0
- package/dist/arcade/surface.cjs +113 -0
- package/dist/arcade/surface.cjs.map +1 -0
- package/dist/arcade/surface.d.cts +14 -0
- package/dist/arcade/surface.d.ts +14 -0
- package/dist/arcade/surface.js +27 -0
- package/dist/arcade/surface.js.map +1 -0
- package/dist/arcade/url.cjs +544 -0
- package/dist/arcade/url.cjs.map +1 -0
- package/dist/arcade/url.d.cts +68 -0
- package/dist/arcade/url.d.ts +68 -0
- package/dist/arcade/url.js +29 -0
- package/dist/arcade/url.js.map +1 -0
- package/dist/arcade-runtime-url-BW-MUAOY.d.cts +28 -0
- package/dist/arcade-runtime-url-l8qj01Pg.d.ts +28 -0
- package/dist/arcade-surface-identity-CQxDpn_w.d.cts +16 -0
- package/dist/arcade-surface-identity-CQxDpn_w.d.ts +16 -0
- package/dist/arcade.cjs +1737 -0
- package/dist/arcade.cjs.map +1 -0
- package/dist/arcade.d.cts +18 -0
- package/dist/arcade.d.ts +18 -0
- package/dist/arcade.js +123 -0
- package/dist/arcade.js.map +1 -0
- package/dist/capabilities.cjs +39 -0
- package/dist/capabilities.cjs.map +1 -0
- package/dist/capabilities.d.cts +31 -0
- package/dist/capabilities.d.ts +31 -0
- package/dist/capabilities.js +12 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/chunk-32NYL7XI.js +539 -0
- package/dist/chunk-32NYL7XI.js.map +1 -0
- package/dist/chunk-3USU7GY2.js +54 -0
- package/dist/chunk-3USU7GY2.js.map +1 -0
- package/dist/chunk-7UXSWCZZ.js +32 -0
- package/dist/chunk-7UXSWCZZ.js.map +1 -0
- package/dist/chunk-BE6Z4SIT.js +65 -0
- package/dist/chunk-BE6Z4SIT.js.map +1 -0
- package/dist/chunk-CABEUV65.js +184 -0
- package/dist/chunk-CABEUV65.js.map +1 -0
- package/dist/chunk-CEJ5RFSG.js +288 -0
- package/dist/chunk-CEJ5RFSG.js.map +1 -0
- package/dist/chunk-EDRQIOCV.js +25 -0
- package/dist/chunk-EDRQIOCV.js.map +1 -0
- package/dist/chunk-EVZJA6RN.js +140 -0
- package/dist/chunk-EVZJA6RN.js.map +1 -0
- package/dist/chunk-FAT2KJ3K.js +238 -0
- package/dist/chunk-FAT2KJ3K.js.map +1 -0
- package/dist/chunk-IKKDONQL.js +1 -0
- package/dist/chunk-IKKDONQL.js.map +1 -0
- package/dist/chunk-JEHV5C2X.js +249 -0
- package/dist/chunk-JEHV5C2X.js.map +1 -0
- package/dist/chunk-JO2HR5PV.js +43 -0
- package/dist/chunk-JO2HR5PV.js.map +1 -0
- package/dist/chunk-JTF47B56.js +1 -0
- package/dist/chunk-JTF47B56.js.map +1 -0
- package/dist/chunk-KXAFI5OP.js +193 -0
- package/dist/chunk-KXAFI5OP.js.map +1 -0
- package/dist/chunk-LIXPF4P6.js +22 -0
- package/dist/chunk-LIXPF4P6.js.map +1 -0
- package/dist/chunk-MPDMJIX5.js +1 -0
- package/dist/chunk-MPDMJIX5.js.map +1 -0
- package/dist/chunk-NCL6WJCL.js +91 -0
- package/dist/chunk-NCL6WJCL.js.map +1 -0
- package/dist/chunk-NUJBMV3O.js +1435 -0
- package/dist/chunk-NUJBMV3O.js.map +1 -0
- package/dist/chunk-TGRTEWYV.js +195 -0
- package/dist/chunk-TGRTEWYV.js.map +1 -0
- package/dist/chunk-UWJOIVON.js +369 -0
- package/dist/chunk-UWJOIVON.js.map +1 -0
- package/dist/chunk-VKBMZHMQ.js +216 -0
- package/dist/chunk-VKBMZHMQ.js.map +1 -0
- package/dist/chunk-W2VK36RO.js +11 -0
- package/dist/chunk-W2VK36RO.js.map +1 -0
- package/dist/chunk-W3YA5BWR.js +126 -0
- package/dist/chunk-W3YA5BWR.js.map +1 -0
- package/dist/chunk-X24K52DG.js +12 -0
- package/dist/chunk-X24K52DG.js.map +1 -0
- package/dist/chunk-YXHH3MQT.js +230 -0
- package/dist/chunk-YXHH3MQT.js.map +1 -0
- package/dist/chunk-ZLPL2R3R.js +183 -0
- package/dist/chunk-ZLPL2R3R.js.map +1 -0
- package/dist/chunk-ZTQ5SP4H.js +9 -0
- package/dist/chunk-ZTQ5SP4H.js.map +1 -0
- package/dist/controller-Bod8YYr1.d.cts +172 -0
- package/dist/controller-DxVchfiA.d.ts +172 -0
- package/dist/dev-log-events-CVAM29hx.d.cts +123 -0
- package/dist/dev-log-events-CVAM29hx.d.ts +123 -0
- package/dist/handshake-CC_LrK5g.d.cts +31 -0
- package/dist/handshake-CC_LrK5g.d.ts +31 -0
- package/dist/host-8hmq_Sgc.d.cts +109 -0
- package/dist/host-Cw-N6e-5.d.ts +109 -0
- package/dist/index.cjs +8730 -3426
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +676 -1070
- package/dist/index.d.ts +676 -1070
- package/dist/index.js +4892 -3196
- package/dist/index.js.map +1 -1
- package/dist/metadata.cjs +114 -0
- package/dist/metadata.cjs.map +1 -0
- package/dist/metadata.d.cts +95 -0
- package/dist/metadata.d.ts +95 -0
- package/dist/metadata.js +83 -0
- package/dist/metadata.js.map +1 -0
- package/dist/notices-CnGaaS8B.d.ts +38 -0
- package/dist/notices-NyDM5Mtz.d.cts +38 -0
- package/dist/platform-machine.cjs +425 -0
- package/dist/platform-machine.cjs.map +1 -0
- package/dist/platform-machine.d.cts +1183 -0
- package/dist/platform-machine.d.ts +1183 -0
- package/dist/platform-machine.js +309 -0
- package/dist/platform-machine.js.map +1 -0
- package/dist/platform-settings-cuor3i11.d.cts +48 -0
- package/dist/platform-settings-cuor3i11.d.ts +48 -0
- package/dist/prefabs.cjs +36 -0
- package/dist/prefabs.cjs.map +1 -0
- package/dist/prefabs.d.cts +49 -0
- package/dist/prefabs.d.ts +49 -0
- package/dist/prefabs.js +8 -0
- package/dist/prefabs.js.map +1 -0
- package/dist/preview.cjs +2620 -0
- package/dist/preview.cjs.map +1 -0
- package/dist/preview.d.cts +155 -0
- package/dist/preview.d.ts +155 -0
- package/dist/preview.js +1671 -0
- package/dist/preview.js.map +1 -0
- package/dist/protocol.cjs +621 -54
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +76 -240
- package/dist/protocol.d.ts +76 -240
- package/dist/protocol.js +100 -2
- package/dist/protocol.js.map +1 -1
- package/dist/realtime-client-Cu8yVJFw.d.cts +15 -0
- package/dist/realtime-client-Cu8yVJFw.d.ts +15 -0
- package/dist/release.cjs +143 -0
- package/dist/release.cjs.map +1 -0
- package/dist/release.d.cts +64 -0
- package/dist/release.d.ts +64 -0
- package/dist/release.js +43 -0
- package/dist/release.js.map +1 -0
- package/dist/runtime-topology.cjs +405 -0
- package/dist/runtime-topology.cjs.map +1 -0
- package/dist/runtime-topology.d.cts +59 -0
- package/dist/runtime-topology.d.ts +59 -0
- package/dist/runtime-topology.js +31 -0
- package/dist/runtime-topology.js.map +1 -0
- package/dist/standard-match-phase-BucA5dYo.d.ts +44 -0
- package/dist/standard-match-phase-U2ra8J-0.d.cts +44 -0
- package/dist/sync-B6QsNrXz.d.cts +125 -0
- package/dist/sync-B6QsNrXz.d.ts +125 -0
- package/dist/ui.cjs +3061 -0
- package/dist/ui.cjs.map +1 -0
- package/dist/ui.d.cts +320 -0
- package/dist/ui.d.ts +320 -0
- package/dist/ui.js +1719 -0
- package/dist/ui.js.map +1 -0
- package/dist/url-policy-C89zxgw9.d.cts +9 -0
- package/dist/url-policy-C89zxgw9.d.ts +9 -0
- package/package.json +155 -10
- package/src/agent/agent-action.ts +304 -0
- package/src/agent/agent-contract.ts +180 -0
- package/src/agent-tooling.ts +20 -0
- package/src/arcade/bridge/controller.ts +15 -0
- package/src/arcade/bridge/host.ts +12 -0
- package/src/arcade/bridge/iframe.ts +61 -0
- package/src/arcade/bridge.ts +3 -0
- package/src/arcade/host.ts +1 -0
- package/src/arcade/surface.ts +4 -0
- package/src/arcade/url.ts +60 -0
- package/src/arcade.ts +4 -0
- package/src/audio/audio-manager.ts +162 -171
- package/src/audio/hooks.tsx +218 -97
- package/src/audio/index.ts +1 -1
- package/src/audio/music.tsx +139 -0
- package/src/capabilities/manifest.ts +71 -0
- package/src/capabilities.ts +12 -0
- package/src/components/connection-status-pill.tsx +55 -0
- package/src/components/controller-player-name-field.tsx +119 -0
- package/src/components/controller-primary-action.tsx +58 -0
- package/src/components/host-mute-button.tsx +49 -0
- package/src/components/join-qr-overlay.tsx +133 -0
- package/src/components/join-url-action-buttons.tsx +95 -0
- package/src/components/join-url-controls.tsx +58 -0
- package/src/components/join-url-field.tsx +52 -0
- package/src/components/lifecycle-action-group.tsx +129 -0
- package/src/components/player-avatar-strip.tsx +65 -0
- package/src/components/player-avatar.tsx +42 -13
- package/src/components/room-qr-code.tsx +125 -0
- package/src/components/runtime-shell-header.tsx +37 -0
- package/src/components/shell-classes.ts +19 -0
- package/src/components/surface-orientation-layout.ts +60 -0
- package/src/components/surface-viewport-layout.ts +268 -0
- package/src/components/surface-viewport.tsx +314 -0
- package/src/components/ui/button.tsx +4 -6
- package/src/components/ui/slider.tsx +1 -1
- package/src/components/volume-controls.tsx +65 -6
- package/src/context/air-jam-context.tsx +209 -161
- package/src/context/index.ts +2 -2
- package/src/context/session-providers.tsx +77 -0
- package/src/context/session-scope.ts +64 -0
- package/src/context/socket-manager.ts +6 -24
- package/src/contracts/v2/bridge.ts +261 -0
- package/src/contracts/v2/handshake.ts +40 -0
- package/src/contracts/v2/index.ts +2 -0
- package/src/dev/browser-log-sink.ts +912 -0
- package/src/diagnostics.ts +128 -0
- package/src/events.ts +7 -34
- package/src/hooks/internal/use-controller-runtime-api.ts +875 -0
- package/src/hooks/internal/use-host-runtime-api.ts +1051 -0
- package/src/hooks/internal/use-runtime-control-contract.ts +15 -0
- package/src/hooks/internal/use-runtime-inspection-contract.ts +16 -0
- package/src/hooks/internal/use-runtime-observability-contract.ts +24 -0
- package/src/hooks/use-air-jam-controller.ts +155 -475
- package/src/hooks/use-air-jam-host.ts +156 -485
- package/src/hooks/use-connection-status.ts +8 -0
- package/src/hooks/use-controller-lifecycle-intents.ts +27 -0
- package/src/hooks/use-controller-lifecycle-permissions.ts +36 -0
- package/src/hooks/use-controller-shell-status.ts +40 -0
- package/src/hooks/use-controller-tick.ts +65 -0
- package/src/hooks/use-controller-toasts.ts +116 -0
- package/src/hooks/use-get-input.ts +8 -5
- package/src/hooks/use-host-arcade-restore.ts +30 -0
- package/src/hooks/use-host-join-controls.ts +152 -0
- package/src/hooks/use-host-tick.ts +171 -0
- package/src/hooks/use-input-writer.ts +83 -0
- package/src/hooks/use-lifecycle-action-group-model.ts +98 -0
- package/src/hooks/use-players.ts +12 -0
- package/src/hooks/use-room.ts +22 -0
- package/src/hooks/use-send-signal.ts +6 -2
- package/src/index.ts +205 -31
- package/src/internal/input-manager.ts +195 -215
- package/src/lifecycle/index.ts +9 -0
- package/src/lifecycle/standard-match-phase.ts +32 -0
- package/src/metadata/manifest.ts +152 -0
- package/src/metadata.ts +12 -0
- package/src/platform-machine.ts +475 -0
- package/src/prefabs/types.ts +82 -0
- package/src/prefabs.ts +12 -0
- package/src/preview/host-workspace.tsx +59 -0
- package/src/preview/identity.ts +66 -0
- package/src/preview/layout.ts +223 -0
- package/src/preview/manager.ts +577 -0
- package/src/preview/messages.ts +26 -0
- package/src/preview/ownership.ts +81 -0
- package/src/preview/url.ts +117 -0
- package/src/preview/window.tsx +490 -0
- package/src/preview/workspace.tsx +678 -0
- package/src/preview.ts +42 -0
- package/src/protocol/arcade-platform-actions.ts +29 -0
- package/src/protocol/controller.ts +187 -0
- package/src/protocol/core.ts +23 -0
- package/src/protocol/dev-log-events.ts +222 -0
- package/src/protocol/errors.ts +21 -0
- package/src/protocol/host-grant.ts +185 -0
- package/src/protocol/host.ts +138 -0
- package/src/protocol/notices.ts +43 -0
- package/src/protocol/signals.ts +38 -0
- package/src/protocol/socket-events.ts +154 -0
- package/src/protocol/sync.ts +121 -0
- package/src/protocol/url-policy.ts +63 -0
- package/src/protocol.ts +12 -386
- package/src/qrcode.d.ts +16 -0
- package/src/release.ts +99 -0
- package/src/runtime/air-jam-config.ts +287 -0
- package/src/runtime/air-jam-error-boundary.tsx +672 -0
- package/src/runtime/arcade-bridge-request-surface.ts +15 -0
- package/src/runtime/arcade-runtime-url.ts +95 -0
- package/src/runtime/arcade-surface-identity.ts +16 -0
- package/src/runtime/contracts/control.ts +68 -0
- package/src/runtime/contracts/inspection.ts +165 -0
- package/src/runtime/contracts/observability.ts +94 -0
- package/src/runtime/controller-bridge.ts +451 -0
- package/src/runtime/controller-identity.ts +132 -0
- package/src/runtime/controller-presentation.ts +24 -0
- package/src/runtime/controller-realtime-client.ts +591 -0
- package/src/runtime/create-air-jam-app.tsx +260 -0
- package/src/runtime/dev-runtime-events.ts +36 -0
- package/src/runtime/embedded-runtime-adapters.ts +68 -0
- package/src/runtime/host-bridge.ts +388 -0
- package/src/runtime/host-realtime-client.ts +550 -0
- package/src/runtime/iframe-bridge.ts +135 -0
- package/src/runtime/realtime-client.ts +20 -0
- package/src/runtime/router-basename.ts +25 -0
- package/src/runtime/runtime-owner-contexts.tsx +4 -0
- package/src/runtime/runtime-session-params.ts +169 -0
- package/src/runtime/sdk-version.ts +6 -0
- package/src/runtime/session-runtimes.tsx +188 -0
- package/src/runtime/validate-arcade-bridge-attach.ts +14 -0
- package/src/runtime-control.ts +10 -0
- package/src/runtime-inspection.ts +14 -0
- package/src/runtime-observability.ts +9 -0
- package/src/runtime-topology.ts +569 -0
- package/src/settings/platform-settings-bridge.ts +336 -0
- package/src/settings/platform-settings-runtime.tsx +387 -0
- package/src/settings/platform-settings.ts +288 -0
- package/src/state/connection-store.ts +80 -12
- package/src/store/air-jam-store-domain-constants.ts +4 -0
- package/src/store/create-air-jam-store.ts +1094 -227
- package/src/styles.css +4 -38
- package/src/ui.ts +29 -0
- package/src/utils/is-rpc-serializable.ts +56 -0
- package/src/utils/player-avatar-url.ts +48 -0
- package/src/utils/url-builder.ts +7 -0
- package/dist/.tsbuildinfo +0 -1
- package/dist/chunk-B5DURUWT.js +0 -80
- package/dist/chunk-B5DURUWT.js.map +0 -1
- package/src/AirJamClient.ts +0 -224
- package/src/audio/volume-store.ts +0 -124
- package/src/components/controller-shell.tsx +0 -346
- package/src/components/host-shell.tsx +0 -520
- package/src/components/qr-scanner-dialog.tsx +0 -373
- package/src/components/ui/alert.tsx +0 -66
- package/src/components/ui/avatar.tsx +0 -46
- package/src/components/ui/badge.tsx +0 -47
- package/src/components/ui/card.tsx +0 -92
- package/src/components/ui/dialog.tsx +0 -122
- package/src/components/ui/tabs.tsx +0 -64
- package/src/hooks/use-air-jam-shell.ts +0 -379
- package/src/hooks/use-fullscreen.ts +0 -108
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import type { ZodType } from "zod";
|
|
2
|
+
|
|
3
|
+
export type AirJamAgentActionPayloadKind =
|
|
4
|
+
| "none"
|
|
5
|
+
| "boolean"
|
|
6
|
+
| "number"
|
|
7
|
+
| "string"
|
|
8
|
+
| "enum"
|
|
9
|
+
| "json";
|
|
10
|
+
|
|
11
|
+
export type AirJamAgentActionPayloadMetadata = {
|
|
12
|
+
kind: AirJamAgentActionPayloadKind;
|
|
13
|
+
description?: string;
|
|
14
|
+
allowedValues?: string[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type AirJamAgentActionMetadata = {
|
|
18
|
+
description?: string;
|
|
19
|
+
payload: AirJamAgentActionPayloadMetadata;
|
|
20
|
+
resultDescription?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type AirJamAgentActionDescriptor = {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string | null;
|
|
26
|
+
payload: {
|
|
27
|
+
kind: AirJamAgentActionPayloadKind;
|
|
28
|
+
description: string | null;
|
|
29
|
+
allowedValues?: string[];
|
|
30
|
+
};
|
|
31
|
+
resultDescription: string | null;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type AirJamAgentActionParseMeta = {
|
|
35
|
+
gameId: string;
|
|
36
|
+
actionName: string;
|
|
37
|
+
contractKind?: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type AirJamAgentActionInputDefinition<TPayload = unknown> = {
|
|
41
|
+
parse: (payload: unknown, meta: AirJamAgentActionParseMeta) => TPayload;
|
|
42
|
+
metadata: AirJamAgentActionMetadata;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type InferAirJamAgentActionInputPayload<TInput> =
|
|
46
|
+
TInput extends AirJamAgentActionInputDefinition<infer TPayload>
|
|
47
|
+
? TPayload
|
|
48
|
+
: never;
|
|
49
|
+
|
|
50
|
+
export type AirJamAgentActionOptions = {
|
|
51
|
+
description?: string;
|
|
52
|
+
payloadDescription?: string;
|
|
53
|
+
resultDescription?: string;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type AirJamAgentActionCustomOptions = AirJamAgentActionOptions & {
|
|
57
|
+
payloadKind?: AirJamAgentActionPayloadKind;
|
|
58
|
+
allowedValues?: string[];
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const createActionError = (
|
|
62
|
+
meta: AirJamAgentActionParseMeta,
|
|
63
|
+
message: string,
|
|
64
|
+
): Error =>
|
|
65
|
+
new Error(
|
|
66
|
+
`[${meta.contractKind ?? "action"}:${meta.gameId}.${meta.actionName}] ${message}`,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
export const createAgentActionMetadata = (
|
|
70
|
+
payload: AirJamAgentActionPayloadMetadata,
|
|
71
|
+
options?: AirJamAgentActionOptions,
|
|
72
|
+
): AirJamAgentActionMetadata => ({
|
|
73
|
+
description: options?.description,
|
|
74
|
+
payload: {
|
|
75
|
+
...payload,
|
|
76
|
+
description: options?.payloadDescription ?? payload.description,
|
|
77
|
+
},
|
|
78
|
+
resultDescription: options?.resultDescription,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const defineAgentActionInput = <TPayload>(
|
|
82
|
+
parse: (payload: unknown, meta: AirJamAgentActionParseMeta) => TPayload,
|
|
83
|
+
metadata: AirJamAgentActionMetadata,
|
|
84
|
+
): AirJamAgentActionInputDefinition<TPayload> => ({
|
|
85
|
+
parse,
|
|
86
|
+
metadata,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const parseFiniteNumber = (
|
|
90
|
+
payload: unknown,
|
|
91
|
+
meta: AirJamAgentActionParseMeta,
|
|
92
|
+
): number => {
|
|
93
|
+
const nextValue =
|
|
94
|
+
typeof payload === "number" && Number.isFinite(payload)
|
|
95
|
+
? payload
|
|
96
|
+
: typeof payload === "string"
|
|
97
|
+
? Number(payload)
|
|
98
|
+
: Number.NaN;
|
|
99
|
+
|
|
100
|
+
if (!Number.isFinite(nextValue)) {
|
|
101
|
+
throw createActionError(meta, "expected a finite number payload");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return nextValue;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const parseStringValue = (
|
|
108
|
+
payload: unknown,
|
|
109
|
+
meta: AirJamAgentActionParseMeta,
|
|
110
|
+
): string => {
|
|
111
|
+
if (typeof payload !== "string") {
|
|
112
|
+
throw createActionError(meta, "expected a string payload");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return payload;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const parseBooleanValue = (
|
|
119
|
+
payload: unknown,
|
|
120
|
+
meta: AirJamAgentActionParseMeta,
|
|
121
|
+
): boolean => {
|
|
122
|
+
if (typeof payload === "boolean") {
|
|
123
|
+
return payload;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (payload === "true" || payload === "1") {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (payload === "false" || payload === "0") {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
throw createActionError(meta, "expected a boolean payload");
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const parseEnumValue = <const TValues extends readonly string[]>(
|
|
138
|
+
values: TValues,
|
|
139
|
+
payload: unknown,
|
|
140
|
+
meta: AirJamAgentActionParseMeta,
|
|
141
|
+
): TValues[number] => {
|
|
142
|
+
if (typeof payload !== "string" || !values.includes(payload)) {
|
|
143
|
+
throw createActionError(meta, `expected one of: ${values.join(", ")}`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return payload as TValues[number];
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
type AirJamAgentActionCustomParser<TPayload> = (
|
|
150
|
+
payload: unknown,
|
|
151
|
+
meta: AirJamAgentActionParseMeta,
|
|
152
|
+
) => TPayload;
|
|
153
|
+
|
|
154
|
+
type AirJamAgentActionZodSchema<TPayload> = ZodType<TPayload>;
|
|
155
|
+
|
|
156
|
+
const noneInput = (
|
|
157
|
+
options?: AirJamAgentActionOptions,
|
|
158
|
+
): AirJamAgentActionInputDefinition<void> =>
|
|
159
|
+
defineAgentActionInput(
|
|
160
|
+
() => undefined,
|
|
161
|
+
createAgentActionMetadata({ kind: "none" }, options),
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const numberInput = (
|
|
165
|
+
options?: AirJamAgentActionOptions,
|
|
166
|
+
): AirJamAgentActionInputDefinition<number> =>
|
|
167
|
+
defineAgentActionInput(
|
|
168
|
+
parseFiniteNumber,
|
|
169
|
+
createAgentActionMetadata({ kind: "number" }, options),
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
const stringInput = (
|
|
173
|
+
options?: AirJamAgentActionOptions,
|
|
174
|
+
): AirJamAgentActionInputDefinition<string> =>
|
|
175
|
+
defineAgentActionInput(
|
|
176
|
+
parseStringValue,
|
|
177
|
+
createAgentActionMetadata({ kind: "string" }, options),
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const booleanInput = (
|
|
181
|
+
options?: AirJamAgentActionOptions,
|
|
182
|
+
): AirJamAgentActionInputDefinition<boolean> =>
|
|
183
|
+
defineAgentActionInput(
|
|
184
|
+
parseBooleanValue,
|
|
185
|
+
createAgentActionMetadata({ kind: "boolean" }, options),
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const enumInput = <const TValues extends readonly string[]>(
|
|
189
|
+
values: TValues,
|
|
190
|
+
options?: AirJamAgentActionOptions,
|
|
191
|
+
): AirJamAgentActionInputDefinition<TValues[number]> =>
|
|
192
|
+
defineAgentActionInput(
|
|
193
|
+
(payload, meta) => parseEnumValue(values, payload, meta),
|
|
194
|
+
createAgentActionMetadata(
|
|
195
|
+
{
|
|
196
|
+
kind: "enum",
|
|
197
|
+
allowedValues: [...values],
|
|
198
|
+
},
|
|
199
|
+
options,
|
|
200
|
+
),
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
const jsonInput = (
|
|
204
|
+
options?: AirJamAgentActionOptions,
|
|
205
|
+
): AirJamAgentActionInputDefinition<unknown> =>
|
|
206
|
+
defineAgentActionInput(
|
|
207
|
+
(payload) => payload,
|
|
208
|
+
createAgentActionMetadata({ kind: "json" }, options),
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
function customInput<TPayload>(
|
|
212
|
+
parse: AirJamAgentActionCustomParser<TPayload>,
|
|
213
|
+
): AirJamAgentActionInputDefinition<TPayload>;
|
|
214
|
+
function customInput<TPayload>(
|
|
215
|
+
options: AirJamAgentActionCustomOptions,
|
|
216
|
+
parse: AirJamAgentActionCustomParser<TPayload>,
|
|
217
|
+
): AirJamAgentActionInputDefinition<TPayload>;
|
|
218
|
+
function customInput<TPayload>(
|
|
219
|
+
optionsOrParse:
|
|
220
|
+
| AirJamAgentActionCustomOptions
|
|
221
|
+
| AirJamAgentActionCustomParser<TPayload>,
|
|
222
|
+
maybeParse?: AirJamAgentActionCustomParser<TPayload>,
|
|
223
|
+
): AirJamAgentActionInputDefinition<TPayload> {
|
|
224
|
+
if (typeof optionsOrParse === "function") {
|
|
225
|
+
return defineAgentActionInput(
|
|
226
|
+
optionsOrParse,
|
|
227
|
+
createAgentActionMetadata({ kind: "json" }),
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (typeof maybeParse === "function") {
|
|
232
|
+
return defineAgentActionInput(
|
|
233
|
+
maybeParse,
|
|
234
|
+
createAgentActionMetadata(
|
|
235
|
+
{
|
|
236
|
+
kind: optionsOrParse.payloadKind ?? "json",
|
|
237
|
+
allowedValues: optionsOrParse.allowedValues,
|
|
238
|
+
},
|
|
239
|
+
optionsOrParse,
|
|
240
|
+
),
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
throw new Error("Invalid agent action input definition.");
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const zodInput = <TPayload>(
|
|
248
|
+
schema: AirJamAgentActionZodSchema<TPayload>,
|
|
249
|
+
options?: AirJamAgentActionOptions,
|
|
250
|
+
): AirJamAgentActionInputDefinition<TPayload> =>
|
|
251
|
+
defineAgentActionInput(
|
|
252
|
+
(payload, meta) => {
|
|
253
|
+
const result = schema.safeParse(payload);
|
|
254
|
+
if (result.success) {
|
|
255
|
+
return result.data;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const firstIssue = result.error.issues[0];
|
|
259
|
+
throw createActionError(
|
|
260
|
+
meta,
|
|
261
|
+
firstIssue?.message ?? "payload failed schema validation",
|
|
262
|
+
);
|
|
263
|
+
},
|
|
264
|
+
createAgentActionMetadata({ kind: "json" }, options),
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
export const agentActionInput = {
|
|
268
|
+
none: noneInput,
|
|
269
|
+
number: numberInput,
|
|
270
|
+
string: stringInput,
|
|
271
|
+
boolean: booleanInput,
|
|
272
|
+
enum: enumInput,
|
|
273
|
+
json: jsonInput,
|
|
274
|
+
custom: customInput,
|
|
275
|
+
zod: zodInput,
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export const describeAgentActionInputs = <
|
|
279
|
+
TActions extends Record<
|
|
280
|
+
string,
|
|
281
|
+
{ metadata?: AirJamAgentActionMetadata | undefined }
|
|
282
|
+
>,
|
|
283
|
+
>(
|
|
284
|
+
actions: TActions,
|
|
285
|
+
): AirJamAgentActionDescriptor[] =>
|
|
286
|
+
Object.entries(actions)
|
|
287
|
+
.map(([name, definition]) => {
|
|
288
|
+
const metadata = definition.metadata;
|
|
289
|
+
return {
|
|
290
|
+
name,
|
|
291
|
+
description: metadata?.description ?? null,
|
|
292
|
+
payload: {
|
|
293
|
+
kind: metadata?.payload.kind ?? "json",
|
|
294
|
+
description: metadata?.payload.description ?? null,
|
|
295
|
+
...(metadata?.payload.allowedValues
|
|
296
|
+
? {
|
|
297
|
+
allowedValues: [...metadata.payload.allowedValues],
|
|
298
|
+
}
|
|
299
|
+
: {}),
|
|
300
|
+
},
|
|
301
|
+
resultDescription: metadata?.resultDescription ?? null,
|
|
302
|
+
};
|
|
303
|
+
})
|
|
304
|
+
.sort((left, right) => left.name.localeCompare(right.name));
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type AirJamAgentActionInputDefinition,
|
|
3
|
+
type AirJamAgentActionMetadata,
|
|
4
|
+
type AirJamAgentActionOptions,
|
|
5
|
+
type AirJamAgentActionParseMeta,
|
|
6
|
+
type AirJamAgentActionPayloadKind,
|
|
7
|
+
type AirJamAgentActionPayloadMetadata,
|
|
8
|
+
} from "./agent-action.js";
|
|
9
|
+
|
|
10
|
+
export type AirJamAgentJsonObject = Record<string, unknown>;
|
|
11
|
+
|
|
12
|
+
export type AirJamAgentContractPayloadKind = AirJamAgentActionPayloadKind;
|
|
13
|
+
|
|
14
|
+
export type AirJamAgentContractPayloadMetadata =
|
|
15
|
+
AirJamAgentActionPayloadMetadata;
|
|
16
|
+
|
|
17
|
+
export type AirJamAgentStoreDeclaration<TStore extends object = object> = {
|
|
18
|
+
readonly __store?: TStore;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type AirJamAgentStoreDeclarations = Record<
|
|
22
|
+
string,
|
|
23
|
+
AirJamAgentStoreDeclaration<object>
|
|
24
|
+
>;
|
|
25
|
+
|
|
26
|
+
export type AirJamAgentActionTarget = {
|
|
27
|
+
kind: "participant" | "host";
|
|
28
|
+
actionName: string;
|
|
29
|
+
storeDomain?: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type AirJamAgentStores = Record<string, object>;
|
|
33
|
+
|
|
34
|
+
export type InferAirJamAgentStores<
|
|
35
|
+
TDeclarations extends AirJamAgentStoreDeclarations,
|
|
36
|
+
> = {
|
|
37
|
+
[TKey in keyof TDeclarations]: TDeclarations[TKey] extends AirJamAgentStoreDeclaration<
|
|
38
|
+
infer TStore
|
|
39
|
+
>
|
|
40
|
+
? TStore
|
|
41
|
+
: never;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
type AirJamAgentActionContractBase = {
|
|
45
|
+
target: AirJamAgentActionTarget;
|
|
46
|
+
description?: string;
|
|
47
|
+
availability?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Human and agent-facing description of the expected semantic effect.
|
|
50
|
+
* This does not automatically become runtime result data; return
|
|
51
|
+
* `acceptAirJamAction(result)` from the underlying store action when callers
|
|
52
|
+
* need an actual result payload.
|
|
53
|
+
*/
|
|
54
|
+
resultDescription?: string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type AirJamAgentResolvedActionContract<
|
|
58
|
+
TInput = unknown,
|
|
59
|
+
TPayload = TInput,
|
|
60
|
+
> = AirJamAgentActionContractBase & {
|
|
61
|
+
input: AirJamAgentActionInputDefinition<TInput>;
|
|
62
|
+
toPayload?: (input: TInput) => TPayload;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Existential wildcard for heterogenous action contracts.
|
|
66
|
+
/* eslint-disable @typescript-eslint/no-explicit-any -- These aliases intentionally erase generic action and store shapes at contract boundaries. */
|
|
67
|
+
export type AirJamAgentActionContract = AirJamAgentResolvedActionContract<
|
|
68
|
+
any,
|
|
69
|
+
any
|
|
70
|
+
>;
|
|
71
|
+
|
|
72
|
+
// Existential wildcard for published agent contracts with arbitrary snapshot/store shapes.
|
|
73
|
+
export type AnyAirJamAgentContract = AirJamAgentContract<any, any>;
|
|
74
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
75
|
+
|
|
76
|
+
export type AirJamAgentContractActionOptions<
|
|
77
|
+
TInput,
|
|
78
|
+
TPayload = TInput,
|
|
79
|
+
> = AirJamAgentActionOptions & {
|
|
80
|
+
availability?: string;
|
|
81
|
+
input: AirJamAgentActionInputDefinition<TInput>;
|
|
82
|
+
toPayload?: (input: TInput) => TPayload;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export type AirJamAgentSnapshotContext<
|
|
86
|
+
TStores extends AirJamAgentStores = AirJamAgentStores,
|
|
87
|
+
> = {
|
|
88
|
+
controllerId: string | null;
|
|
89
|
+
stores: Partial<TStores>;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export type AirJamAgentContract<
|
|
93
|
+
TSnapshot extends AirJamAgentJsonObject = AirJamAgentJsonObject,
|
|
94
|
+
TStoreDeclarations extends AirJamAgentStoreDeclarations =
|
|
95
|
+
AirJamAgentStoreDeclarations,
|
|
96
|
+
> = {
|
|
97
|
+
stores: TStoreDeclarations;
|
|
98
|
+
snapshotDescription?: string;
|
|
99
|
+
projectSnapshot: (
|
|
100
|
+
context: AirJamAgentSnapshotContext<
|
|
101
|
+
InferAirJamAgentStores<TStoreDeclarations>
|
|
102
|
+
>,
|
|
103
|
+
) => TSnapshot | Promise<TSnapshot>;
|
|
104
|
+
actions: Record<string, AirJamAgentActionContract>;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const agentStore = <
|
|
108
|
+
TStore extends object,
|
|
109
|
+
>(): AirJamAgentStoreDeclaration<TStore> =>
|
|
110
|
+
({}) as AirJamAgentStoreDeclaration<TStore>;
|
|
111
|
+
|
|
112
|
+
export const defineAirJamAgentStores = <
|
|
113
|
+
TDeclarations extends AirJamAgentStoreDeclarations,
|
|
114
|
+
>(
|
|
115
|
+
stores: TDeclarations,
|
|
116
|
+
): TDeclarations => stores;
|
|
117
|
+
|
|
118
|
+
export const listAirJamAgentStoreDomains = (
|
|
119
|
+
contract: AnyAirJamAgentContract,
|
|
120
|
+
): string[] => Object.keys(contract.stores);
|
|
121
|
+
|
|
122
|
+
export const describeAirJamAgentAction = (
|
|
123
|
+
action: AirJamAgentActionContract,
|
|
124
|
+
): AirJamAgentActionMetadata => ({
|
|
125
|
+
description: action.description ?? action.input.metadata.description,
|
|
126
|
+
payload: {
|
|
127
|
+
...action.input.metadata.payload,
|
|
128
|
+
},
|
|
129
|
+
resultDescription:
|
|
130
|
+
action.resultDescription ?? action.input.metadata.resultDescription,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
export const resolveAirJamAgentActionPayload = (
|
|
134
|
+
action: AirJamAgentActionContract,
|
|
135
|
+
payload: unknown,
|
|
136
|
+
meta: AirJamAgentActionParseMeta,
|
|
137
|
+
): unknown => {
|
|
138
|
+
const parsedInput = action.input.parse(payload, meta);
|
|
139
|
+
return action.toPayload ? action.toPayload(parsedInput) : parsedInput;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const agentAction = {
|
|
143
|
+
participant: <TInput, TPayload = TInput>(
|
|
144
|
+
target: Omit<AirJamAgentActionTarget, "kind">,
|
|
145
|
+
options: AirJamAgentContractActionOptions<TInput, TPayload>,
|
|
146
|
+
): AirJamAgentResolvedActionContract<TInput, TPayload> => ({
|
|
147
|
+
target: {
|
|
148
|
+
kind: "participant",
|
|
149
|
+
actionName: target.actionName,
|
|
150
|
+
...(target.storeDomain ? { storeDomain: target.storeDomain } : {}),
|
|
151
|
+
},
|
|
152
|
+
description: options.description,
|
|
153
|
+
availability: options.availability,
|
|
154
|
+
input: options.input,
|
|
155
|
+
toPayload: options.toPayload,
|
|
156
|
+
resultDescription: options.resultDescription,
|
|
157
|
+
}),
|
|
158
|
+
host: <TInput, TPayload = TInput>(
|
|
159
|
+
target: Omit<AirJamAgentActionTarget, "kind">,
|
|
160
|
+
options: AirJamAgentContractActionOptions<TInput, TPayload>,
|
|
161
|
+
): AirJamAgentResolvedActionContract<TInput, TPayload> => ({
|
|
162
|
+
target: {
|
|
163
|
+
kind: "host",
|
|
164
|
+
actionName: target.actionName,
|
|
165
|
+
...(target.storeDomain ? { storeDomain: target.storeDomain } : {}),
|
|
166
|
+
},
|
|
167
|
+
description: options.description,
|
|
168
|
+
availability: options.availability,
|
|
169
|
+
input: options.input,
|
|
170
|
+
toPayload: options.toPayload,
|
|
171
|
+
resultDescription: options.resultDescription,
|
|
172
|
+
}),
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export const defineAirJamAgentContract = <
|
|
176
|
+
TSnapshot extends AirJamAgentJsonObject,
|
|
177
|
+
TStoreDeclarations extends AirJamAgentStoreDeclarations,
|
|
178
|
+
>(
|
|
179
|
+
contract: AirJamAgentContract<TSnapshot, TStoreDeclarations>,
|
|
180
|
+
): AirJamAgentContract<TSnapshot, TStoreDeclarations> => contract;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export {
|
|
2
|
+
createAgentActionMetadata,
|
|
3
|
+
defineAgentActionInput,
|
|
4
|
+
describeAgentActionInputs,
|
|
5
|
+
type AirJamAgentActionDescriptor,
|
|
6
|
+
type AirJamAgentActionInputDefinition,
|
|
7
|
+
type AirJamAgentActionMetadata,
|
|
8
|
+
type AirJamAgentActionOptions,
|
|
9
|
+
type AirJamAgentActionParseMeta,
|
|
10
|
+
type AirJamAgentActionPayloadKind,
|
|
11
|
+
type AirJamAgentActionPayloadMetadata,
|
|
12
|
+
} from "./agent/agent-action";
|
|
13
|
+
export type { AirJamAgentActionCustomOptions } from "./agent/agent-action";
|
|
14
|
+
export {
|
|
15
|
+
describeAirJamAgentAction,
|
|
16
|
+
listAirJamAgentStoreDomains,
|
|
17
|
+
resolveAirJamAgentActionPayload,
|
|
18
|
+
type AirJamAgentActionContract,
|
|
19
|
+
type AirJamAgentContract,
|
|
20
|
+
} from "./agent/agent-contract";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export {
|
|
2
|
+
AIRJAM_CONTROLLER_BRIDGE_EVENT,
|
|
3
|
+
AIRJAM_CONTROLLER_BRIDGE_RESPONSE,
|
|
4
|
+
AIRJAM_CONTROLLER_PRESENTATION_SYNC,
|
|
5
|
+
createControllerBridgeAttachMessage,
|
|
6
|
+
createControllerBridgeCloseMessage,
|
|
7
|
+
createControllerBridgeResponseMessage,
|
|
8
|
+
createControllerPresentationSyncMessage,
|
|
9
|
+
parseControllerBridgeEmitMessage,
|
|
10
|
+
parseControllerBridgeRequestMessage,
|
|
11
|
+
parseControllerBridgeResponseMessage,
|
|
12
|
+
parseControllerPresentationSyncMessage,
|
|
13
|
+
type ControllerBridgeServerEventName,
|
|
14
|
+
type ControllerPresentationSyncMessage,
|
|
15
|
+
} from "../../runtime/controller-bridge";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export {
|
|
2
|
+
AIRJAM_HOST_BRIDGE_EVENT,
|
|
3
|
+
AIRJAM_HOST_BRIDGE_RESPONSE,
|
|
4
|
+
createHostBridgeAttachMessage,
|
|
5
|
+
createHostBridgeCloseMessage,
|
|
6
|
+
createHostBridgeResponseMessage,
|
|
7
|
+
parseHostBridgeEmitMessage,
|
|
8
|
+
parseHostBridgeRequestMessage,
|
|
9
|
+
parseHostBridgeResponseMessage,
|
|
10
|
+
type HostBridgeServerEventName,
|
|
11
|
+
} from "../../runtime/host-bridge";
|
|
12
|
+
export type { AirJamRealtimeClient } from "../../runtime/realtime-client";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AIRJAM_DEV_LOG_SINK_FAILURE,
|
|
3
|
+
AIRJAM_DEV_PROVIDER_MOUNTED,
|
|
4
|
+
AIRJAM_DEV_RUNTIME_EVENT,
|
|
5
|
+
emitAirJamDevRuntimeEvent,
|
|
6
|
+
type AirJamDevRuntimeEventDetail,
|
|
7
|
+
} from "../../runtime/dev-runtime-events";
|
|
8
|
+
import {
|
|
9
|
+
AIRJAM_BRIDGE_INIT,
|
|
10
|
+
AIRJAM_SETTINGS_SYNC,
|
|
11
|
+
createBridgeHandshake,
|
|
12
|
+
isAirJamSettingsReadyMessage,
|
|
13
|
+
type AirJamBridgeInitMessage,
|
|
14
|
+
type AirJamSettingsReadyMessage,
|
|
15
|
+
type AirJamSettingsSyncMessage,
|
|
16
|
+
} from "../../runtime/iframe-bridge";
|
|
17
|
+
import { AIR_JAM_SDK_VERSION } from "../../runtime/sdk-version";
|
|
18
|
+
import type { PlatformSettingsSnapshot } from "../../settings/platform-settings";
|
|
19
|
+
export {
|
|
20
|
+
createParentPlatformSettingsBridge,
|
|
21
|
+
type ParentPlatformSettingsBridgeController,
|
|
22
|
+
type ParentPlatformSettingsBridgeEventMap,
|
|
23
|
+
type PlatformSettingsBridgeState,
|
|
24
|
+
type PlatformSettingsBridgeTransport,
|
|
25
|
+
} from "../../settings/platform-settings-bridge";
|
|
26
|
+
|
|
27
|
+
export const createArcadeBridgeInitMessage = (): AirJamBridgeInitMessage => ({
|
|
28
|
+
type: AIRJAM_BRIDGE_INIT,
|
|
29
|
+
payload: {
|
|
30
|
+
handshake: createBridgeHandshake({
|
|
31
|
+
sdkVersion: AIR_JAM_SDK_VERSION,
|
|
32
|
+
runtimeKind: "arcade-runtime",
|
|
33
|
+
capabilityFlags: {
|
|
34
|
+
settingsSync: true,
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const createArcadeSettingsSyncMessage = (
|
|
41
|
+
settings: PlatformSettingsSnapshot,
|
|
42
|
+
): AirJamSettingsSyncMessage => ({
|
|
43
|
+
type: AIRJAM_SETTINGS_SYNC,
|
|
44
|
+
payload: {
|
|
45
|
+
settings,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
AIRJAM_DEV_LOG_SINK_FAILURE,
|
|
51
|
+
AIRJAM_DEV_PROVIDER_MOUNTED,
|
|
52
|
+
AIRJAM_DEV_RUNTIME_EVENT,
|
|
53
|
+
emitAirJamDevRuntimeEvent,
|
|
54
|
+
isAirJamSettingsReadyMessage,
|
|
55
|
+
};
|
|
56
|
+
export type {
|
|
57
|
+
AirJamBridgeInitMessage,
|
|
58
|
+
AirJamDevRuntimeEventDetail,
|
|
59
|
+
AirJamSettingsReadyMessage,
|
|
60
|
+
AirJamSettingsSyncMessage,
|
|
61
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../hooks/use-host-arcade-restore";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ResolvedAirJamRuntimeTopology } from "../runtime-topology";
|
|
2
|
+
import { runtimeTopologyToQueryParams } from "../runtime-topology";
|
|
3
|
+
import type { ChildHostCapability } from "../protocol";
|
|
4
|
+
import {
|
|
5
|
+
appendRuntimeQueryParams,
|
|
6
|
+
getRuntimeUrlOrigin,
|
|
7
|
+
normalizeRuntimeUrl,
|
|
8
|
+
} from "../protocol/url-policy";
|
|
9
|
+
import {
|
|
10
|
+
arcadeSurfaceRuntimeUrlParams,
|
|
11
|
+
type ArcadeSurfaceRuntimeIdentity,
|
|
12
|
+
} from "./surface";
|
|
13
|
+
export { urlBuilder } from "../utils/url-builder";
|
|
14
|
+
export { arcadeSurfaceRuntimeUrlParams } from "./surface";
|
|
15
|
+
export { appendRuntimeQueryParams, getRuntimeUrlOrigin, normalizeRuntimeUrl };
|
|
16
|
+
|
|
17
|
+
export const buildArcadeGameIframeSrc = ({
|
|
18
|
+
normalizedUrl,
|
|
19
|
+
roomId,
|
|
20
|
+
launchCapability,
|
|
21
|
+
joinUrl,
|
|
22
|
+
topology,
|
|
23
|
+
arcadeSurface,
|
|
24
|
+
}: {
|
|
25
|
+
normalizedUrl: string;
|
|
26
|
+
roomId: string;
|
|
27
|
+
launchCapability: ChildHostCapability;
|
|
28
|
+
joinUrl?: string | null;
|
|
29
|
+
topology: ResolvedAirJamRuntimeTopology;
|
|
30
|
+
arcadeSurface: ArcadeSurfaceRuntimeIdentity;
|
|
31
|
+
}): string | null =>
|
|
32
|
+
appendRuntimeQueryParams(normalizedUrl, {
|
|
33
|
+
aj_room: roomId,
|
|
34
|
+
aj_cap: launchCapability.token,
|
|
35
|
+
aj_cap_exp: String(launchCapability.expiresAt),
|
|
36
|
+
aj_join_url: joinUrl,
|
|
37
|
+
...runtimeTopologyToQueryParams(topology),
|
|
38
|
+
...arcadeSurfaceRuntimeUrlParams(arcadeSurface),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const buildArcadeControllerRuntimeUrl = (
|
|
42
|
+
normalizedUrl: string,
|
|
43
|
+
): string | null => {
|
|
44
|
+
try {
|
|
45
|
+
const runtimeUrl = new URL(normalizedUrl);
|
|
46
|
+
const trimmedPath =
|
|
47
|
+
runtimeUrl.pathname !== "/" && runtimeUrl.pathname.endsWith("/")
|
|
48
|
+
? runtimeUrl.pathname.slice(0, -1)
|
|
49
|
+
: runtimeUrl.pathname;
|
|
50
|
+
const pathSegments = trimmedPath.split("/").filter(Boolean);
|
|
51
|
+
const controllerPath =
|
|
52
|
+
trimmedPath === "/" || pathSegments.length <= 1
|
|
53
|
+
? "/controller"
|
|
54
|
+
: `${trimmedPath}/controller`;
|
|
55
|
+
|
|
56
|
+
return new URL(controllerPath, runtimeUrl.origin).toString();
|
|
57
|
+
} catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
};
|
package/src/arcade.ts
ADDED