polydev-ai 1.9.3 → 1.9.5
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/lib/cliManager.js +9 -0
- package/mcp/stdio-wrapper.js +35 -9
- package/package.json +6 -2
package/lib/cliManager.js
CHANGED
|
@@ -208,6 +208,15 @@ class CLIManager {
|
|
|
208
208
|
if (process.env.POLYDEV_CLI_DEBUG) {
|
|
209
209
|
console.log(`[CLI Debug] File-based auth check for ${provider.id}:`, authenticated);
|
|
210
210
|
}
|
|
211
|
+
} else if (provider.id === 'gemini_cli') {
|
|
212
|
+
// Gemini CLI has no 'auth-status' subcommand — 'gemini auth-status' hangs/times out.
|
|
213
|
+
// Use file-based auth directly (checks ~/.gemini/oauth_creds.json for tokens)
|
|
214
|
+
authenticated = await this.checkAuthenticationByFiles(provider.id);
|
|
215
|
+
|
|
216
|
+
if (process.env.POLYDEV_CLI_DEBUG) {
|
|
217
|
+
console.log(`[CLI Debug] File-based auth check for ${provider.id}:`, authenticated);
|
|
218
|
+
}
|
|
219
|
+
// Note: quota exhaustion is detected at prompt time, not during detection
|
|
211
220
|
} else {
|
|
212
221
|
// For other providers, try command-based auth check first
|
|
213
222
|
try {
|
package/mcp/stdio-wrapper.js
CHANGED
|
@@ -436,8 +436,8 @@ Token will be saved automatically after login.`
|
|
|
436
436
|
return await this.handleGetPerspectivesWithCLIs(params, id);
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
-
// Handle
|
|
440
|
-
if (
|
|
439
|
+
// Handle CLI tools locally (support both prefixed and unprefixed names)
|
|
440
|
+
if (this.isCliTool(toolName)) {
|
|
441
441
|
return await this.handleLocalCliTool(request);
|
|
442
442
|
} else {
|
|
443
443
|
// Forward non-CLI tools to remote server
|
|
@@ -1222,6 +1222,9 @@ Error: ${error.message}`
|
|
|
1222
1222
|
*/
|
|
1223
1223
|
isCliTool(toolName) {
|
|
1224
1224
|
const cliTools = [
|
|
1225
|
+
'force_cli_detection',
|
|
1226
|
+
'get_cli_status',
|
|
1227
|
+
'send_cli_prompt',
|
|
1225
1228
|
'polydev.force_cli_detection',
|
|
1226
1229
|
'polydev.get_cli_status',
|
|
1227
1230
|
'polydev.send_cli_prompt'
|
|
@@ -1281,14 +1284,17 @@ Error: ${error.message}`
|
|
|
1281
1284
|
let result;
|
|
1282
1285
|
|
|
1283
1286
|
switch (toolName) {
|
|
1287
|
+
case 'force_cli_detection':
|
|
1284
1288
|
case 'polydev.force_cli_detection':
|
|
1285
1289
|
result = await this.localForceCliDetection(args);
|
|
1286
1290
|
break;
|
|
1287
1291
|
|
|
1292
|
+
case 'get_cli_status':
|
|
1288
1293
|
case 'polydev.get_cli_status':
|
|
1289
1294
|
result = await this.localGetCliStatus(args);
|
|
1290
1295
|
break;
|
|
1291
1296
|
|
|
1297
|
+
case 'send_cli_prompt':
|
|
1292
1298
|
case 'polydev.send_cli_prompt':
|
|
1293
1299
|
result = await this.localSendCliPrompt(args);
|
|
1294
1300
|
break;
|
|
@@ -1558,7 +1564,23 @@ Error: ${error.message}`
|
|
|
1558
1564
|
if (model) {
|
|
1559
1565
|
console.error(`[Stdio Wrapper] Using model for ${providerEntry.cliId}: ${model}`);
|
|
1560
1566
|
}
|
|
1561
|
-
|
|
1567
|
+
let result = await this.cliManager.sendCliPrompt(providerEntry.cliId, prompt, mode, gracefulTimeout, model);
|
|
1568
|
+
|
|
1569
|
+
// If CLI failed with a model and the error suggests model issue, retry with CLI default
|
|
1570
|
+
if (!result.success && model) {
|
|
1571
|
+
const errorLower = (result.error || '').toLowerCase();
|
|
1572
|
+
const isModelError = errorLower.includes('not found') ||
|
|
1573
|
+
errorLower.includes('not supported') ||
|
|
1574
|
+
errorLower.includes('invalid model') ||
|
|
1575
|
+
errorLower.includes('entity was not found') ||
|
|
1576
|
+
errorLower.includes('does not exist') ||
|
|
1577
|
+
errorLower.includes('unknown model');
|
|
1578
|
+
if (isModelError) {
|
|
1579
|
+
console.error(`[Stdio Wrapper] Model '${model}' failed for ${providerEntry.cliId}, retrying with CLI default...`);
|
|
1580
|
+
result = await this.cliManager.sendCliPrompt(providerEntry.cliId, prompt, mode, gracefulTimeout, null);
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1562
1584
|
return {
|
|
1563
1585
|
provider_id: providerEntry.cliId,
|
|
1564
1586
|
original_provider: providerEntry.provider,
|
|
@@ -1670,13 +1692,17 @@ Error: ${error.message}`
|
|
|
1670
1692
|
const availableProviders = [];
|
|
1671
1693
|
const unavailableProviders = [];
|
|
1672
1694
|
|
|
1673
|
-
//
|
|
1674
|
-
//
|
|
1675
|
-
//
|
|
1676
|
-
|
|
1695
|
+
// ALWAYS check ALL CLIs (they're FREE) — don't limit to userProviderOrder
|
|
1696
|
+
// userProviderOrder only affects ordering, not which CLIs get checked
|
|
1697
|
+
// This fixes the bug where CLIs were missed because model-preferences API
|
|
1698
|
+
// only returned providerOrder for credits-tier models
|
|
1699
|
+
const allCliIds = ['claude_code', 'codex_cli', 'gemini_cli'];
|
|
1700
|
+
const userOrder = (this.userProviderOrder && this.userProviderOrder.length > 0)
|
|
1677
1701
|
? this.userProviderOrder
|
|
1678
|
-
: [
|
|
1679
|
-
|
|
1702
|
+
: [];
|
|
1703
|
+
// Merge: user's preferred order first, then any CLIs not in their order
|
|
1704
|
+
const priorityOrder = [...new Set([...userOrder, ...allCliIds])];
|
|
1705
|
+
console.error(`[Stdio Wrapper] Using provider order: ${priorityOrder.join(' > ')} (user order: ${userOrder.join(', ') || 'none'})`);
|
|
1680
1706
|
|
|
1681
1707
|
for (const providerId of priorityOrder) {
|
|
1682
1708
|
const status = results[providerId];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polydev-ai",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.5",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=20.x <=22.x"
|
|
6
6
|
},
|
|
@@ -45,7 +45,11 @@
|
|
|
45
45
|
"test:admin": "jest __tests__/api/admin",
|
|
46
46
|
"mcp": "node mcp/server.js",
|
|
47
47
|
"mcp-stdio": "node mcp/stdio-wrapper.js",
|
|
48
|
-
"cli-detect": "node -e \"const CLIManager = require('./lib/cliManager').default; const m = new CLIManager(); m.forceCliDetection().then(console.log);\""
|
|
48
|
+
"cli-detect": "node -e \"const CLIManager = require('./lib/cliManager').default; const m = new CLIManager(); m.forceCliDetection().then(console.log);\"",
|
|
49
|
+
"release": "bash scripts/release.sh",
|
|
50
|
+
"release:patch": "bash scripts/release.sh patch",
|
|
51
|
+
"release:minor": "bash scripts/release.sh minor",
|
|
52
|
+
"release:major": "bash scripts/release.sh major"
|
|
49
53
|
},
|
|
50
54
|
"repository": {
|
|
51
55
|
"type": "git",
|