polydev-ai 1.8.80 → 1.8.81
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 +68 -45
- package/package.json +2 -1
package/mcp/stdio-wrapper.js
CHANGED
|
@@ -479,29 +479,11 @@ class StdioMCPWrapper {
|
|
|
479
479
|
|
|
480
480
|
console.error(`[Polydev] Opening browser for authentication: ${authUrl}`);
|
|
481
481
|
|
|
482
|
-
//
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
if (platform === 'darwin') {
|
|
488
|
-
// Use osascript for more reliable browser opening on macOS
|
|
489
|
-
openCommand = `osascript -e 'open location "${authUrl}"'`;
|
|
490
|
-
} else if (platform === 'win32') {
|
|
491
|
-
openCommand = `start "" "${authUrl}"`;
|
|
492
|
-
} else {
|
|
493
|
-
openCommand = `xdg-open "${authUrl}"`;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
exec(openCommand, (error) => {
|
|
497
|
-
if (error) {
|
|
498
|
-
console.error('[Polydev] Browser open failed, trying fallback...');
|
|
499
|
-
// Fallback to spawn
|
|
500
|
-
const { spawn } = require('child_process');
|
|
501
|
-
if (platform === 'darwin') {
|
|
502
|
-
spawn('open', [authUrl], { detached: true, stdio: 'ignore' }).unref();
|
|
503
|
-
}
|
|
504
|
-
}
|
|
482
|
+
// Best-in-class browser opening using 'open' package (cross-platform)
|
|
483
|
+
// Falls back to platform-specific commands if package fails
|
|
484
|
+
this.openBrowser(authUrl).catch(() => {
|
|
485
|
+
console.error('[Polydev] All browser open methods failed');
|
|
486
|
+
console.error('[Polydev] Please open this URL manually:', authUrl);
|
|
505
487
|
});
|
|
506
488
|
|
|
507
489
|
// Timeout after 5 minutes
|
|
@@ -609,6 +591,64 @@ class StdioMCPWrapper {
|
|
|
609
591
|
}
|
|
610
592
|
}
|
|
611
593
|
|
|
594
|
+
/**
|
|
595
|
+
* Open URL in browser - best-in-class cross-platform implementation
|
|
596
|
+
* Uses 'open' npm package with fallbacks for reliability in MCP/stdio context
|
|
597
|
+
*/
|
|
598
|
+
async openBrowser(url) {
|
|
599
|
+
// Try the 'open' package first (ESM, requires dynamic import)
|
|
600
|
+
try {
|
|
601
|
+
const open = await import('open');
|
|
602
|
+
await open.default(url);
|
|
603
|
+
console.error('[Polydev] Browser opened successfully');
|
|
604
|
+
return;
|
|
605
|
+
} catch (openError) {
|
|
606
|
+
console.error('[Polydev] open package failed:', openError.message);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// Fallback 1: Platform-specific commands with exec
|
|
610
|
+
const { exec } = require('child_process');
|
|
611
|
+
const platform = process.platform;
|
|
612
|
+
|
|
613
|
+
return new Promise((resolve, reject) => {
|
|
614
|
+
let command;
|
|
615
|
+
if (platform === 'darwin') {
|
|
616
|
+
// macOS: try osascript first (more reliable in headless contexts)
|
|
617
|
+
command = `osascript -e 'open location "${url}"'`;
|
|
618
|
+
} else if (platform === 'win32') {
|
|
619
|
+
command = `start "" "${url}"`;
|
|
620
|
+
} else {
|
|
621
|
+
command = `xdg-open "${url}"`;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
exec(command, (error) => {
|
|
625
|
+
if (error) {
|
|
626
|
+
console.error('[Polydev] exec command failed:', error.message);
|
|
627
|
+
|
|
628
|
+
// Fallback 2: spawn with detached
|
|
629
|
+
const { spawn } = require('child_process');
|
|
630
|
+
try {
|
|
631
|
+
if (platform === 'darwin') {
|
|
632
|
+
spawn('open', [url], { detached: true, stdio: 'ignore' }).unref();
|
|
633
|
+
} else if (platform === 'win32') {
|
|
634
|
+
spawn('cmd', ['/c', 'start', '', url], { detached: true, stdio: 'ignore', shell: true }).unref();
|
|
635
|
+
} else {
|
|
636
|
+
spawn('xdg-open', [url], { detached: true, stdio: 'ignore' }).unref();
|
|
637
|
+
}
|
|
638
|
+
console.error('[Polydev] Browser opened via spawn fallback');
|
|
639
|
+
resolve();
|
|
640
|
+
} catch (spawnError) {
|
|
641
|
+
console.error('[Polydev] spawn fallback failed:', spawnError.message);
|
|
642
|
+
reject(new Error('All browser open methods failed'));
|
|
643
|
+
}
|
|
644
|
+
} else {
|
|
645
|
+
console.error('[Polydev] Browser opened via exec');
|
|
646
|
+
resolve();
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
|
|
612
652
|
/**
|
|
613
653
|
* Save token to shell config files
|
|
614
654
|
*/
|
|
@@ -2112,28 +2152,11 @@ class StdioMCPWrapper {
|
|
|
2112
2152
|
console.error(authUrl);
|
|
2113
2153
|
console.error('');
|
|
2114
2154
|
|
|
2115
|
-
//
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
// Use osascript for more reliable browser opening on macOS
|
|
2121
|
-
openCommand = `osascript -e 'open location "${authUrl}"'`;
|
|
2122
|
-
} else if (platform === 'win32') {
|
|
2123
|
-
openCommand = `start "" "${authUrl}"`;
|
|
2124
|
-
} else {
|
|
2125
|
-
openCommand = `xdg-open "${authUrl}"`;
|
|
2126
|
-
}
|
|
2127
|
-
|
|
2128
|
-
exec(openCommand, (error) => {
|
|
2129
|
-
if (error) {
|
|
2130
|
-
console.error('[Polydev] Browser open failed, trying fallback...');
|
|
2131
|
-
// Fallback to spawn
|
|
2132
|
-
const { spawn } = require('child_process');
|
|
2133
|
-
if (platform === 'darwin') {
|
|
2134
|
-
spawn('open', [authUrl], { detached: true, stdio: 'ignore' }).unref();
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2155
|
+
// Best-in-class browser opening using 'open' package (cross-platform)
|
|
2156
|
+
// Falls back to platform-specific commands if package fails
|
|
2157
|
+
this.openBrowser(authUrl).catch(() => {
|
|
2158
|
+
console.error('[Polydev] All browser open methods failed');
|
|
2159
|
+
console.error('[Polydev] Please open this URL manually:', authUrl);
|
|
2137
2160
|
});
|
|
2138
2161
|
|
|
2139
2162
|
// Don't block forever - resolve after timeout
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polydev-ai",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.81",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=20.x <=22.x"
|
|
6
6
|
},
|
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
"lucide-react": "^0.542.0",
|
|
74
74
|
"marked": "^16.2.1",
|
|
75
75
|
"next": "^15.5.7",
|
|
76
|
+
"open": "^11.0.0",
|
|
76
77
|
"polydev-ai": "^1.8.42",
|
|
77
78
|
"posthog-js": "^1.157.2",
|
|
78
79
|
"prismjs": "^1.30.0",
|