polydev-ai 1.5.0 → 1.5.2
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 +59 -15
- package/mcp/stdio-wrapper.js +3 -3
- package/package.json +2 -2
package/lib/cliManager.js
CHANGED
|
@@ -379,17 +379,15 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
async sendCliPrompt(providerId, prompt, mode = 'args', timeoutMs = null) {
|
|
382
|
-
// Set provider-specific default timeouts
|
|
382
|
+
// Set provider-specific default timeouts (180s for all by default, complex prompts take time)
|
|
383
383
|
if (timeoutMs === null) {
|
|
384
|
-
timeoutMs =
|
|
385
|
-
}
|
|
386
|
-
if (providerId === 'codex_cli' && timeoutMs < 90000) {
|
|
387
|
-
timeoutMs = 90000;
|
|
384
|
+
timeoutMs = 180000; // 180 seconds default for all providers
|
|
388
385
|
}
|
|
389
386
|
|
|
390
387
|
// Ensure timeoutMs is valid (not undefined, null, Infinity, or negative)
|
|
388
|
+
// Allow up to 300 seconds (5 minutes) for complex operations
|
|
391
389
|
if (!timeoutMs || timeoutMs === Infinity || timeoutMs < 1 || timeoutMs > 300000) {
|
|
392
|
-
timeoutMs =
|
|
390
|
+
timeoutMs = 180000 // Default to 180 seconds
|
|
393
391
|
}
|
|
394
392
|
|
|
395
393
|
const startTime = Date.now();
|
|
@@ -514,10 +512,11 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
514
512
|
}
|
|
515
513
|
}
|
|
516
514
|
|
|
517
|
-
async executeCliCommand(command, args, mode = 'args', timeoutMs =
|
|
515
|
+
async executeCliCommand(command, args, mode = 'args', timeoutMs = 180000, stdinInput) {
|
|
518
516
|
// Ensure timeoutMs is valid (not undefined, null, Infinity, or negative)
|
|
517
|
+
// Allow up to 300 seconds (5 minutes) for complex operations
|
|
519
518
|
if (!timeoutMs || timeoutMs === Infinity || timeoutMs < 1 || timeoutMs > 300000) {
|
|
520
|
-
timeoutMs =
|
|
519
|
+
timeoutMs = 180000 // Default to 180 seconds
|
|
521
520
|
}
|
|
522
521
|
|
|
523
522
|
return new Promise((resolve, reject) => {
|
|
@@ -672,17 +671,52 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
672
671
|
stop(() => reject(new Error(`Codex exec timeout after ${timeoutMs}ms`)));
|
|
673
672
|
}, timeoutMs);
|
|
674
673
|
|
|
674
|
+
// Helper function to parse Codex output robustly
|
|
675
|
+
const parseCodexOutput = (output) => {
|
|
676
|
+
if (!output || !output.trim()) return null;
|
|
677
|
+
|
|
678
|
+
const lines = output.split('\n');
|
|
679
|
+
const contentLines = [];
|
|
680
|
+
|
|
681
|
+
// Filter out MCP protocol noise and collect actual content
|
|
682
|
+
for (const line of lines) {
|
|
683
|
+
const trimmedLine = line.trim();
|
|
684
|
+
// Skip empty lines and MCP/protocol noise
|
|
685
|
+
if (!trimmedLine) continue;
|
|
686
|
+
if (trimmedLine.startsWith('MCP ')) continue;
|
|
687
|
+
if (trimmedLine.includes('handshake') && trimmedLine.includes('error')) continue;
|
|
688
|
+
if (trimmedLine.startsWith('[MCP]')) continue;
|
|
689
|
+
if (trimmedLine.startsWith('Error:') && trimmedLine.includes('MCP')) continue;
|
|
690
|
+
|
|
691
|
+
// Extract bullet content if present, otherwise keep the line
|
|
692
|
+
const bulletMatch = trimmedLine.match(/^•\s*(.+)/);
|
|
693
|
+
if (bulletMatch) {
|
|
694
|
+
contentLines.push(bulletMatch[1].trim());
|
|
695
|
+
} else if (!trimmedLine.startsWith('•')) {
|
|
696
|
+
// Keep non-bullet content that isn't just whitespace
|
|
697
|
+
contentLines.push(trimmedLine);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
const result = contentLines.join('\n').trim();
|
|
702
|
+
return result.length > 0 ? result : null;
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
// Check if we have a complete response - look for actual content
|
|
675
706
|
const flushIfComplete = () => {
|
|
676
|
-
const
|
|
677
|
-
if (
|
|
707
|
+
const parsed = parseCodexOutput(stdout);
|
|
708
|
+
// Only resolve early if we have meaningful content (at least 2 chars) and output seems done
|
|
709
|
+
// This prevents cutting off multi-line responses
|
|
710
|
+
if (parsed && parsed.length >= 2 && stdout.includes('\n') && !stdout.endsWith('...')) {
|
|
678
711
|
clearTimeout(timeoutHandle);
|
|
679
|
-
stop(() => resolve(
|
|
712
|
+
stop(() => resolve(parsed));
|
|
680
713
|
}
|
|
681
714
|
};
|
|
682
715
|
|
|
683
716
|
child.stdout?.on('data', (data) => {
|
|
684
717
|
stdout += data.toString();
|
|
685
|
-
|
|
718
|
+
// Don't flush too eagerly - wait a bit for more data
|
|
719
|
+
// flushIfComplete(); // Disabled: let the process complete naturally
|
|
686
720
|
});
|
|
687
721
|
|
|
688
722
|
child.stderr?.on('data', (data) => {
|
|
@@ -698,12 +732,22 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
698
732
|
const trimmedStderr = stderr.trim();
|
|
699
733
|
|
|
700
734
|
if (code === 0 && trimmedStdout) {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
735
|
+
// Use the robust parser for consistent output handling
|
|
736
|
+
const parsed = parseCodexOutput(trimmedStdout);
|
|
737
|
+
if (parsed) {
|
|
738
|
+
resolve(parsed);
|
|
704
739
|
return;
|
|
705
740
|
}
|
|
741
|
+
// Fallback to raw output if parsing yields nothing
|
|
706
742
|
resolve(trimmedStdout);
|
|
743
|
+
} else if (code === 0) {
|
|
744
|
+
// Code 0 but no stdout - check if stderr has useful info
|
|
745
|
+
const parsedStderr = parseCodexOutput(trimmedStderr);
|
|
746
|
+
if (parsedStderr) {
|
|
747
|
+
resolve(parsedStderr);
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
reject(new Error('Codex completed but produced no output'));
|
|
707
751
|
} else {
|
|
708
752
|
reject(new Error(trimmedStderr || trimmedStdout || `Codex exited with code ${code}`));
|
|
709
753
|
}
|
package/mcp/stdio-wrapper.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const os = require('os');
|
|
7
|
-
const { CLIManager } = require('
|
|
7
|
+
const { CLIManager } = require('../lib/cliManager');
|
|
8
8
|
|
|
9
9
|
// Simple .env file loader (no external dependencies)
|
|
10
10
|
function loadEnvFile(filePath) {
|
|
@@ -449,8 +449,8 @@ class StdioMCPWrapper {
|
|
|
449
449
|
throw new Error('prompt is required');
|
|
450
450
|
}
|
|
451
451
|
|
|
452
|
-
// Use reasonable timeout for CLI responses (
|
|
453
|
-
const gracefulTimeout = Math.min(timeout_ms,
|
|
452
|
+
// Use reasonable timeout for CLI responses (180 seconds for complex prompts)
|
|
453
|
+
const gracefulTimeout = Math.min(timeout_ms, 180000);
|
|
454
454
|
|
|
455
455
|
let localResults = [];
|
|
456
456
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polydev-ai",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
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": "latest",
|
|
71
71
|
"posthog-js": "^1.157.2",
|
|
72
72
|
"prismjs": "^1.30.0",
|
|
73
73
|
"react": "^18.3.1",
|