wolverine-ai 3.7.4 → 3.7.6

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.7.4",
3
+ "version": "3.7.6",
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": {
@@ -42,13 +42,14 @@ function getClient(provider) {
42
42
 
43
43
  function _getWolverineClient() {
44
44
  if (!_wolverineClient) {
45
- // Wolverine inference: direct to GPU or via proxy
46
- // WOLVERINE_GPU_KEY = internal key for direct GPU access (llama.cpp --api-key)
47
- // WOLVERINE_API_KEY = user key for billed proxy access (api.wolverinenode.xyz)
45
+ // Wolverine inference: always route through billing proxy when API key is set.
46
+ // WOLVERINE_API_KEY = billed API key (credits deducted per call)
47
+ // WOLVERINE_GPU_KEY = direct GPU access (no billing, admin/internal only)
48
+ // Priority: API_KEY (billed) > GPU_KEY (direct) — billing is the default path
49
+ const apiKey = process.env.WOLVERINE_API_KEY || process.env.WOLVERINE_GPU_KEY || "none";
48
50
  const baseURL = process.env.WOLVERINE_INFERENCE_URL
49
51
  ? process.env.WOLVERINE_INFERENCE_URL + "/v1"
50
52
  : "https://api.wolverinenode.xyz/v1";
51
- const apiKey = process.env.WOLVERINE_GPU_KEY || process.env.WOLVERINE_API_KEY || "none";
52
53
  _wolverineClient = new OpenAI({ apiKey, baseURL });
53
54
  }
54
55
  return _wolverineClient;
@@ -169,7 +170,20 @@ async function _withRetry(fn, maxRetries = 3) {
169
170
  try {
170
171
  return await fn();
171
172
  } catch (err) {
172
- const isRateLimit = err.status === 429 || err.code === "rate_limit_exceeded";
173
+ const msg = (err.message || "").toLowerCase();
174
+ const code = (err.code || "").toLowerCase();
175
+
176
+ // Permanent billing/quota errors — never retry, surface immediately
177
+ const isBillingError = err.status === 402
178
+ || /insufficient.*(quota|credits|funds)/i.test(msg)
179
+ || /billing_hard_limit|insufficient_quota|quota_exceeded/i.test(msg)
180
+ || /billing_hard_limit|insufficient_quota|quota_exceeded/i.test(code);
181
+ if (isBillingError) {
182
+ console.log(chalk.red(` 💳 Billing error (not retrying): ${err.message}`));
183
+ throw err;
184
+ }
185
+
186
+ const isRateLimit = err.status === 429 || code === "rate_limit_exceeded";
173
187
  const isServerError = err.status >= 500;
174
188
  if ((isRateLimit || isServerError) && attempt < maxRetries) {
175
189
  const delay = Math.min(1000 * Math.pow(2, attempt) + Math.random() * 1000, 30000);
@@ -29,11 +29,17 @@ const HUMAN_REQUIRED_PATTERNS = [
29
29
  { pattern: /(api|auth|token|key|credential).*(expired|revoked|rotated|invalid)/i, category: "auth", hint: "Credential has expired or been revoked" },
30
30
  { pattern: /authentication\s+failed/i, category: "auth", hint: "Authentication failed — check credentials" },
31
31
 
32
- // Billing/Quota
32
+ // Billing/Quota — covers OpenAI, Anthropic, Wolverine, and generic patterns
33
33
  { pattern: /429\s*(too many|rate limit)/i, category: "billing", hint: "Rate limit hit — may need to upgrade plan or wait" },
34
34
  { pattern: /(quota|limit|credits?)\s*(exceeded|exhausted|depleted)/i, category: "billing", hint: "Usage quota or credits exhausted" },
35
35
  { pattern: /billing.*(?:issue|error|failed|inactive)/i, category: "billing", hint: "Billing issue on the account" },
36
36
  { pattern: /insufficient.*(funds|credits|quota)/i, category: "billing", hint: "Insufficient credits or funds" },
37
+ { pattern: /billing_hard_limit_reached/i, category: "billing", hint: "OpenAI billing hard limit reached — add payment method or raise limit" },
38
+ { pattern: /insufficient_quota/i, category: "billing", hint: "API quota exhausted — check billing dashboard" },
39
+ { pattern: /rate_limit_exceeded/i, category: "billing", hint: "API rate limit exceeded — wait or upgrade plan" },
40
+ { pattern: /402\s*(payment|required)/i, category: "billing", hint: "Payment required — check billing status" },
41
+ { pattern: /exceeded.*(?:budget|spending|token)/i, category: "billing", hint: "Spending or token budget exceeded" },
42
+ { pattern: /overloaded_error/i, category: "billing", hint: "Anthropic API overloaded — retry later" },
37
43
 
38
44
  // External service failures
39
45
  { pattern: /ECONNREFUSED/i, category: "service", hint: "External service connection refused — is it running?" },