polydev-ai 1.8.78 → 1.8.80
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 +38 -29
- package/package.json +1 -1
package/mcp/stdio-wrapper.js
CHANGED
|
@@ -400,7 +400,7 @@ class StdioMCPWrapper {
|
|
|
400
400
|
*/
|
|
401
401
|
async handleLoginTool(params, id) {
|
|
402
402
|
const http = require('http');
|
|
403
|
-
const {
|
|
403
|
+
const { spawn } = require('child_process');
|
|
404
404
|
|
|
405
405
|
return new Promise((resolve) => {
|
|
406
406
|
// Check if already authenticated
|
|
@@ -479,23 +479,28 @@ class StdioMCPWrapper {
|
|
|
479
479
|
|
|
480
480
|
console.error(`[Polydev] Opening browser for authentication: ${authUrl}`);
|
|
481
481
|
|
|
482
|
-
// Open browser
|
|
482
|
+
// Open browser - use exec with shell for better reliability in MCP stdio context
|
|
483
|
+
const { exec } = require('child_process');
|
|
483
484
|
const platform = process.platform;
|
|
484
|
-
|
|
485
|
+
|
|
486
|
+
let openCommand;
|
|
485
487
|
if (platform === 'darwin') {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
+
// Use osascript for more reliable browser opening on macOS
|
|
489
|
+
openCommand = `osascript -e 'open location "${authUrl}"'`;
|
|
488
490
|
} else if (platform === 'win32') {
|
|
489
|
-
|
|
490
|
-
args = ['/c', 'start', '', authUrl];
|
|
491
|
+
openCommand = `start "" "${authUrl}"`;
|
|
491
492
|
} else {
|
|
492
|
-
|
|
493
|
-
args = [authUrl];
|
|
493
|
+
openCommand = `xdg-open "${authUrl}"`;
|
|
494
494
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
if (
|
|
498
|
-
console.error('[Polydev]
|
|
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
|
+
}
|
|
499
504
|
}
|
|
500
505
|
});
|
|
501
506
|
|
|
@@ -2047,7 +2052,7 @@ class StdioMCPWrapper {
|
|
|
2047
2052
|
*/
|
|
2048
2053
|
async autoLoginOnStartup() {
|
|
2049
2054
|
const http = require('http');
|
|
2050
|
-
const {
|
|
2055
|
+
const { spawn } = require('child_process');
|
|
2051
2056
|
|
|
2052
2057
|
return new Promise((resolve) => {
|
|
2053
2058
|
const server = http.createServer((req, res) => {
|
|
@@ -2107,23 +2112,27 @@ class StdioMCPWrapper {
|
|
|
2107
2112
|
console.error(authUrl);
|
|
2108
2113
|
console.error('');
|
|
2109
2114
|
|
|
2110
|
-
// Open browser
|
|
2115
|
+
// Open browser - use exec with shell for better reliability in stdio context
|
|
2116
|
+
const { exec } = require('child_process');
|
|
2111
2117
|
const platform = process.platform;
|
|
2112
|
-
let
|
|
2118
|
+
let openCommand;
|
|
2113
2119
|
if (platform === 'darwin') {
|
|
2114
|
-
|
|
2115
|
-
|
|
2120
|
+
// Use osascript for more reliable browser opening on macOS
|
|
2121
|
+
openCommand = `osascript -e 'open location "${authUrl}"'`;
|
|
2116
2122
|
} else if (platform === 'win32') {
|
|
2117
|
-
|
|
2118
|
-
args = ['/c', 'start', '', authUrl];
|
|
2123
|
+
openCommand = `start "" "${authUrl}"`;
|
|
2119
2124
|
} else {
|
|
2120
|
-
|
|
2121
|
-
args = [authUrl];
|
|
2125
|
+
openCommand = `xdg-open "${authUrl}"`;
|
|
2122
2126
|
}
|
|
2123
2127
|
|
|
2124
|
-
|
|
2125
|
-
if (
|
|
2126
|
-
console.error('[
|
|
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
|
+
}
|
|
2127
2136
|
}
|
|
2128
2137
|
});
|
|
2129
2138
|
|
|
@@ -2231,16 +2240,16 @@ class StdioMCPWrapper {
|
|
|
2231
2240
|
console.error('Opening Polydev Models page for API key configuration...');
|
|
2232
2241
|
console.error('Add your API keys to unlock more models!\n');
|
|
2233
2242
|
|
|
2234
|
-
const {
|
|
2243
|
+
const { spawn } = require('child_process');
|
|
2235
2244
|
const modelsUrl = 'https://polydev.ai/dashboard/models';
|
|
2236
2245
|
const platform = process.platform;
|
|
2237
2246
|
|
|
2238
2247
|
if (platform === 'darwin') {
|
|
2239
|
-
|
|
2248
|
+
spawn('open', [modelsUrl], { detached: true, stdio: 'ignore' }).unref();
|
|
2240
2249
|
} else if (platform === 'win32') {
|
|
2241
|
-
|
|
2250
|
+
spawn('cmd', ['/c', 'start', '', modelsUrl], { detached: true, stdio: 'ignore', shell: true }).unref();
|
|
2242
2251
|
} else {
|
|
2243
|
-
|
|
2252
|
+
spawn('xdg-open', [modelsUrl], { detached: true, stdio: 'ignore' }).unref();
|
|
2244
2253
|
}
|
|
2245
2254
|
}
|
|
2246
2255
|
} catch (error) {
|