polydev-ai 1.8.89 → 1.8.91

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.
@@ -410,18 +410,16 @@ class StdioMCPWrapper {
410
410
  */
411
411
  async handleLoginTool(params, id) {
412
412
  const http = require('http');
413
- const { spawn } = require('child_process');
414
413
 
415
- return new Promise((resolve) => {
416
- // Check if already authenticated
417
- if (this.isAuthenticated && this.userToken) {
418
- resolve({
419
- jsonrpc: '2.0',
420
- id,
421
- result: {
422
- content: [{
423
- type: 'text',
424
- text: `╭─────────────────────────────────────────╮
414
+ // Check if already authenticated
415
+ if (this.isAuthenticated && this.userToken) {
416
+ return {
417
+ jsonrpc: '2.0',
418
+ id,
419
+ result: {
420
+ content: [{
421
+ type: 'text',
422
+ text: `╭─────────────────────────────────────────╮
425
423
  │ ALREADY AUTHENTICATED ✓ │
426
424
  ╰─────────────────────────────────────────╯
427
425
 
@@ -433,12 +431,13 @@ class StdioMCPWrapper {
433
431
  • get_perspectives - Direct tool call
434
432
 
435
433
  To re-login: npx polydev-ai`
436
- }]
437
- }
438
- });
439
- return;
440
- }
441
-
434
+ }]
435
+ }
436
+ };
437
+ }
438
+
439
+ // Start login server in background (don't block the tool response)
440
+ const loginPromise = new Promise((resolve) => {
442
441
  const server = http.createServer((req, res) => {
443
442
  const url = new URL(req.url, `http://localhost`);
444
443
 
@@ -460,7 +459,7 @@ To re-login: npx polydev-ai`
460
459
  this.saveTokenToFiles(token);
461
460
  this.userToken = token;
462
461
  this.isAuthenticated = true;
463
- this._freshLogin = true; // Flag for opening models page after CLI detection
462
+ this._freshLogin = true;
464
463
 
465
464
  res.writeHead(200, {
466
465
  'Content-Type': 'text/html; charset=utf-8',
@@ -469,35 +468,13 @@ To re-login: npx polydev-ai`
469
468
  res.end(this.getLoginSuccessHTML());
470
469
 
471
470
  console.error('[Polydev] Login successful, token saved');
471
+ console.error('[Polydev] ✓ You can now use Polydev tools!');
472
472
 
473
+ // Wait 7 seconds before closing server
473
474
  setTimeout(() => {
474
475
  server.close();
475
- resolve({
476
- jsonrpc: '2.0',
477
- id,
478
- result: {
479
- content: [{
480
- type: 'text',
481
- text: `╭─────────────────────────────────────────╮
482
- │ LOGIN SUCCESSFUL! ✓ │
483
- ╰─────────────────────────────────────────╯
484
-
485
- 🔐 Token saved to:
486
- • ~/.polydev.env
487
- • ~/.zshrc
488
-
489
- ⚠️ IMPORTANT: Restart your IDE to activate.
490
-
491
- 🤖 After restart, you can:
492
- • Use /polydev:ask to query multiple AI models
493
- • Use /polydev:auth to check status & credits
494
- • Use get_perspectives tool directly
495
-
496
- 📊 Dashboard: https://polydev.ai/dashboard`
497
- }]
498
- }
499
- });
500
- }, 500);
476
+ resolve(true);
477
+ }, 7000);
501
478
  } else {
502
479
  res.writeHead(400, { 'Content-Type': 'text/plain' });
503
480
  res.end('Invalid or missing token');
@@ -513,47 +490,57 @@ To re-login: npx polydev-ai`
513
490
  const callbackUrl = `http://localhost:${port}/callback`;
514
491
  const authUrl = `https://polydev.ai/auth?callback=${encodeURIComponent(callbackUrl)}&redirect=ide-plugin&auto=true`;
515
492
 
516
- console.error(`[Polydev] Opening browser for authentication: ${authUrl}`);
493
+ console.error(`[Polydev] Opening browser for authentication...`);
494
+ console.error(`[Polydev] Auth URL: ${authUrl}`);
517
495
 
518
- // Best-in-class browser opening using 'open' package (cross-platform)
519
- // Falls back to platform-specific commands if package fails
520
496
  this.openBrowser(authUrl).catch(() => {
521
- console.error('[Polydev] All browser open methods failed');
497
+ console.error('[Polydev] Could not open browser automatically');
522
498
  console.error('[Polydev] Please open this URL manually:', authUrl);
523
499
  });
524
-
525
- // Timeout after 5 minutes
526
- setTimeout(() => {
527
- server.close();
528
- resolve({
529
- jsonrpc: '2.0',
530
- id,
531
- result: {
532
- content: [{
533
- type: 'text',
534
- text: `Login timed out.\n\nPlease try again or run in terminal: npx polydev-ai`
535
- }],
536
- isError: true
537
- }
538
- });
539
- }, 5 * 60 * 1000);
540
500
  });
541
501
 
502
+ // Timeout after 5 minutes
503
+ setTimeout(() => {
504
+ server.close();
505
+ resolve(false);
506
+ }, 5 * 60 * 1000);
507
+
542
508
  server.on('error', (err) => {
543
509
  console.error('[Polydev] Login server error:', err.message);
544
- resolve({
545
- jsonrpc: '2.0',
546
- id,
547
- result: {
548
- content: [{
549
- type: 'text',
550
- text: `Login failed: ${err.message}\n\nPlease run in terminal: npx polydev-ai`
551
- }],
552
- isError: true
553
- }
554
- });
510
+ resolve(false);
555
511
  });
556
512
  });
513
+
514
+ // Don't await - let it run in background
515
+ loginPromise.then((success) => {
516
+ if (success) {
517
+ console.error('[Polydev] Authentication completed successfully!');
518
+ }
519
+ });
520
+
521
+ // Return immediately - don't wait for auth to complete
522
+ return {
523
+ jsonrpc: '2.0',
524
+ id,
525
+ result: {
526
+ content: [{
527
+ type: 'text',
528
+ text: `╭─────────────────────────────────────────╮
529
+ │ BROWSER OPENED FOR LOGIN 🌐 │
530
+ ╰─────────────────────────────────────────╯
531
+
532
+ 📱 Complete authentication in your browser.
533
+
534
+ After login:
535
+ • Token will be saved automatically
536
+ • You'll see a success page with auto-close
537
+ • Return here and the tools will be ready!
538
+
539
+ ⏳ Waiting for authentication...
540
+ (Server listening for up to 5 minutes)`
541
+ }]
542
+ }
543
+ };
557
544
  }
558
545
 
559
546
  /**
@@ -893,6 +880,16 @@ Error: ${error.message}`
893
880
  }
894
881
  .secondary-btn:hover { background: #fafafa; }
895
882
  .note { color: #999; font-size: 11px; margin-top: 16px; }
883
+ .countdown {
884
+ color: #666; font-size: 12px; margin-top: 8px;
885
+ display: flex; align-items: center; justify-content: center; gap: 6px;
886
+ }
887
+ .countdown-spinner {
888
+ width: 12px; height: 12px; border: 2px solid #e5e5e5;
889
+ border-top-color: #666; border-radius: 50%;
890
+ animation: spin 1s linear infinite;
891
+ }
892
+ @keyframes spin { to { transform: rotate(360deg); } }
896
893
  </style>
897
894
  </head>
898
895
  <body>
@@ -937,8 +934,29 @@ Error: ${error.message}`
937
934
  </a>
938
935
  <button onclick="window.close()" class="secondary-btn">Close Window</button>
939
936
 
940
- <p class="note">Restart your IDE to use the new token</p>
937
+ <p class="note">✓ Token saved. Restart your IDE to activate.</p>
938
+ <div class="countdown" id="countdown">
939
+ <div class="countdown-spinner"></div>
940
+ <span>Closing in <strong id="seconds">5</strong>s...</span>
941
+ </div>
941
942
  </div>
943
+ <script>
944
+ // Auto-close countdown
945
+ let seconds = 5;
946
+ const interval = setInterval(() => {
947
+ seconds--;
948
+ document.getElementById('seconds').textContent = seconds;
949
+ if (seconds <= 0) {
950
+ clearInterval(interval);
951
+ document.getElementById('countdown').innerHTML = 'Closing...';
952
+ window.close();
953
+ // Fallback: if window.close() doesn't work, hide countdown
954
+ setTimeout(() => {
955
+ document.getElementById('countdown').innerHTML = 'You can close this tab now.';
956
+ }, 500);
957
+ }
958
+ }, 1000);
959
+ </script>
942
960
  </body>
943
961
  </html>`;
944
962
  }
@@ -1395,7 +1413,7 @@ Error: ${error.message}`
1395
1413
  if (this._cliDetectionReady && !this._cliDetectionComplete) {
1396
1414
  console.error('[Stdio Wrapper] Waiting for initial CLI detection to complete...');
1397
1415
  await this._cliDetectionReady;
1398
- console.error('[Stdio Wrapper] CLI detection ready, proceeding with request');
1416
+ console.error('[Polydev] CLI detection ready, proceeding with request');
1399
1417
  }
1400
1418
 
1401
1419
  const results = await this.cliManager.forceCliDetection();
@@ -2371,6 +2389,7 @@ Error: ${error.message}`
2371
2389
 
2372
2390
  console.error('[Polydev] Login successful, token saved');
2373
2391
 
2392
+ // Wait 7 seconds before closing server (gives time for 5s auto-close countdown + buffer)
2374
2393
  setTimeout(() => {
2375
2394
  server.close();
2376
2395
  resolve({
@@ -2398,7 +2417,7 @@ Error: ${error.message}`
2398
2417
  }]
2399
2418
  }
2400
2419
  });
2401
- }, 500);
2420
+ }, 7000);
2402
2421
  } else {
2403
2422
  res.writeHead(400, { 'Content-Type': 'text/plain' });
2404
2423
  res.end('Invalid or missing token');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polydev-ai",
3
- "version": "1.8.89",
3
+ "version": "1.8.91",
4
4
  "engines": {
5
5
  "node": ">=20.x <=22.x"
6
6
  },
@@ -74,7 +74,7 @@
74
74
  "marked": "^16.2.1",
75
75
  "next": "^15.5.7",
76
76
  "open": "^11.0.0",
77
- "polydev-ai": "^1.8.42",
77
+ "polydev-ai": "^1.8.90",
78
78
  "posthog-js": "^1.157.2",
79
79
  "prismjs": "^1.30.0",
80
80
  "react": "^18.3.1",