@principal-ai/control-tower-core 0.1.17 → 0.1.19

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/dist/index.mjs CHANGED
@@ -2856,6 +2856,23 @@ var require_websocket_server = __commonJS((exports, module) => {
2856
2856
  }
2857
2857
  }
2858
2858
  });
2859
+ // src/types/room.ts
2860
+ function serializeRoomState(state) {
2861
+ return {
2862
+ room: state.room,
2863
+ users: Object.fromEntries(state.users),
2864
+ eventHistory: state.eventHistory,
2865
+ locks: Object.fromEntries(state.locks)
2866
+ };
2867
+ }
2868
+ function deserializeRoomState(serialized) {
2869
+ return {
2870
+ room: serialized.room,
2871
+ users: new Map(Object.entries(serialized.users)),
2872
+ eventHistory: serialized.eventHistory,
2873
+ locks: new Map(Object.entries(serialized.locks))
2874
+ };
2875
+ }
2859
2876
  // src/types/experimental.ts
2860
2877
  class ExperimentalFeatureError extends Error {
2861
2878
  feature;
@@ -4806,8 +4823,9 @@ class BaseClient extends TypedEventEmitter {
4806
4823
  }
4807
4824
  async handleRoomJoined(payload) {
4808
4825
  this.currentRoomId = payload.roomId;
4809
- this.currentRoomState = payload.state;
4810
- await this.emit("room_joined", payload);
4826
+ const roomState = deserializeRoomState(payload.state);
4827
+ this.currentRoomState = roomState;
4828
+ await this.emit("room_joined", { roomId: payload.roomId, state: roomState });
4811
4829
  }
4812
4830
  async handleRoomLeft(payload) {
4813
4831
  if (this.currentRoomId === payload.roomId) {
@@ -5589,12 +5607,7 @@ class BaseServer extends TypedEventEmitter {
5589
5607
  if (!updatedRoomState) {
5590
5608
  throw new Error("Failed to get updated room state after joining");
5591
5609
  }
5592
- const serializableState = {
5593
- room: updatedRoomState.room,
5594
- users: Object.fromEntries(updatedRoomState.users),
5595
- eventHistory: updatedRoomState.eventHistory,
5596
- locks: Object.fromEntries(updatedRoomState.locks)
5597
- };
5610
+ const serializableState = serializeRoomState(updatedRoomState);
5598
5611
  await this.sendToClient(clientId, {
5599
5612
  type: "room_joined",
5600
5613
  roomId: payload.roomId,
@@ -5922,4 +5935,4 @@ export {
5922
5935
  BaseClient
5923
5936
  };
5924
5937
 
5925
- //# debugId=781119E335F817FC64756E2164756E21
5938
+ //# debugId=16358B5F472DB04F64756E2164756E21