wolverine-ai 3.4.0 → 3.4.1
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 +1 -1
- package/src/core/ai-client.js +5 -1
- package/src/core/wolverine.js +14 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wolverine-ai",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.1",
|
|
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": {
|
package/src/core/ai-client.js
CHANGED
|
@@ -8,6 +8,10 @@ let _anthropicClient = null;
|
|
|
8
8
|
let _tracker = null;
|
|
9
9
|
|
|
10
10
|
function setTokenTracker(tracker) { _tracker = tracker; }
|
|
11
|
+
function getTrackerSnapshot() {
|
|
12
|
+
if (!_tracker) return { tokens: 0, cost: 0, calls: 0 };
|
|
13
|
+
return { tokens: _tracker._totalTokens || 0, cost: _tracker._totalCostUsd || 0, calls: _tracker._totalCalls || 0 };
|
|
14
|
+
}
|
|
11
15
|
|
|
12
16
|
function _extractTokens(usage) {
|
|
13
17
|
if (!usage) return { input: 0, output: 0, cacheCreation: 0, cacheRead: 0 };
|
|
@@ -580,4 +584,4 @@ Include both if needed, or just one.`;
|
|
|
580
584
|
}
|
|
581
585
|
}
|
|
582
586
|
|
|
583
|
-
module.exports = { requestRepair, getClient, tokenParam, aiCall, aiCallWithHistory, isResponsesModel, isAnthropicModel, setTokenTracker, detectProvider };
|
|
587
|
+
module.exports = { requestRepair, getClient, tokenParam, aiCall, aiCallWithHistory, isResponsesModel, isAnthropicModel, setTokenTracker, getTrackerSnapshot, detectProvider };
|
package/src/core/wolverine.js
CHANGED
|
@@ -43,6 +43,9 @@ async function heal(opts) {
|
|
|
43
43
|
|
|
44
44
|
async function _healImpl({ stderr, cwd, sandbox, notifier, rateLimiter, backupManager, logger, brain, mcp, skills, repairHistory, routeContext }) {
|
|
45
45
|
const healStartTime = Date.now();
|
|
46
|
+
// Snapshot token tracker at heal start — diff at end = FULL pipeline cost
|
|
47
|
+
const { getTrackerSnapshot } = require("./ai-client");
|
|
48
|
+
const _snapshot = getTrackerSnapshot();
|
|
46
49
|
const { redact, hasSecrets } = require("../security/secret-redactor");
|
|
47
50
|
|
|
48
51
|
// Guard: don't burn tokens on empty stderr (signal kills, clean shutdowns, etc.)
|
|
@@ -155,11 +158,15 @@ async function _healImpl({ stderr, cwd, sandbox, notifier, rateLimiter, backupMa
|
|
|
155
158
|
if (opsFix.fixed) {
|
|
156
159
|
console.log(chalk.green(` ⚡ Operational fix applied: ${opsFix.action}`));
|
|
157
160
|
if (logger) logger.info(EVENT_TYPES.HEAL_SUCCESS, `Operational fix: ${opsFix.action}`, { action: opsFix.action });
|
|
161
|
+
// Record with FULL pipeline cost (includes injection scan, brain lookup, etc.)
|
|
162
|
+
const _endSnap = getTrackerSnapshot();
|
|
163
|
+
const pipelineTokens = _endSnap.tokens - _snapshot.tokens;
|
|
164
|
+
const pipelineCost = _endSnap.cost - _snapshot.cost;
|
|
158
165
|
if (repairHistory) {
|
|
159
166
|
repairHistory.record({
|
|
160
167
|
error: parsed.errorMessage, file: parsed.filePath, line: parsed.line,
|
|
161
168
|
resolution: opsFix.action, success: true, mode: "operational",
|
|
162
|
-
model: "
|
|
169
|
+
model: getModel("audit"), tokens: pipelineTokens, cost: pipelineCost, iteration: 0,
|
|
163
170
|
duration: Date.now() - healStartTime, filesModified: [],
|
|
164
171
|
});
|
|
165
172
|
}
|
|
@@ -396,13 +403,13 @@ async function _healImpl({ stderr, cwd, sandbox, notifier, rateLimiter, backupMa
|
|
|
396
403
|
|
|
397
404
|
backupManager.prune();
|
|
398
405
|
|
|
399
|
-
// Record to repair history
|
|
406
|
+
// Record to repair history — use FULL pipeline cost (injection scan + brain + fix)
|
|
400
407
|
if (repairHistory) {
|
|
401
408
|
const duration = Date.now() - healStartTime;
|
|
402
|
-
const
|
|
403
|
-
const
|
|
409
|
+
const _endSnap = getTrackerSnapshot();
|
|
410
|
+
const pipelineTokens = _endSnap.tokens - _snapshot.tokens;
|
|
411
|
+
const pipelineCost = _endSnap.cost - _snapshot.cost;
|
|
404
412
|
const model = goalResult.mode === "fast" ? getModel("coding") : getModel("reasoning");
|
|
405
|
-
const cost = calculateCost(model, tokenUsage * 0.7, tokenUsage * 0.3); // estimate in/out split
|
|
406
413
|
|
|
407
414
|
repairHistory.record({
|
|
408
415
|
error: parsed.errorMessage,
|
|
@@ -412,8 +419,8 @@ async function _healImpl({ stderr, cwd, sandbox, notifier, rateLimiter, backupMa
|
|
|
412
419
|
success: goalResult.success,
|
|
413
420
|
mode: goalResult.mode || "unknown",
|
|
414
421
|
model,
|
|
415
|
-
tokens:
|
|
416
|
-
cost:
|
|
422
|
+
tokens: pipelineTokens,
|
|
423
|
+
cost: pipelineCost,
|
|
417
424
|
iteration: goalResult.iteration,
|
|
418
425
|
duration,
|
|
419
426
|
filesModified: goalResult.agentStats?.filesModified || [],
|