vibex-sh 0.2.0 → 0.2.1

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 +57 -8
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -377,10 +377,13 @@ async function main() {
377
377
 
378
378
  // Auto-claim session if token is available and fetch auth code
379
379
  let authCode = null;
380
- if (token && !options.sessionId) {
381
- // Only auto-claim new sessions (not when reusing existing session)
380
+ if (token) {
381
+ // Try to claim session (works for both new and existing sessions)
382
+ // For new sessions, this will create and claim
383
+ // For existing sessions, this will return the auth code if user owns it
382
384
  authCode = await claimSession(sessionId, token, webUrl);
383
- if (authCode) {
385
+ if (authCode && !options.sessionId) {
386
+ // Only show claim message for new sessions
384
387
  console.log(' ✓ Session automatically claimed to your account\n');
385
388
  }
386
389
  }
@@ -446,11 +449,15 @@ async function main() {
446
449
 
447
450
  // Listen for auth code from socket.io (for unclaimed sessions)
448
451
  socket.on('session-auth-code', (data) => {
449
- if (data.sessionId === sessionId && data.authCode && !receivedAuthCode) {
450
- receivedAuthCode = data.authCode;
451
- // Display auth code when received (for both new and existing sessions)
452
- console.log(` 🔑 Auth Code: ${receivedAuthCode}`);
453
- console.log(` 📋 Dashboard: ${webUrl}/${sessionId}?auth=${receivedAuthCode}\n`);
452
+ 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
+ if (!receivedAuthCode || receivedAuthCode !== data.authCode) {
456
+ 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`);
460
+ }
454
461
  }
455
462
  });
456
463
 
@@ -502,6 +509,48 @@ async function main() {
502
509
  }
503
510
  });
504
511
 
512
+ // Handle rate limit errors from server
513
+ socket.on('rate-limit-exceeded', (data) => {
514
+ console.error('\n ⚠️ Rate Limit Exceeded');
515
+ console.error(` ${data.message || 'Too many requests. Please try again later.'}`);
516
+ if (data.rateLimit) {
517
+ const { limit, remaining, resetAt, windowSeconds } = data.rateLimit;
518
+ if (limit !== undefined) {
519
+ console.error(` Limit: ${limit} requests`);
520
+ }
521
+ if (remaining !== undefined) {
522
+ console.error(` Remaining: ${remaining} requests`);
523
+ }
524
+ if (resetAt) {
525
+ const resetDate = new Date(resetAt);
526
+ const now = new Date();
527
+ const secondsUntilReset = Math.ceil((resetDate - now) / 1000);
528
+ if (secondsUntilReset > 0) {
529
+ console.error(` Resets in: ${secondsUntilReset} seconds`);
530
+ }
531
+ }
532
+ }
533
+ console.error('');
534
+ // Don't exit - let user decide, but clear the queue
535
+ logQueue.length = 0;
536
+ });
537
+
538
+ // Handle general errors from server
539
+ socket.on('error', (data) => {
540
+ console.error('\n ✗ Server Error');
541
+ if (typeof data === 'string') {
542
+ console.error(` ${data}`);
543
+ } else if (data && data.message) {
544
+ console.error(` ${data.message}`);
545
+ if (data.error) {
546
+ console.error(` Error: ${data.error}`);
547
+ }
548
+ } else {
549
+ console.error(' An unexpected error occurred');
550
+ }
551
+ console.error('');
552
+ });
553
+
505
554
  const rl = readline.createInterface({
506
555
  input: process.stdin,
507
556
  output: process.stdout,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibex-sh",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Zero-config observability CLI - pipe logs and visualize instantly",
5
5
  "type": "module",
6
6
  "bin": {