wolverine-ai 3.9.6 → 3.9.8
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 +12 -2
- package/src/core/ai-client.js +7 -2
- package/src/core/wolverine.js +10 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wolverine-ai",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.8",
|
|
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": {
|
|
@@ -52,11 +52,21 @@
|
|
|
52
52
|
],
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@anthropic-ai/sdk": "^0.82.0",
|
|
55
|
+
"@fastify/compress": "^8.0.0",
|
|
56
|
+
"@fastify/cors": "^10.0.0",
|
|
55
57
|
"chalk": "^4.1.2",
|
|
56
58
|
"diff": "^7.0.0",
|
|
57
59
|
"dotenv": "^16.4.7",
|
|
58
60
|
"fastify": "^5.8.4",
|
|
59
|
-
"
|
|
61
|
+
"ioredis": "^5.0.0",
|
|
62
|
+
"openai": "^4.73.0",
|
|
63
|
+
"pg": "^8.0.0"
|
|
64
|
+
},
|
|
65
|
+
"optionalDependencies": {
|
|
66
|
+
"@privy-io/server-auth": "^3.0.0",
|
|
67
|
+
"better-sqlite3": "^11.0.0",
|
|
68
|
+
"ethers": "^6.0.0",
|
|
69
|
+
"stripe": "^18.0.0"
|
|
60
70
|
},
|
|
61
71
|
"engines": {
|
|
62
72
|
"node": ">=18.0.0"
|
package/src/core/ai-client.js
CHANGED
|
@@ -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: "
|
|
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 };
|
package/src/core/wolverine.js
CHANGED
|
@@ -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
|
|