@mastra/fastembed 1.0.0 → 1.0.1

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 (62) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE.md +15 -0
  3. package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +2103 -269
  4. package/dist/{chunk-SG3GRV3O.cjs → chunk-23EXJLET.cjs} +3 -3
  5. package/dist/chunk-23EXJLET.cjs.map +1 -0
  6. package/dist/{chunk-KMQS2YEC.js → chunk-BSDWQEU3.js} +3 -3
  7. package/dist/chunk-BSDWQEU3.js.map +1 -0
  8. package/dist/chunk-EQ4M72KU.js +439 -0
  9. package/dist/chunk-EQ4M72KU.js.map +1 -0
  10. package/dist/{chunk-WC4XBMZT.js → chunk-HJYHDIOC.js} +5 -5
  11. package/dist/chunk-HJYHDIOC.js.map +1 -0
  12. package/dist/{chunk-ZUQPUTTO.cjs → chunk-IDRQZVB4.cjs} +4 -4
  13. package/dist/chunk-IDRQZVB4.cjs.map +1 -0
  14. package/dist/{chunk-YMNW6DEN.cjs → chunk-LIBOSOHM.cjs} +14 -14
  15. package/dist/chunk-LIBOSOHM.cjs.map +1 -0
  16. package/dist/{chunk-MMUHFOCG.js → chunk-RC6RZVYE.js} +4 -4
  17. package/dist/chunk-RC6RZVYE.js.map +1 -0
  18. package/dist/chunk-ZD3BKU5O.cjs +441 -0
  19. package/dist/chunk-ZD3BKU5O.cjs.map +1 -0
  20. package/dist/index.cjs +1153 -465
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.ts +7 -2
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +1142 -455
  25. package/dist/index.js.map +1 -1
  26. package/dist/{token-6GSAFR2W-VLY2XUPA.js → token-6GSAFR2W-ABXTQD64.js} +5 -5
  27. package/dist/token-6GSAFR2W-ABXTQD64.js.map +1 -0
  28. package/dist/{token-6GSAFR2W-YCB5SK2Z.cjs → token-6GSAFR2W-TW2P7HCS.cjs} +8 -8
  29. package/dist/token-6GSAFR2W-TW2P7HCS.cjs.map +1 -0
  30. package/dist/{token-6GSAFR2W-K2BTU23I.js → token-APYSY3BW-2DN6RAUY.js} +11 -11
  31. package/dist/token-APYSY3BW-2DN6RAUY.js.map +1 -0
  32. package/dist/{token-6GSAFR2W-JV3TZR4M.cjs → token-APYSY3BW-ZQ7TMBY7.cjs} +14 -14
  33. package/dist/token-APYSY3BW-ZQ7TMBY7.cjs.map +1 -0
  34. package/dist/token-util-NEHG7TUY-GYFEVMWP.cjs +10 -0
  35. package/dist/{token-util-NEHG7TUY-7IL6JUVY.cjs.map → token-util-NEHG7TUY-GYFEVMWP.cjs.map} +1 -1
  36. package/dist/token-util-NEHG7TUY-XQP3QSPX.js +8 -0
  37. package/dist/{token-util-NEHG7TUY-TIJ3LMSH.js.map → token-util-NEHG7TUY-XQP3QSPX.js.map} +1 -1
  38. package/dist/token-util-RMHT2CPJ-6TGPE335.cjs +10 -0
  39. package/dist/token-util-RMHT2CPJ-6TGPE335.cjs.map +1 -0
  40. package/dist/token-util-RMHT2CPJ-RJEA3FAN.js +8 -0
  41. package/dist/token-util-RMHT2CPJ-RJEA3FAN.js.map +1 -0
  42. package/package.json +12 -12
  43. package/dist/chunk-KMQS2YEC.js.map +0 -1
  44. package/dist/chunk-MMUHFOCG.js.map +0 -1
  45. package/dist/chunk-QY6BZOPJ.js +0 -250
  46. package/dist/chunk-QY6BZOPJ.js.map +0 -1
  47. package/dist/chunk-SG3GRV3O.cjs.map +0 -1
  48. package/dist/chunk-W72AYUIF.cjs +0 -252
  49. package/dist/chunk-W72AYUIF.cjs.map +0 -1
  50. package/dist/chunk-WC4XBMZT.js.map +0 -1
  51. package/dist/chunk-YMNW6DEN.cjs.map +0 -1
  52. package/dist/chunk-ZUQPUTTO.cjs.map +0 -1
  53. package/dist/token-6GSAFR2W-JV3TZR4M.cjs.map +0 -1
  54. package/dist/token-6GSAFR2W-K2BTU23I.js.map +0 -1
  55. package/dist/token-6GSAFR2W-VLY2XUPA.js.map +0 -1
  56. package/dist/token-6GSAFR2W-YCB5SK2Z.cjs.map +0 -1
  57. package/dist/token-util-NEHG7TUY-7IL6JUVY.cjs +0 -10
  58. package/dist/token-util-NEHG7TUY-HF7KBP2H.cjs +0 -10
  59. package/dist/token-util-NEHG7TUY-HF7KBP2H.cjs.map +0 -1
  60. package/dist/token-util-NEHG7TUY-KSXDO2NO.js +0 -8
  61. package/dist/token-util-NEHG7TUY-KSXDO2NO.js.map +0 -1
  62. package/dist/token-util-NEHG7TUY-TIJ3LMSH.js +0 -8
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import { __commonJS, require_token_error, __toESM } from './chunk-KMQS2YEC.js';
2
- import { __commonJS as __commonJS$1, require_token_error as require_token_error$1, __toESM as __toESM$1 } from './chunk-MMUHFOCG.js';
1
+ import { __commonJS, require_token_error, __toESM } from './chunk-BSDWQEU3.js';
2
+ import { __commonJS as __commonJS$1, require_token_error as require_token_error$1, __toESM as __toESM$1 } from './chunk-RC6RZVYE.js';
3
3
  import fsp from 'fs/promises';
4
4
  import os from 'os';
5
5
  import path from 'path';
6
6
  import * as z4 from 'zod/v4';
7
7
  import { z } from 'zod/v4';
8
8
  import { ZodFirstPartyTypeKind } from 'zod/v3';
9
- import { z as z$1, ZodFirstPartyTypeKind as ZodFirstPartyTypeKind$1 } from 'zod';
9
+ import { z as z$1 } from 'zod';
10
10
  import { FlagEmbedding, EmbeddingModel } from 'fastembed';
11
11
 
12
12
  var marker = "vercel.ai.error";
