polydev-ai 1.8.10 → 1.8.12
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 +75 -31
- package/package.json +1 -1
package/lib/cliManager.js
CHANGED
|
@@ -443,38 +443,82 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
443
443
|
|
|
444
444
|
if (providerId === 'codex_cli') {
|
|
445
445
|
const execArgs = promptVariants.find(args => args.includes('exec')) || promptVariants[0];
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
446
|
+
|
|
447
|
+
// Try with specified model first, fallback to CLI default if model fails
|
|
448
|
+
let modelToUse = model;
|
|
449
|
+
let attempts = 0;
|
|
450
|
+
const maxAttempts = model ? 2 : 1; // Only retry if model was specified
|
|
451
|
+
|
|
452
|
+
while (attempts < maxAttempts) {
|
|
453
|
+
attempts++;
|
|
454
|
+
try {
|
|
455
|
+
const result = await this.executeCodexExec(provider.command, execArgs, prompt, timeoutMs, modelToUse);
|
|
456
|
+
// executeCodexExec now returns { content, detectedModel, rawStdout, rawStderr }
|
|
457
|
+
const content = result.content;
|
|
458
|
+
const detectedModel = result.detectedModel;
|
|
459
|
+
const rawStdout = result.rawStdout || '';
|
|
460
|
+
const rawStderr = result.rawStderr || '';
|
|
461
|
+
|
|
462
|
+
// Check ALL outputs for model error - content, rawStdout, and rawStderr
|
|
463
|
+
const combinedOutput = `${content || ''} ${rawStdout} ${rawStderr}`.toLowerCase();
|
|
464
|
+
const modelError = combinedOutput.includes('model is not supported') ||
|
|
465
|
+
combinedOutput.includes('model not found') ||
|
|
466
|
+
combinedOutput.includes('invalid model') ||
|
|
467
|
+
combinedOutput.includes("doesn't exist") ||
|
|
468
|
+
combinedOutput.includes("model does not exist") ||
|
|
469
|
+
combinedOutput.includes("unknown model");
|
|
470
|
+
|
|
471
|
+
if (modelError && modelToUse && attempts < maxAttempts) {
|
|
472
|
+
console.log(`[Polydev CLI] Model '${modelToUse}' failed for Codex CLI (detected in output), retrying with CLI default...`);
|
|
473
|
+
modelToUse = null; // Retry without model flag
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// Use detected model if available, otherwise fall back to what was requested or 'cli_default'
|
|
478
|
+
const actualModel = detectedModel || modelToUse || 'cli_default';
|
|
479
|
+
|
|
480
|
+
if (detectedModel && detectedModel !== model) {
|
|
481
|
+
console.log(`[Polydev CLI] Codex CLI detected model: ${detectedModel} (requested: ${model || 'none'})`);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
return {
|
|
485
|
+
success: true,
|
|
486
|
+
content,
|
|
487
|
+
tokens_used: this.estimateTokens(prompt + content),
|
|
488
|
+
latency_ms: Date.now() - startTime,
|
|
489
|
+
provider: providerId,
|
|
490
|
+
mode: 'args',
|
|
491
|
+
model_used: actualModel,
|
|
492
|
+
timestamp: new Date()
|
|
493
|
+
};
|
|
494
|
+
} catch (error) {
|
|
495
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
496
|
+
|
|
497
|
+
// Check if error is model-related and we can retry
|
|
498
|
+
const isModelError = errorMsg.toLowerCase().includes('model') && (
|
|
499
|
+
errorMsg.includes('not supported') ||
|
|
500
|
+
errorMsg.includes('not found') ||
|
|
501
|
+
errorMsg.includes('invalid') ||
|
|
502
|
+
errorMsg.includes("doesn't exist") ||
|
|
503
|
+
errorMsg.includes("does not exist") ||
|
|
504
|
+
errorMsg.includes("unknown")
|
|
505
|
+
);
|
|
506
|
+
|
|
507
|
+
if (isModelError && modelToUse && attempts < maxAttempts) {
|
|
508
|
+
console.log(`[Polydev CLI] Model '${modelToUse}' error for Codex CLI, retrying with CLI default...`);
|
|
509
|
+
modelToUse = null; // Retry without model flag
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
return {
|
|
514
|
+
success: false,
|
|
515
|
+
error: `CLI execution failed: ${errorMsg}`,
|
|
516
|
+
latency_ms: Date.now() - startTime,
|
|
517
|
+
provider: providerId,
|
|
518
|
+
mode,
|
|
519
|
+
timestamp: new Date()
|
|
520
|
+
};
|
|
457
521
|
}
|
|
458
|
-
|
|
459
|
-
return {
|
|
460
|
-
success: true,
|
|
461
|
-
content,
|
|
462
|
-
tokens_used: this.estimateTokens(prompt + content),
|
|
463
|
-
latency_ms: Date.now() - startTime,
|
|
464
|
-
provider: providerId,
|
|
465
|
-
mode: 'args',
|
|
466
|
-
model_used: actualModel,
|
|
467
|
-
timestamp: new Date()
|
|
468
|
-
};
|
|
469
|
-
} catch (error) {
|
|
470
|
-
return {
|
|
471
|
-
success: false,
|
|
472
|
-
error: `CLI execution failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
473
|
-
latency_ms: Date.now() - startTime,
|
|
474
|
-
provider: providerId,
|
|
475
|
-
mode,
|
|
476
|
-
timestamp: new Date()
|
|
477
|
-
};
|
|
478
522
|
}
|
|
479
523
|
}
|
|
480
524
|
|
package/package.json
CHANGED