@principal-ai/control-tower-core 0.2.2 → 0.3.0

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.
@@ -92,37 +92,91 @@ class PresenceClient extends EventEmitter_js_1.TypedEventEmitter {
92
92
  }
93
93
  }
94
94
  /**
95
- * Get all online users
95
+ * Get all online users with their presence data
96
96
  *
97
- * Note: This requires a corresponding API endpoint on your server.
97
+ * @returns Array of user presence objects
98
98
  */
99
99
  async getOnlineUsers() {
100
- // This assumes you have a REST API endpoint for fetching online users
101
- // You can customize this based on your server implementation
102
- throw new Error("getOnlineUsers() requires a REST API endpoint. " +
103
- "Implement this method based on your server API.");
100
+ const response = await this.client.request("presence:get_users", {});
101
+ return response.users;
102
+ }
103
+ /**
104
+ * Get presence information for a specific user
105
+ *
106
+ * @param userId The user ID to look up
107
+ * @returns User presence or null if not found
108
+ */
109
+ async getUserPresence(userId) {
110
+ const response = await this.client.request("presence:get_user", { userId });
111
+ return response.user;
112
+ }
113
+ /**
114
+ * Get all users in a specific repository
115
+ *
116
+ * @param owner Repository owner
117
+ * @param repo Repository name
118
+ * @returns Array of user presence objects
119
+ */
120
+ async getRepoUsers(owner, repo) {
121
+ const response = await this.client.request("presence:get_repo_users", { owner, repo });
122
+ return response.users;
104
123
  }
105
124
  /**
106
125
  * Set user status
107
126
  *
108
- * Note: This requires a corresponding API endpoint on your server.
127
+ * @param status The status to set ('online' or 'away')
128
+ * @param statusMessage Optional status message
109
129
  */