@@ -22,13 +22,13 @@ var _AISDKError = class _AISDKError2 extends Error {
22
22
  * @param {unknown} [params.cause] - The underlying cause of the error.
23
23
  */
24
24
  constructor({
25
- name: name145,
25
+ name: name146,
26
26
  message,
27
27
  cause
28
28
  }) {
29
29
  super(message);
30
30
  this[_a] = true;
31
- this.name = name145;
31
+ this.name = name146;
32
32
  this.cause = cause;
33
33
  }
34
34
  /**
@@ -39,8 +39,8 @@ var _AISDKError = class _AISDKError2 extends Error {
39
39
  static isInstance(error) {
40
40
  return _AISDKError2.hasMarker(error, marker);
41
41
  }
42
- static hasMarker(error, marker155) {
43
- const markerSymbol = Symbol.for(marker155);
42
+ static hasMarker(error, marker156) {
43
+ const markerSymbol = Symbol.for(marker156);
44
44
  return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
45
45
  }
46
46
  };
@@ -395,11 +395,11 @@ function handleFetchError({
395
395
  return error;
396
396
  }
397
397
  function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
398
- var _a155, _b17, _c;
398
+ var _a156, _b17, _c;
399
399
  if (globalThisAny.window) {
400
400
  return `runtime/browser`;
401
401
  }
402
- if ((_a155 = globalThisAny.navigator) == null ? void 0 : _a155.userAgent) {
402
+ if ((_a156 = globalThisAny.navigator) == null ? void 0 : _a156.userAgent) {
403
403
  return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
404
404
  }
405
405
  if ((_c = (_b17 = globalThisAny.process) == null ? void 0 : _b17.versions) == null ? void 0 : _c.node) {
@@ -921,11 +921,11 @@ function parseAnyDef() {
921
921
  return {};
922
922
  }
923
923
  function parseArrayDef(def, refs) {
924
- var _a155, _b17, _c;
924
+ var _a156, _b17, _c;
925
925
  const res = {
926
926
  type: "array"
927
927
  };
928
- if (((_a155 = def.type) == null ? void 0 : _a155._def) && ((_c = (_b17 = def.type) == null ? void 0 : _b17._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
928
+ if (((_a156 = def.type) == null ? void 0 : _a156._def) && ((_c = (_b17 = def.type) == null ? void 0 : _b17._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
929
929
  res.items = parseDef(def.type._def, {
930
930
  ...refs,
931
931
  currentPath: [...refs.currentPath, "items"]
@@ -1284,8 +1284,8 @@ function escapeNonAlphaNumeric(source) {
1284
1284
  return result;
1285
1285
  }
1286
1286
  function addFormat(schema, value, message, refs) {
1287
- var _a155;
1288
- if (schema.format || ((_a155 = schema.anyOf) == null ? void 0 : _a155.some((x) => x.format))) {
1287
+ var _a156;
1288
+ if (schema.format || ((_a156 = schema.anyOf) == null ? void 0 : _a156.some((x) => x.format))) {
1289
1289
  if (!schema.anyOf) {
1290
1290
  schema.anyOf = [];
1291
1291
  }
@@ -1304,8 +1304,8 @@ function addFormat(schema, value, message, refs) {
1304
1304
  }
1305
1305
  }
1306
1306
  function addPattern(schema, regex, message, refs) {
1307
- var _a155;
1308
- if (schema.pattern || ((_a155 = schema.allOf) == null ? void 0 : _a155.some((x) => x.pattern))) {
1307
+ var _a156;
1308
+ if (schema.pattern || ((_a156 = schema.allOf) == null ? void 0 : _a156.some((x) => x.pattern))) {
1309
1309
  if (!schema.allOf) {
1310
1310
  schema.allOf = [];
1311
1311
  }
@@ -1324,7 +1324,7 @@ function addPattern(schema, regex, message, refs) {
1324
1324
  }
1325
1325
  }
1326
1326
  function stringifyRegExpWithFlags(regex, refs) {
1327
- var _a155;
1327
+ var _a156;
1328
1328
  if (!refs.applyRegexFlags || !regex.flags) {
1329
1329
  return regex.source;
1330
1330
  }
@@ -1354,7 +1354,7 @@ function stringifyRegExpWithFlags(regex, refs) {
1354
1354
  pattern += source[i];
1355
1355
  pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
1356
1356
  inCharRange = false;
1357
- } else if (source[i + 1] === "-" && ((_a155 = source[i + 2]) == null ? void 0 : _a155.match(/[a-z]/))) {
1357
+ } else if (source[i + 1] === "-" && ((_a156 = source[i + 2]) == null ? void 0 : _a156.match(/[a-z]/))) {
1358
1358
  pattern += source[i];
1359
1359
  inCharRange = true;
1360
1360
  } else {
@@ -1396,13 +1396,13 @@ function stringifyRegExpWithFlags(regex, refs) {
1396
1396
  return pattern;
1397
1397
  }
1398
1398
  function parseRecordDef(def, refs) {
1399
- var _a155, _b17, _c, _d, _e, _f;
1399
+ var _a156, _b17, _c, _d, _e, _f;
1400
1400
  const schema = {
1401
1401
  type: "object",
1402
- additionalProperties: (_a155 = parseDef(def.valueType._def, {
1402
+ additionalProperties: (_a156 = parseDef(def.valueType._def, {
1403
1403
  ...refs,
1404
1404
  currentPath: [...refs.currentPath, "additionalProperties"]
1405
- })) != null ? _a155 : refs.allowedAdditionalProperties
1405
+ })) != null ? _a156 : refs.allowedAdditionalProperties
1406
1406
  };
1407
1407
  if (((_b17 = def.keyType) == null ? void 0 : _b17._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
1408
1408
  const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
@@ -1659,8 +1659,8 @@ function safeIsOptional(schema) {
1659
1659
  }
1660
1660
  }
1661
1661
  var parseOptionalDef = (def, refs) => {
1662
- var _a155;
1663
- if (refs.currentPath.toString() === ((_a155 = refs.propertyPath) == null ? void 0 : _a155.toString())) {
1662
+ var _a156;
1663
+ if (refs.currentPath.toString() === ((_a156 = refs.propertyPath) == null ? void 0 : _a156.toString())) {
1664
1664
  return parseDef(def.innerType._def, refs);
1665
1665
  }
1666
1666
  const innerSchema = parseDef(def.innerType._def, {
@@ -1830,10 +1830,10 @@ var selectParser = (def, typeName, refs) => {
1830
1830
  }
1831
1831
  };
1832
1832
  function parseDef(def, refs, forceResolution = false) {
1833
- var _a155;
1833
+ var _a156;
1834
1834
  const seenItem = refs.seen.get(def);
1835
1835
  if (refs.override) {
1836
- const overrideResult = (_a155 = refs.override) == null ? void 0 : _a155.call(
1836
+ const overrideResult = (_a156 = refs.override) == null ? void 0 : _a156.call(
1837
1837
  refs,
1838
1838
  def,
1839
1839
  refs,
@@ -1899,11 +1899,11 @@ var getRefs = (options) => {
1899
1899
  currentPath,
1900
1900
  propertyPath: void 0,
1901
1901
  seen: new Map(
1902
- Object.entries(_options.definitions).map(([name145, def]) => [
1902
+ Object.entries(_options.definitions).map(([name146, def]) => [
1903
1903
  def._def,
1904
1904
  {
1905
1905
  def: def._def,
1906
- path: [..._options.basePath, _options.definitionPath, name145],
1906
+ path: [..._options.basePath, _options.definitionPath, name146],
1907
1907
  // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
1908
1908
  jsonSchema: void 0
1909
1909
  }
@@ -1912,7 +1912,7 @@ var getRefs = (options) => {
1912
1912
  };
1913
1913
  };
1914
1914
  var zodToJsonSchema = (schema, options) => {
1915
- var _a155;
1915
+ var _a156;
1916
1916
  const refs = getRefs(options);
1917
1917
  let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
1918
1918
  (acc, [name224, schema2]) => {
@@ -1931,31 +1931,31 @@ var zodToJsonSchema = (schema, options) => {
1931
1931
  },
1932
1932
  {}
1933
1933
  ) : void 0;
1934
- const name145 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
1935
- const main = (_a155 = parseDef(
1934
+ const name146 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
1935
+ const main = (_a156 = parseDef(
1936
1936
  schema._def,
1937
- name145 === void 0 ? refs : {
1937
+ name146 === void 0 ? refs : {
1938
1938
  ...refs,
1939
- currentPath: [...refs.basePath, refs.definitionPath, name145]
1939
+ currentPath: [...refs.basePath, refs.definitionPath, name146]
1940
1940
  },
1941
1941
  false
1942
- )) != null ? _a155 : parseAnyDef();
1942
+ )) != null ? _a156 : parseAnyDef();
1943
1943
  const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
1944
1944
  if (title !== void 0) {
1945
1945
  main.title = title;
1946
1946
  }
1947
- const combined = name145 === void 0 ? definitions ? {
1947
+ const combined = name146 === void 0 ? definitions ? {
1948
1948
  ...main,
1949
1949
  [refs.definitionPath]: definitions
1950
1950
  } : main : {
1951
1951
  $ref: [
1952
1952
  ...refs.$refStrategy === "relative" ? [] : refs.basePath,
1953
1953
  refs.definitionPath,
1954
- name145
1954
+ name146
1955
1955
  ].join("/"),
1956
1956
  [refs.definitionPath]: {
1957
1957
  ...definitions,
1958
- [name145]: main
1958
+ [name146]: main
1959
1959
  }
1960
1960
  };
1961
1961
  combined.$schema = "http://json-schema.org/draft-07/schema#";
@@ -1963,8 +1963,8 @@ var zodToJsonSchema = (schema, options) => {
1963
1963
  };
1964
1964
  var zod_to_json_schema_default = zodToJsonSchema;
1965
1965
  function zod3Schema(zodSchema22, options) {
1966
- var _a155;
1967
- const useReferences = (_a155 = void 0 ) != null ? _a155 : false;
1966
+ var _a156;
1967
+ const useReferences = (_a156 = void 0 ) != null ? _a156 : false;
1968
1968
  return jsonSchema(
1969
1969
  // defer json schema creation to avoid unnecessary computation when only validation is needed
1970
1970
  () => zod_to_json_schema_default(zodSchema22, {
@@ -1979,8 +1979,8 @@ function zod3Schema(zodSchema22, options) {
1979
1979
  );
1980
1980
  }
1981
1981
  function zod4Schema(zodSchema22, options) {
1982
- var _a155;
1983
- const useReferences = (_a155 = void 0 ) != null ? _a155 : false;
1982
+ var _a156;
1983
+ const useReferences = (_a156 = void 0 ) != null ? _a156 : false;
1984
1984
  return jsonSchema(
1985
1985
  // defer json schema creation to avoid unnecessary computation when only validation is needed
1986
1986
  () => z4.toJSONSchema(zodSchema22, {
@@ -2037,14 +2037,14 @@ function withoutTrailingSlash(url) {
2037
2037
  return url == null ? void 0 : url.replace(/\/$/, "");
2038
2038
  }
2039
2039
  var require_get_context = __commonJS({
2040
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-context.js"(exports, module) {
2040
+ "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-context.js"(exports$1, module) {
2041
2041
  var __defProp22 = Object.defineProperty;
2042
2042
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
2043
2043
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
2044
2044
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
2045
2045
  var __export22 = (target, all) => {
2046
- for (var name163 in all)
2047
- __defProp22(target, name163, { get: all[name163], enumerable: true });
2046
+ for (var name164 in all)
2047
+ __defProp22(target, name164, { get: all[name164], enumerable: true });
2048
2048
  };
2049
2049
  var __copyProps2 = (to, from, except, desc) => {
2050
2050
  if (from && typeof from === "object" || typeof from === "function") {
@@ -2069,14 +2069,14 @@ var require_get_context = __commonJS({
2069
2069
  }
2070
2070
  });
2071
2071
  var require_get_vercel_oidc_token = __commonJS({
2072
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports, module) {
2072
+ "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports$1, module) {
2073
2073
  var __defProp22 = Object.defineProperty;
2074
2074
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
2075
2075
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
2076
2076
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
2077
2077
  var __export22 = (target, all) => {
2078
- for (var name163 in all)
2079
- __defProp22(target, name163, { get: all[name163], enumerable: true });
2078
+ for (var name164 in all)
2079
+ __defProp22(target, name164, { get: all[name164], enumerable: true });
2080
2080
  };
2081
2081
  var __copyProps2 = (to, from, except, desc) => {
2082
2082
  if (from && typeof from === "object" || typeof from === "function") {
@@ -2105,8 +2105,8 @@ var require_get_vercel_oidc_token = __commonJS({
2105
2105
  }
2106
2106
  try {
2107
2107
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
2108
- await import('./token-util-NEHG7TUY-TIJ3LMSH.js'),
2109
- await import('./token-6GSAFR2W-VLY2XUPA.js')
2108
+ await import('./token-util-NEHG7TUY-XQP3QSPX.js'),
2109
+ await import('./token-6GSAFR2W-ABXTQD64.js')
2110
2110
  ]);
2111
2111
  if (!token || isExpired(getTokenPayload(token))) {
2112
2112
  await refreshToken();
@@ -2133,14 +2133,14 @@ ${error.message}`;
2133
2133
  }
2134
2134
  });
2135
2135
  var require_dist = __commonJS({
2136
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/index.js"(exports, module) {
2136
+ "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/index.js"(exports$1, module) {
2137
2137
  var __defProp22 = Object.defineProperty;
2138
2138
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
2139
2139
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
2140
2140
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
2141
2141
  var __export22 = (target, all) => {
2142
- for (var name163 in all)
2143
- __defProp22(target, name163, { get: all[name163], enumerable: true });
2142
+ for (var name164 in all)
2143
+ __defProp22(target, name164, { get: all[name164], enumerable: true });
2144
2144
  };
2145
2145
  var __copyProps2 = (to, from, except, desc) => {
2146
2146
  if (from && typeof from === "object" || typeof from === "function") {
@@ -2879,12 +2879,12 @@ async function getVercelRequestId() {
2879
2879
  var VERSION2 = "2.0.15";
2880
2880
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
2881
2881
  function createGatewayProvider(options = {}) {
2882
- var _a832, _b83;
2882
+ var _a832, _b84;
2883
2883
  let pendingMetadata = null;
2884
2884
  let metadataCache = null;
2885
2885
  const cacheRefreshMillis = (_a832 = options.metadataCacheRefreshMillis) != null ? _a832 : 1e3 * 60 * 5;
2886
2886
  let lastFetchTime = 0;
2887
- const baseURL = (_b83 = withoutTrailingSlash(options.baseURL)) != null ? _b83 : "https://ai-gateway.vercel.sh/v1/ai";
2887
+ const baseURL = (_b84 = withoutTrailingSlash(options.baseURL)) != null ? _b84 : "https://ai-gateway.vercel.sh/v1/ai";
2888
2888
  const getHeaders = async () => {
2889
2889
  const auth = await getGatewayAuthToken(options);
2890
2890
  if (auth) {
@@ -2937,8 +2937,8 @@ function createGatewayProvider(options = {}) {
2937
2937
  });
2938
2938
  };
2939
2939
  const getAvailableModels = async () => {
2940
- var _a922, _b92, _c;
2941
- const now2 = (_c = (_b92 = (_a922 = options._internal) == null ? void 0 : _a922.currentDate) == null ? void 0 : _b92.call(_a922).getTime()) != null ? _c : Date.now();
2940
+ var _a923, _b92, _c;
2941
+ const now2 = (_c = (_b92 = (_a923 = options._internal) == null ? void 0 : _a923.currentDate) == null ? void 0 : _b92.call(_a923).getTime()) != null ? _c : Date.now();
2942
2942
  if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
2943
2943
  lastFetchTime = now2;
2944
2944
  pendingMetadata = new GatewayFetchMetadata({
@@ -3093,11 +3093,11 @@ var major = VERSION22.split(".")[0];
3093
3093
  var GLOBAL_OPENTELEMETRY_API_KEY = /* @__PURE__ */ Symbol.for("opentelemetry.js.api." + major);
3094
3094
  var _global = _globalThis;
3095
3095
  function registerGlobal(type, instance, diag, allowOverride) {
3096
- var _a163;
3096
+ var _a164;
3097
3097
  if (allowOverride === void 0) {
3098
3098
  allowOverride = false;
3099
3099
  }
3100
- var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a163 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a163 !== void 0 ? _a163 : {
3100
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a164 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a164 !== void 0 ? _a164 : {
3101
3101
  version: VERSION22
3102
3102
  };
3103
3103
  if (!allowOverride && api[type]) {
@@ -3115,12 +3115,12 @@ function registerGlobal(type, instance, diag, allowOverride) {
3115
3115
  return true;
3116
3116
  }
3117
3117
  function getGlobal(type) {
3118
- var _a163, _b83;
3119
- var globalVersion = (_a163 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a163 === void 0 ? void 0 : _a163.version;
3118
+ var _a164, _b84;
3119
+ var globalVersion = (_a164 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a164 === void 0 ? void 0 : _a164.version;
3120
3120
  if (!globalVersion || !isCompatible(globalVersion)) {
3121
3121
  return;
3122
3122
  }
3123
- return (_b83 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b83 === void 0 ? void 0 : _b83[type];
3123
+ return (_b84 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b84 === void 0 ? void 0 : _b84[type];
3124
3124
  }
3125
3125
  function unregisterGlobal(type, diag) {
3126
3126
  diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION22 + ".");
@@ -3285,13 +3285,13 @@ var DiagAPI = (
3285
3285
  }
3286
3286
  var self = this;
3287
3287
  var setLogger = function(logger, optionsOrLogLevel) {
3288
- var _a163, _b83, _c;
3288
+ var _a164, _b84, _c;
3289
3289
  if (optionsOrLogLevel === void 0) {
3290
3290
  optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
3291
3291
  }
3292
3292
  if (logger === self) {
3293
3293
  var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
3294
- self.error((_a163 = err.stack) !== null && _a163 !== void 0 ? _a163 : err.message);
3294
+ self.error((_a164 = err.stack) !== null && _a164 !== void 0 ? _a164 : err.message);
3295
3295
  return false;
3296
3296
  }
3297
3297
  if (typeof optionsOrLogLevel === "number") {
@@ -3300,7 +3300,7 @@ var DiagAPI = (
3300
3300
  };
3301
3301
  }
3302
3302
  var oldLogger = getGlobal("diag");
3303
- var newLogger = createLogLevelDiagLogger((_b83 = optionsOrLogLevel.logLevel) !== null && _b83 !== void 0 ? _b83 : DiagLogLevel.INFO, logger);
3303
+ var newLogger = createLogLevelDiagLogger((_b84 = optionsOrLogLevel.logLevel) !== null && _b84 !== void 0 ? _b84 : DiagLogLevel.INFO, logger);
3304
3304
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
3305
3305
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
3306
3306
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -3343,14 +3343,14 @@ var BaseContext = (
3343
3343
  return self._currentContext.get(key);
3344
3344
  };
3345
3345
  self.setValue = function(key, value) {
3346
- var context = new BaseContext22(self._currentContext);
3347
- context._currentContext.set(key, value);
3348
- return context;
3346
+ var context2 = new BaseContext22(self._currentContext);
3347
+ context2._currentContext.set(key, value);
3348
+ return context2;
3349
3349
  };
3350
3350
  self.deleteValue = function(key) {
3351
- var context = new BaseContext22(self._currentContext);
3352
- context._currentContext.delete(key);
3353
- return context;
3351
+ var context2 = new BaseContext22(self._currentContext);
3352
+ context2._currentContext.delete(key);
3353
+ return context2;
3354
3354
  };
3355
3355
  }
3356
3356
  return BaseContext22;
@@ -3455,16 +3455,16 @@ var ContextAPI = (
3455
3455
  ContextAPI22.prototype.active = function() {
3456
3456
  return this._getContextManager().active();
3457
3457
  };
3458
- ContextAPI22.prototype.with = function(context, fn, thisArg) {
3459
- var _a163;
3458
+ ContextAPI22.prototype.with = function(context2, fn, thisArg) {
3459
+ var _a164;
3460
3460
  var args = [];
3461
3461
  for (var _i = 3; _i < arguments.length; _i++) {
3462
3462
  args[_i - 3] = arguments[_i];
3463
3463
  }
3464
- return (_a163 = this._getContextManager()).with.apply(_a163, __spreadArray4([context, fn, thisArg], __read4(args), false));
3464
+ return (_a164 = this._getContextManager()).with.apply(_a164, __spreadArray4([context2, fn, thisArg], __read4(args), false));
3465
3465
  };
3466
- ContextAPI22.prototype.bind = function(context, target) {
3467
- return this._getContextManager().bind(context, target);
3466
+ ContextAPI22.prototype.bind = function(context2, target) {
3467
+ return this._getContextManager().bind(context2, target);
3468
3468
  };
3469
3469
  ContextAPI22.prototype._getContextManager = function() {
3470
3470
  return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
@@ -3532,24 +3532,24 @@ var NonRecordingSpan = (
3532
3532
  })()
3533
3533
  );
3534
3534
  var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
3535
- function getSpan(context) {
3536
- return context.getValue(SPAN_KEY) || void 0;
3535
+ function getSpan(context2) {
3536
+ return context2.getValue(SPAN_KEY) || void 0;
3537
3537
  }
3538
3538
  function getActiveSpan() {
3539
3539
  return getSpan(ContextAPI.getInstance().active());
3540
3540
  }
3541
- function setSpan(context, span) {
3542
- return context.setValue(SPAN_KEY, span);
3541
+ function setSpan(context2, span) {
3542
+ return context2.setValue(SPAN_KEY, span);
3543
3543
  }
3544
- function deleteSpan(context) {
3545
- return context.deleteValue(SPAN_KEY);
3544
+ function deleteSpan(context2) {
3545
+ return context2.deleteValue(SPAN_KEY);
3546
3546
  }
3547
- function setSpanContext(context, spanContext) {
3548
- return setSpan(context, new NonRecordingSpan(spanContext));
3547
+ function setSpanContext(context2, spanContext) {
3548
+ return setSpan(context2, new NonRecordingSpan(spanContext));
3549
3549
  }
3550
- function getSpanContext(context) {
3551
- var _a163;
3552
- return (_a163 = getSpan(context)) === null || _a163 === void 0 ? void 0 : _a163.spanContext();
3550
+ function getSpanContext(context2) {
3551
+ var _a164;
3552
+ return (_a164 = getSpan(context2)) === null || _a164 === void 0 ? void 0 : _a164.spanContext();
3553
3553
  }
3554
3554
  var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
3555
3555
  var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
@@ -3571,22 +3571,22 @@ var NoopTracer = (
3571
3571
  (function() {
3572
3572
  function NoopTracer22() {
3573
3573
  }
3574
- NoopTracer22.prototype.startSpan = function(name163, options, context) {
3575
- if (context === void 0) {
3576
- context = contextApi.active();
3574
+ NoopTracer22.prototype.startSpan = function(name164, options, context2) {
3575
+ if (context2 === void 0) {
3576
+ context2 = contextApi.active();
3577
3577
  }
3578
3578
  var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
3579
3579
  if (root) {
3580
3580
  return new NonRecordingSpan();
3581
3581
  }
3582
- var parentFromContext = context && getSpanContext(context);
3582
+ var parentFromContext = context2 && getSpanContext(context2);
3583
3583
  if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
3584
3584
  return new NonRecordingSpan(parentFromContext);
3585
3585
  } else {
3586
3586
  return new NonRecordingSpan();
3587
3587
  }
3588
3588
  };
3589
- NoopTracer22.prototype.startActiveSpan = function(name163, arg2, arg3, arg4) {
3589
+ NoopTracer22.prototype.startActiveSpan = function(name164, arg2, arg3, arg4) {
3590
3590
  var opts;
3591
3591
  var ctx;
3592
3592
  var fn;
@@ -3603,7 +3603,7 @@ var NoopTracer = (
3603
3603
  fn = arg4;
3604
3604
  }
3605
3605
  var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
3606
- var span = this.startSpan(name163, opts, parentContext);
3606
+ var span = this.startSpan(name164, opts, parentContext);
3607
3607
  var contextWithSpanSet = setSpan(parentContext, span);
3608
3608
  return contextApi.with(contextWithSpanSet, fn, void 0, span);
3609
3609
  };
@@ -3617,14 +3617,14 @@ var NOOP_TRACER = new NoopTracer();
3617
3617
  var ProxyTracer = (
3618
3618
  /** @class */
3619
3619
  (function() {
3620
- function ProxyTracer22(_provider, name163, version, options) {
3620
+ function ProxyTracer22(_provider, name164, version, options) {
3621
3621
  this._provider = _provider;
3622
- this.name = name163;
3622
+ this.name = name164;
3623
3623
  this.version = version;
3624
3624
  this.options = options;
3625
3625
  }
3626
- ProxyTracer22.prototype.startSpan = function(name163, options, context) {
3627
- return this._getTracer().startSpan(name163, options, context);
3626
+ ProxyTracer22.prototype.startSpan = function(name164, options, context2) {
3627
+ return this._getTracer().startSpan(name164, options, context2);
3628
3628
  };
3629
3629
  ProxyTracer22.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
3630
3630
  var tracer = this._getTracer();
@@ -3661,20 +3661,20 @@ var ProxyTracerProvider = (
3661
3661
  (function() {
3662
3662
  function ProxyTracerProvider22() {
3663
3663
  }
3664
- ProxyTracerProvider22.prototype.getTracer = function(name163, version, options) {
3665
- var _a163;
3666
- return (_a163 = this.getDelegateTracer(name163, version, options)) !== null && _a163 !== void 0 ? _a163 : new ProxyTracer(this, name163, version, options);
3664
+ ProxyTracerProvider22.prototype.getTracer = function(name164, version, options) {
3665
+ var _a164;
3666
+ return (_a164 = this.getDelegateTracer(name164, version, options)) !== null && _a164 !== void 0 ? _a164 : new ProxyTracer(this, name164, version, options);
3667
3667
  };
3668
3668
  ProxyTracerProvider22.prototype.getDelegate = function() {
3669
- var _a163;
3670
- return (_a163 = this._delegate) !== null && _a163 !== void 0 ? _a163 : NOOP_TRACER_PROVIDER;
3669
+ var _a164;
3670
+ return (_a164 = this._delegate) !== null && _a164 !== void 0 ? _a164 : NOOP_TRACER_PROVIDER;
3671
3671
  };
3672
3672
  ProxyTracerProvider22.prototype.setDelegate = function(delegate) {
3673
3673
  this._delegate = delegate;
3674
3674
  };
3675
- ProxyTracerProvider22.prototype.getDelegateTracer = function(name163, version, options) {
3676
- var _a163;
3677
- return (_a163 = this._delegate) === null || _a163 === void 0 ? void 0 : _a163.getTracer(name163, version, options);
3675
+ ProxyTracerProvider22.prototype.getDelegateTracer = function(name164, version, options) {
3676
+ var _a164;
3677
+ return (_a164 = this._delegate) === null || _a164 === void 0 ? void 0 : _a164.getTracer(name164, version, options);
3678
3678
  };
3679
3679
  return ProxyTracerProvider22;
3680
3680
  })()
@@ -3716,8 +3716,8 @@ var TraceAPI = (
3716
3716
  TraceAPI22.prototype.getTracerProvider = function() {
3717
3717
  return getGlobal(API_NAME3) || this._proxyTracerProvider;
3718
3718
  };
3719
- TraceAPI22.prototype.getTracer = function(name163, version) {
3720
- return this.getTracerProvider().getTracer(name163, version);
3719
+ TraceAPI22.prototype.getTracer = function(name164, version) {
3720
+ return this.getTracerProvider().getTracer(name164, version);
3721
3721
  };
3722
3722
  TraceAPI22.prototype.disable = function() {
3723
3723
  unregisterGlobal(API_NAME3, DiagAPI.instance());
@@ -3729,8 +3729,8 @@ var TraceAPI = (
3729
3729
  TraceAPI.getInstance();
3730
3730
  var __defProp = Object.defineProperty;
3731
3731
  var __export = (target, all) => {
3732
- for (var name163 in all)
3733
- __defProp(target, name163, { get: all[name163], enumerable: true });
3732
+ for (var name164 in all)
3733
+ __defProp(target, name164, { get: all[name164], enumerable: true });
3734
3734
  };
3735
3735
  var name622 = "AI_NoObjectGeneratedError";
3736
3736
  var marker622 = `vercel.ai.error.${name622}`;
@@ -3764,8 +3764,8 @@ var dataContentSchema = z.union([
3764
3764
  z.custom(
3765
3765
  // Buffer might not be available in some environments such as CloudFlare:
3766
3766
  (value) => {
3767
- var _a163, _b83;
3768
- return (_b83 = (_a163 = globalThis.Buffer) == null ? void 0 : _a163.isBuffer(value)) != null ? _b83 : false;
3767
+ var _a164, _b84;
3768
+ return (_b84 = (_a164 = globalThis.Buffer) == null ? void 0 : _a164.isBuffer(value)) != null ? _b84 : false;
3769
3769
  },
3770
3770
  { message: "Must be a Buffer" }
3771
3771
  )
@@ -4281,16 +4281,16 @@ var object = ({
4281
4281
  }
4282
4282
  }
4283
4283
  },
4284
- async parseOutput({ text: text22 }, context) {
4284
+ async parseOutput({ text: text22 }, context2) {
4285
4285
  const parseResult = await safeParseJSON({ text: text22 });
4286
4286
  if (!parseResult.success) {
4287
4287
  throw new NoObjectGeneratedError({
4288
4288
  message: "No object generated: could not parse the response.",
4289
4289
  cause: parseResult.error,
4290
4290
  text: text22,
4291
- response: context.response,
4292
- usage: context.usage,
4293
- finishReason: context.finishReason
4291
+ response: context2.response,
4292
+ usage: context2.usage,
4293
+ finishReason: context2.finishReason
4294
4294
  });
4295
4295
  }
4296
4296
  const validationResult = await safeValidateTypes({
@@ -4302,9 +4302,9 @@ var object = ({
4302
4302
  message: "No object generated: response did not match schema.",
4303
4303
  cause: validationResult.error,
4304
4304
  text: text22,
4305
- response: context.response,
4306
- usage: context.usage,
4307
- finishReason: context.finishReason
4305
+ response: context2.response,
4306
+ usage: context2.usage,
4307
+ finishReason: context2.finishReason
4308
4308
  });
4309
4309
  }
4310
4310
  return validationResult.value;
@@ -4395,7 +4395,7 @@ var __toESM3 = (mod, isNodeMode, target) => (target = mod != null ? __create(__g
4395
4395
  mod
4396
4396
  ));
4397
4397
  var require_secure_json_parse = __commonJS3({
4398
- "../../../node_modules/.pnpm/secure-json-parse@2.7.0/node_modules/secure-json-parse/index.js"(exports, module) {
4398
+ "../../../node_modules/.pnpm/secure-json-parse@2.7.0/node_modules/secure-json-parse/index.js"(exports$1, module) {
4399
4399
  var hasBuffer = typeof Buffer !== "undefined";
4400
4400
  var suspectProtoRx3 = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
4401
4401
  var suspectConstructorRx3 = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
@@ -4508,13 +4508,13 @@ var _AISDKError3 = class _AISDKError22 extends Error {
4508
4508
  * @param {unknown} [params.cause] - The underlying cause of the error.
4509
4509
  */
4510
4510
  constructor({
4511
- name: name145,
4511
+ name: name146,
4512
4512
  message,
4513
4513
  cause
4514
4514
  }) {
4515
4515
  super(message);
4516
4516
  this[_a16] = true;
4517
- this.name = name145;
4517
+ this.name = name146;
4518
4518
  this.cause = cause;
4519
4519
  }
4520
4520
  /**
@@ -4525,8 +4525,8 @@ var _AISDKError3 = class _AISDKError22 extends Error {
4525
4525
  static isInstance(error) {
4526
4526
  return _AISDKError22.hasMarker(error, marker16);
4527
4527
  }
4528
- static hasMarker(error, marker155) {
4529
- const markerSymbol = Symbol.for(marker155);
4528
+ static hasMarker(error, marker156) {
4529
+ const markerSymbol = Symbol.for(marker156);
4530
4530
  return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
4531
4531
  }
4532
4532
  };
@@ -4796,11 +4796,11 @@ var getRefs2 = (options) => {
4796
4796
  flags: { hasReferencedOpenAiAnyType: false },
4797
4797
  currentPath,
4798
4798
  propertyPath: void 0,
4799
- seen: new Map(Object.entries(_options.definitions).map(([name172, def]) => [
4799
+ seen: new Map(Object.entries(_options.definitions).map(([name173, def]) => [
4800
4800
  def._def,
4801
4801
  {
4802
4802
  def: def._def,
4803
- path: [..._options.basePath, _options.definitionPath, name172],
4803
+ path: [..._options.basePath, _options.definitionPath, name173],
4804
4804
  // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
4805
4805
  jsonSchema: void 0
4806
4806
  }
@@ -4847,7 +4847,7 @@ function parseArrayDef2(def, refs) {
4847
4847
  const res = {
4848
4848
  type: "array"
4849
4849
  };
4850
- if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind$1.ZodAny) {
4850
+ if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind.ZodAny) {
4851
4851
  res.items = parseDef2(def.type._def, {
4852
4852
  ...refs,
4853
4853
  currentPath: [...refs.currentPath, "items"]
@@ -5364,7 +5364,7 @@ function parseRecordDef2(def, refs) {
5364
5364
  if (refs.target === "openAi") {
5365
5365
  console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
5366
5366
  }
5367
- if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind$1.ZodEnum) {
5367
+ if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
5368
5368
  return {
5369
5369
  type: "object",
5370
5370
  required: def.keyType._def.values,
@@ -5388,20 +5388,20 @@ function parseRecordDef2(def, refs) {
5388
5388
  if (refs.target === "openApi3") {
5389
5389
  return schema;
5390
5390
  }
5391
- if (def.keyType?._def.typeName === ZodFirstPartyTypeKind$1.ZodString && def.keyType._def.checks?.length) {
5391
+ if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
5392
5392
  const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
5393
5393
  return {
5394
5394
  ...schema,
5395
5395
  propertyNames: keyType
5396
5396
  };
5397
- } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind$1.ZodEnum) {
5397
+ } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
5398
5398
  return {
5399
5399
  ...schema,
5400
5400
  propertyNames: {
5401
5401
  enum: def.keyType._def.values
5402
5402
  }
5403
5403
  };
5404
- } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind$1.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind$1.ZodString && def.keyType._def.type._def.checks?.length) {
5404
+ } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
5405
5405
  const { type, ...keyType } = parseBrandedDef2(def.keyType._def, refs);
5406
5406
  return {
5407
5407
  ...schema,
@@ -5767,73 +5767,73 @@ var parseReadonlyDef2 = (def, refs) => {
5767
5767
  };
5768
5768
  var selectParser2 = (def, typeName, refs) => {
5769
5769
  switch (typeName) {
5770
- case ZodFirstPartyTypeKind$1.ZodString:
5770
+ case ZodFirstPartyTypeKind.ZodString:
5771
5771
  return parseStringDef2(def, refs);
5772
- case ZodFirstPartyTypeKind$1.ZodNumber:
5772
+ case ZodFirstPartyTypeKind.ZodNumber:
5773
5773
  return parseNumberDef2(def, refs);
5774
- case ZodFirstPartyTypeKind$1.ZodObject:
5774
+ case ZodFirstPartyTypeKind.ZodObject:
5775
5775
  return parseObjectDef2(def, refs);
5776
- case ZodFirstPartyTypeKind$1.ZodBigInt:
5776
+ case ZodFirstPartyTypeKind.ZodBigInt:
5777
5777
  return parseBigintDef2(def, refs);
5778
- case ZodFirstPartyTypeKind$1.ZodBoolean:
5778
+ case ZodFirstPartyTypeKind.ZodBoolean:
5779
5779
  return parseBooleanDef2();
5780
- case ZodFirstPartyTypeKind$1.ZodDate:
5780
+ case ZodFirstPartyTypeKind.ZodDate:
5781
5781
  return parseDateDef2(def, refs);
5782
- case ZodFirstPartyTypeKind$1.ZodUndefined:
5782
+ case ZodFirstPartyTypeKind.ZodUndefined:
5783
5783
  return parseUndefinedDef2(refs);
5784
- case ZodFirstPartyTypeKind$1.ZodNull:
5784
+ case ZodFirstPartyTypeKind.ZodNull:
5785
5785
  return parseNullDef2(refs);
5786
- case ZodFirstPartyTypeKind$1.ZodArray:
5786
+ case ZodFirstPartyTypeKind.ZodArray:
5787
5787
  return parseArrayDef2(def, refs);
5788
- case ZodFirstPartyTypeKind$1.ZodUnion:
5789
- case ZodFirstPartyTypeKind$1.ZodDiscriminatedUnion:
5788
+ case ZodFirstPartyTypeKind.ZodUnion:
5789
+ case ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
5790
5790
  return parseUnionDef2(def, refs);
5791
- case ZodFirstPartyTypeKind$1.ZodIntersection:
5791
+ case ZodFirstPartyTypeKind.ZodIntersection:
5792
5792
  return parseIntersectionDef2(def, refs);
5793
- case ZodFirstPartyTypeKind$1.ZodTuple:
5793
+ case ZodFirstPartyTypeKind.ZodTuple:
5794
5794
  return parseTupleDef2(def, refs);
5795
- case ZodFirstPartyTypeKind$1.ZodRecord:
5795
+ case ZodFirstPartyTypeKind.ZodRecord:
5796
5796
  return parseRecordDef2(def, refs);
5797
- case ZodFirstPartyTypeKind$1.ZodLiteral:
5797
+ case ZodFirstPartyTypeKind.ZodLiteral:
5798
5798
  return parseLiteralDef2(def, refs);
5799
- case ZodFirstPartyTypeKind$1.ZodEnum:
5799
+ case ZodFirstPartyTypeKind.ZodEnum:
5800
5800
  return parseEnumDef2(def);
5801
- case ZodFirstPartyTypeKind$1.ZodNativeEnum:
5801
+ case ZodFirstPartyTypeKind.ZodNativeEnum:
5802
5802
  return parseNativeEnumDef2(def);
5803
- case ZodFirstPartyTypeKind$1.ZodNullable:
5803
+ case ZodFirstPartyTypeKind.ZodNullable:
5804
5804
  return parseNullableDef2(def, refs);
5805
- case ZodFirstPartyTypeKind$1.ZodOptional:
5805
+ case ZodFirstPartyTypeKind.ZodOptional:
5806
5806
  return parseOptionalDef2(def, refs);
5807
- case ZodFirstPartyTypeKind$1.ZodMap:
5807
+ case ZodFirstPartyTypeKind.ZodMap:
5808
5808
  return parseMapDef2(def, refs);
5809
- case ZodFirstPartyTypeKind$1.ZodSet:
5809
+ case ZodFirstPartyTypeKind.ZodSet:
5810
5810
  return parseSetDef2(def, refs);
5811
- case ZodFirstPartyTypeKind$1.ZodLazy:
5811
+ case ZodFirstPartyTypeKind.ZodLazy:
5812
5812
  return () => def.getter()._def;
5813
- case ZodFirstPartyTypeKind$1.ZodPromise:
5813
+ case ZodFirstPartyTypeKind.ZodPromise:
5814
5814
  return parsePromiseDef2(def, refs);
5815
- case ZodFirstPartyTypeKind$1.ZodNaN:
5816
- case ZodFirstPartyTypeKind$1.ZodNever:
5815
+ case ZodFirstPartyTypeKind.ZodNaN:
5816
+ case ZodFirstPartyTypeKind.ZodNever:
5817
5817
  return parseNeverDef2(refs);
5818
- case ZodFirstPartyTypeKind$1.ZodEffects:
5818
+ case ZodFirstPartyTypeKind.ZodEffects:
5819
5819
  return parseEffectsDef2(def, refs);
5820
- case ZodFirstPartyTypeKind$1.ZodAny:
5820
+ case ZodFirstPartyTypeKind.ZodAny:
5821
5821
  return parseAnyDef2(refs);
5822
- case ZodFirstPartyTypeKind$1.ZodUnknown:
5822
+ case ZodFirstPartyTypeKind.ZodUnknown:
5823
5823
  return parseUnknownDef2(refs);
5824
- case ZodFirstPartyTypeKind$1.ZodDefault:
5824
+ case ZodFirstPartyTypeKind.ZodDefault:
5825
5825
  return parseDefaultDef2(def, refs);
5826
- case ZodFirstPartyTypeKind$1.ZodBranded:
5826
+ case ZodFirstPartyTypeKind.ZodBranded:
5827
5827
  return parseBrandedDef2(def, refs);
5828
- case ZodFirstPartyTypeKind$1.ZodReadonly:
5828
+ case ZodFirstPartyTypeKind.ZodReadonly:
5829
5829
  return parseReadonlyDef2(def, refs);
5830
- case ZodFirstPartyTypeKind$1.ZodCatch:
5830
+ case ZodFirstPartyTypeKind.ZodCatch:
5831
5831
  return parseCatchDef2(def, refs);
5832
- case ZodFirstPartyTypeKind$1.ZodPipeline:
5832
+ case ZodFirstPartyTypeKind.ZodPipeline:
5833
5833
  return parsePipelineDef2(def, refs);
5834
- case ZodFirstPartyTypeKind$1.ZodFunction:
5835
- case ZodFirstPartyTypeKind$1.ZodVoid:
5836
- case ZodFirstPartyTypeKind$1.ZodSymbol:
5834
+ case ZodFirstPartyTypeKind.ZodFunction:
5835
+ case ZodFirstPartyTypeKind.ZodVoid:
5836
+ case ZodFirstPartyTypeKind.ZodSymbol:
5837
5837
  return void 0;
5838
5838
  default:
5839
5839
  return /* @__PURE__ */ ((_) => void 0)();
@@ -5895,17 +5895,17 @@ var addMeta2 = (def, refs, jsonSchema22) => {
5895
5895
  };
5896
5896
  var zodToJsonSchema2 = (schema, options) => {
5897
5897
  const refs = getRefs2(options);
5898
- let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name182, schema2]) => ({
5898
+ let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name183, schema2]) => ({
5899
5899
  ...acc,
5900
- [name182]: parseDef2(schema2._def, {
5900
+ [name183]: parseDef2(schema2._def, {
5901
5901
  ...refs,
5902
- currentPath: [...refs.basePath, refs.definitionPath, name182]
5902
+ currentPath: [...refs.basePath, refs.definitionPath, name183]
5903
5903
  }, true) ?? parseAnyDef2(refs)
5904
5904
  }), {}) : void 0;
5905
- const name172 = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
5906
- const main = parseDef2(schema._def, name172 === void 0 ? refs : {
5905
+ const name173 = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
5906
+ const main = parseDef2(schema._def, name173 === void 0 ? refs : {
5907
5907
  ...refs,
5908
- currentPath: [...refs.basePath, refs.definitionPath, name172]
5908
+ currentPath: [...refs.basePath, refs.definitionPath, name173]
5909
5909
  }, false) ?? parseAnyDef2(refs);
5910
5910
  const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
5911
5911
  if (title !== void 0) {
@@ -5929,18 +5929,18 @@ var zodToJsonSchema2 = (schema, options) => {
5929
5929
  };
5930
5930
  }
5931
5931
  }
5932
- const combined = name172 === void 0 ? definitions ? {
5932
+ const combined = name173 === void 0 ? definitions ? {
5933
5933
  ...main,
5934
5934
  [refs.definitionPath]: definitions
5935
5935
  } : main : {
5936
5936
  $ref: [
5937
5937
  ...refs.$refStrategy === "relative" ? [] : refs.basePath,
5938
5938
  refs.definitionPath,
5939
- name172
5939
+ name173
5940
5940
  ].join("/"),
5941
5941
  [refs.definitionPath]: {
5942
5942
  ...definitions,
5943
- [name172]: main
5943
+ [name173]: main
5944
5944
  }
5945
5945
  };
5946
5946
  if (refs.target === "jsonSchema7") {
@@ -6548,8 +6548,8 @@ function formatDataStreamPart(type, value) {
6548
6548
  `;
6549
6549
  }
6550
6550
  function zodSchema2(zodSchema22, options) {
6551
- var _a172;
6552
- const useReferences = (_a172 = void 0 ) != null ? _a172 : false;
6551
+ var _a173;
6552
+ const useReferences = (_a173 = void 0 ) != null ? _a173 : false;
6553
6553
  return jsonSchema2(
6554
6554
  esm_default(zodSchema22, {
6555
6555
  $refStrategy: useReferences ? "root" : "none",
@@ -6654,11 +6654,11 @@ var major2 = VERSION3.split(".")[0];
6654
6654
  var GLOBAL_OPENTELEMETRY_API_KEY2 = /* @__PURE__ */ Symbol.for("opentelemetry.js.api." + major2);
6655
6655
  var _global2 = _globalThis2;
6656
6656
  function registerGlobal2(type, instance, diag, allowOverride) {
6657
- var _a172;
6657
+ var _a173;
6658
6658
  if (allowOverride === void 0) {
6659
6659
  allowOverride = false;
6660
6660
  }
6661
- var api = _global2[GLOBAL_OPENTELEMETRY_API_KEY2] = (_a172 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) !== null && _a172 !== void 0 ? _a172 : {
6661
+ var api = _global2[GLOBAL_OPENTELEMETRY_API_KEY2] = (_a173 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) !== null && _a173 !== void 0 ? _a173 : {
6662
6662
  version: VERSION3
6663
6663
  };
6664
6664
  if (!allowOverride && api[type]) {
@@ -6676,8 +6676,8 @@ function registerGlobal2(type, instance, diag, allowOverride) {
6676
6676
  return true;
6677
6677
  }
6678
6678
  function getGlobal2(type) {
6679
- var _a172, _b17;
6680
- var globalVersion = (_a172 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _a172 === void 0 ? void 0 : _a172.version;
6679
+ var _a173, _b17;
6680
+ var globalVersion = (_a173 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _a173 === void 0 ? void 0 : _a173.version;
6681
6681
  if (!globalVersion || !isCompatible2(globalVersion)) {
6682
6682
  return;
6683
6683
  }
@@ -6846,13 +6846,13 @@ var DiagAPI2 = (
6846
6846
  }
6847
6847
  var self = this;
6848
6848
  var setLogger = function(logger, optionsOrLogLevel) {
6849
- var _a172, _b17, _c;
6849
+ var _a173, _b17, _c;
6850
6850
  if (optionsOrLogLevel === void 0) {
6851
6851
  optionsOrLogLevel = { logLevel: DiagLogLevel2.INFO };
6852
6852
  }
6853
6853
  if (logger === self) {
6854
6854
  var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
6855
- self.error((_a172 = err.stack) !== null && _a172 !== void 0 ? _a172 : err.message);
6855
+ self.error((_a173 = err.stack) !== null && _a173 !== void 0 ? _a173 : err.message);
6856
6856
  return false;
6857
6857
  }
6858
6858
  if (typeof optionsOrLogLevel === "number") {
@@ -6904,14 +6904,14 @@ var BaseContext2 = (
6904
6904
  return self._currentContext.get(key);
6905
6905
  };
6906
6906
  self.setValue = function(key, value) {
6907
- var context = new BaseContext22(self._currentContext);
6908
- context._currentContext.set(key, value);
6909
- return context;
6907
+ var context2 = new BaseContext22(self._currentContext);
6908
+ context2._currentContext.set(key, value);
6909
+ return context2;
6910
6910
  };
6911
6911
  self.deleteValue = function(key) {
6912
- var context = new BaseContext22(self._currentContext);
6913
- context._currentContext.delete(key);
6914
- return context;
6912
+ var context2 = new BaseContext22(self._currentContext);
6913
+ context2._currentContext.delete(key);
6914
+ return context2;
6915
6915
  };
6916
6916
  }
6917
6917
  return BaseContext22;
@@ -7016,16 +7016,16 @@ var ContextAPI2 = (
7016
7016
  ContextAPI22.prototype.active = function() {
7017
7017
  return this._getContextManager().active();
7018
7018
  };
7019
- ContextAPI22.prototype.with = function(context, fn, thisArg) {
7020
- var _a172;
7019
+ ContextAPI22.prototype.with = function(context2, fn, thisArg) {
7020
+ var _a173;
7021
7021
  var args = [];
7022
7022
  for (var _i = 3; _i < arguments.length; _i++) {
7023
7023
  args[_i - 3] = arguments[_i];
7024
7024
  }
7025
- return (_a172 = this._getContextManager()).with.apply(_a172, __spreadArray42([context, fn, thisArg], __read42(args), false));
7025
+ return (_a173 = this._getContextManager()).with.apply(_a173, __spreadArray42([context2, fn, thisArg], __read42(args), false));
7026
7026
  };
7027
- ContextAPI22.prototype.bind = function(context, target) {
7028
- return this._getContextManager().bind(context, target);
7027
+ ContextAPI22.prototype.bind = function(context2, target) {
7028
+ return this._getContextManager().bind(context2, target);
7029
7029
  };
7030
7030
  ContextAPI22.prototype._getContextManager = function() {
7031
7031
  return getGlobal2(API_NAME22) || NOOP_CONTEXT_MANAGER2;
@@ -7093,24 +7093,24 @@ var NonRecordingSpan2 = (
7093
7093
  })()
7094
7094
  );
7095
7095
  var SPAN_KEY2 = createContextKey2("OpenTelemetry Context Key SPAN");
7096
- function getSpan2(context) {
7097
- return context.getValue(SPAN_KEY2) || void 0;
7096
+ function getSpan2(context2) {
7097
+ return context2.getValue(SPAN_KEY2) || void 0;
7098
7098
  }
7099
7099
  function getActiveSpan2() {
7100
7100
  return getSpan2(ContextAPI2.getInstance().active());
7101
7101
  }
7102
- function setSpan2(context, span) {
7103
- return context.setValue(SPAN_KEY2, span);
7102
+ function setSpan2(context2, span) {
7103
+ return context2.setValue(SPAN_KEY2, span);
7104
7104
  }
7105
- function deleteSpan2(context) {
7106
- return context.deleteValue(SPAN_KEY2);
7105
+ function deleteSpan2(context2) {
7106
+ return context2.deleteValue(SPAN_KEY2);
7107
7107
  }
7108
- function setSpanContext2(context, spanContext) {
7109
- return setSpan2(context, new NonRecordingSpan2(spanContext));
7108
+ function setSpanContext2(context2, spanContext) {
7109
+ return setSpan2(context2, new NonRecordingSpan2(spanContext));
7110
7110
  }
7111
- function getSpanContext2(context) {
7112
- var _a172;
7113
- return (_a172 = getSpan2(context)) === null || _a172 === void 0 ? void 0 : _a172.spanContext();
7111
+ function getSpanContext2(context2) {
7112
+ var _a173;
7113
+ return (_a173 = getSpan2(context2)) === null || _a173 === void 0 ? void 0 : _a173.spanContext();
7114
7114
  }
7115
7115
  var VALID_TRACEID_REGEX2 = /^([0-9a-f]{32})$/i;
7116
7116
  var VALID_SPANID_REGEX2 = /^[0-9a-f]{16}$/i;
@@ -7132,22 +7132,22 @@ var NoopTracer2 = (
7132
7132
  (function() {
7133
7133
  function NoopTracer22() {
7134
7134
  }
7135
- NoopTracer22.prototype.startSpan = function(name172, options, context) {
7136
- if (context === void 0) {
7137
- context = contextApi2.active();
7135
+ NoopTracer22.prototype.startSpan = function(name173, options, context2) {
7136
+ if (context2 === void 0) {
7137
+ context2 = contextApi2.active();
7138
7138
  }
7139
7139
  var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
7140
7140
  if (root) {
7141
7141
  return new NonRecordingSpan2();
7142
7142
  }
7143
- var parentFromContext = context && getSpanContext2(context);
7143
+ var parentFromContext = context2 && getSpanContext2(context2);
7144
7144
  if (isSpanContext2(parentFromContext) && isSpanContextValid2(parentFromContext)) {
7145
7145
  return new NonRecordingSpan2(parentFromContext);
7146
7146
  } else {
7147
7147
  return new NonRecordingSpan2();
7148
7148
  }
7149
7149
  };
7150
- NoopTracer22.prototype.startActiveSpan = function(name172, arg2, arg3, arg4) {
7150
+ NoopTracer22.prototype.startActiveSpan = function(name173, arg2, arg3, arg4) {
7151
7151
  var opts;
7152
7152
  var ctx;
7153
7153
  var fn;
@@ -7164,7 +7164,7 @@ var NoopTracer2 = (
7164
7164
  fn = arg4;
7165
7165
  }
7166
7166
  var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi2.active();
7167
- var span = this.startSpan(name172, opts, parentContext);
7167
+ var span = this.startSpan(name173, opts, parentContext);
7168
7168
  var contextWithSpanSet = setSpan2(parentContext, span);
7169
7169
  return contextApi2.with(contextWithSpanSet, fn, void 0, span);
7170
7170
  };
@@ -7178,14 +7178,14 @@ var NOOP_TRACER2 = new NoopTracer2();
7178
7178
  var ProxyTracer2 = (
7179
7179
  /** @class */
7180
7180
  (function() {
7181
- function ProxyTracer22(_provider, name172, version, options) {
7181
+ function ProxyTracer22(_provider, name173, version, options) {
7182
7182
  this._provider = _provider;
7183
- this.name = name172;
7183
+ this.name = name173;
7184
7184
  this.version = version;
7185
7185
  this.options = options;
7186
7186
  }
7187
- ProxyTracer22.prototype.startSpan = function(name172, options, context) {
7188
- return this._getTracer().startSpan(name172, options, context);
7187
+ ProxyTracer22.prototype.startSpan = function(name173, options, context2) {
7188
+ return this._getTracer().startSpan(name173, options, context2);
7189
7189
  };
7190
7190
  ProxyTracer22.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
7191
7191
  var tracer = this._getTracer();
@@ -7222,20 +7222,20 @@ var ProxyTracerProvider2 = (
7222
7222
  (function() {
7223
7223
  function ProxyTracerProvider22() {
7224
7224
  }
7225
- ProxyTracerProvider22.prototype.getTracer = function(name172, version, options) {
7226
- var _a172;
7227
- return (_a172 = this.getDelegateTracer(name172, version, options)) !== null && _a172 !== void 0 ? _a172 : new ProxyTracer2(this, name172, version, options);
7225
+ ProxyTracerProvider22.prototype.getTracer = function(name173, version, options) {
7226
+ var _a173;
7227
+ return (_a173 = this.getDelegateTracer(name173, version, options)) !== null && _a173 !== void 0 ? _a173 : new ProxyTracer2(this, name173, version, options);
7228
7228
  };
7229
7229
  ProxyTracerProvider22.prototype.getDelegate = function() {
7230
- var _a172;
7231
- return (_a172 = this._delegate) !== null && _a172 !== void 0 ? _a172 : NOOP_TRACER_PROVIDER2;
7230
+ var _a173;
7231
+ return (_a173 = this._delegate) !== null && _a173 !== void 0 ? _a173 : NOOP_TRACER_PROVIDER2;
7232
7232
  };
7233
7233
  ProxyTracerProvider22.prototype.setDelegate = function(delegate) {
7234
7234
  this._delegate = delegate;
7235
7235
  };
7236
- ProxyTracerProvider22.prototype.getDelegateTracer = function(name172, version, options) {
7237
- var _a172;
7238
- return (_a172 = this._delegate) === null || _a172 === void 0 ? void 0 : _a172.getTracer(name172, version, options);
7236
+ ProxyTracerProvider22.prototype.getDelegateTracer = function(name173, version, options) {
7237
+ var _a173;
7238
+ return (_a173 = this._delegate) === null || _a173 === void 0 ? void 0 : _a173.getTracer(name173, version, options);
7239
7239
  };
7240
7240
  return ProxyTracerProvider22;
7241
7241
  })()
@@ -7277,8 +7277,8 @@ var TraceAPI2 = (
7277
7277
  TraceAPI22.prototype.getTracerProvider = function() {
7278
7278
  return getGlobal2(API_NAME32) || this._proxyTracerProvider;
7279
7279
  };
7280
- TraceAPI22.prototype.getTracer = function(name172, version) {
7281
- return this.getTracerProvider().getTracer(name172, version);
7280
+ TraceAPI22.prototype.getTracer = function(name173, version) {
7281
+ return this.getTracerProvider().getTracer(name173, version);
7282
7282
  };
7283
7283
  TraceAPI22.prototype.disable = function() {
7284
7284
  unregisterGlobal2(API_NAME32, DiagAPI2.instance());
@@ -7290,8 +7290,8 @@ var TraceAPI2 = (
7290
7290
  TraceAPI2.getInstance();
7291
7291
  var __defProp3 = Object.defineProperty;
7292
7292
  var __export2 = (target, all) => {
7293
- for (var name172 in all)
7294
- __defProp3(target, name172, { get: all[name172], enumerable: true });
7293
+ for (var name173 in all)
7294
+ __defProp3(target, name173, { get: all[name173], enumerable: true });
7295
7295
  };
7296
7296
  function prepareResponseHeaders(headers, {
7297
7297
  contentType,
@@ -7338,8 +7338,8 @@ var dataContentSchema2 = z$1.union([
7338
7338
  z$1.custom(
7339
7339
  // Buffer might not be available in some environments such as CloudFlare:
7340
7340
  (value) => {
7341
- var _a172, _b17;
7342
- return (_b17 = (_a172 = globalThis.Buffer) == null ? void 0 : _a172.isBuffer(value)) != null ? _b17 : false;
7341
+ var _a173, _b17;
7342
+ return (_b17 = (_a173 = globalThis.Buffer) == null ? void 0 : _a173.isBuffer(value)) != null ? _b17 : false;
7343
7343
  },
7344
7344
  { message: "Must be a Buffer" }
7345
7345
  )
@@ -7543,16 +7543,16 @@ var object2 = ({
7543
7543
  }
7544
7544
  }
7545
7545
  },
7546
- parseOutput({ text: text22 }, context) {
7546
+ parseOutput({ text: text22 }, context2) {
7547
7547
  const parseResult = safeParseJSON2({ text: text22 });
7548
7548
  if (!parseResult.success) {
7549
7549
  throw new NoObjectGeneratedError2({
7550
7550
  message: "No object generated: could not parse the response.",
7551
7551
  cause: parseResult.error,
7552
7552
  text: text22,
7553
- response: context.response,
7554
- usage: context.usage,
7555
- finishReason: context.finishReason
7553
+ response: context2.response,
7554
+ usage: context2.usage,
7555
+ finishReason: context2.finishReason
7556
7556
  });
7557
7557
  }
7558
7558
  const validationResult = safeValidateTypes2({
@@ -7564,9 +7564,9 @@ var object2 = ({
7564
7564
  message: "No object generated: response did not match schema.",
7565
7565
  cause: validationResult.error,
7566
7566
  text: text22,
7567
- response: context.response,
7568
- usage: context.usage,
7569
- finishReason: context.finishReason
7567
+ response: context2.response,
7568
+ usage: context2.usage,
7569
+ finishReason: context2.finishReason
7570
7570
  });
7571
7571
  }
7572
7572
  return validationResult.value;
@@ -7864,7 +7864,7 @@ function toDataStreamInternal(stream, callbacks) {
7864
7864
  return stream.pipeThrough(
7865
7865
  new TransformStream({
7866
7866
  transform: async (value, controller) => {
7867
- var _a172;
7867
+ var _a173;
7868
7868
  if (typeof value === "string") {
7869
7869
  controller.enqueue(value);
7870
7870
  return;
@@ -7872,7 +7872,7 @@ function toDataStreamInternal(stream, callbacks) {
7872
7872
  if ("event" in value) {
7873
7873
  if (value.event === "on_chat_model_stream") {
7874
7874
  forwardAIMessageChunk(
7875
- (_a172 = value.data) == null ? void 0 : _a172.chunk,
7875
+ (_a173 = value.data) == null ? void 0 : _a173.chunk,
7876
7876
  controller
7877
7877
  );
7878
7878
  }
@@ -7895,7 +7895,7 @@ function toDataStream(stream, callbacks) {
7895
7895
  );
7896
7896
  }
7897
7897
  function toDataStreamResponse(stream, options) {
7898
- var _a172;
7898
+ var _a173;
7899
7899
  const dataStream = toDataStreamInternal(
7900
7900
  stream,
7901
7901
  options == null ? void 0 : options.callbacks
@@ -7904,7 +7904,7 @@ function toDataStreamResponse(stream, options) {
7904
7904
  const init = options == null ? void 0 : options.init;
7905
7905
  const responseStream = data ? mergeStreams(data.stream, dataStream) : dataStream;
7906
7906
  return new Response(responseStream, {
7907
- status: (_a172 = init == null ? void 0 : init.status) != null ? _a172 : 200,
7907
+ status: (_a173 = init == null ? void 0 : init.status) != null ? _a173 : 200,
7908
7908
  statusText: init == null ? void 0 : init.statusText,
7909
7909
  headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
7910
7910
  contentType: "text/plain; charset=utf-8",
@@ -7955,14 +7955,14 @@ function toDataStream2(stream, callbacks) {
7955
7955
  );
7956
7956
  }
7957
7957
  function toDataStreamResponse2(stream, options = {}) {
7958
- var _a172;
7958
+ var _a173;
7959
7959
  const { init, data, callbacks } = options;
7960
7960
  const dataStream = toDataStreamInternal2(stream, callbacks).pipeThrough(
7961
7961
  new TextEncoderStream()
7962
7962
  );
7963
7963
  const responseStream = data ? mergeStreams(data.stream, dataStream) : dataStream;
7964
7964
  return new Response(responseStream, {
7965
- status: (_a172 = init == null ? void 0 : init.status) != null ? _a172 : 200,
7965
+ status: (_a173 = init == null ? void 0 : init.status) != null ? _a173 : 200,
7966
7966
  statusText: init == null ? void 0 : init.statusText,
7967
7967
  headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
7968
7968
  contentType: "text/plain; charset=utf-8",
@@ -8148,34 +8148,61 @@ var symbol135 = Symbol.for(marker135);
8148
8148
  var _a135;
8149
8149
  var _b13;
8150
8150
  var TypeValidationError3 = class _TypeValidationError4 extends (_b13 = AISDKError3, _a135 = symbol135, _b13) {
8151
- constructor({ value, cause }) {
8151
+ constructor({
8152
+ value,
8153
+ cause,
8154
+ context: context2
8155
+ }) {
8156
+ let contextPrefix = "Type validation failed";
8157
+ if (context2 == null ? void 0 : context2.field) {
8158
+ contextPrefix += ` for ${context2.field}`;
8159
+ }
8160
+ if ((context2 == null ? void 0 : context2.entityName) || (context2 == null ? void 0 : context2.entityId)) {
8161
+ contextPrefix += " (";
8162
+ const parts = [];
8163
+ if (context2.entityName) {
8164
+ parts.push(context2.entityName);
8165
+ }
8166
+ if (context2.entityId) {
8167
+ parts.push(`id: "${context2.entityId}"`);
8168
+ }
8169
+ contextPrefix += parts.join(", ");
8170
+ contextPrefix += ")";
8171
+ }
8152
8172
  super({
8153
8173
  name: name125,
8154
- message: `Type validation failed: Value: ${JSON.stringify(value)}.
8174
+ message: `${contextPrefix}: Value: ${JSON.stringify(value)}.
8155
8175
  Error message: ${getErrorMessage4(cause)}`,
8156
8176
  cause
8157
8177
  });
8158
8178
  this[_a135] = true;
8159
8179
  this.value = value;
8180
+ this.context = context2;
8160
8181
  }
8161
8182
  static isInstance(error) {
8162
8183
  return AISDKError3.hasMarker(error, marker135);
8163
8184
  }
8164
8185
  /**
8165
8186
  * Wraps an error into a TypeValidationError.
8166
- * If the cause is already a TypeValidationError with the same value, it returns the cause.
8187
+ * If the cause is already a TypeValidationError with the same value and context, it returns the cause.
8167
8188
  * Otherwise, it creates a new TypeValidationError.
8168
8189
  *
8169
8190
  * @param {Object} params - The parameters for wrapping the error.
8170
8191
  * @param {unknown} params.value - The value that failed validation.
8171
8192
  * @param {unknown} params.cause - The original error or cause of the validation failure.
8193
+ * @param {TypeValidationContext} params.context - Optional context about what is being validated.
8172
8194
  * @returns {TypeValidationError} A TypeValidationError instance.
8173
8195
  */
8174
8196
  static wrap({
8175
8197
  value,
8176
- cause
8198
+ cause,
8199
+ context: context2
8177
8200
  }) {
8178
- return _TypeValidationError4.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError4({ value, cause });
8201
+ var _a1522, _b152, _c;
8202
+ if (_TypeValidationError4.isInstance(cause) && cause.value === value && ((_a1522 = cause.context) == null ? void 0 : _a1522.field) === (context2 == null ? void 0 : context2.field) && ((_b152 = cause.context) == null ? void 0 : _b152.entityName) === (context2 == null ? void 0 : context2.entityName) && ((_c = cause.context) == null ? void 0 : _c.entityId) === (context2 == null ? void 0 : context2.entityId)) {
8203
+ return cause;
8204
+ }
8205
+ return new _TypeValidationError4({ value, cause, context: context2 });
8179
8206
  }
8180
8207
  };
8181
8208
  var ParseError2 = class extends Error {
@@ -8313,6 +8340,14 @@ function combineHeaders2(...headers) {
8313
8340
  function extractResponseHeaders2(response) {
8314
8341
  return Object.fromEntries([...response.headers]);
8315
8342
  }
8343
+ var { btoa: btoa3} = globalThis;
8344
+ function convertUint8ArrayToBase643(array2) {
8345
+ let latin1string = "";
8346
+ for (let i = 0; i < array2.length; i++) {
8347
+ latin1string += String.fromCodePoint(array2[i]);
8348
+ }
8349
+ return btoa3(latin1string);
8350
+ }
8316
8351
  var createIdGenerator3 = ({
8317
8352
  prefix,
8318
8353
  size = 16,
@@ -8344,6 +8379,25 @@ function isAbortError3(error) {
8344
8379
  error.name === "TimeoutError");
8345
8380
  }
8346
8381
  var FETCH_FAILED_ERROR_MESSAGES2 = ["fetch failed", "failed to fetch"];
8382
+ var BUN_ERROR_CODES = [
8383
+ "ConnectionRefused",
8384
+ "ConnectionClosed",
8385
+ "FailedToOpenSocket",
8386
+ "ECONNRESET",
8387
+ "ECONNREFUSED",
8388
+ "ETIMEDOUT",
8389
+ "EPIPE"
8390
+ ];
8391
+ function isBunNetworkError(error) {
8392
+ if (!(error instanceof Error)) {
8393
+ return false;
8394
+ }
8395
+ const code = error.code;
8396
+ if (typeof code === "string" && BUN_ERROR_CODES.includes(code)) {
8397
+ return true;
8398
+ }
8399
+ return false;
8400
+ }
8347
8401
  function handleFetchError2({
8348
8402
  error,
8349
8403
  url,
@@ -8365,6 +8419,15 @@ function handleFetchError2({
8365
8419
  });
8366
8420
  }
8367
8421
  }
8422
+ if (isBunNetworkError(error)) {
8423
+ return new APICallError3({
8424
+ message: `Cannot connect to API: ${error.message}`,
8425
+ cause: error,
8426
+ url,
8427
+ requestBodyValues,
8428
+ isRetryable: true
8429
+ });
8430
+ }
8368
8431
  return error;
8369
8432
  }
8370
8433
  function getRuntimeEnvironmentUserAgent2(globalThisAny = globalThis) {
@@ -8413,7 +8476,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
8413
8476
  );
8414
8477
  return Object.fromEntries(normalizedHeaders.entries());
8415
8478
  }
8416
- var VERSION4 = "4.0.0";
8479
+ var VERSION4 = "4.0.19";
8417
8480
  var getOriginalFetch3 = () => globalThis.fetch;
8418
8481
  var getFromApi2 = async ({
8419
8482
  url,
@@ -8498,8 +8561,8 @@ function loadOptionalSetting2({
8498
8561
  }
8499
8562
  return settingValue;
8500
8563
  }
8501
- var suspectProtoRx2 = /"__proto__"\s*:/;
8502
- var suspectConstructorRx2 = /"constructor"\s*:/;
8564
+ var suspectProtoRx2 = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
8565
+ var suspectConstructorRx2 = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
8503
8566
  function _parse2(text4) {
8504
8567
  const obj = JSON.parse(text4);
8505
8568
  if (obj === null || typeof obj !== "object") {
@@ -8519,7 +8582,7 @@ function filter2(obj) {
8519
8582
  if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
8520
8583
  throw new SyntaxError("Object contains forbidden prototype property");
8521
8584
  }
8522
- if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
8585
+ if (Object.prototype.hasOwnProperty.call(node, "constructor") && node.constructor !== null && typeof node.constructor === "object" && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
8523
8586
  throw new SyntaxError("Object contains forbidden prototype property");
8524
8587
  }
8525
8588
  for (const key in node) {
@@ -8546,30 +8609,39 @@ function secureJsonParse2(text4) {
8546
8609
  }
8547
8610
  }
8548
8611
  function addAdditionalPropertiesToJsonSchema(jsonSchema22) {
8549
- if (jsonSchema22.type === "object") {
8612
+ if (jsonSchema22.type === "object" || Array.isArray(jsonSchema22.type) && jsonSchema22.type.includes("object")) {
8550
8613
  jsonSchema22.additionalProperties = false;
8551
- const properties = jsonSchema22.properties;
8614
+ const { properties } = jsonSchema22;
8552
8615
  if (properties != null) {
8553
- for (const property in properties) {
8554
- properties[property] = addAdditionalPropertiesToJsonSchema(
8555
- properties[property]
8556
- );
8616
+ for (const key of Object.keys(properties)) {
8617
+ properties[key] = visit(properties[key]);
8557
8618
  }
8558
8619
  }
8559
8620
  }
8560
- if (jsonSchema22.type === "array" && jsonSchema22.items != null) {
8561
- if (Array.isArray(jsonSchema22.items)) {
8562
- jsonSchema22.items = jsonSchema22.items.map(
8563
- (item) => addAdditionalPropertiesToJsonSchema(item)
8564
- );
8565
- } else {
8566
- jsonSchema22.items = addAdditionalPropertiesToJsonSchema(
8567
- jsonSchema22.items
8568
- );
8621
+ if (jsonSchema22.items != null) {
8622
+ jsonSchema22.items = Array.isArray(jsonSchema22.items) ? jsonSchema22.items.map(visit) : visit(jsonSchema22.items);
8623
+ }
8624
+ if (jsonSchema22.anyOf != null) {
8625
+ jsonSchema22.anyOf = jsonSchema22.anyOf.map(visit);
8626
+ }
8627
+ if (jsonSchema22.allOf != null) {
8628
+ jsonSchema22.allOf = jsonSchema22.allOf.map(visit);
8629
+ }
8630
+ if (jsonSchema22.oneOf != null) {
8631
+ jsonSchema22.oneOf = jsonSchema22.oneOf.map(visit);
8632
+ }
8633
+ const { definitions } = jsonSchema22;
8634
+ if (definitions != null) {
8635
+ for (const key of Object.keys(definitions)) {
8636
+ definitions[key] = visit(definitions[key]);
8569
8637
  }
8570
8638
  }
8571
8639
  return jsonSchema22;
8572
8640
  }
8641
+ function visit(def) {
8642
+ if (typeof def === "boolean") return def;
8643
+ return addAdditionalPropertiesToJsonSchema(def);
8644
+ }
8573
8645
  var ignoreOverride3 = /* @__PURE__ */ Symbol(
8574
8646
  "Let zodToJsonSchema decide on which parser to use"
8575
8647
  );
@@ -9686,9 +9758,11 @@ function asSchema3(schema) {
9686
9758
  }
9687
9759
  function standardSchema(standardSchema2) {
9688
9760
  return jsonSchema3(
9689
- () => standardSchema2["~standard"].jsonSchema.input({
9690
- target: "draft-07"
9691
- }),
9761
+ () => addAdditionalPropertiesToJsonSchema(
9762
+ standardSchema2["~standard"].jsonSchema.input({
9763
+ target: "draft-07"
9764
+ })
9765
+ ),
9692
9766
  {
9693
9767
  validate: async (value) => {
9694
9768
  const result = await standardSchema2["~standard"].validate(value);
@@ -9751,17 +9825,19 @@ function zodSchema3(zodSchema22, options) {
9751
9825
  }
9752
9826
  async function validateTypes2({
9753
9827
  value,
9754
- schema
9828
+ schema,
9829
+ context: context2
9755
9830
  }) {
9756
- const result = await safeValidateTypes3({ value, schema });
9831
+ const result = await safeValidateTypes3({ value, schema, context: context2 });
9757
9832
  if (!result.success) {
9758
- throw TypeValidationError3.wrap({ value, cause: result.error });
9833
+ throw TypeValidationError3.wrap({ value, cause: result.error, context: context2 });
9759
9834
  }
9760
9835
  return result.value;
9761
9836
  }
9762
9837
  async function safeValidateTypes3({
9763
9838
  value,
9764
- schema
9839
+ schema,
9840
+ context: context2
9765
9841
  }) {
9766
9842
  const actualSchema = asSchema3(schema);
9767
9843
  try {
@@ -9774,13 +9850,13 @@ async function safeValidateTypes3({
9774
9850
  }
9775
9851
  return {
9776
9852
  success: false,
9777
- error: TypeValidationError3.wrap({ value, cause: result.error }),
9853
+ error: TypeValidationError3.wrap({ value, cause: result.error, context: context2 }),
9778
9854
  rawValue: value
9779
9855
  };
9780
9856
  } catch (error) {
9781
9857
  return {
9782
9858
  success: false,
9783
- error: TypeValidationError3.wrap({ value, cause: error }),
9859
+ error: TypeValidationError3.wrap({ value, cause: error, context: context2 }),
9784
9860
  rawValue: value
9785
9861
  };
9786
9862
  }
@@ -9928,6 +10004,38 @@ var postToApi2 = async ({
9928
10004
  throw handleFetchError2({ error, url, requestBodyValues: body.values });
9929
10005
  }
9930
10006
  };
10007
+ function tool(tool2) {
10008
+ return tool2;
10009
+ }
10010
+ function createProviderToolFactoryWithOutputSchema({
10011
+ id,
10012
+ inputSchema,
10013
+ outputSchema: outputSchema3,
10014
+ supportsDeferredResults
10015
+ }) {
10016
+ return ({
10017
+ execute,
10018
+ needsApproval,
10019
+ toModelOutput,
10020
+ onInputStart,
10021
+ onInputDelta,
10022
+ onInputAvailable,
10023
+ ...args
10024
+ }) => tool({
10025
+ type: "provider",
10026
+ id,
10027
+ args,
10028
+ inputSchema,
10029
+ outputSchema: outputSchema3,
10030
+ execute,
10031
+ needsApproval,
10032
+ toModelOutput,
10033
+ onInputStart,
10034
+ onInputDelta,
10035
+ onInputAvailable,
10036
+ supportsDeferredResults
10037
+ });
10038
+ }
9931
10039
  async function resolve2(value) {
9932
10040
  if (typeof value === "function") {
9933
10041
  value = value();
@@ -10029,14 +10137,14 @@ function withoutTrailingSlash2(url) {
10029
10137
  return url == null ? void 0 : url.replace(/\/$/, "");
10030
10138
  }
10031
10139
  var require_get_context2 = __commonJS$1({
10032
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-context.js"(exports, module) {
10140
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/get-context.js"(exports$1, module) {
10033
10141
  var __defProp22 = Object.defineProperty;
10034
10142
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
10035
10143
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
10036
10144
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
10037
10145
  var __export22 = (target, all) => {
10038
- for (var name145 in all)
10039
- __defProp22(target, name145, { get: all[name145], enumerable: true });
10146
+ for (var name21 in all)
10147
+ __defProp22(target, name21, { get: all[name21], enumerable: true });
10040
10148
  };
10041
10149
  var __copyProps2 = (to, from, except, desc) => {
10042
10150
  if (from && typeof from === "object" || typeof from === "function") {
@@ -10061,14 +10169,14 @@ var require_get_context2 = __commonJS$1({
10061
10169
  }
10062
10170
  });
10063
10171
  var require_get_vercel_oidc_token2 = __commonJS$1({
10064
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports, module) {
10172
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports$1, module) {
10065
10173
  var __defProp22 = Object.defineProperty;
10066
10174
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
10067
10175
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
10068
10176
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
10069
10177
  var __export22 = (target, all) => {
10070
- for (var name145 in all)
10071
- __defProp22(target, name145, { get: all[name145], enumerable: true });
10178
+ for (var name21 in all)
10179
+ __defProp22(target, name21, { get: all[name21], enumerable: true });
10072
10180
  };
10073
10181
  var __copyProps2 = (to, from, except, desc) => {
10074
10182
  if (from && typeof from === "object" || typeof from === "function") {
@@ -10097,19 +10205,23 @@ var require_get_vercel_oidc_token2 = __commonJS$1({
10097
10205
  }
10098
10206
  try {
10099
10207
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
10100
- await import('./token-util-NEHG7TUY-KSXDO2NO.js'),
10101
- await import('./token-6GSAFR2W-K2BTU23I.js')
10208
+ await import('./token-util-RMHT2CPJ-RJEA3FAN.js'),
10209
+ await import('./token-APYSY3BW-2DN6RAUY.js')
10102
10210
  ]);
10103
10211
  if (!token || isExpired(getTokenPayload(token))) {
10104
10212
  await refreshToken();
10105
10213
  token = getVercelOidcTokenSync2();
10106
10214
  }
10107
10215
  } catch (error) {
10108
- if (err?.message && error instanceof Error) {
10109
- error.message = `${err.message}
10216
+ let message = err instanceof Error ? err.message : "";
10217
+ if (error instanceof Error) {
10218
+ message = `${message}
10110
10219
  ${error.message}`;
10111
10220
  }
10112
- throw new import_token_error.VercelOidcTokenError(`Failed to refresh OIDC token`, error);
10221
+ if (message) {
10222
+ throw new import_token_error.VercelOidcTokenError(message);
10223
+ }
10224
+ throw error;
10113
10225
  }
10114
10226
  return token;
10115
10227
  }
@@ -10125,14 +10237,14 @@ ${error.message}`;
10125
10237
  }
10126
10238
  });
10127
10239
  var require_dist2 = __commonJS$1({
10128
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/index.js"(exports, module) {
10240
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/index.js"(exports$1, module) {
10129
10241
  var __defProp22 = Object.defineProperty;
10130
10242
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
10131
10243
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
10132
10244
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
10133
10245
  var __export22 = (target, all) => {
10134
- for (var name145 in all)
10135
- __defProp22(target, name145, { get: all[name145], enumerable: true });
10246
+ for (var name21 in all)
10247
+ __defProp22(target, name21, { get: all[name21], enumerable: true });
10136
10248
  };
10137
10249
  var __copyProps2 = (to, from, except, desc) => {
10138
10250
  if (from && typeof from === "object" || typeof from === "function") {
@@ -10164,12 +10276,14 @@ var GatewayError2 = class _GatewayError2 extends (_b16 = Error, _a19 = symbol19,
10164
10276
  constructor({
10165
10277
  message,
10166
10278
  statusCode = 500,
10167
- cause
10279
+ cause,
10280
+ generationId
10168
10281
  }) {
10169
- super(message);
10282
+ super(generationId ? `${message} [${generationId}]` : message);
10170
10283
  this[_a19] = true;
10171
10284
  this.statusCode = statusCode;
10172
10285
  this.cause = cause;
10286
+ this.generationId = generationId;
10173
10287
  }
10174
10288
  /**
10175
10289
  * Checks if the given error is a Gateway Error.
@@ -10192,9 +10306,10 @@ var GatewayAuthenticationError2 = class _GatewayAuthenticationError2 extends (_b
10192
10306
  constructor({
10193
10307
  message = "Authentication failed",
10194
10308
  statusCode = 401,
10195
- cause
10309
+ cause,
10310
+ generationId
10196
10311
  } = {}) {
10197
- super({ message, statusCode, cause });
10312
+ super({ message, statusCode, cause, generationId });
10198
10313
  this[_a26] = true;
10199
10314
  this.name = name19;
10200
10315
  this.type = "authentication_error";
@@ -10210,7 +10325,8 @@ var GatewayAuthenticationError2 = class _GatewayAuthenticationError2 extends (_b
10210
10325
  oidcTokenProvided,
10211
10326
  message = "Authentication failed",
10212
10327
  statusCode = 401,
10213
- cause
10328
+ cause,
10329
+ generationId
10214
10330
  }) {
10215
10331
  let contextualMessage;
10216
10332
  if (apiKeyProvided) {
@@ -10238,7 +10354,8 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
10238
10354
  return new _GatewayAuthenticationError2({
10239
10355
  message: contextualMessage,
10240
10356
  statusCode,
10241
- cause
10357
+ cause,
10358
+ generationId
10242
10359
  });
10243
10360
  }
10244
10361
  };
@@ -10251,9 +10368,10 @@ var GatewayInvalidRequestError2 = class extends (_b33 = GatewayError2, _a36 = sy
10251
10368
  constructor({
10252
10369
  message = "Invalid request",
10253
10370
  statusCode = 400,
10254
- cause
10371
+ cause,
10372
+ generationId
10255
10373
  } = {}) {
10256
- super({ message, statusCode, cause });
10374
+ super({ message, statusCode, cause, generationId });
10257
10375
  this[_a36] = true;
10258
10376
  this.name = name26;
10259
10377
  this.type = "invalid_request_error";
@@ -10271,9 +10389,10 @@ var GatewayRateLimitError2 = class extends (_b43 = GatewayError2, _a46 = symbol4
10271
10389
  constructor({
10272
10390
  message = "Rate limit exceeded",
10273
10391
  statusCode = 429,
10274
- cause
10392
+ cause,
10393
+ generationId
10275
10394
  } = {}) {
10276
- super({ message, statusCode, cause });
10395
+ super({ message, statusCode, cause, generationId });
10277
10396
  this[_a46] = true;
10278
10397
  this.name = name36;
10279
10398
  this.type = "rate_limit_exceeded";
@@ -10299,9 +10418,10 @@ var GatewayModelNotFoundError2 = class extends (_b53 = GatewayError2, _a56 = sym
10299
10418
  message = "Model not found",
10300
10419
  statusCode = 404,
10301
10420
  modelId,
10302
- cause
10421
+ cause,
10422
+ generationId
10303
10423
  } = {}) {
10304
- super({ message, statusCode, cause });
10424
+ super({ message, statusCode, cause, generationId });
10305
10425
  this[_a56] = true;
10306
10426
  this.name = name46;
10307
10427
  this.type = "model_not_found";
@@ -10320,9 +10440,10 @@ var GatewayInternalServerError2 = class extends (_b63 = GatewayError2, _a66 = sy
10320
10440
  constructor({
10321
10441
  message = "Internal server error",
10322
10442
  statusCode = 500,
10323
- cause
10443
+ cause,
10444
+ generationId
10324
10445
  } = {}) {
10325
- super({ message, statusCode, cause });
10446
+ super({ message, statusCode, cause, generationId });
10326
10447
  this[_a66] = true;
10327
10448
  this.name = name56;
10328
10449
  this.type = "internal_server_error";
@@ -10342,9 +10463,10 @@ var GatewayResponseError2 = class extends (_b73 = GatewayError2, _a76 = symbol76
10342
10463
  statusCode = 502,
10343
10464
  response,
10344
10465
  validationError,
10345
- cause
10466
+ cause,
10467
+ generationId
10346
10468
  } = {}) {
10347
- super({ message, statusCode, cause });
10469
+ super({ message, statusCode, cause, generationId });
10348
10470
  this[_a76] = true;
10349
10471
  this.name = name66;
10350
10472
  this.type = "response_error";
@@ -10362,34 +10484,49 @@ async function createGatewayErrorFromResponse2({
10362
10484
  cause,
10363
10485
  authMethod
10364
10486
  }) {
10487
+ var _a932;
10365
10488
  const parseResult = await safeValidateTypes3({
10366
10489
  value: response,
10367
10490
  schema: gatewayErrorResponseSchema2
10368
10491
  });
10369
10492
  if (!parseResult.success) {
10493
+ const rawGenerationId = typeof response === "object" && response !== null && "generationId" in response ? response.generationId : void 0;
10370
10494
  return new GatewayResponseError2({
10371
10495
  message: `Invalid error response format: ${defaultMessage}`,
10372
10496
  statusCode,
10373
10497
  response,
10374
10498
  validationError: parseResult.error,
10375
- cause
10499
+ cause,
10500
+ generationId: rawGenerationId
10376
10501
  });
10377
10502
  }
10378
10503
  const validatedResponse = parseResult.value;
10379
10504
  const errorType = validatedResponse.error.type;
10380
10505
  const message = validatedResponse.error.message;
10506
+ const generationId = (_a932 = validatedResponse.generationId) != null ? _a932 : void 0;
10381
10507
  switch (errorType) {
10382
10508
  case "authentication_error":
10383
10509
  return GatewayAuthenticationError2.createContextualError({
10384
10510
  apiKeyProvided: authMethod === "api-key",
10385
10511
  oidcTokenProvided: authMethod === "oidc",
10386
10512
  statusCode,
10387
- cause
10513
+ cause,
10514
+ generationId
10388
10515
  });
10389
10516
  case "invalid_request_error":
10390
- return new GatewayInvalidRequestError2({ message, statusCode, cause });
10517
+ return new GatewayInvalidRequestError2({
10518
+ message,
10519
+ statusCode,
10520
+ cause,
10521
+ generationId
10522
+ });
10391
10523
  case "rate_limit_exceeded":
10392
- return new GatewayRateLimitError2({ message, statusCode, cause });
10524
+ return new GatewayRateLimitError2({
10525
+ message,
10526
+ statusCode,
10527
+ cause,
10528
+ generationId
10529
+ });
10393
10530
  case "model_not_found": {
10394
10531
  const modelResult = await safeValidateTypes3({
10395
10532
  value: validatedResponse.error.param,
@@ -10399,13 +10536,24 @@ async function createGatewayErrorFromResponse2({
10399
10536
  message,
10400
10537
  statusCode,
10401
10538
  modelId: modelResult.success ? modelResult.value.modelId : void 0,
10402
- cause
10539
+ cause,
10540
+ generationId
10403
10541
  });
10404
10542
  }
10405
10543
  case "internal_server_error":
10406
- return new GatewayInternalServerError2({ message, statusCode, cause });
10544
+ return new GatewayInternalServerError2({
10545
+ message,
10546
+ statusCode,
10547
+ cause,
10548
+ generationId
10549
+ });
10407
10550
  default:
10408
- return new GatewayInternalServerError2({ message, statusCode, cause });
10551
+ return new GatewayInternalServerError2({
10552
+ message,
10553
+ statusCode,
10554
+ cause,
10555
+ generationId
10556
+ });
10409
10557
  }
10410
10558
  }
10411
10559
  var gatewayErrorResponseSchema2 = lazySchema(
@@ -10416,25 +10564,93 @@ var gatewayErrorResponseSchema2 = lazySchema(
10416
10564
  type: z.string().nullish(),
10417
10565
  param: z.unknown().nullish(),
10418
10566
  code: z.union([z.string(), z.number()]).nullish()
10419
- })
10567
+ }),
10568
+ generationId: z.string().nullish()
10420
10569
  })
10421
10570
  )
10422
10571
  );
10423
- function asGatewayError2(error, authMethod) {
10424
- var _a832;
10572
+ var name76 = "GatewayTimeoutError";
10573
+ var marker86 = `vercel.ai.gateway.error.${name76}`;
10574
+ var symbol86 = Symbol.for(marker86);
10575
+ var _a86;
10576
+ var _b83;
10577
+ var GatewayTimeoutError = class _GatewayTimeoutError extends (_b83 = GatewayError2, _a86 = symbol86, _b83) {
10578
+ constructor({
10579
+ message = "Request timed out",
10580
+ statusCode = 408,
10581
+ cause,
10582
+ generationId
10583
+ } = {}) {
10584
+ super({ message, statusCode, cause, generationId });
10585
+ this[_a86] = true;
10586
+ this.name = name76;
10587
+ this.type = "timeout_error";
10588
+ }
10589
+ static isInstance(error) {
10590
+ return GatewayError2.hasMarker(error) && symbol86 in error;
10591
+ }
10592
+ /**
10593
+ * Creates a helpful timeout error message with troubleshooting guidance
10594
+ */
10595
+ static createTimeoutError({
10596
+ originalMessage,
10597
+ statusCode = 408,
10598
+ cause,
10599
+ generationId
10600
+ }) {
10601
+ const message = `Gateway request timed out: ${originalMessage}
10602
+
10603
+ This is a client-side timeout. To resolve this, increase your timeout configuration: https://vercel.com/docs/ai-gateway/capabilities/video-generation#extending-timeouts-for-node.js`;
10604
+ return new _GatewayTimeoutError({
10605
+ message,
10606
+ statusCode,
10607
+ cause,
10608
+ generationId
10609
+ });
10610
+ }
10611
+ };
10612
+ function isTimeoutError(error) {
10613
+ if (!(error instanceof Error)) {
10614
+ return false;
10615
+ }
10616
+ const errorCode = error.code;
10617
+ if (typeof errorCode === "string") {
10618
+ const undiciTimeoutCodes = [
10619
+ "UND_ERR_HEADERS_TIMEOUT",
10620
+ "UND_ERR_BODY_TIMEOUT",
10621
+ "UND_ERR_CONNECT_TIMEOUT"
10622
+ ];
10623
+ return undiciTimeoutCodes.includes(errorCode);
10624
+ }
10625
+ return false;
10626
+ }
10627
+ async function asGatewayError2(error, authMethod) {
10628
+ var _a932;
10425
10629
  if (GatewayError2.isInstance(error)) {
10426
10630
  return error;
10427
10631
  }
10632
+ if (isTimeoutError(error)) {
10633
+ return GatewayTimeoutError.createTimeoutError({
10634
+ originalMessage: error instanceof Error ? error.message : "Unknown error",
10635
+ cause: error
10636
+ });
10637
+ }
10428
10638
  if (APICallError3.isInstance(error)) {
10429
- return createGatewayErrorFromResponse2({
10639
+ if (error.cause && isTimeoutError(error.cause)) {
10640
+ return GatewayTimeoutError.createTimeoutError({
10641
+ originalMessage: error.message,
10642
+ cause: error
10643
+ });
10644
+ }
10645
+ return await createGatewayErrorFromResponse2({
10430
10646
  response: extractApiCallResponse2(error),
10431
- statusCode: (_a832 = error.statusCode) != null ? _a832 : 500,
10647
+ statusCode: (_a932 = error.statusCode) != null ? _a932 : 500,
10432
10648
  defaultMessage: "Gateway request failed",
10433
10649
  cause: error,
10434
10650
  authMethod
10435
10651
  });
10436
10652
  }
10437
- return createGatewayErrorFromResponse2({
10653
+ return await createGatewayErrorFromResponse2({
10438
10654
  response: {},
10439
10655
  statusCode: 500,
10440
10656
  defaultMessage: error instanceof Error ? `Gateway request failed: ${error.message}` : "Unknown Gateway error",
@@ -10536,7 +10752,7 @@ var gatewayAvailableModelsResponseSchema2 = lazySchema(
10536
10752
  provider: z.string(),
10537
10753
  modelId: z.string()
10538
10754
  }),
10539
- modelType: z.enum(["language", "embedding", "image"]).nullish()
10755
+ modelType: z.enum(["embedding", "image", "language", "video"]).nullish()
10540
10756
  })
10541
10757
  )
10542
10758
  })
@@ -10692,7 +10908,7 @@ var GatewayLanguageModel2 = class {
10692
10908
  }
10693
10909
  getModelConfigHeaders(modelId, streaming) {
10694
10910
  return {
10695
- "ai-language-model-specification-version": "2",
10911
+ "ai-language-model-specification-version": "3",
10696
10912
  "ai-language-model-id": modelId,
10697
10913
  "ai-language-model-streaming": String(streaming)
10698
10914
  };
@@ -10715,7 +10931,7 @@ var GatewayEmbeddingModel2 = class {
10715
10931
  abortSignal,
10716
10932
  providerOptions
10717
10933
  }) {
10718
- var _a832;
10934
+ var _a932;
10719
10935
  const resolvedHeaders = await resolve2(this.config.headers());
10720
10936
  try {
10721
10937
  const {
@@ -10746,7 +10962,7 @@ var GatewayEmbeddingModel2 = class {
10746
10962
  });
10747
10963
  return {
10748
10964
  embeddings: responseBody.embeddings,
10749
- usage: (_a832 = responseBody.usage) != null ? _a832 : void 0,
10965
+ usage: (_a932 = responseBody.usage) != null ? _a932 : void 0,
10750
10966
  providerMetadata: responseBody.providerMetadata,
10751
10967
  response: { headers: responseHeaders, body: rawValue },
10752
10968
  warnings: []
@@ -10760,7 +10976,7 @@ var GatewayEmbeddingModel2 = class {
10760
10976
  }
10761
10977
  getModelConfigHeaders() {
10762
10978
  return {
10763
- "ai-embedding-model-specification-version": "2",
10979
+ "ai-embedding-model-specification-version": "3",
10764
10980
  "ai-model-id": this.modelId
10765
10981
  };
10766
10982
  }
@@ -10790,11 +11006,13 @@ var GatewayImageModel2 = class {
10790
11006
  size,
10791
11007
  aspectRatio,
10792
11008
  seed,
11009
+ files,
11010
+ mask,
10793
11011
  providerOptions,
10794
11012
  headers,
10795
11013
  abortSignal
10796
11014
  }) {
10797
- var _a832;
11015
+ var _a932, _b92, _c, _d;
10798
11016
  const resolvedHeaders = await resolve2(this.config.headers());
10799
11017
  try {
10800
11018
  const {
@@ -10814,7 +11032,11 @@ var GatewayImageModel2 = class {
10814
11032
  ...size && { size },
10815
11033
  ...aspectRatio && { aspectRatio },
10816
11034
  ...seed && { seed },
10817
- ...providerOptions && { providerOptions }
11035
+ ...providerOptions && { providerOptions },
11036
+ ...files && {
11037
+ files: files.map((file) => maybeEncodeImageFile(file))
11038
+ },
11039
+ ...mask && { mask: maybeEncodeImageFile(mask) }
10818
11040
  },
10819
11041
  successfulResponseHandler: createJsonResponseHandler2(
10820
11042
  gatewayImageResponseSchema2
@@ -10829,16 +11051,23 @@ var GatewayImageModel2 = class {
10829
11051
  return {
10830
11052
  images: responseBody.images,
10831
11053
  // Always base64 strings from server
10832
- warnings: (_a832 = responseBody.warnings) != null ? _a832 : [],
11054
+ warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
10833
11055
  providerMetadata: responseBody.providerMetadata,
10834
11056
  response: {
10835
11057
  timestamp: /* @__PURE__ */ new Date(),
10836
11058
  modelId: this.modelId,
10837
11059
  headers: responseHeaders
11060
+ },
11061
+ ...responseBody.usage != null && {
11062
+ usage: {
11063
+ inputTokens: (_b92 = responseBody.usage.inputTokens) != null ? _b92 : void 0,
11064
+ outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : void 0,
11065
+ totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : void 0
11066
+ }
10838
11067
  }
10839
11068
  };
10840
11069
  } catch (error) {
10841
- throw asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
11070
+ throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
10842
11071
  }
10843
11072
  }
10844
11073
  getUrl() {
@@ -10846,41 +11075,435 @@ var GatewayImageModel2 = class {
10846
11075
  }
10847
11076
  getModelConfigHeaders() {
10848
11077
  return {
10849
- "ai-image-model-specification-version": "2",
11078
+ "ai-image-model-specification-version": "3",
10850
11079
  "ai-model-id": this.modelId
10851
11080
  };
10852
11081
  }
10853
11082
  };
11083
+ function maybeEncodeImageFile(file) {
11084
+ if (file.type === "file" && file.data instanceof Uint8Array) {
11085
+ return {
11086
+ ...file,
11087
+ data: convertUint8ArrayToBase643(file.data)
11088
+ };
11089
+ }
11090
+ return file;
11091
+ }
10854
11092
  var providerMetadataEntrySchema2 = z.object({
10855
11093
  images: z.array(z.unknown()).optional()
10856
11094
  }).catchall(z.unknown());
11095
+ var gatewayImageWarningSchema = z.discriminatedUnion("type", [
11096
+ z.object({
11097
+ type: z.literal("unsupported"),
11098
+ feature: z.string(),
11099
+ details: z.string().optional()
11100
+ }),
11101
+ z.object({
11102
+ type: z.literal("compatibility"),
11103
+ feature: z.string(),
11104
+ details: z.string().optional()
11105
+ }),
11106
+ z.object({
11107
+ type: z.literal("other"),
11108
+ message: z.string()
11109
+ })
11110
+ ]);
11111
+ var gatewayImageUsageSchema = z.object({
11112
+ inputTokens: z.number().nullish(),
11113
+ outputTokens: z.number().nullish(),
11114
+ totalTokens: z.number().nullish()
11115
+ });
10857
11116
  var gatewayImageResponseSchema2 = z.object({
10858
11117
  images: z.array(z.string()),
10859
11118
  // Always base64 strings over the wire
10860
- warnings: z.array(
10861
- z.object({
10862
- type: z.literal("other"),
10863
- message: z.string()
11119
+ warnings: z.array(gatewayImageWarningSchema).optional(),
11120
+ providerMetadata: z.record(z.string(), providerMetadataEntrySchema2).optional(),
11121
+ usage: gatewayImageUsageSchema.optional()
11122
+ });
11123
+ var GatewayVideoModel = class {
11124
+ constructor(modelId, config) {
11125
+ this.modelId = modelId;
11126
+ this.config = config;
11127
+ this.specificationVersion = "v3";
11128
+ this.maxVideosPerCall = Number.MAX_SAFE_INTEGER;
11129
+ }
11130
+ get provider() {
11131
+ return this.config.provider;
11132
+ }
11133
+ async doGenerate({
11134
+ prompt,
11135
+ n,
11136
+ aspectRatio,
11137
+ resolution,
11138
+ duration,
11139
+ fps,
11140
+ seed,
11141
+ image,
11142
+ providerOptions,
11143
+ headers,
11144
+ abortSignal
11145
+ }) {
11146
+ var _a932;
11147
+ const resolvedHeaders = await resolve2(this.config.headers());
11148
+ try {
11149
+ const { responseHeaders, value: responseBody } = await postJsonToApi2({
11150
+ url: this.getUrl(),
11151
+ headers: combineHeaders2(
11152
+ resolvedHeaders,
11153
+ headers != null ? headers : {},
11154
+ this.getModelConfigHeaders(),
11155
+ await resolve2(this.config.o11yHeaders),
11156
+ { accept: "text/event-stream" }
11157
+ ),
11158
+ body: {
11159
+ prompt,
11160
+ n,
11161
+ ...aspectRatio && { aspectRatio },
11162
+ ...resolution && { resolution },
11163
+ ...duration && { duration },
11164
+ ...fps && { fps },
11165
+ ...seed && { seed },
11166
+ ...providerOptions && { providerOptions },
11167
+ ...image && { image: maybeEncodeVideoFile(image) }
11168
+ },
11169
+ successfulResponseHandler: async ({
11170
+ response,
11171
+ url,
11172
+ requestBodyValues
11173
+ }) => {
11174
+ if (response.body == null) {
11175
+ throw new APICallError3({
11176
+ message: "SSE response body is empty",
11177
+ url,
11178
+ requestBodyValues,
11179
+ statusCode: response.status
11180
+ });
11181
+ }
11182
+ const eventStream = parseJsonEventStream2({
11183
+ stream: response.body,
11184
+ schema: gatewayVideoEventSchema
11185
+ });
11186
+ const reader = eventStream.getReader();
11187
+ const { done, value: parseResult } = await reader.read();
11188
+ reader.releaseLock();
11189
+ if (done || !parseResult) {
11190
+ throw new APICallError3({
11191
+ message: "SSE stream ended without a data event",
11192
+ url,
11193
+ requestBodyValues,
11194
+ statusCode: response.status
11195
+ });
11196
+ }
11197
+ if (!parseResult.success) {
11198
+ throw new APICallError3({
11199
+ message: "Failed to parse video SSE event",
11200
+ cause: parseResult.error,
11201
+ url,
11202
+ requestBodyValues,
11203
+ statusCode: response.status
11204
+ });
11205
+ }
11206
+ const event = parseResult.value;
11207
+ if (event.type === "error") {
11208
+ throw new APICallError3({
11209
+ message: event.message,
11210
+ statusCode: event.statusCode,
11211
+ url,
11212
+ requestBodyValues,
11213
+ responseHeaders: Object.fromEntries([...response.headers]),
11214
+ responseBody: JSON.stringify(event),
11215
+ data: {
11216
+ error: {
11217
+ message: event.message,
11218
+ type: event.errorType,
11219
+ param: event.param
11220
+ }
11221
+ }
11222
+ });
11223
+ }
11224
+ return {
11225
+ value: {
11226
+ videos: event.videos,
11227
+ warnings: event.warnings,
11228
+ providerMetadata: event.providerMetadata
11229
+ },
11230
+ responseHeaders: Object.fromEntries([...response.headers])
11231
+ };
11232
+ },
11233
+ failedResponseHandler: createJsonErrorResponseHandler2({
11234
+ errorSchema: z.any(),
11235
+ errorToMessage: (data) => data
11236
+ }),
11237
+ ...abortSignal && { abortSignal },
11238
+ fetch: this.config.fetch
11239
+ });
11240
+ return {
11241
+ videos: responseBody.videos,
11242
+ warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
11243
+ providerMetadata: responseBody.providerMetadata,
11244
+ response: {
11245
+ timestamp: /* @__PURE__ */ new Date(),
11246
+ modelId: this.modelId,
11247
+ headers: responseHeaders
11248
+ }
11249
+ };
11250
+ } catch (error) {
11251
+ throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
11252
+ }
11253
+ }
11254
+ getUrl() {
11255
+ return `${this.config.baseURL}/video-model`;
11256
+ }
11257
+ getModelConfigHeaders() {
11258
+ return {
11259
+ "ai-video-model-specification-version": "3",
11260
+ "ai-model-id": this.modelId
11261
+ };
11262
+ }
11263
+ };
11264
+ function maybeEncodeVideoFile(file) {
11265
+ if (file.type === "file" && file.data instanceof Uint8Array) {
11266
+ return {
11267
+ ...file,
11268
+ data: convertUint8ArrayToBase643(file.data)
11269
+ };
11270
+ }
11271
+ return file;
11272
+ }
11273
+ var providerMetadataEntrySchema22 = z.object({
11274
+ videos: z.array(z.unknown()).optional()
11275
+ }).catchall(z.unknown());
11276
+ var gatewayVideoDataSchema = z.union([
11277
+ z.object({
11278
+ type: z.literal("url"),
11279
+ url: z.string(),
11280
+ mediaType: z.string()
11281
+ }),
11282
+ z.object({
11283
+ type: z.literal("base64"),
11284
+ data: z.string(),
11285
+ mediaType: z.string()
11286
+ })
11287
+ ]);
11288
+ var gatewayVideoWarningSchema = z.discriminatedUnion("type", [
11289
+ z.object({
11290
+ type: z.literal("unsupported"),
11291
+ feature: z.string(),
11292
+ details: z.string().optional()
11293
+ }),
11294
+ z.object({
11295
+ type: z.literal("compatibility"),
11296
+ feature: z.string(),
11297
+ details: z.string().optional()
11298
+ }),
11299
+ z.object({
11300
+ type: z.literal("other"),
11301
+ message: z.string()
11302
+ })
11303
+ ]);
11304
+ var gatewayVideoEventSchema = z.discriminatedUnion("type", [
11305
+ z.object({
11306
+ type: z.literal("result"),
11307
+ videos: z.array(gatewayVideoDataSchema),
11308
+ warnings: z.array(gatewayVideoWarningSchema).optional(),
11309
+ providerMetadata: z.record(z.string(), providerMetadataEntrySchema22).optional()
11310
+ }),
11311
+ z.object({
11312
+ type: z.literal("error"),
11313
+ message: z.string(),
11314
+ errorType: z.string(),
11315
+ statusCode: z.number(),
11316
+ param: z.unknown().nullable()
11317
+ })
11318
+ ]);
11319
+ var parallelSearchInputSchema = lazySchema(
11320
+ () => zodSchema3(
11321
+ z$1.object({
11322
+ objective: z$1.string().describe(
11323
+ "Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
11324
+ ),
11325
+ search_queries: z$1.array(z$1.string()).optional().describe(
11326
+ "Optional search queries to supplement the objective. Maximum 200 characters per query."
11327
+ ),
11328
+ mode: z$1.enum(["one-shot", "agentic"]).optional().describe(
11329
+ 'Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'
11330
+ ),
11331
+ max_results: z$1.number().optional().describe(
11332
+ "Maximum number of results to return (1-20). Defaults to 10 if not specified."
11333
+ ),
11334
+ source_policy: z$1.object({
11335
+ include_domains: z$1.array(z$1.string()).optional().describe("List of domains to include in search results."),
11336
+ exclude_domains: z$1.array(z$1.string()).optional().describe("List of domains to exclude from search results."),
11337
+ after_date: z$1.string().optional().describe(
11338
+ "Only include results published after this date (ISO 8601 format)."
11339
+ )
11340
+ }).optional().describe(
11341
+ "Source policy for controlling which domains to include/exclude and freshness."
11342
+ ),
11343
+ excerpts: z$1.object({
11344
+ max_chars_per_result: z$1.number().optional().describe("Maximum characters per result."),
11345
+ max_chars_total: z$1.number().optional().describe("Maximum total characters across all results.")
11346
+ }).optional().describe("Excerpt configuration for controlling result length."),
11347
+ fetch_policy: z$1.object({
11348
+ max_age_seconds: z$1.number().optional().describe(
11349
+ "Maximum age in seconds for cached content. Set to 0 to always fetch fresh content."
11350
+ )
11351
+ }).optional().describe("Fetch policy for controlling content freshness.")
10864
11352
  })
10865
- ).optional(),
10866
- providerMetadata: z.record(z.string(), providerMetadataEntrySchema2).optional()
11353
+ )
11354
+ );
11355
+ var parallelSearchOutputSchema = lazySchema(
11356
+ () => zodSchema3(
11357
+ z$1.union([
11358
+ // Success response
11359
+ z$1.object({
11360
+ searchId: z$1.string(),
11361
+ results: z$1.array(
11362
+ z$1.object({
11363
+ url: z$1.string(),
11364
+ title: z$1.string(),
11365
+ excerpt: z$1.string(),
11366
+ publishDate: z$1.string().nullable().optional(),
11367
+ relevanceScore: z$1.number().optional()
11368
+ })
11369
+ )
11370
+ }),
11371
+ // Error response
11372
+ z$1.object({
11373
+ error: z$1.enum([
11374
+ "api_error",
11375
+ "rate_limit",
11376
+ "timeout",
11377
+ "invalid_input",
11378
+ "configuration_error",
11379
+ "unknown"
11380
+ ]),
11381
+ statusCode: z$1.number().optional(),
11382
+ message: z$1.string()
11383
+ })
11384
+ ])
11385
+ )
11386
+ );
11387
+ var parallelSearchToolFactory = createProviderToolFactoryWithOutputSchema({
11388
+ id: "gateway.parallel_search",
11389
+ inputSchema: parallelSearchInputSchema,
11390
+ outputSchema: parallelSearchOutputSchema
11391
+ });
11392
+ var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
11393
+ var perplexitySearchInputSchema = lazySchema(
11394
+ () => zodSchema3(
11395
+ z$1.object({
11396
+ query: z$1.union([z$1.string(), z$1.array(z$1.string())]).describe(
11397
+ "Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
11398
+ ),
11399
+ max_results: z$1.number().optional().describe(
11400
+ "Maximum number of search results to return (1-20, default: 10)"
11401
+ ),
11402
+ max_tokens_per_page: z$1.number().optional().describe(
11403
+ "Maximum number of tokens to extract per search result page (256-2048, default: 2048)"
11404
+ ),
11405
+ max_tokens: z$1.number().optional().describe(
11406
+ "Maximum total tokens across all search results (default: 25000, max: 1000000)"
11407
+ ),
11408
+ country: z$1.string().optional().describe(
11409
+ "Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"
11410
+ ),
11411
+ search_domain_filter: z$1.array(z$1.string()).optional().describe(
11412
+ "List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"
11413
+ ),
11414
+ search_language_filter: z$1.array(z$1.string()).optional().describe(
11415
+ "List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"
11416
+ ),
11417
+ search_after_date: z$1.string().optional().describe(
11418
+ "Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
11419
+ ),
11420
+ search_before_date: z$1.string().optional().describe(
11421
+ "Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
11422
+ ),
11423
+ last_updated_after_filter: z$1.string().optional().describe(
11424
+ "Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
11425
+ ),
11426
+ last_updated_before_filter: z$1.string().optional().describe(
11427
+ "Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
11428
+ ),
11429
+ search_recency_filter: z$1.enum(["day", "week", "month", "year"]).optional().describe(
11430
+ "Filter results by relative time period. Cannot be used with search_after_date or search_before_date."
11431
+ )
11432
+ })
11433
+ )
11434
+ );
11435
+ var perplexitySearchOutputSchema = lazySchema(
11436
+ () => zodSchema3(
11437
+ z$1.union([
11438
+ // Success response
11439
+ z$1.object({
11440
+ results: z$1.array(
11441
+ z$1.object({
11442
+ title: z$1.string(),
11443
+ url: z$1.string(),
11444
+ snippet: z$1.string(),
11445
+ date: z$1.string().optional(),
11446
+ lastUpdated: z$1.string().optional()
11447
+ })
11448
+ ),
11449
+ id: z$1.string()
11450
+ }),
11451
+ // Error response
11452
+ z$1.object({
11453
+ error: z$1.enum([
11454
+ "api_error",
11455
+ "rate_limit",
11456
+ "timeout",
11457
+ "invalid_input",
11458
+ "unknown"
11459
+ ]),
11460
+ statusCode: z$1.number().optional(),
11461
+ message: z$1.string()
11462
+ })
11463
+ ])
11464
+ )
11465
+ );
11466
+ var perplexitySearchToolFactory = createProviderToolFactoryWithOutputSchema({
11467
+ id: "gateway.perplexity_search",
11468
+ inputSchema: perplexitySearchInputSchema,
11469
+ outputSchema: perplexitySearchOutputSchema
10867
11470
  });
11471
+ var perplexitySearch = (config = {}) => perplexitySearchToolFactory(config);
11472
+ var gatewayTools = {
11473
+ /**
11474
+ * Search the web using Parallel AI's Search API for LLM-optimized excerpts.
11475
+ *
11476
+ * Takes a natural language objective and returns relevant excerpts,
11477
+ * replacing multiple keyword searches with a single call for broad
11478
+ * or complex queries. Supports different search types for depth vs
11479
+ * breadth tradeoffs.
11480
+ */
11481
+ parallelSearch,
11482
+ /**
11483
+ * Search the web using Perplexity's Search API for real-time information,
11484
+ * news, research papers, and articles.
11485
+ *
11486
+ * Provides ranked search results with advanced filtering options including
11487
+ * domain, language, date range, and recency filters.
11488
+ */
11489
+ perplexitySearch
11490
+ };
10868
11491
  async function getVercelRequestId2() {
10869
- var _a832;
10870
- return (_a832 = (0, import_oidc3.getContext)().headers) == null ? void 0 : _a832["x-vercel-id"];
11492
+ var _a932;
11493
+ return (_a932 = (0, import_oidc3.getContext)().headers) == null ? void 0 : _a932["x-vercel-id"];
10871
11494
  }
10872
- var VERSION5 = "3.0.0";
11495
+ var VERSION5 = "3.0.66";
10873
11496
  var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
10874
11497
  function createGatewayProvider2(options = {}) {
10875
- var _a832, _b83;
11498
+ var _a932, _b92;
10876
11499
  let pendingMetadata = null;
10877
11500
  let metadataCache = null;
10878
- const cacheRefreshMillis = (_a832 = options.metadataCacheRefreshMillis) != null ? _a832 : 1e3 * 60 * 5;
11501
+ const cacheRefreshMillis = (_a932 = options.metadataCacheRefreshMillis) != null ? _a932 : 1e3 * 60 * 5;
10879
11502
  let lastFetchTime = 0;
10880
- const baseURL = (_b83 = withoutTrailingSlash2(options.baseURL)) != null ? _b83 : "https://ai-gateway.vercel.sh/v3/ai";
11503
+ const baseURL = (_b92 = withoutTrailingSlash2(options.baseURL)) != null ? _b92 : "https://ai-gateway.vercel.sh/v3/ai";
10881
11504
  const getHeaders = async () => {
10882
- const auth = await getGatewayAuthToken2(options);
10883
- if (auth) {
11505
+ try {
11506
+ const auth = await getGatewayAuthToken2(options);
10884
11507
  return withUserAgentSuffix2(
10885
11508
  {
10886
11509
  Authorization: `Bearer ${auth.token}`,
@@ -10890,12 +11513,14 @@ function createGatewayProvider2(options = {}) {
10890
11513
  },
10891
11514
  `ai-sdk/gateway/${VERSION5}`
10892
11515
  );
11516
+ } catch (error) {
11517
+ throw GatewayAuthenticationError2.createContextualError({
11518
+ apiKeyProvided: false,
11519
+ oidcTokenProvided: false,
11520
+ statusCode: 401,
11521
+ cause: error
11522
+ });
10893
11523
  }
10894
- throw GatewayAuthenticationError2.createContextualError({
10895
- apiKeyProvided: false,
10896
- oidcTokenProvided: false,
10897
- statusCode: 401
10898
- });
10899
11524
  };
10900
11525
  const createO11yHeaders = () => {
10901
11526
  const deploymentId = loadOptionalSetting2({
@@ -10910,13 +11535,18 @@ function createGatewayProvider2(options = {}) {
10910
11535
  settingValue: void 0,
10911
11536
  environmentVariableName: "VERCEL_REGION"
10912
11537
  });
11538
+ const projectId = loadOptionalSetting2({
11539
+ settingValue: void 0,
11540
+ environmentVariableName: "VERCEL_PROJECT_ID"
11541
+ });
10913
11542
  return async () => {
10914
11543
  const requestId = await getVercelRequestId2();
10915
11544
  return {
10916
11545
  ...deploymentId && { "ai-o11y-deployment-id": deploymentId },
10917
11546
  ...environment && { "ai-o11y-environment": environment },
10918
11547
  ...region && { "ai-o11y-region": region },
10919
- ...requestId && { "ai-o11y-request-id": requestId }
11548
+ ...requestId && { "ai-o11y-request-id": requestId },
11549
+ ...projectId && { "ai-o11y-project-id": projectId }
10920
11550
  };
10921
11551
  };
10922
11552
  };
@@ -10930,8 +11560,8 @@ function createGatewayProvider2(options = {}) {
10930
11560
  });
10931
11561
  };
10932
11562
  const getAvailableModels = async () => {
10933
- var _a922, _b92, _c;
10934
- const now2 = (_c = (_b92 = (_a922 = options._internal) == null ? void 0 : _a922.currentDate) == null ? void 0 : _b92.call(_a922).getTime()) != null ? _c : Date.now();
11563
+ var _a1022, _b102, _c;
11564
+ const now2 = (_c = (_b102 = (_a1022 = options._internal) == null ? void 0 : _a1022.currentDate) == null ? void 0 : _b102.call(_a1022).getTime()) != null ? _c : Date.now();
10935
11565
  if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
10936
11566
  lastFetchTime = now2;
10937
11567
  pendingMetadata = new GatewayFetchMetadata2({
@@ -10994,6 +11624,20 @@ function createGatewayProvider2(options = {}) {
10994
11624
  };
10995
11625
  provider.embeddingModel = createEmbeddingModel;
10996
11626
  provider.textEmbeddingModel = createEmbeddingModel;
11627
+ provider.videoModel = (modelId) => {
11628
+ return new GatewayVideoModel(modelId, {
11629
+ provider: "gateway",
11630
+ baseURL,
11631
+ headers: getHeaders,
11632
+ fetch: options.fetch,
11633
+ o11yHeaders: createO11yHeaders()
11634
+ });
11635
+ };
11636
+ provider.chat = provider.languageModel;
11637
+ provider.embedding = provider.embeddingModel;
11638
+ provider.image = provider.imageModel;
11639
+ provider.video = provider.videoModel;
11640
+ provider.tools = gatewayTools;
10997
11641
  return provider;
10998
11642
  }
10999
11643
  createGatewayProvider2();
@@ -11008,15 +11652,11 @@ async function getGatewayAuthToken2(options) {
11008
11652
  authMethod: "api-key"
11009
11653
  };
11010
11654
  }
11011
- try {
11012
- const oidcToken = await (0, import_oidc22.getVercelOidcToken)();
11013
- return {
11014
- token: oidcToken,
11015
- authMethod: "oidc"
11016
- };
11017
- } catch (e) {
11018
- return null;
11019
- }
11655
+ const oidcToken = await (0, import_oidc22.getVercelOidcToken)();
11656
+ return {
11657
+ token: oidcToken,
11658
+ authMethod: "oidc"
11659
+ };
11020
11660
  }
11021
11661
  var _globalThis3 = typeof globalThis === "object" ? globalThis : global;
11022
11662
  var VERSION23 = "1.9.0";
@@ -11089,11 +11729,11 @@ var major3 = VERSION23.split(".")[0];
11089
11729
  var GLOBAL_OPENTELEMETRY_API_KEY3 = /* @__PURE__ */ Symbol.for("opentelemetry.js.api." + major3);
11090
11730
  var _global3 = _globalThis3;
11091
11731
  function registerGlobal3(type, instance, diag, allowOverride) {
11092
- var _a146;
11732
+ var _a21;
11093
11733
  if (allowOverride === void 0) {
11094
11734
  allowOverride = false;
11095
11735
  }
11096
- var api = _global3[GLOBAL_OPENTELEMETRY_API_KEY3] = (_a146 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) !== null && _a146 !== void 0 ? _a146 : {
11736
+ var api = _global3[GLOBAL_OPENTELEMETRY_API_KEY3] = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) !== null && _a21 !== void 0 ? _a21 : {
11097
11737
  version: VERSION23
11098
11738
  };
11099
11739
  if (!allowOverride && api[type]) {
@@ -11111,12 +11751,12 @@ function registerGlobal3(type, instance, diag, allowOverride) {
11111
11751
  return true;
11112
11752
  }
11113
11753
  function getGlobal3(type) {
11114
- var _a146, _b83;
11115
- var globalVersion = (_a146 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _a146 === void 0 ? void 0 : _a146.version;
11754
+ var _a21, _b92;
11755
+ var globalVersion = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _a21 === void 0 ? void 0 : _a21.version;
11116
11756
  if (!globalVersion || !isCompatible3(globalVersion)) {
11117
11757
  return;
11118
11758
  }
11119
- return (_b83 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b83 === void 0 ? void 0 : _b83[type];
11759
+ return (_b92 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b92 === void 0 ? void 0 : _b92[type];
11120
11760
  }
11121
11761
  function unregisterGlobal3(type, diag) {
11122
11762
  diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION23 + ".");
@@ -11281,13 +11921,13 @@ var DiagAPI3 = (
11281
11921
  }
11282
11922
  var self = this;
11283
11923
  var setLogger = function(logger, optionsOrLogLevel) {
11284
- var _a146, _b83, _c;
11924
+ var _a21, _b92, _c;
11285
11925
  if (optionsOrLogLevel === void 0) {
11286
11926
  optionsOrLogLevel = { logLevel: DiagLogLevel3.INFO };
11287
11927
  }
11288
11928
  if (logger === self) {
11289
11929
  var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
11290
- self.error((_a146 = err.stack) !== null && _a146 !== void 0 ? _a146 : err.message);
11930
+ self.error((_a21 = err.stack) !== null && _a21 !== void 0 ? _a21 : err.message);
11291
11931
  return false;
11292
11932
  }
11293
11933
  if (typeof optionsOrLogLevel === "number") {
@@ -11296,7 +11936,7 @@ var DiagAPI3 = (
11296
11936
  };
11297
11937
  }
11298
11938
  var oldLogger = getGlobal3("diag");
11299
- var newLogger = createLogLevelDiagLogger3((_b83 = optionsOrLogLevel.logLevel) !== null && _b83 !== void 0 ? _b83 : DiagLogLevel3.INFO, logger);
11939
+ var newLogger = createLogLevelDiagLogger3((_b92 = optionsOrLogLevel.logLevel) !== null && _b92 !== void 0 ? _b92 : DiagLogLevel3.INFO, logger);
11300
11940
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
11301
11941
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
11302
11942
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -11339,14 +11979,14 @@ var BaseContext3 = (
11339
11979
  return self._currentContext.get(key);
11340
11980
  };
11341
11981
  self.setValue = function(key, value) {
11342
- var context = new BaseContext22(self._currentContext);
11343
- context._currentContext.set(key, value);
11344
- return context;
11982
+ var context2 = new BaseContext22(self._currentContext);
11983
+ context2._currentContext.set(key, value);
11984
+ return context2;
11345
11985
  };
11346
11986
  self.deleteValue = function(key) {
11347
- var context = new BaseContext22(self._currentContext);
11348
- context._currentContext.delete(key);
11349
- return context;
11987
+ var context2 = new BaseContext22(self._currentContext);
11988
+ context2._currentContext.delete(key);
11989
+ return context2;
11350
11990
  };
11351
11991
  }
11352
11992
  return BaseContext22;
@@ -11451,16 +12091,16 @@ var ContextAPI3 = (
11451
12091
  ContextAPI22.prototype.active = function() {
11452
12092
  return this._getContextManager().active();
11453
12093
  };
11454
- ContextAPI22.prototype.with = function(context, fn, thisArg) {
11455
- var _a146;
12094
+ ContextAPI22.prototype.with = function(context2, fn, thisArg) {
12095
+ var _a21;
11456
12096
  var args = [];
11457
12097
  for (var _i = 3; _i < arguments.length; _i++) {
11458
12098
  args[_i - 3] = arguments[_i];
11459
12099
  }
11460
- return (_a146 = this._getContextManager()).with.apply(_a146, __spreadArray43([context, fn, thisArg], __read43(args), false));
12100
+ return (_a21 = this._getContextManager()).with.apply(_a21, __spreadArray43([context2, fn, thisArg], __read43(args), false));
11461
12101
  };
11462
- ContextAPI22.prototype.bind = function(context, target) {
11463
- return this._getContextManager().bind(context, target);
12102
+ ContextAPI22.prototype.bind = function(context2, target) {
12103
+ return this._getContextManager().bind(context2, target);
11464
12104
  };
11465
12105
  ContextAPI22.prototype._getContextManager = function() {
11466
12106
  return getGlobal3(API_NAME23) || NOOP_CONTEXT_MANAGER3;
@@ -11528,24 +12168,24 @@ var NonRecordingSpan3 = (
11528
12168
  })()
11529
12169
  );
11530
12170
  var SPAN_KEY3 = createContextKey3("OpenTelemetry Context Key SPAN");
11531
- function getSpan3(context) {
11532
- return context.getValue(SPAN_KEY3) || void 0;
12171
+ function getSpan3(context2) {
12172
+ return context2.getValue(SPAN_KEY3) || void 0;
11533
12173
  }
11534
12174
  function getActiveSpan3() {
11535
12175
  return getSpan3(ContextAPI3.getInstance().active());
11536
12176
  }
11537
- function setSpan3(context, span) {
11538
- return context.setValue(SPAN_KEY3, span);
12177
+ function setSpan3(context2, span) {
12178
+ return context2.setValue(SPAN_KEY3, span);
11539
12179
  }
11540
- function deleteSpan3(context) {
11541
- return context.deleteValue(SPAN_KEY3);
12180
+ function deleteSpan3(context2) {
12181
+ return context2.deleteValue(SPAN_KEY3);
11542
12182
  }
11543
- function setSpanContext3(context, spanContext) {
11544
- return setSpan3(context, new NonRecordingSpan3(spanContext));
12183
+ function setSpanContext3(context2, spanContext) {
12184
+ return setSpan3(context2, new NonRecordingSpan3(spanContext));
11545
12185
  }
11546
- function getSpanContext3(context) {
11547
- var _a146;
11548
- return (_a146 = getSpan3(context)) === null || _a146 === void 0 ? void 0 : _a146.spanContext();
12186
+ function getSpanContext3(context2) {
12187
+ var _a21;
12188
+ return (_a21 = getSpan3(context2)) === null || _a21 === void 0 ? void 0 : _a21.spanContext();
11549
12189
  }
11550
12190
  var VALID_TRACEID_REGEX3 = /^([0-9a-f]{32})$/i;
11551
12191
  var VALID_SPANID_REGEX3 = /^[0-9a-f]{16}$/i;
@@ -11567,22 +12207,22 @@ var NoopTracer3 = (
11567
12207
  (function() {
11568
12208
  function NoopTracer22() {
11569
12209
  }
11570
- NoopTracer22.prototype.startSpan = function(name145, options, context) {
11571
- if (context === void 0) {
11572
- context = contextApi3.active();
12210
+ NoopTracer22.prototype.startSpan = function(name21, options, context2) {
12211
+ if (context2 === void 0) {
12212
+ context2 = contextApi3.active();
11573
12213
  }
11574
12214
  var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
11575
12215
  if (root) {
11576
12216
  return new NonRecordingSpan3();
11577
12217
  }
11578
- var parentFromContext = context && getSpanContext3(context);
12218
+ var parentFromContext = context2 && getSpanContext3(context2);
11579
12219
  if (isSpanContext3(parentFromContext) && isSpanContextValid3(parentFromContext)) {
11580
12220
  return new NonRecordingSpan3(parentFromContext);
11581
12221
  } else {
11582
12222
  return new NonRecordingSpan3();
11583
12223
  }
11584
12224
  };
11585
- NoopTracer22.prototype.startActiveSpan = function(name145, arg2, arg3, arg4) {
12225
+ NoopTracer22.prototype.startActiveSpan = function(name21, arg2, arg3, arg4) {
11586
12226
  var opts;
11587
12227
  var ctx;
11588
12228
  var fn;
@@ -11599,7 +12239,7 @@ var NoopTracer3 = (
11599
12239
  fn = arg4;
11600
12240
  }
11601
12241
  var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi3.active();
11602
- var span = this.startSpan(name145, opts, parentContext);
12242
+ var span = this.startSpan(name21, opts, parentContext);
11603
12243
  var contextWithSpanSet = setSpan3(parentContext, span);
11604
12244
  return contextApi3.with(contextWithSpanSet, fn, void 0, span);
11605
12245
  };
@@ -11613,14 +12253,14 @@ var NOOP_TRACER3 = new NoopTracer3();
11613
12253
  var ProxyTracer3 = (
11614
12254
  /** @class */
11615
12255
  (function() {
11616
- function ProxyTracer22(_provider, name145, version, options) {
12256
+ function ProxyTracer22(_provider, name21, version, options) {
11617
12257
  this._provider = _provider;
11618
- this.name = name145;
12258
+ this.name = name21;
11619
12259
  this.version = version;
11620
12260
  this.options = options;
11621
12261
  }
11622
- ProxyTracer22.prototype.startSpan = function(name145, options, context) {
11623
- return this._getTracer().startSpan(name145, options, context);
12262
+ ProxyTracer22.prototype.startSpan = function(name21, options, context2) {
12263
+ return this._getTracer().startSpan(name21, options, context2);
11624
12264
  };
11625
12265
  ProxyTracer22.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
11626
12266
  var tracer = this._getTracer();
@@ -11657,20 +12297,20 @@ var ProxyTracerProvider3 = (
11657
12297
  (function() {
11658
12298
  function ProxyTracerProvider22() {
11659
12299
  }
11660
- ProxyTracerProvider22.prototype.getTracer = function(name145, version, options) {
11661
- var _a146;
11662
- return (_a146 = this.getDelegateTracer(name145, version, options)) !== null && _a146 !== void 0 ? _a146 : new ProxyTracer3(this, name145, version, options);
12300
+ ProxyTracerProvider22.prototype.getTracer = function(name21, version, options) {
12301
+ var _a21;
12302
+ return (_a21 = this.getDelegateTracer(name21, version, options)) !== null && _a21 !== void 0 ? _a21 : new ProxyTracer3(this, name21, version, options);
11663
12303
  };
11664
12304
  ProxyTracerProvider22.prototype.getDelegate = function() {
11665
- var _a146;
11666
- return (_a146 = this._delegate) !== null && _a146 !== void 0 ? _a146 : NOOP_TRACER_PROVIDER3;
12305
+ var _a21;
12306
+ return (_a21 = this._delegate) !== null && _a21 !== void 0 ? _a21 : NOOP_TRACER_PROVIDER3;
11667
12307
  };
11668
12308
  ProxyTracerProvider22.prototype.setDelegate = function(delegate) {
11669
12309
  this._delegate = delegate;
11670
12310
  };
11671
- ProxyTracerProvider22.prototype.getDelegateTracer = function(name145, version, options) {
11672
- var _a146;
11673
- return (_a146 = this._delegate) === null || _a146 === void 0 ? void 0 : _a146.getTracer(name145, version, options);
12311
+ ProxyTracerProvider22.prototype.getDelegateTracer = function(name21, version, options) {
12312
+ var _a21;
12313
+ return (_a21 = this._delegate) === null || _a21 === void 0 ? void 0 : _a21.getTracer(name21, version, options);
11674
12314
  };
11675
12315
  return ProxyTracerProvider22;
11676
12316
  })()
@@ -11681,6 +12321,7 @@ var SpanStatusCode3;
11681
12321
  SpanStatusCode22[SpanStatusCode22["OK"] = 1] = "OK";
11682
12322
  SpanStatusCode22[SpanStatusCode22["ERROR"] = 2] = "ERROR";
11683
12323
  })(SpanStatusCode3 || (SpanStatusCode3 = {}));
12324
+ ContextAPI3.getInstance();
11684
12325
  var API_NAME33 = "trace";
11685
12326
  var TraceAPI3 = (
11686
12327
  /** @class */
@@ -11712,8 +12353,8 @@ var TraceAPI3 = (
11712
12353
  TraceAPI22.prototype.getTracerProvider = function() {
11713
12354
  return getGlobal3(API_NAME33) || this._proxyTracerProvider;
11714
12355
  };
11715
- TraceAPI22.prototype.getTracer = function(name145, version) {
11716
- return this.getTracerProvider().getTracer(name145, version);
12356
+ TraceAPI22.prototype.getTracer = function(name21, version) {
12357
+ return this.getTracerProvider().getTracer(name21, version);
11717
12358
  };
11718
12359
  TraceAPI22.prototype.disable = function() {
11719
12360
  unregisterGlobal3(API_NAME33, DiagAPI3.instance());
@@ -11725,13 +12366,13 @@ var TraceAPI3 = (
11725
12366
  TraceAPI3.getInstance();
11726
12367
  var __defProp4 = Object.defineProperty;
11727
12368
  var __export3 = (target, all) => {
11728
- for (var name145 in all)
11729
- __defProp4(target, name145, { get: all[name145], enumerable: true });
12369
+ for (var name21 in all)
12370
+ __defProp4(target, name21, { get: all[name21], enumerable: true });
11730
12371
  };
11731
- var name523 = "AI_NoObjectGeneratedError";
11732
- var marker523 = `vercel.ai.error.${name523}`;
11733
- var symbol523 = Symbol.for(marker523);
11734
- var _a523;
12372
+ var name822 = "AI_NoObjectGeneratedError";
12373
+ var marker823 = `vercel.ai.error.${name822}`;
12374
+ var symbol823 = Symbol.for(marker823);
12375
+ var _a823;
11735
12376
  var NoObjectGeneratedError3 = class extends AISDKError3 {
11736
12377
  constructor({
11737
12378
  message = "No object generated.",
@@ -11741,18 +12382,18 @@ var NoObjectGeneratedError3 = class extends AISDKError3 {
11741
12382
  usage,
11742
12383
  finishReason
11743
12384
  }) {
11744
- super({ name: name523, message, cause });
11745
- this[_a523] = true;
12385
+ super({ name: name822, message, cause });
12386
+ this[_a823] = true;
11746
12387
  this.text = text22;
11747
12388
  this.response = response;
11748
12389
  this.usage = usage;
11749
12390
  this.finishReason = finishReason;
11750
12391
  }
11751
12392
  static isInstance(error) {
11752
- return AISDKError3.hasMarker(error, marker523);
12393
+ return AISDKError3.hasMarker(error, marker823);
11753
12394
  }
11754
12395
  };
11755
- _a523 = symbol523;
12396
+ _a823 = symbol823;
11756
12397
  function formatWarning({
11757
12398
  warning,
11758
12399
  provider,
@@ -11974,8 +12615,8 @@ var dataContentSchema3 = z.union([
11974
12615
  z.custom(
11975
12616
  // Buffer might not be available in some environments such as CloudFlare:
11976
12617
  (value) => {
11977
- var _a146, _b83;
11978
- return (_b83 = (_a146 = globalThis.Buffer) == null ? void 0 : _a146.isBuffer(value)) != null ? _b83 : false;
12618
+ var _a21, _b92;
12619
+ return (_b92 = (_a21 = globalThis.Buffer) == null ? void 0 : _a21.isBuffer(value)) != null ? _b92 : false;
11979
12620
  },
11980
12621
  { message: "Must be a Buffer" }
11981
12622
  )
@@ -12509,37 +13150,42 @@ async function parsePartialJson3(jsonText) {
12509
13150
  return { value: void 0, state: "failed-parse" };
12510
13151
  }
12511
13152
  var text3 = () => ({
13153
+ name: "text",
12512
13154
  responseFormat: Promise.resolve({ type: "text" }),
12513
13155
  async parseCompleteOutput({ text: text22 }) {
12514
13156
  return text22;
12515
13157
  },
12516
13158
  async parsePartialOutput({ text: text22 }) {
12517
13159
  return { partial: text22 };
13160
+ },
13161
+ createElementStreamTransform() {
13162
+ return void 0;
12518
13163
  }
12519
13164
  });
12520
13165
  var object3 = ({
12521
13166
  schema: inputSchema,
12522
- name: name145,
13167
+ name: name21,
12523
13168
  description
12524
13169
  }) => {
12525
13170
  const schema = asSchema3(inputSchema);
12526
13171
  return {
13172
+ name: "object",
12527
13173
  responseFormat: resolve2(schema.jsonSchema).then((jsonSchema22) => ({
12528
13174
  type: "json",
12529
13175
  schema: jsonSchema22,
12530
- ...name145 != null && { name: name145 },
13176
+ ...name21 != null && { name: name21 },
12531
13177
  ...description != null && { description }
12532
13178
  })),
12533
- async parseCompleteOutput({ text: text22 }, context) {
13179
+ async parseCompleteOutput({ text: text22 }, context2) {
12534
13180
  const parseResult = await safeParseJSON3({ text: text22 });
12535
13181
  if (!parseResult.success) {
12536
13182
  throw new NoObjectGeneratedError3({
12537
13183
  message: "No object generated: could not parse the response.",
12538
13184
  cause: parseResult.error,
12539
13185
  text: text22,
12540
- response: context.response,
12541
- usage: context.usage,
12542
- finishReason: context.finishReason
13186
+ response: context2.response,
13187
+ usage: context2.usage,
13188
+ finishReason: context2.finishReason
12543
13189
  });
12544
13190
  }
12545
13191
  const validationResult = await safeValidateTypes3({
@@ -12551,9 +13197,9 @@ var object3 = ({
12551
13197
  message: "No object generated: response did not match schema.",
12552
13198
  cause: validationResult.error,
12553
13199
  text: text22,
12554
- response: context.response,
12555
- usage: context.usage,
12556
- finishReason: context.finishReason
13200
+ response: context2.response,
13201
+ usage: context2.usage,
13202
+ finishReason: context2.finishReason
12557
13203
  });
12558
13204
  }
12559
13205
  return validationResult.value;
@@ -12573,16 +13219,20 @@ var object3 = ({
12573
13219
  };
12574
13220
  }
12575
13221
  }
13222
+ },
13223
+ createElementStreamTransform() {
13224
+ return void 0;
12576
13225
  }
12577
13226
  };
12578
13227
  };
12579
13228
  var array = ({
12580
13229
  element: inputElementSchema,
12581
- name: name145,
13230
+ name: name21,
12582
13231
  description
12583
13232
  }) => {
12584
13233
  const elementSchema = asSchema3(inputElementSchema);
12585
13234
  return {
13235
+ name: "array",
12586
13236
  // JSON schema that describes an array of elements:
12587
13237
  responseFormat: resolve2(elementSchema.jsonSchema).then((jsonSchema22) => {
12588
13238
  const { $schema, ...itemSchema } = jsonSchema22;
@@ -12597,20 +13247,20 @@ var array = ({
12597
13247
  required: ["elements"],
12598
13248
  additionalProperties: false
12599
13249
  },
12600
- ...name145 != null && { name: name145 },
13250
+ ...name21 != null && { name: name21 },
12601
13251
  ...description != null && { description }
12602
13252
  };
12603
13253
  }),
12604
- async parseCompleteOutput({ text: text22 }, context) {
13254
+ async parseCompleteOutput({ text: text22 }, context2) {
12605
13255
  const parseResult = await safeParseJSON3({ text: text22 });
12606
13256
  if (!parseResult.success) {
12607
13257
  throw new NoObjectGeneratedError3({
12608
13258
  message: "No object generated: could not parse the response.",
12609
13259
  cause: parseResult.error,
12610
13260
  text: text22,
12611
- response: context.response,
12612
- usage: context.usage,
12613
- finishReason: context.finishReason
13261
+ response: context2.response,
13262
+ usage: context2.usage,
13263
+ finishReason: context2.finishReason
12614
13264
  });
12615
13265
  }
12616
13266
  const outerValue = parseResult.value;
@@ -12622,9 +13272,9 @@ var array = ({
12622
13272
  cause: "response must be an object with an elements array"
12623
13273
  }),
12624
13274
  text: text22,
12625
- response: context.response,
12626
- usage: context.usage,
12627
- finishReason: context.finishReason
13275
+ response: context2.response,
13276
+ usage: context2.usage,
13277
+ finishReason: context2.finishReason
12628
13278
  });
12629
13279
  }
12630
13280
  for (const element of outerValue.elements) {
@@ -12637,9 +13287,9 @@ var array = ({
12637
13287
  message: "No object generated: response did not match schema.",
12638
13288
  cause: validationResult.error,
12639
13289
  text: text22,
12640
- response: context.response,
12641
- usage: context.usage,
12642
- finishReason: context.finishReason
13290
+ response: context2.response,
13291
+ usage: context2.usage,
13292
+ finishReason: context2.finishReason
12643
13293
  });
12644
13294
  }
12645
13295
  }
@@ -12672,15 +13322,28 @@ var array = ({
12672
13322
  return { partial: parsedElements };
12673
13323
  }
12674
13324
  }
13325
+ },
13326
+ createElementStreamTransform() {
13327
+ let publishedElements = 0;
13328
+ return new TransformStream({
13329
+ transform({ partialOutput }, controller) {
13330
+ if (partialOutput != null) {
13331
+ for (; publishedElements < partialOutput.length; publishedElements++) {
13332
+ controller.enqueue(partialOutput[publishedElements]);
13333
+ }
13334
+ }
13335
+ }
13336
+ });
12675
13337
  }
12676
13338
  };
12677
13339
  };
12678
13340
  var choice = ({
12679
13341
  options: choiceOptions,
12680
- name: name145,
13342
+ name: name21,
12681
13343
  description
12682
13344
  }) => {
12683
13345
  return {
13346
+ name: "choice",
12684
13347
  // JSON schema that describes an enumeration:
12685
13348
  responseFormat: Promise.resolve({
12686
13349
  type: "json",
@@ -12693,19 +13356,19 @@ var choice = ({
12693
13356
  required: ["result"],
12694
13357
  additionalProperties: false
12695
13358
  },
12696
- ...name145 != null && { name: name145 },
13359
+ ...name21 != null && { name: name21 },
12697
13360
  ...description != null && { description }
12698
13361
  }),
12699
- async parseCompleteOutput({ text: text22 }, context) {
13362
+ async parseCompleteOutput({ text: text22 }, context2) {
12700
13363
  const parseResult = await safeParseJSON3({ text: text22 });
12701
13364
  if (!parseResult.success) {
12702
13365
  throw new NoObjectGeneratedError3({
12703
13366
  message: "No object generated: could not parse the response.",
12704
13367
  cause: parseResult.error,
12705
13368
  text: text22,
12706
- response: context.response,
12707
- usage: context.usage,
12708
- finishReason: context.finishReason
13369
+ response: context2.response,
13370
+ usage: context2.usage,
13371
+ finishReason: context2.finishReason
12709
13372
  });
12710
13373
  }
12711
13374
  const outerValue = parseResult.value;
@@ -12717,9 +13380,9 @@ var choice = ({
12717
13380
  cause: "response must be an object that contains a choice value."
12718
13381
  }),
12719
13382
  text: text22,
12720
- response: context.response,
12721
- usage: context.usage,
12722
- finishReason: context.finishReason
13383
+ response: context2.response,
13384
+ usage: context2.usage,
13385
+ finishReason: context2.finishReason
12723
13386
  });
12724
13387
  }
12725
13388
  return outerValue.result;
@@ -12747,29 +13410,33 @@ var choice = ({
12747
13410
  }
12748
13411
  }
12749
13412
  }
13413
+ },
13414
+ createElementStreamTransform() {
13415
+ return void 0;
12750
13416
  }
12751
13417
  };
12752
13418
  };
12753
13419
  var json = ({
12754
- name: name145,
13420
+ name: name21,
12755
13421
  description
12756
13422
  } = {}) => {
12757
13423
  return {
13424
+ name: "json",
12758
13425
  responseFormat: Promise.resolve({
12759
13426
  type: "json",
12760
- ...name145 != null && { name: name145 },
13427
+ ...name21 != null && { name: name21 },
12761
13428
  ...description != null && { description }
12762
13429
  }),
12763
- async parseCompleteOutput({ text: text22 }, context) {
13430
+ async parseCompleteOutput({ text: text22 }, context2) {
12764
13431
  const parseResult = await safeParseJSON3({ text: text22 });
12765
13432
  if (!parseResult.success) {
12766
13433
  throw new NoObjectGeneratedError3({
12767
13434
  message: "No object generated: could not parse the response.",
12768
13435
  cause: parseResult.error,
12769
13436
  text: text22,
12770
- response: context.response,
12771
- usage: context.usage,
12772
- finishReason: context.finishReason
13437
+ response: context2.response,
13438
+ usage: context2.usage,
13439
+ finishReason: context2.finishReason
12773
13440
  });
12774
13441
  }
12775
13442
  return parseResult.value;
@@ -12786,6 +13453,9 @@ var json = ({
12786
13453
  return result.value === void 0 ? void 0 : { partial: result.value };
12787
13454
  }
12788
13455
  }
13456
+ },
13457
+ createElementStreamTransform() {
13458
+ return void 0;
12789
13459
  }
12790
13460
  };
12791
13461
  };
@@ -12822,6 +13492,7 @@ function customProvider3({
12822
13492
  transcriptionModels,
12823
13493
  speechModels,
12824
13494
  rerankingModels,
13495
+ videoModels,
12825
13496
  fallbackProvider: fallbackProviderArg
12826
13497
  }) {
12827
13498
  const fallbackProvider = fallbackProviderArg ? asProviderV3(fallbackProviderArg) : void 0;
@@ -12880,6 +13551,16 @@ function customProvider3({
12880
13551
  return fallbackProvider.rerankingModel(modelId);
12881
13552
  }
12882
13553
  throw new NoSuchModelError3({ modelId, modelType: "rerankingModel" });
13554
+ },
13555
+ videoModel(modelId) {
13556
+ if (videoModels != null && modelId in videoModels) {
13557
+ return videoModels[modelId];
13558
+ }
13559
+ const videoModel = fallbackProvider == null ? void 0 : fallbackProvider.videoModel;
13560
+ if (videoModel) {
13561
+ return videoModel(modelId);
13562
+ }
13563
+ throw new NoSuchModelError3({ modelId, modelType: "videoModel" });
12883
13564
  }
12884
13565
  };
12885
13566
  }
@@ -12888,6 +13569,12 @@ async function getModelCachePath() {
12888
13569
  await fsp.mkdir(cachePath, { recursive: true });
12889
13570
  return cachePath;
12890
13571
  }
13572
+ async function warmup() {
13573
+ const cacheDir = await getModelCachePath();
13574
+ const retrieve = FlagEmbedding.retrieveModel.bind(FlagEmbedding);
13575
+ await retrieve(EmbeddingModel.BGESmallENV15, cacheDir, false);
13576
+ await retrieve(EmbeddingModel.BGEBaseENV15, cacheDir, false);
13577
+ }
12891
13578
  async function generateEmbeddings(values, modelType) {
12892
13579
  const model = await FlagEmbedding.init({
12893
13580
  model: EmbeddingModel[modelType],
@@ -12986,6 +13673,6 @@ var fastembed = Object.assign(fastEmbedProviderV3.embeddingModel(`bge-small-en-v
12986
13673
  baseLegacy: fastEmbedLegacyProvider.textEmbeddingModel(`bge-base-en-v1.5`)
12987
13674
  });
12988
13675
 
12989
- export { fastembed };
13676
+ export { fastembed, warmup };
12990
13677
  //# sourceMappingURL=index.js.map
12991
13678
  //# sourceMappingURL=index.js.map