@hypersoniclabs/helix-sdk 0.1.1 → 0.1.9

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 (120) hide show
  1. package/README.md +954 -2
  2. package/dist/action-surface.d.ts +182 -0
  3. package/dist/action-surface.js +1032 -0
  4. package/dist/action-surface.js.map +1 -0
  5. package/dist/camera.d.ts +78 -0
  6. package/dist/camera.js +640 -0
  7. package/dist/camera.js.map +1 -0
  8. package/dist/dev-shell/criteria.d.ts +46 -0
  9. package/dist/dev-shell/criteria.js +98 -0
  10. package/dist/dev-shell/criteria.js.map +1 -0
  11. package/dist/dev-shell/index.d.ts +189 -0
  12. package/dist/dev-shell/index.js +287 -0
  13. package/dist/dev-shell/index.js.map +1 -0
  14. package/dist/dev-shell/keys.d.ts +14 -0
  15. package/dist/dev-shell/keys.js +78 -0
  16. package/dist/dev-shell/keys.js.map +1 -0
  17. package/dist/dev-shell/simulator.d.ts +436 -0
  18. package/dist/dev-shell/simulator.js +1634 -0
  19. package/dist/dev-shell/simulator.js.map +1 -0
  20. package/dist/dev-shell/state.d.ts +148 -0
  21. package/dist/dev-shell/state.js +196 -0
  22. package/dist/dev-shell/state.js.map +1 -0
  23. package/dist/device-definition-resolver.d.ts +34 -0
  24. package/dist/device-definition-resolver.js +172 -0
  25. package/dist/device-definition-resolver.js.map +1 -0
  26. package/dist/device-trial.d.ts +3 -0
  27. package/dist/device-trial.js +132 -0
  28. package/dist/device-trial.js.map +1 -0
  29. package/dist/devices.d.ts +228 -0
  30. package/dist/devices.js +198 -0
  31. package/dist/devices.js.map +1 -0
  32. package/dist/dreamerAudio.d.ts +126 -0
  33. package/dist/dreamerAudio.js +135 -0
  34. package/dist/dreamerAudio.js.map +1 -0
  35. package/dist/generated/runtime-contract.d.ts +15529 -0
  36. package/dist/generated/runtime-contract.js +20470 -0
  37. package/dist/generated/runtime-contract.js.map +1 -0
  38. package/dist/index.d.ts +364 -3
  39. package/dist/index.js +1954 -13
  40. package/dist/index.js.map +1 -1
  41. package/dist/interaction-mode.d.ts +172 -0
  42. package/dist/interaction-mode.js +553 -0
  43. package/dist/interaction-mode.js.map +1 -0
  44. package/dist/internal/avatar-pose.d.ts +25 -0
  45. package/dist/internal/avatar-pose.js +46 -0
  46. package/dist/internal/avatar-pose.js.map +1 -0
  47. package/dist/internal/keyed-collection.d.ts +2 -0
  48. package/dist/internal/keyed-collection.js +12 -0
  49. package/dist/internal/keyed-collection.js.map +1 -0
  50. package/dist/internal/vehicle-detach-action.d.ts +2 -0
  51. package/dist/internal/vehicle-detach-action.js +6 -0
  52. package/dist/internal/vehicle-detach-action.js.map +1 -0
  53. package/dist/matchmaking.d.ts +433 -0
  54. package/dist/matchmaking.js +1487 -0
  55. package/dist/matchmaking.js.map +1 -0
  56. package/dist/materials.d.ts +122 -0
  57. package/dist/materials.js +217 -0
  58. package/dist/materials.js.map +1 -0
  59. package/dist/multiplayer-accessors.d.ts +100 -0
  60. package/dist/multiplayer-accessors.js +200 -0
  61. package/dist/multiplayer-accessors.js.map +1 -0
  62. package/dist/multiplayer-contract/avatar-pose.d.ts +112 -0
  63. package/dist/multiplayer-contract/avatar-pose.js +250 -0
  64. package/dist/multiplayer-contract/avatar-pose.js.map +1 -0
  65. package/dist/multiplayer-contract/credential.d.ts +80 -0
  66. package/dist/multiplayer-contract/credential.js +5 -0
  67. package/dist/multiplayer-contract/credential.js.map +1 -0
  68. package/dist/multiplayer-contract/final-rest.d.ts +66 -0
  69. package/dist/multiplayer-contract/final-rest.js +38 -0
  70. package/dist/multiplayer-contract/final-rest.js.map +1 -0
  71. package/dist/multiplayer-contract/index.d.ts +20 -0
  72. package/dist/multiplayer-contract/index.js +41 -0
  73. package/dist/multiplayer-contract/index.js.map +1 -0
  74. package/dist/multiplayer-contract/messages.d.ts +731 -0
  75. package/dist/multiplayer-contract/messages.js +237 -0
  76. package/dist/multiplayer-contract/messages.js.map +1 -0
  77. package/dist/multiplayer-contract/room.d.ts +177 -0
  78. package/dist/multiplayer-contract/room.js +17 -0
  79. package/dist/multiplayer-contract/room.js.map +1 -0
  80. package/dist/multiplayer-contract/state.d.ts +241 -0
  81. package/dist/multiplayer-contract/state.js +15 -0
  82. package/dist/multiplayer-contract/state.js.map +1 -0
  83. package/dist/multiplayer-final-rest.d.ts +32 -0
  84. package/dist/multiplayer-final-rest.js +217 -0
  85. package/dist/multiplayer-final-rest.js.map +1 -0
  86. package/dist/multiplayer.d.ts +624 -0
  87. package/dist/multiplayer.js +2503 -0
  88. package/dist/multiplayer.js.map +1 -0
  89. package/dist/package.json +3 -0
  90. package/dist/protocol.d.ts +859 -1
  91. package/dist/protocol.js +117 -5
  92. package/dist/protocol.js.map +1 -1
  93. package/dist/runtime-contract/index.d.ts +15 -0
  94. package/dist/runtime-contract/index.js +12 -0
  95. package/dist/runtime-contract/index.js.map +1 -0
  96. package/dist/server-clock.d.ts +25 -0
  97. package/dist/server-clock.js +88 -0
  98. package/dist/server-clock.js.map +1 -0
  99. package/dist/tsconfig.build.tsbuildinfo +1 -1
  100. package/dist/universal-vehicles.d.ts +111 -0
  101. package/dist/universal-vehicles.js +2 -0
  102. package/dist/universal-vehicles.js.map +1 -0
  103. package/dist/vault.d.ts +562 -0
  104. package/dist/vault.js +365 -0
  105. package/dist/vault.js.map +1 -0
  106. package/dist/vehicle-specialty-placement.d.ts +28 -0
  107. package/dist/vehicle-specialty-placement.js +154 -0
  108. package/dist/vehicle-specialty-placement.js.map +1 -0
  109. package/dist/vehicle-specialty-transport.d.ts +78 -0
  110. package/dist/vehicle-specialty-transport.js +183 -0
  111. package/dist/vehicle-specialty-transport.js.map +1 -0
  112. package/dist/voice.d.ts +229 -0
  113. package/dist/voice.js +1348 -0
  114. package/dist/voice.js.map +1 -0
  115. package/generated/runtime-contract/helix-runtime-contract.json +13332 -0
  116. package/generated/runtime-contract/known-answer.json +20471 -0
  117. package/generated/runtime-contract/known-answer.schema.json +630 -0
  118. package/generated/runtime-contract/runtime-contract.schema.json +607 -0
  119. package/generated/runtime-contract/unreal/HelixRuntimeContract.generated.h +908 -0
  120. package/package.json +44 -5
