@broberg/ai-sdk 0.36.5 → 0.36.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/dist/index.d.ts CHANGED
@@ -17,7 +17,7 @@ export { AvailabilitySource, AvailabilityStatus, ModelStatus, ModelUnavailableEr
17
17
  type Region = "eu" | "us" | "cn" | "unknown";
18
18
  /** Region of the endpoint a call will actually hit. Never throws — a residency
19
19
  * reading must not be able to break a call that already succeeded. */
20
- declare function regionOfHost(url: string | undefined): Region;
20
+ declare function regionOfHost(hostOrUrl: string | undefined): Region;
21
21
  /** Classify a provider REGION STRING — a Vertex/GCP location like `europe-west1`, or
22
22
  * an Azure region like `westeurope`. Anything unrecognised is `"unknown"`: a region
23
23
  * name we have never seen is exactly the case where guessing is most tempting and
@@ -2200,8 +2200,8 @@ declare const falStubAdapter: ProviderAdapter;
2200
2200
  * wires the live adapters. */
2201
2201
  declare const stubProviders: Record<string, ProviderAdapter>;
2202
2202
 
2203
- declare const VERSION: "0.36.5";
2204
- declare const SDK_TAG: "@broberg/ai-sdk@0.36.5";
2203
+ declare const VERSION: "0.36.6";
2204
+ declare const SDK_TAG: "@broberg/ai-sdk@0.36.6";
2205
2205
 
2206
2206
  /** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
2207
2207
  * per-call override.
package/dist/index.js CHANGED
@@ -241,14 +241,20 @@ var HOST_REGION = {
241
241
  "openrouter.ai": "unknown",
242
242
  "router.requesty.ai": "unknown"
243
243
  };
244
- function regionOfHost(url) {
245
- if (!url) return "unknown";
244
+ function regionOfHost(hostOrUrl) {
245
+ if (!hostOrUrl) return "unknown";
246
+ const trimmed = hostOrUrl.trim();
247
+ if (!trimmed) return "unknown";
248
+ let host = "";
246
249
  try {
247
- const host = new URL(url).host.toLowerCase();
248
- return Object.hasOwn(HOST_REGION, host) ? HOST_REGION[host] : "unknown";
250
+ host = new URL(trimmed).host;
249
251
  } catch {
250
- return "unknown";
251
252
  }
253
+ if (!host) {
254
+ host = trimmed.split("/")[0].split("@").pop().split(":")[0];
255
+ }
256
+ host = host.toLowerCase();
257
+ return Object.hasOwn(HOST_REGION, host) ? HOST_REGION[host] : "unknown";
252
258
  }
253
259
  var FIXED_PROVIDER_REGION = {
254
260
  // NB: mistral and deepl are deliberately ABSENT — both take a config.baseUrl, so
@@ -303,6 +309,7 @@ function classifyRegionName(name) {
303
309
  if (!name) return "unknown";
304
310
  const n = name.trim().toLowerCase();
305
311
  if (!n) return "unknown";
312
+ if (n === "eu" || n === "us" || n === "cn" || n === "unknown") return n;
306
313
  if (n.startsWith("europe-")) return "eu";
307
314
  if (n.startsWith("us-")) return "us";
308
315
  if (EU_REGION_NAMES.has(n)) return "eu";
@@ -2986,8 +2993,8 @@ var aiConfigSchema = z.object({
2986
2993
  });
2987
2994
 
2988
2995
  // src/version.ts
2989
- var VERSION = "0.36.5";
2990
- var SDK_TAG = "@broberg/ai-sdk@0.36.5";
2996
+ var VERSION = "0.36.6";
2997
+ var SDK_TAG = "@broberg/ai-sdk@0.36.6";
2991
2998
 
2992
2999
  // src/cost/sinks/upmetrics.ts
2993
3000
  function upmetricsSink(config) {