polydev-ai 1.8.90 → 1.8.92
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.
- package/mcp/stdio-wrapper.js +107 -117
- package/package.json +2 -2
package/mcp/stdio-wrapper.js
CHANGED
|
@@ -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
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
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,128 +431,120 @@ class StdioMCPWrapper {
|
|
|
433
431
|
• get_perspectives - Direct tool call
|
|
434
432
|
|
|
435
433
|
To re-login: npx polydev-ai`
|
|
436
|
-
|
|
437
|
-
|
|
434
|
+
}]
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// Close any existing login server
|
|
440
|
+
if (this._loginServer) {
|
|
441
|
+
try { this._loginServer.close(); } catch (e) {}
|
|
442
|
+
this._loginServer = null;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// Create and STORE the server at class level so it stays alive
|
|
446
|
+
this._loginServer = http.createServer((req, res) => {
|
|
447
|
+
const url = new URL(req.url, `http://localhost`);
|
|
448
|
+
|
|
449
|
+
if (req.method === 'OPTIONS') {
|
|
450
|
+
res.writeHead(204, {
|
|
451
|
+
'Access-Control-Allow-Origin': '*',
|
|
452
|
+
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
|
|
453
|
+
'Access-Control-Allow-Headers': 'Content-Type'
|
|
438
454
|
});
|
|
455
|
+
res.end();
|
|
439
456
|
return;
|
|
440
457
|
}
|
|
441
|
-
|
|
442
|
-
const server = http.createServer((req, res) => {
|
|
443
|
-
const url = new URL(req.url, `http://localhost`);
|
|
444
|
-
|
|
445
|
-
if (req.method === 'OPTIONS') {
|
|
446
|
-
res.writeHead(204, {
|
|
447
|
-
'Access-Control-Allow-Origin': '*',
|
|
448
|
-
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
|
|
449
|
-
'Access-Control-Allow-Headers': 'Content-Type'
|
|
450
|
-
});
|
|
451
|
-
res.end();
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
458
|
|
|
455
|
-
|
|
456
|
-
|
|
459
|
+
if (url.pathname === '/callback') {
|
|
460
|
+
const token = url.searchParams.get('token');
|
|
457
461
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
462
|
+
if (token && token.startsWith('pd_')) {
|
|
463
|
+
// Save token
|
|
464
|
+
this.saveTokenToFiles(token);
|
|
465
|
+
this.userToken = token;
|
|
466
|
+
this.isAuthenticated = true;
|
|
467
|
+
this._freshLogin = true;
|
|
464
468
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
469
|
+
res.writeHead(200, {
|
|
470
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
471
|
+
'Access-Control-Allow-Origin': '*'
|
|
472
|
+
});
|
|
473
|
+
res.end(this.getLoginSuccessHTML());
|
|
470
474
|
|
|
471
|
-
|
|
475
|
+
console.error('[Polydev] Login successful, token saved');
|
|
476
|
+
console.error('[Polydev] ✓ You can now use Polydev tools!');
|
|
472
477
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
478
|
+
// Wait 7 seconds before closing server (let browser render success page)
|
|
479
|
+
setTimeout(() => {
|
|
480
|
+
if (this._loginServer) {
|
|
481
|
+
this._loginServer.close();
|
|
482
|
+
this._loginServer = null;
|
|
483
|
+
}
|
|
484
|
+
}, 7000);
|
|
485
|
+
} else {
|
|
486
|
+
res.writeHead(400, { 'Content-Type': 'text/plain' });
|
|
487
|
+
res.end('Invalid or missing token');
|
|
488
|
+
}
|
|
489
|
+
} else {
|
|
490
|
+
res.writeHead(404);
|
|
491
|
+
res.end('Not found');
|
|
492
|
+
}
|
|
493
|
+
});
|
|
485
494
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
495
|
+
// Start listening
|
|
496
|
+
this._loginServer.listen(0, 'localhost', () => {
|
|
497
|
+
const port = this._loginServer.address().port;
|
|
498
|
+
const callbackUrl = `http://localhost:${port}/callback`;
|
|
499
|
+
const authUrl = `https://polydev.ai/auth?callback=${encodeURIComponent(callbackUrl)}&redirect=ide-plugin&auto=true`;
|
|
489
500
|
|
|
490
|
-
|
|
501
|
+
console.error(`[Polydev] Opening browser for authentication...`);
|
|
502
|
+
console.error(`[Polydev] Callback server listening on port ${port}`);
|
|
503
|
+
console.error(`[Polydev] Auth URL: ${authUrl}`);
|
|
504
|
+
|
|
505
|
+
this.openBrowser(authUrl).catch(() => {
|
|
506
|
+
console.error('[Polydev] Could not open browser automatically');
|
|
507
|
+
console.error('[Polydev] Please open this URL manually:', authUrl);
|
|
508
|
+
});
|
|
509
|
+
});
|
|
491
510
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
511
|
+
// Timeout after 5 minutes
|
|
512
|
+
this._loginServerTimeout = setTimeout(() => {
|
|
513
|
+
if (this._loginServer) {
|
|
514
|
+
console.error('[Polydev] Login timeout - closing server');
|
|
515
|
+
this._loginServer.close();
|
|
516
|
+
this._loginServer = null;
|
|
517
|
+
}
|
|
518
|
+
}, 5 * 60 * 1000);
|
|
496
519
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
}, 7000);
|
|
502
|
-
} else {
|
|
503
|
-
res.writeHead(400, { 'Content-Type': 'text/plain' });
|
|
504
|
-
res.end('Invalid or missing token');
|
|
505
|
-
}
|
|
506
|
-
} else {
|
|
507
|
-
res.writeHead(404);
|
|
508
|
-
res.end('Not found');
|
|
509
|
-
}
|
|
510
|
-
});
|
|
520
|
+
this._loginServer.on('error', (err) => {
|
|
521
|
+
console.error('[Polydev] Login server error:', err.message);
|
|
522
|
+
this._loginServer = null;
|
|
523
|
+
});
|
|
511
524
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
525
|
+
// Return immediately - server stays alive at this._loginServer
|
|
526
|
+
return {
|
|
527
|
+
jsonrpc: '2.0',
|
|
528
|
+
id,
|
|
529
|
+
result: {
|
|
530
|
+
content: [{
|
|
531
|
+
type: 'text',
|
|
532
|
+
text: `╭─────────────────────────────────────────╮
|
|
533
|
+
│ BROWSER OPENED FOR LOGIN 🌐 │
|
|
534
|
+
╰─────────────────────────────────────────╯
|
|
516
535
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
// Best-in-class browser opening using 'open' package (cross-platform)
|
|
520
|
-
// Falls back to platform-specific commands if package fails
|
|
521
|
-
this.openBrowser(authUrl).catch(() => {
|
|
522
|
-
console.error('[Polydev] All browser open methods failed');
|
|
523
|
-
console.error('[Polydev] Please open this URL manually:', authUrl);
|
|
524
|
-
});
|
|
536
|
+
📱 Complete authentication in your browser.
|
|
525
537
|
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
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
|
-
});
|
|
538
|
+
After login:
|
|
539
|
+
• Token will be saved automatically
|
|
540
|
+
• You'll see a success page with auto-close
|
|
541
|
+
• Return here and the tools will be ready!
|
|
542
542
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
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
|
-
});
|
|
556
|
-
});
|
|
557
|
-
});
|
|
543
|
+
⏳ Waiting for authentication...
|
|
544
|
+
(Server listening for up to 5 minutes)`
|
|
545
|
+
}]
|
|
546
|
+
}
|
|
547
|
+
};
|
|
558
548
|
}
|
|
559
549
|
|
|
560
550
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polydev-ai",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.92",
|
|
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.
|
|
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",
|