wolverine-ai 3.9.5 → 3.9.7

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.9.5",
3
+ "version": "3.9.7",
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": {
@@ -38,6 +38,11 @@ function _trackEmbedding(model, usage, latencyMs, success) {
38
38
  _tracker.record(model, "embedding", input, 0, null, latencyMs, success, 0, 0);
39
39
  }
40
40
 
41
+ function _trackOp(model, category, inputTokens, outputTokens, tool, latencyMs, success) {
42
+ if (!_tracker) return;
43
+ _tracker.record(model, category, inputTokens || 0, outputTokens || 0, tool || null, latencyMs || 0, success, 0, 0);
44
+ }
45
+
41
46
  // ── Client Management ──
42
47
 
43
48
  function getClient(provider) {
@@ -614,7 +619,7 @@ ${backupSourceCode ? `## Last Known Working Version\n\`\`\`javascript\n${backupS
614
619
  "changes" is for code edits (optional, use for actual code fixes).
615
620
  Include both if needed, or just one.`;
616
621
 
617
- const result = await aiCall({ model, systemPrompt, userPrompt, maxTokens: 2048, category: "coding" });
622
+ const result = await aiCall({ model, systemPrompt, userPrompt, maxTokens: 2048, category: "reasoning" });
618
623
  const content = (result.content || "").trim();
619
624
 
620
625
  // Strip thinking tags (Gemma), markdown fences, and any prefix text
@@ -639,4 +644,4 @@ Include both if needed, or just one.`;
639
644
  }
640
645
  }
641
646
 
642
- module.exports = { requestRepair, getClient, tokenParam, aiCall, aiCallWithHistory, isResponsesModel, isAnthropicModel, setTokenTracker, getTrackerSnapshot, detectProvider, _trackEmbedding };
647
+ module.exports = { requestRepair, getClient, tokenParam, aiCall, aiCallWithHistory, isResponsesModel, isAnthropicModel, setTokenTracker, getTrackerSnapshot, detectProvider, _trackEmbedding, _trackOp };
@@ -1,6 +1,6 @@
1
1
  const chalk = require("chalk");
2
2
  const { parseError } = require("./error-parser");
3
- const { requestRepair, getClient, aiCall } = require("./ai-client");
3
+ const { requestRepair, getClient, aiCall, _trackOp } = require("./ai-client");
4
4
  const { getModel } = require("./models");
5
5
  const { applyPatch } = require("./patcher");
6
6
  const { verifyFix } = require("./verifier");
@@ -341,6 +341,10 @@ async function _healImpl({ stderr, cwd, sandbox, notifier, rateLimiter, backupMa
341
341
  const patchResults = applyPatch(repair.changes, cwd, sandbox);
342
342
  if (!patchResults.every(r => r.success)) throw new Error("Patch failed");
343
343
 
344
+ // Track code generation as "coding" — the AI produced code changes
345
+ const codeTokens = repair.changes.reduce((s, c) => s + ((c.new || "").length / 4), 0);
346
+ _trackOp(getModel("coding"), "coding", 0, Math.round(codeTokens), "patch_apply", 0, true);
347
+
344
348
  for (const r of patchResults) console.log(chalk.green(` ✅ Patched: ${r.file}`));
345
349
  }
346
350
 
@@ -348,6 +352,11 @@ async function _healImpl({ stderr, cwd, sandbox, notifier, rateLimiter, backupMa
348
352
  if (verification.verified) {
349
353
  backupManager.markVerified(bid);
350
354
  rateLimiter.clearSignature(errorSignature);
355
+ // Track tool operations: file read + patch + verify + any commands
356
+ // These are the same operations an agent would do with read_file/write_file/bash_exec
357
+ const toolOps = 1 + (repair.changes?.length || 0) + (repair.commands?.length || 0) + 1; // read + patches + commands + verify
358
+ const toolTokens = (sourceCode?.length || 0) / 4; // approximate tokens for file read
359
+ _trackOp(getModel("tool"), "tool", Math.round(toolTokens), 0, "fast_path_ops", Date.now() - healStartTime, true);
351
360
  return { healed: true, explanation: repair.explanation, backupId: bid, mode: "fast" };
352
361
  }
353
362