@pensar/apex 2.1.2 → 2.1.3-canary.9978c1ae

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 (55) hide show
  1. package/build/agent-brysbb20.js +19 -0
  2. package/build/{agent-737mxp3v.js → agent-gf41p56q.js} +8 -8
  3. package/build/{agent-vdrtakz4.js → agent-yz2ygex0.js} +10 -10
  4. package/build/{apps-j0bwey0w.js → apps-yzmjmpf9.js} +16 -16
  5. package/build/{auth-5stxpmga.js → auth-p29y3nzn.js} +16 -16
  6. package/build/authentication-mh5ymtgy.js +19 -0
  7. package/build/blackboxAgent-3z0r12m0.js +19 -0
  8. package/build/{blackboxPentest-2edr9rj3.js → blackboxPentest-dg3b1t6b.js} +14 -14
  9. package/build/{cli-v1aqbv58.js → cli-1xx6s4nh.js} +24882 -26968
  10. package/build/{cli-9z6vwf30.js → cli-24mzbewx.js} +1 -1
  11. package/build/{cli-f7d23ded.js → cli-29yqhrjq.js} +936 -1775
  12. package/build/{cli-gbkj2has.js → cli-366c64xy.js} +3 -3
  13. package/build/{cli-0gk2x2sc.js → cli-704tt332.js} +3 -3
  14. package/build/{cli-xnnkeg5p.js → cli-80jkzpct.js} +1 -1
  15. package/build/{cli-yjbkaqvy.js → cli-bpcymyg8.js} +43 -13
  16. package/build/{cli-tw3fe8bj.js → cli-d4bn60j7.js} +2 -2
  17. package/build/{cli-ks60cc3h.js → cli-dgyyj1b0.js} +30 -30
  18. package/build/{cli-6vs0mtsb.js → cli-ecp92fqe.js} +2 -2
  19. package/build/{cli-6wwpk9d9.js → cli-fex1cvdc.js} +1 -1
  20. package/build/{cli-35czfv00.js → cli-hty9x6e3.js} +68109 -77017
  21. package/build/{cli-jd0c0b91.js → cli-j313zw46.js} +1 -1
  22. package/build/{cli-dqkdnd3c.js → cli-mmc95pfp.js} +88 -49
  23. package/build/{cli-9vzc18m5.js → cli-qnqppth7.js} +8 -8
  24. package/build/{cli-hj3t87r2.js → cli-twhj2d1q.js} +1 -1
  25. package/build/{cli-whtdyc0e.js → cli-zbwmbxpd.js} +3 -3
  26. package/build/cli.js +68 -68
  27. package/build/{config-s5ryv5ez.js → config-t3ny5d68.js} +3 -3
  28. package/build/{doctor-f08gegwc.js → doctor-atj45rne.js} +7 -7
  29. package/build/{fixes-qf4s92z2.js → fixes-pqgk5v9z.js} +16 -16
  30. package/build/{index-gakk2t5q.js → index-7cw66451.js} +18 -18
  31. package/build/{index-x4xefngs.js → index-9j3fxkcg.js} +3 -3
  32. package/build/{index-s8gw83d6.js → index-cm74qg8e.js} +17 -9
  33. package/build/{index-sqjve2bm.js → index-ehk56y92.js} +2 -2
  34. package/build/{index-5h1hjhzw.js → index-eyt8y7cq.js} +10 -10
  35. package/build/{index-mgng15va.js → index-n1yh9e86.js} +909 -456
  36. package/build/{index-c6qz0gve.js → index-n22g9ytc.js} +7 -7
  37. package/build/{index-exvkbve0.js → index-s03jmg2x.js} +4 -4
  38. package/build/{issues-5anqrh2j.js → issues-6gyfhe2j.js} +16 -16
  39. package/build/{logs-q6ankt6m.js → logs-5ga7w81s.js} +16 -16
  40. package/build/{main-3zneyg7p.js → main-3d7dfdvs.js} +17 -93
  41. package/build/{offesecAgent-hsej0pfc.js → offesecAgent-zvj9q4yc.js} +9 -9
  42. package/build/pentest-90d9gtrs.js +28 -0
  43. package/build/{pentests-hyx3c3qa.js → pentests-887d85z1.js} +16 -16
  44. package/build/{targetedPentest-ws0a7frk.js → targetedPentest-56fzgqyw.js} +10 -10
  45. package/build/{targets-9cqrshet.js → targets-63cs73s2.js} +16 -16
  46. package/build/threatModel-gznjwpk9.js +26 -0
  47. package/build/{uninstall-1j469qj7.js → uninstall-6hc47s0e.js} +1 -1
  48. package/build/{upload-ymvhkyq5.js → upload-8kv9v08h.js} +7 -7
  49. package/build/{utils-d1ed6jzf.js → utils-etpb7d2y.js} +6 -6
  50. package/package.json +30 -30
  51. package/build/agent-8w9h3tnw.js +0 -19
  52. package/build/authentication-qswvctj4.js +0 -19
  53. package/build/blackboxAgent-vwm9t3h4.js +0 -19
  54. package/build/pentest-1e30q7rs.js +0 -28
  55. package/build/threatModel-z9b213x8.js +0 -26
@@ -14937,14 +14937,6 @@ var init_v4 = __esm(() => {
14937
14937
  init_classic();
14938
14938
  });
14939
14939
 
14940
- // node_modules/zod/index.js
14941
- var zod_default;
14942
- var init_zod = __esm(() => {
14943
- init_external();
14944
- init_external();
14945
- zod_default = exports_external;
14946
- });
14947
-
14948
14940
  // node_modules/zod/v3/helpers/util.js
14949
14941
  var util, objectUtil, ZodParsedType, getParsedType2 = (data) => {
14950
14942
  const t = typeof data;
@@ -18934,16 +18926,78 @@ var init_stream = __esm(() => {
18934
18926
  };
18935
18927
  });
18936
18928
 
18937
- // node_modules/@ai-sdk/gateway/node_modules/@ai-sdk/provider-utils/dist/index.mjs
18929
+ // node_modules/@ai-sdk/provider-utils/dist/index.mjs
18938
18930
  function combineHeaders(...headers) {
18939
18931
  return headers.reduce((combinedHeaders, currentHeaders) => ({
18940
18932
  ...combinedHeaders,
18941
18933
  ...currentHeaders != null ? currentHeaders : {}
18942
18934
  }), {});
18943
18935
  }
18936
+ function createToolNameMapping({
18937
+ tools = [],
18938
+ providerToolNames,
18939
+ resolveProviderToolName
18940
+ }) {
18941
+ var _a22;
18942
+ const customToolNameToProviderToolName = {};
18943
+ const providerToolNameToCustomToolName = {};
18944
+ for (const tool2 of tools) {
18945
+ if (tool2.type === "provider") {
18946
+ const providerToolName = (_a22 = resolveProviderToolName == null ? undefined : resolveProviderToolName(tool2)) != null ? _a22 : (tool2.id in providerToolNames) ? providerToolNames[tool2.id] : undefined;
18947
+ if (providerToolName == null) {
18948
+ continue;
18949
+ }
18950
+ customToolNameToProviderToolName[tool2.name] = providerToolName;
18951
+ providerToolNameToCustomToolName[providerToolName] = tool2.name;
18952
+ }
18953
+ }
18954
+ return {
18955
+ toProviderToolName: (customToolName) => {
18956
+ var _a32;
18957
+ return (_a32 = customToolNameToProviderToolName[customToolName]) != null ? _a32 : customToolName;
18958
+ },
18959
+ toCustomToolName: (providerToolName) => {
18960
+ var _a32;
18961
+ return (_a32 = providerToolNameToCustomToolName[providerToolName]) != null ? _a32 : providerToolName;
18962
+ }
18963
+ };
18964
+ }
18965
+ async function delay(delayInMs, options) {
18966
+ if (delayInMs == null) {
18967
+ return Promise.resolve();
18968
+ }
18969
+ const signal = options == null ? undefined : options.abortSignal;
18970
+ return new Promise((resolve2, reject) => {
18971
+ if (signal == null ? undefined : signal.aborted) {
18972
+ reject(createAbortError());
18973
+ return;
18974
+ }
18975
+ const timeoutId = setTimeout(() => {
18976
+ cleanup();
18977
+ resolve2();
18978
+ }, delayInMs);
18979
+ const cleanup = () => {
18980
+ clearTimeout(timeoutId);
18981
+ signal == null || signal.removeEventListener("abort", onAbort);
18982
+ };
18983
+ const onAbort = () => {
18984
+ cleanup();
18985
+ reject(createAbortError());
18986
+ };
18987
+ signal == null || signal.addEventListener("abort", onAbort);
18988
+ });
18989
+ }
18990
+ function createAbortError() {
18991
+ return new DOMException("Delay was aborted", "AbortError");
18992
+ }
18944
18993
  function extractResponseHeaders(response) {
18945
18994
  return Object.fromEntries([...response.headers]);
18946
18995
  }
