vibex-sh 0.2.1 β†’ 0.2.3

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.
Files changed (2) hide show
  1. package/index.js +48 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -399,15 +399,8 @@ async function main() {
399
399
  console.log(' πŸ’‘ Tip: Use -s to send more logs to this session');
400
400
  console.log(` Example: echo '{"cpu": 45, "memory": 78}' | npx vibex-sh -s ${sessionSlug}${localFlag}\n`);
401
401
  } else {
402
- // When reusing a session, show minimal info
403
- const dashboardUrl = authCode
404
- ? `${webUrl}/${sessionId}?auth=${authCode}`
405
- : `${webUrl}/${sessionId}`;
406
- console.log(` πŸ” Sending logs to session: ${sessionId}`);
407
- if (authCode) {
408
- console.log(` Auth Code: ${authCode}`);
409
- }
410
- console.log(` Dashboard: ${dashboardUrl}\n`);
402
+ // When reusing a session, show minimal info (no auth code)
403
+ console.log(` πŸ” Sending logs to session: ${sessionId}\n`);
411
404
  }
412
405
 
413
406
  const socket = io(socketUrl, {
@@ -427,18 +420,26 @@ async function main() {
427
420
 
428
421
  // Store auth code received from socket
429
422
  let receivedAuthCode = authCode;
423
+
424
+ // Track if this is a new session (not reusing an existing one)
425
+ const isNewSession = !options.sessionId;
430
426
 
431
427
  socket.on('connect', () => {
432
428
  isConnected = true;
433
429
  console.log(' βœ“ Connected to server\n');
430
+ console.error(`[CLI DEBUG] Socket connected, socket.id: ${socket.id}`);
431
+ console.error(`[CLI DEBUG] About to emit join-session for: ${sessionId}`);
434
432
  // Rejoin session on reconnect
435
433
  socket.emit('join-session', sessionId);
434
+ console.error(`[CLI DEBUG] βœ… join-session emitted, waiting 100ms before setting hasJoinedSession`);
436
435
  // Wait a tiny bit for join-session to be processed
437
436
  setTimeout(() => {
438
437
  hasJoinedSession = true;
438
+ console.error(`[CLI DEBUG] hasJoinedSession set to true, processing ${logQueue.length} queued logs`);
439
439
  // Process any queued logs
440
440
  while (logQueue.length > 0) {
441
441
  const logData = logQueue.shift();
442
+ console.error(`[CLI DEBUG] Emitting queued cli-emit (connect) for sessionId: ${sessionId}`);
442
443
  socket.emit('cli-emit', {
443
444
  sessionId,
444
445
  ...logData,
@@ -448,15 +449,17 @@ async function main() {
448
449
  });
449
450
 
450
451
  // Listen for auth code from socket.io (for unclaimed sessions)
452
+ // Only display auth code if this is a new session (not when reusing existing session)
451
453
  socket.on('session-auth-code', (data) => {
452
454
  if (data.sessionId === sessionId && data.authCode) {
453
- // Always update and display auth code if received from socket
454
- // This ensures we show it even if we didn't get it from claimSession
455
+ // Update received auth code
455
456
  if (!receivedAuthCode || receivedAuthCode !== data.authCode) {
456
457
  receivedAuthCode = data.authCode;
457
- // Display auth code when received (for both new and existing sessions)
458
- console.log(` πŸ”‘ Auth Code: ${receivedAuthCode}`);
459
- console.log(` πŸ“‹ Dashboard: ${webUrl}/${sessionId}?auth=${receivedAuthCode}\n`);
458
+ // Only display auth code for new sessions, not when reusing existing sessions
459
+ if (isNewSession) {
460
+ console.log(` πŸ”‘ Auth Code: ${receivedAuthCode}`);
461
+ console.log(` πŸ“‹ Dashboard: ${webUrl}/${sessionId}?auth=${receivedAuthCode}\n`);
462
+ }
460
463
  }
461
464
  }
462
465
  });
@@ -471,6 +474,7 @@ async function main() {
471
474
  // Process any queued logs
472
475
  while (logQueue.length > 0) {
473
476
  const logData = logQueue.shift();
477
+ console.error(`[CLI DEBUG] Emitting queued cli-emit (reconnect) for sessionId: ${sessionId}`);
474
478
  socket.emit('cli-emit', {
475
479
  sessionId,
476
480
  ...logData,
@@ -537,6 +541,25 @@ async function main() {
537
541
 
538
542
  // Handle general errors from server
539
543
  socket.on('error', (data) => {
544
+ // Check if it's a history limit error
545
+ if (data && data.error === 'History Limit Reached') {
546
+ console.error('\n 🚫 History Limit Reached');
547
+ console.error(` ${data.message || 'Session history limit reached'}`);
548
+ if (data.limit !== undefined && data.current !== undefined) {
549
+ console.error(` Current: ${data.current} / ${data.limit} logs`);
550
+ }
551
+ if (data.upgradeRequired) {
552
+ console.error(' πŸ’‘ Upgrade to Pro to unlock 30 days retention');
553
+ console.error(' 🌐 Visit: https://vibex.sh/pricing');
554
+ }
555
+ console.error('');
556
+ // Clear the queue and stop processing
557
+ logQueue.length = 0;
558
+ hasJoinedSession = false; // Prevent further logs from being sent
559
+ return;
560
+ }
561
+
562
+ // Handle other errors
540
563
  console.error('\n βœ— Server Error');
541
564
  if (typeof data === 'string') {
542
565
  console.error(` ${data}`);
@@ -558,8 +581,10 @@ async function main() {
558
581
  });
559
582
 
560
583
  rl.on('line', (line) => {
584
+ console.error(`[CLI DEBUG] Received line from stdin: "${line}"`);
561
585
  const trimmedLine = line.trim();
562
586
  if (!trimmedLine) {
587
+ console.error(`[CLI DEBUG] Line is empty, skipping`);
563
588
  return;
564
589
  }
565
590
 
@@ -571,22 +596,31 @@ async function main() {
571
596
  payload: parsed,
572
597
  timestamp: Date.now(),
573
598
  };
599
+ console.error(`[CLI DEBUG] Parsed as JSON log`);
574
600
  } catch (e) {
575
601
  logData = {
576
602
  type: 'text',
577
603
  payload: trimmedLine,
578
604
  timestamp: Date.now(),
579
605
  };
606
+ console.error(`[CLI DEBUG] Parsed as text log`);
580
607
  }
581
608
 
609
+ console.error(`[CLI DEBUG] Connection state - isConnected: ${isConnected}, hasJoinedSession: ${hasJoinedSession}, socket.connected: ${socket?.connected}`);
610
+
582
611
  // If connected and joined session, send immediately; otherwise queue it
583
612
  if (isConnected && hasJoinedSession && socket.connected) {
613
+ console.error(`[CLI DEBUG] βœ… Ready to emit - Emitting cli-emit for sessionId: ${sessionId}`);
614
+ console.error(`[CLI DEBUG] Log data:`, JSON.stringify(logData, null, 2));
584
615
  socket.emit('cli-emit', {
585
616
  sessionId,
586
617
  ...logData,
587
618
  });
619
+ console.error(`[CLI DEBUG] βœ… cli-emit event emitted successfully`);
588
620
  } else {
621
+ console.error(`[CLI DEBUG] ⏸️ Queueing log - isConnected: ${isConnected}, hasJoinedSession: ${hasJoinedSession}, socket.connected: ${socket?.connected}`);
589
622
  logQueue.push(logData);
623
+ console.error(`[CLI DEBUG] Queue now has ${logQueue.length} items`);
590
624
  }
591
625
  });
592
626
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibex-sh",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Zero-config observability CLI - pipe logs and visualize instantly",
5
5
  "type": "module",
6
6
  "bin": {