From c363f1207c55df159ce62a2245d4d82032e27b08 Mon Sep 17 00:00:00 2001 From: rUv Date: Tue, 12 Aug 2025 18:49:25 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=96=20Checkpoint:=20Edit=20/workspaces?= =?UTF-8?q?/claude-code-flow/src/cli/simple-commands/stream-chain.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/checkpoints/1755024546.json | 1 + .claude/checkpoints/1755024548.json | 1 + src/cli/simple-commands/stream-chain.js | 39 ++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 .claude/checkpoints/1755024546.json create mode 100644 .claude/checkpoints/1755024548.json diff --git a/.claude/checkpoints/1755024546.json b/.claude/checkpoints/1755024546.json new file mode 100644 index 0000000000..8ab7e00af9 --- /dev/null +++ b/.claude/checkpoints/1755024546.json @@ -0,0 +1 @@ +{"branch": "checkpoint/pre-edit-20250812-184906", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/stream-chain.js", "timestamp": "2025-08-12T18:49:06Z", "type": "pre-edit", "original_branch": "alpha-89"} diff --git a/.claude/checkpoints/1755024548.json b/.claude/checkpoints/1755024548.json new file mode 100644 index 0000000000..35f02d6879 --- /dev/null +++ b/.claude/checkpoints/1755024548.json @@ -0,0 +1 @@ +{"tag": "checkpoint-20250812-184908", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/stream-chain.js", "timestamp": "2025-08-12T18:49:08Z", "type": "post-edit", "branch": "alpha-89", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 490 ++++++++++++++++++++++++++++--- .claude-flow/metrics/task-metrics.json | 6 +- .claude/checkpoints/1755024432.json | 1 + .claude/checkpoints/1755024434.json | 1 + claude-flow-wiki | 0 src/cli/simple-commands/stream-chain.js | 2 +- 7 files changed, 462 insertions(+), 40 deletions(-) "} diff --git a/src/cli/simple-commands/stream-chain.js b/src/cli/simple-commands/stream-chain.js index e07ee6b2a0..d40f665e62 100644 --- a/src/cli/simple-commands/stream-chain.js +++ b/src/cli/simple-commands/stream-chain.js @@ -390,7 +390,44 @@ async function executeStreamStep(prompt, inputStream, isLast, flags = {}) { console.log(` Debug: Executing: claude ${args.join(' ')}`); } - // Spawn Claude process + // Try exec instead of spawn for better compatibility + const command = `claude ${args.join(' ')}`; + + exec(command, { + timeout: stepTimeout, + maxBuffer: 1024 * 1024 * 10 // 10MB buffer + }, (error, stdout, stderr) => { + clearTimeout(timeoutId); + + if (timedOut) { + return; // Already handled by timeout + } + + const duration = Date.now() - startTime; + + if (error && error.code === 'TIMEOUT') { + // Handle timeout via exec + timedOut = true; + console.log('⚠️ Claude CLI timed out, falling back to mock mode...'); + mockStreamStep(prompt, inputStream, isLast, { ...flags, mock: true }, safeResolve, Date.now()); + return; + } + + if (flags.verbose && stderr) { + console.error('Error output:', stderr); + } + + safeResolve({ + success: !error || error.code === 0, + duration, + output: stdout || '', + stream: (!isLast && stdout) ? stdout : null, + error: stderr || (error ? error.message : null) + }); + }); + + // Keep the original spawn logic as backup (commented out) + /* const claudeProcess = spawn('claude', args, { stdio: ['pipe', 'pipe', 'pipe'] });