@principal-ai/control-tower-core 0.1.7 → 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.
- package/README.md +53 -0
- package/dist/abstractions/DefaultPresenceManager.d.ts +40 -0
- package/dist/abstractions/DefaultPresenceManager.d.ts.map +1 -0
- package/dist/abstractions/DefaultPresenceManager.js +256 -0
- package/dist/abstractions/PresenceManager.d.ts +127 -0
- package/dist/abstractions/PresenceManager.d.ts.map +1 -0
- package/dist/abstractions/PresenceManager.js +80 -0
- package/dist/abstractions/index.d.ts +2 -0
- package/dist/abstractions/index.d.ts.map +1 -1
- package/dist/abstractions/index.js +5 -1
- package/dist/adapters/mock/MockTransportAdapter.d.ts +37 -1
- package/dist/adapters/mock/MockTransportAdapter.d.ts.map +1 -1
- package/dist/adapters/mock/MockTransportAdapter.js +101 -2
- package/dist/adapters/websocket/WebSocketTransportAdapter.d.ts.map +1 -1
- package/dist/adapters/websocket/WebSocketTransportAdapter.js +5 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +9 -7
- package/dist/index.mjs +513 -30
- package/dist/index.mjs.map +9 -7
- package/dist/server/BaseServer.d.ts +59 -0
- package/dist/server/BaseServer.d.ts.map +1 -1
- package/dist/server/BaseServer.js +219 -28
- package/dist/server/ServerBuilder.d.ts +11 -0
- package/dist/server/ServerBuilder.d.ts.map +1 -1
- package/dist/server/ServerBuilder.js +13 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/presence.d.ts +163 -0
- package/dist/types/presence.d.ts.map +1 -0
- package/dist/types/presence.js +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Presence System Types
|
|
3
|
+
*
|
|
4
|
+
* Types for tracking global user presence independent of room membership.
|
|
5
|
+
* Supports multi-device connections and activity monitoring.
|
|
6
|
+
*/
|
|
7
|
+
export type PresenceStatus = 'online' | 'away' | 'offline';
|
|
8
|
+
/**
|
|
9
|
+
* Device information for a connected client
|
|
10
|
+
*/
|
|
11
|
+
export interface DeviceInfo {
|
|
12
|
+
/**
|
|
13
|
+
* Unique device identifier (client ID)
|
|
14
|
+
*/
|
|
15
|
+
deviceId: string;
|
|
16
|
+
/**
|
|
17
|
+
* Device type (desktop, mobile, web, etc.)
|
|
18
|
+
*/
|
|
19
|
+
type?: string;
|
|
20
|
+
/**
|
|
21
|
+
* When this device connected
|
|
22
|
+
*/
|
|
23
|
+
connectedAt: number;
|
|
24
|
+
/**
|
|
25
|
+
* Last activity timestamp for this device
|
|
26
|
+
*/
|
|
27
|
+
lastActivity: number;
|
|
28
|
+
/**
|
|
29
|
+
* Device metadata (browser, OS, etc.)
|
|
30
|
+
*/
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* User presence state
|
|
35
|
+
*
|
|
36
|
+
* Tracks a user's global presence across all their connected devices
|
|
37
|
+
*/
|
|
38
|
+
export interface UserPresence {
|
|
39
|
+
/**
|
|
40
|
+
* User ID
|
|
41
|
+
*/
|
|
42
|
+
userId: string;
|
|
43
|
+
/**
|
|
44
|
+
* Overall presence status
|
|
45
|
+
* - online: At least one device is active
|
|
46
|
+
* - away: All devices are idle
|
|
47
|
+
* - offline: No devices connected (grace period may apply)
|
|
48
|
+
*/
|
|
49
|
+
status: PresenceStatus;
|
|
50
|
+
/**
|
|
51
|
+
* All devices connected for this user
|
|
52
|
+
*/
|
|
53
|
+
devices: Map<string, DeviceInfo>;
|
|
54
|
+
/**
|
|
55
|
+
* When the user first connected (earliest device connection)
|
|
56
|
+
*/
|
|
57
|
+
firstConnectedAt: number;
|
|
58
|
+
/**
|
|
59
|
+
* Last activity across all devices
|
|
60
|
+
*/
|
|
61
|
+
lastActivity: number;
|
|
62
|
+
/**
|
|
63
|
+
* User metadata
|
|
64
|
+
*/
|
|
65
|
+
metadata?: Record<string, unknown>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Configuration for presence tracking
|
|
69
|
+
*/
|
|
70
|
+
export interface PresenceConfig {
|
|
71
|
+
/**
|
|
72
|
+
* Enable global presence tracking
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
enabled?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Heartbeat interval in milliseconds
|
|
78
|
+
* How often clients should send heartbeats
|
|
79
|
+
* @default 30000 (30 seconds)
|
|
80
|
+
*/
|
|
81
|
+
heartbeatInterval?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Number of missed heartbeats before marking as away
|
|
84
|
+
* @default 2
|
|
85
|
+
*/
|
|
86
|
+
awayThreshold?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Number of missed heartbeats before disconnecting
|
|
89
|
+
* @default 3
|
|
90
|
+
*/
|
|
91
|
+
disconnectThreshold?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Grace period in milliseconds after disconnect
|
|
94
|
+
* Allows seamless reconnection without losing state
|
|
95
|
+
* @default 30000 (30 seconds)
|
|
96
|
+
*/
|
|
97
|
+
gracePeriod?: number;
|
|
98
|
+
/**
|
|
99
|
+
* Track device-level activity
|
|
100
|
+
* @default true
|
|
101
|
+
*/
|
|
102
|
+
trackDeviceActivity?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Broadcast presence updates to authenticated clients
|
|
105
|
+
* @default true
|
|
106
|
+
*/
|
|
107
|
+
broadcastPresenceUpdates?: boolean;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Presence change event
|
|
111
|
+
*/
|
|
112
|
+
export interface PresenceChangeEvent {
|
|
113
|
+
/**
|
|
114
|
+
* User whose presence changed
|
|
115
|
+
*/
|
|
116
|
+
userId: string;
|
|
117
|
+
/**
|
|
118
|
+
* Previous status
|
|
119
|
+
*/
|
|
120
|
+
previousStatus: PresenceStatus;
|
|
121
|
+
/**
|
|
122
|
+
* New status
|
|
123
|
+
*/
|
|
124
|
+
status: PresenceStatus;
|
|
125
|
+
/**
|
|
126
|
+
* Timestamp of the change
|
|
127
|
+
*/
|
|
128
|
+
timestamp: number;
|
|
129
|
+
/**
|
|
130
|
+
* Device that triggered the change (if applicable)
|
|
131
|
+
*/
|
|
132
|
+
deviceId?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Reason for the change
|
|
135
|
+
*/
|
|
136
|
+
reason?: 'connected' | 'disconnected' | 'activity' | 'heartbeat_timeout' | 'grace_period_expired';
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Activity update from a client
|
|
140
|
+
*/
|
|
141
|
+
export interface ActivityUpdate {
|
|
142
|
+
/**
|
|
143
|
+
* User ID
|
|
144
|
+
*/
|
|
145
|
+
userId: string;
|
|
146
|
+
/**
|
|
147
|
+
* Device ID (client ID)
|
|
148
|
+
*/
|
|
149
|
+
deviceId: string;
|
|
150
|
+
/**
|
|
151
|
+
* Timestamp of the activity
|
|
152
|
+
*/
|
|
153
|
+
timestamp: number;
|
|
154
|
+
/**
|
|
155
|
+
* Type of activity (optional)
|
|
156
|
+
*/
|
|
157
|
+
activityType?: 'heartbeat' | 'message' | 'user_action';
|
|
158
|
+
/**
|
|
159
|
+
* Additional metadata
|
|
160
|
+
*/
|
|
161
|
+
metadata?: Record<string, unknown>;
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=presence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../../src/types/presence.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;I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