18996
+ function convertBase64ToUint8Array(base64String) {
18997
+ const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
18998
+ const latin1string = atob2(base64Url);
18999
+ return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
19000
+ }
18947
19001
  function convertUint8ArrayToBase64(array2) {
18948
19002
  let latin1string = "";
18949
19003
  for (let i = 0;i < array2.length; i++) {
@@ -18951,6 +19005,327 @@ function convertUint8ArrayToBase64(array2) {
18951
19005
  }
18952
19006
  return btoa2(latin1string);
18953
19007
  }
19008
+ function convertToBase64(value) {
19009
+ return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
19010
+ }
19011
+ function convertToFormData(input, options = {}) {
19012
+ const { useArrayBrackets = true } = options;
19013
+ const formData = new FormData;
19014
+ for (const [key, value] of Object.entries(input)) {
19015
+ if (value == null) {
19016
+ continue;
19017
+ }
19018
+ if (Array.isArray(value)) {
19019
+ if (value.length === 1) {
19020
+ formData.append(key, value[0]);
19021
+ continue;
19022
+ }
19023
+ const arrayKey = useArrayBrackets ? `${key}[]` : key;
19024
+ for (const item of value) {
19025
+ formData.append(arrayKey, item);
19026
+ }
19027
+ continue;
19028
+ }
19029
+ formData.append(key, value);
19030
+ }
19031
+ return formData;
19032
+ }
19033
+ async function cancelResponseBody(response) {
19034
+ var _a22;
19035
+ try {
19036
+ await ((_a22 = response.body) == null ? undefined : _a22.cancel());
19037
+ } catch (e) {}
19038
+ }
19039
+ function isBrowserRuntime(globalThisAny = globalThis) {
19040
+ return globalThisAny.window != null;
19041
+ }
19042
+ function validateDownloadUrl(url2) {
19043
+ let parsed;
19044
+ try {
19045
+ parsed = new URL(url2);
19046
+ } catch (e) {
19047
+ throw new DownloadError({
19048
+ url: url2,
19049
+ message: `Invalid URL: ${url2}`
19050
+ });
19051
+ }
19052
+ if (parsed.protocol === "data:") {
19053
+ return;
19054
+ }
19055
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
19056
+ throw new DownloadError({
19057
+ url: url2,
19058
+ message: `URL scheme must be http, https, or data, got ${parsed.protocol}`
19059
+ });
19060
+ }
19061
+ const hostname3 = parsed.hostname.toLowerCase().replace(/\.+$/, "");
19062
+ if (!hostname3) {
19063
+ throw new DownloadError({
19064
+ url: url2,
19065
+ message: `URL must have a hostname`
19066
+ });
19067
+ }
19068
+ if (hostname3 === "localhost" || hostname3.endsWith(".local") || hostname3.endsWith(".localhost")) {
19069
+ throw new DownloadError({
19070
+ url: url2,
19071
+ message: `URL with hostname ${hostname3} is not allowed`
19072
+ });
19073
+ }
19074
+ if (hostname3.startsWith("[") && hostname3.endsWith("]")) {
19075
+ const ipv63 = hostname3.slice(1, -1);
19076
+ if (isPrivateIPv6(ipv63)) {
19077
+ throw new DownloadError({
19078
+ url: url2,
19079
+ message: `URL with IPv6 address ${hostname3} is not allowed`
19080
+ });
19081
+ }
19082
+ return;
19083
+ }
19084
+ if (isIPv4(hostname3)) {
19085
+ if (isPrivateIPv4(hostname3)) {
19086
+ throw new DownloadError({
19087
+ url: url2,
19088
+ message: `URL with IP address ${hostname3} is not allowed`
19089
+ });
19090
+ }
19091
+ return;
19092
+ }
19093
+ }
19094
+ function isIPv4(hostname3) {
19095
+ const parts = hostname3.split(".");
19096
+ if (parts.length !== 4)
19097
+ return false;
19098
+ return parts.every((part) => {
19099
+ const num = Number(part);
19100
+ return Number.isInteger(num) && num >= 0 && num <= 255 && String(num) === part;
19101
+ });
19102
+ }
19103
+ function isPrivateIPv4(ip) {
19104
+ const parts = ip.split(".").map(Number);
19105
+ const [a, b, c] = parts;
19106
+ if (a === 0)
19107
+ return true;
19108
+ if (a === 10)
19109
+ return true;
19110
+ if (a === 100 && b >= 64 && b <= 127)
19111
+ return true;
19112
+ if (a === 127)
19113
+ return true;
19114
+ if (a === 169 && b === 254)
19115
+ return true;
19116
+ if (a === 172 && b >= 16 && b <= 31)
19117
+ return true;
19118
+ if (a === 192 && b === 0 && c === 0)
19119
+ return true;
19120
+ if (a === 192 && b === 168)
19121
+ return true;
19122
+ if (a === 198 && (b === 18 || b === 19))
19123
+ return true;
19124
+ if (a >= 240)
19125
+ return true;
19126
+ return false;
19127
+ }
19128
+ function parseIPv6(ip) {
19129
+ let address = ip.toLowerCase();
19130
+ const zoneIndex = address.indexOf("%");
19131
+ if (zoneIndex !== -1) {
19132
+ address = address.slice(0, zoneIndex);
19133
+ }
19134
+ const halves = address.split("::");
19135
+ if (halves.length > 2)
19136
+ return null;
19137
+ const toGroups = (segment) => {
19138
+ if (segment === "")
19139
+ return [];
19140
+ const groups = [];
19141
+ const parts = segment.split(":");
19142
+ for (let i = 0;i < parts.length; i++) {
19143
+ const part = parts[i];
19144
+ if (part.includes(".")) {
19145
+ if (i !== parts.length - 1 || !isIPv4(part))
19146
+ return null;
19147
+ const [a, b, c, d] = part.split(".").map(Number);
19148
+ groups.push(a << 8 | b, c << 8 | d);
19149
+ continue;
19150
+ }
19151
+ if (!/^[0-9a-f]{1,4}$/.test(part))
19152
+ return null;
19153
+ groups.push(parseInt(part, 16));
19154
+ }
19155
+ return groups;
19156
+ };
19157
+ const head = toGroups(halves[0]);
19158
+ if (head === null)
19159
+ return null;
19160
+ if (halves.length === 2) {
19161
+ const tail = toGroups(halves[1]);
19162
+ if (tail === null)
19163
+ return null;
19164
+ const fill = 8 - head.length - tail.length;
19165
+ if (fill < 0)
19166
+ return null;
19167
+ return [...head, ...new Array(fill).fill(0), ...tail];
19168
+ }
19169
+ return head.length === 8 ? head : null;
19170
+ }
19171
+ function isPrivateIPv6(ip) {
19172
+ const groups = parseIPv6(ip);
19173
+ if (groups === null)
19174
+ return true;
19175
+ const topZero = (count) => groups.slice(0, count).every((group) => group === 0);
19176
+ if (topZero(7) && (groups[7] === 0 || groups[7] === 1))
19177
+ return true;
19178
+ if ((groups[0] & 65024) === 64512)
19179
+ return true;
19180
+ if ((groups[0] & 65472) === 65152)
19181
+ return true;
19182
+ if ((groups[0] & 65472) === 65216)
19183
+ return true;
19184
+ if ((groups[0] & 65280) === 65280)
19185
+ return true;
19186
+ const embedsIPv4 = topZero(6) || topZero(5) && groups[5] === 65535 || topZero(4) && groups[4] === 65535 && groups[5] === 0 || groups[0] === 100 && groups[1] === 65435 && groups[2] === 0 && groups[3] === 0 && groups[4] === 0 && groups[5] === 0 || groups[0] === 100 && groups[1] === 65435 && groups[2] === 1;
19187
+ if (embedsIPv4) {
19188
+ const a = groups[6] >> 8 & 255;
19189
+ const b = groups[6] & 255;
19190
+ const c = groups[7] >> 8 & 255;
19191
+ const d = groups[7] & 255;
19192
+ return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
19193
+ }
19194
+ return false;
19195
+ }
19196
+ async function fetchWithValidatedRedirects({
19197
+ url: url2,
19198
+ headers,
19199
+ abortSignal,
19200
+ maxRedirects = MAX_DOWNLOAD_REDIRECTS
19201
+ }) {
19202
+ const baseInit = { signal: abortSignal };
19203
+ if (headers !== undefined) {
19204
+ baseInit.headers = headers;
19205
+ }
19206
+ let currentUrl = url2;
19207
+ for (let redirectCount = 0;redirectCount <= maxRedirects; redirectCount++) {
19208
+ validateDownloadUrl(currentUrl);
19209
+ const response = await fetch(currentUrl, {
19210
+ ...baseInit,
19211
+ redirect: "manual"
19212
+ });
19213
+ if (response.type === "opaqueredirect") {
19214
+ if (!isBrowserRuntime()) {
19215
+ throw new DownloadError({
19216
+ url: url2,
19217
+ message: `Redirect from ${currentUrl} could not be validated and was blocked`
19218
+ });
19219
+ }
19220
+ return await fetch(currentUrl, { ...baseInit, redirect: "follow" });
19221
+ }
19222
+ const location = response.headers.get("location");
19223
+ if (response.status >= 300 && response.status < 400 && location) {
19224
+ await cancelResponseBody(response);
19225
+ currentUrl = new URL(location, currentUrl).toString();
19226
+ continue;
19227
+ }
19228
+ return response;
19229
+ }
19230
+ throw new DownloadError({
19231
+ url: url2,
19232
+ message: `Too many redirects (max ${maxRedirects})`
19233
+ });
19234
+ }
19235
+ async function readResponseWithSizeLimit({
19236
+ response,
19237
+ url: url2,
19238
+ maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE
19239
+ }) {
19240
+ const contentLength = response.headers.get("content-length");
19241
+ if (contentLength != null) {
19242
+ const length = parseInt(contentLength, 10);
19243
+ if (!isNaN(length) && length > maxBytes) {
19244
+ await cancelResponseBody(response);
19245
+ throw new DownloadError({
19246
+ url: url2,
19247
+ message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
19248
+ });
19249
+ }
19250
+ }
19251
+ const body = response.body;
19252
+ if (body == null) {
19253
+ return new Uint8Array(0);
19254
+ }
19255
+ const reader = body.getReader();
19256
+ const chunks = [];
19257
+ let totalBytes = 0;
19258
+ try {
19259
+ while (true) {
19260
+ const { done, value } = await reader.read();
19261
+ if (done) {
19262
+ break;
19263
+ }
19264
+ totalBytes += value.length;
19265
+ if (totalBytes > maxBytes) {
19266
+ throw new DownloadError({
19267
+ url: url2,
19268
+ message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes.`
19269
+ });
19270
+ }
19271
+ chunks.push(value);
19272
+ }
19273
+ } finally {
19274
+ try {
19275
+ await reader.cancel();
19276
+ } finally {
19277
+ reader.releaseLock();
19278
+ }
19279
+ }
19280
+ const result = new Uint8Array(totalBytes);
19281
+ let offset = 0;
19282
+ for (const chunk of chunks) {
19283
+ result.set(chunk, offset);
19284
+ offset += chunk.length;
19285
+ }
19286
+ return result;
19287
+ }
19288
+ async function downloadBlob(url2, options) {
19289
+ var _a22, _b22;
19290
+ try {
19291
+ const response = await fetchWithValidatedRedirects({
19292
+ url: url2,
19293
+ abortSignal: options == null ? undefined : options.abortSignal
19294
+ });
19295
+ if (!response.ok) {
19296
+ await cancelResponseBody(response);
19297
+ throw new DownloadError({
19298
+ url: url2,
19299
+ statusCode: response.status,
19300
+ statusText: response.statusText
19301
+ });
19302
+ }
19303
+ const data = await readResponseWithSizeLimit({
19304
+ response,
19305
+ url: url2,
19306
+ maxBytes: (_a22 = options == null ? undefined : options.maxBytes) != null ? _a22 : DEFAULT_MAX_DOWNLOAD_SIZE
19307
+ });
19308
+ const contentType = (_b22 = response.headers.get("content-type")) != null ? _b22 : undefined;
19309
+ return new Blob([data], contentType ? { type: contentType } : undefined);
19310
+ } catch (error51) {
19311
+ if (DownloadError.isInstance(error51)) {
19312
+ throw error51;
19313
+ }
19314
+ throw new DownloadError({ url: url2, cause: error51 });
19315
+ }
19316
+ }
19317
+ function getErrorMessage2(error51) {
19318
+ if (error51 == null) {
19319
+ return "unknown error";
19320
+ }
19321
+ if (typeof error51 === "string") {
19322
+ return error51;
19323
+ }
19324
+ if (error51 instanceof Error) {
19325
+ return error51.message;
19326
+ }
19327
+ return JSON.stringify(error51);
19328
+ }
18954
19329
  function isAbortError(error51) {
18955
19330
  return (error51 instanceof Error || error51 instanceof DOMException) && (error51.name === "AbortError" || error51.name === "ResponseAborted" || error51.name === "TimeoutError");
18956
19331
  }
@@ -19038,12 +19413,66 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
19038
19413
  normalizedHeaders.set("user-agent", [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" "));
19039
19414
  return Object.fromEntries(normalizedHeaders.entries());
19040
19415
  }
19041
- function loadOptionalSetting({
19042
- settingValue,
19043
- environmentVariableName
19044
- }) {
19045
- if (typeof settingValue === "string") {
19046
- return settingValue;
19416
+ function isNonNullable(value) {
19417
+ return value != null;
19418
+ }
19419
+ function isSameOrigin(url2, baseUrl) {
19420
+ try {
19421
+ return new URL(url2).origin === new URL(baseUrl).origin;
19422
+ } catch (e) {
19423
+ return false;
19424
+ }
19425
+ }
19426
+ function isUrlSupported({
19427
+ mediaType,
19428
+ url: url2,
19429
+ supportedUrls
19430
+ }) {
19431
+ url2 = url2.toLowerCase();
19432
+ mediaType = mediaType.toLowerCase();
19433
+ return Object.entries(supportedUrls).map(([key, value]) => {
19434
+ const mediaType2 = key.toLowerCase();
19435
+ return mediaType2 === "*" || mediaType2 === "*/*" ? { mediaTypePrefix: "", regexes: value } : { mediaTypePrefix: mediaType2.replace(/\*/, ""), regexes: value };
19436
+ }).filter(({ mediaTypePrefix }) => mediaType.startsWith(mediaTypePrefix)).flatMap(({ regexes }) => regexes).some((pattern) => pattern.test(url2));
19437
+ }
19438
+ function loadApiKey({
19439
+ apiKey,
19440
+ environmentVariableName,
19441
+ apiKeyParameterName = "apiKey",
19442
+ description
19443
+ }) {
19444
+ if (typeof apiKey === "string") {
19445
+ return apiKey;
19446
+ }
19447
+ if (apiKey != null) {
19448
+ throw new LoadAPIKeyError({
19449
+ message: `${description} API key must be a string.`
19450
+ });
19451
+ }
19452
+ if (typeof process === "undefined") {
19453
+ throw new LoadAPIKeyError({
19454
+ message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables are not supported in this environment.`
19455
+ });
19456
+ }
19457
+ apiKey = process.env[environmentVariableName];
19458
+ if (apiKey == null) {
19459
+ throw new LoadAPIKeyError({
19460
+ message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter or the ${environmentVariableName} environment variable.`
19461
+ });
19462
+ }
19463
+ if (typeof apiKey !== "string") {
19464
+ throw new LoadAPIKeyError({
19465
+ message: `${description} API key must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
19466
+ });
19467
+ }
19468
+ return apiKey;
19469
+ }
19470
+ function loadOptionalSetting({
19471
+ settingValue,
19472
+ environmentVariableName
19473
+ }) {
19474
+ if (typeof settingValue === "string") {
19475
+ return settingValue;
19047
19476
  }
19048
19477
  if (settingValue != null || typeof process === "undefined") {
19049
19478
  return;
@@ -19054,6 +19483,38 @@ function loadOptionalSetting({
19054
19483
  }
19055
19484
  return settingValue;
19056
19485
  }
19486
+ function loadSetting({
19487
+ settingValue,
19488
+ environmentVariableName,
19489
+ settingName,
19490
+ description
19491
+ }) {
19492
+ if (typeof settingValue === "string") {
19493
+ return settingValue;
19494
+ }
19495
+ if (settingValue != null) {
19496
+ throw new LoadSettingError({
19497
+ message: `${description} setting must be a string.`
19498
+ });
19499
+ }
19500
+ if (typeof process === "undefined") {
19501
+ throw new LoadSettingError({
19502
+ message: `${description} setting is missing. Pass it using the '${settingName}' parameter. Environment variables are not supported in this environment.`
19503
+ });
19504
+ }
19505
+ settingValue = process.env[environmentVariableName];
19506
+ if (settingValue == null) {
19507
+ throw new LoadSettingError({
19508
+ message: `${description} setting is missing. Pass it using the '${settingName}' parameter or the ${environmentVariableName} environment variable.`
19509
+ });
19510
+ }
19511
+ if (typeof settingValue !== "string") {
19512
+ throw new LoadSettingError({
19513
+ message: `${description} setting must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
19514
+ });
19515
+ }
19516
+ return settingValue;
19517
+ }
19057
19518
  function _parse2(text) {
19058
19519
  const obj = JSON.parse(text);
19059
19520
  if (obj === null || typeof obj !== "object") {
@@ -19997,6 +20458,14 @@ async function safeParseJSON({
19997
20458
  };
19998
20459
  }
19999
20460
  }
20461
+ function isParsableJson(input) {
20462
+ try {
20463
+ secureJsonParse(input);
20464
+ return true;
20465
+ } catch (e) {
20466
+ return false;
20467
+ }
20468
+ }
20000
20469
  function parseJsonEventStream({
20001
20470
  stream,
20002
20471
  schema
@@ -20010,9 +20479,60 @@ function parseJsonEventStream({
20010
20479
  }
20011
20480
  }));
20012
20481
  }
20482
+ async function parseProviderOptions({
20483
+ provider,
20484
+ providerOptions,
20485
+ schema
20486
+ }) {
20487
+ if ((providerOptions == null ? undefined : providerOptions[provider]) == null) {
20488
+ return;
20489
+ }
20490
+ const parsedProviderOptions = await safeValidateTypes({
20491
+ value: providerOptions[provider],
20492
+ schema
20493
+ });
20494
+ if (!parsedProviderOptions.success) {
20495
+ throw new InvalidArgumentError({
20496
+ argument: "providerOptions",
20497
+ message: `invalid ${provider} provider options`,
20498
+ cause: parsedProviderOptions.error
20499
+ });
20500
+ }
20501
+ return parsedProviderOptions.value;
20502
+ }
20013
20503
  function tool(tool2) {
20014
20504
  return tool2;
20015
20505
  }
20506
+ function dynamicTool(tool2) {
20507
+ return { ...tool2, type: "dynamic" };
20508
+ }
20509
+ function createProviderToolFactory({
20510
+ id,
20511
+ inputSchema
20512
+ }) {
20513
+ return ({
20514
+ execute,
20515
+ outputSchema,
20516
+ needsApproval,
20517
+ toModelOutput,
20518
+ onInputStart,
20519
+ onInputDelta,
20520
+ onInputAvailable,
20521
+ ...args
20522
+ }) => tool({
20523
+ type: "provider",
20524
+ id,
20525
+ args,
20526
+ inputSchema,
20527
+ outputSchema,
20528
+ execute,
20529
+ needsApproval,
20530
+ toModelOutput,
20531
+ onInputStart,
20532
+ onInputDelta,
20533
+ onInputAvailable
20534
+ });
20535
+ }
20016
20536
  function createProviderToolFactoryWithOutputSchema({
20017
20537
  id,
20018
20538
  inputSchema,
@@ -20048,10 +20568,78 @@ async function resolve(value) {
20048
20568
  }
20049
20569
  return Promise.resolve(value);
20050
20570
  }
20571
+ function stripFileExtension(filename) {
20572
+ const firstDotIndex = filename.indexOf(".");
20573
+ return firstDotIndex === -1 ? filename : filename.slice(0, firstDotIndex);
20574
+ }
20051
20575
  function withoutTrailingSlash(url2) {
20052
20576
  return url2 == null ? undefined : url2.replace(/\/$/, "");
20053
20577
  }
20054
- var btoa2, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a18, _b15, DownloadError, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
20578
+ function isAsyncIterable(obj) {
20579
+ return obj != null && typeof obj[Symbol.asyncIterator] === "function";
20580
+ }
20581
+ async function* executeTool({
20582
+ execute,
20583
+ input,
20584
+ options
20585
+ }) {
20586
+ const result = execute(input, options);
20587
+ if (isAsyncIterable(result)) {
20588
+ let lastOutput;
20589
+ for await (const output of result) {
20590
+ lastOutput = output;
20591
+ yield { type: "preliminary", output };
20592
+ }
20593
+ yield { type: "final", output: lastOutput };
20594
+ } else {
20595
+ yield { type: "final", output: await result };
20596
+ }
20597
+ }
20598
+ var DelayedPromise = class {
20599
+ constructor() {
20600
+ this.status = { type: "pending" };
20601
+ this._resolve = undefined;
20602
+ this._reject = undefined;
20603
+ }
20604
+ get promise() {
20605
+ if (this._promise) {
20606
+ return this._promise;
20607
+ }
20608
+ this._promise = new Promise((resolve2, reject) => {
20609
+ if (this.status.type === "resolved") {
20610
+ resolve2(this.status.value);
20611
+ } else if (this.status.type === "rejected") {
20612
+ reject(this.status.error);
20613
+ }
20614
+ this._resolve = resolve2;
20615
+ this._reject = reject;
20616
+ });
20617
+ return this._promise;
20618
+ }
20619
+ resolve(value) {
20620
+ var _a22;
20621
+ this.status = { type: "resolved", value };
20622
+ if (this._promise) {
20623
+ (_a22 = this._resolve) == null || _a22.call(this, value);
20624
+ }
20625
+ }
20626
+ reject(error51) {
20627
+ var _a22;
20628
+ this.status = { type: "rejected", error: error51 };
20629
+ if (this._promise) {
20630
+ (_a22 = this._reject) == null || _a22.call(this, error51);
20631
+ }
20632
+ }
20633
+ isResolved() {
20634
+ return this.status.type === "resolved";
20635
+ }
20636
+ isRejected() {
20637
+ return this.status.type === "rejected";
20638
+ }
20639
+ isPending() {
20640
+ return this.status.type === "pending";
20641
+ }
20642
+ }, btoa2, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a18, _b15, DownloadError, MAX_DOWNLOAD_REDIRECTS = 10, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
20055
20643
  prefix,
20056
20644
  size = 16,
20057
20645
  alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
@@ -20075,7 +20663,7 @@ var btoa2, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a18, _b15, D
20075
20663
  });
20076
20664
  }
20077
20665
  return () => `${prefix}${separator}${generator()}`;
20078
- }, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.26", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
20666
+ }, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.30", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
20079
20667
  url: url2,
20080
20668
  headers = {},
20081
20669
  successfulResponseHandler,
@@ -20378,6 +20966,25 @@ var btoa2, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a18, _b15, D
20378
20966
  successfulResponseHandler,
20379
20967
  abortSignal,
20380
20968
  fetch: fetch2
20969
+ }), postFormDataToApi = async ({
20970
+ url: url2,
20971
+ headers,
20972
+ formData,
20973
+ failedResponseHandler,
20974
+ successfulResponseHandler,
20975
+ abortSignal,
20976
+ fetch: fetch2
20977
+ }) => postToApi({
20978
+ url: url2,
20979
+ headers,
20980
+ body: {
20981
+ content: formData,
20982
+ values: Object.fromEntries(formData.entries())
20983
+ },
20984
+ failedResponseHandler,
20985
+ successfulResponseHandler,
20986
+ abortSignal,
20987
+ fetch: fetch2
20381
20988
  }), postToApi = async ({
20382
20989
  url: url2,
20383
20990
  headers = {},
@@ -20539,6 +21146,8 @@ var init_dist3 = __esm(() => {
20539
21146
  init_dist();
20540
21147
  init_dist();
20541
21148
  init_dist();
21149
+ init_dist();
21150
+ init_dist();
20542
21151
  init_v4();
20543
21152
  init_v3();
20544
21153
  init_v3();
@@ -20546,6 +21155,7 @@ var init_dist3 = __esm(() => {
20546
21155
  init_stream();
20547
21156
  init_dist();
20548
21157
  init_dist();
21158
+ init_dist();
20549
21159
  ({ btoa: btoa2, atob: atob2 } = globalThis);
20550
21160
  marker15 = `vercel.ai.error.${name14}`;
20551
21161
  symbol17 = Symbol.for(marker15);
@@ -20635,6 +21245,14 @@ var init_dist3 = __esm(() => {
20635
21245
  schemaSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
20636
21246
  });
20637
21247
 
21248
+ // node_modules/zod/index.js
21249
+ var zod_default;
21250
+ var init_zod = __esm(() => {
21251
+ init_external();
21252
+ init_external();
21253
+ zod_default = exports_external;
21254
+ });
21255
+
20638
21256
  // node_modules/@vercel/oidc/dist/get-context.js
20639
21257
  var require_get_context = __commonJS((exports, module) => {
20640
21258
  var __defProp = Object.defineProperty;
@@ -20776,7 +21394,7 @@ async function createGatewayErrorFromResponse({
20776
21394
  cause,
20777
21395
  authMethod
20778
21396
  }) {
20779
- var _a92;
21397
+ var _a112;
20780
21398
  const parseResult = await safeValidateTypes({
20781
21399
  value: response,
20782
21400
  schema: gatewayErrorResponseSchema
@@ -20795,7 +21413,7 @@ async function createGatewayErrorFromResponse({
20795
21413
  const validatedResponse = parseResult.value;
20796
21414
  const errorType = validatedResponse.error.type;
20797
21415
  const message = validatedResponse.error.message;
20798
- const generationId = (_a92 = validatedResponse.generationId) != null ? _a92 : undefined;
21416
+ const generationId = (_a112 = validatedResponse.generationId) != null ? _a112 : undefined;
20799
21417
  switch (errorType) {
20800
21418
  case "authentication_error":
20801
21419
  return GatewayAuthenticationError.createContextualError({
@@ -20839,6 +21457,20 @@ async function createGatewayErrorFromResponse({
20839
21457
  cause,
20840
21458
  generationId
20841
21459
  });
21460
+ case "failed_dependency":
21461
+ return new GatewayFailedDependencyError({
21462
+ message,
21463
+ statusCode,
21464
+ cause,
21465
+ generationId
21466
+ });
21467
+ case "forbidden":
21468
+ return new GatewayForbiddenError({
21469
+ message,
21470
+ statusCode,
21471
+ cause,
21472
+ generationId
21473
+ });
20842
21474
  default:
20843
21475
  return new GatewayInternalServerError({
20844
21476
  message,
@@ -20877,7 +21509,7 @@ function isTimeoutError(error51) {
20877
21509
  return false;
20878
21510
  }
20879
21511
  async function asGatewayError(error51, authMethod) {
20880
- var _a92;
21512
+ var _a112;
20881
21513
  if (GatewayError.isInstance(error51)) {
20882
21514
  return error51;
20883
21515
  }
@@ -20896,7 +21528,7 @@ async function asGatewayError(error51, authMethod) {
20896
21528
  }
20897
21529
  return await createGatewayErrorFromResponse({
20898
21530
  response: extractApiCallResponse(error51),
20899
- statusCode: (_a92 = error51.statusCode) != null ? _a92 : 500,
21531
+ statusCode: (_a112 = error51.statusCode) != null ? _a112 : 500,
20900
21532
  defaultMessage: "Gateway request failed",
20901
21533
  cause: error51,
20902
21534
  authMethod
@@ -20936,16 +21568,16 @@ function maybeEncodeVideoFile(file2) {
20936
21568
  return file2;
20937
21569
  }
20938
21570
  async function getVercelRequestId() {
20939
- var _a92;
20940
- return (_a92 = import_oidc.getContext().headers) == null ? undefined : _a92["x-vercel-id"];
21571
+ var _a112;
21572
+ return (_a112 = import_oidc.getContext().headers) == null ? undefined : _a112["x-vercel-id"];
20941
21573
  }
20942
21574
  function createGatewayProvider(options = {}) {
20943
- var _a92, _b92;
21575
+ var _a112, _b112;
20944
21576
  let pendingMetadata = null;
20945
21577
  let metadataCache = null;
20946
- const cacheRefreshMillis = (_a92 = options.metadataCacheRefreshMillis) != null ? _a92 : 1000 * 60 * 5;
21578
+ const cacheRefreshMillis = (_a112 = options.metadataCacheRefreshMillis) != null ? _a112 : 1000 * 60 * 5;
20947
21579
  let lastFetchTime = 0;
20948
- const baseURL = (_b92 = withoutTrailingSlash(options.baseURL)) != null ? _b92 : "https://ai-gateway.vercel.sh/v3/ai";
21580
+ const baseURL = (_b112 = withoutTrailingSlash(options.baseURL)) != null ? _b112 : "https://ai-gateway.vercel.sh/v3/ai";
20949
21581
  const getHeaders = async () => {
20950
21582
  try {
20951
21583
  const auth = await getGatewayAuthToken(options);
@@ -21002,8 +21634,8 @@ function createGatewayProvider(options = {}) {
21002
21634
  });
21003
21635
  };
21004
21636
  const getAvailableModels = async () => {
21005
- var _a102, _b102, _c;
21006
- const now = (_c = (_b102 = (_a102 = options._internal) == null ? undefined : _a102.currentDate) == null ? undefined : _b102.call(_a102).getTime()) != null ? _c : Date.now();
21637
+ var _a122, _b122, _c;
21638
+ const now = (_c = (_b122 = (_a122 = options._internal) == null ? undefined : _a122.currentDate) == null ? undefined : _b122.call(_a122).getTime()) != null ? _c : Date.now();
21007
21639
  if (!pendingMetadata || now - lastFetchTime > cacheRefreshMillis) {
21008
21640
  lastFetchTime = now;
21009
21641
  pendingMetadata = new GatewayFetchMetadata({
@@ -21122,7 +21754,7 @@ async function getGatewayAuthToken(options) {
21122
21754
  authMethod: "oidc"
21123
21755
  };
21124
21756
  }
21125
- var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _a19, _b17, GatewayError, name16 = "GatewayAuthenticationError", marker22, symbol22, _a22, _b22, GatewayAuthenticationError, name22 = "GatewayInvalidRequestError", marker32, symbol32, _a32, _b32, GatewayInvalidRequestError, name32 = "GatewayRateLimitError", marker42, symbol42, _a42, _b42, GatewayRateLimitError, name42 = "GatewayModelNotFoundError", marker52, symbol52, modelNotFoundParamSchema, _a52, _b52, GatewayModelNotFoundError, name52 = "GatewayInternalServerError", marker62, symbol62, _a62, _b62, GatewayInternalServerError, name62 = "GatewayResponseError", marker72, symbol72, _a72, _b72, GatewayResponseError, gatewayErrorResponseSchema, name72 = "GatewayTimeoutError", marker82, symbol82, _a82, _b82, GatewayTimeoutError, GATEWAY_AUTH_METHOD_HEADER = "ai-gateway-auth-method", gatewayAuthMethodSchema, KNOWN_MODEL_TYPES, GatewayFetchMetadata = class {
21757
+ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _a19, _b17, GatewayError, name16 = "GatewayAuthenticationError", marker22, symbol22, _a22, _b22, GatewayAuthenticationError, name22 = "GatewayInvalidRequestError", marker32, symbol32, _a32, _b32, GatewayInvalidRequestError, name32 = "GatewayRateLimitError", marker42, symbol42, _a42, _b42, GatewayRateLimitError, name42 = "GatewayModelNotFoundError", marker52, symbol52, modelNotFoundParamSchema, _a52, _b52, GatewayModelNotFoundError, name52 = "GatewayInternalServerError", marker62, symbol62, _a62, _b62, GatewayInternalServerError, name62 = "GatewayFailedDependencyError", marker72, symbol72, _a72, _b72, GatewayFailedDependencyError, name72 = "GatewayForbiddenError", marker82, symbol82, _a82, _b82, GatewayForbiddenError, name82 = "GatewayResponseError", marker92, symbol92, _a92, _b92, GatewayResponseError, gatewayErrorResponseSchema, name92 = "GatewayTimeoutError", marker102, symbol102, _a102, _b102, GatewayTimeoutError, GATEWAY_AUTH_METHOD_HEADER = "ai-gateway-auth-method", gatewayAuthMethodSchema, KNOWN_MODEL_TYPES, GatewayFetchMetadata = class {
21126
21758
  constructor(config2) {
21127
21759
  this.config = config2;
21128
21760
  }
@@ -21368,7 +22000,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
21368
22000
  abortSignal,
21369
22001
  providerOptions
21370
22002
  }) {
21371
- var _a92;
22003
+ var _a112, _b112;
21372
22004
  const resolvedHeaders = await resolve(this.config.headers());
21373
22005
  try {
21374
22006
  const {
@@ -21392,10 +22024,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
21392
22024
  });
21393
22025
  return {
21394
22026
  embeddings: responseBody.embeddings,
21395
- usage: (_a92 = responseBody.usage) != null ? _a92 : undefined,
22027
+ usage: (_a112 = responseBody.usage) != null ? _a112 : undefined,
21396
22028
  providerMetadata: responseBody.providerMetadata,
21397
22029
  response: { headers: responseHeaders, body: rawValue },
21398
- warnings: []
22030
+ warnings: (_b112 = responseBody.warnings) != null ? _b112 : []
21399
22031
  };
21400
22032
  } catch (error51) {
21401
22033
  throw await asGatewayError(error51, await parseAuthMethod(resolvedHeaders));
@@ -21410,7 +22042,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
21410
22042
  "ai-model-id": this.modelId
21411
22043
  };
21412
22044
  }
21413
- }, gatewayEmbeddingResponseSchema, GatewayImageModel = class {
22045
+ }, gatewayEmbeddingWarningSchema, gatewayEmbeddingResponseSchema, GatewayImageModel = class {
21414
22046
  constructor(modelId, config2) {
21415
22047
  this.modelId = modelId;
21416
22048
  this.config = config2;
@@ -21432,7 +22064,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
21432
22064
  headers,
21433
22065
  abortSignal
21434
22066
  }) {
21435
- var _a92, _b92, _c, _d;
22067
+ var _a112, _b112, _c, _d;
21436
22068
  const resolvedHeaders = await resolve(this.config.headers());
21437
22069
  try {
21438
22070
  const {
@@ -21464,7 +22096,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
21464
22096
  });
21465
22097
  return {
21466
22098
  images: responseBody.images,
21467
- warnings: (_a92 = responseBody.warnings) != null ? _a92 : [],
22099
+ warnings: (_a112 = responseBody.warnings) != null ? _a112 : [],
21468
22100
  providerMetadata: responseBody.providerMetadata,
21469
22101
  response: {
21470
22102
  timestamp: /* @__PURE__ */ new Date,
@@ -21473,7 +22105,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
21473
22105
  },
21474
22106
  ...responseBody.usage != null && {
21475
22107
  usage: {
21476
- inputTokens: (_b92 = responseBody.usage.inputTokens) != null ? _b92 : undefined,
22108
+ inputTokens: (_b112 = responseBody.usage.inputTokens) != null ? _b112 : undefined,
21477
22109
  outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : undefined,
21478
22110
  totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : undefined
21479
22111
  }
@@ -21515,7 +22147,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
21515
22147
  headers,
21516
22148
  abortSignal
21517
22149
  }) {
21518
- var _a92;
22150
+ var _a112;
21519
22151
  const resolvedHeaders = await resolve(this.config.headers());
21520
22152
  try {
21521
22153
  const { responseHeaders, value: responseBody } = await postJsonToApi({
@@ -21605,7 +22237,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
21605
22237
  });
21606
22238
  return {
21607
22239
  videos: responseBody.videos,
21608
- warnings: (_a92 = responseBody.warnings) != null ? _a92 : [],
22240
+ warnings: (_a112 = responseBody.warnings) != null ? _a112 : [],
21609
22241
  providerMetadata: responseBody.providerMetadata,
21610
22242
  response: {
21611
22243
  timestamp: /* @__PURE__ */ new Date,
@@ -21643,6 +22275,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
21643
22275
  abortSignal,
21644
22276
  providerOptions
21645
22277
  }) {
22278
+ var _a112;
21646
22279
  const resolvedHeaders = await resolve(this.config.headers());
21647
22280
  try {
21648
22281
  const {
@@ -21670,7 +22303,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
21670
22303
  ranking: responseBody.ranking,
21671
22304
  providerMetadata: responseBody.providerMetadata,
21672
22305
  response: { headers: responseHeaders, body: rawValue },
21673
- warnings: []
22306
+ warnings: (_a112 = responseBody.warnings) != null ? _a112 : []
21674
22307
  };
21675
22308
  } catch (error51) {
21676
22309
  throw await asGatewayError(error51, await parseAuthMethod(resolvedHeaders));
@@ -21685,7 +22318,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
21685
22318
  "ai-model-id": this.modelId
21686
22319
  };
21687
22320
  }
21688
- }, gatewayRerankingResponseSchema, parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION2 = "3.0.110", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
22321
+ }, gatewayRerankingWarningSchema, gatewayRerankingResponseSchema, parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION2 = "3.0.133", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
21689
22322
  var init_dist4 = __esm(() => {
21690
22323
  init_dist3();
21691
22324
  init_dist();
@@ -21724,13 +22357,15 @@ var init_dist4 = __esm(() => {
21724
22357
  message,
21725
22358
  statusCode = 500,
21726
22359
  cause,
21727
- generationId
22360
+ generationId,
22361
+ isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500)
21728
22362
  }) {
21729
22363
  super(generationId ? `${message} [${generationId}]` : message);
21730
22364
  this[_a19] = true;
21731
22365
  this.statusCode = statusCode;
21732
22366
  this.cause = cause;
21733
22367
  this.generationId = generationId;
22368
+ this.isRetryable = isRetryable;
21734
22369
  }
21735
22370
  static isInstance(error51) {
21736
22371
  return _GatewayError.hasMarker(error51);
@@ -21874,7 +22509,43 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
21874
22509
  };
21875
22510
  marker72 = `vercel.ai.gateway.error.${name62}`;
21876
22511
  symbol72 = Symbol.for(marker72);
21877
- GatewayResponseError = class extends (_b72 = GatewayError, _a72 = symbol72, _b72) {
22512
+ GatewayFailedDependencyError = class extends (_b72 = GatewayError, _a72 = symbol72, _b72) {
22513
+ constructor({
22514
+ message = "Failed dependency",
22515
+ statusCode = 424,
22516
+ cause,
22517
+ generationId
22518
+ } = {}) {
22519
+ super({ message, statusCode, cause, generationId });
22520
+ this[_a72] = true;
22521
+ this.name = name62;
22522
+ this.type = "failed_dependency";
22523
+ }
22524
+ static isInstance(error51) {
22525
+ return GatewayError.hasMarker(error51) && symbol72 in error51;
22526
+ }
22527
+ };
22528
+ marker82 = `vercel.ai.gateway.error.${name72}`;
22529
+ symbol82 = Symbol.for(marker82);
22530
+ GatewayForbiddenError = class extends (_b82 = GatewayError, _a82 = symbol82, _b82) {
22531
+ constructor({
22532
+ message = "Forbidden",
22533
+ statusCode = 403,
22534
+ cause,
22535
+ generationId
22536
+ } = {}) {
22537
+ super({ message, statusCode, cause, generationId });
22538
+ this[_a82] = true;
22539
+ this.name = name72;
22540
+ this.type = "forbidden";
22541
+ }
22542
+ static isInstance(error51) {
22543
+ return GatewayError.hasMarker(error51) && symbol82 in error51;
22544
+ }
22545
+ };
22546
+ marker92 = `vercel.ai.gateway.error.${name82}`;
22547
+ symbol92 = Symbol.for(marker92);
22548
+ GatewayResponseError = class extends (_b92 = GatewayError, _a92 = symbol92, _b92) {
21878
22549
  constructor({
21879
22550
  message = "Invalid response from Gateway",
21880
22551
  statusCode = 502,
@@ -21884,14 +22555,14 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
21884
22555
  generationId
21885
22556
  } = {}) {
21886
22557
  super({ message, statusCode, cause, generationId });
21887
- this[_a72] = true;
21888
- this.name = name62;
22558
+ this[_a92] = true;
22559
+ this.name = name82;
21889
22560
  this.type = "response_error";
21890
22561
  this.response = response;
21891
22562
  this.validationError = validationError;
21892
22563
  }
21893
22564
  static isInstance(error51) {
21894
- return GatewayError.hasMarker(error51) && symbol72 in error51;
22565
+ return GatewayError.hasMarker(error51) && symbol92 in error51;
21895
22566
  }
21896
22567
  };
21897
22568
  gatewayErrorResponseSchema = lazySchema(() => zodSchema(exports_external.object({
@@ -21903,9 +22574,9 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
21903
22574
  }),
21904
22575
  generationId: exports_external.string().nullish()
21905
22576
  })));
21906
- marker82 = `vercel.ai.gateway.error.${name72}`;
21907
- symbol82 = Symbol.for(marker82);
21908
- GatewayTimeoutError = class _GatewayTimeoutError extends (_b82 = GatewayError, _a82 = symbol82, _b82) {
22577
+ marker102 = `vercel.ai.gateway.error.${name92}`;
22578
+ symbol102 = Symbol.for(marker102);
22579
+ GatewayTimeoutError = class _GatewayTimeoutError extends (_b102 = GatewayError, _a102 = symbol102, _b102) {
21909
22580
  constructor({
21910
22581
  message = "Request timed out",
21911
22582
  statusCode = 408,
@@ -21913,12 +22584,12 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
21913
22584
  generationId
21914
22585
  } = {}) {
21915
22586
  super({ message, statusCode, cause, generationId });
21916
- this[_a82] = true;
21917
- this.name = name72;
22587
+ this[_a102] = true;
22588
+ this.name = name92;
21918
22589
  this.type = "timeout_error";
21919
22590
  }
21920
22591
  static isInstance(error51) {
21921
- return GatewayError.hasMarker(error51) && symbol82 in error51;
22592
+ return GatewayError.hasMarker(error51) && symbol102 in error51;
21922
22593
  }
21923
22594
  static createTimeoutError({
21924
22595
  originalMessage,
@@ -22069,9 +22740,26 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
22069
22740
  billableWebSearchCalls: billable_web_search_calls
22070
22741
  }))
22071
22742
  }).transform(({ data }) => data)));
22743
+ gatewayEmbeddingWarningSchema = exports_external.discriminatedUnion("type", [
22744
+ exports_external.object({
22745
+ type: exports_external.literal("unsupported"),
22746
+ feature: exports_external.string(),
22747
+ details: exports_external.string().optional()
22748
+ }),
22749
+ exports_external.object({
22750
+ type: exports_external.literal("compatibility"),
22751
+ feature: exports_external.string(),
22752
+ details: exports_external.string().optional()
22753
+ }),
22754
+ exports_external.object({
22755
+ type: exports_external.literal("other"),
22756
+ message: exports_external.string()
22757
+ })
22758
+ ]);
22072
22759
  gatewayEmbeddingResponseSchema = lazySchema(() => zodSchema(exports_external.object({
22073
22760
  embeddings: exports_external.array(exports_external.array(exports_external.number())),
22074
22761
  usage: exports_external.object({ tokens: exports_external.number() }).nullish(),
22762
+ warnings: exports_external.array(gatewayEmbeddingWarningSchema).optional(),
22075
22763
  providerMetadata: exports_external.record(exports_external.string(), exports_external.record(exports_external.string(), exports_external.unknown())).optional()
22076
22764
  })));
22077
22765
  providerMetadataEntrySchema = exports_external.object({
@@ -22150,11 +22838,28 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
22150
22838
  param: exports_external.unknown().nullable()
22151
22839
  })
22152
22840
  ]);
22841
+ gatewayRerankingWarningSchema = exports_external.discriminatedUnion("type", [
22842
+ exports_external.object({
22843
+ type: exports_external.literal("unsupported"),
22844
+ feature: exports_external.string(),
22845
+ details: exports_external.string().optional()
22846
+ }),
22847
+ exports_external.object({
22848
+ type: exports_external.literal("compatibility"),
22849
+ feature: exports_external.string(),
22850
+ details: exports_external.string().optional()
22851
+ }),
22852
+ exports_external.object({
22853
+ type: exports_external.literal("other"),
22854
+ message: exports_external.string()
22855
+ })
22856
+ ]);
22153
22857
  gatewayRerankingResponseSchema = lazySchema(() => zodSchema(exports_external.object({
22154
22858
  ranking: exports_external.array(exports_external.object({
22155
22859
  index: exports_external.number(),
22156
22860
  relevanceScore: exports_external.number()
22157
22861
  })),
22862
+ warnings: exports_external.array(gatewayRerankingWarningSchema).optional(),
22158
22863
  providerMetadata: exports_external.record(exports_external.string(), exports_external.record(exports_external.string(), exports_external.unknown())).optional()
22159
22864
  })));
22160
22865
  parallelSearchInputSchema = lazySchema(() => zodSchema(exports_external.object({
@@ -22253,1685 +22958,11 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
22253
22958
  gateway = createGatewayProvider();
22254
22959
  });
22255
22960
 
22256
- // node_modules/ai/node_modules/@ai-sdk/provider-utils/dist/index.mjs
22257
- async function delay(delayInMs, options) {
22258
- if (delayInMs == null) {
22259
- return Promise.resolve();
22260
- }
22261
- const signal = options == null ? undefined : options.abortSignal;
22262
- return new Promise((resolve2, reject) => {
22263
- if (signal == null ? undefined : signal.aborted) {
22264
- reject(createAbortError());
22265
- return;
22266
- }
22267
- const timeoutId = setTimeout(() => {
22268
- cleanup();
22269
- resolve2();
22270
- }, delayInMs);
22271
- const cleanup = () => {
22272
- clearTimeout(timeoutId);
22273
- signal == null || signal.removeEventListener("abort", onAbort);
22274
- };
22275
- const onAbort = () => {
22276
- cleanup();
22277
- reject(createAbortError());
22278
- };
22279
- signal == null || signal.addEventListener("abort", onAbort);
22280
- });
22281
- }
22282
- function createAbortError() {
22283
- return new DOMException("Delay was aborted", "AbortError");
22284
- }
22285
- function convertBase64ToUint8Array(base64String) {
22286
- const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
22287
- const latin1string = atob3(base64Url);
22288
- return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
22289
- }
22290
- function convertUint8ArrayToBase642(array2) {
22291
- let latin1string = "";
22292
- for (let i = 0;i < array2.length; i++) {
22293
- latin1string += String.fromCodePoint(array2[i]);
22294
- }
22295
- return btoa3(latin1string);
22296
- }
22297
- async function readResponseWithSizeLimit({
22298
- response,
22299
- url: url2,
22300
- maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE2
22301
- }) {
22302
- const contentLength = response.headers.get("content-length");
22303
- if (contentLength != null) {
22304
- const length = parseInt(contentLength, 10);
22305
- if (!isNaN(length) && length > maxBytes) {
22306
- throw new DownloadError2({
22307
- url: url2,
22308
- message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
22309
- });
22310
- }
22311
- }
22312
- const body = response.body;
22313
- if (body == null) {
22314
- return new Uint8Array(0);
22315
- }
22316
- const reader = body.getReader();
22317
- const chunks = [];
22318
- let totalBytes = 0;
22319
- try {
22320
- while (true) {
22321
- const { done, value } = await reader.read();
22322
- if (done) {
22323
- break;
22324
- }
22325
- totalBytes += value.length;
22326
- if (totalBytes > maxBytes) {
22327
- throw new DownloadError2({
22328
- url: url2,
22329
- message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes.`
22330
- });
22331
- }
22332
- chunks.push(value);
22333
- }
22334
- } finally {
22335
- try {
22336
- await reader.cancel();
22337
- } finally {
22338
- reader.releaseLock();
22339
- }
22340
- }
22341
- const result = new Uint8Array(totalBytes);
22342
- let offset = 0;
22343
- for (const chunk of chunks) {
22344
- result.set(chunk, offset);
22345
- offset += chunk.length;
22346
- }
22347
- return result;
22348
- }
22349
- function validateDownloadUrl(url2) {
22350
- let parsed;
22351
- try {
22352
- parsed = new URL(url2);
22353
- } catch (e) {
22354
- throw new DownloadError2({
22355
- url: url2,
22356
- message: `Invalid URL: ${url2}`
22357
- });
22358
- }
22359
- if (parsed.protocol === "data:") {
22360
- return;
22361
- }
22362
- if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
22363
- throw new DownloadError2({
22364
- url: url2,
22365
- message: `URL scheme must be http, https, or data, got ${parsed.protocol}`
22366
- });
22367
- }
22368
- const hostname3 = parsed.hostname;
22369
- if (!hostname3) {
22370
- throw new DownloadError2({
22371
- url: url2,
22372
- message: `URL must have a hostname`
22373
- });
22374
- }
22375
- if (hostname3 === "localhost" || hostname3.endsWith(".local") || hostname3.endsWith(".localhost")) {
22376
- throw new DownloadError2({
22377
- url: url2,
22378
- message: `URL with hostname ${hostname3} is not allowed`
22379
- });
22380
- }
22381
- if (hostname3.startsWith("[") && hostname3.endsWith("]")) {
22382
- const ipv63 = hostname3.slice(1, -1);
22383
- if (isPrivateIPv6(ipv63)) {
22384
- throw new DownloadError2({
22385
- url: url2,
22386
- message: `URL with IPv6 address ${hostname3} is not allowed`
22387
- });
22388
- }
22389
- return;
22390
- }
22391
- if (isIPv4(hostname3)) {
22392
- if (isPrivateIPv4(hostname3)) {
22393
- throw new DownloadError2({
22394
- url: url2,
22395
- message: `URL with IP address ${hostname3} is not allowed`
22396
- });
22397
- }
22398
- return;
22399
- }
22400
- }
22401
- function isIPv4(hostname3) {
22402
- const parts = hostname3.split(".");
22403
- if (parts.length !== 4)
22404
- return false;
22405
- return parts.every((part) => {
22406
- const num = Number(part);
22407
- return Number.isInteger(num) && num >= 0 && num <= 255 && String(num) === part;
22408
- });
22409
- }
22410
- function isPrivateIPv4(ip) {
22411
- const parts = ip.split(".").map(Number);
22412
- const [a, b] = parts;
22413
- if (a === 0)
22414
- return true;
22415
- if (a === 10)
22416
- return true;
22417
- if (a === 127)
22418
- return true;
22419
- if (a === 169 && b === 254)
22420
- return true;
22421
- if (a === 172 && b >= 16 && b <= 31)
22422
- return true;
22423
- if (a === 192 && b === 168)
22424
- return true;
22425
- return false;
22426
- }
22427
- function isPrivateIPv6(ip) {
22428
- const normalized = ip.toLowerCase();
22429
- if (normalized === "::1")
22430
- return true;
22431
- if (normalized === "::")
22432
- return true;
22433
- if (normalized.startsWith("::ffff:")) {
22434
- const mappedPart = normalized.slice(7);
22435
- if (isIPv4(mappedPart)) {
22436
- return isPrivateIPv4(mappedPart);
22437
- }
22438
- const hexParts = mappedPart.split(":");
22439
- if (hexParts.length === 2) {
22440
- const high = parseInt(hexParts[0], 16);
22441
- const low = parseInt(hexParts[1], 16);
22442
- if (!isNaN(high) && !isNaN(low)) {
22443
- const a = high >> 8 & 255;
22444
- const b = high & 255;
22445
- const c = low >> 8 & 255;
22446
- const d = low & 255;
22447
- return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
22448
- }
22449
- }
22450
- }
22451
- if (normalized.startsWith("fc") || normalized.startsWith("fd"))
22452
- return true;
22453
- if (normalized.startsWith("fe80"))
22454
- return true;
22455
- return false;
22456
- }
22457
- function getErrorMessage2(error51) {
22458
- if (error51 == null) {
22459
- return "unknown error";
22460
- }
22461
- if (typeof error51 === "string") {
22462
- return error51;
22463
- }
22464
- if (error51 instanceof Error) {
22465
- return error51.message;
22466
- }
22467
- return JSON.stringify(error51);
22468
- }
22469
- function isAbortError2(error51) {
22470
- return (error51 instanceof Error || error51 instanceof DOMException) && (error51.name === "AbortError" || error51.name === "ResponseAborted" || error51.name === "TimeoutError");
22471
- }
22472
- function getRuntimeEnvironmentUserAgent2(globalThisAny = globalThis) {
22473
- var _a23, _b23, _c;
22474
- if (globalThisAny.window) {
22475
- return `runtime/browser`;
22476
- }
22477
- if ((_a23 = globalThisAny.navigator) == null ? undefined : _a23.userAgent) {
22478
- return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
22479
- }
22480
- if ((_c = (_b23 = globalThisAny.process) == null ? undefined : _b23.versions) == null ? undefined : _c.node) {
22481
- return `runtime/node.js/${globalThisAny.process.version.substring(0)}`;
22482
- }
22483
- if (globalThisAny.EdgeRuntime) {
22484
- return `runtime/vercel-edge`;
22485
- }
22486
- return "runtime/unknown";
22487
- }
22488
- function normalizeHeaders2(headers) {
22489
- if (headers == null) {
22490
- return {};
22491
- }
22492
- const normalized = {};
22493
- if (headers instanceof Headers) {
22494
- headers.forEach((value, key) => {
22495
- normalized[key.toLowerCase()] = value;
22496
- });
22497
- } else {
22498
- if (!Array.isArray(headers)) {
22499
- headers = Object.entries(headers);
22500
- }
22501
- for (const [key, value] of headers) {
22502
- if (value != null) {
22503
- normalized[key.toLowerCase()] = value;
22504
- }
22505
- }
22506
- }
22507
- return normalized;
22508
- }
22509
- function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
22510
- const normalizedHeaders = new Headers(normalizeHeaders2(headers));
22511
- const currentUserAgentHeader = normalizedHeaders.get("user-agent") || "";
22512
- normalizedHeaders.set("user-agent", [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" "));
22513
- return Object.fromEntries(normalizedHeaders.entries());
22514
- }
22515
- function isNonNullable(value) {
22516
- return value != null;
22517
- }
22518
- function isUrlSupported({
22519
- mediaType,
22520
- url: url2,
22521
- supportedUrls
22522
- }) {
22523
- url2 = url2.toLowerCase();
22524
- mediaType = mediaType.toLowerCase();
22525
- return Object.entries(supportedUrls).map(([key, value]) => {
22526
- const mediaType2 = key.toLowerCase();
22527
- return mediaType2 === "*" || mediaType2 === "*/*" ? { mediaTypePrefix: "", regexes: value } : { mediaTypePrefix: mediaType2.replace(/\*/, ""), regexes: value };
22528
- }).filter(({ mediaTypePrefix }) => mediaType.startsWith(mediaTypePrefix)).flatMap(({ regexes }) => regexes).some((pattern) => pattern.test(url2));
22529
- }
22530
- function _parse3(text) {
22531
- const obj = JSON.parse(text);
22532
- if (obj === null || typeof obj !== "object") {
22533
- return obj;
22534
- }
22535
- if (suspectProtoRx2.test(text) === false && suspectConstructorRx2.test(text) === false) {
22536
- return obj;
22537
- }
22538
- return filter2(obj);
22539
- }
22540
- function filter2(obj) {
22541
- let next = [obj];
22542
- while (next.length) {
22543
- const nodes = next;
22544
- next = [];
22545
- for (const node of nodes) {
22546
- if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
22547
- throw new SyntaxError("Object contains forbidden prototype property");
22548
- }
22549
- if (Object.prototype.hasOwnProperty.call(node, "constructor") && node.constructor !== null && typeof node.constructor === "object" && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
22550
- throw new SyntaxError("Object contains forbidden prototype property");
22551
- }
22552
- for (const key in node) {
22553
- const value = node[key];
22554
- if (value && typeof value === "object") {
22555
- next.push(value);
22556
- }
22557
- }
22558
- }
22559
- }
22560
- return obj;
22561
- }
22562
- function secureJsonParse2(text) {
22563
- const { stackTraceLimit } = Error;
22564
- try {
22565
- Error.stackTraceLimit = 0;
22566
- } catch (e) {
22567
- return _parse3(text);
22568
- }
22569
- try {
22570
- return _parse3(text);
22571
- } finally {
22572
- Error.stackTraceLimit = stackTraceLimit;
22573
- }
22574
- }
22575
- function addAdditionalPropertiesToJsonSchema2(jsonSchema2) {
22576
- if (jsonSchema2.type === "object" || Array.isArray(jsonSchema2.type) && jsonSchema2.type.includes("object")) {
22577
- jsonSchema2.additionalProperties = false;
22578
- const { properties } = jsonSchema2;
22579
- if (properties != null) {
22580
- for (const key of Object.keys(properties)) {
22581
- properties[key] = visit2(properties[key]);
22582
- }
22583
- }
22584
- }
22585
- if (jsonSchema2.items != null) {
22586
- jsonSchema2.items = Array.isArray(jsonSchema2.items) ? jsonSchema2.items.map(visit2) : visit2(jsonSchema2.items);
22587
- }
22588
- if (jsonSchema2.anyOf != null) {
22589
- jsonSchema2.anyOf = jsonSchema2.anyOf.map(visit2);
22590
- }
22591
- if (jsonSchema2.allOf != null) {
22592
- jsonSchema2.allOf = jsonSchema2.allOf.map(visit2);
22593
- }
22594
- if (jsonSchema2.oneOf != null) {
22595
- jsonSchema2.oneOf = jsonSchema2.oneOf.map(visit2);
22596
- }
22597
- const { definitions } = jsonSchema2;
22598
- if (definitions != null) {
22599
- for (const key of Object.keys(definitions)) {
22600
- definitions[key] = visit2(definitions[key]);
22601
- }
22602
- }
22603
- return jsonSchema2;
22604
- }
22605
- function visit2(def) {
22606
- if (typeof def === "boolean")
22607
- return def;
22608
- return addAdditionalPropertiesToJsonSchema2(def);
22609
- }
22610
- function parseAnyDef2() {
22611
- return {};
22612
- }
22613
- function parseArrayDef2(def, refs) {
22614
- var _a23, _b23, _c;
22615
- const res = {
22616
- type: "array"
22617
- };
22618
- if (((_a23 = def.type) == null ? undefined : _a23._def) && ((_c = (_b23 = def.type) == null ? undefined : _b23._def) == null ? undefined : _c.typeName) !== ZodFirstPartyTypeKind2.ZodAny) {
22619
- res.items = parseDef2(def.type._def, {
22620
- ...refs,
22621
- currentPath: [...refs.currentPath, "items"]
22622
- });
22623
- }
22624
- if (def.minLength) {
22625
- res.minItems = def.minLength.value;
22626
- }
22627
- if (def.maxLength) {
22628
- res.maxItems = def.maxLength.value;
22629
- }
22630
- if (def.exactLength) {
22631
- res.minItems = def.exactLength.value;
22632
- res.maxItems = def.exactLength.value;
22633
- }
22634
- return res;
22635
- }
22636
- function parseBigintDef2(def) {
22637
- const res = {
22638
- type: "integer",
22639
- format: "int64"
22640
- };
22641
- if (!def.checks)
22642
- return res;
22643
- for (const check2 of def.checks) {
22644
- switch (check2.kind) {
22645
- case "min":
22646
- if (check2.inclusive) {
22647
- res.minimum = check2.value;
22648
- } else {
22649
- res.exclusiveMinimum = check2.value;
22650
- }
22651
- break;
22652
- case "max":
22653
- if (check2.inclusive) {
22654
- res.maximum = check2.value;
22655
- } else {
22656
- res.exclusiveMaximum = check2.value;
22657
- }
22658
- break;
22659
- case "multipleOf":
22660
- res.multipleOf = check2.value;
22661
- break;
22662
- }
22663
- }
22664
- return res;
22665
- }
22666
- function parseBooleanDef2() {
22667
- return { type: "boolean" };
22668
- }
22669
- function parseBrandedDef2(_def, refs) {
22670
- return parseDef2(_def.type._def, refs);
22671
- }
22672
- function parseDateDef2(def, refs, overrideDateStrategy) {
22673
- const strategy = overrideDateStrategy != null ? overrideDateStrategy : refs.dateStrategy;
22674
- if (Array.isArray(strategy)) {
22675
- return {
22676
- anyOf: strategy.map((item, i) => parseDateDef2(def, refs, item))
22677
- };
22678
- }
22679
- switch (strategy) {
22680
- case "string":
22681
- case "format:date-time":
22682
- return {
22683
- type: "string",
22684
- format: "date-time"
22685
- };
22686
- case "format:date":
22687
- return {
22688
- type: "string",
22689
- format: "date"
22690
- };
22691
- case "integer":
22692
- return integerDateParser2(def);
22693
- }
22694
- }
22695
- function parseDefaultDef2(_def, refs) {
22696
- return {
22697
- ...parseDef2(_def.innerType._def, refs),
22698
- default: _def.defaultValue()
22699
- };
22700
- }
22701
- function parseEffectsDef2(_def, refs) {
22702
- return refs.effectStrategy === "input" ? parseDef2(_def.schema._def, refs) : parseAnyDef2();
22703
- }
22704
- function parseEnumDef2(def) {
22705
- return {
22706
- type: "string",
22707
- enum: Array.from(def.values)
22708
- };
22709
- }
22710
- function parseIntersectionDef2(def, refs) {
22711
- const allOf = [
22712
- parseDef2(def.left._def, {
22713
- ...refs,
22714
- currentPath: [...refs.currentPath, "allOf", "0"]
22715
- }),
22716
- parseDef2(def.right._def, {
22717
- ...refs,
22718
- currentPath: [...refs.currentPath, "allOf", "1"]
22719
- })
22720
- ].filter((x) => !!x);
22721
- const mergedAllOf = [];
22722
- allOf.forEach((schema) => {
22723
- if (isJsonSchema7AllOfType2(schema)) {
22724
- mergedAllOf.push(...schema.allOf);
22725
- } else {
22726
- let nestedSchema = schema;
22727
- if ("additionalProperties" in schema && schema.additionalProperties === false) {
22728
- const { additionalProperties, ...rest } = schema;
22729
- nestedSchema = rest;
22730
- }
22731
- mergedAllOf.push(nestedSchema);
22732
- }
22733
- });
22734
- return mergedAllOf.length ? { allOf: mergedAllOf } : undefined;
22735
- }
22736
- function parseLiteralDef2(def) {
22737
- const parsedType2 = typeof def.value;
22738
- if (parsedType2 !== "bigint" && parsedType2 !== "number" && parsedType2 !== "boolean" && parsedType2 !== "string") {
22739
- return {
22740
- type: Array.isArray(def.value) ? "array" : "object"
22741
- };
22742
- }
22743
- return {
22744
- type: parsedType2 === "bigint" ? "integer" : parsedType2,
22745
- const: def.value
22746
- };
22747
- }
22748
- function parseStringDef2(def, refs) {
22749
- const res = {
22750
- type: "string"
22751
- };
22752
- if (def.checks) {
22753
- for (const check2 of def.checks) {
22754
- switch (check2.kind) {
22755
- case "min":
22756
- res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check2.value) : check2.value;
22757
- break;
22758
- case "max":
22759
- res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check2.value) : check2.value;
22760
- break;
22761
- case "email":
22762
- switch (refs.emailStrategy) {
22763
- case "format:email":
22764
- addFormat2(res, "email", check2.message, refs);
22765
- break;
22766
- case "format:idn-email":
22767
- addFormat2(res, "idn-email", check2.message, refs);
22768
- break;
22769
- case "pattern:zod":
22770
- addPattern2(res, zodPatterns2.email, check2.message, refs);
22771
- break;
22772
- }
22773
- break;
22774
- case "url":
22775
- addFormat2(res, "uri", check2.message, refs);
22776
- break;
22777
- case "uuid":
22778
- addFormat2(res, "uuid", check2.message, refs);
22779
- break;
22780
- case "regex":
22781
- addPattern2(res, check2.regex, check2.message, refs);
22782
- break;
22783
- case "cuid":
22784
- addPattern2(res, zodPatterns2.cuid, check2.message, refs);
22785
- break;
22786
- case "cuid2":
22787
- addPattern2(res, zodPatterns2.cuid2, check2.message, refs);
22788
- break;
22789
- case "startsWith":
22790
- addPattern2(res, RegExp(`^${escapeLiteralCheckValue2(check2.value, refs)}`), check2.message, refs);
22791
- break;
22792
- case "endsWith":
22793
- addPattern2(res, RegExp(`${escapeLiteralCheckValue2(check2.value, refs)}$`), check2.message, refs);
22794
- break;
22795
- case "datetime":
22796
- addFormat2(res, "date-time", check2.message, refs);
22797
- break;
22798
- case "date":
22799
- addFormat2(res, "date", check2.message, refs);
22800
- break;
22801
- case "time":
22802
- addFormat2(res, "time", check2.message, refs);
22803
- break;
22804
- case "duration":
22805
- addFormat2(res, "duration", check2.message, refs);
22806
- break;
22807
- case "length":
22808
- res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check2.value) : check2.value;
22809
- res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check2.value) : check2.value;
22810
- break;
22811
- case "includes": {
22812
- addPattern2(res, RegExp(escapeLiteralCheckValue2(check2.value, refs)), check2.message, refs);
22813
- break;
22814
- }
22815
- case "ip": {
22816
- if (check2.version !== "v6") {
22817
- addFormat2(res, "ipv4", check2.message, refs);
22818
- }
22819
- if (check2.version !== "v4") {
22820
- addFormat2(res, "ipv6", check2.message, refs);
22821
- }
22822
- break;
22823
- }
22824
- case "base64url":
22825
- addPattern2(res, zodPatterns2.base64url, check2.message, refs);
22826
- break;
22827
- case "jwt":
22828
- addPattern2(res, zodPatterns2.jwt, check2.message, refs);
22829
- break;
22830
- case "cidr": {
22831
- if (check2.version !== "v6") {
22832
- addPattern2(res, zodPatterns2.ipv4Cidr, check2.message, refs);
22833
- }
22834
- if (check2.version !== "v4") {
22835
- addPattern2(res, zodPatterns2.ipv6Cidr, check2.message, refs);
22836
- }
22837
- break;
22838
- }
22839
- case "emoji":
22840
- addPattern2(res, zodPatterns2.emoji(), check2.message, refs);
22841
- break;
22842
- case "ulid": {
22843
- addPattern2(res, zodPatterns2.ulid, check2.message, refs);
22844
- break;
22845
- }
22846
- case "base64": {
22847
- switch (refs.base64Strategy) {
22848
- case "format:binary": {
22849
- addFormat2(res, "binary", check2.message, refs);
22850
- break;
22851
- }
22852
- case "contentEncoding:base64": {
22853
- res.contentEncoding = "base64";
22854
- break;
22855
- }
22856
- case "pattern:zod": {
22857
- addPattern2(res, zodPatterns2.base64, check2.message, refs);
22858
- break;
22859
- }
22860
- }
22861
- break;
22862
- }
22863
- case "nanoid": {
22864
- addPattern2(res, zodPatterns2.nanoid, check2.message, refs);
22865
- }
22866
- case "toLowerCase":
22867
- case "toUpperCase":
22868
- case "trim":
22869
- break;
22870
- default:
22871
- }
22872
- }
22873
- }
22874
- return res;
22875
- }
22876
- function escapeLiteralCheckValue2(literal2, refs) {
22877
- return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric2(literal2) : literal2;
22878
- }
22879
- function escapeNonAlphaNumeric2(source) {
22880
- let result = "";
22881
- for (let i = 0;i < source.length; i++) {
22882
- if (!ALPHA_NUMERIC2.has(source[i])) {
22883
- result += "\\";
22884
- }
22885
- result += source[i];
22886
- }
22887
- return result;
22888
- }
22889
- function addFormat2(schema, value, message, refs) {
22890
- var _a23;
22891
- if (schema.format || ((_a23 = schema.anyOf) == null ? undefined : _a23.some((x) => x.format))) {
22892
- if (!schema.anyOf) {
22893
- schema.anyOf = [];
22894
- }
22895
- if (schema.format) {
22896
- schema.anyOf.push({
22897
- format: schema.format
22898
- });
22899
- delete schema.format;
22900
- }
22901
- schema.anyOf.push({
22902
- format: value,
22903
- ...message && refs.errorMessages && { errorMessage: { format: message } }
22904
- });
22905
- } else {
22906
- schema.format = value;
22907
- }
22908
- }
22909
- function addPattern2(schema, regex, message, refs) {
22910
- var _a23;
22911
- if (schema.pattern || ((_a23 = schema.allOf) == null ? undefined : _a23.some((x) => x.pattern))) {
22912
- if (!schema.allOf) {
22913
- schema.allOf = [];
22914
- }
22915
- if (schema.pattern) {
22916
- schema.allOf.push({
22917
- pattern: schema.pattern
22918
- });
22919
- delete schema.pattern;
22920
- }
22921
- schema.allOf.push({
22922
- pattern: stringifyRegExpWithFlags2(regex, refs),
22923
- ...message && refs.errorMessages && { errorMessage: { pattern: message } }
22924
- });
22925
- } else {
22926
- schema.pattern = stringifyRegExpWithFlags2(regex, refs);
22927
- }
22928
- }
22929
- function stringifyRegExpWithFlags2(regex, refs) {
22930
- var _a23;
22931
- if (!refs.applyRegexFlags || !regex.flags) {
22932
- return regex.source;
22933
- }
22934
- const flags = {
22935
- i: regex.flags.includes("i"),
22936
- m: regex.flags.includes("m"),
22937
- s: regex.flags.includes("s")
22938
- };
22939
- const source = flags.i ? regex.source.toLowerCase() : regex.source;
22940
- let pattern = "";
22941
- let isEscaped = false;
22942
- let inCharGroup = false;
22943
- let inCharRange = false;
22944
- for (let i = 0;i < source.length; i++) {
22945
- if (isEscaped) {
22946
- pattern += source[i];
22947
- isEscaped = false;
22948
- continue;
22949
- }
22950
- if (flags.i) {
22951
- if (inCharGroup) {
22952
- if (source[i].match(/[a-z]/)) {
22953
- if (inCharRange) {
22954
- pattern += source[i];
22955
- pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
22956
- inCharRange = false;
22957
- } else if (source[i + 1] === "-" && ((_a23 = source[i + 2]) == null ? undefined : _a23.match(/[a-z]/))) {
22958
- pattern += source[i];
22959
- inCharRange = true;
22960
- } else {
22961
- pattern += `${source[i]}${source[i].toUpperCase()}`;
22962
- }
22963
- continue;
22964
- }
22965
- } else if (source[i].match(/[a-z]/)) {
22966
- pattern += `[${source[i]}${source[i].toUpperCase()}]`;
22967
- continue;
22968
- }
22969
- }
22970
- if (flags.m) {
22971
- if (source[i] === "^") {
22972
- pattern += `(^|(?<=[\r
22973
- ]))`;
22974
- continue;
22975
- } else if (source[i] === "$") {
22976
- pattern += `($|(?=[\r
22977
- ]))`;
22978
- continue;
22979
- }
22980
- }
22981
- if (flags.s && source[i] === ".") {
22982
- pattern += inCharGroup ? `${source[i]}\r
22983
- ` : `[${source[i]}\r
22984
- ]`;
22985
- continue;
22986
- }
22987
- pattern += source[i];
22988
- if (source[i] === "\\") {
22989
- isEscaped = true;
22990
- } else if (inCharGroup && source[i] === "]") {
22991
- inCharGroup = false;
22992
- } else if (!inCharGroup && source[i] === "[") {
22993
- inCharGroup = true;
22994
- }
22995
- }
22996
- try {
22997
- new RegExp(pattern);
22998
- } catch (e) {
22999
- console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
23000
- return regex.source;
23001
- }
23002
- return pattern;
23003
- }
23004
- function parseRecordDef2(def, refs) {
23005
- var _a23, _b23, _c, _d, _e, _f;
23006
- const schema = {
23007
- type: "object",
23008
- additionalProperties: (_a23 = parseDef2(def.valueType._def, {
23009
- ...refs,
23010
- currentPath: [...refs.currentPath, "additionalProperties"]
23011
- })) != null ? _a23 : refs.allowedAdditionalProperties
23012
- };
23013
- if (((_b23 = def.keyType) == null ? undefined : _b23._def.typeName) === ZodFirstPartyTypeKind2.ZodString && ((_c = def.keyType._def.checks) == null ? undefined : _c.length)) {
23014
- const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
23015
- return {
23016
- ...schema,
23017
- propertyNames: keyType
23018
- };
23019
- } else if (((_d = def.keyType) == null ? undefined : _d._def.typeName) === ZodFirstPartyTypeKind2.ZodEnum) {
23020
- return {
23021
- ...schema,
23022
- propertyNames: {
23023
- enum: def.keyType._def.values
23024
- }
23025
- };
23026
- } else if (((_e = def.keyType) == null ? undefined : _e._def.typeName) === ZodFirstPartyTypeKind2.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind2.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? undefined : _f.length)) {
23027
- const { type, ...keyType } = parseBrandedDef2(def.keyType._def, refs);
23028
- return {
23029
- ...schema,
23030
- propertyNames: keyType
23031
- };
23032
- }
23033
- return schema;
23034
- }
23035
- function parseMapDef2(def, refs) {
23036
- if (refs.mapStrategy === "record") {
23037
- return parseRecordDef2(def, refs);
23038
- }
23039
- const keys = parseDef2(def.keyType._def, {
23040
- ...refs,
23041
- currentPath: [...refs.currentPath, "items", "items", "0"]
23042
- }) || parseAnyDef2();
23043
- const values = parseDef2(def.valueType._def, {
23044
- ...refs,
23045
- currentPath: [...refs.currentPath, "items", "items", "1"]
23046
- }) || parseAnyDef2();
23047
- return {
23048
- type: "array",
23049
- maxItems: 125,
23050
- items: {
23051
- type: "array",
23052
- items: [keys, values],
23053
- minItems: 2,
23054
- maxItems: 2
23055
- }
23056
- };
23057
- }
23058
- function parseNativeEnumDef2(def) {
23059
- const object2 = def.values;
23060
- const actualKeys = Object.keys(def.values).filter((key) => {
23061
- return typeof object2[object2[key]] !== "number";
23062
- });
23063
- const actualValues = actualKeys.map((key) => object2[key]);
23064
- const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
23065
- return {
23066
- type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
23067
- enum: actualValues
23068
- };
23069
- }
23070
- function parseNeverDef2() {
23071
- return { not: parseAnyDef2() };
23072
- }
23073
- function parseNullDef2() {
23074
- return {
23075
- type: "null"
23076
- };
23077
- }
23078
- function parseUnionDef2(def, refs) {
23079
- const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
23080
- if (options.every((x) => (x._def.typeName in primitiveMappings2) && (!x._def.checks || !x._def.checks.length))) {
23081
- const types2 = options.reduce((types22, x) => {
23082
- const type = primitiveMappings2[x._def.typeName];
23083
- return type && !types22.includes(type) ? [...types22, type] : types22;
23084
- }, []);
23085
- return {
23086
- type: types2.length > 1 ? types2 : types2[0]
23087
- };
23088
- } else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
23089
- const types2 = options.reduce((acc, x) => {
23090
- const type = typeof x._def.value;
23091
- switch (type) {
23092
- case "string":
23093
- case "number":
23094
- case "boolean":
23095
- return [...acc, type];
23096
- case "bigint":
23097
- return [...acc, "integer"];
23098
- case "object":
23099
- if (x._def.value === null)
23100
- return [...acc, "null"];
23101
- case "symbol":
23102
- case "undefined":
23103
- case "function":
23104
- default:
23105
- return acc;
23106
- }
23107
- }, []);
23108
- if (types2.length === options.length) {
23109
- const uniqueTypes = types2.filter((x, i, a) => a.indexOf(x) === i);
23110
- return {
23111
- type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
23112
- enum: options.reduce((acc, x) => {
23113
- return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
23114
- }, [])
23115
- };
23116
- }
23117
- } else if (options.every((x) => x._def.typeName === "ZodEnum")) {
23118
- return {
23119
- type: "string",
23120
- enum: options.reduce((acc, x) => [
23121
- ...acc,
23122
- ...x._def.values.filter((x2) => !acc.includes(x2))
23123
- ], [])
23124
- };
23125
- }
23126
- return asAnyOf2(def, refs);
23127
- }
23128
- function parseNullableDef2(def, refs) {
23129
- if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
23130
- return {
23131
- type: [
23132
- primitiveMappings2[def.innerType._def.typeName],
23133
- "null"
23134
- ]
23135
- };
23136
- }
23137
- const base = parseDef2(def.innerType._def, {
23138
- ...refs,
23139
- currentPath: [...refs.currentPath, "anyOf", "0"]
23140
- });
23141
- return base && { anyOf: [base, { type: "null" }] };
23142
- }
23143
- function parseNumberDef2(def) {
23144
- const res = {
23145
- type: "number"
23146
- };
23147
- if (!def.checks)
23148
- return res;
23149
- for (const check2 of def.checks) {
23150
- switch (check2.kind) {
23151
- case "int":
23152
- res.type = "integer";
23153
- break;
23154
- case "min":
23155
- if (check2.inclusive) {
23156
- res.minimum = check2.value;
23157
- } else {
23158
- res.exclusiveMinimum = check2.value;
23159
- }
23160
- break;
23161
- case "max":
23162
- if (check2.inclusive) {
23163
- res.maximum = check2.value;
23164
- } else {
23165
- res.exclusiveMaximum = check2.value;
23166
- }
23167
- break;
23168
- case "multipleOf":
23169
- res.multipleOf = check2.value;
23170
- break;
23171
- }
23172
- }
23173
- return res;
23174
- }
23175
- function parseObjectDef2(def, refs) {
23176
- const result = {
23177
- type: "object",
23178
- properties: {}
23179
- };
23180
- const required2 = [];
23181
- const shape = def.shape();
23182
- for (const propName in shape) {
23183
- let propDef = shape[propName];
23184
- if (propDef === undefined || propDef._def === undefined) {
23185
- continue;
23186
- }
23187
- const propOptional = safeIsOptional2(propDef);
23188
- const parsedDef = parseDef2(propDef._def, {
23189
- ...refs,
23190
- currentPath: [...refs.currentPath, "properties", propName],
23191
- propertyPath: [...refs.currentPath, "properties", propName]
23192
- });
23193
- if (parsedDef === undefined) {
23194
- continue;
23195
- }
23196
- result.properties[propName] = parsedDef;
23197
- if (!propOptional) {
23198
- required2.push(propName);
23199
- }
23200
- }
23201
- if (required2.length) {
23202
- result.required = required2;
23203
- }
23204
- const additionalProperties = decideAdditionalProperties2(def, refs);
23205
- if (additionalProperties !== undefined) {
23206
- result.additionalProperties = additionalProperties;
23207
- }
23208
- return result;
23209
- }
23210
- function decideAdditionalProperties2(def, refs) {
23211
- if (def.catchall._def.typeName !== "ZodNever") {
23212
- return parseDef2(def.catchall._def, {
23213
- ...refs,
23214
- currentPath: [...refs.currentPath, "additionalProperties"]
23215
- });
23216
- }
23217
- switch (def.unknownKeys) {
23218
- case "passthrough":
23219
- return refs.allowedAdditionalProperties;
23220
- case "strict":
23221
- return refs.rejectedAdditionalProperties;
23222
- case "strip":
23223
- return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
23224
- }
23225
- }
23226
- function safeIsOptional2(schema) {
23227
- try {
23228
- return schema.isOptional();
23229
- } catch (e) {
23230
- return true;
23231
- }
23232
- }
23233
- function parsePromiseDef2(def, refs) {
23234
- return parseDef2(def.type._def, refs);
23235
- }
23236
- function parseSetDef2(def, refs) {
23237
- const items = parseDef2(def.valueType._def, {
23238
- ...refs,
23239
- currentPath: [...refs.currentPath, "items"]
23240
- });
23241
- const schema = {
23242
- type: "array",
23243
- uniqueItems: true,
23244
- items
23245
- };
23246
- if (def.minSize) {
23247
- schema.minItems = def.minSize.value;
23248
- }
23249
- if (def.maxSize) {
23250
- schema.maxItems = def.maxSize.value;
23251
- }
23252
- return schema;
23253
- }
23254
- function parseTupleDef2(def, refs) {
23255
- if (def.rest) {
23256
- return {
23257
- type: "array",
23258
- minItems: def.items.length,
23259
- items: def.items.map((x, i) => parseDef2(x._def, {
23260
- ...refs,
23261
- currentPath: [...refs.currentPath, "items", `${i}`]
23262
- })).reduce((acc, x) => x === undefined ? acc : [...acc, x], []),
23263
- additionalItems: parseDef2(def.rest._def, {
23264
- ...refs,
23265
- currentPath: [...refs.currentPath, "additionalItems"]
23266
- })
23267
- };
23268
- } else {
23269
- return {
23270
- type: "array",
23271
- minItems: def.items.length,
23272
- maxItems: def.items.length,
23273
- items: def.items.map((x, i) => parseDef2(x._def, {
23274
- ...refs,
23275
- currentPath: [...refs.currentPath, "items", `${i}`]
23276
- })).reduce((acc, x) => x === undefined ? acc : [...acc, x], [])
23277
- };
23278
- }
23279
- }
23280
- function parseUndefinedDef2() {
23281
- return {
23282
- not: parseAnyDef2()
23283
- };
23284
- }
23285
- function parseUnknownDef2() {
23286
- return parseAnyDef2();
23287
- }
23288
- function parseDef2(def, refs, forceResolution = false) {
23289
- var _a23;
23290
- const seenItem = refs.seen.get(def);
23291
- if (refs.override) {
23292
- const overrideResult = (_a23 = refs.override) == null ? undefined : _a23.call(refs, def, refs, seenItem, forceResolution);
23293
- if (overrideResult !== ignoreOverride2) {
23294
- return overrideResult;
23295
- }
23296
- }
23297
- if (seenItem && !forceResolution) {
23298
- const seenSchema = get$ref2(seenItem, refs);
23299
- if (seenSchema !== undefined) {
23300
- return seenSchema;
23301
- }
23302
- }
23303
- const newItem = { def, path: refs.currentPath, jsonSchema: undefined };
23304
- refs.seen.set(def, newItem);
23305
- const jsonSchemaOrGetter = selectParser2(def, def.typeName, refs);
23306
- const jsonSchema2 = typeof jsonSchemaOrGetter === "function" ? parseDef2(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
23307
- if (jsonSchema2) {
23308
- addMeta2(def, refs, jsonSchema2);
23309
- }
23310
- if (refs.postProcess) {
23311
- const postProcessResult = refs.postProcess(jsonSchema2, def, refs);
23312
- newItem.jsonSchema = jsonSchema2;
23313
- return postProcessResult;
23314
- }
23315
- newItem.jsonSchema = jsonSchema2;
23316
- return jsonSchema2;
23317
- }
23318
- function lazySchema2(createSchema) {
23319
- let schema;
23320
- return () => {
23321
- if (schema == null) {
23322
- schema = createSchema();
23323
- }
23324
- return schema;
23325
- };
23326
- }
23327
- function jsonSchema2(jsonSchema22, {
23328
- validate
23329
- } = {}) {
23330
- return {
23331
- [schemaSymbol2]: true,
23332
- _type: undefined,
23333
- get jsonSchema() {
23334
- if (typeof jsonSchema22 === "function") {
23335
- jsonSchema22 = jsonSchema22();
23336
- }
23337
- return jsonSchema22;
23338
- },
23339
- validate
23340
- };
23341
- }
23342
- function isSchema2(value) {
23343
- return typeof value === "object" && value !== null && schemaSymbol2 in value && value[schemaSymbol2] === true && "jsonSchema" in value && "validate" in value;
23344
- }
23345
- function asSchema2(schema) {
23346
- return schema == null ? jsonSchema2({ properties: {}, additionalProperties: false }) : isSchema2(schema) ? schema : ("~standard" in schema) ? schema["~standard"].vendor === "zod" ? zodSchema2(schema) : standardSchema2(schema) : schema();
23347
- }
23348
- function standardSchema2(standardSchema22) {
23349
- return jsonSchema2(() => addAdditionalPropertiesToJsonSchema2(standardSchema22["~standard"].jsonSchema.input({
23350
- target: "draft-07"
23351
- })), {
23352
- validate: async (value) => {
23353
- const result = await standardSchema22["~standard"].validate(value);
23354
- return "value" in result ? { success: true, value: result.value } : {
23355
- success: false,
23356
- error: new TypeValidationError({
23357
- value,
23358
- cause: result.issues
23359
- })
23360
- };
23361
- }
23362
- });
23363
- }
23364
- function zod3Schema2(zodSchema2, options) {
23365
- var _a23;
23366
- const useReferences = (_a23 = options == null ? undefined : options.useReferences) != null ? _a23 : false;
23367
- return jsonSchema2(() => zod3ToJsonSchema2(zodSchema2, {
23368
- $refStrategy: useReferences ? "root" : "none"
23369
- }), {
23370
- validate: async (value) => {
23371
- const result = await zodSchema2.safeParseAsync(value);
23372
- return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
23373
- }
23374
- });
23375
- }
23376
- function zod4Schema2(zodSchema2, options) {
23377
- var _a23;
23378
- const useReferences = (_a23 = options == null ? undefined : options.useReferences) != null ? _a23 : false;
23379
- return jsonSchema2(() => addAdditionalPropertiesToJsonSchema2(toJSONSchema(zodSchema2, {
23380
- target: "draft-7",
23381
- io: "input",
23382
- reused: useReferences ? "ref" : "inline"
23383
- })), {
23384
- validate: async (value) => {
23385
- const result = await safeParseAsync2(zodSchema2, value);
23386
- return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
23387
- }
23388
- });
23389
- }
23390
- function isZod4Schema2(zodSchema2) {
23391
- return "_zod" in zodSchema2;
23392
- }
23393
- function zodSchema2(zodSchema22, options) {
23394
- if (isZod4Schema2(zodSchema22)) {
23395
- return zod4Schema2(zodSchema22, options);
23396
- } else {
23397
- return zod3Schema2(zodSchema22, options);
23398
- }
23399
- }
23400
- async function validateTypes2({
23401
- value,
23402
- schema,
23403
- context
23404
- }) {
23405
- const result = await safeValidateTypes2({ value, schema, context });
23406
- if (!result.success) {
23407
- throw TypeValidationError.wrap({ value, cause: result.error, context });
23408
- }
23409
- return result.value;
23410
- }
23411
- async function safeValidateTypes2({
23412
- value,
23413
- schema,
23414
- context
23415
- }) {
23416
- const actualSchema = asSchema2(schema);
23417
- try {
23418
- if (actualSchema.validate == null) {
23419
- return { success: true, value, rawValue: value };
23420
- }
23421
- const result = await actualSchema.validate(value);
23422
- if (result.success) {
23423
- return { success: true, value: result.value, rawValue: value };
23424
- }
23425
- return {
23426
- success: false,
23427
- error: TypeValidationError.wrap({ value, cause: result.error, context }),
23428
- rawValue: value
23429
- };
23430
- } catch (error51) {
23431
- return {
23432
- success: false,
23433
- error: TypeValidationError.wrap({ value, cause: error51, context }),
23434
- rawValue: value
23435
- };
23436
- }
23437
- }
23438
- async function safeParseJSON2({
23439
- text,
23440
- schema
23441
- }) {
23442
- try {
23443
- const value = secureJsonParse2(text);
23444
- if (schema == null) {
23445
- return { success: true, value, rawValue: value };
23446
- }
23447
- return await safeValidateTypes2({ value, schema });
23448
- } catch (error51) {
23449
- return {
23450
- success: false,
23451
- error: JSONParseError.isInstance(error51) ? error51 : new JSONParseError({ text, cause: error51 }),
23452
- rawValue: undefined
23453
- };
23454
- }
23455
- }
23456
- function parseJsonEventStream2({
23457
- stream,
23458
- schema
23459
- }) {
23460
- return stream.pipeThrough(new TextDecoderStream).pipeThrough(new EventSourceParserStream).pipeThrough(new TransformStream({
23461
- async transform({ data }, controller) {
23462
- if (data === "[DONE]") {
23463
- return;
23464
- }
23465
- controller.enqueue(await safeParseJSON2({ text: data, schema }));
23466
- }
23467
- }));
23468
- }
23469
- function tool2(tool22) {
23470
- return tool22;
23471
- }
23472
- function dynamicTool(tool22) {
23473
- return { ...tool22, type: "dynamic" };
23474
- }
23475
- async function resolve2(value) {
23476
- if (typeof value === "function") {
23477
- value = value();
23478
- }
23479
- return Promise.resolve(value);
23480
- }
23481
- function isAsyncIterable(obj) {
23482
- return obj != null && typeof obj[Symbol.asyncIterator] === "function";
23483
- }
23484
- async function* executeTool({
23485
- execute,
23486
- input,
23487
- options
23488
- }) {
23489
- const result = execute(input, options);
23490
- if (isAsyncIterable(result)) {
23491
- let lastOutput;
23492
- for await (const output of result) {
23493
- lastOutput = output;
23494
- yield { type: "preliminary", output };
23495
- }
23496
- yield { type: "final", output: lastOutput };
23497
- } else {
23498
- yield { type: "final", output: await result };
23499
- }
23500
- }
23501
- var DelayedPromise = class {
23502
- constructor() {
23503
- this.status = { type: "pending" };
23504
- this._resolve = undefined;
23505
- this._reject = undefined;
23506
- }
23507
- get promise() {
23508
- if (this._promise) {
23509
- return this._promise;
23510
- }
23511
- this._promise = new Promise((resolve2, reject) => {
23512
- if (this.status.type === "resolved") {
23513
- resolve2(this.status.value);
23514
- } else if (this.status.type === "rejected") {
23515
- reject(this.status.error);
23516
- }
23517
- this._resolve = resolve2;
23518
- this._reject = reject;
23519
- });
23520
- return this._promise;
23521
- }
23522
- resolve(value) {
23523
- var _a23;
23524
- this.status = { type: "resolved", value };
23525
- if (this._promise) {
23526
- (_a23 = this._resolve) == null || _a23.call(this, value);
23527
- }
23528
- }
23529
- reject(error51) {
23530
- var _a23;
23531
- this.status = { type: "rejected", error: error51 };
23532
- if (this._promise) {
23533
- (_a23 = this._reject) == null || _a23.call(this, error51);
23534
- }
23535
- }
23536
- isResolved() {
23537
- return this.status.type === "resolved";
23538
- }
23539
- isRejected() {
23540
- return this.status.type === "rejected";
23541
- }
23542
- isPending() {
23543
- return this.status.type === "pending";
23544
- }
23545
- }, btoa3, atob3, name17 = "AI_DownloadError", marker18, symbol19, _a20, _b18, DownloadError2, DEFAULT_MAX_DOWNLOAD_SIZE2, createIdGenerator2 = ({
23546
- prefix,
23547
- size = 16,
23548
- alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
23549
- separator = "-"
23550
- } = {}) => {
23551
- const generator = () => {
23552
- const alphabetLength = alphabet.length;
23553
- const chars = new Array(size);
23554
- for (let i = 0;i < size; i++) {
23555
- chars[i] = alphabet[Math.random() * alphabetLength | 0];
23556
- }
23557
- return chars.join("");
23558
- };
23559
- if (prefix == null) {
23560
- return generator;
23561
- }
23562
- if (alphabet.includes(separator)) {
23563
- throw new InvalidArgumentError({
23564
- argument: "separator",
23565
- message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
23566
- });
23567
- }
23568
- return () => `${prefix}${separator}${generator()}`;
23569
- }, generateId2, suspectProtoRx2, suspectConstructorRx2, ignoreOverride2, defaultOptions2, getDefaultOptions2 = (options) => typeof options === "string" ? {
23570
- ...defaultOptions2,
23571
- name: options
23572
- } : {
23573
- ...defaultOptions2,
23574
- ...options
23575
- }, parseCatchDef2 = (def, refs) => {
23576
- return parseDef2(def.innerType._def, refs);
23577
- }, integerDateParser2 = (def) => {
23578
- const res = {
23579
- type: "integer",
23580
- format: "unix-time"
23581
- };
23582
- for (const check2 of def.checks) {
23583
- switch (check2.kind) {
23584
- case "min":
23585
- res.minimum = check2.value;
23586
- break;
23587
- case "max":
23588
- res.maximum = check2.value;
23589
- break;
23590
- }
23591
- }
23592
- return res;
23593
- }, isJsonSchema7AllOfType2 = (type) => {
23594
- if ("type" in type && type.type === "string")
23595
- return false;
23596
- return "allOf" in type;
23597
- }, emojiRegex3 = undefined, zodPatterns2, ALPHA_NUMERIC2, primitiveMappings2, asAnyOf2 = (def, refs) => {
23598
- const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef2(x._def, {
23599
- ...refs,
23600
- currentPath: [...refs.currentPath, "anyOf", `${i}`]
23601
- })).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
23602
- return anyOf.length ? { anyOf } : undefined;
23603
- }, parseOptionalDef2 = (def, refs) => {
23604
- var _a23;
23605
- if (refs.currentPath.toString() === ((_a23 = refs.propertyPath) == null ? undefined : _a23.toString())) {
23606
- return parseDef2(def.innerType._def, refs);
23607
- }
23608
- const innerSchema = parseDef2(def.innerType._def, {
23609
- ...refs,
23610
- currentPath: [...refs.currentPath, "anyOf", "1"]
23611
- });
23612
- return innerSchema ? { anyOf: [{ not: parseAnyDef2() }, innerSchema] } : parseAnyDef2();
23613
- }, parsePipelineDef2 = (def, refs) => {
23614
- if (refs.pipeStrategy === "input") {
23615
- return parseDef2(def.in._def, refs);
23616
- } else if (refs.pipeStrategy === "output") {
23617
- return parseDef2(def.out._def, refs);
23618
- }
23619
- const a = parseDef2(def.in._def, {
23620
- ...refs,
23621
- currentPath: [...refs.currentPath, "allOf", "0"]
23622
- });
23623
- const b = parseDef2(def.out._def, {
23624
- ...refs,
23625
- currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
23626
- });
23627
- return {
23628
- allOf: [a, b].filter((x) => x !== undefined)
23629
- };
23630
- }, parseReadonlyDef2 = (def, refs) => {
23631
- return parseDef2(def.innerType._def, refs);
23632
- }, selectParser2 = (def, typeName, refs) => {
23633
- switch (typeName) {
23634
- case ZodFirstPartyTypeKind2.ZodString:
23635
- return parseStringDef2(def, refs);
23636
- case ZodFirstPartyTypeKind2.ZodNumber:
23637
- return parseNumberDef2(def);
23638
- case ZodFirstPartyTypeKind2.ZodObject:
23639
- return parseObjectDef2(def, refs);
23640
- case ZodFirstPartyTypeKind2.ZodBigInt:
23641
- return parseBigintDef2(def);
23642
- case ZodFirstPartyTypeKind2.ZodBoolean:
23643
- return parseBooleanDef2();
23644
- case ZodFirstPartyTypeKind2.ZodDate:
23645
- return parseDateDef2(def, refs);
23646
- case ZodFirstPartyTypeKind2.ZodUndefined:
23647
- return parseUndefinedDef2();
23648
- case ZodFirstPartyTypeKind2.ZodNull:
23649
- return parseNullDef2();
23650
- case ZodFirstPartyTypeKind2.ZodArray:
23651
- return parseArrayDef2(def, refs);
23652
- case ZodFirstPartyTypeKind2.ZodUnion:
23653
- case ZodFirstPartyTypeKind2.ZodDiscriminatedUnion:
23654
- return parseUnionDef2(def, refs);
23655
- case ZodFirstPartyTypeKind2.ZodIntersection:
23656
- return parseIntersectionDef2(def, refs);
23657
- case ZodFirstPartyTypeKind2.ZodTuple:
23658
- return parseTupleDef2(def, refs);
23659
- case ZodFirstPartyTypeKind2.ZodRecord:
23660
- return parseRecordDef2(def, refs);
23661
- case ZodFirstPartyTypeKind2.ZodLiteral:
23662
- return parseLiteralDef2(def);
23663
- case ZodFirstPartyTypeKind2.ZodEnum:
23664
- return parseEnumDef2(def);
23665
- case ZodFirstPartyTypeKind2.ZodNativeEnum:
23666
- return parseNativeEnumDef2(def);
23667
- case ZodFirstPartyTypeKind2.ZodNullable:
23668
- return parseNullableDef2(def, refs);
23669
- case ZodFirstPartyTypeKind2.ZodOptional:
23670
- return parseOptionalDef2(def, refs);
23671
- case ZodFirstPartyTypeKind2.ZodMap:
23672
- return parseMapDef2(def, refs);
23673
- case ZodFirstPartyTypeKind2.ZodSet:
23674
- return parseSetDef2(def, refs);
23675
- case ZodFirstPartyTypeKind2.ZodLazy:
23676
- return () => def.getter()._def;
23677
- case ZodFirstPartyTypeKind2.ZodPromise:
23678
- return parsePromiseDef2(def, refs);
23679
- case ZodFirstPartyTypeKind2.ZodNaN:
23680
- case ZodFirstPartyTypeKind2.ZodNever:
23681
- return parseNeverDef2();
23682
- case ZodFirstPartyTypeKind2.ZodEffects:
23683
- return parseEffectsDef2(def, refs);
23684
- case ZodFirstPartyTypeKind2.ZodAny:
23685
- return parseAnyDef2();
23686
- case ZodFirstPartyTypeKind2.ZodUnknown:
23687
- return parseUnknownDef2();
23688
- case ZodFirstPartyTypeKind2.ZodDefault:
23689
- return parseDefaultDef2(def, refs);
23690
- case ZodFirstPartyTypeKind2.ZodBranded:
23691
- return parseBrandedDef2(def, refs);
23692
- case ZodFirstPartyTypeKind2.ZodReadonly:
23693
- return parseReadonlyDef2(def, refs);
23694
- case ZodFirstPartyTypeKind2.ZodCatch:
23695
- return parseCatchDef2(def, refs);
23696
- case ZodFirstPartyTypeKind2.ZodPipeline:
23697
- return parsePipelineDef2(def, refs);
23698
- case ZodFirstPartyTypeKind2.ZodFunction:
23699
- case ZodFirstPartyTypeKind2.ZodVoid:
23700
- case ZodFirstPartyTypeKind2.ZodSymbol:
23701
- return;
23702
- default:
23703
- return /* @__PURE__ */ ((_) => {
23704
- return;
23705
- })(typeName);
23706
- }
23707
- }, getRelativePath2 = (pathA, pathB) => {
23708
- let i = 0;
23709
- for (;i < pathA.length && i < pathB.length; i++) {
23710
- if (pathA[i] !== pathB[i])
23711
- break;
23712
- }
23713
- return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
23714
- }, get$ref2 = (item, refs) => {
23715
- switch (refs.$refStrategy) {
23716
- case "root":
23717
- return { $ref: item.path.join("/") };
23718
- case "relative":
23719
- return { $ref: getRelativePath2(refs.currentPath, item.path) };
23720
- case "none":
23721
- case "seen": {
23722
- if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
23723
- console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
23724
- return parseAnyDef2();
23725
- }
23726
- return refs.$refStrategy === "seen" ? parseAnyDef2() : undefined;
23727
- }
23728
- }
23729
- }, addMeta2 = (def, refs, jsonSchema2) => {
23730
- if (def.description) {
23731
- jsonSchema2.description = def.description;
23732
- }
23733
- return jsonSchema2;
23734
- }, getRefs2 = (options) => {
23735
- const _options = getDefaultOptions2(options);
23736
- const currentPath = _options.name !== undefined ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
23737
- return {
23738
- ..._options,
23739
- currentPath,
23740
- propertyPath: undefined,
23741
- seen: new Map(Object.entries(_options.definitions).map(([name23, def]) => [
23742
- def._def,
23743
- {
23744
- def: def._def,
23745
- path: [..._options.basePath, _options.definitionPath, name23],
23746
- jsonSchema: undefined
23747
- }
23748
- ]))
23749
- };
23750
- }, zod3ToJsonSchema2 = (schema, options) => {
23751
- var _a23;
23752
- const refs = getRefs2(options);
23753
- let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name33, schema2]) => {
23754
- var _a33;
23755
- return {
23756
- ...acc,
23757
- [name33]: (_a33 = parseDef2(schema2._def, {
23758
- ...refs,
23759
- currentPath: [...refs.basePath, refs.definitionPath, name33]
23760
- }, true)) != null ? _a33 : parseAnyDef2()
23761
- };
23762
- }, {}) : undefined;
23763
- const name23 = typeof options === "string" ? options : (options == null ? undefined : options.nameStrategy) === "title" ? undefined : options == null ? undefined : options.name;
23764
- const main = (_a23 = parseDef2(schema._def, name23 === undefined ? refs : {
23765
- ...refs,
23766
- currentPath: [...refs.basePath, refs.definitionPath, name23]
23767
- }, false)) != null ? _a23 : parseAnyDef2();
23768
- const title = typeof options === "object" && options.name !== undefined && options.nameStrategy === "title" ? options.name : undefined;
23769
- if (title !== undefined) {
23770
- main.title = title;
23771
- }
23772
- const combined = name23 === undefined ? definitions ? {
23773
- ...main,
23774
- [refs.definitionPath]: definitions
23775
- } : main : {
23776
- $ref: [
23777
- ...refs.$refStrategy === "relative" ? [] : refs.basePath,
23778
- refs.definitionPath,
23779
- name23
23780
- ].join("/"),
23781
- [refs.definitionPath]: {
23782
- ...definitions,
23783
- [name23]: main
23784
- }
23785
- };
23786
- combined.$schema = "http://json-schema.org/draft-07/schema#";
23787
- return combined;
23788
- }, schemaSymbol2;
23789
- var init_dist5 = __esm(() => {
23790
- init_dist();
23791
- init_dist();
23792
- init_dist();
23793
- init_dist();
23794
- init_dist();
23795
- init_v4();
23796
- init_v3();
23797
- init_v3();
23798
- init_v3();
23799
- init_stream();
23800
- ({ btoa: btoa3, atob: atob3 } = globalThis);
23801
- marker18 = `vercel.ai.error.${name17}`;
23802
- symbol19 = Symbol.for(marker18);
23803
- DownloadError2 = class extends (_b18 = AISDKError, _a20 = symbol19, _b18) {
23804
- constructor({
23805
- url: url2,
23806
- statusCode,
23807
- statusText,
23808
- cause,
23809
- message = cause == null ? `Failed to download ${url2}: ${statusCode} ${statusText}` : `Failed to download ${url2}: ${cause}`
23810
- }) {
23811
- super({ name: name17, message, cause });
23812
- this[_a20] = true;
23813
- this.url = url2;
23814
- this.statusCode = statusCode;
23815
- this.statusText = statusText;
23816
- }
23817
- static isInstance(error51) {
23818
- return AISDKError.hasMarker(error51, marker18);
23819
- }
23820
- };
23821
- DEFAULT_MAX_DOWNLOAD_SIZE2 = 2 * 1024 * 1024 * 1024;
23822
- generateId2 = createIdGenerator2();
23823
- suspectProtoRx2 = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
23824
- 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*:/;
23825
- ignoreOverride2 = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
23826
- defaultOptions2 = {
23827
- name: undefined,
23828
- $refStrategy: "root",
23829
- basePath: ["#"],
23830
- effectStrategy: "input",
23831
- pipeStrategy: "all",
23832
- dateStrategy: "format:date-time",
23833
- mapStrategy: "entries",
23834
- removeAdditionalStrategy: "passthrough",
23835
- allowedAdditionalProperties: true,
23836
- rejectedAdditionalProperties: false,
23837
- definitionPath: "definitions",
23838
- strictUnions: false,
23839
- definitions: {},
23840
- errorMessages: false,
23841
- patternStrategy: "escape",
23842
- applyRegexFlags: false,
23843
- emailStrategy: "format:email",
23844
- base64Strategy: "contentEncoding:base64",
23845
- nameStrategy: "ref"
23846
- };
23847
- zodPatterns2 = {
23848
- cuid: /^[cC][^\s-]{8,}$/,
23849
- cuid2: /^[0-9a-z]+$/,
23850
- ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
23851
- email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
23852
- emoji: () => {
23853
- if (emojiRegex3 === undefined) {
23854
- emojiRegex3 = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
23855
- }
23856
- return emojiRegex3;
23857
- },
23858
- uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
23859
- ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
23860
- ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
23861
- ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
23862
- ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
23863
- base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
23864
- base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
23865
- nanoid: /^[a-zA-Z0-9_-]{21}$/,
23866
- jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
23867
- };
23868
- ALPHA_NUMERIC2 = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
23869
- primitiveMappings2 = {
23870
- ZodString: "string",
23871
- ZodNumber: "number",
23872
- ZodBigInt: "integer",
23873
- ZodBoolean: "boolean",
23874
- ZodNull: "null"
23875
- };
23876
- schemaSymbol2 = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
23877
- });
23878
-
23879
- // node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js
23880
- var require_globalThis = __commonJS((exports) => {
23881
- Object.defineProperty(exports, "__esModule", { value: true });
23882
- exports._globalThis = undefined;
23883
- exports._globalThis = typeof globalThis === "object" ? globalThis : global;
23884
- });
23885
-
23886
- // node_modules/@opentelemetry/api/build/src/platform/node/index.js
23887
- var require_node = __commonJS((exports) => {
23888
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
23889
- if (k2 === undefined)
23890
- k2 = k;
23891
- Object.defineProperty(o, k2, { enumerable: true, get: function() {
23892
- return m[k];
23893
- } });
23894
- } : function(o, m, k, k2) {
23895
- if (k2 === undefined)
23896
- k2 = k;
23897
- o[k2] = m[k];
23898
- });
23899
- var __exportStar = exports && exports.__exportStar || function(m, exports2) {
23900
- for (var p in m)
23901
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
23902
- __createBinding(exports2, m, p);
23903
- };
23904
- Object.defineProperty(exports, "__esModule", { value: true });
23905
- __exportStar(require_globalThis(), exports);
23906
- });
23907
-
23908
- // node_modules/@opentelemetry/api/build/src/platform/index.js
23909
- var require_platform = __commonJS((exports) => {
23910
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
23911
- if (k2 === undefined)
23912
- k2 = k;
23913
- Object.defineProperty(o, k2, { enumerable: true, get: function() {
23914
- return m[k];
23915
- } });
23916
- } : function(o, m, k, k2) {
23917
- if (k2 === undefined)
23918
- k2 = k;
23919
- o[k2] = m[k];
23920
- });
23921
- var __exportStar = exports && exports.__exportStar || function(m, exports2) {
23922
- for (var p in m)
23923
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
23924
- __createBinding(exports2, m, p);
23925
- };
23926
- Object.defineProperty(exports, "__esModule", { value: true });
23927
- __exportStar(require_node(), exports);
23928
- });
23929
-
23930
22961
  // node_modules/@opentelemetry/api/build/src/version.js
