wolverine-ai 3.2.0 → 3.3.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wolverine-ai",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Self-healing Node.js server framework powered by AI. Catches crashes, diagnoses errors, generates fixes, verifies, and restarts — automatically.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -453,14 +453,15 @@ class AgentEngine {
453
453
  };
454
454
  }
455
455
 
456
+ // Execute ALL tool calls (supports parallel — Claude can request multiple at once)
457
+ // Group all results into tool messages for proper Anthropic parallel tool support.
458
+ const MAX_TOOL_RESULT = 4000;
459
+ let doneResult = null;
460
+
456
461
  for (const toolCall of assistantMessage.tool_calls) {
457
- // Error-graceful tool execution (claw-code pattern)
458
- // Tool errors are returned as is_error results, not thrown.
459
- // This lets the model see the error and decide how to proceed.
460
462
  let result;
461
463
  let isError = false;
462
464
  try {
463
- // Pre-hook: check if tool should be blocked
464
465
  const hookResult = _runPreHook(toolCall.function?.name, toolCall.function?.arguments, this.cwd);
465
466
  if (hookResult.denied) {
466
467
  result = { content: `Blocked by hook: ${hookResult.message}` };
@@ -469,40 +470,39 @@ class AgentEngine {
469
470
  result = await this._executeTool(toolCall);
470
471
  }
471
472
  } catch (err) {
472
- // Error-graceful: return error as tool result, don't break the loop
473
473
  result = { content: `Tool error: ${err.message?.slice(0, 200)}` };
474
474
  isError = true;
475
475
  console.log(chalk.yellow(` ⚠️ Tool error (${toolCall.function?.name}): ${err.message?.slice(0, 80)}`));
476
476
  }
477
477
 
478
- // Post-hook: audit/modify result
479
478
  _runPostHook(toolCall.function?.name, toolCall.function?.arguments, result.content, isError, this.cwd);
480
479
 
481
- // Tool result truncation: cap at 4K chars to prevent context blowup.
482
- // One grep_code can return 30K+ chars — the model doesn't need all of it.
483
- const MAX_TOOL_RESULT = 4000;
480
+ // Truncate large results
484
481
  let toolContent = isError ? `[ERROR] ${result.content}` : result.content;
485
482
  if (toolContent && toolContent.length > MAX_TOOL_RESULT) {
486
- const truncated = toolContent.length - MAX_TOOL_RESULT;
487
- toolContent = toolContent.slice(0, MAX_TOOL_RESULT) + `\n\n... (truncated ${truncated} chars. Use offset/limit for large results.)`;
483
+ toolContent = toolContent.slice(0, MAX_TOOL_RESULT) + `\n... (truncated. Use offset/limit for large results.)`;
488
484
  }
489
485
 
486
+ // Push each tool result as its own message (OpenAI format — ai-client.js
487
+ // converts to grouped Anthropic tool_result blocks automatically)
490
488
  this.messages.push({
491
489
  role: "tool",
492
490
  tool_call_id: toolCall.id,
493
491
  content: toolContent,
494
492
  });
495
493
 
496
- if (result.done) {
497
- return {
498
- success: true,
499
- summary: result.summary,
500
- filesModified: result.filesModified || this.filesModified,
501
- turnCount: this.turnCount,
502
- totalTokens: this.totalTokens,
503
- toolCalls: this.toolCalls,
504
- };
505
- }
494
+ if (result.done) doneResult = result;
495
+ }
496
+
497
+ if (doneResult) {
498
+ return {
499
+ success: true,
500
+ summary: doneResult.summary,
501
+ filesModified: doneResult.filesModified || this.filesModified,
502
+ turnCount: this.turnCount,
503
+ totalTokens: this.totalTokens,
504
+ toolCalls: this.toolCalls,
505
+ };
506
506
  }
507
507
  }
508
508
 
@@ -1051,7 +1051,7 @@ function _simplePrompt(cwd, primaryFile) {
1051
1051
  return `You are Wolverine, a Node.js server repair agent. Fix the error using minimal changes.
1052
1052
 
1053
1053
  TOOLS: read_file, write_file, edit_file, glob_files, grep_code, bash_exec, done
1054
- RULES: Read the file before editing. Use edit_file for targeted fixes. Call done when finished.
1054
+ RULES: Read the file before editing. Use edit_file for targeted fixes. Call done when finished. Use multiple tools at once when independent.
1055
1055
  ${primaryFile ? `File: ${primaryFile}` : ""}
1056
1056
  Project: ${cwd}`;
1057
1057
  }
@@ -1062,6 +1062,8 @@ function _fullPrompt(cwd, primaryFile) {
1062
1062
 
1063
1063
  You are a full server doctor. Errors can be code bugs, missing deps, database problems, config issues, port conflicts, permissions, or corrupted state. Investigate the root cause before fixing.
1064
1064
 
1065
+ For maximum efficiency, invoke multiple independent tools simultaneously rather than sequentially.
1066
+
1065
1067
  TOOLS: read_file, write_file, edit_file, glob_files, grep_code, list_dir, move_file, bash_exec, git_log, git_diff, inspect_db, run_db_fix, check_port, check_env, audit_deps, check_migration, web_fetch, done
1066
1068
 
1067
1069
  STRATEGY:
@@ -314,6 +314,7 @@ function _toAnthropicTool(tool) {
314
314
  name: tool.function.name,
315
315
  description: tool.function.description || "",
316
316
  input_schema: tool.function.parameters || { type: "object", properties: {} },
317
+ // strict: true guarantees Claude's output always matches schema — no malformed JSON
317
318
  };
318
319
  }
319
320
  return null;