thinkncollab-shell 0.0.9 → 0.0.12

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.
@@ -74,6 +74,9 @@ class WebSocketManager extends EventEmitter {
74
74
  this.connected = false;
75
75
  this.emit('disconnected', { reason });
76
76
  });
77
+ this.socket.on('task:verdict', (data) => {
78
+ this.emit('task:verdict', data);
79
+ });
77
80
 
78
81
  this.socket.on('reconnect', () => {
79
82
  this.connected = true;
@@ -113,6 +116,7 @@ class WebSocketManager extends EventEmitter {
113
116
  * { userId, name, userType } ← legacy
114
117
  */
115
118
  setUser(user, token = null) {
119
+ this._user = user;
116
120
  if (!user) return;
117
121
 
118
122
  if (token) this._authToken = token;
@@ -295,27 +299,27 @@ class WebSocketManager extends EventEmitter {
295
299
  return Promise.resolve({ success: true });
296
300
  }
297
301
 
298
- // ─── Send message ─────────────────────────────────────────────────────────
302
+ sendMessage(message, replyTo = null) {
303
+ return new Promise((resolve, reject) => {
304
+ if (!this.socket?.connected) return reject(new Error('Not connected'));
299
305
 
300
- sendMessage(message) {
301
- if (!this.connected || !this.socket) {
302
- this.messageQueue.push(message);
303
- return Promise.resolve({ queued: true });
304
- }
305
- if (!this.roomId) return Promise.reject(new Error('Not in a room — run: join <room-id>'));
306
- if (!this.currentUser) return Promise.reject(new Error('Not logged in — run: login'));
306
+ const roomId = this.roomId;
307
+ if (!roomId) return reject(new Error('Not in any room. Use: join <room-id>'));
308
+
309
+ if (!this.currentUser) return reject(new Error('Not authenticated. Run: login'));
307
310
 
308
311
  this.socket.emit('thinknsh:message', {
309
- roomId: this.roomId,
312
+ roomId,
310
313
  userId: this.currentUser.userId,
311
314
  name: this.currentUser.name,
312
- userType: this.currentUser.userType,
315
+ userType: this.currentUser.userType || 'User',
313
316
  message,
317
+ replyTo: replyTo || null
314
318
  });
315
319
 
316
- return Promise.resolve({ success: true });
317
- }
318
-
320
+ resolve();
321
+ });
322
+ }
319
323
  // ─── History ──────────────────────────────────────────────────────────────
320
324
 
321
325
  getHistory(limit = 30, skip = 0) {
@@ -109,10 +109,9 @@ class NotificationManager extends EventEmitter {
109
109
 
110
110
  /* Play notification sound
111
111
  */
112
- playSound() {
113
- // TODO: Implement sound playing
114
- // This would use 'sound-play' or similar package
115
- }
112
+ playSound() {
113
+ process.stdout.write('\x07'); // terminal bell — zero dependencies
114
+ }
116
115
 
117
116
  /* Mark notification as read
118
117
  */