@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.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkSG3GRV3O_cjs = require('./chunk-SG3GRV3O.cjs');
4
- var chunkZUQPUTTO_cjs = require('./chunk-ZUQPUTTO.cjs');
3
+ var chunk23EXJLET_cjs = require('./chunk-23EXJLET.cjs');
4
+ var chunkIDRQZVB4_cjs = require('./chunk-IDRQZVB4.cjs');
5
5
  var fsp = require('fs/promises');
6
6
  var os = require('os');
7
7
  var path = require('path');
@@ -48,13 +48,13 @@ var _AISDKError = class _AISDKError2 extends Error {
48
48
  * @param {unknown} [params.cause] - The underlying cause of the error.
49
49
  */
50
50
  constructor({
51
- name: name145,
51
+ name: name146,
52
52
  message,
53
53
  cause
54
54
  }) {
55
55
  super(message);
56
56
  this[_a] = true;
57
- this.name = name145;
57
+ this.name = name146;
58
58
  this.cause = cause;
59
59
  }
60
60
  /**
@@ -65,8 +65,8 @@ var _AISDKError = class _AISDKError2 extends Error {
65
65
  static isInstance(error) {
66
66
  return _AISDKError2.hasMarker(error, marker);
67
67
  }
68
- static hasMarker(error, marker155) {
69
- const markerSymbol = Symbol.for(marker155);
68
+ static hasMarker(error, marker156) {
69
+ const markerSymbol = Symbol.for(marker156);
70
70
  return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
71
71
  }
72
72
  };
@@ -421,11 +421,11 @@ function handleFetchError({
421
421
  return error;
422
422
  }
423
423
  function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
424
- var _a155, _b17, _c;
424
+ var _a156, _b17, _c;
425
425
  if (globalThisAny.window) {
426
426
  return `runtime/browser`;
427
427
  }
428
- if ((_a155 = globalThisAny.navigator) == null ? void 0 : _a155.userAgent) {
428
+ if ((_a156 = globalThisAny.navigator) == null ? void 0 : _a156.userAgent) {
429
429
  return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
430
430
  }
431
431
  if ((_c = (_b17 = globalThisAny.process) == null ? void 0 : _b17.versions) == null ? void 0 : _c.node) {
@@ -947,11 +947,11 @@ function parseAnyDef() {
947
947
  return {};
948
948
  }
949
949
  function parseArrayDef(def, refs) {
950
- var _a155, _b17, _c;
950
+ var _a156, _b17, _c;
951
951
  const res = {
952
952
  type: "array"
953
953
  };
954
- if (((_a155 = def.type) == null ? void 0 : _a155._def) && ((_c = (_b17 = def.type) == null ? void 0 : _b17._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
954
+ if (((_a156 = def.type) == null ? void 0 : _a156._def) && ((_c = (_b17 = def.type) == null ? void 0 : _b17._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
955
955
  res.items = parseDef(def.type._def, {
956
956
  ...refs,
957
957
  currentPath: [...refs.currentPath, "items"]
@@ -1310,8 +1310,8 @@ function escapeNonAlphaNumeric(source) {
1310
1310
  return result;
1311
1311
  }
1312
1312
  function addFormat(schema, value, message, refs) {
1313
- var _a155;
1314
- if (schema.format || ((_a155 = schema.anyOf) == null ? void 0 : _a155.some((x) => x.format))) {
1313
+ var _a156;
1314
+ if (schema.format || ((_a156 = schema.anyOf) == null ? void 0 : _a156.some((x) => x.format))) {
1315
1315
  if (!schema.anyOf) {
1316
1316
  schema.anyOf = [];
1317
1317
  }
@@ -1330,8 +1330,8 @@ function addFormat(schema, value, message, refs) {
1330
1330
  }
1331
1331
  }
1332
1332
  function addPattern(schema, regex, message, refs) {
1333
- var _a155;
1334
- if (schema.pattern || ((_a155 = schema.allOf) == null ? void 0 : _a155.some((x) => x.pattern))) {
1333
+ var _a156;
1334
+ if (schema.pattern || ((_a156 = schema.allOf) == null ? void 0 : _a156.some((x) => x.pattern))) {
1335
1335
  if (!schema.allOf) {
1336
1336
  schema.allOf = [];
1337
1337
  }
@@ -1350,7 +1350,7 @@ function addPattern(schema, regex, message, refs) {
1350
1350
  }
1351
1351
  }
1352
1352
  function stringifyRegExpWithFlags(regex, refs) {
1353
- var _a155;
1353
+ var _a156;
1354
1354
  if (!refs.applyRegexFlags || !regex.flags) {
1355
1355
  return regex.source;
1356
1356
  }
@@ -1380,7 +1380,7 @@ function stringifyRegExpWithFlags(regex, refs) {
1380
1380
  pattern += source[i];
1381
1381
  pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
1382
1382
  inCharRange = false;
1383
- } else if (source[i + 1] === "-" && ((_a155 = source[i + 2]) == null ? void 0 : _a155.match(/[a-z]/))) {
1383
+ } else if (source[i + 1] === "-" && ((_a156 = source[i + 2]) == null ? void 0 : _a156.match(/[a-z]/))) {
1384
1384
  pattern += source[i];
1385
1385
  inCharRange = true;
1386
1386
  } else {
@@ -1422,13 +1422,13 @@ function stringifyRegExpWithFlags(regex, refs) {
1422
1422
  return pattern;
1423
1423
  }
1424
1424
  function parseRecordDef(def, refs) {
1425
- var _a155, _b17, _c, _d, _e, _f;
1425
+ var _a156, _b17, _c, _d, _e, _f;
1426
1426
  const schema = {
1427
1427
  type: "object",
1428
- additionalProperties: (_a155 = parseDef(def.valueType._def, {
1428
+ additionalProperties: (_a156 = parseDef(def.valueType._def, {
1429
1429
  ...refs,
1430
1430
  currentPath: [...refs.currentPath, "additionalProperties"]
1431
- })) != null ? _a155 : refs.allowedAdditionalProperties
1431
+ })) != null ? _a156 : refs.allowedAdditionalProperties
1432
1432
  };
1433
1433
  if (((_b17 = def.keyType) == null ? void 0 : _b17._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
1434
1434
  const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
@@ -1685,8 +1685,8 @@ function safeIsOptional(schema) {
1685
1685
  }
1686
1686
  }
1687
1687
  var parseOptionalDef = (def, refs) => {
1688
- var _a155;
1689
- if (refs.currentPath.toString() === ((_a155 = refs.propertyPath) == null ? void 0 : _a155.toString())) {
1688
+ var _a156;
1689
+ if (refs.currentPath.toString() === ((_a156 = refs.propertyPath) == null ? void 0 : _a156.toString())) {
1690
1690
  return parseDef(def.innerType._def, refs);
1691
1691
  }
1692
1692
  const innerSchema = parseDef(def.innerType._def, {
@@ -1856,10 +1856,10 @@ var selectParser = (def, typeName, refs) => {
1856
1856
  }
1857
1857
  };
1858
1858
  function parseDef(def, refs, forceResolution = false) {
1859
- var _a155;
1859
+ var _a156;
1860
1860
  const seenItem = refs.seen.get(def);
1861
1861
  if (refs.override) {
1862
- const overrideResult = (_a155 = refs.override) == null ? void 0 : _a155.call(
1862
+ const overrideResult = (_a156 = refs.override) == null ? void 0 : _a156.call(
1863
1863
  refs,
1864
1864
  def,
1865
1865
  refs,
@@ -1925,11 +1925,11 @@ var getRefs = (options) => {
1925
1925
  currentPath,
1926
1926
  propertyPath: void 0,
1927
1927
  seen: new Map(
1928
- Object.entries(_options.definitions).map(([name145, def]) => [
1928
+ Object.entries(_options.definitions).map(([name146, def]) => [
1929
1929
  def._def,
1930
1930
  {
1931
1931
  def: def._def,
1932
- path: [..._options.basePath, _options.definitionPath, name145],
1932
+ path: [..._options.basePath, _options.definitionPath, name146],
1933
1933
  // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
1934
1934
  jsonSchema: void 0
1935
1935
  }
@@ -1938,7 +1938,7 @@ var getRefs = (options) => {
1938
1938
  };
1939
1939
  };
1940
1940
  var zodToJsonSchema = (schema, options) => {
1941
- var _a155;
1941
+ var _a156;
1942
1942
  const refs = getRefs(options);
1943
1943
  let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
1944
1944
  (acc, [name224, schema2]) => {
@@ -1957,31 +1957,31 @@ var zodToJsonSchema = (schema, options) => {
1957
1957
  },
1958
1958
  {}
1959
1959
  ) : void 0;
1960
- const name145 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
1961
- const main = (_a155 = parseDef(
1960
+ const name146 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
1961
+ const main = (_a156 = parseDef(
1962
1962
  schema._def,
1963
- name145 === void 0 ? refs : {
1963
+ name146 === void 0 ? refs : {
1964
1964
  ...refs,
1965
- currentPath: [...refs.basePath, refs.definitionPath, name145]
1965
+ currentPath: [...refs.basePath, refs.definitionPath, name146]
1966
1966
  },
1967
1967
  false
1968
- )) != null ? _a155 : parseAnyDef();
1968
+ )) != null ? _a156 : parseAnyDef();
1969
1969
  const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
1970
1970
  if (title !== void 0) {
1971
1971
  main.title = title;
1972
1972
  }
1973
- const combined = name145 === void 0 ? definitions ? {
1973
+ const combined = name146 === void 0 ? definitions ? {
1974
1974
  ...main,
1975
1975
  [refs.definitionPath]: definitions
1976
1976
  } : main : {
1977
1977
  $ref: [
1978
1978
  ...refs.$refStrategy === "relative" ? [] : refs.basePath,
1979
1979
  refs.definitionPath,
1980
- name145
1980
+ name146
1981
1981
  ].join("/"),
1982
1982
  [refs.definitionPath]: {
1983
1983
  ...definitions,
1984
- [name145]: main
1984
+ [name146]: main
1985
1985
  }
1986
1986
  };
1987
1987
  combined.$schema = "http://json-schema.org/draft-07/schema#";
@@ -1989,8 +1989,8 @@ var zodToJsonSchema = (schema, options) => {
1989
1989
  };
1990
1990
  var zod_to_json_schema_default = zodToJsonSchema;
1991
1991
  function zod3Schema(zodSchema22, options) {
1992
- var _a155;
1993
- const useReferences = (_a155 = void 0 ) != null ? _a155 : false;
1992
+ var _a156;
1993
+ const useReferences = (_a156 = void 0 ) != null ? _a156 : false;
1994
1994
  return jsonSchema(
1995
1995
  // defer json schema creation to avoid unnecessary computation when only validation is needed
1996
1996
  () => zod_to_json_schema_default(zodSchema22, {
@@ -2005,8 +2005,8 @@ function zod3Schema(zodSchema22, options) {
2005
2005
  );
2006
2006
  }
2007
2007
  function zod4Schema(zodSchema22, options) {
2008
- var _a155;
2009
- const useReferences = (_a155 = void 0 ) != null ? _a155 : false;
2008
+ var _a156;
2009
+ const useReferences = (_a156 = void 0 ) != null ? _a156 : false;
2010
2010
  return jsonSchema(
2011
2011
  // defer json schema creation to avoid unnecessary computation when only validation is needed
2012
2012
  () => z4__namespace.toJSONSchema(zodSchema22, {
@@ -2062,15 +2062,15 @@ function asSchema(schema) {
2062
2062
  function withoutTrailingSlash(url) {
2063
2063
  return url == null ? void 0 : url.replace(/\/$/, "");
2064
2064
  }
2065
- var require_get_context = chunkSG3GRV3O_cjs.__commonJS({
2066
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-context.js"(exports, module) {
2065
+ var require_get_context = chunk23EXJLET_cjs.__commonJS({
2066
+ "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-context.js"(exports$1, module) {
2067
2067
  var __defProp22 = Object.defineProperty;
2068
2068
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
2069
2069
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
2070
2070
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
2071
2071
  var __export22 = (target, all) => {
2072
- for (var name163 in all)
2073
- __defProp22(target, name163, { get: all[name163], enumerable: true });
2072
+ for (var name164 in all)
2073
+ __defProp22(target, name164, { get: all[name164], enumerable: true });
2074
2074
  };
2075
2075
  var __copyProps2 = (to, from, except, desc) => {
2076
2076
  if (from && typeof from === "object" || typeof from === "function") {
@@ -2094,15 +2094,15 @@ var require_get_context = chunkSG3GRV3O_cjs.__commonJS({
2094
2094
  }
2095
2095
  }
2096
2096
  });
2097
- var require_get_vercel_oidc_token = chunkSG3GRV3O_cjs.__commonJS({
2098
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports, module) {
2097
+ var require_get_vercel_oidc_token = chunk23EXJLET_cjs.__commonJS({
2098
+ "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports$1, module) {
2099
2099
  var __defProp22 = Object.defineProperty;
2100
2100
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
2101
2101
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
2102
2102
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
2103
2103
  var __export22 = (target, all) => {
2104
- for (var name163 in all)
2105
- __defProp22(target, name163, { get: all[name163], enumerable: true });
2104
+ for (var name164 in all)
2105
+ __defProp22(target, name164, { get: all[name164], enumerable: true });
2106
2106
  };
2107
2107
  var __copyProps2 = (to, from, except, desc) => {
2108
2108
  if (from && typeof from === "object" || typeof from === "function") {
@@ -2120,7 +2120,7 @@ var require_get_vercel_oidc_token = chunkSG3GRV3O_cjs.__commonJS({
2120
2120
  });
2121
2121
  module.exports = __toCommonJS(get_vercel_oidc_token_exports);
2122
2122
  var import_get_context = require_get_context();
2123
- var import_token_error = chunkSG3GRV3O_cjs.require_token_error();
2123
+ var import_token_error = chunk23EXJLET_cjs.require_token_error();
2124
2124
  async function getVercelOidcToken3() {
2125
2125
  let token = "";
2126
2126
  let err;
@@ -2131,8 +2131,8 @@ var require_get_vercel_oidc_token = chunkSG3GRV3O_cjs.__commonJS({
2131
2131
  }
2132
2132
  try {
2133
2133
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
2134
- await import('./token-util-NEHG7TUY-7IL6JUVY.cjs'),
2135
- await import('./token-6GSAFR2W-YCB5SK2Z.cjs')
2134
+ await import('./token-util-NEHG7TUY-GYFEVMWP.cjs'),
2135
+ await import('./token-6GSAFR2W-TW2P7HCS.cjs')
2136
2136
  ]);
2137
2137
  if (!token || isExpired(getTokenPayload(token))) {
2138
2138
  await refreshToken();
@@ -2158,15 +2158,15 @@ ${error.message}`;
2158
2158
  }
2159
2159
  }
2160
2160
  });
2161
- var require_dist = chunkSG3GRV3O_cjs.__commonJS({
2162
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/index.js"(exports, module) {
2161
+ var require_dist = chunk23EXJLET_cjs.__commonJS({
2162
+ "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/index.js"(exports$1, module) {
2163
2163
  var __defProp22 = Object.defineProperty;
2164
2164
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
2165
2165
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
2166
2166
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
2167
2167
  var __export22 = (target, all) => {
2168
- for (var name163 in all)
2169
- __defProp22(target, name163, { get: all[name163], enumerable: true });
2168
+ for (var name164 in all)
2169
+ __defProp22(target, name164, { get: all[name164], enumerable: true });
2170
2170
  };
2171
2171
  var __copyProps2 = (to, from, except, desc) => {
2172
2172
  if (from && typeof from === "object" || typeof from === "function") {
@@ -2188,8 +2188,8 @@ var require_dist = chunkSG3GRV3O_cjs.__commonJS({
2188
2188
  var import_get_context = require_get_context();
2189
2189
  }
2190
2190
  });
2191
- var import_oidc = chunkSG3GRV3O_cjs.__toESM(require_dist(), 1);
2192
- var import_oidc2 = chunkSG3GRV3O_cjs.__toESM(require_dist(), 1);
2191
+ var import_oidc = chunk23EXJLET_cjs.__toESM(require_dist(), 1);
2192
+ var import_oidc2 = chunk23EXJLET_cjs.__toESM(require_dist(), 1);
2193
2193
  var marker15 = "vercel.ai.gateway.error";
2194
2194
  var symbol15 = Symbol.for(marker15);
2195
2195
  var _a15;
@@ -2905,12 +2905,12 @@ async function getVercelRequestId() {
2905
2905
  var VERSION2 = "2.0.15";
2906
2906
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
2907
2907
  function createGatewayProvider(options = {}) {
2908
- var _a832, _b83;
2908
+ var _a832, _b84;
2909
2909
  let pendingMetadata = null;
2910
2910
  let metadataCache = null;
2911
2911
  const cacheRefreshMillis = (_a832 = options.metadataCacheRefreshMillis) != null ? _a832 : 1e3 * 60 * 5;
2912
2912
  let lastFetchTime = 0;
2913
- const baseURL = (_b83 = withoutTrailingSlash(options.baseURL)) != null ? _b83 : "https://ai-gateway.vercel.sh/v1/ai";
2913
+ const baseURL = (_b84 = withoutTrailingSlash(options.baseURL)) != null ? _b84 : "https://ai-gateway.vercel.sh/v1/ai";
2914
2914
  const getHeaders = async () => {
2915
2915
  const auth = await getGatewayAuthToken(options);
2916
2916
  if (auth) {
@@ -2963,8 +2963,8 @@ function createGatewayProvider(options = {}) {
2963
2963
  });
2964
2964
  };
2965
2965
  const getAvailableModels = async () => {
2966
- var _a922, _b92, _c;
2967
- const now2 = (_c = (_b92 = (_a922 = options._internal) == null ? void 0 : _a922.currentDate) == null ? void 0 : _b92.call(_a922).getTime()) != null ? _c : Date.now();
2966
+ var _a923, _b92, _c;
2967
+ const now2 = (_c = (_b92 = (_a923 = options._internal) == null ? void 0 : _a923.currentDate) == null ? void 0 : _b92.call(_a923).getTime()) != null ? _c : Date.now();
2968
2968
  if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
2969
2969
  lastFetchTime = now2;
2970
2970
  pendingMetadata = new GatewayFetchMetadata({
@@ -3119,11 +3119,11 @@ var major = VERSION22.split(".")[0];
3119
3119
  var GLOBAL_OPENTELEMETRY_API_KEY = /* @__PURE__ */ Symbol.for("opentelemetry.js.api." + major);
3120
3120
  var _global = _globalThis;
3121
3121
  function registerGlobal(type, instance, diag, allowOverride) {
3122
- var _a163;
3122
+ var _a164;
3123
3123
  if (allowOverride === void 0) {
3124
3124
  allowOverride = false;
3125
3125
  }
3126
- var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a163 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a163 !== void 0 ? _a163 : {
3126
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a164 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a164 !== void 0 ? _a164 : {
3127
3127
  version: VERSION22
3128
3128
  };
3129
3129
  if (!allowOverride && api[type]) {
@@ -3141,12 +3141,12 @@ function registerGlobal(type, instance, diag, allowOverride) {
3141
3141
  return true;
3142
3142
  }
3143
3143
  function getGlobal(type) {
3144
- var _a163, _b83;
3145
- var globalVersion = (_a163 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a163 === void 0 ? void 0 : _a163.version;
3144
+ var _a164, _b84;
3145
+ var globalVersion = (_a164 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a164 === void 0 ? void 0 : _a164.version;
3146
3146
  if (!globalVersion || !isCompatible(globalVersion)) {
3147
3147
  return;
3148
3148
  }
3149
- return (_b83 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b83 === void 0 ? void 0 : _b83[type];
3149
+ return (_b84 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b84 === void 0 ? void 0 : _b84[type];
3150
3150
  }
3151
3151
  function unregisterGlobal(type, diag) {
3152
3152
  diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION22 + ".");
@@ -3311,13 +3311,13 @@ var DiagAPI = (
3311
3311
  }
3312
3312
  var self = this;
3313
3313
  var setLogger = function(logger, optionsOrLogLevel) {
3314
- var _a163, _b83, _c;
3314
+ var _a164, _b84, _c;
3315
3315
  if (optionsOrLogLevel === void 0) {
3316
3316
  optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
3317
3317
  }
3318
3318
  if (logger === self) {
3319
3319
  var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
3320
- self.error((_a163 = err.stack) !== null && _a163 !== void 0 ? _a163 : err.message);
3320
+ self.error((_a164 = err.stack) !== null && _a164 !== void 0 ? _a164 : err.message);
3321
3321
  return false;
3322
3322
  }
3323
3323
  if (typeof optionsOrLogLevel === "number") {
@@ -3326,7 +3326,7 @@ var DiagAPI = (
3326
3326
  };
3327
3327
  }
3328
3328
  var oldLogger = getGlobal("diag");
3329
- var newLogger = createLogLevelDiagLogger((_b83 = optionsOrLogLevel.logLevel) !== null && _b83 !== void 0 ? _b83 : DiagLogLevel.INFO, logger);
3329
+ var newLogger = createLogLevelDiagLogger((_b84 = optionsOrLogLevel.logLevel) !== null && _b84 !== void 0 ? _b84 : DiagLogLevel.INFO, logger);
3330
3330
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
3331
3331
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
3332
3332
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -3369,14 +3369,14 @@ var BaseContext = (
3369
3369
  return self._currentContext.get(key);
3370
3370
  };
3371
3371
  self.setValue = function(key, value) {
3372
- var context = new BaseContext22(self._currentContext);
3373
- context._currentContext.set(key, value);
3374
- return context;
3372
+ var context2 = new BaseContext22(self._currentContext);
3373
+ context2._currentContext.set(key, value);
3374
+ return context2;
3375
3375
  };
3376
3376
  self.deleteValue = function(key) {
3377
- var context = new BaseContext22(self._currentContext);
3378
- context._currentContext.delete(key);
3379
- return context;
3377
+ var context2 = new BaseContext22(self._currentContext);
3378
+ context2._currentContext.delete(key);
3379
+ return context2;
3380
3380
  };
3381
3381
  }
3382
3382
  return BaseContext22;
@@ -3481,16 +3481,16 @@ var ContextAPI = (
3481
3481
  ContextAPI22.prototype.active = function() {
3482
3482
  return this._getContextManager().active();
3483
3483
  };
3484
- ContextAPI22.prototype.with = function(context, fn, thisArg) {
3485
- var _a163;
3484
+ ContextAPI22.prototype.with = function(context2, fn, thisArg) {
3485
+ var _a164;
3486
3486
  var args = [];
3487
3487
  for (var _i = 3; _i < arguments.length; _i++) {
3488
3488
  args[_i - 3] = arguments[_i];
3489
3489
  }
3490
- return (_a163 = this._getContextManager()).with.apply(_a163, __spreadArray4([context, fn, thisArg], __read4(args), false));
3490
+ return (_a164 = this._getContextManager()).with.apply(_a164, __spreadArray4([context2, fn, thisArg], __read4(args), false));
3491
3491
  };
3492
- ContextAPI22.prototype.bind = function(context, target) {
3493
- return this._getContextManager().bind(context, target);
3492
+ ContextAPI22.prototype.bind = function(context2, target) {
3493
+ return this._getContextManager().bind(context2, target);
3494
3494
  };
3495
3495
  ContextAPI22.prototype._getContextManager = function() {
3496
3496
  return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
@@ -3558,24 +3558,24 @@ var NonRecordingSpan = (
3558
3558
  })()
3559
3559
  );
3560
3560
  var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
3561
- function getSpan(context) {
3562
- return context.getValue(SPAN_KEY) || void 0;
3561
+ function getSpan(context2) {
3562
+ return context2.getValue(SPAN_KEY) || void 0;
3563
3563
  }
3564
3564
  function getActiveSpan() {
3565
3565
  return getSpan(ContextAPI.getInstance().active());
3566
3566
  }
3567
- function setSpan(context, span) {
3568
- return context.setValue(SPAN_KEY, span);
3567
+ function setSpan(context2, span) {
3568
+ return context2.setValue(SPAN_KEY, span);
3569
3569
  }
3570
- function deleteSpan(context) {
3571
- return context.deleteValue(SPAN_KEY);
3570
+ function deleteSpan(context2) {
3571
+ return context2.deleteValue(SPAN_KEY);
3572
3572
  }
3573
- function setSpanContext(context, spanContext) {
3574
- return setSpan(context, new NonRecordingSpan(spanContext));
3573
+ function setSpanContext(context2, spanContext) {
3574
+ return setSpan(context2, new NonRecordingSpan(spanContext));
3575
3575
  }
3576
- function getSpanContext(context) {
3577
- var _a163;
3578
- return (_a163 = getSpan(context)) === null || _a163 === void 0 ? void 0 : _a163.spanContext();
3576
+ function getSpanContext(context2) {
3577
+ var _a164;
3578
+ return (_a164 = getSpan(context2)) === null || _a164 === void 0 ? void 0 : _a164.spanContext();
3579
3579
  }
3580
3580
  var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
3581
3581
  var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
@@ -3597,22 +3597,22 @@ var NoopTracer = (
3597
3597
  (function() {
3598
3598
  function NoopTracer22() {
3599
3599
  }
3600
- NoopTracer22.prototype.startSpan = function(name163, options, context) {
3601
- if (context === void 0) {
3602
- context = contextApi.active();
3600
+ NoopTracer22.prototype.startSpan = function(name164, options, context2) {
3601
+ if (context2 === void 0) {
3602
+ context2 = contextApi.active();
3603
3603
  }
3604
3604
  var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
3605
3605
  if (root) {
3606
3606
  return new NonRecordingSpan();
3607
3607
  }
3608
- var parentFromContext = context && getSpanContext(context);
3608
+ var parentFromContext = context2 && getSpanContext(context2);
3609
3609
  if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
3610
3610
  return new NonRecordingSpan(parentFromContext);
3611
3611
  } else {
3612
3612
  return new NonRecordingSpan();
3613
3613
  }
3614
3614
  };
3615
- NoopTracer22.prototype.startActiveSpan = function(name163, arg2, arg3, arg4) {
3615
+ NoopTracer22.prototype.startActiveSpan = function(name164, arg2, arg3, arg4) {
3616
3616
  var opts;
3617
3617
  var ctx;
3618
3618
  var fn;
@@ -3629,7 +3629,7 @@ var NoopTracer = (
3629
3629
  fn = arg4;
3630
3630
  }
3631
3631
  var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
3632
- var span = this.startSpan(name163, opts, parentContext);
3632
+ var span = this.startSpan(name164, opts, parentContext);
3633
3633
  var contextWithSpanSet = setSpan(parentContext, span);
3634
3634
  return contextApi.with(contextWithSpanSet, fn, void 0, span);
3635
3635
  };
@@ -3643,14 +3643,14 @@ var NOOP_TRACER = new NoopTracer();
3643
3643
  var ProxyTracer = (
3644
3644
  /** @class */
3645
3645
  (function() {
3646
- function ProxyTracer22(_provider, name163, version, options) {
3646
+ function ProxyTracer22(_provider, name164, version, options) {
3647
3647
  this._provider = _provider;
3648
- this.name = name163;
3648
+ this.name = name164;
3649
3649
  this.version = version;
3650
3650
  this.options = options;
3651
3651
  }
3652
- ProxyTracer22.prototype.startSpan = function(name163, options, context) {
3653
- return this._getTracer().startSpan(name163, options, context);
3652
+ ProxyTracer22.prototype.startSpan = function(name164, options, context2) {
3653
+ return this._getTracer().startSpan(name164, options, context2);
3654
3654
  };
3655
3655
  ProxyTracer22.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
3656
3656
  var tracer = this._getTracer();
@@ -3687,20 +3687,20 @@ var ProxyTracerProvider = (
3687
3687
  (function() {
3688
3688
  function ProxyTracerProvider22() {
3689
3689
  }
3690
- ProxyTracerProvider22.prototype.getTracer = function(name163, version, options) {
3691
- var _a163;
3692
- return (_a163 = this.getDelegateTracer(name163, version, options)) !== null && _a163 !== void 0 ? _a163 : new ProxyTracer(this, name163, version, options);
3690
+ ProxyTracerProvider22.prototype.getTracer = function(name164, version, options) {
3691
+ var _a164;
3692
+ return (_a164 = this.getDelegateTracer(name164, version, options)) !== null && _a164 !== void 0 ? _a164 : new ProxyTracer(this, name164, version, options);
3693
3693
  };
3694
3694
  ProxyTracerProvider22.prototype.getDelegate = function() {
3695
- var _a163;
3696
- return (_a163 = this._delegate) !== null && _a163 !== void 0 ? _a163 : NOOP_TRACER_PROVIDER;
3695
+ var _a164;
3696
+ return (_a164 = this._delegate) !== null && _a164 !== void 0 ? _a164 : NOOP_TRACER_PROVIDER;
3697
3697
  };
3698
3698
  ProxyTracerProvider22.prototype.setDelegate = function(delegate) {
3699
3699
  this._delegate = delegate;
3700
3700
  };
3701
- ProxyTracerProvider22.prototype.getDelegateTracer = function(name163, version, options) {
3702
- var _a163;
3703
- return (_a163 = this._delegate) === null || _a163 === void 0 ? void 0 : _a163.getTracer(name163, version, options);
3701
+ ProxyTracerProvider22.prototype.getDelegateTracer = function(name164, version, options) {
3702
+ var _a164;
3703
+ return (_a164 = this._delegate) === null || _a164 === void 0 ? void 0 : _a164.getTracer(name164, version, options);
3704
3704
  };
3705
3705
  return ProxyTracerProvider22;
3706
3706
  })()
@@ -3742,8 +3742,8 @@ var TraceAPI = (
3742
3742
  TraceAPI22.prototype.getTracerProvider = function() {
3743
3743
  return getGlobal(API_NAME3) || this._proxyTracerProvider;
3744
3744
  };
3745
- TraceAPI22.prototype.getTracer = function(name163, version) {
3746
- return this.getTracerProvider().getTracer(name163, version);
3745
+ TraceAPI22.prototype.getTracer = function(name164, version) {
3746
+ return this.getTracerProvider().getTracer(name164, version);
3747
3747
  };
3748
3748
  TraceAPI22.prototype.disable = function() {
3749
3749
  unregisterGlobal(API_NAME3, DiagAPI.instance());
@@ -3755,8 +3755,8 @@ var TraceAPI = (
3755
3755
  TraceAPI.getInstance();
3756
3756
  var __defProp = Object.defineProperty;
3757
3757
  var __export = (target, all) => {
3758
- for (var name163 in all)
3759
- __defProp(target, name163, { get: all[name163], enumerable: true });
3758
+ for (var name164 in all)
3759
+ __defProp(target, name164, { get: all[name164], enumerable: true });
3760
3760
  };
3761
3761
  var name622 = "AI_NoObjectGeneratedError";
3762
3762
  var marker622 = `vercel.ai.error.${name622}`;
@@ -3790,8 +3790,8 @@ var dataContentSchema = z4.z.union([
3790
3790
  z4.z.custom(
3791
3791
  // Buffer might not be available in some environments such as CloudFlare:
3792
3792
  (value) => {
3793
- var _a163, _b83;
3794
- return (_b83 = (_a163 = globalThis.Buffer) == null ? void 0 : _a163.isBuffer(value)) != null ? _b83 : false;
3793
+ var _a164, _b84;
3794
+ return (_b84 = (_a164 = globalThis.Buffer) == null ? void 0 : _a164.isBuffer(value)) != null ? _b84 : false;
3795
3795
  },
3796
3796
  { message: "Must be a Buffer" }
3797
3797
  )
@@ -4307,16 +4307,16 @@ var object = ({
4307
4307
  }
4308
4308
  }
4309
4309
  },
4310
- async parseOutput({ text: text22 }, context) {
4310
+ async parseOutput({ text: text22 }, context2) {
4311
4311
  const parseResult = await safeParseJSON({ text: text22 });
4312
4312
  if (!parseResult.success) {
4313
4313
  throw new NoObjectGeneratedError({
4314
4314
  message: "No object generated: could not parse the response.",
4315
4315
  cause: parseResult.error,
4316
4316
  text: text22,
4317
- response: context.response,
4318
- usage: context.usage,
4319
- finishReason: context.finishReason
4317
+ response: context2.response,
4318
+ usage: context2.usage,
4319
+ finishReason: context2.finishReason
4320
4320
  });
4321
4321
  }
4322
4322
  const validationResult = await safeValidateTypes({
@@ -4328,9 +4328,9 @@ var object = ({
4328
4328
  message: "No object generated: response did not match schema.",
4329
4329
  cause: validationResult.error,
4330
4330
  text: text22,
4331
- response: context.response,
4332
- usage: context.usage,
4333
- finishReason: context.finishReason
4331
+ response: context2.response,
4332
+ usage: context2.usage,
4333
+ finishReason: context2.finishReason
4334
4334
  });
4335
4335
  }
4336
4336
  return validationResult.value;
@@ -4421,7 +4421,7 @@ var __toESM3 = (mod, isNodeMode, target) => (target = mod != null ? __create(__g
4421
4421
  mod
4422
4422
  ));
4423
4423
  var require_secure_json_parse = __commonJS3({
4424
- "../../../node_modules/.pnpm/secure-json-parse@2.7.0/node_modules/secure-json-parse/index.js"(exports, module) {
4424
+ "../../../node_modules/.pnpm/secure-json-parse@2.7.0/node_modules/secure-json-parse/index.js"(exports$1, module) {
4425
4425
  var hasBuffer = typeof Buffer !== "undefined";
4426
4426
  var suspectProtoRx3 = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
4427
4427
  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*:/;
@@ -4534,13 +4534,13 @@ var _AISDKError3 = class _AISDKError22 extends Error {
4534
4534
  * @param {unknown} [params.cause] - The underlying cause of the error.
4535
4535
  */
4536
4536
  constructor({
4537
- name: name145,
4537
+ name: name146,
4538
4538
  message,
4539
4539
  cause
4540
4540
  }) {
4541
4541
  super(message);
4542
4542
  this[_a16] = true;
4543
- this.name = name145;
4543
+ this.name = name146;
4544
4544
  this.cause = cause;
4545
4545
  }
4546
4546
  /**
@@ -4551,8 +4551,8 @@ var _AISDKError3 = class _AISDKError22 extends Error {
4551
4551
  static isInstance(error) {
4552
4552
  return _AISDKError22.hasMarker(error, marker16);
4553
4553
  }
4554
- static hasMarker(error, marker155) {
4555
- const markerSymbol = Symbol.for(marker155);
4554
+ static hasMarker(error, marker156) {
4555
+ const markerSymbol = Symbol.for(marker156);
4556
4556
  return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
4557
4557
  }
4558
4558
  };
@@ -4822,11 +4822,11 @@ var getRefs2 = (options) => {
4822
4822
  flags: { hasReferencedOpenAiAnyType: false },
4823
4823
  currentPath,
4824
4824
  propertyPath: void 0,
4825
- seen: new Map(Object.entries(_options.definitions).map(([name172, def]) => [
4825
+ seen: new Map(Object.entries(_options.definitions).map(([name173, def]) => [
4826
4826
  def._def,
4827
4827
  {
4828
4828
  def: def._def,
4829
- path: [..._options.basePath, _options.definitionPath, name172],
4829
+ path: [..._options.basePath, _options.definitionPath, name173],
4830
4830
  // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
4831
4831
  jsonSchema: void 0
4832
4832
  }
@@ -4873,7 +4873,7 @@ function parseArrayDef2(def, refs) {
4873
4873
  const res = {
4874
4874
  type: "array"
4875
4875
  };
4876
- if (def.type?._def && def.type?._def?.typeName !== zod.ZodFirstPartyTypeKind.ZodAny) {
4876
+ if (def.type?._def && def.type?._def?.typeName !== v3.ZodFirstPartyTypeKind.ZodAny) {
4877
4877
  res.items = parseDef2(def.type._def, {
4878
4878
  ...refs,
4879
4879
  currentPath: [...refs.currentPath, "items"]
@@ -5390,7 +5390,7 @@ function parseRecordDef2(def, refs) {
5390
5390
  if (refs.target === "openAi") {
5391
5391
  console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
5392
5392
  }
5393
- if (refs.target === "openApi3" && def.keyType?._def.typeName === zod.ZodFirstPartyTypeKind.ZodEnum) {
5393
+ if (refs.target === "openApi3" && def.keyType?._def.typeName === v3.ZodFirstPartyTypeKind.ZodEnum) {
5394
5394
  return {
5395
5395
  type: "object",
5396
5396
  required: def.keyType._def.values,
@@ -5414,20 +5414,20 @@ function parseRecordDef2(def, refs) {
5414
5414
  if (refs.target === "openApi3") {
5415
5415
  return schema;
5416
5416
  }
5417
- if (def.keyType?._def.typeName === zod.ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
5417
+ if (def.keyType?._def.typeName === v3.ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
5418
5418
  const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
5419
5419
  return {
5420
5420
  ...schema,
5421
5421
  propertyNames: keyType
5422
5422
  };
5423
- } else if (def.keyType?._def.typeName === zod.ZodFirstPartyTypeKind.ZodEnum) {
5423
+ } else if (def.keyType?._def.typeName === v3.ZodFirstPartyTypeKind.ZodEnum) {
5424
5424
  return {
5425
5425
  ...schema,
5426
5426
  propertyNames: {
5427
5427
  enum: def.keyType._def.values
5428
5428
  }
5429
5429
  };
5430
- } else if (def.keyType?._def.typeName === zod.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === zod.ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
5430
+ } else if (def.keyType?._def.typeName === v3.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === v3.ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
5431
5431
  const { type, ...keyType } = parseBrandedDef2(def.keyType._def, refs);
5432
5432
  return {
5433
5433
  ...schema,
@@ -5793,73 +5793,73 @@ var parseReadonlyDef2 = (def, refs) => {
5793
5793
  };
5794
5794
  var selectParser2 = (def, typeName, refs) => {
5795
5795
  switch (typeName) {
5796
- case zod.ZodFirstPartyTypeKind.ZodString:
5796
+ case v3.ZodFirstPartyTypeKind.ZodString:
5797
5797
  return parseStringDef2(def, refs);
5798
- case zod.ZodFirstPartyTypeKind.ZodNumber:
5798
+ case v3.ZodFirstPartyTypeKind.ZodNumber:
5799
5799
  return parseNumberDef2(def, refs);
5800
- case zod.ZodFirstPartyTypeKind.ZodObject:
5800
+ case v3.ZodFirstPartyTypeKind.ZodObject:
5801
5801
  return parseObjectDef2(def, refs);
5802
- case zod.ZodFirstPartyTypeKind.ZodBigInt:
5802
+ case v3.ZodFirstPartyTypeKind.ZodBigInt:
5803
5803
  return parseBigintDef2(def, refs);
5804
- case zod.ZodFirstPartyTypeKind.ZodBoolean:
5804
+ case v3.ZodFirstPartyTypeKind.ZodBoolean:
5805
5805
  return parseBooleanDef2();
5806
- case zod.ZodFirstPartyTypeKind.ZodDate:
5806
+ case v3.ZodFirstPartyTypeKind.ZodDate:
5807
5807
  return parseDateDef2(def, refs);
5808
- case zod.ZodFirstPartyTypeKind.ZodUndefined:
5808
+ case v3.ZodFirstPartyTypeKind.ZodUndefined:
5809
5809
  return parseUndefinedDef2(refs);
5810
- case zod.ZodFirstPartyTypeKind.ZodNull:
5810
+ case v3.ZodFirstPartyTypeKind.ZodNull:
5811
5811
  return parseNullDef2(refs);
5812
- case zod.ZodFirstPartyTypeKind.ZodArray:
5812
+ case v3.ZodFirstPartyTypeKind.ZodArray:
5813
5813
  return parseArrayDef2(def, refs);
5814
- case zod.ZodFirstPartyTypeKind.ZodUnion:
5815
- case zod.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
5814
+ case v3.ZodFirstPartyTypeKind.ZodUnion:
5815
+ case v3.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
5816
5816
  return parseUnionDef2(def, refs);
5817
- case zod.ZodFirstPartyTypeKind.ZodIntersection:
5817
+ case v3.ZodFirstPartyTypeKind.ZodIntersection:
5818
5818
  return parseIntersectionDef2(def, refs);
5819
- case zod.ZodFirstPartyTypeKind.ZodTuple:
5819
+ case v3.ZodFirstPartyTypeKind.ZodTuple:
5820
5820
  return parseTupleDef2(def, refs);
5821
- case zod.ZodFirstPartyTypeKind.ZodRecord:
5821
+ case v3.ZodFirstPartyTypeKind.ZodRecord:
5822
5822
  return parseRecordDef2(def, refs);
5823
- case zod.ZodFirstPartyTypeKind.ZodLiteral:
5823
+ case v3.ZodFirstPartyTypeKind.ZodLiteral:
5824
5824
  return parseLiteralDef2(def, refs);
5825
- case zod.ZodFirstPartyTypeKind.ZodEnum:
5825
+ case v3.ZodFirstPartyTypeKind.ZodEnum:
5826
5826
  return parseEnumDef2(def);
5827
- case zod.ZodFirstPartyTypeKind.ZodNativeEnum:
5827
+ case v3.ZodFirstPartyTypeKind.ZodNativeEnum:
5828
5828
  return parseNativeEnumDef2(def);
5829
- case zod.ZodFirstPartyTypeKind.ZodNullable:
5829
+ case v3.ZodFirstPartyTypeKind.ZodNullable:
5830
5830
  return parseNullableDef2(def, refs);
5831
- case zod.ZodFirstPartyTypeKind.ZodOptional:
5831
+ case v3.ZodFirstPartyTypeKind.ZodOptional:
5832
5832
  return parseOptionalDef2(def, refs);
5833
- case zod.ZodFirstPartyTypeKind.ZodMap:
5833
+ case v3.ZodFirstPartyTypeKind.ZodMap:
5834
5834
  return parseMapDef2(def, refs);
5835
- case zod.ZodFirstPartyTypeKind.ZodSet:
5835
+ case v3.ZodFirstPartyTypeKind.ZodSet:
5836
5836
  return parseSetDef2(def, refs);
5837
- case zod.ZodFirstPartyTypeKind.ZodLazy:
5837
+ case v3.ZodFirstPartyTypeKind.ZodLazy:
5838
5838
  return () => def.getter()._def;
5839
- case zod.ZodFirstPartyTypeKind.ZodPromise:
5839
+ case v3.ZodFirstPartyTypeKind.ZodPromise:
5840
5840
  return parsePromiseDef2(def, refs);
5841
- case zod.ZodFirstPartyTypeKind.ZodNaN:
5842
- case zod.ZodFirstPartyTypeKind.ZodNever:
5841
+ case v3.ZodFirstPartyTypeKind.ZodNaN:
5842
+ case v3.ZodFirstPartyTypeKind.ZodNever:
5843
5843
  return parseNeverDef2(refs);
5844
- case zod.ZodFirstPartyTypeKind.ZodEffects:
5844
+ case v3.ZodFirstPartyTypeKind.ZodEffects:
5845
5845
  return parseEffectsDef2(def, refs);
5846
- case zod.ZodFirstPartyTypeKind.ZodAny:
5846
+ case v3.ZodFirstPartyTypeKind.ZodAny:
5847
5847
  return parseAnyDef2(refs);
5848
- case zod.ZodFirstPartyTypeKind.ZodUnknown:
5848
+ case v3.ZodFirstPartyTypeKind.ZodUnknown:
5849
5849
  return parseUnknownDef2(refs);
5850
- case zod.ZodFirstPartyTypeKind.ZodDefault:
5850
+ case v3.ZodFirstPartyTypeKind.ZodDefault:
5851
5851
  return parseDefaultDef2(def, refs);
5852
- case zod.ZodFirstPartyTypeKind.ZodBranded:
5852
+ case v3.ZodFirstPartyTypeKind.ZodBranded:
5853
5853
  return parseBrandedDef2(def, refs);
5854
- case zod.ZodFirstPartyTypeKind.ZodReadonly:
5854
+ case v3.ZodFirstPartyTypeKind.ZodReadonly:
5855
5855
  return parseReadonlyDef2(def, refs);
5856
- case zod.ZodFirstPartyTypeKind.ZodCatch:
5856
+ case v3.ZodFirstPartyTypeKind.ZodCatch:
5857
5857
  return parseCatchDef2(def, refs);
5858
- case zod.ZodFirstPartyTypeKind.ZodPipeline:
5858
+ case v3.ZodFirstPartyTypeKind.ZodPipeline:
5859
5859
  return parsePipelineDef2(def, refs);
5860
- case zod.ZodFirstPartyTypeKind.ZodFunction:
5861
- case zod.ZodFirstPartyTypeKind.ZodVoid:
5862
- case zod.ZodFirstPartyTypeKind.ZodSymbol:
5860
+ case v3.ZodFirstPartyTypeKind.ZodFunction:
5861
+ case v3.ZodFirstPartyTypeKind.ZodVoid:
5862
+ case v3.ZodFirstPartyTypeKind.ZodSymbol:
5863
5863
  return void 0;
5864
5864
  default:
5865
5865
  return /* @__PURE__ */ ((_) => void 0)();
@@ -5921,17 +5921,17 @@ var addMeta2 = (def, refs, jsonSchema22) => {
5921
5921
  };
5922
5922
  var zodToJsonSchema2 = (schema, options) => {
5923
5923
  const refs = getRefs2(options);
5924
- let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name182, schema2]) => ({
5924
+ let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name183, schema2]) => ({
5925
5925
  ...acc,
5926
- [name182]: parseDef2(schema2._def, {
5926
+ [name183]: parseDef2(schema2._def, {
5927
5927
  ...refs,
5928
- currentPath: [...refs.basePath, refs.definitionPath, name182]
5928
+ currentPath: [...refs.basePath, refs.definitionPath, name183]
5929
5929
  }, true) ?? parseAnyDef2(refs)
5930
5930
  }), {}) : void 0;
5931
- const name172 = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
5932
- const main = parseDef2(schema._def, name172 === void 0 ? refs : {
5931
+ const name173 = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
5932
+ const main = parseDef2(schema._def, name173 === void 0 ? refs : {
5933
5933
  ...refs,
5934
- currentPath: [...refs.basePath, refs.definitionPath, name172]
5934
+ currentPath: [...refs.basePath, refs.definitionPath, name173]
5935
5935
  }, false) ?? parseAnyDef2(refs);
5936
5936
  const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
5937
5937
  if (title !== void 0) {
@@ -5955,18 +5955,18 @@ var zodToJsonSchema2 = (schema, options) => {
5955
5955
  };
5956
5956
  }
5957
5957
  }
5958
- const combined = name172 === void 0 ? definitions ? {
5958
+ const combined = name173 === void 0 ? definitions ? {
5959
5959
  ...main,
5960
5960
  [refs.definitionPath]: definitions
5961
5961
  } : main : {
5962
5962
  $ref: [
5963
5963
  ...refs.$refStrategy === "relative" ? [] : refs.basePath,
5964
5964
  refs.definitionPath,
5965
- name172
5965
+ name173
5966
5966
  ].join("/"),
5967
5967
  [refs.definitionPath]: {
5968
5968
  ...definitions,
5969
- [name172]: main
5969
+ [name173]: main
5970
5970
  }
5971
5971
  };
5972
5972
  if (refs.target === "jsonSchema7") {
@@ -6574,8 +6574,8 @@ function formatDataStreamPart(type, value) {
6574
6574
  `;
6575
6575
  }
6576
6576
  function zodSchema2(zodSchema22, options) {
6577
- var _a172;
6578
- const useReferences = (_a172 = void 0 ) != null ? _a172 : false;
6577
+ var _a173;
6578
+ const useReferences = (_a173 = void 0 ) != null ? _a173 : false;
6579
6579
  return jsonSchema2(
6580
6580
  esm_default(zodSchema22, {
6581
6581
  $refStrategy: useReferences ? "root" : "none",
@@ -6680,11 +6680,11 @@ var major2 = VERSION3.split(".")[0];
6680
6680
  var GLOBAL_OPENTELEMETRY_API_KEY2 = /* @__PURE__ */ Symbol.for("opentelemetry.js.api." + major2);
6681
6681
  var _global2 = _globalThis2;
6682
6682
  function registerGlobal2(type, instance, diag, allowOverride) {
6683
- var _a172;
6683
+ var _a173;
6684
6684
  if (allowOverride === void 0) {
6685
6685
  allowOverride = false;
6686
6686
  }
6687
- var api = _global2[GLOBAL_OPENTELEMETRY_API_KEY2] = (_a172 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) !== null && _a172 !== void 0 ? _a172 : {
6687
+ var api = _global2[GLOBAL_OPENTELEMETRY_API_KEY2] = (_a173 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) !== null && _a173 !== void 0 ? _a173 : {
6688
6688
  version: VERSION3
6689
6689
  };
6690
6690
  if (!allowOverride && api[type]) {
@@ -6702,8 +6702,8 @@ function registerGlobal2(type, instance, diag, allowOverride) {
6702
6702
  return true;
6703
6703
  }
6704
6704
  function getGlobal2(type) {
6705
- var _a172, _b17;
6706
- var globalVersion = (_a172 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _a172 === void 0 ? void 0 : _a172.version;
6705
+ var _a173, _b17;
6706
+ var globalVersion = (_a173 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _a173 === void 0 ? void 0 : _a173.version;
6707
6707
  if (!globalVersion || !isCompatible2(globalVersion)) {
6708
6708
  return;
6709
6709
  }
@@ -6872,13 +6872,13 @@ var DiagAPI2 = (
6872
6872
  }
6873
6873
  var self = this;
6874
6874
  var setLogger = function(logger, optionsOrLogLevel) {
6875
- var _a172, _b17, _c;
6875
+ var _a173, _b17, _c;
6876
6876
  if (optionsOrLogLevel === void 0) {
6877
6877
  optionsOrLogLevel = { logLevel: DiagLogLevel2.INFO };
6878
6878
  }
6879
6879
  if (logger === self) {
6880
6880
  var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
6881
- self.error((_a172 = err.stack) !== null && _a172 !== void 0 ? _a172 : err.message);
6881
+ self.error((_a173 = err.stack) !== null && _a173 !== void 0 ? _a173 : err.message);
6882
6882
  return false;
6883
6883
  }
6884
6884
  if (typeof optionsOrLogLevel === "number") {
@@ -6930,14 +6930,14 @@ var BaseContext2 = (
6930
6930
  return self._currentContext.get(key);
6931
6931
  };
6932
6932
  self.setValue = function(key, value) {
6933
- var context = new BaseContext22(self._currentContext);
6934
- context._currentContext.set(key, value);
6935
- return context;
6933
+ var context2 = new BaseContext22(self._currentContext);
6934
+ context2._currentContext.set(key, value);
6935
+ return context2;
6936
6936
  };
6937
6937
  self.deleteValue = function(key) {
6938
- var context = new BaseContext22(self._currentContext);
6939
- context._currentContext.delete(key);
6940
- return context;
6938
+ var context2 = new BaseContext22(self._currentContext);
6939
+ context2._currentContext.delete(key);
6940
+ return context2;
6941
6941
  };
6942
6942
  }
6943
6943
  return BaseContext22;
@@ -7042,16 +7042,16 @@ var ContextAPI2 = (
7042
7042
  ContextAPI22.prototype.active = function() {
7043
7043
  return this._getContextManager().active();
7044
7044
  };
7045
- ContextAPI22.prototype.with = function(context, fn, thisArg) {
7046
- var _a172;
7045
+ ContextAPI22.prototype.with = function(context2, fn, thisArg) {
7046
+ var _a173;
7047
7047
  var args = [];
7048
7048
  for (var _i = 3; _i < arguments.length; _i++) {
7049
7049
  args[_i - 3] = arguments[_i];
7050
7050
  }
7051
- return (_a172 = this._getContextManager()).with.apply(_a172, __spreadArray42([context, fn, thisArg], __read42(args), false));
7051
+ return (_a173 = this._getContextManager()).with.apply(_a173, __spreadArray42([context2, fn, thisArg], __read42(args), false));
7052
7052
  };
7053
- ContextAPI22.prototype.bind = function(context, target) {
7054
- return this._getContextManager().bind(context, target);
7053
+ ContextAPI22.prototype.bind = function(context2, target) {
7054
+ return this._getContextManager().bind(context2, target);
7055
7055
  };
7056
7056
  ContextAPI22.prototype._getContextManager = function() {
7057
7057
  return getGlobal2(API_NAME22) || NOOP_CONTEXT_MANAGER2;
@@ -7119,24 +7119,24 @@ var NonRecordingSpan2 = (
7119
7119
  })()
7120
7120
  );
7121
7121
  var SPAN_KEY2 = createContextKey2("OpenTelemetry Context Key SPAN");
7122
- function getSpan2(context) {
7123
- return context.getValue(SPAN_KEY2) || void 0;
7122
+ function getSpan2(context2) {
7123
+ return context2.getValue(SPAN_KEY2) || void 0;
7124
7124
  }
7125
7125
  function getActiveSpan2() {
7126
7126
  return getSpan2(ContextAPI2.getInstance().active());
7127
7127
  }
7128
- function setSpan2(context, span) {
7129
- return context.setValue(SPAN_KEY2, span);
7128
+ function setSpan2(context2, span) {
7129
+ return context2.setValue(SPAN_KEY2, span);
7130
7130
  }
7131
- function deleteSpan2(context) {
7132
- return context.deleteValue(SPAN_KEY2);
7131
+ function deleteSpan2(context2) {
7132
+ return context2.deleteValue(SPAN_KEY2);
7133
7133
  }
7134
- function setSpanContext2(context, spanContext) {
7135
- return setSpan2(context, new NonRecordingSpan2(spanContext));
7134
+ function setSpanContext2(context2, spanContext) {
7135
+ return setSpan2(context2, new NonRecordingSpan2(spanContext));
7136
7136
  }
7137
- function getSpanContext2(context) {
7138
- var _a172;
7139
- return (_a172 = getSpan2(context)) === null || _a172 === void 0 ? void 0 : _a172.spanContext();
7137
+ function getSpanContext2(context2) {
7138
+ var _a173;
7139
+ return (_a173 = getSpan2(context2)) === null || _a173 === void 0 ? void 0 : _a173.spanContext();
7140
7140
  }
7141
7141
  var VALID_TRACEID_REGEX2 = /^([0-9a-f]{32})$/i;
7142
7142
  var VALID_SPANID_REGEX2 = /^[0-9a-f]{16}$/i;
@@ -7158,22 +7158,22 @@ var NoopTracer2 = (
7158
7158
  (function() {
7159
7159
  function NoopTracer22() {
7160
7160
  }
7161
- NoopTracer22.prototype.startSpan = function(name172, options, context) {
7162
- if (context === void 0) {
7163
- context = contextApi2.active();
7161
+ NoopTracer22.prototype.startSpan = function(name173, options, context2) {
7162
+ if (context2 === void 0) {
7163
+ context2 = contextApi2.active();
7164
7164
  }
7165
7165
  var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
7166
7166
  if (root) {
7167
7167
  return new NonRecordingSpan2();
7168
7168
  }
7169
- var parentFromContext = context && getSpanContext2(context);
7169
+ var parentFromContext = context2 && getSpanContext2(context2);
7170
7170
  if (isSpanContext2(parentFromContext) && isSpanContextValid2(parentFromContext)) {
7171
7171
  return new NonRecordingSpan2(parentFromContext);
7172
7172
  } else {
7173
7173
  return new NonRecordingSpan2();
7174
7174
  }
7175
7175
  };
7176
- NoopTracer22.prototype.startActiveSpan = function(name172, arg2, arg3, arg4) {
7176
+ NoopTracer22.prototype.startActiveSpan = function(name173, arg2, arg3, arg4) {
7177
7177
  var opts;
7178
7178
  var ctx;
7179
7179
  var fn;
@@ -7190,7 +7190,7 @@ var NoopTracer2 = (
7190
7190
  fn = arg4;
7191
7191
  }
7192
7192
  var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi2.active();
7193
- var span = this.startSpan(name172, opts, parentContext);
7193
+ var span = this.startSpan(name173, opts, parentContext);
7194
7194
  var contextWithSpanSet = setSpan2(parentContext, span);
7195
7195
  return contextApi2.with(contextWithSpanSet, fn, void 0, span);
7196
7196
  };
@@ -7204,14 +7204,14 @@ var NOOP_TRACER2 = new NoopTracer2();
7204
7204
  var ProxyTracer2 = (
7205
7205
  /** @class */
7206
7206
  (function() {
7207
- function ProxyTracer22(_provider, name172, version, options) {
7207
+ function ProxyTracer22(_provider, name173, version, options) {
7208
7208
  this._provider = _provider;
7209
- this.name = name172;
7209
+ this.name = name173;
7210
7210
  this.version = version;
7211
7211
  this.options = options;
7212
7212
  }
7213
- ProxyTracer22.prototype.startSpan = function(name172, options, context) {
7214
- return this._getTracer().startSpan(name172, options, context);
7213
+ ProxyTracer22.prototype.startSpan = function(name173, options, context2) {
7214
+ return this._getTracer().startSpan(name173, options, context2);
7215
7215
  };
7216
7216
  ProxyTracer22.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
7217
7217
  var tracer = this._getTracer();
@@ -7248,20 +7248,20 @@ var ProxyTracerProvider2 = (
7248
7248
  (function() {
7249
7249
  function ProxyTracerProvider22() {
7250
7250
  }
7251
- ProxyTracerProvider22.prototype.getTracer = function(name172, version, options) {
7252
- var _a172;
7253
- return (_a172 = this.getDelegateTracer(name172, version, options)) !== null && _a172 !== void 0 ? _a172 : new ProxyTracer2(this, name172, version, options);
7251
+ ProxyTracerProvider22.prototype.getTracer = function(name173, version, options) {
7252
+ var _a173;
7253
+ return (_a173 = this.getDelegateTracer(name173, version, options)) !== null && _a173 !== void 0 ? _a173 : new ProxyTracer2(this, name173, version, options);
7254
7254
  };
7255
7255
  ProxyTracerProvider22.prototype.getDelegate = function() {
7256
- var _a172;
7257
- return (_a172 = this._delegate) !== null && _a172 !== void 0 ? _a172 : NOOP_TRACER_PROVIDER2;
7256
+ var _a173;
7257
+ return (_a173 = this._delegate) !== null && _a173 !== void 0 ? _a173 : NOOP_TRACER_PROVIDER2;
7258
7258
  };
7259
7259
  ProxyTracerProvider22.prototype.setDelegate = function(delegate) {
7260
7260
  this._delegate = delegate;
7261
7261
  };
7262
- ProxyTracerProvider22.prototype.getDelegateTracer = function(name172, version, options) {
7263
- var _a172;
7264
- return (_a172 = this._delegate) === null || _a172 === void 0 ? void 0 : _a172.getTracer(name172, version, options);
7262
+ ProxyTracerProvider22.prototype.getDelegateTracer = function(name173, version, options) {
7263
+ var _a173;
7264
+ return (_a173 = this._delegate) === null || _a173 === void 0 ? void 0 : _a173.getTracer(name173, version, options);
7265
7265
  };
7266
7266
  return ProxyTracerProvider22;
7267
7267
  })()
@@ -7303,8 +7303,8 @@ var TraceAPI2 = (
7303
7303
  TraceAPI22.prototype.getTracerProvider = function() {
7304
7304
  return getGlobal2(API_NAME32) || this._proxyTracerProvider;
7305
7305
  };
7306
- TraceAPI22.prototype.getTracer = function(name172, version) {
7307
- return this.getTracerProvider().getTracer(name172, version);
7306
+ TraceAPI22.prototype.getTracer = function(name173, version) {
7307
+ return this.getTracerProvider().getTracer(name173, version);
7308
7308
  };
7309
7309
  TraceAPI22.prototype.disable = function() {
7310
7310
  unregisterGlobal2(API_NAME32, DiagAPI2.instance());
@@ -7316,8 +7316,8 @@ var TraceAPI2 = (
7316
7316
  TraceAPI2.getInstance();
7317
7317
  var __defProp3 = Object.defineProperty;
7318
7318
  var __export2 = (target, all) => {
7319
- for (var name172 in all)
7320
- __defProp3(target, name172, { get: all[name172], enumerable: true });
7319
+ for (var name173 in all)
7320
+ __defProp3(target, name173, { get: all[name173], enumerable: true });
7321
7321
  };
7322
7322
  function prepareResponseHeaders(headers, {
7323
7323
  contentType,
@@ -7364,8 +7364,8 @@ var dataContentSchema2 = zod.z.union([
7364
7364
  zod.z.custom(
7365
7365
  // Buffer might not be available in some environments such as CloudFlare:
7366
7366
  (value) => {
7367
- var _a172, _b17;
7368
- return (_b17 = (_a172 = globalThis.Buffer) == null ? void 0 : _a172.isBuffer(value)) != null ? _b17 : false;
7367
+ var _a173, _b17;
7368
+ return (_b17 = (_a173 = globalThis.Buffer) == null ? void 0 : _a173.isBuffer(value)) != null ? _b17 : false;
7369
7369
  },
7370
7370
  { message: "Must be a Buffer" }
7371
7371
  )
@@ -7569,16 +7569,16 @@ var object2 = ({
7569
7569
  }
7570
7570
  }
7571
7571
  },
7572
- parseOutput({ text: text22 }, context) {
7572
+ parseOutput({ text: text22 }, context2) {
7573
7573
  const parseResult = safeParseJSON2({ text: text22 });
7574
7574
  if (!parseResult.success) {
7575
7575
  throw new NoObjectGeneratedError2({
7576
7576
  message: "No object generated: could not parse the response.",
7577
7577
  cause: parseResult.error,
7578
7578
  text: text22,
7579
- response: context.response,
7580
- usage: context.usage,
7581
- finishReason: context.finishReason
7579
+ response: context2.response,
7580
+ usage: context2.usage,
7581
+ finishReason: context2.finishReason
7582
7582
  });
7583
7583
  }
7584
7584
  const validationResult = safeValidateTypes2({
@@ -7590,9 +7590,9 @@ var object2 = ({
7590
7590
  message: "No object generated: response did not match schema.",
7591
7591
  cause: validationResult.error,
7592
7592
  text: text22,
7593
- response: context.response,
7594
- usage: context.usage,
7595
- finishReason: context.finishReason
7593
+ response: context2.response,
7594
+ usage: context2.usage,
7595
+ finishReason: context2.finishReason
7596
7596
  });
7597
7597
  }
7598
7598
  return validationResult.value;
@@ -7890,7 +7890,7 @@ function toDataStreamInternal(stream, callbacks) {
7890
7890
  return stream.pipeThrough(
7891
7891
  new TransformStream({
7892
7892
  transform: async (value, controller) => {
7893
- var _a172;
7893
+ var _a173;
7894
7894
  if (typeof value === "string") {
7895
7895
  controller.enqueue(value);
7896
7896
  return;
@@ -7898,7 +7898,7 @@ function toDataStreamInternal(stream, callbacks) {
7898
7898
  if ("event" in value) {
7899
7899
  if (value.event === "on_chat_model_stream") {
7900
7900
  forwardAIMessageChunk(
7901
- (_a172 = value.data) == null ? void 0 : _a172.chunk,
7901
+ (_a173 = value.data) == null ? void 0 : _a173.chunk,
7902
7902
  controller
7903
7903
  );
7904
7904
  }
@@ -7921,7 +7921,7 @@ function toDataStream(stream, callbacks) {
7921
7921
  );
7922
7922
  }
7923
7923
  function toDataStreamResponse(stream, options) {
7924
- var _a172;
7924
+ var _a173;
7925
7925
  const dataStream = toDataStreamInternal(
7926
7926
  stream,
7927
7927
  options == null ? void 0 : options.callbacks
@@ -7930,7 +7930,7 @@ function toDataStreamResponse(stream, options) {
7930
7930
  const init = options == null ? void 0 : options.init;
7931
7931
  const responseStream = data ? mergeStreams(data.stream, dataStream) : dataStream;
7932
7932
  return new Response(responseStream, {
7933
- status: (_a172 = init == null ? void 0 : init.status) != null ? _a172 : 200,
7933
+ status: (_a173 = init == null ? void 0 : init.status) != null ? _a173 : 200,
7934
7934
  statusText: init == null ? void 0 : init.statusText,
7935
7935
  headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
7936
7936
  contentType: "text/plain; charset=utf-8",
@@ -7981,14 +7981,14 @@ function toDataStream2(stream, callbacks) {
7981
7981
  );
7982
7982
  }
7983
7983
  function toDataStreamResponse2(stream, options = {}) {
7984
- var _a172;
7984
+ var _a173;
7985
7985
  const { init, data, callbacks } = options;
7986
7986
  const dataStream = toDataStreamInternal2(stream, callbacks).pipeThrough(
7987
7987
  new TextEncoderStream()
7988
7988
  );
7989
7989
  const responseStream = data ? mergeStreams(data.stream, dataStream) : dataStream;
7990
7990
  return new Response(responseStream, {
7991
- status: (_a172 = init == null ? void 0 : init.status) != null ? _a172 : 200,
7991
+ status: (_a173 = init == null ? void 0 : init.status) != null ? _a173 : 200,
7992
7992
  statusText: init == null ? void 0 : init.statusText,
7993
7993
  headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
7994
7994
  contentType: "text/plain; charset=utf-8",
@@ -8174,34 +8174,61 @@ var symbol135 = Symbol.for(marker135);
8174
8174
  var _a135;
8175
8175
  var _b13;
8176
8176
  var TypeValidationError3 = class _TypeValidationError4 extends (_b13 = AISDKError3, _a135 = symbol135, _b13) {
8177
- constructor({ value, cause }) {
8177
+ constructor({
8178
+ value,
8179
+ cause,
8180
+ context: context2
8181
+ }) {
8182
+ let contextPrefix = "Type validation failed";
8183
+ if (context2 == null ? void 0 : context2.field) {
8184
+ contextPrefix += ` for ${context2.field}`;
8185
+ }
8186
+ if ((context2 == null ? void 0 : context2.entityName) || (context2 == null ? void 0 : context2.entityId)) {
8187
+ contextPrefix += " (";
8188
+ const parts = [];
8189
+ if (context2.entityName) {
8190
+ parts.push(context2.entityName);
8191
+ }
8192
+ if (context2.entityId) {
8193
+ parts.push(`id: "${context2.entityId}"`);
8194
+ }
8195
+ contextPrefix += parts.join(", ");
8196
+ contextPrefix += ")";
8197
+ }
8178
8198
  super({
8179
8199
  name: name125,
8180
- message: `Type validation failed: Value: ${JSON.stringify(value)}.
8200
+ message: `${contextPrefix}: Value: ${JSON.stringify(value)}.
8181
8201
  Error message: ${getErrorMessage4(cause)}`,
8182
8202
  cause
8183
8203
  });
8184
8204
  this[_a135] = true;
8185
8205
  this.value = value;
8206
+ this.context = context2;
8186
8207
  }
8187
8208
  static isInstance(error) {
8188
8209
  return AISDKError3.hasMarker(error, marker135);
8189
8210
  }
8190
8211
  /**
8191
8212
  * Wraps an error into a TypeValidationError.
8192
- * If the cause is already a TypeValidationError with the same value, it returns the cause.
8213
+ * If the cause is already a TypeValidationError with the same value and context, it returns the cause.
8193
8214
  * Otherwise, it creates a new TypeValidationError.
8194
8215
  *
8195
8216
  * @param {Object} params - The parameters for wrapping the error.
8196
8217
  * @param {unknown} params.value - The value that failed validation.
8197
8218
  * @param {unknown} params.cause - The original error or cause of the validation failure.
8219
+ * @param {TypeValidationContext} params.context - Optional context about what is being validated.
8198
8220
  * @returns {TypeValidationError} A TypeValidationError instance.
8199
8221
  */
8200
8222
  static wrap({
8201
8223
  value,
8202
- cause
8224
+ cause,
8225
+ context: context2
8203
8226
  }) {
8204
- return _TypeValidationError4.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError4({ value, cause });
8227
+ var _a1522, _b152, _c;
8228
+ 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)) {
8229
+ return cause;
8230
+ }
8231
+ return new _TypeValidationError4({ value, cause, context: context2 });
8205
8232
  }
8206
8233
  };
8207
8234
  var ParseError2 = class extends Error {
@@ -8339,6 +8366,14 @@ function combineHeaders2(...headers) {
8339
8366
  function extractResponseHeaders2(response) {
8340
8367
  return Object.fromEntries([...response.headers]);
8341
8368
  }
8369
+ var { btoa: btoa3} = globalThis;
8370
+ function convertUint8ArrayToBase643(array2) {
8371
+ let latin1string = "";
8372
+ for (let i = 0; i < array2.length; i++) {
8373
+ latin1string += String.fromCodePoint(array2[i]);
8374
+ }
8375
+ return btoa3(latin1string);
8376
+ }
8342
8377
  var createIdGenerator3 = ({
8343
8378
  prefix,
8344
8379
  size = 16,
@@ -8370,6 +8405,25 @@ function isAbortError3(error) {
8370
8405
  error.name === "TimeoutError");
8371
8406
  }
8372
8407
  var FETCH_FAILED_ERROR_MESSAGES2 = ["fetch failed", "failed to fetch"];
8408
+ var BUN_ERROR_CODES = [
8409
+ "ConnectionRefused",
8410
+ "ConnectionClosed",
8411
+ "FailedToOpenSocket",
8412
+ "ECONNRESET",
8413
+ "ECONNREFUSED",
8414
+ "ETIMEDOUT",
8415
+ "EPIPE"
8416
+ ];
8417
+ function isBunNetworkError(error) {
8418
+ if (!(error instanceof Error)) {
8419
+ return false;
8420
+ }
8421
+ const code = error.code;
8422
+ if (typeof code === "string" && BUN_ERROR_CODES.includes(code)) {
8423
+ return true;
8424
+ }
8425
+ return false;
8426
+ }
8373
8427
  function handleFetchError2({
8374
8428
  error,
8375
8429
  url,
@@ -8391,6 +8445,15 @@ function handleFetchError2({
8391
8445
  });
8392
8446
  }
8393
8447
  }
8448
+ if (isBunNetworkError(error)) {
8449
+ return new APICallError3({
8450
+ message: `Cannot connect to API: ${error.message}`,
8451
+ cause: error,
8452
+ url,
8453
+ requestBodyValues,
8454
+ isRetryable: true
8455
+ });
8456
+ }
8394
8457
  return error;
8395
8458
  }
8396
8459
  function getRuntimeEnvironmentUserAgent2(globalThisAny = globalThis) {
@@ -8439,7 +8502,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
8439
8502
  );
8440
8503
  return Object.fromEntries(normalizedHeaders.entries());
8441
8504
  }
8442
- var VERSION4 = "4.0.0";
8505
+ var VERSION4 = "4.0.19";
8443
8506
  var getOriginalFetch3 = () => globalThis.fetch;
8444
8507
  var getFromApi2 = async ({
8445
8508
  url,
@@ -8524,8 +8587,8 @@ function loadOptionalSetting2({
8524
8587
  }
8525
8588
  return settingValue;
8526
8589
  }
8527
- var suspectProtoRx2 = /"__proto__"\s*:/;
8528
- var suspectConstructorRx2 = /"constructor"\s*:/;
8590
+ var suspectProtoRx2 = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
8591
+ 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*:/;
8529
8592
  function _parse2(text4) {
8530
8593
  const obj = JSON.parse(text4);
8531
8594
  if (obj === null || typeof obj !== "object") {
@@ -8545,7 +8608,7 @@ function filter2(obj) {
8545
8608
  if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
8546
8609
  throw new SyntaxError("Object contains forbidden prototype property");
8547
8610
  }
8548
- if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
8611
+ if (Object.prototype.hasOwnProperty.call(node, "constructor") && node.constructor !== null && typeof node.constructor === "object" && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
8549
8612
  throw new SyntaxError("Object contains forbidden prototype property");
8550
8613
  }
8551
8614
  for (const key in node) {
@@ -8572,30 +8635,39 @@ function secureJsonParse2(text4) {
8572
8635
  }
8573
8636
  }
8574
8637
  function addAdditionalPropertiesToJsonSchema(jsonSchema22) {
8575
- if (jsonSchema22.type === "object") {
8638
+ if (jsonSchema22.type === "object" || Array.isArray(jsonSchema22.type) && jsonSchema22.type.includes("object")) {
8576
8639
  jsonSchema22.additionalProperties = false;
8577
- const properties = jsonSchema22.properties;
8640
+ const { properties } = jsonSchema22;
8578
8641
  if (properties != null) {
8579
- for (const property in properties) {
8580
- properties[property] = addAdditionalPropertiesToJsonSchema(
8581
- properties[property]
8582
- );
8642
+ for (const key of Object.keys(properties)) {
8643
+ properties[key] = visit(properties[key]);
8583
8644
  }
8584
8645
  }
8585
8646
  }
8586
- if (jsonSchema22.type === "array" && jsonSchema22.items != null) {
8587
- if (Array.isArray(jsonSchema22.items)) {
8588
- jsonSchema22.items = jsonSchema22.items.map(
8589
- (item) => addAdditionalPropertiesToJsonSchema(item)
8590
- );
8591
- } else {
8592
- jsonSchema22.items = addAdditionalPropertiesToJsonSchema(
8593
- jsonSchema22.items
8594
- );
8647
+ if (jsonSchema22.items != null) {
8648
+ jsonSchema22.items = Array.isArray(jsonSchema22.items) ? jsonSchema22.items.map(visit) : visit(jsonSchema22.items);
8649
+ }
8650
+ if (jsonSchema22.anyOf != null) {
8651
+ jsonSchema22.anyOf = jsonSchema22.anyOf.map(visit);
8652
+ }
8653
+ if (jsonSchema22.allOf != null) {
8654
+ jsonSchema22.allOf = jsonSchema22.allOf.map(visit);
8655
+ }
8656
+ if (jsonSchema22.oneOf != null) {
8657
+ jsonSchema22.oneOf = jsonSchema22.oneOf.map(visit);
8658
+ }
8659
+ const { definitions } = jsonSchema22;
8660
+ if (definitions != null) {
8661
+ for (const key of Object.keys(definitions)) {
8662
+ definitions[key] = visit(definitions[key]);
8595
8663
  }
8596
8664
  }
8597
8665
  return jsonSchema22;
8598
8666
  }
8667
+ function visit(def) {
8668
+ if (typeof def === "boolean") return def;
8669
+ return addAdditionalPropertiesToJsonSchema(def);
8670
+ }
8599
8671
  var ignoreOverride3 = /* @__PURE__ */ Symbol(
8600
8672
  "Let zodToJsonSchema decide on which parser to use"
8601
8673
  );
@@ -9712,9 +9784,11 @@ function asSchema3(schema) {
9712
9784
  }
9713
9785
  function standardSchema(standardSchema2) {
9714
9786
  return jsonSchema3(
9715
- () => standardSchema2["~standard"].jsonSchema.input({
9716
- target: "draft-07"
9717
- }),
9787
+ () => addAdditionalPropertiesToJsonSchema(
9788
+ standardSchema2["~standard"].jsonSchema.input({
9789
+ target: "draft-07"
9790
+ })
9791
+ ),
9718
9792
  {
9719
9793
  validate: async (value) => {
9720
9794
  const result = await standardSchema2["~standard"].validate(value);
@@ -9777,17 +9851,19 @@ function zodSchema3(zodSchema22, options) {
9777
9851
  }
9778
9852
  async function validateTypes2({
9779
9853
  value,
9780
- schema
9854
+ schema,
9855
+ context: context2
9781
9856
  }) {
9782
- const result = await safeValidateTypes3({ value, schema });
9857
+ const result = await safeValidateTypes3({ value, schema, context: context2 });
9783
9858
  if (!result.success) {
9784
- throw TypeValidationError3.wrap({ value, cause: result.error });
9859
+ throw TypeValidationError3.wrap({ value, cause: result.error, context: context2 });
9785
9860
  }
9786
9861
  return result.value;
9787
9862
  }
9788
9863
  async function safeValidateTypes3({
9789
9864
  value,
9790
- schema
9865
+ schema,
9866
+ context: context2
9791
9867
  }) {
9792
9868
  const actualSchema = asSchema3(schema);
9793
9869
  try {
@@ -9800,13 +9876,13 @@ async function safeValidateTypes3({
9800
9876
  }
9801
9877
  return {
9802
9878
  success: false,
9803
- error: TypeValidationError3.wrap({ value, cause: result.error }),
9879
+ error: TypeValidationError3.wrap({ value, cause: result.error, context: context2 }),
9804
9880
  rawValue: value
9805
9881
  };
9806
9882
  } catch (error) {
9807
9883
  return {
9808
9884
  success: false,
9809
- error: TypeValidationError3.wrap({ value, cause: error }),
9885
+ error: TypeValidationError3.wrap({ value, cause: error, context: context2 }),
9810
9886
  rawValue: value
9811
9887
  };
9812
9888
  }
@@ -9954,6 +10030,38 @@ var postToApi2 = async ({
9954
10030
  throw handleFetchError2({ error, url, requestBodyValues: body.values });
9955
10031
  }
9956
10032
  };
10033
+ function tool(tool2) {
10034
+ return tool2;
10035
+ }
10036
+ function createProviderToolFactoryWithOutputSchema({
10037
+ id,
10038
+ inputSchema,
10039
+ outputSchema: outputSchema3,
10040
+ supportsDeferredResults
10041
+ }) {
10042
+ return ({
10043
+ execute,
10044
+ needsApproval,
10045
+ toModelOutput,
10046
+ onInputStart,
10047
+ onInputDelta,
10048
+ onInputAvailable,
10049
+ ...args
10050
+ }) => tool({
10051
+ type: "provider",
10052
+ id,
10053
+ args,
10054
+ inputSchema,
10055
+ outputSchema: outputSchema3,
10056
+ execute,
10057
+ needsApproval,
10058
+ toModelOutput,
10059
+ onInputStart,
10060
+ onInputDelta,
10061
+ onInputAvailable,
10062
+ supportsDeferredResults
10063
+ });
10064
+ }
9957
10065
  async function resolve2(value) {
9958
10066
  if (typeof value === "function") {
9959
10067
  value = value();
@@ -10054,15 +10162,15 @@ var createJsonResponseHandler2 = (responseSchema) => async ({ response, url, req
10054
10162
  function withoutTrailingSlash2(url) {
10055
10163
  return url == null ? void 0 : url.replace(/\/$/, "");
10056
10164
  }
10057
- var require_get_context2 = chunkZUQPUTTO_cjs.__commonJS({
10058
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-context.js"(exports, module) {
10165
+ var require_get_context2 = chunkIDRQZVB4_cjs.__commonJS({
10166
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/get-context.js"(exports$1, module) {
10059
10167
  var __defProp22 = Object.defineProperty;
10060
10168
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
10061
10169
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
10062
10170
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
10063
10171
  var __export22 = (target, all) => {
10064
- for (var name145 in all)
10065
- __defProp22(target, name145, { get: all[name145], enumerable: true });
10172
+ for (var name21 in all)
10173
+ __defProp22(target, name21, { get: all[name21], enumerable: true });
10066
10174
  };
10067
10175
  var __copyProps2 = (to, from, except, desc) => {
10068
10176
  if (from && typeof from === "object" || typeof from === "function") {
@@ -10086,15 +10194,15 @@ var require_get_context2 = chunkZUQPUTTO_cjs.__commonJS({
10086
10194
  }
10087
10195
  }
10088
10196
  });
10089
- var require_get_vercel_oidc_token2 = chunkZUQPUTTO_cjs.__commonJS({
10090
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports, module) {
10197
+ var require_get_vercel_oidc_token2 = chunkIDRQZVB4_cjs.__commonJS({
10198
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports$1, module) {
10091
10199
  var __defProp22 = Object.defineProperty;
10092
10200
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
10093
10201
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
10094
10202
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
10095
10203
  var __export22 = (target, all) => {
10096
- for (var name145 in all)
10097
- __defProp22(target, name145, { get: all[name145], enumerable: true });
10204
+ for (var name21 in all)
10205
+ __defProp22(target, name21, { get: all[name21], enumerable: true });
10098
10206
  };
10099
10207
  var __copyProps2 = (to, from, except, desc) => {
10100
10208
  if (from && typeof from === "object" || typeof from === "function") {
@@ -10112,7 +10220,7 @@ var require_get_vercel_oidc_token2 = chunkZUQPUTTO_cjs.__commonJS({
10112
10220
  });
10113
10221
  module.exports = __toCommonJS(get_vercel_oidc_token_exports);
10114
10222
  var import_get_context = require_get_context2();
10115
- var import_token_error = chunkZUQPUTTO_cjs.require_token_error();
10223
+ var import_token_error = chunkIDRQZVB4_cjs.require_token_error();
10116
10224
  async function getVercelOidcToken3() {
10117
10225
  let token = "";
10118
10226
  let err;
@@ -10123,19 +10231,23 @@ var require_get_vercel_oidc_token2 = chunkZUQPUTTO_cjs.__commonJS({
10123
10231
  }
10124
10232
  try {
10125
10233
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
10126
- await import('./token-util-NEHG7TUY-HF7KBP2H.cjs'),
10127
- await import('./token-6GSAFR2W-JV3TZR4M.cjs')
10234
+ await import('./token-util-RMHT2CPJ-6TGPE335.cjs'),
10235
+ await import('./token-APYSY3BW-ZQ7TMBY7.cjs')
10128
10236
  ]);
10129
10237
  if (!token || isExpired(getTokenPayload(token))) {
10130
10238
  await refreshToken();
10131
10239
  token = getVercelOidcTokenSync2();
10132
10240
  }
10133
10241
  } catch (error) {
10134
- if (err?.message && error instanceof Error) {
10135
- error.message = `${err.message}
10242
+ let message = err instanceof Error ? err.message : "";
10243
+ if (error instanceof Error) {
10244
+ message = `${message}
10136
10245
  ${error.message}`;
10137
10246
  }
10138
- throw new import_token_error.VercelOidcTokenError(`Failed to refresh OIDC token`, error);
10247
+ if (message) {
10248
+ throw new import_token_error.VercelOidcTokenError(message);
10249
+ }
10250
+ throw error;
10139
10251
  }
10140
10252
  return token;
10141
10253
  }
@@ -10150,15 +10262,15 @@ ${error.message}`;
10150
10262
  }
10151
10263
  }
10152
10264
  });
10153
- var require_dist2 = chunkZUQPUTTO_cjs.__commonJS({
10154
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/index.js"(exports, module) {
10265
+ var require_dist2 = chunkIDRQZVB4_cjs.__commonJS({
10266
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/index.js"(exports$1, module) {
10155
10267
  var __defProp22 = Object.defineProperty;
10156
10268
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
10157
10269
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
10158
10270
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
10159
10271
  var __export22 = (target, all) => {
10160
- for (var name145 in all)
10161
- __defProp22(target, name145, { get: all[name145], enumerable: true });
10272
+ for (var name21 in all)
10273
+ __defProp22(target, name21, { get: all[name21], enumerable: true });
10162
10274
  };
10163
10275
  var __copyProps2 = (to, from, except, desc) => {
10164
10276
  if (from && typeof from === "object" || typeof from === "function") {
@@ -10180,8 +10292,8 @@ var require_dist2 = chunkZUQPUTTO_cjs.__commonJS({
10180
10292
  var import_get_context = require_get_context2();
10181
10293
  }
10182
10294
  });
10183
- var import_oidc3 = chunkZUQPUTTO_cjs.__toESM(require_dist2(), 1);
10184
- var import_oidc22 = chunkZUQPUTTO_cjs.__toESM(require_dist2(), 1);
10295
+ var import_oidc3 = chunkIDRQZVB4_cjs.__toESM(require_dist2(), 1);
10296
+ var import_oidc22 = chunkIDRQZVB4_cjs.__toESM(require_dist2(), 1);
10185
10297
  var marker19 = "vercel.ai.gateway.error";
10186
10298
  var symbol19 = Symbol.for(marker19);
10187
10299
  var _a19;
@@ -10190,12 +10302,14 @@ var GatewayError2 = class _GatewayError2 extends (_b16 = Error, _a19 = symbol19,
10190
10302
  constructor({
10191
10303
  message,
10192
10304
  statusCode = 500,
10193
- cause
10305
+ cause,
10306
+ generationId
10194
10307
  }) {
10195
- super(message);
10308
+ super(generationId ? `${message} [${generationId}]` : message);
10196
10309
  this[_a19] = true;
10197
10310
  this.statusCode = statusCode;
10198
10311
  this.cause = cause;
10312
+ this.generationId = generationId;
10199
10313
  }
10200
10314
  /**
10201
10315
  * Checks if the given error is a Gateway Error.
@@ -10218,9 +10332,10 @@ var GatewayAuthenticationError2 = class _GatewayAuthenticationError2 extends (_b
10218
10332
  constructor({
10219
10333
  message = "Authentication failed",
10220
10334
  statusCode = 401,
10221
- cause
10335
+ cause,
10336
+ generationId
10222
10337
  } = {}) {
10223
- super({ message, statusCode, cause });
10338
+ super({ message, statusCode, cause, generationId });
10224
10339
  this[_a26] = true;
10225
10340
  this.name = name19;
10226
10341
  this.type = "authentication_error";
@@ -10236,7 +10351,8 @@ var GatewayAuthenticationError2 = class _GatewayAuthenticationError2 extends (_b
10236
10351
  oidcTokenProvided,
10237
10352
  message = "Authentication failed",
10238
10353
  statusCode = 401,
10239
- cause
10354
+ cause,
10355
+ generationId
10240
10356
  }) {
10241
10357
  let contextualMessage;
10242
10358
  if (apiKeyProvided) {
@@ -10264,7 +10380,8 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
10264
10380
  return new _GatewayAuthenticationError2({
10265
10381
  message: contextualMessage,
10266
10382
  statusCode,
10267
- cause
10383
+ cause,
10384
+ generationId
10268
10385
  });
10269
10386
  }
10270
10387
  };
@@ -10277,9 +10394,10 @@ var GatewayInvalidRequestError2 = class extends (_b33 = GatewayError2, _a36 = sy
10277
10394
  constructor({
10278
10395
  message = "Invalid request",
10279
10396
  statusCode = 400,
10280
- cause
10397
+ cause,
10398
+ generationId
10281
10399
  } = {}) {
10282
- super({ message, statusCode, cause });
10400
+ super({ message, statusCode, cause, generationId });
10283
10401
  this[_a36] = true;
10284
10402
  this.name = name26;
10285
10403
  this.type = "invalid_request_error";
@@ -10297,9 +10415,10 @@ var GatewayRateLimitError2 = class extends (_b43 = GatewayError2, _a46 = symbol4
10297
10415
  constructor({
10298
10416
  message = "Rate limit exceeded",
10299
10417
  statusCode = 429,
10300
- cause
10418
+ cause,
10419
+ generationId
10301
10420
  } = {}) {
10302
- super({ message, statusCode, cause });
10421
+ super({ message, statusCode, cause, generationId });
10303
10422
  this[_a46] = true;
10304
10423
  this.name = name36;
10305
10424
  this.type = "rate_limit_exceeded";
@@ -10325,9 +10444,10 @@ var GatewayModelNotFoundError2 = class extends (_b53 = GatewayError2, _a56 = sym
10325
10444
  message = "Model not found",
10326
10445
  statusCode = 404,
10327
10446
  modelId,
10328
- cause
10447
+ cause,
10448
+ generationId
10329
10449
  } = {}) {
10330
- super({ message, statusCode, cause });
10450
+ super({ message, statusCode, cause, generationId });
10331
10451
  this[_a56] = true;
10332
10452
  this.name = name46;
10333
10453
  this.type = "model_not_found";
@@ -10346,9 +10466,10 @@ var GatewayInternalServerError2 = class extends (_b63 = GatewayError2, _a66 = sy
10346
10466
  constructor({
10347
10467
  message = "Internal server error",
10348
10468
  statusCode = 500,
10349
- cause
10469
+ cause,
10470
+ generationId
10350
10471
  } = {}) {
10351
- super({ message, statusCode, cause });
10472
+ super({ message, statusCode, cause, generationId });
10352
10473
  this[_a66] = true;
10353
10474
  this.name = name56;
10354
10475
  this.type = "internal_server_error";
@@ -10368,9 +10489,10 @@ var GatewayResponseError2 = class extends (_b73 = GatewayError2, _a76 = symbol76
10368
10489
  statusCode = 502,
10369
10490
  response,
10370
10491
  validationError,
10371
- cause
10492
+ cause,
10493
+ generationId
10372
10494
  } = {}) {
10373
- super({ message, statusCode, cause });
10495
+ super({ message, statusCode, cause, generationId });
10374
10496
  this[_a76] = true;
10375
10497
  this.name = name66;
10376
10498
  this.type = "response_error";
@@ -10388,34 +10510,49 @@ async function createGatewayErrorFromResponse2({
10388
10510
  cause,
10389
10511
  authMethod
10390
10512
  }) {
10513
+ var _a932;
10391
10514
  const parseResult = await safeValidateTypes3({
10392
10515
  value: response,
10393
10516
  schema: gatewayErrorResponseSchema2
10394
10517
  });
10395
10518
  if (!parseResult.success) {
10519
+ const rawGenerationId = typeof response === "object" && response !== null && "generationId" in response ? response.generationId : void 0;
10396
10520
  return new GatewayResponseError2({
10397
10521
  message: `Invalid error response format: ${defaultMessage}`,
10398
10522
  statusCode,
10399
10523
  response,
10400
10524
  validationError: parseResult.error,
10401
- cause
10525
+ cause,
10526
+ generationId: rawGenerationId
10402
10527
  });
10403
10528
  }
10404
10529
  const validatedResponse = parseResult.value;
10405
10530
  const errorType = validatedResponse.error.type;
10406
10531
  const message = validatedResponse.error.message;
10532
+ const generationId = (_a932 = validatedResponse.generationId) != null ? _a932 : void 0;
10407
10533
  switch (errorType) {
10408
10534
  case "authentication_error":
10409
10535
  return GatewayAuthenticationError2.createContextualError({
10410
10536
  apiKeyProvided: authMethod === "api-key",
10411
10537
  oidcTokenProvided: authMethod === "oidc",
10412
10538
  statusCode,
10413
- cause
10539
+ cause,
10540
+ generationId
10414
10541
  });
10415
10542
  case "invalid_request_error":
10416
- return new GatewayInvalidRequestError2({ message, statusCode, cause });
10543
+ return new GatewayInvalidRequestError2({
10544
+ message,
10545
+ statusCode,
10546
+ cause,
10547
+ generationId
10548
+ });
10417
10549
  case "rate_limit_exceeded":
10418
- return new GatewayRateLimitError2({ message, statusCode, cause });
10550
+ return new GatewayRateLimitError2({
10551
+ message,
10552
+ statusCode,
10553
+ cause,
10554
+ generationId
10555
+ });
10419
10556
  case "model_not_found": {
10420
10557
  const modelResult = await safeValidateTypes3({
10421
10558
  value: validatedResponse.error.param,
@@ -10425,13 +10562,24 @@ async function createGatewayErrorFromResponse2({
10425
10562
  message,
10426
10563
  statusCode,
10427
10564
  modelId: modelResult.success ? modelResult.value.modelId : void 0,
10428
- cause
10565
+ cause,
10566
+ generationId
10429
10567
  });
10430
10568
  }
10431
10569
  case "internal_server_error":
10432
- return new GatewayInternalServerError2({ message, statusCode, cause });
10570
+ return new GatewayInternalServerError2({
10571
+ message,
10572
+ statusCode,
10573
+ cause,
10574
+ generationId
10575
+ });
10433
10576
  default:
10434
- return new GatewayInternalServerError2({ message, statusCode, cause });
10577
+ return new GatewayInternalServerError2({
10578
+ message,
10579
+ statusCode,
10580
+ cause,
10581
+ generationId
10582
+ });
10435
10583
  }
10436
10584
  }
10437
10585
  var gatewayErrorResponseSchema2 = lazySchema(
@@ -10442,25 +10590,93 @@ var gatewayErrorResponseSchema2 = lazySchema(
10442
10590
  type: z4.z.string().nullish(),
10443
10591
  param: z4.z.unknown().nullish(),
10444
10592
  code: z4.z.union([z4.z.string(), z4.z.number()]).nullish()
10445
- })
10593
+ }),
10594
+ generationId: z4.z.string().nullish()
10446
10595
  })
10447
10596
  )
10448
10597
  );
10449
- function asGatewayError2(error, authMethod) {
10450
- var _a832;
10598
+ var name76 = "GatewayTimeoutError";
10599
+ var marker86 = `vercel.ai.gateway.error.${name76}`;
10600
+ var symbol86 = Symbol.for(marker86);
10601
+ var _a86;
10602
+ var _b83;
10603
+ var GatewayTimeoutError = class _GatewayTimeoutError extends (_b83 = GatewayError2, _a86 = symbol86, _b83) {
10604
+ constructor({
10605
+ message = "Request timed out",
10606
+ statusCode = 408,
10607
+ cause,
10608
+ generationId
10609
+ } = {}) {
10610
+ super({ message, statusCode, cause, generationId });
10611
+ this[_a86] = true;
10612
+ this.name = name76;
10613
+ this.type = "timeout_error";
10614
+ }
10615
+ static isInstance(error) {
10616
+ return GatewayError2.hasMarker(error) && symbol86 in error;
10617
+ }
10618
+ /**
10619
+ * Creates a helpful timeout error message with troubleshooting guidance
10620
+ */
10621
+ static createTimeoutError({
10622
+ originalMessage,
10623
+ statusCode = 408,
10624
+ cause,
10625
+ generationId
10626
+ }) {
10627
+ const message = `Gateway request timed out: ${originalMessage}
10628
+
10629
+ 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`;
10630
+ return new _GatewayTimeoutError({
10631
+ message,
10632
+ statusCode,
10633
+ cause,
10634
+ generationId
10635
+ });
10636
+ }
10637
+ };
10638
+ function isTimeoutError(error) {
10639
+ if (!(error instanceof Error)) {
10640
+ return false;
10641
+ }
10642
+ const errorCode = error.code;
10643
+ if (typeof errorCode === "string") {
10644
+ const undiciTimeoutCodes = [
10645
+ "UND_ERR_HEADERS_TIMEOUT",
10646
+ "UND_ERR_BODY_TIMEOUT",
10647
+ "UND_ERR_CONNECT_TIMEOUT"
10648
+ ];
10649
+ return undiciTimeoutCodes.includes(errorCode);
10650
+ }
10651
+ return false;
10652
+ }
10653
+ async function asGatewayError2(error, authMethod) {
10654
+ var _a932;
10451
10655
  if (GatewayError2.isInstance(error)) {
10452
10656
  return error;
10453
10657
  }
10658
+ if (isTimeoutError(error)) {
10659
+ return GatewayTimeoutError.createTimeoutError({
10660
+ originalMessage: error instanceof Error ? error.message : "Unknown error",
10661
+ cause: error
10662
+ });
10663
+ }
10454
10664
  if (APICallError3.isInstance(error)) {
10455
- return createGatewayErrorFromResponse2({
10665
+ if (error.cause && isTimeoutError(error.cause)) {
10666
+ return GatewayTimeoutError.createTimeoutError({
10667
+ originalMessage: error.message,
10668
+ cause: error
10669
+ });
10670
+ }
10671
+ return await createGatewayErrorFromResponse2({
10456
10672
  response: extractApiCallResponse2(error),
10457
- statusCode: (_a832 = error.statusCode) != null ? _a832 : 500,
10673
+ statusCode: (_a932 = error.statusCode) != null ? _a932 : 500,
10458
10674
  defaultMessage: "Gateway request failed",
10459
10675
  cause: error,
10460
10676
  authMethod
10461
10677
  });
10462
10678
  }
10463
- return createGatewayErrorFromResponse2({
10679
+ return await createGatewayErrorFromResponse2({
10464
10680
  response: {},
10465
10681
  statusCode: 500,
10466
10682
  defaultMessage: error instanceof Error ? `Gateway request failed: ${error.message}` : "Unknown Gateway error",
@@ -10562,7 +10778,7 @@ var gatewayAvailableModelsResponseSchema2 = lazySchema(
10562
10778
  provider: z4.z.string(),
10563
10779
  modelId: z4.z.string()
10564
10780
  }),
10565
- modelType: z4.z.enum(["language", "embedding", "image"]).nullish()
10781
+ modelType: z4.z.enum(["embedding", "image", "language", "video"]).nullish()
10566
10782
  })
10567
10783
  )
10568
10784
  })
@@ -10718,7 +10934,7 @@ var GatewayLanguageModel2 = class {
10718
10934
  }
10719
10935
  getModelConfigHeaders(modelId, streaming) {
10720
10936
  return {
10721
- "ai-language-model-specification-version": "2",
10937
+ "ai-language-model-specification-version": "3",
10722
10938
  "ai-language-model-id": modelId,
10723
10939
  "ai-language-model-streaming": String(streaming)
10724
10940
  };
@@ -10741,7 +10957,7 @@ var GatewayEmbeddingModel2 = class {
10741
10957
  abortSignal,
10742
10958
  providerOptions
10743
10959
  }) {
10744
- var _a832;
10960
+ var _a932;
10745
10961
  const resolvedHeaders = await resolve2(this.config.headers());
10746
10962
  try {
10747
10963
  const {
@@ -10772,7 +10988,7 @@ var GatewayEmbeddingModel2 = class {
10772
10988
  });
10773
10989
  return {
10774
10990
  embeddings: responseBody.embeddings,
10775
- usage: (_a832 = responseBody.usage) != null ? _a832 : void 0,
10991
+ usage: (_a932 = responseBody.usage) != null ? _a932 : void 0,
10776
10992
  providerMetadata: responseBody.providerMetadata,
10777
10993
  response: { headers: responseHeaders, body: rawValue },
10778
10994
  warnings: []
@@ -10786,7 +11002,7 @@ var GatewayEmbeddingModel2 = class {
10786
11002
  }
10787
11003
  getModelConfigHeaders() {
10788
11004
  return {
10789
- "ai-embedding-model-specification-version": "2",
11005
+ "ai-embedding-model-specification-version": "3",
10790
11006
  "ai-model-id": this.modelId
10791
11007
  };
10792
11008
  }
@@ -10816,11 +11032,13 @@ var GatewayImageModel2 = class {
10816
11032
  size,
10817
11033
  aspectRatio,
10818
11034
  seed,
11035
+ files,
11036
+ mask,
10819
11037
  providerOptions,
10820
11038
  headers,
10821
11039
  abortSignal
10822
11040
  }) {
10823
- var _a832;
11041
+ var _a932, _b92, _c, _d;
10824
11042
  const resolvedHeaders = await resolve2(this.config.headers());
10825
11043
  try {
10826
11044
  const {
@@ -10840,7 +11058,11 @@ var GatewayImageModel2 = class {
10840
11058
  ...size && { size },
10841
11059
  ...aspectRatio && { aspectRatio },
10842
11060
  ...seed && { seed },
10843
- ...providerOptions && { providerOptions }
11061
+ ...providerOptions && { providerOptions },
11062
+ ...files && {
11063
+ files: files.map((file) => maybeEncodeImageFile(file))
11064
+ },
11065
+ ...mask && { mask: maybeEncodeImageFile(mask) }
10844
11066
  },
10845
11067
  successfulResponseHandler: createJsonResponseHandler2(
10846
11068
  gatewayImageResponseSchema2
@@ -10855,16 +11077,23 @@ var GatewayImageModel2 = class {
10855
11077
  return {
10856
11078
  images: responseBody.images,
10857
11079
  // Always base64 strings from server
10858
- warnings: (_a832 = responseBody.warnings) != null ? _a832 : [],
11080
+ warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
10859
11081
  providerMetadata: responseBody.providerMetadata,
10860
11082
  response: {
10861
11083
  timestamp: /* @__PURE__ */ new Date(),
10862
11084
  modelId: this.modelId,
10863
11085
  headers: responseHeaders
11086
+ },
11087
+ ...responseBody.usage != null && {
11088
+ usage: {
11089
+ inputTokens: (_b92 = responseBody.usage.inputTokens) != null ? _b92 : void 0,
11090
+ outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : void 0,
11091
+ totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : void 0
11092
+ }
10864
11093
  }
10865
11094
  };
10866
11095
  } catch (error) {
10867
- throw asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
11096
+ throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
10868
11097
  }
10869
11098
  }
10870
11099
  getUrl() {
@@ -10872,41 +11101,435 @@ var GatewayImageModel2 = class {
10872
11101
  }
10873
11102
  getModelConfigHeaders() {
10874
11103
  return {
10875
- "ai-image-model-specification-version": "2",
11104
+ "ai-image-model-specification-version": "3",
10876
11105
  "ai-model-id": this.modelId
10877
11106
  };
10878
11107
  }
10879
11108
  };
11109
+ function maybeEncodeImageFile(file) {
11110
+ if (file.type === "file" && file.data instanceof Uint8Array) {
11111
+ return {
11112
+ ...file,
11113
+ data: convertUint8ArrayToBase643(file.data)
11114
+ };
11115
+ }
11116
+ return file;
11117
+ }
10880
11118
  var providerMetadataEntrySchema2 = z4.z.object({
10881
11119
  images: z4.z.array(z4.z.unknown()).optional()
10882
11120
  }).catchall(z4.z.unknown());
11121
+ var gatewayImageWarningSchema = z4.z.discriminatedUnion("type", [
11122
+ z4.z.object({
11123
+ type: z4.z.literal("unsupported"),
11124
+ feature: z4.z.string(),
11125
+ details: z4.z.string().optional()
11126
+ }),
11127
+ z4.z.object({
11128
+ type: z4.z.literal("compatibility"),
11129
+ feature: z4.z.string(),
11130
+ details: z4.z.string().optional()
11131
+ }),
11132
+ z4.z.object({
11133
+ type: z4.z.literal("other"),
11134
+ message: z4.z.string()
11135
+ })
11136
+ ]);
11137
+ var gatewayImageUsageSchema = z4.z.object({
11138
+ inputTokens: z4.z.number().nullish(),
11139
+ outputTokens: z4.z.number().nullish(),
11140
+ totalTokens: z4.z.number().nullish()
11141
+ });
10883
11142
  var gatewayImageResponseSchema2 = z4.z.object({
10884
11143
  images: z4.z.array(z4.z.string()),
10885
11144
  // Always base64 strings over the wire
10886
- warnings: z4.z.array(
10887
- z4.z.object({
10888
- type: z4.z.literal("other"),
10889
- message: z4.z.string()
11145
+ warnings: z4.z.array(gatewayImageWarningSchema).optional(),
11146
+ providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema2).optional(),
11147
+ usage: gatewayImageUsageSchema.optional()
11148
+ });
11149
+ var GatewayVideoModel = class {
11150
+ constructor(modelId, config) {
11151
+ this.modelId = modelId;
11152
+ this.config = config;
11153
+ this.specificationVersion = "v3";
11154
+ this.maxVideosPerCall = Number.MAX_SAFE_INTEGER;
11155
+ }
11156
+ get provider() {
11157
+ return this.config.provider;
11158
+ }
11159
+ async doGenerate({
11160
+ prompt,
11161
+ n,
11162
+ aspectRatio,
11163
+ resolution,
11164
+ duration,
11165
+ fps,
11166
+ seed,
11167
+ image,
11168
+ providerOptions,
11169
+ headers,
11170
+ abortSignal
11171
+ }) {
11172
+ var _a932;
11173
+ const resolvedHeaders = await resolve2(this.config.headers());
11174
+ try {
11175
+ const { responseHeaders, value: responseBody } = await postJsonToApi2({
11176
+ url: this.getUrl(),
11177
+ headers: combineHeaders2(
11178
+ resolvedHeaders,
11179
+ headers != null ? headers : {},
11180
+ this.getModelConfigHeaders(),
11181
+ await resolve2(this.config.o11yHeaders),
11182
+ { accept: "text/event-stream" }
11183
+ ),
11184
+ body: {
11185
+ prompt,
11186
+ n,
11187
+ ...aspectRatio && { aspectRatio },
11188
+ ...resolution && { resolution },
11189
+ ...duration && { duration },
11190
+ ...fps && { fps },
11191
+ ...seed && { seed },
11192
+ ...providerOptions && { providerOptions },
11193
+ ...image && { image: maybeEncodeVideoFile(image) }
11194
+ },
11195
+ successfulResponseHandler: async ({
11196
+ response,
11197
+ url,
11198
+ requestBodyValues
11199
+ }) => {
11200
+ if (response.body == null) {
11201
+ throw new APICallError3({
11202
+ message: "SSE response body is empty",
11203
+ url,
11204
+ requestBodyValues,
11205
+ statusCode: response.status
11206
+ });
11207
+ }
11208
+ const eventStream = parseJsonEventStream2({
11209
+ stream: response.body,
11210
+ schema: gatewayVideoEventSchema
11211
+ });
11212
+ const reader = eventStream.getReader();
11213
+ const { done, value: parseResult } = await reader.read();
11214
+ reader.releaseLock();
11215
+ if (done || !parseResult) {
11216
+ throw new APICallError3({
11217
+ message: "SSE stream ended without a data event",
11218
+ url,
11219
+ requestBodyValues,
11220
+ statusCode: response.status
11221
+ });
11222
+ }
11223
+ if (!parseResult.success) {
11224
+ throw new APICallError3({
11225
+ message: "Failed to parse video SSE event",
11226
+ cause: parseResult.error,
11227
+ url,
11228
+ requestBodyValues,
11229
+ statusCode: response.status
11230
+ });
11231
+ }
11232
+ const event = parseResult.value;
11233
+ if (event.type === "error") {
11234
+ throw new APICallError3({
11235
+ message: event.message,
11236
+ statusCode: event.statusCode,
11237
+ url,
11238
+ requestBodyValues,
11239
+ responseHeaders: Object.fromEntries([...response.headers]),
11240
+ responseBody: JSON.stringify(event),
11241
+ data: {
11242
+ error: {
11243
+ message: event.message,
11244
+ type: event.errorType,
11245
+ param: event.param
11246
+ }
11247
+ }
11248
+ });
11249
+ }
11250
+ return {
11251
+ value: {
11252
+ videos: event.videos,
11253
+ warnings: event.warnings,
11254
+ providerMetadata: event.providerMetadata
11255
+ },
11256
+ responseHeaders: Object.fromEntries([...response.headers])
11257
+ };
11258
+ },
11259
+ failedResponseHandler: createJsonErrorResponseHandler2({
11260
+ errorSchema: z4.z.any(),
11261
+ errorToMessage: (data) => data
11262
+ }),
11263
+ ...abortSignal && { abortSignal },
11264
+ fetch: this.config.fetch
11265
+ });
11266
+ return {
11267
+ videos: responseBody.videos,
11268
+ warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
11269
+ providerMetadata: responseBody.providerMetadata,
11270
+ response: {
11271
+ timestamp: /* @__PURE__ */ new Date(),
11272
+ modelId: this.modelId,
11273
+ headers: responseHeaders
11274
+ }
11275
+ };
11276
+ } catch (error) {
11277
+ throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
11278
+ }
11279
+ }
11280
+ getUrl() {
11281
+ return `${this.config.baseURL}/video-model`;
11282
+ }
11283
+ getModelConfigHeaders() {
11284
+ return {
11285
+ "ai-video-model-specification-version": "3",
11286
+ "ai-model-id": this.modelId
11287
+ };
11288
+ }
11289
+ };
11290
+ function maybeEncodeVideoFile(file) {
11291
+ if (file.type === "file" && file.data instanceof Uint8Array) {
11292
+ return {
11293
+ ...file,
11294
+ data: convertUint8ArrayToBase643(file.data)
11295
+ };
11296
+ }
11297
+ return file;
11298
+ }
11299
+ var providerMetadataEntrySchema22 = z4.z.object({
11300
+ videos: z4.z.array(z4.z.unknown()).optional()
11301
+ }).catchall(z4.z.unknown());
11302
+ var gatewayVideoDataSchema = z4.z.union([
11303
+ z4.z.object({
11304
+ type: z4.z.literal("url"),
11305
+ url: z4.z.string(),
11306
+ mediaType: z4.z.string()
11307
+ }),
11308
+ z4.z.object({
11309
+ type: z4.z.literal("base64"),
11310
+ data: z4.z.string(),
11311
+ mediaType: z4.z.string()
11312
+ })
11313
+ ]);
11314
+ var gatewayVideoWarningSchema = z4.z.discriminatedUnion("type", [
11315
+ z4.z.object({
11316
+ type: z4.z.literal("unsupported"),
11317
+ feature: z4.z.string(),
11318
+ details: z4.z.string().optional()
11319
+ }),
11320
+ z4.z.object({
11321
+ type: z4.z.literal("compatibility"),
11322
+ feature: z4.z.string(),
11323
+ details: z4.z.string().optional()
11324
+ }),
11325
+ z4.z.object({
11326
+ type: z4.z.literal("other"),
11327
+ message: z4.z.string()
11328
+ })
11329
+ ]);
11330
+ var gatewayVideoEventSchema = z4.z.discriminatedUnion("type", [
11331
+ z4.z.object({
11332
+ type: z4.z.literal("result"),
11333
+ videos: z4.z.array(gatewayVideoDataSchema),
11334
+ warnings: z4.z.array(gatewayVideoWarningSchema).optional(),
11335
+ providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema22).optional()
11336
+ }),
11337
+ z4.z.object({
11338
+ type: z4.z.literal("error"),
11339
+ message: z4.z.string(),
11340
+ errorType: z4.z.string(),
11341
+ statusCode: z4.z.number(),
11342
+ param: z4.z.unknown().nullable()
11343
+ })
11344
+ ]);
11345
+ var parallelSearchInputSchema = lazySchema(
11346
+ () => zodSchema3(
11347
+ zod.z.object({
11348
+ objective: zod.z.string().describe(
11349
+ "Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
11350
+ ),
11351
+ search_queries: zod.z.array(zod.z.string()).optional().describe(
11352
+ "Optional search queries to supplement the objective. Maximum 200 characters per query."
11353
+ ),
11354
+ mode: zod.z.enum(["one-shot", "agentic"]).optional().describe(
11355
+ 'Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'
11356
+ ),
11357
+ max_results: zod.z.number().optional().describe(
11358
+ "Maximum number of results to return (1-20). Defaults to 10 if not specified."
11359
+ ),
11360
+ source_policy: zod.z.object({
11361
+ include_domains: zod.z.array(zod.z.string()).optional().describe("List of domains to include in search results."),
11362
+ exclude_domains: zod.z.array(zod.z.string()).optional().describe("List of domains to exclude from search results."),
11363
+ after_date: zod.z.string().optional().describe(
11364
+ "Only include results published after this date (ISO 8601 format)."
11365
+ )
11366
+ }).optional().describe(
11367
+ "Source policy for controlling which domains to include/exclude and freshness."
11368
+ ),
11369
+ excerpts: zod.z.object({
11370
+ max_chars_per_result: zod.z.number().optional().describe("Maximum characters per result."),
11371
+ max_chars_total: zod.z.number().optional().describe("Maximum total characters across all results.")
11372
+ }).optional().describe("Excerpt configuration for controlling result length."),
11373
+ fetch_policy: zod.z.object({
11374
+ max_age_seconds: zod.z.number().optional().describe(
11375
+ "Maximum age in seconds for cached content. Set to 0 to always fetch fresh content."
11376
+ )
11377
+ }).optional().describe("Fetch policy for controlling content freshness.")
10890
11378
  })
10891
- ).optional(),
10892
- providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema2).optional()
11379
+ )
11380
+ );
11381
+ var parallelSearchOutputSchema = lazySchema(
11382
+ () => zodSchema3(
11383
+ zod.z.union([
11384
+ // Success response
11385
+ zod.z.object({
11386
+ searchId: zod.z.string(),
11387
+ results: zod.z.array(
11388
+ zod.z.object({
11389
+ url: zod.z.string(),
11390
+ title: zod.z.string(),
11391
+ excerpt: zod.z.string(),
11392
+ publishDate: zod.z.string().nullable().optional(),
11393
+ relevanceScore: zod.z.number().optional()
11394
+ })
11395
+ )
11396
+ }),
11397
+ // Error response
11398
+ zod.z.object({
11399
+ error: zod.z.enum([
11400
+ "api_error",
11401
+ "rate_limit",
11402
+ "timeout",
11403
+ "invalid_input",
11404
+ "configuration_error",
11405
+ "unknown"
11406
+ ]),
11407
+ statusCode: zod.z.number().optional(),
11408
+ message: zod.z.string()
11409
+ })
11410
+ ])
11411
+ )
11412
+ );
11413
+ var parallelSearchToolFactory = createProviderToolFactoryWithOutputSchema({
11414
+ id: "gateway.parallel_search",
11415
+ inputSchema: parallelSearchInputSchema,
11416
+ outputSchema: parallelSearchOutputSchema
11417
+ });
11418
+ var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
11419
+ var perplexitySearchInputSchema = lazySchema(
11420
+ () => zodSchema3(
11421
+ zod.z.object({
11422
+ query: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).describe(
11423
+ "Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
11424
+ ),
11425
+ max_results: zod.z.number().optional().describe(
11426
+ "Maximum number of search results to return (1-20, default: 10)"
11427
+ ),
11428
+ max_tokens_per_page: zod.z.number().optional().describe(
11429
+ "Maximum number of tokens to extract per search result page (256-2048, default: 2048)"
11430
+ ),
11431
+ max_tokens: zod.z.number().optional().describe(
11432
+ "Maximum total tokens across all search results (default: 25000, max: 1000000)"
11433
+ ),
11434
+ country: zod.z.string().optional().describe(
11435
+ "Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"
11436
+ ),
11437
+ search_domain_filter: zod.z.array(zod.z.string()).optional().describe(
11438
+ "List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"
11439
+ ),
11440
+ search_language_filter: zod.z.array(zod.z.string()).optional().describe(
11441
+ "List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"
11442
+ ),
11443
+ search_after_date: zod.z.string().optional().describe(
11444
+ "Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
11445
+ ),
11446
+ search_before_date: zod.z.string().optional().describe(
11447
+ "Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
11448
+ ),
11449
+ last_updated_after_filter: zod.z.string().optional().describe(
11450
+ "Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
11451
+ ),
11452
+ last_updated_before_filter: zod.z.string().optional().describe(
11453
+ "Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
11454
+ ),
11455
+ search_recency_filter: zod.z.enum(["day", "week", "month", "year"]).optional().describe(
11456
+ "Filter results by relative time period. Cannot be used with search_after_date or search_before_date."
11457
+ )
11458
+ })
11459
+ )
11460
+ );
11461
+ var perplexitySearchOutputSchema = lazySchema(
11462
+ () => zodSchema3(
11463
+ zod.z.union([
11464
+ // Success response
11465
+ zod.z.object({
11466
+ results: zod.z.array(
11467
+ zod.z.object({
11468
+ title: zod.z.string(),
11469
+ url: zod.z.string(),
11470
+ snippet: zod.z.string(),
11471
+ date: zod.z.string().optional(),
11472
+ lastUpdated: zod.z.string().optional()
11473
+ })
11474
+ ),
11475
+ id: zod.z.string()
11476
+ }),
11477
+ // Error response
11478
+ zod.z.object({
11479
+ error: zod.z.enum([
11480
+ "api_error",
11481
+ "rate_limit",
11482
+ "timeout",
11483
+ "invalid_input",
11484
+ "unknown"
11485
+ ]),
11486
+ statusCode: zod.z.number().optional(),
11487
+ message: zod.z.string()
11488
+ })
11489
+ ])
11490
+ )
11491
+ );
11492
+ var perplexitySearchToolFactory = createProviderToolFactoryWithOutputSchema({
11493
+ id: "gateway.perplexity_search",
11494
+ inputSchema: perplexitySearchInputSchema,
11495
+ outputSchema: perplexitySearchOutputSchema
10893
11496
  });
11497
+ var perplexitySearch = (config = {}) => perplexitySearchToolFactory(config);
11498
+ var gatewayTools = {
11499
+ /**
11500
+ * Search the web using Parallel AI's Search API for LLM-optimized excerpts.
11501
+ *
11502
+ * Takes a natural language objective and returns relevant excerpts,
11503
+ * replacing multiple keyword searches with a single call for broad
11504
+ * or complex queries. Supports different search types for depth vs
11505
+ * breadth tradeoffs.
11506
+ */
11507
+ parallelSearch,
11508
+ /**
11509
+ * Search the web using Perplexity's Search API for real-time information,
11510
+ * news, research papers, and articles.
11511
+ *
11512
+ * Provides ranked search results with advanced filtering options including
11513
+ * domain, language, date range, and recency filters.
11514
+ */
11515
+ perplexitySearch
11516
+ };
10894
11517
  async function getVercelRequestId2() {
10895
- var _a832;
10896
- return (_a832 = (0, import_oidc3.getContext)().headers) == null ? void 0 : _a832["x-vercel-id"];
11518
+ var _a932;
11519
+ return (_a932 = (0, import_oidc3.getContext)().headers) == null ? void 0 : _a932["x-vercel-id"];
10897
11520
  }
10898
- var VERSION5 = "3.0.0";
11521
+ var VERSION5 = "3.0.66";
10899
11522
  var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
10900
11523
  function createGatewayProvider2(options = {}) {
10901
- var _a832, _b83;
11524
+ var _a932, _b92;
10902
11525
  let pendingMetadata = null;
10903
11526
  let metadataCache = null;
10904
- const cacheRefreshMillis = (_a832 = options.metadataCacheRefreshMillis) != null ? _a832 : 1e3 * 60 * 5;
11527
+ const cacheRefreshMillis = (_a932 = options.metadataCacheRefreshMillis) != null ? _a932 : 1e3 * 60 * 5;
10905
11528
  let lastFetchTime = 0;
10906
- const baseURL = (_b83 = withoutTrailingSlash2(options.baseURL)) != null ? _b83 : "https://ai-gateway.vercel.sh/v3/ai";
11529
+ const baseURL = (_b92 = withoutTrailingSlash2(options.baseURL)) != null ? _b92 : "https://ai-gateway.vercel.sh/v3/ai";
10907
11530
  const getHeaders = async () => {
10908
- const auth = await getGatewayAuthToken2(options);
10909
- if (auth) {
11531
+ try {
11532
+ const auth = await getGatewayAuthToken2(options);
10910
11533
  return withUserAgentSuffix2(
10911
11534
  {
10912
11535
  Authorization: `Bearer ${auth.token}`,
@@ -10916,12 +11539,14 @@ function createGatewayProvider2(options = {}) {
10916
11539
  },
10917
11540
  `ai-sdk/gateway/${VERSION5}`
10918
11541
  );
11542
+ } catch (error) {
11543
+ throw GatewayAuthenticationError2.createContextualError({
11544
+ apiKeyProvided: false,
11545
+ oidcTokenProvided: false,
11546
+ statusCode: 401,
11547
+ cause: error
11548
+ });
10919
11549
  }
10920
- throw GatewayAuthenticationError2.createContextualError({
10921
- apiKeyProvided: false,
10922
- oidcTokenProvided: false,
10923
- statusCode: 401
10924
- });
10925
11550
  };
10926
11551
  const createO11yHeaders = () => {
10927
11552
  const deploymentId = loadOptionalSetting2({
@@ -10936,13 +11561,18 @@ function createGatewayProvider2(options = {}) {
10936
11561
  settingValue: void 0,
10937
11562
  environmentVariableName: "VERCEL_REGION"
10938
11563
  });
11564
+ const projectId = loadOptionalSetting2({
11565
+ settingValue: void 0,
11566
+ environmentVariableName: "VERCEL_PROJECT_ID"
11567
+ });
10939
11568
  return async () => {
10940
11569
  const requestId = await getVercelRequestId2();
10941
11570
  return {
10942
11571
  ...deploymentId && { "ai-o11y-deployment-id": deploymentId },
10943
11572
  ...environment && { "ai-o11y-environment": environment },
10944
11573
  ...region && { "ai-o11y-region": region },
10945
- ...requestId && { "ai-o11y-request-id": requestId }
11574
+ ...requestId && { "ai-o11y-request-id": requestId },
11575
+ ...projectId && { "ai-o11y-project-id": projectId }
10946
11576
  };
10947
11577
  };
10948
11578
  };
@@ -10956,8 +11586,8 @@ function createGatewayProvider2(options = {}) {
10956
11586
  });
10957
11587
  };
10958
11588
  const getAvailableModels = async () => {
10959
- var _a922, _b92, _c;
10960
- const now2 = (_c = (_b92 = (_a922 = options._internal) == null ? void 0 : _a922.currentDate) == null ? void 0 : _b92.call(_a922).getTime()) != null ? _c : Date.now();
11589
+ var _a1022, _b102, _c;
11590
+ const now2 = (_c = (_b102 = (_a1022 = options._internal) == null ? void 0 : _a1022.currentDate) == null ? void 0 : _b102.call(_a1022).getTime()) != null ? _c : Date.now();
10961
11591
  if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
10962
11592
  lastFetchTime = now2;
10963
11593
  pendingMetadata = new GatewayFetchMetadata2({
@@ -11020,6 +11650,20 @@ function createGatewayProvider2(options = {}) {
11020
11650
  };
11021
11651
  provider.embeddingModel = createEmbeddingModel;
11022
11652
  provider.textEmbeddingModel = createEmbeddingModel;
11653
+ provider.videoModel = (modelId) => {
11654
+ return new GatewayVideoModel(modelId, {
11655
+ provider: "gateway",
11656
+ baseURL,
11657
+ headers: getHeaders,
11658
+ fetch: options.fetch,
11659
+ o11yHeaders: createO11yHeaders()
11660
+ });
11661
+ };
11662
+ provider.chat = provider.languageModel;
11663
+ provider.embedding = provider.embeddingModel;
11664
+ provider.image = provider.imageModel;
11665
+ provider.video = provider.videoModel;
11666
+ provider.tools = gatewayTools;
11023
11667
  return provider;
11024
11668
  }
11025
11669
  createGatewayProvider2();
@@ -11034,15 +11678,11 @@ async function getGatewayAuthToken2(options) {
11034
11678
  authMethod: "api-key"
11035
11679
  };
11036
11680
  }
11037
- try {
11038
- const oidcToken = await (0, import_oidc22.getVercelOidcToken)();
11039
- return {
11040
- token: oidcToken,
11041
- authMethod: "oidc"
11042
- };
11043
- } catch (e) {
11044
- return null;
11045
- }
11681
+ const oidcToken = await (0, import_oidc22.getVercelOidcToken)();
11682
+ return {
11683
+ token: oidcToken,
11684
+ authMethod: "oidc"
11685
+ };
11046
11686
  }
11047
11687
  var _globalThis3 = typeof globalThis === "object" ? globalThis : global;
11048
11688
  var VERSION23 = "1.9.0";
@@ -11115,11 +11755,11 @@ var major3 = VERSION23.split(".")[0];
11115
11755
  var GLOBAL_OPENTELEMETRY_API_KEY3 = /* @__PURE__ */ Symbol.for("opentelemetry.js.api." + major3);
11116
11756
  var _global3 = _globalThis3;
11117
11757
  function registerGlobal3(type, instance, diag, allowOverride) {
11118
- var _a146;
11758
+ var _a21;
11119
11759
  if (allowOverride === void 0) {
11120
11760
  allowOverride = false;
11121
11761
  }
11122
- var api = _global3[GLOBAL_OPENTELEMETRY_API_KEY3] = (_a146 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) !== null && _a146 !== void 0 ? _a146 : {
11762
+ var api = _global3[GLOBAL_OPENTELEMETRY_API_KEY3] = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) !== null && _a21 !== void 0 ? _a21 : {
11123
11763
  version: VERSION23
11124
11764
  };
11125
11765
  if (!allowOverride && api[type]) {
@@ -11137,12 +11777,12 @@ function registerGlobal3(type, instance, diag, allowOverride) {
11137
11777
  return true;
11138
11778
  }
11139
11779
  function getGlobal3(type) {
11140
- var _a146, _b83;
11141
- var globalVersion = (_a146 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _a146 === void 0 ? void 0 : _a146.version;
11780
+ var _a21, _b92;
11781
+ var globalVersion = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _a21 === void 0 ? void 0 : _a21.version;
11142
11782
  if (!globalVersion || !isCompatible3(globalVersion)) {
11143
11783
  return;
11144
11784
  }
11145
- return (_b83 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b83 === void 0 ? void 0 : _b83[type];
11785
+ return (_b92 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b92 === void 0 ? void 0 : _b92[type];
11146
11786
  }
11147
11787
  function unregisterGlobal3(type, diag) {
11148
11788
  diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION23 + ".");
@@ -11307,13 +11947,13 @@ var DiagAPI3 = (
11307
11947
  }
11308
11948
  var self = this;
11309
11949
  var setLogger = function(logger, optionsOrLogLevel) {
11310
- var _a146, _b83, _c;
11950
+ var _a21, _b92, _c;
11311
11951
  if (optionsOrLogLevel === void 0) {
11312
11952
  optionsOrLogLevel = { logLevel: DiagLogLevel3.INFO };
11313
11953
  }
11314
11954
  if (logger === self) {
11315
11955
  var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
11316
- self.error((_a146 = err.stack) !== null && _a146 !== void 0 ? _a146 : err.message);
11956
+ self.error((_a21 = err.stack) !== null && _a21 !== void 0 ? _a21 : err.message);
11317
11957
  return false;
11318
11958
  }
11319
11959
  if (typeof optionsOrLogLevel === "number") {
@@ -11322,7 +11962,7 @@ var DiagAPI3 = (
11322
11962
  };
11323
11963
  }
11324
11964
  var oldLogger = getGlobal3("diag");
11325
- var newLogger = createLogLevelDiagLogger3((_b83 = optionsOrLogLevel.logLevel) !== null && _b83 !== void 0 ? _b83 : DiagLogLevel3.INFO, logger);
11965
+ var newLogger = createLogLevelDiagLogger3((_b92 = optionsOrLogLevel.logLevel) !== null && _b92 !== void 0 ? _b92 : DiagLogLevel3.INFO, logger);
11326
11966
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
11327
11967
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
11328
11968
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -11365,14 +12005,14 @@ var BaseContext3 = (
11365
12005
  return self._currentContext.get(key);
11366
12006
  };
11367
12007
  self.setValue = function(key, value) {
11368
- var context = new BaseContext22(self._currentContext);
11369
- context._currentContext.set(key, value);
11370
- return context;
12008
+ var context2 = new BaseContext22(self._currentContext);
12009
+ context2._currentContext.set(key, value);
12010
+ return context2;
11371
12011
  };
11372
12012
  self.deleteValue = function(key) {
11373
- var context = new BaseContext22(self._currentContext);
11374
- context._currentContext.delete(key);
11375
- return context;
12013
+ var context2 = new BaseContext22(self._currentContext);
12014
+ context2._currentContext.delete(key);
12015
+ return context2;
11376
12016
  };
11377
12017
  }
11378
12018
  return BaseContext22;
@@ -11477,16 +12117,16 @@ var ContextAPI3 = (
11477
12117
  ContextAPI22.prototype.active = function() {
11478
12118
  return this._getContextManager().active();
11479
12119
  };
11480
- ContextAPI22.prototype.with = function(context, fn, thisArg) {
11481
- var _a146;
12120
+ ContextAPI22.prototype.with = function(context2, fn, thisArg) {
12121
+ var _a21;
11482
12122
  var args = [];
11483
12123
  for (var _i = 3; _i < arguments.length; _i++) {
11484
12124
  args[_i - 3] = arguments[_i];
11485
12125
  }
11486
- return (_a146 = this._getContextManager()).with.apply(_a146, __spreadArray43([context, fn, thisArg], __read43(args), false));
12126
+ return (_a21 = this._getContextManager()).with.apply(_a21, __spreadArray43([context2, fn, thisArg], __read43(args), false));
11487
12127
  };
11488
- ContextAPI22.prototype.bind = function(context, target) {
11489
- return this._getContextManager().bind(context, target);
12128
+ ContextAPI22.prototype.bind = function(context2, target) {
12129
+ return this._getContextManager().bind(context2, target);
11490
12130
  };
11491
12131
  ContextAPI22.prototype._getContextManager = function() {
11492
12132
  return getGlobal3(API_NAME23) || NOOP_CONTEXT_MANAGER3;
@@ -11554,24 +12194,24 @@ var NonRecordingSpan3 = (
11554
12194
  })()
11555
12195
  );
11556
12196
  var SPAN_KEY3 = createContextKey3("OpenTelemetry Context Key SPAN");
11557
- function getSpan3(context) {
11558
- return context.getValue(SPAN_KEY3) || void 0;
12197
+ function getSpan3(context2) {
12198
+ return context2.getValue(SPAN_KEY3) || void 0;
11559
12199
  }
11560
12200
  function getActiveSpan3() {
11561
12201
  return getSpan3(ContextAPI3.getInstance().active());
11562
12202
  }
11563
- function setSpan3(context, span) {
11564
- return context.setValue(SPAN_KEY3, span);
12203
+ function setSpan3(context2, span) {
12204
+ return context2.setValue(SPAN_KEY3, span);
11565
12205
  }
11566
- function deleteSpan3(context) {
11567
- return context.deleteValue(SPAN_KEY3);
12206
+ function deleteSpan3(context2) {
12207
+ return context2.deleteValue(SPAN_KEY3);
11568
12208
  }
11569
- function setSpanContext3(context, spanContext) {
11570
- return setSpan3(context, new NonRecordingSpan3(spanContext));
12209
+ function setSpanContext3(context2, spanContext) {
12210
+ return setSpan3(context2, new NonRecordingSpan3(spanContext));
11571
12211
  }
11572
- function getSpanContext3(context) {
11573
- var _a146;
11574
- return (_a146 = getSpan3(context)) === null || _a146 === void 0 ? void 0 : _a146.spanContext();
12212
+ function getSpanContext3(context2) {
12213
+ var _a21;
12214
+ return (_a21 = getSpan3(context2)) === null || _a21 === void 0 ? void 0 : _a21.spanContext();
11575
12215
  }
11576
12216
  var VALID_TRACEID_REGEX3 = /^([0-9a-f]{32})$/i;
11577
12217
  var VALID_SPANID_REGEX3 = /^[0-9a-f]{16}$/i;
@@ -11593,22 +12233,22 @@ var NoopTracer3 = (
11593
12233
  (function() {
11594
12234
  function NoopTracer22() {
11595
12235
  }
11596
- NoopTracer22.prototype.startSpan = function(name145, options, context) {
11597
- if (context === void 0) {
11598
- context = contextApi3.active();
12236
+ NoopTracer22.prototype.startSpan = function(name21, options, context2) {
12237
+ if (context2 === void 0) {
12238
+ context2 = contextApi3.active();
11599
12239
  }
11600
12240
  var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
11601
12241
  if (root) {
11602
12242
  return new NonRecordingSpan3();
11603
12243
  }
11604
- var parentFromContext = context && getSpanContext3(context);
12244
+ var parentFromContext = context2 && getSpanContext3(context2);
11605
12245
  if (isSpanContext3(parentFromContext) && isSpanContextValid3(parentFromContext)) {
11606
12246
  return new NonRecordingSpan3(parentFromContext);
11607
12247
  } else {
11608
12248
  return new NonRecordingSpan3();
11609
12249
  }
11610
12250
  };
11611
- NoopTracer22.prototype.startActiveSpan = function(name145, arg2, arg3, arg4) {
12251
+ NoopTracer22.prototype.startActiveSpan = function(name21, arg2, arg3, arg4) {
11612
12252
  var opts;
11613
12253
  var ctx;
11614
12254
  var fn;
@@ -11625,7 +12265,7 @@ var NoopTracer3 = (
11625
12265
  fn = arg4;
11626
12266
  }
11627
12267
  var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi3.active();
11628
- var span = this.startSpan(name145, opts, parentContext);
12268
+ var span = this.startSpan(name21, opts, parentContext);
11629
12269
  var contextWithSpanSet = setSpan3(parentContext, span);
11630
12270
  return contextApi3.with(contextWithSpanSet, fn, void 0, span);
11631
12271
  };
@@ -11639,14 +12279,14 @@ var NOOP_TRACER3 = new NoopTracer3();
11639
12279
  var ProxyTracer3 = (
11640
12280
  /** @class */
11641
12281
  (function() {
11642
- function ProxyTracer22(_provider, name145, version, options) {
12282
+ function ProxyTracer22(_provider, name21, version, options) {
11643
12283
  this._provider = _provider;
11644
- this.name = name145;
12284
+ this.name = name21;
11645
12285
  this.version = version;
11646
12286
  this.options = options;
11647
12287
  }
11648
- ProxyTracer22.prototype.startSpan = function(name145, options, context) {
11649
- return this._getTracer().startSpan(name145, options, context);
12288
+ ProxyTracer22.prototype.startSpan = function(name21, options, context2) {
12289
+ return this._getTracer().startSpan(name21, options, context2);
11650
12290
  };
11651
12291
  ProxyTracer22.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
11652
12292
  var tracer = this._getTracer();
@@ -11683,20 +12323,20 @@ var ProxyTracerProvider3 = (
11683
12323
  (function() {
11684
12324
  function ProxyTracerProvider22() {
11685
12325
  }
11686
- ProxyTracerProvider22.prototype.getTracer = function(name145, version, options) {
11687
- var _a146;
11688
- return (_a146 = this.getDelegateTracer(name145, version, options)) !== null && _a146 !== void 0 ? _a146 : new ProxyTracer3(this, name145, version, options);
12326
+ ProxyTracerProvider22.prototype.getTracer = function(name21, version, options) {
12327
+ var _a21;
12328
+ return (_a21 = this.getDelegateTracer(name21, version, options)) !== null && _a21 !== void 0 ? _a21 : new ProxyTracer3(this, name21, version, options);
11689
12329
  };
11690
12330
  ProxyTracerProvider22.prototype.getDelegate = function() {
11691
- var _a146;
11692
- return (_a146 = this._delegate) !== null && _a146 !== void 0 ? _a146 : NOOP_TRACER_PROVIDER3;
12331
+ var _a21;
12332
+ return (_a21 = this._delegate) !== null && _a21 !== void 0 ? _a21 : NOOP_TRACER_PROVIDER3;
11693
12333
  };
11694
12334
  ProxyTracerProvider22.prototype.setDelegate = function(delegate) {
11695
12335
  this._delegate = delegate;
11696
12336
  };
11697
- ProxyTracerProvider22.prototype.getDelegateTracer = function(name145, version, options) {
11698
- var _a146;
11699
- return (_a146 = this._delegate) === null || _a146 === void 0 ? void 0 : _a146.getTracer(name145, version, options);
12337
+ ProxyTracerProvider22.prototype.getDelegateTracer = function(name21, version, options) {
12338
+ var _a21;
12339
+ return (_a21 = this._delegate) === null || _a21 === void 0 ? void 0 : _a21.getTracer(name21, version, options);
11700
12340
  };
11701
12341
  return ProxyTracerProvider22;
11702
12342
  })()
@@ -11707,6 +12347,7 @@ var SpanStatusCode3;
11707
12347
  SpanStatusCode22[SpanStatusCode22["OK"] = 1] = "OK";
11708
12348
  SpanStatusCode22[SpanStatusCode22["ERROR"] = 2] = "ERROR";
11709
12349
  })(SpanStatusCode3 || (SpanStatusCode3 = {}));
12350
+ ContextAPI3.getInstance();
11710
12351
  var API_NAME33 = "trace";
11711
12352
  var TraceAPI3 = (
11712
12353
  /** @class */
@@ -11738,8 +12379,8 @@ var TraceAPI3 = (
11738
12379
  TraceAPI22.prototype.getTracerProvider = function() {
11739
12380
  return getGlobal3(API_NAME33) || this._proxyTracerProvider;
11740
12381
  };
11741
- TraceAPI22.prototype.getTracer = function(name145, version) {
11742
- return this.getTracerProvider().getTracer(name145, version);
12382
+ TraceAPI22.prototype.getTracer = function(name21, version) {
12383
+ return this.getTracerProvider().getTracer(name21, version);
11743
12384
  };
11744
12385
  TraceAPI22.prototype.disable = function() {
11745
12386
  unregisterGlobal3(API_NAME33, DiagAPI3.instance());
@@ -11751,13 +12392,13 @@ var TraceAPI3 = (
11751
12392
  TraceAPI3.getInstance();
11752
12393
  var __defProp4 = Object.defineProperty;
11753
12394
  var __export3 = (target, all) => {
11754
- for (var name145 in all)
11755
- __defProp4(target, name145, { get: all[name145], enumerable: true });
12395
+ for (var name21 in all)
12396
+ __defProp4(target, name21, { get: all[name21], enumerable: true });
11756
12397
  };
11757
- var name523 = "AI_NoObjectGeneratedError";
11758
- var marker523 = `vercel.ai.error.${name523}`;
11759
- var symbol523 = Symbol.for(marker523);
11760
- var _a523;
12398
+ var name822 = "AI_NoObjectGeneratedError";
12399
+ var marker823 = `vercel.ai.error.${name822}`;
12400
+ var symbol823 = Symbol.for(marker823);
12401
+ var _a823;
11761
12402
  var NoObjectGeneratedError3 = class extends AISDKError3 {
11762
12403
  constructor({
11763
12404
  message = "No object generated.",
@@ -11767,18 +12408,18 @@ var NoObjectGeneratedError3 = class extends AISDKError3 {
11767
12408
  usage,
11768
12409
  finishReason
11769
12410
  }) {
11770
- super({ name: name523, message, cause });
11771
- this[_a523] = true;
12411
+ super({ name: name822, message, cause });
12412
+ this[_a823] = true;
11772
12413
  this.text = text22;
11773
12414
  this.response = response;
11774
12415
  this.usage = usage;
11775
12416
  this.finishReason = finishReason;
11776
12417
  }
11777
12418
  static isInstance(error) {
11778
- return AISDKError3.hasMarker(error, marker523);
12419
+ return AISDKError3.hasMarker(error, marker823);
11779
12420
  }
11780
12421
  };
11781
- _a523 = symbol523;
12422
+ _a823 = symbol823;
11782
12423
  function formatWarning({
11783
12424
  warning,
11784
12425
  provider,
@@ -12000,8 +12641,8 @@ var dataContentSchema3 = z4.z.union([
12000
12641
  z4.z.custom(
12001
12642
  // Buffer might not be available in some environments such as CloudFlare:
12002
12643
  (value) => {
12003
- var _a146, _b83;
12004
- return (_b83 = (_a146 = globalThis.Buffer) == null ? void 0 : _a146.isBuffer(value)) != null ? _b83 : false;
12644
+ var _a21, _b92;
12645
+ return (_b92 = (_a21 = globalThis.Buffer) == null ? void 0 : _a21.isBuffer(value)) != null ? _b92 : false;
12005
12646
  },
12006
12647
  { message: "Must be a Buffer" }
12007
12648
  )
@@ -12535,37 +13176,42 @@ async function parsePartialJson3(jsonText) {
12535
13176
  return { value: void 0, state: "failed-parse" };
12536
13177
  }
12537
13178
  var text3 = () => ({
13179
+ name: "text",
12538
13180
  responseFormat: Promise.resolve({ type: "text" }),
12539
13181
  async parseCompleteOutput({ text: text22 }) {
12540
13182
  return text22;
12541
13183
  },
12542
13184
  async parsePartialOutput({ text: text22 }) {
12543
13185
  return { partial: text22 };
13186
+ },
13187
+ createElementStreamTransform() {
13188
+ return void 0;
12544
13189
  }
12545
13190
  });
12546
13191
  var object3 = ({
12547
13192
  schema: inputSchema,
12548
- name: name145,
13193
+ name: name21,
12549
13194
  description
12550
13195
  }) => {
12551
13196
  const schema = asSchema3(inputSchema);
12552
13197
  return {
13198
+ name: "object",
12553
13199
  responseFormat: resolve2(schema.jsonSchema).then((jsonSchema22) => ({
12554
13200
  type: "json",
12555
13201
  schema: jsonSchema22,
12556
- ...name145 != null && { name: name145 },
13202
+ ...name21 != null && { name: name21 },
12557
13203
  ...description != null && { description }
12558
13204
  })),
12559
- async parseCompleteOutput({ text: text22 }, context) {
13205
+ async parseCompleteOutput({ text: text22 }, context2) {
12560
13206
  const parseResult = await safeParseJSON3({ text: text22 });
12561
13207
  if (!parseResult.success) {
12562
13208
  throw new NoObjectGeneratedError3({
12563
13209
  message: "No object generated: could not parse the response.",
12564
13210
  cause: parseResult.error,
12565
13211
  text: text22,
12566
- response: context.response,
12567
- usage: context.usage,
12568
- finishReason: context.finishReason
13212
+ response: context2.response,
13213
+ usage: context2.usage,
13214
+ finishReason: context2.finishReason
12569
13215
  });
12570
13216
  }
12571
13217
  const validationResult = await safeValidateTypes3({
@@ -12577,9 +13223,9 @@ var object3 = ({
12577
13223
  message: "No object generated: response did not match schema.",
12578
13224
  cause: validationResult.error,
12579
13225
  text: text22,
12580
- response: context.response,
12581
- usage: context.usage,
12582
- finishReason: context.finishReason
13226
+ response: context2.response,
13227
+ usage: context2.usage,
13228
+ finishReason: context2.finishReason
12583
13229
  });
12584
13230
  }
12585
13231
  return validationResult.value;
@@ -12599,16 +13245,20 @@ var object3 = ({
12599
13245
  };
12600
13246
  }
12601
13247
  }
13248
+ },
13249
+ createElementStreamTransform() {
13250
+ return void 0;
12602
13251
  }
12603
13252
  };
12604
13253
  };
12605
13254
  var array = ({
12606
13255
  element: inputElementSchema,
12607
- name: name145,
13256
+ name: name21,
12608
13257
  description
12609
13258
  }) => {
12610
13259
  const elementSchema = asSchema3(inputElementSchema);
12611
13260
  return {
13261
+ name: "array",
12612
13262
  // JSON schema that describes an array of elements:
12613
13263
  responseFormat: resolve2(elementSchema.jsonSchema).then((jsonSchema22) => {
12614
13264
  const { $schema, ...itemSchema } = jsonSchema22;
@@ -12623,20 +13273,20 @@ var array = ({
12623
13273
  required: ["elements"],
12624
13274
  additionalProperties: false
12625
13275
  },
12626
- ...name145 != null && { name: name145 },
13276
+ ...name21 != null && { name: name21 },
12627
13277
  ...description != null && { description }
12628
13278
  };
12629
13279
  }),
12630
- async parseCompleteOutput({ text: text22 }, context) {
13280
+ async parseCompleteOutput({ text: text22 }, context2) {
12631
13281
  const parseResult = await safeParseJSON3({ text: text22 });
12632
13282
  if (!parseResult.success) {
12633
13283
  throw new NoObjectGeneratedError3({
12634
13284
  message: "No object generated: could not parse the response.",
12635
13285
  cause: parseResult.error,
12636
13286
  text: text22,
12637
- response: context.response,
12638
- usage: context.usage,
12639
- finishReason: context.finishReason
13287
+ response: context2.response,
13288
+ usage: context2.usage,
13289
+ finishReason: context2.finishReason
12640
13290
  });
12641
13291
  }
12642
13292
  const outerValue = parseResult.value;
@@ -12648,9 +13298,9 @@ var array = ({
12648
13298
  cause: "response must be an object with an elements array"
12649
13299
  }),
12650
13300
  text: text22,
12651
- response: context.response,
12652
- usage: context.usage,
12653
- finishReason: context.finishReason
13301
+ response: context2.response,
13302
+ usage: context2.usage,
13303
+ finishReason: context2.finishReason
12654
13304
  });
12655
13305
  }
12656
13306
  for (const element of outerValue.elements) {
@@ -12663,9 +13313,9 @@ var array = ({
12663
13313
  message: "No object generated: response did not match schema.",
12664
13314
  cause: validationResult.error,
12665
13315
  text: text22,
12666
- response: context.response,
12667
- usage: context.usage,
12668
- finishReason: context.finishReason
13316
+ response: context2.response,
13317
+ usage: context2.usage,
13318
+ finishReason: context2.finishReason
12669
13319
  });
12670
13320
  }
12671
13321
  }
@@ -12698,15 +13348,28 @@ var array = ({
12698
13348
  return { partial: parsedElements };
12699
13349
  }
12700
13350
  }
13351
+ },
13352
+ createElementStreamTransform() {
13353
+ let publishedElements = 0;
13354
+ return new TransformStream({
13355
+ transform({ partialOutput }, controller) {
13356
+ if (partialOutput != null) {
13357
+ for (; publishedElements < partialOutput.length; publishedElements++) {
13358
+ controller.enqueue(partialOutput[publishedElements]);
13359
+ }
13360
+ }
13361
+ }
13362
+ });
12701
13363
  }
12702
13364
  };
12703
13365
  };
12704
13366
  var choice = ({
12705
13367
  options: choiceOptions,
12706
- name: name145,
13368
+ name: name21,
12707
13369
  description
12708
13370
  }) => {
12709
13371
  return {
13372
+ name: "choice",
12710
13373
  // JSON schema that describes an enumeration:
12711
13374
  responseFormat: Promise.resolve({
12712
13375
  type: "json",
@@ -12719,19 +13382,19 @@ var choice = ({
12719
13382
  required: ["result"],
12720
13383
  additionalProperties: false
12721
13384
  },
12722
- ...name145 != null && { name: name145 },
13385
+ ...name21 != null && { name: name21 },
12723
13386
  ...description != null && { description }
12724
13387
  }),
12725
- async parseCompleteOutput({ text: text22 }, context) {
13388
+ async parseCompleteOutput({ text: text22 }, context2) {
12726
13389
  const parseResult = await safeParseJSON3({ text: text22 });
12727
13390
  if (!parseResult.success) {
12728
13391
  throw new NoObjectGeneratedError3({
12729
13392
  message: "No object generated: could not parse the response.",
12730
13393
  cause: parseResult.error,
12731
13394
  text: text22,
12732
- response: context.response,
12733
- usage: context.usage,
12734
- finishReason: context.finishReason
13395
+ response: context2.response,
13396
+ usage: context2.usage,
13397
+ finishReason: context2.finishReason
12735
13398
  });
12736
13399
  }
12737
13400
  const outerValue = parseResult.value;
@@ -12743,9 +13406,9 @@ var choice = ({
12743
13406
  cause: "response must be an object that contains a choice value."
12744
13407
  }),
12745
13408
  text: text22,
12746
- response: context.response,
12747
- usage: context.usage,
12748
- finishReason: context.finishReason
13409
+ response: context2.response,
13410
+ usage: context2.usage,
13411
+ finishReason: context2.finishReason
12749
13412
  });
12750
13413
  }
12751
13414
  return outerValue.result;
@@ -12773,29 +13436,33 @@ var choice = ({
12773
13436
  }
12774
13437
  }
12775
13438
  }
13439
+ },
13440
+ createElementStreamTransform() {
13441
+ return void 0;
12776
13442
  }
12777
13443
  };
12778
13444
  };
12779
13445
  var json = ({
12780
- name: name145,
13446
+ name: name21,
12781
13447
  description
12782
13448
  } = {}) => {
12783
13449
  return {
13450
+ name: "json",
12784
13451
  responseFormat: Promise.resolve({
12785
13452
  type: "json",
12786
- ...name145 != null && { name: name145 },
13453
+ ...name21 != null && { name: name21 },
12787
13454
  ...description != null && { description }
12788
13455
  }),
12789
- async parseCompleteOutput({ text: text22 }, context) {
13456
+ async parseCompleteOutput({ text: text22 }, context2) {
12790
13457
  const parseResult = await safeParseJSON3({ text: text22 });
12791
13458
  if (!parseResult.success) {
12792
13459
  throw new NoObjectGeneratedError3({
12793
13460
  message: "No object generated: could not parse the response.",
12794
13461
  cause: parseResult.error,
12795
13462
  text: text22,
12796
- response: context.response,
12797
- usage: context.usage,
12798
- finishReason: context.finishReason
13463
+ response: context2.response,
13464
+ usage: context2.usage,
13465
+ finishReason: context2.finishReason
12799
13466
  });
12800
13467
  }
12801
13468
  return parseResult.value;
@@ -12812,6 +13479,9 @@ var json = ({
12812
13479
  return result.value === void 0 ? void 0 : { partial: result.value };
12813
13480
  }
12814
13481
  }
13482
+ },
13483
+ createElementStreamTransform() {
13484
+ return void 0;
12815
13485
  }
12816
13486
  };
12817
13487
  };
@@ -12848,6 +13518,7 @@ function customProvider3({
12848
13518
  transcriptionModels,
12849
13519
  speechModels,
12850
13520
  rerankingModels,
13521
+ videoModels,
12851
13522
  fallbackProvider: fallbackProviderArg
12852
13523
  }) {
12853
13524
  const fallbackProvider = fallbackProviderArg ? asProviderV3(fallbackProviderArg) : void 0;
@@ -12906,6 +13577,16 @@ function customProvider3({
12906
13577
  return fallbackProvider.rerankingModel(modelId);
12907
13578
  }
12908
13579
  throw new NoSuchModelError3({ modelId, modelType: "rerankingModel" });
13580
+ },
13581
+ videoModel(modelId) {
13582
+ if (videoModels != null && modelId in videoModels) {
13583
+ return videoModels[modelId];
13584
+ }
13585
+ const videoModel = fallbackProvider == null ? void 0 : fallbackProvider.videoModel;
13586
+ if (videoModel) {
13587
+ return videoModel(modelId);
13588
+ }
13589
+ throw new NoSuchModelError3({ modelId, modelType: "videoModel" });
12909
13590
  }
12910
13591
  };
12911
13592
  }
@@ -12914,6 +13595,12 @@ async function getModelCachePath() {
12914
13595
  await fsp__default.default.mkdir(cachePath, { recursive: true });
12915
13596
  return cachePath;
12916
13597
  }
13598
+ async function warmup() {
13599
+ const cacheDir = await getModelCachePath();
13600
+ const retrieve = fastembed$1.FlagEmbedding.retrieveModel.bind(fastembed$1.FlagEmbedding);
13601
+ await retrieve(fastembed$1.EmbeddingModel.BGESmallENV15, cacheDir, false);
13602
+ await retrieve(fastembed$1.EmbeddingModel.BGEBaseENV15, cacheDir, false);
13603
+ }
12917
13604
  async function generateEmbeddings(values, modelType) {
12918
13605
  const model = await fastembed$1.FlagEmbedding.init({
12919
13606
  model: fastembed$1.EmbeddingModel[modelType],
@@ -13013,5 +13700,6 @@ var fastembed = Object.assign(fastEmbedProviderV3.embeddingModel(`bge-small-en-v
13013
13700
  });
13014
13701
 
13015
13702
  exports.fastembed = fastembed;
13703
+ exports.warmup = warmup;
13016
13704
  //# sourceMappingURL=index.cjs.map
13017
13705
  //# sourceMappingURL=index.cjs.map