@principal-ai/control-tower-core 0.3.0 → 0.3.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/dist/index.js.map +3 -3
- package/dist/index.mjs +39 -6
- package/dist/index.mjs.map +3 -3
- package/dist/server/BaseServer.d.ts +22 -2
- package/dist/server/BaseServer.d.ts.map +1 -1
- package/dist/server/BaseServer.js +63 -8
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6378,6 +6378,7 @@ class BaseServer extends TypedEventEmitter {
|
|
|
6378
6378
|
const client = {
|
|
6379
6379
|
id: payload.clientId,
|
|
6380
6380
|
userId: payload.userId || "",
|
|
6381
|
+
deviceId: payload.clientId,
|
|
6381
6382
|
roomIds,
|
|
6382
6383
|
get roomId() {
|
|
6383
6384
|
return roomIds.size > 0 ? roomIds.values().next().value || null : null;
|
|
@@ -6457,6 +6458,7 @@ class BaseServer extends TypedEventEmitter {
|
|
|
6457
6458
|
const client = {
|
|
6458
6459
|
id: clientId,
|
|
6459
6460
|
userId: "",
|
|
6461
|
+
deviceId: clientId,
|
|
6460
6462
|
roomIds,
|
|
6461
6463
|
get roomId() {
|
|
6462
6464
|
return roomIds.size > 0 ? roomIds.values().next().value || null : null;
|
|
@@ -6485,10 +6487,10 @@ class BaseServer extends TypedEventEmitter {
|
|
|
6485
6487
|
}
|
|
6486
6488
|
if (this.presenceManager?.isEnabled() && client.userId) {
|
|
6487
6489
|
try {
|
|
6488
|
-
const presence = await this.presenceManager.disconnectDevice(client.userId,
|
|
6490
|
+
const presence = await this.presenceManager.disconnectDevice(client.userId, client.deviceId);
|
|
6489
6491
|
await this.emit("presence_device_disconnected", {
|
|
6490
6492
|
userId: client.userId,
|
|
6491
|
-
deviceId:
|
|
6493
|
+
deviceId: client.deviceId,
|
|
6492
6494
|
timestamp: Date.now()
|
|
6493
6495
|
});
|
|
6494
6496
|
const presenceConfig = this.presenceManager.getConfig();
|
|
@@ -6497,7 +6499,7 @@ class BaseServer extends TypedEventEmitter {
|
|
|
6497
6499
|
type: "presence:user_offline",
|
|
6498
6500
|
payload: {
|
|
6499
6501
|
userId: client.userId,
|
|
6500
|
-
deviceId:
|
|
6502
|
+
deviceId: client.deviceId,
|
|
6501
6503
|
status: presence?.status || "offline",
|
|
6502
6504
|
gracePeriod: presenceConfig.gracePeriod
|
|
6503
6505
|
}
|
|
@@ -6511,6 +6513,17 @@ class BaseServer extends TypedEventEmitter {
|
|
|
6511
6513
|
}
|
|
6512
6514
|
}
|
|
6513
6515
|
for (const roomId of client.roomIds) {
|
|
6516
|
+
try {
|
|
6517
|
+
await this.experimental.broadcastWhere((c) => c.roomIds.has(roomId) && c.id !== clientId, {
|
|
6518
|
+
type: "member_left",
|
|
6519
|
+
payload: {
|
|
6520
|
+
roomId,
|
|
6521
|
+
userId: client.userId,
|
|
6522
|
+
clientId,
|
|
6523
|
+
timestamp: Date.now()
|
|
6524
|
+
}
|
|
6525
|
+
});
|
|
6526
|
+
} catch {}
|
|
6514
6527
|
await this.roomManager.leaveRoom(roomId, client.userId);
|
|
6515
6528
|
await this.emit("client_left_room", { clientId, roomId });
|
|
6516
6529
|
}
|
|
@@ -6527,7 +6540,7 @@ class BaseServer extends TypedEventEmitter {
|
|
|
6527
6540
|
return;
|
|
6528
6541
|
}
|
|
6529
6542
|
if (this.presenceManager?.isEnabled() && client.userId && client.authenticated) {
|
|
6530
|
-
await this.updatePresenceActivity(client.userId,
|
|
6543
|
+
await this.updatePresenceActivity(client.userId, client.deviceId, "message");
|
|
6531
6544
|
}
|
|
6532
6545
|
switch (message.type) {
|
|
6533
6546
|
case "authenticate":
|
|
@@ -6716,6 +6729,17 @@ class BaseServer extends TypedEventEmitter {
|
|
|
6716
6729
|
if (!client.roomIds.has(roomId)) {
|
|
6717
6730
|
continue;
|
|
6718
6731
|
}
|
|
6732
|
+
try {
|
|
6733
|
+
await this.experimental.broadcastWhere((c) => c.roomIds.has(roomId) && c.id !== clientId, {
|
|
6734
|
+
type: "member_left",
|
|
6735
|
+
payload: {
|
|
6736
|
+
roomId,
|
|
6737
|
+
userId: client.userId,
|
|
6738
|
+
clientId,
|
|
6739
|
+
timestamp: Date.now()
|
|
6740
|
+
}
|
|
6741
|
+
});
|
|
6742
|
+
} catch {}
|
|
6719
6743
|
await this.roomManager.leaveRoom(roomId, client.userId);
|
|
6720
6744
|
client.roomIds.delete(roomId);
|
|
6721
6745
|
await this.emit("client_left_room", { clientId, roomId });
|
|
@@ -6888,7 +6912,16 @@ class BaseServer extends TypedEventEmitter {
|
|
|
6888
6912
|
});
|
|
6889
6913
|
}
|
|
6890
6914
|
getDeviceIdFromClientId(clientId) {
|
|
6891
|
-
|
|
6915
|
+
const client = this.clients.get(clientId);
|
|
6916
|
+
return client?.deviceId ?? clientId;
|
|
6917
|
+
}
|
|
6918
|
+
setClientDeviceId(clientId, deviceId) {
|
|
6919
|
+
const client = this.clients.get(clientId);
|
|
6920
|
+
if (client) {
|
|
6921
|
+
client.deviceId = deviceId;
|
|
6922
|
+
return true;
|
|
6923
|
+
}
|
|
6924
|
+
return false;
|
|
6892
6925
|
}
|
|
6893
6926
|
}
|
|
6894
6927
|
// src/server/ServerBuilder.ts
|
|
@@ -7057,4 +7090,4 @@ export {
|
|
|
7057
7090
|
BaseClient
|
|
7058
7091
|
};
|
|
7059
7092
|
|
|
7060
|
-
//# debugId=
|
|
7093
|
+
//# debugId=9959D96F79712BE364756E2164756E21
|