wolverine-ai 2.8.1 → 2.8.2

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": "2.8.1",
3
+ "version": "2.8.2",
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": {
@@ -1,8 +1,20 @@
1
1
  const crypto = require("crypto");
2
2
  const path = require("path");
3
3
 
4
- const INSTANCE_ID = process.env.WOLVERINE_INSTANCE_ID ||
5
- "wlv_" + crypto.createHash("sha256").update(process.cwd() + (process.env.PORT || "3000")).digest("hex").slice(0, 12);
4
+ // Stable instance ID — based on cwd ONLY (not port, which can change during restarts).
5
+ // Persisted to .wolverine/instance-id so it survives even if cwd hash changes.
6
+ const INSTANCE_ID = (() => {
7
+ if (process.env.WOLVERINE_INSTANCE_ID) return process.env.WOLVERINE_INSTANCE_ID;
8
+ const fs = require("fs");
9
+ const idPath = require("path").join(process.cwd(), ".wolverine", "instance-id");
10
+ try {
11
+ const saved = fs.readFileSync(idPath, "utf-8").trim();
12
+ if (saved) return saved;
13
+ } catch {}
14
+ const id = "wlv_" + crypto.createHash("sha256").update(process.cwd()).digest("hex").slice(0, 12);
15
+ try { fs.mkdirSync(require("path").dirname(idPath), { recursive: true }); fs.writeFileSync(idPath, id, "utf-8"); } catch {}
16
+ return id;
17
+ })();
6
18
 
7
19
  let _v = null;
8
20
 
@@ -47,10 +59,11 @@ function collectHeartbeat(subsystems) {
47
59
  totalCost: repairs?.totalCost || 0,
48
60
  },
49
61
 
62
+ // Usage: cumulative totals from disk (not session-only) so restarts don't reset
50
63
  usage: {
51
- totalTokens: usage?.session?.totalTokens || 0,
52
- totalCost: usage?.session?.totalCostUsd || 0,
53
- totalCalls: usage?.session?.totalCalls || 0,
64
+ totalTokens: tokenTracker?._totalTokens || usage?.session?.totalTokens || 0,
65
+ totalCost: tokenTracker?._totalCostUsd || usage?.session?.totalCostUsd || 0,
66
+ totalCalls: tokenTracker?._totalCalls || usage?.session?.totalCalls || 0,
54
67
  byCategory: usage?.byCategory || {},
55
68
  byModel: usage?.byModel || {},
56
69
  byTool: usage?.byTool || {},