polydev-ai 1.8.77 → 1.8.79
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 +55 -49
- 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,26 +479,17 @@ class StdioMCPWrapper {
|
|
|
479
479
|
|
|
480
480
|
console.error(`[Polydev] Opening browser for authentication: ${authUrl}`);
|
|
481
481
|
|
|
482
|
-
// Open browser
|
|
482
|
+
// Open browser - use spawn with detached for better reliability in stdio context
|
|
483
483
|
const platform = process.platform;
|
|
484
|
-
|
|
484
|
+
|
|
485
485
|
if (platform === 'darwin') {
|
|
486
|
-
|
|
487
|
-
args = [authUrl];
|
|
486
|
+
spawn('open', [authUrl], { detached: true, stdio: 'ignore' }).unref();
|
|
488
487
|
} else if (platform === 'win32') {
|
|
489
|
-
cmd
|
|
490
|
-
args = ['/c', 'start', '', authUrl];
|
|
488
|
+
spawn('cmd', ['/c', 'start', '', authUrl], { detached: true, stdio: 'ignore', shell: true }).unref();
|
|
491
489
|
} else {
|
|
492
|
-
|
|
493
|
-
args = [authUrl];
|
|
490
|
+
spawn('xdg-open', [authUrl], { detached: true, stdio: 'ignore' }).unref();
|
|
494
491
|
}
|
|
495
492
|
|
|
496
|
-
execFile(cmd, args, (err) => {
|
|
497
|
-
if (err) {
|
|
498
|
-
console.error('[Polydev] Could not open browser:', err.message);
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
|
|
502
493
|
// Timeout after 5 minutes
|
|
503
494
|
setTimeout(() => {
|
|
504
495
|
server.close();
|
|
@@ -1984,25 +1975,32 @@ class StdioMCPWrapper {
|
|
|
1984
1975
|
// Run the onboarding/status check
|
|
1985
1976
|
await this.runStartupFlow();
|
|
1986
1977
|
|
|
1987
|
-
//
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
1978
|
+
// Only run CLI detection here if we already have a token
|
|
1979
|
+
// (If no token, CLI detection runs after login completes in runStartupFlow)
|
|
1980
|
+
if (this.userToken) {
|
|
1981
|
+
console.error('[Polydev] Detecting local CLI tools...');
|
|
1982
|
+
|
|
1983
|
+
this.localForceCliDetection({})
|
|
1984
|
+
.then(async () => {
|
|
1985
|
+
this._cliDetectionComplete = true;
|
|
1986
|
+
// Display CLI status after detection
|
|
1987
|
+
await this.displayCliStatus();
|
|
1988
|
+
})
|
|
1989
|
+
.catch((error) => {
|
|
1990
|
+
console.error('[Polydev] CLI detection failed:', error.message);
|
|
1991
|
+
this._cliDetectionComplete = true;
|
|
1992
|
+
})
|
|
1993
|
+
.finally(() => {
|
|
1994
|
+
if (this._cliDetectionResolver) {
|
|
1995
|
+
this._cliDetectionResolver();
|
|
1996
|
+
}
|
|
1997
|
+
this.startSmartRefreshScheduler();
|
|
1998
|
+
});
|
|
1999
|
+
} else {
|
|
2000
|
+
// No token - CLI detection will run after login completes
|
|
2001
|
+
// Just start the scheduler
|
|
2002
|
+
this.startSmartRefreshScheduler();
|
|
2003
|
+
}
|
|
2006
2004
|
}
|
|
2007
2005
|
|
|
2008
2006
|
/**
|
|
@@ -2010,16 +2008,28 @@ class StdioMCPWrapper {
|
|
|
2010
2008
|
*/
|
|
2011
2009
|
async runStartupFlow() {
|
|
2012
2010
|
if (!this.userToken) {
|
|
2013
|
-
// No token - auto-open browser for login
|
|
2011
|
+
// No token - auto-open browser for login (NON-BLOCKING)
|
|
2014
2012
|
console.error('─'.repeat(50));
|
|
2015
2013
|
console.error('Polydev - First Time Setup');
|
|
2016
2014
|
console.error('─'.repeat(50));
|
|
2017
2015
|
console.error('Opening browser for authentication...\n');
|
|
2018
2016
|
|
|
2019
|
-
|
|
2017
|
+
// Run auto-login in background (don't block MCP server startup)
|
|
2018
|
+
this.autoLoginOnStartup().then(() => {
|
|
2019
|
+
console.error('[Polydev] Login completed, running CLI detection...');
|
|
2020
|
+
// After login, run CLI detection
|
|
2021
|
+
return this.localForceCliDetection({});
|
|
2022
|
+
}).then(() => {
|
|
2023
|
+
this._cliDetectionComplete = true;
|
|
2024
|
+
return this.displayCliStatus();
|
|
2025
|
+
}).catch((error) => {
|
|
2026
|
+
console.error('[Polydev] Auto-login flow error:', error.message);
|
|
2027
|
+
});
|
|
2020
2028
|
} else {
|
|
2021
|
-
// Has token - verify it
|
|
2022
|
-
|
|
2029
|
+
// Has token - verify it (also non-blocking)
|
|
2030
|
+
this.verifyAndDisplayAuth().catch((error) => {
|
|
2031
|
+
console.error('[Polydev] Auth verification error:', error.message);
|
|
2032
|
+
});
|
|
2023
2033
|
}
|
|
2024
2034
|
}
|
|
2025
2035
|
|
|
@@ -2028,7 +2038,7 @@ class StdioMCPWrapper {
|
|
|
2028
2038
|
*/
|
|
2029
2039
|
async autoLoginOnStartup() {
|
|
2030
2040
|
const http = require('http');
|
|
2031
|
-
const {
|
|
2041
|
+
const { spawn } = require('child_process');
|
|
2032
2042
|
|
|
2033
2043
|
return new Promise((resolve) => {
|
|
2034
2044
|
const server = http.createServer((req, res) => {
|
|
@@ -2088,7 +2098,7 @@ class StdioMCPWrapper {
|
|
|
2088
2098
|
console.error(authUrl);
|
|
2089
2099
|
console.error('');
|
|
2090
2100
|
|
|
2091
|
-
// Open browser
|
|
2101
|
+
// Open browser - use spawn with detached for better reliability in stdio context
|
|
2092
2102
|
const platform = process.platform;
|
|
2093
2103
|
let cmd, args;
|
|
2094
2104
|
if (platform === 'darwin') {
|
|
@@ -2102,11 +2112,7 @@ class StdioMCPWrapper {
|
|
|
2102
2112
|
args = [authUrl];
|
|
2103
2113
|
}
|
|
2104
2114
|
|
|
2105
|
-
|
|
2106
|
-
if (err) {
|
|
2107
|
-
console.error('[!] Could not open browser automatically.');
|
|
2108
|
-
}
|
|
2109
|
-
});
|
|
2115
|
+
spawn(cmd, args, { detached: true, stdio: 'ignore' }).unref();
|
|
2110
2116
|
|
|
2111
2117
|
// Don't block forever - resolve after timeout
|
|
2112
2118
|
setTimeout(() => {
|
|
@@ -2212,16 +2218,16 @@ class StdioMCPWrapper {
|
|
|
2212
2218
|
console.error('Opening Polydev Models page for API key configuration...');
|
|
2213
2219
|
console.error('Add your API keys to unlock more models!\n');
|
|
2214
2220
|
|
|
2215
|
-
const {
|
|
2221
|
+
const { spawn } = require('child_process');
|
|
2216
2222
|
const modelsUrl = 'https://polydev.ai/dashboard/models';
|
|
2217
2223
|
const platform = process.platform;
|
|
2218
2224
|
|
|
2219
2225
|
if (platform === 'darwin') {
|
|
2220
|
-
|
|
2226
|
+
spawn('open', [modelsUrl], { detached: true, stdio: 'ignore' }).unref();
|
|
2221
2227
|
} else if (platform === 'win32') {
|
|
2222
|
-
|
|
2228
|
+
spawn('cmd', ['/c', 'start', '', modelsUrl], { detached: true, stdio: 'ignore', shell: true }).unref();
|
|
2223
2229
|
} else {
|
|
2224
|
-
|
|
2230
|
+
spawn('xdg-open', [modelsUrl], { detached: true, stdio: 'ignore' }).unref();
|
|
2225
2231
|
}
|
|
2226
2232
|
}
|
|
2227
2233
|
} catch (error) {
|