polydev-ai 1.8.90 → 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,12 @@ 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 (gives time for 5s auto-close countdown + buffer)
473
+ // Wait 7 seconds before closing server
474
474
  setTimeout(() => {
475
475
  server.close();
476
- resolve({
477
- jsonrpc: '2.0',
478
- id,
479
- result: {
480
- content: [{
481
- type: 'text',
482
- text: `╭─────────────────────────────────────────╮
483
- │ LOGIN SUCCESSFUL! ✓ │
484
- ╰─────────────────────────────────────────╯
485
-
486
- 🔐 Token saved to:
487
- • ~/.polydev.env
488
- • ~/.zshrc
489
-
490
- ⚠️ IMPORTANT: Restart your IDE to activate.
491
-
492
- 🤖 After restart, you can:
493
- • Use /polydev:ask to query multiple AI models
494
- • Use /polydev:auth to check status & credits
495
- • Use get_perspectives tool directly
496
-
497
- 📊 Dashboard: https://polydev.ai/dashboard`
498
- }]
499
- }
500
- });
476
+ resolve(true);
501
477
  }, 7000);
502
478
  } else {
503
479
  res.writeHead(400, { 'Content-Type': 'text/plain' });
@@ -514,47 +490,57 @@ To re-login: npx polydev-ai`
514
490
  const callbackUrl = `http://localhost:${port}/callback`;
515
491
  const authUrl = `https://polydev.ai/auth?callback=${encodeURIComponent(callbackUrl)}&redirect=ide-plugin&auto=true`;
516
492
 
517
- console.error(`[Polydev] Opening browser for authentication: ${authUrl}`);
493
+ console.error(`[Polydev] Opening browser for authentication...`);
494
+ console.error(`[Polydev] Auth URL: ${authUrl}`);
518
495
 
519
- // Best-in-class browser opening using 'open' package (cross-platform)
520
- // Falls back to platform-specific commands if package fails
521
496
  this.openBrowser(authUrl).catch(() => {
522
- console.error('[Polydev] All browser open methods failed');
497
+ console.error('[Polydev] Could not open browser automatically');
523
498
  console.error('[Polydev] Please open this URL manually:', authUrl);
524
499
  });
525
-
526
- // Timeout after 5 minutes
527
- setTimeout(() => {
528
- server.close();
529
- resolve({
530
- jsonrpc: '2.0',
531
- id,
532
- result: {
533
- content: [{
534
- type: 'text',
535
- text: `Login timed out.\n\nPlease try again or run in terminal: npx polydev-ai`
536
- }],
537
- isError: true
538
- }
539
- });
540
- }, 5 * 60 * 1000);
541
500
  });
542
501
 
502
+ // Timeout after 5 minutes
503
+ setTimeout(() => {
504
+ server.close();
505
+ resolve(false);
506
+ }, 5 * 60 * 1000);
507
+
543
508
  server.on('error', (err) => {
544
509
  console.error('[Polydev] Login server error:', err.message);
545
- resolve({
546
- jsonrpc: '2.0',
547
- id,
548
- result: {
549
- content: [{
550
- type: 'text',
551
- text: `Login failed: ${err.message}\n\nPlease run in terminal: npx polydev-ai`
552
- }],
553
- isError: true
554
- }
555
- });
510
+ resolve(false);
556
511
  });
557
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
+ };
558
544
  }
559
545
 
560
546
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polydev-ai",
3
- "version": "1.8.90",
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",