omnigateway 0.4.4 → 0.4.5

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.
Files changed (2) hide show
  1. package/gateway.js +15 -2
  2. package/package.json +1 -1
package/gateway.js CHANGED
@@ -46261,6 +46261,11 @@ var NETWORK_HINTS = [
46261
46261
  "socket hang up",
46262
46262
  "unable to connect"
46263
46263
  ];
46264
+ function describeError(error51) {
46265
+ if (!(error51 instanceof Error))
46266
+ return "attempt failed";
46267
+ return error51.message.length > 0 ? error51.message : error51.name;
46268
+ }
46264
46269
  function classify(error51) {
46265
46270
  if (error51 instanceof GatewayError) {
46266
46271
  return {
@@ -46272,6 +46277,14 @@ function classify(error51) {
46272
46277
  if (error51 instanceof DOMException && error51.name === "AbortError") {
46273
46278
  return { code: "TIMEOUT" };
46274
46279
  }
46280
+ if (error51 instanceof AggregateError && Array.isArray(error51.errors)) {
46281
+ for (const inner of error51.errors) {
46282
+ const classified = classify(inner);
46283
+ if (classified.code !== "INTERNAL")
46284
+ return classified;
46285
+ }
46286
+ return { code: "INTERNAL" };
46287
+ }
46275
46288
  if (error51 instanceof Error) {
46276
46289
  const text = `${error51.name} ${error51.message}`.toLowerCase();
46277
46290
  if (NETWORK_HINTS.some((hint) => text.includes(hint)))
@@ -46580,7 +46593,7 @@ async function dispatch(request2, deps, signal, requestId) {
46580
46593
  throw signal.reason;
46581
46594
  const classifiedError = deadlineAt !== null && dispatchSignal.aborted ? { code: "TIMEOUT" } : classify(error51);
46582
46595
  const { code: code2 } = classifiedError;
46583
- const message2 = error51 instanceof Error ? error51.message : "attempt failed";
46596
+ const message2 = describeError(error51);
46584
46597
  lastError = rewrap(classifiedError, message2);
46585
46598
  if (code2 === "AUTH" && !committed && !authRefreshRetried && !preemptiveRefreshRequired && candidate.credential.authType === "oauth" && candidate.credential.hasRefreshToken) {
46586
46599
  authRefreshRetried = true;
@@ -46599,7 +46612,7 @@ async function dispatch(request2, deps, signal, requestId) {
46599
46612
  if (signal.aborted)
46600
46613
  throw signal.reason;
46601
46614
  const classified = deadlineAt !== null && dispatchSignal.aborted ? { code: "TIMEOUT" } : classify(refreshError);
46602
- const refreshMessage = refreshError instanceof Error ? refreshError.message : "credential refresh failed";
46615
+ const refreshMessage = refreshError instanceof Error ? describeError(refreshError) : "credential refresh failed";
46603
46616
  lastError = rewrap(classified, refreshMessage);
46604
46617
  logger2.warn("credential refresh failed", {
46605
46618
  requestId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnigateway",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "Self-hosted AI gateway with Anthropic- and OpenAI-compatible APIs, an admin console, and a CLI",
5
5
  "license": "MIT",
6
6
  "author": "Harismawan <mail@harismawan.com>",