provider-kit 0.1.1 → 1.0.0

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/README.md CHANGED
@@ -141,4 +141,4 @@ const reply = await provider.chat('gpt-4', messages)
141
141
 
142
142
  ## Related
143
143
 
144
- - `@openchat/fairy-guardian` �?self-healing process cluster for AI model servers
144
+ - `fairy-guardian` �?self-healing process cluster for AI model servers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "provider-kit",
3
- "version": "0.1.1",
3
+ "version": "1.0.0",
4
4
  "description": "42 LLM provider unified API — one interface for OpenAI, Anthropic, Ollama, OpenRouter, and 38 more. Built-in retry, timeout, and error handling.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -47,7 +47,10 @@ export async function withRetry(fn, { retries = 2, baseDelay = 1000, provider }
47
47
  if (i === retries) throw e;
48
48
  const isRetryable = e instanceof ProviderError ? e.retryable : true;
49
49
  if (!isRetryable) throw e;
50
- await new Promise(r => setTimeout(r, baseDelay * Math.pow(2, i)));
50
+ // Exponential backoff with jitter (±25%) to prevent thundering herd
51
+ const delay = baseDelay * Math.pow(2, i);
52
+ const jitter = delay * (0.75 + Math.random() * 0.5);
53
+ await new Promise(r => setTimeout(r, jitter));
51
54
  }
52
55
  }
53
56
  }