agentic-flow 1.8.10 → 1.8.11

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.
@@ -237,13 +237,63 @@ export async function claudeAgent(agent, input, onStream, modelOverride) {
237
237
  options: queryOptions
238
238
  });
239
239
  let output = '';
240
+ let toolCallCount = 0;
240
241
  for await (const msg of result) {
242
+ const msgAny = msg; // Use any to handle different event types from SDK
243
+ // Debug: Log message structure to understand SDK events
244
+ if (process.env.DEBUG_STREAMING === 'true') {
245
+ console.error(`[DEBUG] Message type: ${msg.type}, keys: ${Object.keys(msg).join(', ')}`);
246
+ }
247
+ // Handle assistant text messages
241
248
  if (msg.type === 'assistant') {
242
249
  const chunk = msg.message.content?.map((c) => c.type === 'text' ? c.text : '').join('') || '';
243
250
  output += chunk;
244
251
  if (onStream && chunk) {
245
252
  onStream(chunk);
246
253
  }
254
+ // Check for tool use in message content blocks
255
+ const toolBlocks = msg.message.content?.filter((c) => c.type === 'tool_use') || [];
256
+ for (const toolBlock of toolBlocks) {
257
+ toolCallCount++;
258
+ const toolName = toolBlock.name || 'unknown';
259
+ const timestamp = new Date().toISOString().split('T')[1].split('.')[0];
260
+ const progressMsg = `\n[${timestamp}] 🔍 Tool call #${toolCallCount}: ${toolName}\n`;
261
+ process.stderr.write(progressMsg);
262
+ if (onStream) {
263
+ onStream(progressMsg);
264
+ }
265
+ }
266
+ }
267
+ // Handle stream events that contain tool information
268
+ if (msgAny.streamEvent) {
269
+ const event = msgAny.streamEvent;
270
+ // Tool use event (content_block_start with tool_use)
271
+ if (event.type === 'content_block_start' && event.content_block?.type === 'tool_use') {
272
+ toolCallCount++;
273
+ const toolName = event.content_block.name || 'unknown';
274
+ const timestamp = new Date().toISOString().split('T')[1].split('.')[0];
275
+ const progressMsg = `\n[${timestamp}] 🔍 Tool call #${toolCallCount}: ${toolName}\n`;
276
+ process.stderr.write(progressMsg);
277
+ if (onStream) {
278
+ onStream(progressMsg);
279
+ }
280
+ }
281
+ // Tool result event (content_block_stop)
282
+ if (event.type === 'content_block_stop') {
283
+ const timestamp = new Date().toISOString().split('T')[1].split('.')[0];
284
+ const resultMsg = `[${timestamp}] ✅ Tool completed\n`;
285
+ process.stderr.write(resultMsg);
286
+ if (onStream) {
287
+ onStream(resultMsg);
288
+ }
289
+ }
290
+ }
291
+ // Flush output to ensure immediate visibility
292
+ if (process.stderr.uncork) {
293
+ process.stderr.uncork();
294
+ }
295
+ if (process.stdout.uncork) {
296
+ process.stdout.uncork();
247
297
  }
248
298
  }
249
299
  const duration = Date.now() - startTime;
package/dist/index.js CHANGED
@@ -76,7 +76,24 @@ async function runAgentMode(agentName, task, stream, modelOverride) {
76
76
  console.log(`🔧 Model: ${modelOverride}\n`);
77
77
  }
78
78
  console.log('⏳ Running...\n');
79
- const streamHandler = stream ? (chunk) => process.stdout.write(chunk) : undefined;
79
+ // Enhanced stream handler that writes to stderr for progress and stdout for content
80
+ const streamHandler = stream ? (chunk) => {
81
+ // Write progress indicators (timestamps, tool calls) to stderr
82
+ if (chunk.startsWith('\n[') || chunk.startsWith('[') || chunk.includes('🔍') || chunk.includes('✅') || chunk.includes('❌')) {
83
+ process.stderr.write(chunk);
84
+ }
85
+ else {
86
+ // Write text content to stdout
87
+ process.stdout.write(chunk);
88
+ }
89
+ // Force flush to ensure immediate visibility
90
+ if (process.stdout.uncork) {
91
+ process.stdout.uncork();
92
+ }
93
+ if (process.stderr.uncork) {
94
+ process.stderr.uncork();
95
+ }
96
+ } : undefined;
80
97
  // Use Claude Agent SDK with in-SDK MCP server and optional model override
81
98
  logger.info('Using Claude Agent SDK with in-SDK MCP server', { modelOverride });
82
99
  const result = await claudeAgent(agent, task, streamHandler, modelOverride);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-flow",
3
- "version": "1.8.10",
3
+ "version": "1.8.11",
4
4
  "description": "Production-ready AI agent orchestration platform with 66 specialized agents, 213 MCP tools, ReasoningBank learning memory, and autonomous multi-agent swarms. Built by @ruvnet with Claude Agent SDK, neural networks, memory persistence, GitHub integration, and distributed consensus protocols.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",