110
- async setStatus(status, message) {
111
- // This assumes you have a REST API endpoint for setting status
112
- // You can customize this based on your server implementation
113
- throw new Error("setStatus() requires a REST API endpoint. " +
114
- "Implement this method based on your server API.");
130
+ async setStatus(status, statusMessage) {
131
+ const response = await this.client.request("presence:set_status", { status, statusMessage });
132
+ if (!response.success) {
133
+ throw new Error(response.error || "Failed to set status");
134
+ }
115
135
  }
116
136
  /**
117
- * Set visibility
137
+ * Set visibility (invisible/lurker mode)
118
138
  *
119
- * Note: This requires a corresponding API endpoint on your server.
139
+ * @param visible Whether the user should be visible to others
120
140
  */
121
141
  async setVisibility(visible) {
122
- // This assumes you have a REST API endpoint for setting visibility
123
- // You can customize this based on your server implementation
124
- throw new Error("setVisibility() requires a REST API endpoint. " +
125
- "Implement this method based on your server API.");
142
+ const response = await this.client.request("presence:set_visibility", { visible });
143
+ if (!response.success) {
144
+ throw new Error(response.error || "Failed to set visibility");
145
+ }
146
+ }
147
+ /**
148
+ * Report that a repository was opened
149
+ *
150
+ * @param repoId Repository ID (format: "owner/repo")
151
+ * @param branch Branch name
152
+ */
153
+ async reportRepoOpened(repoId, branch) {
154
+ const response = await this.client.request("presence:repo_open", { repoId, branch });
155
+ if (!response.success) {
156
+ throw new Error(response.error || "Failed to report repo opened");
157
+ }
158
+ }
159
+ /**
160
+ * Report that a repository was closed
161
+ *
162
+ * @param repoId Repository ID (format: "owner/repo")
163
+ */
164
+ async reportRepoClosed(repoId) {
165
+ const response = await this.client.request("presence:repo_close", { repoId });
166
+ if (!response.success) {
167
+ throw new Error(response.error || "Failed to report repo closed");
168
+ }
169
+ }
170
+ /**
171
+ * Report that a repository is now focused/active
172
+ *
173
+ * @param repoId Repository ID (format: "owner/repo")
174
+ */
175
+ async reportRepoFocused(repoId) {
176
+ const response = await this.client.request("presence:repo_focus", { repoId });
177
+ if (!response.success) {
178
+ throw new Error(response.error || "Failed to report repo focused");
179
+ }
126
180
  }
127
181
  /**
128
182
  * Get the underlying BaseClient
package/dist/index.d.ts CHANGED
@@ -3,6 +3,6 @@ export { MockAuthAdapter, type MockICECandidate, MockRTCDataChannel, type MockRT
3
3
  export { type PeerConnection, type PeerConnectionState, WebRTCSignalingAdapter, type WebRTCSignalingConfig, type WebRTCSignalingEvents, } from "./adapters/webrtc/index.js";
4
4
  export { BrowserWebSocketTransportAdapter, type BrowserWebSocketConfig, type WebSocketClientConfig, WebSocketClientTransportAdapter, WebSocketServerTransportAdapter, type WebSocketServerTransportConfig, } from "./adapters/websocket/index.js";
5
5
  export { BaseClient, ClientBuilder, type ClientConfig, type ClientEvents, PresenceClient, type PresenceClientConfig, type PresenceClientEvents, } from "./client/index.js";
6
- export { BaseServer, type ConnectedClient, ExperimentalAPI, ServerBuilder, type ServerConfig, type ServerEvents, } from "./server/index.js";
7
- export { ActivityUpdate, AuthenticatePayload, AuthenticateResult, AuthResult, BaseEvent, BranchChangeEvent, BroadcastOptions, BroadcastResult, ClientPredicate, CloseHandler, CommitEvent, ConnectionOptions, ConnectionState, CursorPositionEvent, DeviceInfo, ErrorHandler, Event, EventType, ExperimentalFeatureConfig, ExperimentalFeatureError, ExperimentalUsageEvent, FileAction, FileChangeEvent, GitStatusEvent, JWTConfig, Lock, LockPriority, LockQueueItem, LockRequest, LockState, LockType, Message, MessageHandler, PresenceChangeEvent, PresenceConfig, PresenceStatus, Room, RoomConfig, RoomPermission, RoomState, RoomUser, TokenPayload, UserPresence, UserStatus, } from "./types/index.js";
6
+ export { BaseServer, type ConnectedClient, type CustomMessageHandler, ExperimentalAPI, ServerBuilder, type ServerConfig, type ServerEvents, } from "./server/index.js";
7
+ export { ActivityUpdate, AuthenticatePayload, AuthenticateResult, AuthResult, BaseEvent, BranchChangeEvent, BroadcastOptions, BroadcastResult, ClientPredicate, CloseHandler, CommitEvent, ConnectionOptions, ConnectionState, CursorPositionEvent, DeviceInfo, ErrorHandler, Event, EventType, ExperimentalFeatureConfig, ExperimentalFeatureError, ExperimentalUsageEvent, FileAction, FileChangeEvent, GitStatusEvent, JWTConfig, Lock, LockPriority, LockQueueItem, LockRequest, LockState, LockType, Message, MessageHandler, PresenceActionResponse, PresenceChangeEvent, PresenceConfig, PresenceGetRepoUsersResponse, PresenceGetUserResponse, PresenceGetUsersResponse, PresenceStats, PresenceStatus, RepositorySession, Room, RoomConfig, RoomPermission, RoomState, RoomUser, SerializableUserPresence, TokenPayload, UserPresence, UserStatus, } from "./types/index.js";
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3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AiB,EACjB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,WAAW,EACX,iBAAiB,EAEjB,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,KAAK,EAEL,SAAS,EAET,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,EACtB,UAAU,EACV,eAAe,EACf,cAAc,EACd,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,WAAW,EACX,SAAS,EAET,QAAQ,EACR,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,cAAc,EAEd,cAAc,EACd,IAAI,EACJ,UAAU,EAEV,cAAc,EACd,SAAS,EACT,QAAQ,EAER,YAAY,EACZ,YAAY,EACZ,UAAU,GACV,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,GACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACN,eAAe,EACf,KAAK,gBAAgB,EAErB,kBAAkB,EAClB,KAAK,wBAAwB,EAC7B,qBAAqB,EACrB,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAC3B,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,GACtB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,sBAAsB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC1B,MAAM,4BAA4B,CAAC;AAGpC,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