polydev-ai 1.8.76 → 1.8.78
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 +63 -23
- package/package.json +1 -1
package/mcp/stdio-wrapper.js
CHANGED
|
@@ -439,6 +439,7 @@ class StdioMCPWrapper {
|
|
|
439
439
|
this.saveTokenToFiles(token);
|
|
440
440
|
this.userToken = token;
|
|
441
441
|
this.isAuthenticated = true;
|
|
442
|
+
this._freshLogin = true; // Flag for opening models page after CLI detection
|
|
442
443
|
|
|
443
444
|
res.writeHead(200, {
|
|
444
445
|
'Content-Type': 'text/html; charset=utf-8',
|
|
@@ -1983,25 +1984,32 @@ class StdioMCPWrapper {
|
|
|
1983
1984
|
// Run the onboarding/status check
|
|
1984
1985
|
await this.runStartupFlow();
|
|
1985
1986
|
|
|
1986
|
-
//
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
1987
|
+
// Only run CLI detection here if we already have a token
|
|
1988
|
+
// (If no token, CLI detection runs after login completes in runStartupFlow)
|
|
1989
|
+
if (this.userToken) {
|
|
1990
|
+
console.error('[Polydev] Detecting local CLI tools...');
|
|
1991
|
+
|
|
1992
|
+
this.localForceCliDetection({})
|
|
1993
|
+
.then(async () => {
|
|
1994
|
+
this._cliDetectionComplete = true;
|
|
1995
|
+
// Display CLI status after detection
|
|
1996
|
+
await this.displayCliStatus();
|
|
1997
|
+
})
|
|
1998
|
+
.catch((error) => {
|
|
1999
|
+
console.error('[Polydev] CLI detection failed:', error.message);
|
|
2000
|
+
this._cliDetectionComplete = true;
|
|
2001
|
+
})
|
|
2002
|
+
.finally(() => {
|
|
2003
|
+
if (this._cliDetectionResolver) {
|
|
2004
|
+
this._cliDetectionResolver();
|
|
2005
|
+
}
|
|
2006
|
+
this.startSmartRefreshScheduler();
|
|
2007
|
+
});
|
|
2008
|
+
} else {
|
|
2009
|
+
// No token - CLI detection will run after login completes
|
|
2010
|
+
// Just start the scheduler
|
|
2011
|
+
this.startSmartRefreshScheduler();
|
|
2012
|
+
}
|
|
2005
2013
|
}
|
|
2006
2014
|
|
|
2007
2015
|
/**
|
|
@@ -2009,16 +2017,28 @@ class StdioMCPWrapper {
|
|
|
2009
2017
|
*/
|
|
2010
2018
|
async runStartupFlow() {
|
|
2011
2019
|
if (!this.userToken) {
|
|
2012
|
-
// No token - auto-open browser for login
|
|
2020
|
+
// No token - auto-open browser for login (NON-BLOCKING)
|
|
2013
2021
|
console.error('─'.repeat(50));
|
|
2014
2022
|
console.error('Polydev - First Time Setup');
|
|
2015
2023
|
console.error('─'.repeat(50));
|
|
2016
2024
|
console.error('Opening browser for authentication...\n');
|
|
2017
2025
|
|
|
2018
|
-
|
|
2026
|
+
// Run auto-login in background (don't block MCP server startup)
|
|
2027
|
+
this.autoLoginOnStartup().then(() => {
|
|
2028
|
+
console.error('[Polydev] Login completed, running CLI detection...');
|
|
2029
|
+
// After login, run CLI detection
|
|
2030
|
+
return this.localForceCliDetection({});
|
|
2031
|
+
}).then(() => {
|
|
2032
|
+
this._cliDetectionComplete = true;
|
|
2033
|
+
return this.displayCliStatus();
|
|
2034
|
+
}).catch((error) => {
|
|
2035
|
+
console.error('[Polydev] Auto-login flow error:', error.message);
|
|
2036
|
+
});
|
|
2019
2037
|
} else {
|
|
2020
|
-
// Has token - verify it
|
|
2021
|
-
|
|
2038
|
+
// Has token - verify it (also non-blocking)
|
|
2039
|
+
this.verifyAndDisplayAuth().catch((error) => {
|
|
2040
|
+
console.error('[Polydev] Auth verification error:', error.message);
|
|
2041
|
+
});
|
|
2022
2042
|
}
|
|
2023
2043
|
}
|
|
2024
2044
|
|
|
@@ -2050,6 +2070,7 @@ class StdioMCPWrapper {
|
|
|
2050
2070
|
this.saveTokenToFiles(token);
|
|
2051
2071
|
this.userToken = token;
|
|
2052
2072
|
this.isAuthenticated = true;
|
|
2073
|
+
this._freshLogin = true; // Flag for opening models page after CLI detection
|
|
2053
2074
|
|
|
2054
2075
|
res.writeHead(200, {
|
|
2055
2076
|
'Content-Type': 'text/html; charset=utf-8',
|
|
@@ -2203,6 +2224,25 @@ class StdioMCPWrapper {
|
|
|
2203
2224
|
}
|
|
2204
2225
|
|
|
2205
2226
|
console.error('─'.repeat(50) + '\n');
|
|
2227
|
+
|
|
2228
|
+
// Open models page on fresh login for API key setup
|
|
2229
|
+
if (this._freshLogin) {
|
|
2230
|
+
this._freshLogin = false;
|
|
2231
|
+
console.error('Opening Polydev Models page for API key configuration...');
|
|
2232
|
+
console.error('Add your API keys to unlock more models!\n');
|
|
2233
|
+
|
|
2234
|
+
const { execFile } = require('child_process');
|
|
2235
|
+
const modelsUrl = 'https://polydev.ai/dashboard/models';
|
|
2236
|
+
const platform = process.platform;
|
|
2237
|
+
|
|
2238
|
+
if (platform === 'darwin') {
|
|
2239
|
+
execFile('open', [modelsUrl]);
|
|
2240
|
+
} else if (platform === 'win32') {
|
|
2241
|
+
execFile('cmd', ['/c', 'start', '', modelsUrl]);
|
|
2242
|
+
} else {
|
|
2243
|
+
execFile('xdg-open', [modelsUrl]);
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2206
2246
|
} catch (error) {
|
|
2207
2247
|
// Ignore errors in status display
|
|
2208
2248
|
}
|