vibex-sh 0.2.1 → 0.2.2

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 +36 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -431,14 +431,19 @@ async function main() {
431
431
  socket.on('connect', () => {
432
432
  isConnected = true;
433
433
  console.log(' ✓ Connected to server\n');
434
+ console.error(`[CLI DEBUG] Socket connected, socket.id: ${socket.id}`);
435
+ console.error(`[CLI DEBUG] About to emit join-session for: ${sessionId}`);
434
436
  // Rejoin session on reconnect
435
437
  socket.emit('join-session', sessionId);
438
+ console.error(`[CLI DEBUG] ✅ join-session emitted, waiting 100ms before setting hasJoinedSession`);
436
439
  // Wait a tiny bit for join-session to be processed
437
440
  setTimeout(() => {
438
441
  hasJoinedSession = true;
442
+ console.error(`[CLI DEBUG] hasJoinedSession set to true, processing ${logQueue.length} queued logs`);
439
443
  // Process any queued logs
440
444
  while (logQueue.length > 0) {
441
445
  const logData = logQueue.shift();
446
+ console.error(`[CLI DEBUG] Emitting queued cli-emit (connect) for sessionId: ${sessionId}`);
442
447
  socket.emit('cli-emit', {
443
448
  sessionId,
444
449
  ...logData,
@@ -471,6 +476,7 @@ async function main() {
471
476
  // Process any queued logs
472
477
  while (logQueue.length > 0) {
473
478
  const logData = logQueue.shift();
479
+ console.error(`[CLI DEBUG] Emitting queued cli-emit (reconnect) for sessionId: ${sessionId}`);
474
480
  socket.emit('cli-emit', {
475
481
  sessionId,
476
482
  ...logData,
@@ -537,6 +543,25 @@ async function main() {
537
543
 
538
544
  // Handle general errors from server
539
545
  socket.on('error', (data) => {
546
+ // Check if it's a history limit error
547
+ if (data && data.error === 'History Limit Reached') {
548
+ console.error('\n 🚫 History Limit Reached');
549
+ console.error(` ${data.message || 'Session history limit reached'}`);
550
+ if (data.limit !== undefined && data.current !== undefined) {
551
+ console.error(` Current: ${data.current} / ${data.limit} logs`);
552
+ }
553
+ if (data.upgradeRequired) {
554
+ console.error(' 💡 Upgrade to Pro to unlock 30 days retention');
555
+ console.error(' 🌐 Visit: https://vibex.sh/pricing');
556
+ }
557
+ console.error('');
558
+ // Clear the queue and stop processing
559
+ logQueue.length = 0;
560
+ hasJoinedSession = false; // Prevent further logs from being sent
561
+ return;
562
+ }
563
+
564
+ // Handle other errors
540
565
  console.error('\n ✗ Server Error');
541
566
  if (typeof data === 'string') {
542
567
  console.error(` ${data}`);
@@ -558,8 +583,10 @@ async function main() {
558
583
  });
559
584
 
560
585
  rl.on('line', (line) => {
586
+ console.error(`[CLI DEBUG] Received line from stdin: "${line}"`);
561
587
  const trimmedLine = line.trim();
562
588
  if (!trimmedLine) {
589
+ console.error(`[CLI DEBUG] Line is empty, skipping`);
563
590
  return;
564
591
  }
565
592
 
@@ -571,22 +598,31 @@ async function main() {
571
598
  payload: parsed,
572
599
  timestamp: Date.now(),
573
600
  };
601
+ console.error(`[CLI DEBUG] Parsed as JSON log`);
574
602
  } catch (e) {
575
603
  logData = {
576
604
  type: 'text',
577
605
  payload: trimmedLine,
578
606
  timestamp: Date.now(),
579
607
  };
608
+ console.error(`[CLI DEBUG] Parsed as text log`);
580
609
  }
581
610
 
611
+ console.error(`[CLI DEBUG] Connection state - isConnected: ${isConnected}, hasJoinedSession: ${hasJoinedSession}, socket.connected: ${socket?.connected}`);
612
+
582
613
  // If connected and joined session, send immediately; otherwise queue it
583
614
  if (isConnected && hasJoinedSession && socket.connected) {
615
+ console.error(`[CLI DEBUG] ✅ Ready to emit - Emitting cli-emit for sessionId: ${sessionId}`);
616
+ console.error(`[CLI DEBUG] Log data:`, JSON.stringify(logData, null, 2));
584
617
  socket.emit('cli-emit', {
585
618
  sessionId,
586
619
  ...logData,
587
620
  });
621
+ console.error(`[CLI DEBUG] ✅ cli-emit event emitted successfully`);
588
622
  } else {
623
+ console.error(`[CLI DEBUG] ⏸️ Queueing log - isConnected: ${isConnected}, hasJoinedSession: ${hasJoinedSession}, socket.connected: ${socket?.connected}`);
589
624
  logQueue.push(logData);
625
+ console.error(`[CLI DEBUG] Queue now has ${logQueue.length} items`);
590
626
  }
591
627
  });
592
628
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibex-sh",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Zero-config observability CLI - pipe logs and visualize instantly",
5
5
  "type": "module",
6
6
  "bin": {