@@ -0,0 +1,241 @@
1
+ export type Vec3 = {
2
+ x: number;
3
+ y: number;
4
+ z: number;
5
+ };
6
+ /** A rotation quaternion. Physics (dynamic-body) kinds only — kinematic kinds carry no orientation on the wire. */
7
+ export type Quat = {
8
+ x: number;
9
+ y: number;
10
+ z: number;
11
+ w: number;
12
+ };
13
+ /** Pinned units. Linear in meters / meters-per-second; every angle is degrees (see the *Deg suffixes). */
14
+ export declare const UNITS: {
15
+ readonly position: "meters";
16
+ readonly velocity: "meters/second";
17
+ readonly angles: "degrees";
18
+ };
19
+ /** Stable per-player identity (set at join from the room credential; not part of the per-tick churn). */
20
+ export interface PlayerIdentity {
21
+ /** Opaque per-connection room playerKey (= the state.players map key). Gameplay state is keyed by THIS, never by `userId`. */
22
+ id: string;
23
+ /** Sanitized display name for nameplates (sanitized before it enters room state — see plan H4). */
24
+ displayName: string;
25
+ /**
26
+ * The player's PLATFORM user id (the credential `sub`), so a roster UI can link a seat to a real
27
+ * profile (batch /api/v1/users lookup, profile drill-in). v18 deliberately supersedes the original §4
28
+ * stance that `sub` never replicates: user ids are already public directory data on the platform, so
29
+ * room-mates learn nothing new. Copied once at join from the verified credential, never client-supplied.
30
+ * '' when the room predates v18. Gameplay state stays keyed by the opaque per-connection `id`.
31
+ */
32
+ userId: string;
33
+ /**
34
+ * CDN URL of this player's equipped universal avatar (a converted single-file GLB on the
35
+ * helix-humanoid rig), or '' when they have none — clients render the default body on ''.
36
+ * Resolved and skeleton-gated SERVER-SIDE at join (backend → signed credential → room), never
37
+ * client-supplied — and it is item-keyed public catalog data, NOT the userId (which stays
38
+ * server-side, §4). Fixed for the seat's lifetime: equip changes apply on the next join. (v17)
39
+ */
40
+ avatarUrl: string;
41
+ }
42
+ /**
43
+ * One replicated prop attachment (v20). Exactly what a remote replica needs to render the prop: the
44
+ * asset URL (opaque world data — every client fetches the same CDN asset), the socket name, and the
45
+ * sender-RESOLVED socket-local offsets — the preset is applied at the sender, so replicas place the
46
+ * prop correctly across humanoid-character version skew. `preset` still rides the wire as a forward
47
+ * hook (Phase 3 pairs presets with grip finger poses); placement never depends on it.
48
+ */
49
+ export interface AttachmentEntry {
50
+ /** Client-generated id, unique within the seat (ATTACHMENT_LIMITS.idPattern); replicas diff + evict by it. */
51
+ id: string;
52
+ /** Prop GLB URL (https, room-sanitized, length-bounded). A failed/unknown asset no-ops on replicas. */
53
+ asset: string;
54
+ /** Socket name on the helix-humanoid rig (e.g. 'hand_r.grip'); a socket the replica's rig lacks no-ops. */
55
+ socket: string;
56
+ /** Socket-local offset, METERS. Vec3 like every other wire position (the room mirrors it as Vec3Schema). */
57
+ position: Vec3;
58
+ /** Socket-local orientation, DEGREES (XYZ euler order), as a Vec3 {x,y,z}. */
59
+ rotationEulerDeg: Vec3;
60
+ /** HELD_ITEM_PRESETS key or '' — the offsets above are already final. */
61
+ preset: string;
62
+ }
63
+ /**
64
+ * One emote the player CARRIES (v28) — an owned item, resolved onto the seat by the ROOM from the platform,
65
+ * never named by the client (the `avatarUrl` trust shape, not the `attachments` one). `slot` is the wheel
66
+ * position it plays from, `clip` the animation URL every client fetches for itself, `playback` how it runs.
67
+ */
68
+ export interface EmoteEntry {
69
+ /** Wheel position: 'r0'..'r7' are the eight radial slots, 'sit'/'lie' the two posture emotes. */
70
+ slot: 'r0' | 'r1' | 'r2' | 'r3' | 'r4' | 'r5' | 'r6' | 'r7' | 'sit' | 'lie';
71
+ /** The universal-item id this emote came from; replicas diff + evict by (slot, itemId). */
72
+ itemId: string;
73
+ /** Clip URL (servable, room-sanitized, EMOTE_LIMITS-bounded). A failed/unknown clip no-ops on replicas. */
74
+ clip: string;
75
+ /** How the clip runs once triggered: once through, or until it is stopped. */
76
+ playback: 'oneshot' | 'loop';
77
+ /**
78
+ * The emote's SOUND url, every client fetches it for itself exactly like `clip` and under the same servable
79
+ * rule. Absent when the emote is silent — audio is garnish, so a clip whose sound fails sanitization still
80
+ * lands, without it.
81
+ */
82
+ audio?: string;
83
+ /** The item's display title, for the wheel's petals. Nameplate-sanitized + capped at EMOTE_LIMITS.maxLabelLength; absent when the platform named it nothing. */
84
+ label?: string;
85
+ /**
86
+ * Optional ENTER transition: plays once and chains into `clip`. Same servable-url rule and the same
87
+ * EMOTE_LIMITS.maxClipUrlLength bound as `clip`. Never present with `roles`.
88
+ */
89
+ intro?: string;
90
+ /**
91
+ * Optional EXIT transition: plays on a deliberate end and on a oneshot's natural completion. Same servable-url
92
+ * rule and bound as `clip`. Never present with `roles`. It replicates through the v19 `gesture` relay under the
93
+ * suffixed name `emote.<slot>:outro` — the relay is name-opaque, so no new message channel exists for it.
94
+ */
95
+ outro?: string;
96
+ /**
97
+ * PAIRED emote (v28): the second role this emote offers, so another player can join it. Absent = a solo emote,
98
+ * and only an 'r0'..'r7' slot may carry it (the room strips it elsewhere) — the posture slots are stances, not
99
+ * invitations. The INITIATOR is whoever plays the emote; a joiner runs `joinerClip` at the offset below,
100
+ * which is expressed in the INITIATOR-LOCAL frame (+Z = the initiator's facing, +X their right) so the pair
101
+ * stays composed wherever the initiator stands. The offer itself is a HELD POSE (`offerAtS`), and a pair is
102
+ * strictly 1:1 — the room refuses a second joiner on an initiator that already has one.
103
+ */
104
+ roles?: {
105
+ /** The joiner's clip URL — same servable-url rule and same EMOTE_LIMITS.maxClipUrlLength bound as `clip`. */
106
+ joinerClip: string;
107
+ /**
108
+ * The OFFER freeze, SECONDS into the INITIATOR's own `clip`: the engine plays 0→offerAtS once as a wind-up, then
109
+ * HOLDS that pose until a joiner arrives or the initiator cancels. ≥ 0 (0 = the first frame), bounded by
110
+ * EMOTE_LIMITS.maxOfferAtS and independent of `playback`, which describes only the JOINED performance.
111
+ */
112
+ offerAtS: number;
113
+ /** Joiner offset from the initiator, METERS, initiator-local; each axis clamped to ±EMOTE_LIMITS.maxPairOffsetM. */
114
+ offsetX: number;
115
+ offsetZ: number;
116
+ /** The joiner's facing RELATIVE to the initiator's, DEGREES, normalized to [−180, 180] (180 = facing them). */
117
+ offsetYawDeg: number;
118
+ };
119
+ }
120
+ /**
121
+ * The per-tick replicated kinematic + animation parameters for one player. The room holds the
122
+ * authoritative copy (a @colyseus/schema mirror of these fields); the NetworkDriver maps each field
123
+ * onto the named character blackboard param. FIRST DRAFT — the exact injected set is confirmed by
124
+ * spike S2 (engine headless-replica write-path); changing the field set bumps CONTRACT_VERSION.
125
+ */
126
+ export interface PlayerReplicaState {
127
+ /** World feet position, METERS. Interpolated by the remote replica. */
128
+ position: Vec3;
129
+ /** Body facing, DEGREES. The adapter converts to radians for body.setFacingYaw. */
130
+ facingYawDeg: number;
131
+ /** Horizontal planar speed, M/S. → blackboard 'speed' (blend-space input). */
132
+ speed: number;
133
+ /** Signed movement direction relative to facing, DEGREES (−180..180). → blackboard 'direction'. */
134
+ moveDirectionDeg: number;
135
+ /** Vertical velocity, M/S (+up). → blackboard 'verticalVelocity' (jump/fall states). */
136
+ verticalVelocity: number;
137
+ /** Ground contact. → blackboard 'isGrounded' (grounded/air transitions). */
138
+ grounded: boolean;
139
+ /** Crouch stance. → routes the locomotion anim graph to its crouched states. */
140
+ crouched: boolean;
141
+ /**
142
+ * Physics owns this player's body (v25) — the death ragdoll, or a world's manual `character.ragdoll.enter()`.
143
+ * Client-authoritative cosmetic state like `crouched`: replicas mirror it into their OWN ragdoll driver, so a
144
+ * late joiner sees a limp player through STATE, not a missed event.
145
+ */
146
+ ragdolled: boolean;
147
+ /**
148
+ * The shove this ragdoll STARTED with (v26): unit horizontal direction × speed (m/s); all 0 when the body just
149
+ * crumpled. Held stable while `ragdolled` is true so a replica that observes the false→true EDGE re-creates the
150
+ * entry impulse on its own corpse. A late joiner reads state (not the edge) and must NOT re-apply it — the
151
+ * sender's followed position already encodes where the flight ended.
152
+ */
153
+ ragdollLaunchX: number;
154
+ ragdollLaunchZ: number;
155
+ ragdollSpeedMps: number;
156
+ /** Aim yaw, DEGREES (world). → blackboard 'cameraYaw' (aim-additive source). */
157
+ aimYawDeg: number;
158
+ /** Aim pitch, DEGREES. → blackboard 'cameraPitch' (aim-additive source). */
159
+ aimPitchDeg: number;
160
+ /** Ability ids currently active (e.g. ['locomotion','fly']). Drives remote ability activation. */
161
+ activeAbilities: string[];
162
+ /**
163
+ * The world-registered LOOPING gesture clip this player currently plays, '' when none (v19). Loops replicate
164
+ * as STATE — not events — so a late joiner starts them at replica spawn; oneshot gestures ride the transient
165
+ * `gesture` broadcast instead. The name is opaque world data: every client registered the same clips from the
166
+ * same bundle (registerAnimation), so only the name crosses the wire; an unknown name renders as no gesture.
167
+ */
168
+ loopGesture: string;
169
+ /**
170
+ * The props currently attached to this player (v20). Attachments are persistent, so they sync as STATE —
171
+ * a late joiner converges at replica spawn — never as events. Written whole by the `attachments` full-set
172
+ * replace message; bounded by ATTACHMENT_LIMITS.maxAttachments; [] when none (or the room predates v20).
173
+ */
174
+ attachments: AttachmentEntry[];
175
+ /**
176
+ * Live IK reach state (v21) — the WORLD-SPACE point each hand's procedural arm IK is holding (ik.reach:
177
+ * door handles, buttons, levers) and the interaction gaze point (ik.lookAt). Continuous per-tick data
178
+ * like position/aim, ridden in on the `state` upload (omitted field = inactive). Replicas feed the points
179
+ * into their OWN local solvers — no bone transforms ever cross the wire. When an `*Active` flag is false
180
+ * the paired vector just holds its last value (unwritten fields delta-encode to ~0 bytes) — always check
181
+ * the flag first. False/zero when the room predates v21.
182
+ */
183
+ reachLeftActive: boolean;
184
+ /** Left-hand reach target, world METERS. Meaningful only while reachLeftActive. */
185
+ reachLeft: Vec3;
186
+ reachRightActive: boolean;
187
+ /** Right-hand reach target, world METERS. Meaningful only while reachRightActive. */
188
+ reachRight: Vec3;
189
+ lookTargetActive: boolean;
190
+ /** Interaction gaze point, world METERS (beats replicated aim-follow gaze). Meaningful only while lookTargetActive. */
191
+ lookTarget: Vec3;
192
+ /**
193
+ * Gun state (v24) — weapon SIGNALS, not motion: replicas re-run the same local easing/FX off these fields.
194
+ * Absent when the sender carries no gun-control ability (or the room predates v24).
195
+ *
196
+ * `shotSeq` is a monotonic per-session shot counter, +1 per real shot. It is coalesced latest-wins at
197
+ * 10/20 Hz, so consumers react to the DELTA (never assume +1); it restarts at 0 on reconnect, and a
198
+ * non-positive delta means re-anchor (never replay).
199
+ */
200
+ shotSeq?: number;
201
+ /** Weapon drawn (vs holstered). */
202
+ gunDrawn?: boolean;
203
+ /** ADS intent, not an aim fraction — replicas ease locally with the same time constant. */
204
+ aiming?: boolean;
205
+ /** Reload in progress (wire-timed on replicas). */
206
+ reloading?: boolean;
207
+ /**
208
+ * The emote set this player CARRIES (v28) — resolved SERVER-SIDE from their equipped items at join and on the
209
+ * `emoteRefresh` hint, exactly like `avatarUrl` (v17): a client can never name the clip URLs that land on its
210
+ * own seat, so this is NOT the client-written `attachments` lane despite the matching array shape. Emotes are
211
+ * persistent → they sync as STATE, so a late joiner converges at replica spawn. Bounded by
212
+ * EMOTE_LIMITS.maxEntries; absent/[] when the player carries none, the world disabled emotes, or the room
213
+ * predates v28.
214
+ */
215
+ emotes?: EmoteEntry[];
216
+ /**
217
+ * The locomotion clip set this player MOVES on (v34), as ONE servable pack-manifest base URL — resolved
218
+ * SERVER-SIDE from their equipped locomotion pack at join and on the `avatarRefresh` hint, exactly like
219
+ * `avatarUrl` (v17): a client can never name the pack that lands on its own seat. A pack is persistent → it
220
+ * syncs as STATE, so a late joiner sees the right walk at replica spawn instead of a corrected one. '' or
221
+ * absent = the platform locomotion set, which is also what a room predating v34 replicates.
222
+ */
223
+ locomotionPack?: string;
224
+ /**
225
+ * PAIRED emotes (v28) — the pair this player JOINED, and never the one they offer: the initiator's own seat
226
+ * carries nothing (their offering is derivable — their `loopGesture` is `emote.<slot>` and that slot's entry
227
+ * has `roles`). ROOM-WRITTEN ONLY, like `avatarUrl`/`emotes` and unlike every other field here: the `emoteJoin`
228
+ * message is a request the room validates (liveness, range, the initiator actually offering and not already
229
+ * paired — a pair is strictly 1:1) and answers by writing — or by writing nothing — so a client can never seat
230
+ * itself in someone else's emote. The room also owns every clear (the initiator
231
+ * stops/changes/teleports/leaves/dies, the joiner dies or drifts away).
232
+ *
233
+ * '' = not paired; otherwise the INITIATOR's player id (the `players` map key, the id-space `activeAbilities`
234
+ * and every other ref use).
235
+ */
236
+ pairInitiator: string;
237
+ /** The initiator's slot being joined ('r0'..'r7'), so replicas read the roles off the right entry. '' = none. */
238
+ pairSlot: string;
239
+ /** Room clock (epoch ms, the `{op:now}` source) at pair creation, so replicas can phase-align. 0 = none. */
240
+ pairStartMs: number;
241
+ }
@@ -0,0 +1,15 @@
1
+ // Replicated player state — the parameters the room broadcasts and the engine's NetworkDriver feeds
2
+ // into the character blackboard. We replicate PARAMETERS, never bone transforms: animation runs fully
3
+ // client-side off these values (see character-architecture §3).
4
+ //
5
+ // ALL ANGLES ARE DEGREES — every angular field is suffixed *Deg. One unit on the wire, so there is no
6
+ // radians/degrees ambiguity to forget. The engine mixes units internally (the body is radians, the
7
+ // animation params are degrees); the engine adapter owns the single deg↔rad conversion at the body
8
+ // boundary (body.setFacingYaw) — the contract itself stays all-degrees.
9
+ /** Pinned units. Linear in meters / meters-per-second; every angle is degrees (see the *Deg suffixes). */
10
+ export const UNITS = {
11
+ position: 'meters',
12
+ velocity: 'meters/second',
13
+ angles: 'degrees',
14
+ };
15
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/multiplayer-contract/state.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,sGAAsG;AACtG,gEAAgE;AAChE,EAAE;AACF,sGAAsG;AACtG,mGAAmG;AACnG,mGAAmG;AACnG,wEAAwE;AAQxE,0GAA0G;AAC1G,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,eAAe;IACzB,MAAM,EAAE,SAAS;CACT,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { type FinalRestScope, FINAL_REST_REPLY, type FinalRestGrant, type FinalRestReply, type GroupRestSnapshotMessage, type RoomVarValue, type EntityStateBatchEntry } from './multiplayer-contract/index.js';
2
+ /** Room-scoped client state. Retries resend frozen bytes, never resample a settled body. */
3
+ export declare class FinalRestClient {
4
+ private readonly send;
5
+ private readonly nextSequence;
6
+ private request;
7
+ private readonly claiming;
8
+ private supported;
9
+ private moduleSupported;
10
+ private generations;
11
+ private lifecycle;
12
+ private readonly retiredGenerations;
13
+ private readonly snapshotGenerations;
14
+ private readonly moduleLifecycles;
15
+ private dead;
16
+ private readonly transactions;
17
+ private readonly revoked;
18
+ private readonly pending;
19
+ constructor(send: (type: string, payload: unknown) => void, nextSequence: () => number);
20
+ capability(payload: unknown): void;
21
+ receive(reply: FinalRestReply): void;
22
+ drop(): void;
23
+ reconnect(): void;
24
+ acceptSnapshot(snapshot: GroupRestSnapshotMessage): boolean;
25
+ invalidateModule(moduleId: string): void;
26
+ /** null means fenced; undefined is the unchanged legacy path. */
27
+ upload(id: string, moduleId?: string): string | null | undefined;
28
+ private rpc;
29
+ claim(action: string, group: string, args?: Record<string, RoomVarValue>, address?: FinalRestScope, engagementEpoch?: number): Promise<FinalRestGrant>;
30
+ commit(transactionId: string, states: readonly EntityStateBatchEntry[]): Promise<GroupRestSnapshotMessage>;
31
+ }
32
+ export { FINAL_REST_REPLY };
@@ -0,0 +1,217 @@
1
+ import { sameFinalRestScope, finalRestScopeKey, validFinalRestScope, finalRestSequence, FINAL_REST_REPLY, isFinalRestBatch, isFinalRestClaim, } from './multiplayer-contract/index.js';
2
+ /** Room-scoped client state. Retries resend frozen bytes, never resample a settled body. */
3
+ export class FinalRestClient {
4
+ send;
5
+ nextSequence;
6
+ request = Date.now() * 1000;
7
+ claiming = new Set();
8
+ supported = false;
9
+ moduleSupported = false;
10
+ generations = {};
11
+ lifecycle = 0;
12
+ retiredGenerations = new Map();
13
+ snapshotGenerations = new Map();
14
+ moduleLifecycles = new Map();
15
+ dead = false;
16
+ transactions = new Map();
17
+ revoked = new Set();
18
+ pending = new Map();
19
+ constructor(send, nextSequence) {
20
+ this.send = send;
21
+ this.nextSequence = nextSequence;
22
+ }
23
+ capability(payload) {
24
+ if (this.dead)
25
+ return;
26
+ if (payload?.finalRestVersion === 1)
27
+ this.supported = true;
28
+ const p = payload;
29
+ if (p?.moduleFinalRestVersion === 1) {
30
+ this.moduleSupported = true;
31
+ this.generations = p.finalRestModules ?? {};
32
+ }
33
+ }
34
+ receive(reply) {
35
+ if (!reply || reply.version !== 1)
36
+ return;
37
+ const known = reply.transactionId ? this.transactions.get(reply.transactionId) : undefined;
38
+ const pending = this.pending.get(reply.requestId);
39
+ if (known && !sameFinalRestScope(known.grant.scope, reply.scope))
40
+ return;
41
+ if (pending && !sameFinalRestScope(pending.scope, reply.scope))
42
+ return;
43
+ if (reply.status === 'invalidated' && reply.transactionId) {
44
+ this.revoked.add(reply.transactionId);
45
+ if (this.revoked.size > 128)
46
+ this.revoked.delete(this.revoked.values().next().value);
47
+ const t = this.transactions.get(reply.transactionId);
48
+ if (t)
49
+ t.phase = 'invalid';
50
+ // Reject a final request too, even though invalidation names the original claim request.
51
+ for (const p of this.pending.values())
52
+ if (p.transactionId === reply.transactionId && sameFinalRestScope(p.scope, reply.scope))
53
+ p.reject(new Error(`Final rest recovery required: ${reply.reason}`));
54
+ }
55
+ this.pending.get(reply.requestId)?.receive(reply);
56
+ }
57
+ drop() {
58
+ this.lifecycle++;
59
+ this.dead = true;
60
+ this.moduleSupported = false;
61
+ this.generations = {};
62
+ this.supported = false;
63
+ for (const t of this.transactions.values())
64
+ t.phase = 'invalid';
65
+ for (const p of this.pending.values())
66
+ p.reject(new Error('Final rest recovery required: transport dropped'));
67
+ }
68
+ reconnect() { this.dead = false; }
69
+ acceptSnapshot(snapshot) {
70
+ if (this.dead || !validFinalRestScope(snapshot.scope) || !finalRestSequence(snapshot.seq))
71
+ return false;
72
+ if (snapshot.commit && (this.revoked.has(snapshot.commit.transactionId) || this.transactions.get(snapshot.commit.transactionId)?.phase === 'invalid'))
73
+ return false;
74
+ if (!snapshot.scope)
75
+ return true;
76
+ const { moduleId, generation } = snapshot.scope;
77
+ if (generation <= (this.retiredGenerations.get(moduleId) ?? 0) || generation < (this.snapshotGenerations.get(moduleId) ?? 0))
78
+ return false;
79
+ this.snapshotGenerations.set(moduleId, generation);
80
+ return true;
81
+ }
82
+ invalidateModule(moduleId) {
83
+ this.retiredGenerations.set(moduleId, Math.max(this.retiredGenerations.get(moduleId) ?? 0, this.generations[moduleId] ?? 0, this.snapshotGenerations.get(moduleId) ?? 0));
84
+ this.moduleLifecycles.set(moduleId, (this.moduleLifecycles.get(moduleId) ?? 0) + 1);
85
+ delete this.generations[moduleId];
86
+ for (const t of this.transactions.values())
87
+ if (t.grant.scope?.moduleId === moduleId)
88
+ t.phase = 'invalid';
89
+ for (const p of this.pending.values())
90
+ if (p.scope?.moduleId === moduleId)
91
+ p.reject(new Error('Final rest recovery required: module lifecycle'));
92
+ }
93
+ /** null means fenced; undefined is the unchanged legacy path. */
94
+ upload(id, moduleId) {
95
+ for (const [tx, t] of this.transactions) {
96
+ if (t.grant.scope?.moduleId === moduleId && t.grant.members.some(m => m.id === id))
97
+ return t.phase === 'active' ? tx : null;
98
+ }
99
+ return undefined;
100
+ }
101
+ rpc(type, payload, requestId, transactionId, scope) {
102
+ // Own immutable request, independent of caller mutations and retries.
103
+ const frozen = JSON.stringify(payload);
104
+ return new Promise((resolve, reject) => {
105
+ let attempts = 0;
106
+ let timer;
107
+ const finish = (reply, error) => {
108
+ clearTimeout(timer);
109
+ this.pending.delete(requestId);
110
+ if (error)
111
+ reject(error);
112
+ else
113
+ resolve(reply);
114
+ };
115
+ this.pending.set(requestId, { transactionId, scope, receive: reply => finish(reply), reject: error => finish(undefined, error) });
116
+ const attempt = () => {
117
+ if (this.dead || attempts === 3) {
118
+ finish(undefined, new Error('Final rest recovery required: acknowledgement timeout'));
119
+ return;
120
+ }
121
+ attempts++;
122
+ timer = setTimeout(attempt, 500);
123
+ try {
124
+ this.send(type, JSON.parse(frozen));
125
+ }
126
+ catch (e) {
127
+ finish(undefined, e instanceof Error ? e : new Error(String(e)));
128
+ }
129
+ };
130
+ attempt();
131
+ });
132
+ }
133
+ async claim(action, group, args, address, engagementEpoch) {
134
+ // Capture nested action values before capability discovery yields to caller code.
135
+ args = args === undefined ? undefined : JSON.parse(JSON.stringify(args));
136
+ address = address === undefined ? undefined : { moduleId: address.moduleId };
137
+ if (address !== undefined && (typeof address.moduleId !== 'string' || !address.moduleId))
138
+ throw new Error('Invalid final rest scope');
139
+ const key = finalRestScopeKey(group, address);
140
+ const lifecycle = this.lifecycle;
141
+ const moduleLifecycle = address ? this.moduleLifecycles.get(address.moduleId) ?? 0 : 0;
142
+ if (this.dead)
143
+ throw new Error('Final rest recovery required: disconnected');
144
+ if (this.claiming.has(key))
145
+ throw new Error('Final rest claim already pending');
146
+ this.claiming.add(key);
147
+ try {
148
+ // Probe only the pre-existing ping channel: old servers cannot execute an unacknowledged claim.
149
+ if (!this.supported || address !== undefined) {
150
+ this.send('ping', { clientTimeMs: Date.now() });
151
+ await new Promise(resolve => setTimeout(resolve, 500));
152
+ }
153
+ if (!this.supported || this.dead)
154
+ throw new Error('Final rest protocol unavailable');
155
+ if (lifecycle !== this.lifecycle || (address && moduleLifecycle !== (this.moduleLifecycles.get(address.moduleId) ?? 0)))
156
+ throw new Error('Final rest recovery required: stale lifecycle');
157
+ if (address && (!this.moduleSupported || !this.generations[address.moduleId]))
158
+ throw new Error('Module final rest protocol unavailable');
159
+ const scope = address && { ...address, generation: this.generations[address.moduleId], ...(engagementEpoch === undefined ? {} : { engagementEpoch }) };
160
+ const requestId = ++this.request;
161
+ const meta = { version: 1, requestId, group, ...(scope ? { scope } : {}) };
162
+ if (!isFinalRestClaim(meta))
163
+ throw new Error('Invalid final rest claim');
164
+ const reply = await this.rpc('action', { name: action, args, finalRest: meta, ...(scope ? { moduleId: scope.moduleId, engagementEpoch: scope.engagementEpoch } : {}) }, requestId, undefined, scope);
165
+ if (this.dead || lifecycle !== this.lifecycle || (address && moduleLifecycle !== (this.moduleLifecycles.get(address.moduleId) ?? 0)) || !sameFinalRestScope(scope, reply.scope) || reply.status !== 'claimed' || this.revoked.has(reply.transactionId) || reply.group !== group || !reply.members.length ||
166
+ new Set(reply.members.map(m => m.id)).size !== reply.members.length)
167
+ throw new Error('Final rest claim rejected');
168
+ for (const [id, t] of this.transactions)
169
+ if (finalRestScopeKey(t.grant.group, t.grant.scope) === key)
170
+ this.transactions.delete(id);
171
+ this.transactions.set(reply.transactionId, { grant: JSON.parse(JSON.stringify(reply)), phase: 'active' });
172
+ return JSON.parse(JSON.stringify(reply));
173
+ }
174
+ finally {
175
+ this.claiming.delete(key);
176
+ }
177
+ }
178
+ async commit(transactionId, states) {
179
+ states = JSON.parse(JSON.stringify(states));
180
+ const t = this.transactions.get(transactionId);
181
+ if (!t || t.phase !== 'active' || this.dead)
182
+ throw new Error('Final rest recovery required: no active claim');
183
+ const requestId = ++this.request;
184
+ const msg = { ...(t.grant.scope ? { moduleId: t.grant.scope.moduleId } : {}), seq: this.nextSequence(), tMs: performance.now(),
185
+ states: states.map(s => ({ ...s, transactionId })),
186
+ finalRest: { version: 1, requestId, group: t.grant.group, transactionId, ...(t.grant.scope ? { scope: t.grant.scope } : {}) } };
187
+ if (!isFinalRestBatch(msg) || states.length !== t.grant.members.length ||
188
+ new Set(states.map(s => s.e)).size !== states.length ||
189
+ t.grant.members.some(m => !states.some(s => s.e === m.id && s.ep === m.epoch)))
190
+ throw new Error('Invalid final rest batch');
191
+ t.phase = 'final'; // engine uploads cannot overwrite frozen settled samples during an ack delay/loss
192
+ try {
193
+ const reply = await this.rpc('entityStateBatch', msg, requestId, transactionId, t.grant.scope);
194
+ if (this.dead || !sameFinalRestScope(t.grant.scope, reply.scope) || t.phase !== 'final' || reply.status !== 'committed' || reply.transactionId !== transactionId || reply.group !== t.grant.group ||
195
+ !sameFinalRestScope(t.grant.scope, reply.snapshot.scope) || reply.snapshot.group !== t.grant.group ||
196
+ reply.snapshot.commit?.transactionId !== transactionId || reply.snapshot.commit.requestId !== requestId ||
197
+ reply.snapshot.entities.length !== states.length ||
198
+ states.some(s => !reply.snapshot.entities.some(e => {
199
+ const length = Math.hypot(...s.q);
200
+ return e.id === s.e && e.epoch === s.ep && e.pos.x === s.p[0] && e.pos.y === s.p[1] && e.pos.z === s.p[2] &&
201
+ e.velocity?.x === 0 && e.velocity.y === 0 && e.velocity.z === 0 &&
202
+ e.angularVelocity?.x === 0 && e.angularVelocity.y === 0 && e.angularVelocity.z === 0 &&
203
+ [e.rot.x, e.rot.y, e.rot.z, e.rot.w].every((v, i) => Math.abs(v - s.q[i] / length) < 1e-12);
204
+ }))) {
205
+ throw new Error('Final rest recovery required: commit rejected or snapshot mismatch');
206
+ }
207
+ t.phase = 'committed';
208
+ return reply.snapshot;
209
+ }
210
+ catch (e) {
211
+ t.phase = 'invalid';
212
+ throw e;
213
+ }
214
+ }
215
+ }
216
+ export { FINAL_REST_REPLY };
217
+ //# sourceMappingURL=multiplayer-final-rest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiplayer-final-rest.js","sourceRoot":"","sources":["../src/multiplayer-final-rest.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iBAAiB,EAC7E,gBAAgB,EAC6D,gBAAgB,EAAE,gBAAgB,GAChH,MAAM,wBAAwB,CAAC;AAEhC,4FAA4F;AAC5F,MAAM,OAAO,eAAe;IAcG;IACV;IAdX,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;IACnB,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,SAAS,GAAG,KAAK,CAAC;IAClB,eAAe,GAAG,KAAK,CAAC;IACxB,WAAW,GAA2B,EAAE,CAAC;IACzC,SAAS,GAAG,CAAC,CAAC;IACL,kBAAkB,GAAG,IAAI,GAAG,EA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