polydev-ai 1.8.2 → 1.8.4
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 +90 -7
- package/mcp/stdio-wrapper.js +1 -1
- package/package.json +2 -2
package/lib/cliManager.js
CHANGED
|
@@ -444,7 +444,18 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
444
444
|
if (providerId === 'codex_cli') {
|
|
445
445
|
const execArgs = promptVariants.find(args => args.includes('exec')) || promptVariants[0];
|
|
446
446
|
try {
|
|
447
|
-
const
|
|
447
|
+
const result = await this.executeCodexExec(provider.command, execArgs, prompt, timeoutMs, model);
|
|
448
|
+
// executeCodexExec now returns { content, detectedModel, rawStdout, rawStderr }
|
|
449
|
+
const content = result.content;
|
|
450
|
+
const detectedModel = result.detectedModel;
|
|
451
|
+
|
|
452
|
+
// Use detected model if available, otherwise fall back to what was requested or 'cli_default'
|
|
453
|
+
const actualModel = detectedModel || model || 'cli_default';
|
|
454
|
+
|
|
455
|
+
if (detectedModel && detectedModel !== model) {
|
|
456
|
+
console.log(`[Polydev CLI] Codex CLI detected model: ${detectedModel} (requested: ${model || 'none'})`);
|
|
457
|
+
}
|
|
458
|
+
|
|
448
459
|
return {
|
|
449
460
|
success: true,
|
|
450
461
|
content,
|
|
@@ -452,7 +463,7 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
452
463
|
latency_ms: Date.now() - startTime,
|
|
453
464
|
provider: providerId,
|
|
454
465
|
mode: 'args',
|
|
455
|
-
model_used:
|
|
466
|
+
model_used: actualModel,
|
|
456
467
|
timestamp: new Date()
|
|
457
468
|
};
|
|
458
469
|
} catch (error) {
|
|
@@ -500,6 +511,15 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
500
511
|
|
|
501
512
|
if (!result.error) {
|
|
502
513
|
const content = this.cleanCliResponse(result.stdout || '');
|
|
514
|
+
|
|
515
|
+
// Detect actual model from CLI output
|
|
516
|
+
const detectedModel = this.detectModelFromOutput(providerId, result.stdout || '', result.stderr || '');
|
|
517
|
+
const actualModel = detectedModel || model || 'cli_default';
|
|
518
|
+
|
|
519
|
+
if (detectedModel && detectedModel !== model) {
|
|
520
|
+
console.log(`[Polydev CLI] ${providerId} detected model: ${detectedModel} (requested: ${model || 'none'})`);
|
|
521
|
+
}
|
|
522
|
+
|
|
503
523
|
return {
|
|
504
524
|
success: true,
|
|
505
525
|
content,
|
|
@@ -507,7 +527,7 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
507
527
|
latency_ms: Date.now() - startTime,
|
|
508
528
|
provider: providerId,
|
|
509
529
|
mode: 'args',
|
|
510
|
-
model_used:
|
|
530
|
+
model_used: actualModel,
|
|
511
531
|
timestamp: new Date()
|
|
512
532
|
};
|
|
513
533
|
}
|
|
@@ -531,6 +551,15 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
531
551
|
|
|
532
552
|
if (!fallbackResult.error) {
|
|
533
553
|
const content = this.cleanCliResponse(fallbackResult.stdout || '');
|
|
554
|
+
|
|
555
|
+
// Detect actual model from fallback output
|
|
556
|
+
const detectedModel = this.detectModelFromOutput(providerId, fallbackResult.stdout || '', fallbackResult.stderr || '');
|
|
557
|
+
const actualModel = detectedModel || 'cli_default_fallback';
|
|
558
|
+
|
|
559
|
+
if (detectedModel) {
|
|
560
|
+
console.log(`[Polydev CLI] ${providerId} fallback detected model: ${detectedModel}`);
|
|
561
|
+
}
|
|
562
|
+
|
|
534
563
|
return {
|
|
535
564
|
success: true,
|
|
536
565
|
content,
|
|
@@ -538,7 +567,7 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
538
567
|
latency_ms: Date.now() - startTime,
|
|
539
568
|
provider: providerId,
|
|
540
569
|
mode: 'args',
|
|
541
|
-
model_used:
|
|
570
|
+
model_used: actualModel,
|
|
542
571
|
timestamp: new Date()
|
|
543
572
|
};
|
|
544
573
|
}
|
|
@@ -667,6 +696,57 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
667
696
|
});
|
|
668
697
|
}
|
|
669
698
|
|
|
699
|
+
// Detect actual model from CLI output before parsing/cleaning
|
|
700
|
+
detectModelFromOutput(providerId, stdout, stderr) {
|
|
701
|
+
const combinedOutput = (stdout || '') + '\n' + (stderr || '');
|
|
702
|
+
|
|
703
|
+
// Different patterns for different CLI tools
|
|
704
|
+
switch (providerId) {
|
|
705
|
+
case 'claude_code': {
|
|
706
|
+
// Claude Code may output model info in various formats
|
|
707
|
+
// Look for patterns like "model: claude-sonnet-4-20250514" or "Using model: ..."
|
|
708
|
+
const claudeModelMatch = combinedOutput.match(/(?:model|using model)[:\s]+([a-zA-Z0-9_.-]+)/i);
|
|
709
|
+
if (claudeModelMatch && claudeModelMatch[1]) {
|
|
710
|
+
const model = claudeModelMatch[1].trim();
|
|
711
|
+
// Filter out invalid values
|
|
712
|
+
if (model && model !== 'undefined' && model !== 'null' && model.length > 2) {
|
|
713
|
+
return model;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
break;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
case 'codex_cli': {
|
|
720
|
+
// Codex CLI outputs configuration header like:
|
|
721
|
+
// model: gpt-4.1
|
|
722
|
+
// or: model: o4-mini
|
|
723
|
+
const codexModelMatch = combinedOutput.match(/^\s*model:\s*([a-zA-Z0-9_.-]+)/mi);
|
|
724
|
+
if (codexModelMatch && codexModelMatch[1]) {
|
|
725
|
+
const model = codexModelMatch[1].trim();
|
|
726
|
+
if (model && model !== 'undefined' && model !== 'null' && model.length > 2) {
|
|
727
|
+
return model;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
break;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
case 'gemini_cli': {
|
|
734
|
+
// Gemini CLI may output model info
|
|
735
|
+
// Look for patterns like "model: gemini-2.0-flash" or "Using gemini-..."
|
|
736
|
+
const geminiModelMatch = combinedOutput.match(/(?:model|using)[:\s]+(gemini[a-zA-Z0-9_.-]*)/i);
|
|
737
|
+
if (geminiModelMatch && geminiModelMatch[1]) {
|
|
738
|
+
const model = geminiModelMatch[1].trim();
|
|
739
|
+
if (model && model.length > 2) {
|
|
740
|
+
return model;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
break;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
return null; // Could not detect model from output
|
|
748
|
+
}
|
|
749
|
+
|
|
670
750
|
async executeCodexExec(executable, commandArgs, prompt, timeoutMs, model = null) {
|
|
671
751
|
if (!executable) {
|
|
672
752
|
throw new Error('Missing Codex executable');
|
|
@@ -849,18 +929,21 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
849
929
|
// Combine stdout and stderr for parsing - Codex may output to either
|
|
850
930
|
const combinedOutput = trimmedStdout + '\n' + trimmedStderr;
|
|
851
931
|
|
|
932
|
+
// Detect the actual model used BEFORE parsing (model info is in the header)
|
|
933
|
+
const detectedModel = this.detectModelFromOutput('codex_cli', trimmedStdout, trimmedStderr);
|
|
934
|
+
|
|
852
935
|
// Always try to parse stdout first, regardless of exit code
|
|
853
936
|
// MCP handshake failures cause non-zero exit but don't prevent valid responses
|
|
854
937
|
const parsedStdout = parseCodexOutput(trimmedStdout);
|
|
855
938
|
if (parsedStdout) {
|
|
856
|
-
resolve(parsedStdout);
|
|
939
|
+
resolve({ content: parsedStdout, detectedModel, rawStdout: trimmedStdout, rawStderr: trimmedStderr });
|
|
857
940
|
return;
|
|
858
941
|
}
|
|
859
942
|
|
|
860
943
|
// Try parsing combined output (some responses may appear in stderr)
|
|
861
944
|
const parsedCombined = parseCodexOutput(combinedOutput);
|
|
862
945
|
if (parsedCombined) {
|
|
863
|
-
resolve(parsedCombined);
|
|
946
|
+
resolve({ content: parsedCombined, detectedModel, rawStdout: trimmedStdout, rawStderr: trimmedStderr });
|
|
864
947
|
return;
|
|
865
948
|
}
|
|
866
949
|
|
|
@@ -868,7 +951,7 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
868
951
|
if (code === 0) {
|
|
869
952
|
// Successful exit but no parseable output
|
|
870
953
|
if (trimmedStdout) {
|
|
871
|
-
resolve(trimmedStdout); // Return raw output as fallback
|
|
954
|
+
resolve({ content: trimmedStdout, detectedModel, rawStdout: trimmedStdout, rawStderr: trimmedStderr }); // Return raw output as fallback
|
|
872
955
|
} else {
|
|
873
956
|
reject(new Error('Codex completed but produced no output'));
|
|
874
957
|
}
|
package/mcp/stdio-wrapper.js
CHANGED
|
@@ -686,7 +686,7 @@ class StdioMCPWrapper {
|
|
|
686
686
|
// Format CLI responses for logging on the server
|
|
687
687
|
const cliResponses = localResults.map(result => ({
|
|
688
688
|
provider_id: result.provider_id,
|
|
689
|
-
model: result.
|
|
689
|
+
model: result.model_used || this.getDefaultModelForCli(result.provider_id),
|
|
690
690
|
content: result.content || '',
|
|
691
691
|
tokens_used: result.tokens_used || 0,
|
|
692
692
|
latency_ms: result.latency_ms || 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polydev-ai",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.4",
|
|
4
4
|
"description": "Agentic workflow assistant with CLI integration - get diverse perspectives from multiple LLMs when stuck or need enhanced reasoning",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"lucide-react": "^0.542.0",
|
|
68
68
|
"marked": "^16.2.1",
|
|
69
69
|
"next": "^15.5.7",
|
|
70
|
-
"polydev-ai": "
|
|
70
|
+
"polydev-ai": "^1.8.3",
|
|
71
71
|
"posthog-js": "^1.157.2",
|
|
72
72
|
"prismjs": "^1.30.0",
|
|
73
73
|
"react": "^18.3.1",
|