polydev-ai 1.5.1 → 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 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 = providerId === 'claude_code' ? 60000 : 30000; // 60s for Claude Code, 30s for others
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 = 30000 // Default to 30 seconds
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 = 30000, stdinInput) {
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 = 30000 // Default to 30 seconds
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 match = stdout.match(/•\s*(.+)/);
677
- if (match && match[1]) {
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(match[1].trim()));
712
+ stop(() => resolve(parsed));
680
713
  }
681
714
  };
682
715
 
683
716
  child.stdout?.on('data', (data) => {
684
717
  stdout += data.toString();
685
- flushIfComplete();
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
- const match = trimmedStdout.match(/•\s*(.+)/);
702
- if (match && match[1]) {
703
- resolve(match[1].trim());
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
  }
@@ -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 (15 seconds instead of 5)
453
- const gracefulTimeout = Math.min(timeout_ms, 15000);
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.1",
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",