Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/src/cli/simple-commands/stream-chain.js

rUv928bd34ec175
diff --git a/.claude/checkpoints/task-1755025932.json b/.claude/checkpoints/task-1755025932.json
new file mode 100644
index 0000000000..0b51ac90c0
--- /dev/null
+++ b/.claude/checkpoints/task-1755025932.json
@@ -0,0 +1 @@
+{"checkpoint": "task-20250812-191211", "task": "fix The error we're seeing ("Expected message type 'user' or 'control', got 'system'") is because ", "timestamp": "2025-08-12T19:12:12Z", "commit": "cc9985446f76167438a98c0e3b48088bf1cabf5e", "github_release": "true"}
diff --git a/src/cli/simple-commands/stream-chain.js b/src/cli/simple-commands/stream-chain.js
index 679bb294aa..4b657d741d 100644
--- a/src/cli/simple-commands/stream-chain.js
+++ b/src/cli/simple-commands/stream-chain.js
@@ -67,6 +67,33 @@ async function executeRealChain(prompts, flags = {}) {
return results;
}
+/**
+ * Filter stream-json to remove system messages and keep only user/assistant/result
+ */
+function filterStreamJson(rawOutput) {
+ const lines = rawOutput.split('\n').filter(line => line.trim());
+ const filtered = [];
+
+ for (const line of lines) {
+ try {
+ const json = JSON.parse(line);
+ // Keep only message types that --input-format accepts
+ if (json.type === 'message' || json.type === 'tool_use' || json.type === 'tool_result' || json.type === 'result') {
+ // For messages, ensure they have user or assistant role
+ if (json.type === 'message' && json.role !== 'system') {
+ filtered.push(line);
+ } else if (json.type !== 'message') {
+ filtered.push(line);
+ }
+ }
+ } catch (e) {
+ // Skip invalid JSON lines
+ }
+ }
+
+ return filtered.join('\n');
+}
+
/**
* Execute a single step in the chain with proper stream-json handling
*/
@@ -110,11 +137,15 @@ async function executeChainStep(prompt, inputData, isFirst, isLast, flags) {
// Pipe input data if available
if (!isFirst && inputData) {
try {
- // Write the previous output as input
- claudeProcess.stdin.write(inputData);
+ // Filter the input to remove system messages
+ const filteredInput = filterStreamJson(inputData);
+
+ // Write the filtered output as input
+ claudeProcess.stdin.write(filteredInput);
claudeProcess.stdin.end();
if (flags.verbose) {
- console.log(' πŸ”— Piped input from previous step');
+ console.log(' πŸ”— Piped filtered input from previous step');
+ console.log(` Filtered ${inputData.split('\n').length} lines to ${filteredInput.split('\n').filter(l => l).length} lines`);
}
} catch (error) {
console.error(' Error piping input:', error.message);