wolverine-ai 4.0.2 → 4.0.3

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": "4.0.2",
3
+ "version": "4.0.3",
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": {
@@ -43,14 +43,21 @@ async function embed(text) {
43
43
 
44
44
  const model = getEmbeddingModel();
45
45
  const provider = detectProvider(model);
46
- // wolverine-embedding-1 routes through billing proxy, others go direct
47
46
  const client = provider === "wolverine" ? getClient("wolverine") : getClient("openai");
48
47
 
49
48
  const startMs = Date.now();
50
- const response = await client.embeddings.create({
51
- model,
52
- input: text,
53
- });
49
+ let response;
50
+ try {
51
+ response = await client.embeddings.create({ model, input: text });
52
+ } catch (err) {
53
+ // If wolverine proxy is down (startup, crash loop), fall back to OpenAI direct
54
+ if (provider === "wolverine" && /ECONNREFUSED|ECONNRESET|ETIMEDOUT|fetch failed/i.test(err.message || "")) {
55
+ const directClient = getClient("openai");
56
+ response = await directClient.embeddings.create({ model: "text-embedding-3-small", input: text });
57
+ } else {
58
+ throw err;
59
+ }
60
+ }
54
61
 
55
62
  const embedding = response.data[0].embedding;
56
63
  _trackEmbedding(model, response.usage, Date.now() - startMs, true);
@@ -87,10 +94,17 @@ async function embedBatch(texts) {
87
94
  const client = provider === "wolverine" ? getClient("wolverine") : getClient("openai");
88
95
 
89
96
  const startMs = Date.now();
90
- const response = await client.embeddings.create({
91
- model,
92
- input: uncached,
93
- });
97
+ let response;
98
+ try {
99
+ response = await client.embeddings.create({ model, input: uncached });
100
+ } catch (err) {
101
+ if (provider === "wolverine" && /ECONNREFUSED|ECONNRESET|ETIMEDOUT|fetch failed/i.test(err.message || "")) {
102
+ const directClient = getClient("openai");
103
+ response = await directClient.embeddings.create({ model: "text-embedding-3-small", input: uncached });
104
+ } else {
105
+ throw err;
106
+ }
107
+ }
94
108
  _trackEmbedding(model, response.usage, Date.now() - startMs, true);
95
109
 
96
110
  // Sort by index to maintain order