23931
22962
  var require_version = __commonJS((exports) => {
23932
22963
  Object.defineProperty(exports, "__esModule", { value: true });
23933
22964
  exports.VERSION = undefined;
23934
- exports.VERSION = "1.9.0";
22965
+ exports.VERSION = "1.9.1";
23935
22966
  });
23936
22967
 
23937
22968
  // node_modules/@opentelemetry/api/build/src/internal/semver.js
@@ -24009,12 +23040,11 @@ var require_semver = __commonJS((exports) => {
24009
23040
  var require_global_utils = __commonJS((exports) => {
24010
23041
  Object.defineProperty(exports, "__esModule", { value: true });
24011
23042
  exports.unregisterGlobal = exports.getGlobal = exports.registerGlobal = undefined;
24012
- var platform_1 = require_platform();
24013
23043
  var version_1 = require_version();
24014
23044
  var semver_1 = require_semver();
24015
23045
  var major = version_1.VERSION.split(".")[0];
24016
23046
  var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(`opentelemetry.js.api.${major}`);
24017
- var _global = platform_1._globalThis;
23047
+ var _global = typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof window === "object" ? window : typeof global === "object" ? global : {};
24018
23048
  function registerGlobal(type, instance, diag, allowOverride = false) {
24019
23049
  var _a16;
24020
23050
  const api2 = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a16 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a16 !== undefined ? _a16 : {
@@ -24086,8 +23116,7 @@ var require_ComponentLogger = __commonJS((exports) => {
24086
23116
  if (!logger) {
24087
23117
  return;
24088
23118
  }
24089
- args.unshift(namespace);
24090
- return logger[funcName](...args);
23119
+ return logger[funcName](namespace, ...args);
24091
23120
  }
24092
23121
  });
24093
23122
 
@@ -24148,6 +23177,12 @@ var require_diag = __commonJS((exports) => {
24148
23177
  var API_NAME = "diag";
24149
23178
 
24150
23179
  class DiagAPI {
23180
+ static instance() {
23181
+ if (!this._instance) {
23182
+ this._instance = new DiagAPI;
23183
+ }
23184
+ return this._instance;
23185
+ }
24151
23186
  constructor() {
24152
23187
  function _logProxy(funcName) {
24153
23188
  return function(...args) {
@@ -24157,12 +23192,12 @@ var require_diag = __commonJS((exports) => {
24157
23192
  return logger[funcName](...args);
24158
23193
  };
24159
23194
  }
24160
- const self = this;
23195
+ const self2 = this;
24161
23196
  const setLogger = (logger, optionsOrLogLevel = { logLevel: types_1.DiagLogLevel.INFO }) => {
24162
23197
  var _a16, _b16, _c;
24163
- if (logger === self) {
23198
+ if (logger === self2) {
24164
23199
  const err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
24165
- self.error((_a16 = err.stack) !== null && _a16 !== undefined ? _a16 : err.message);
23200
+ self2.error((_a16 = err.stack) !== null && _a16 !== undefined ? _a16 : err.message);
24166
23201
  return false;
24167
23202
  }
24168
23203
  if (typeof optionsOrLogLevel === "number") {
@@ -24177,26 +23212,20 @@ var require_diag = __commonJS((exports) => {
24177
23212
  oldLogger.warn(`Current logger will be overwritten from ${stack}`);
24178
23213
  newLogger.warn(`Current logger will overwrite one already registered from ${stack}`);
24179
23214
  }
24180
- return (0, global_utils_1.registerGlobal)("diag", newLogger, self, true);
23215
+ return (0, global_utils_1.registerGlobal)("diag", newLogger, self2, true);
24181
23216
  };
24182
- self.setLogger = setLogger;
24183
- self.disable = () => {
24184
- (0, global_utils_1.unregisterGlobal)(API_NAME, self);
23217
+ self2.setLogger = setLogger;
23218
+ self2.disable = () => {
23219
+ (0, global_utils_1.unregisterGlobal)(API_NAME, self2);
24185
23220
  };
24186
- self.createComponentLogger = (options) => {
23221
+ self2.createComponentLogger = (options) => {
24187
23222
  return new ComponentLogger_1.DiagComponentLogger(options);
24188
23223
  };
24189
- self.verbose = _logProxy("verbose");
24190
- self.debug = _logProxy("debug");
24191
- self.info = _logProxy("info");
24192
- self.warn = _logProxy("warn");
24193
- self.error = _logProxy("error");
24194
- }
24195
- static instance() {
24196
- if (!this._instance) {
24197
- this._instance = new DiagAPI;
24198
- }
24199
- return this._instance;
23224
+ self2.verbose = _logProxy("verbose");
23225
+ self2.debug = _logProxy("debug");
23226
+ self2.info = _logProxy("info");
23227
+ self2.warn = _logProxy("warn");
23228
+ self2.error = _logProxy("error");
24200
23229
  }
24201
23230
  }
24202
23231
  exports.DiagAPI = DiagAPI;
@@ -24219,7 +23248,7 @@ var require_baggage_impl = __commonJS((exports) => {
24219
23248
  return Object.assign({}, entry);
24220
23249
  }
24221
23250
  getAllEntries() {
24222
- return Array.from(this._entries.entries()).map(([k, v]) => [k, v]);
23251
+ return Array.from(this._entries.entries());
24223
23252
  }
24224
23253
  setEntry(key, entry) {
24225
23254
  const newBaggage = new BaggageImpl(this._entries);
@@ -24290,16 +23319,16 @@ var require_context = __commonJS((exports) => {
24290
23319
 
24291
23320
  class BaseContext {
24292
23321
  constructor(parentContext) {
24293
- const self = this;
24294
- self._currentContext = parentContext ? new Map(parentContext) : new Map;
24295
- self.getValue = (key) => self._currentContext.get(key);
24296
- self.setValue = (key, value) => {
24297
- const context = new BaseContext(self._currentContext);
23322
+ const self2 = this;
23323
+ self2._currentContext = parentContext ? new Map(parentContext) : new Map;
23324
+ self2.getValue = (key) => self2._currentContext.get(key);
23325
+ self2.setValue = (key, value) => {
23326
+ const context = new BaseContext(self2._currentContext);
24298
23327
  context._currentContext.set(key, value);
24299
23328
  return context;
24300
23329
  };
24301
- self.deleteValue = (key) => {
24302
- const context = new BaseContext(self._currentContext);
23330
+ self2.deleteValue = (key) => {
23331
+ const context = new BaseContext(self2._currentContext);
24303
23332
  context._currentContext.delete(key);
24304
23333
  return context;
24305
23334
  };
@@ -24311,7 +23340,7 @@ var require_context = __commonJS((exports) => {
24311
23340
  // node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js
24312
23341
  var require_consoleLogger = __commonJS((exports) => {
24313
23342
  Object.defineProperty(exports, "__esModule", { value: true });
24314
- exports.DiagConsoleLogger = undefined;
23343
+ exports.DiagConsoleLogger = exports._originalConsoleMethods = undefined;
24315
23344
  var consoleMap = [
24316
23345
  { n: "error", c: "error" },
24317
23346
  { n: "warn", c: "warn" },
@@ -24319,19 +23348,39 @@ var require_consoleLogger = __commonJS((exports) => {
24319
23348
  { n: "debug", c: "debug" },
24320
23349
  { n: "verbose", c: "trace" }
24321
23350
  ];
23351
+ exports._originalConsoleMethods = {};
23352
+ if (typeof console !== "undefined") {
23353
+ const keys = [
23354
+ "error",
23355
+ "warn",
23356
+ "info",
23357
+ "debug",
23358
+ "trace",
23359
+ "log"
23360
+ ];
23361
+ for (const key of keys) {
23362
+ if (typeof console[key] === "function") {
23363
+ exports._originalConsoleMethods[key] = console[key];
23364
+ }
23365
+ }
23366
+ }
24322
23367
 
24323
23368
  class DiagConsoleLogger {
24324
23369
  constructor() {
24325
23370
  function _consoleFunc(funcName) {
24326
23371
  return function(...args) {
24327
- if (console) {
24328
- let theFunc = console[funcName];
23372
+ let theFunc = exports._originalConsoleMethods[funcName];
23373
+ if (typeof theFunc !== "function") {
23374
+ theFunc = exports._originalConsoleMethods["log"];
23375
+ }
23376
+ if (typeof theFunc !== "function" && console) {
23377
+ theFunc = console[funcName];
24329
23378
  if (typeof theFunc !== "function") {
24330
23379
  theFunc = console.log;
24331
23380
  }
24332
- if (typeof theFunc === "function") {
24333
- return theFunc.apply(console, args);
24334
- }
23381
+ }
23382
+ if (typeof theFunc === "function") {
23383
+ return theFunc.apply(console, args);
24335
23384
  }
24336
23385
  };
24337
23386
  }
@@ -24569,8 +23618,8 @@ var require_NonRecordingSpan = __commonJS((exports) => {
24569
23618
  var invalid_span_constants_1 = require_invalid_span_constants();
24570
23619
 
24571
23620
  class NonRecordingSpan {
24572
- constructor(_spanContext = invalid_span_constants_1.INVALID_SPAN_CONTEXT) {
24573
- this._spanContext = _spanContext;
23621
+ constructor(spanContext = invalid_span_constants_1.INVALID_SPAN_CONTEXT) {
23622
+ this._spanContext = spanContext;
24574
23623
  }
24575
23624
  spanContext() {
24576
23625
  return this._spanContext;
@@ -24646,14 +23695,126 @@ var require_spancontext_utils = __commonJS((exports) => {
24646
23695
  exports.wrapSpanContext = exports.isSpanContextValid = exports.isValidSpanId = exports.isValidTraceId = undefined;
24647
23696
  var invalid_span_constants_1 = require_invalid_span_constants();
24648
23697
  var NonRecordingSpan_1 = require_NonRecordingSpan();
24649
- var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
24650
- var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
23698
+ var isHex = new Uint8Array([
23699
+ 0,
23700
+ 0,
23701
+ 0,
23702
+ 0,
23703
+ 0,
23704
+ 0,
23705
+ 0,
23706
+ 0,
23707
+ 0,
23708
+ 0,
23709
+ 0,
23710
+ 0,
23711
+ 0,
23712
+ 0,
23713
+ 0,
23714
+ 0,
23715
+ 0,
23716
+ 0,
23717
+ 0,
23718
+ 0,
23719
+ 0,
23720
+ 0,
23721
+ 0,
23722
+ 0,
23723
+ 0,
23724
+ 0,
23725
+ 0,
23726
+ 0,
23727
+ 0,
23728
+ 0,
23729
+ 0,
23730
+ 0,
23731
+ 0,
23732
+ 0,
23733
+ 0,
23734
+ 0,
23735
+ 0,
23736
+ 0,
23737
+ 0,
23738
+ 0,
23739
+ 0,
23740
+ 0,
23741
+ 0,
23742
+ 0,
23743
+ 0,
23744
+ 0,
23745
+ 0,
23746
+ 0,
23747
+ 1,
23748
+ 1,
23749
+ 1,
23750
+ 1,
23751
+ 1,
23752
+ 1,
23753
+ 1,
23754
+ 1,
23755
+ 1,
23756
+ 1,
23757
+ 0,
23758
+ 0,
23759
+ 0,
23760
+ 0,
23761
+ 0,
23762
+ 0,
23763
+ 0,
23764
+ 1,
23765
+ 1,
23766
+ 1,
23767
+ 1,
23768
+ 1,
23769
+ 1,
23770
+ 0,
23771
+ 0,
23772
+ 0,
23773
+ 0,
23774
+ 0,
23775
+ 0,
23776
+ 0,
23777
+ 0,
23778
+ 0,
23779
+ 0,
23780
+ 0,
23781
+ 0,
23782
+ 0,
23783
+ 0,
23784
+ 0,
23785
+ 0,
23786
+ 0,
23787
+ 0,
23788
+ 0,
23789
+ 0,
23790
+ 0,
23791
+ 0,
23792
+ 0,
23793
+ 0,
23794
+ 0,
23795
+ 0,
23796
+ 1,
23797
+ 1,
23798
+ 1,
23799
+ 1,
23800
+ 1,
23801
+ 1
23802
+ ]);
23803
+ function isValidHex(id, length) {
23804
+ if (typeof id !== "string" || id.length !== length)
23805
+ return false;
23806
+ let r = 0;
23807
+ for (let i = 0;i < id.length; i += 4) {
23808
+ r += (isHex[id.charCodeAt(i)] | 0) + (isHex[id.charCodeAt(i + 1)] | 0) + (isHex[id.charCodeAt(i + 2)] | 0) + (isHex[id.charCodeAt(i + 3)] | 0);
23809
+ }
23810
+ return r === length;
23811
+ }
24651
23812
  function isValidTraceId(traceId) {
24652
- return VALID_TRACEID_REGEX.test(traceId) && traceId !== invalid_span_constants_1.INVALID_TRACEID;
23813
+ return isValidHex(traceId, 32) && traceId !== invalid_span_constants_1.INVALID_TRACEID;
24653
23814
  }
24654
23815
  exports.isValidTraceId = isValidTraceId;
24655
23816
  function isValidSpanId(spanId) {
24656
- return VALID_SPANID_REGEX.test(spanId) && spanId !== invalid_span_constants_1.INVALID_SPANID;
23817
+ return isValidHex(spanId, 16) && spanId !== invalid_span_constants_1.INVALID_SPANID;
24657
23818
  }
24658
23819
  exports.isValidSpanId = isValidSpanId;
24659
23820
  function isSpanContextValid(spanContext) {
@@ -24713,7 +23874,7 @@ var require_NoopTracer = __commonJS((exports) => {
24713
23874
  }
24714
23875
  exports.NoopTracer = NoopTracer;
24715
23876
  function isSpanContext(spanContext) {
24716
- return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
23877
+ return spanContext !== null && typeof spanContext === "object" && "spanId" in spanContext && typeof spanContext["spanId"] === "string" && "traceId" in spanContext && typeof spanContext["traceId"] === "string" && "traceFlags" in spanContext && typeof spanContext["traceFlags"] === "number";
24717
23878
  }
24718
23879
  });
24719
23880
 
@@ -24725,8 +23886,8 @@ var require_ProxyTracer = __commonJS((exports) => {
24725
23886
  var NOOP_TRACER = new NoopTracer_1.NoopTracer;
24726
23887
 
24727
23888
  class ProxyTracer {
24728
- constructor(_provider, name15, version2, options) {
24729
- this._provider = _provider;
23889
+ constructor(provider, name15, version2, options) {
23890
+ this._provider = provider;
24730
23891
  this.name = name15;
24731
23892
  this.version = version2;
24732
23893
  this.options = options;
@@ -24886,7 +24047,7 @@ var require_tracestate_impl = __commonJS((exports) => {
24886
24047
  return this._internalState.get(key);
24887
24048
  }
24888
24049
  serialize() {
24889
- return this._keys().reduce((agg, key) => {
24050
+ return Array.from(this._internalState.keys()).reduceRight((agg, key) => {
24890
24051
  agg.push(key + LIST_MEMBER_KEY_VALUE_SPLITTER + this.get(key));
24891
24052
  return agg;
24892
24053
  }, []).join(LIST_MEMBERS_SEPARATOR);
@@ -24894,7 +24055,7 @@ var require_tracestate_impl = __commonJS((exports) => {
24894
24055
  _parse(rawTraceState) {
24895
24056
  if (rawTraceState.length > MAX_TRACE_STATE_LEN)
24896
24057
  return;
24897
- this._internalState = rawTraceState.split(LIST_MEMBERS_SEPARATOR).reverse().reduce((agg, part) => {
24058
+ this._internalState = rawTraceState.split(LIST_MEMBERS_SEPARATOR).reduceRight((agg, part) => {
24898
24059
  const listMember = part.trim();
24899
24060
  const i = listMember.indexOf(LIST_MEMBER_KEY_VALUE_SPLITTER);
24900
24061
  if (i !== -1) {
@@ -25277,4 +24438,4 @@ var require_src = __commonJS((exports) => {
25277
24438
  };
25278
24439
  });
25279
24440
 
25280
- export { AISDKError, APICallError, EmptyResponseBodyError, getErrorMessage, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, JSONParseError, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError, isJSONArray, isJSONObject, init_dist, toJSONSchema, safeParseAsync2 as safeParseAsync, exports_external, init_v4, ZodFirstPartyTypeKind2 as ZodFirstPartyTypeKind, init_v3, EventSourceParserStream, init_stream, zod_default, init_zod, GatewayAuthenticationError, createGatewayProvider, gateway, init_dist4 as init_dist1, delay, DelayedPromise, convertBase64ToUint8Array, convertUint8ArrayToBase642 as convertUint8ArrayToBase64, DownloadError2 as DownloadError, DEFAULT_MAX_DOWNLOAD_SIZE2 as DEFAULT_MAX_DOWNLOAD_SIZE, readResponseWithSizeLimit, validateDownloadUrl, createIdGenerator2 as createIdGenerator, generateId2 as generateId, getErrorMessage2 as getErrorMessage1, isAbortError2 as isAbortError, getRuntimeEnvironmentUserAgent2 as getRuntimeEnvironmentUserAgent, normalizeHeaders2 as normalizeHeaders, withUserAgentSuffix2 as withUserAgentSuffix, isNonNullable, isUrlSupported, lazySchema2 as lazySchema, jsonSchema2 as jsonSchema, asSchema2 as asSchema, zodSchema2 as zodSchema, validateTypes2 as validateTypes, safeValidateTypes2 as safeValidateTypes, safeParseJSON2 as safeParseJSON, parseJsonEventStream2 as parseJsonEventStream, tool2 as tool, dynamicTool, resolve2 as resolve, executeTool, init_dist5 as init_dist2, require_src };
24441
+ export { AISDKError, APICallError, EmptyResponseBodyError, getErrorMessage, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, JSONParseError, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError, isJSONArray, isJSONObject, init_dist, safeParse, toJSONSchema, init_core2 as init_core, exports_iso, safeParseAsync2 as safeParseAsync, string2 as string, number2 as number, boolean2 as boolean, _null3 as _null, unknown, array, object, looseObject, union, discriminatedUnion, intersection, record, _enum2 as _enum, literal, optional, custom, preprocess, exports_external, init_v4, ZodFirstPartyTypeKind2 as ZodFirstPartyTypeKind, init_v3, EventSourceParserStream, init_stream, combineHeaders, createToolNameMapping, delay, DelayedPromise, extractResponseHeaders, convertBase64ToUint8Array, convertUint8ArrayToBase64, convertToBase64, convertToFormData, cancelResponseBody, DownloadError, fetchWithValidatedRedirects, DEFAULT_MAX_DOWNLOAD_SIZE, readResponseWithSizeLimit, downloadBlob, createIdGenerator, generateId, getErrorMessage2 as getErrorMessage1, isAbortError, getRuntimeEnvironmentUserAgent, normalizeHeaders, withUserAgentSuffix, getFromApi, isNonNullable, isSameOrigin, isUrlSupported, loadApiKey, loadOptionalSetting, loadSetting, lazySchema, jsonSchema, asSchema, zodSchema, validateTypes, safeValidateTypes, safeParseJSON, isParsableJson, parseJsonEventStream, parseProviderOptions, postJsonToApi, postFormDataToApi, tool, dynamicTool, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, resolve, createJsonErrorResponseHandler, createEventSourceResponseHandler, createJsonResponseHandler, stripFileExtension, withoutTrailingSlash, executeTool, init_dist3 as init_dist1, zod_default, init_zod, GatewayError, GatewayAuthenticationError, createGatewayProvider, gateway, init_dist4 as init_dist2, require_src };