You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 23, 2025. It is now read-only.
// Default fallback model when the primary model fails or is unavailable
43
45
constFALLBACK_MODEL="openrouter/auto";
@@ -252,13 +254,13 @@ export function callAi(
252
254
}
253
255
254
256
// Create error with standard format
255
-
consterror=newError(errorMessage);
256
-
257
-
// Add useful metadata
258
-
(errorasany).status=response.status;
259
-
(errorasany).statusText=response.statusText;
260
-
(errorasany).details=errorJson;
261
-
(errorasany).contentType=contentType;
257
+
consterror=newCallAIError({
258
+
message: errorMessage,
259
+
status: response.status,
260
+
statusText: response.statusText,
261
+
details: errorJson,
262
+
contentType,
263
+
})
262
264
throwerror;
263
265
}catch(jsonError){
264
266
// If JSON parsing fails, extract a useful message from the raw error body
@@ -295,11 +297,13 @@ export function callAi(
295
297
);
296
298
}
297
299
298
-
consterror=newError(errorMessage);
299
-
(errorasany).status=response.status;
300
-
(errorasany).statusText=response.statusText;
301
-
(errorasany).details=errorBody;
302
-
(errorasany).contentType=contentType;
300
+
consterror=newCallAIError({
301
+
message: errorMessage,
302
+
status: response.status,
303
+
statusText: response.statusText,
304
+
details: errorBody,
305
+
contentType,
306
+
})
303
307
throwerror;
304
308
}
305
309
}catch(responseError){
@@ -309,12 +313,14 @@ export function callAi(
309
313
}
310
314
311
315
// Fallback error
312
-
consterror=newError(
313
-
`API returned ${response.status}: ${response.statusText}`,
314
-
);
315
-
(errorasany).status=response.status;
316
-
(errorasany).statusText=response.statusText;
317
-
(errorasany).contentType=contentType;
316
+
consterror=newCallAIError(
317
+
{
318
+
message: `API returned ${response.status}: ${response.statusText}`,
319
+
status: response.status,
320
+
statusText: response.statusText,
321
+
details: undefined,
322
+
contentType,
323
+
})
318
324
throwerror;
319
325
}
320
326
}
@@ -328,7 +334,7 @@ export function callAi(
328
334
})();
329
335
330
336
// For backward compatibility with v0.6.x where users didn't await the result
331
-
if(process.env.NODE_ENV!=="production"){
337
+
if(callAiEnv.NODE_ENV!=="production"){
332
338
if(options.debug){
333
339
console.warn(
334
340
`[callAi:${PACKAGE_VERSION}] No await found - using legacy streaming pattern. This will be removed in a future version and may cause issues with certain models.`,
@@ -337,7 +343,7 @@ export function callAi(
337
343
}
338
344
339
345
// Create a proxy object that acts both as a Promise and an AsyncGenerator for backward compatibility
340
-
// @ts-ignore - We're deliberately implementing a proxy with dual behavior
346
+
//...@ts-ignore - We're deliberately implementing a proxy with dual behavior
0 commit comments