@hasna/mementos 0.14.61 → 0.14.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -133,6 +133,7 @@ function translateSql(sql) {
133
133
  });
134
134
  translated = translated.replace(/lower\s*\(\s*hex\s*\(\s*randomblob\s*\(\s*\d+\s*\)\s*\)\s*\)/gi, "gen_random_uuid()::text");
135
135
  translated = translated.replace(/\bIFNULL\s*\(/gi, "COALESCE(");
136
+ translated = translated.replace(/\bINSTR\s*\(/gi, "STRPOS(");
136
137
  if (/INSERT\s+OR\s+IGNORE\s+INTO/i.test(translated)) {
137
138
  translated = translated.replace(/INSERT\s+OR\s+IGNORE\s+INTO/gi, "INSERT INTO");
138
139
  translated = translated.replace(/;?\s*$/, " ON CONFLICT DO NOTHING");
@@ -5967,7 +5968,7 @@ var init_zod = __esm(() => {
5967
5968
  init_external();
5968
5969
  });
5969
5970
 
5970
- // node_modules/@ai-sdk/provider/dist/index.mjs
5971
+ // node_modules/.pnpm/@ai-sdk+provider@3.0.13/node_modules/@ai-sdk/provider/dist/index.mjs
5971
5972
  function getErrorMessage(error) {
5972
5973
  if (error == null) {
5973
5974
  return "unknown error";
@@ -17632,7 +17633,7 @@ var init_v3 = __esm(() => {
17632
17633
  init_external();
17633
17634
  });
17634
17635
 
17635
- // node_modules/@ai-sdk/provider-utils/node_modules/eventsource-parser/dist/index.js
17636
+ // node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/index.js
17636
17637
  function noop(_arg) {}
17637
17638
  function createParser(config2) {
17638
17639
  if (typeof config2 == "function")
@@ -17792,7 +17793,7 @@ var init_dist2 = __esm(() => {
17792
17793
  };
17793
17794
  });
17794
17795
 
17795
- // node_modules/@ai-sdk/provider-utils/node_modules/eventsource-parser/dist/stream.js
17796
+ // node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/stream.js
17796
17797
  var EventSourceParserStream;
17797
17798
  var init_stream = __esm(() => {
17798
17799
  init_dist2();
@@ -17821,7 +17822,7 @@ var init_stream = __esm(() => {
17821
17822
  };
17822
17823
  });
17823
17824
 
17824
- // node_modules/@ai-sdk/provider-utils/dist/index.mjs
17825
+ // node_modules/.pnpm/@ai-sdk+provider-utils@4.0.35_zod@3.25.76/node_modules/@ai-sdk/provider-utils/dist/index.mjs
17825
17826
  function combineHeaders(...headers) {
17826
17827
  return headers.reduce((combinedHeaders, currentHeaders) => ({
17827
17828
  ...combinedHeaders,
@@ -17925,57 +17926,14 @@ function convertToFormData(input, options = {}) {
17925
17926
  }
17926
17927
  return formData;
17927
17928
  }
17928
- async function readResponseWithSizeLimit({
17929
- response,
17930
- url: url2,
17931
- maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE
17932
- }) {
17933
- const contentLength = response.headers.get("content-length");
17934
- if (contentLength != null) {
17935
- const length = parseInt(contentLength, 10);
17936
- if (!isNaN(length) && length > maxBytes) {
17937
- throw new DownloadError({
17938
- url: url2,
17939
- message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
17940
- });
17941
- }
17942
- }
17943
- const body = response.body;
17944
- if (body == null) {
17945
- return new Uint8Array(0);
17946
- }
17947
- const reader = body.getReader();
17948
- const chunks = [];
17949
- let totalBytes = 0;
17929
+ async function cancelResponseBody(response) {
17930
+ var _a22;
17950
17931
  try {
17951
- while (true) {
17952
- const { done, value } = await reader.read();
17953
- if (done) {
17954
- break;
17955
- }
17956
- totalBytes += value.length;
17957
- if (totalBytes > maxBytes) {
17958
- throw new DownloadError({
17959
- url: url2,
17960
- message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes.`
17961
- });
17962
- }
17963
- chunks.push(value);
17964
- }
17965
- } finally {
17966
- try {
17967
- await reader.cancel();
17968
- } finally {
17969
- reader.releaseLock();
17970
- }
17971
- }
17972
- const result = new Uint8Array(totalBytes);
17973
- let offset = 0;
17974
- for (const chunk of chunks) {
17975
- result.set(chunk, offset);
17976
- offset += chunk.length;
17977
- }
17978
- return result;
17932
+ await ((_a22 = response.body) == null ? undefined : _a22.cancel());
17933
+ } catch (e) {}
17934
+ }
17935
+ function isBrowserRuntime(globalThisAny = globalThis) {
17936
+ return globalThisAny.window != null;
17979
17937
  }
17980
17938
  function validateDownloadUrl(url2) {
17981
17939
  let parsed;
@@ -17996,7 +17954,7 @@ function validateDownloadUrl(url2) {
17996
17954
  message: `URL scheme must be http, https, or data, got ${parsed.protocol}`
17997
17955
  });
17998
17956
  }
17999
- const hostname3 = parsed.hostname;
17957
+ const hostname3 = parsed.hostname.toLowerCase().replace(/\.+$/, "");
18000
17958
  if (!hostname3) {
18001
17959
  throw new DownloadError({
18002
17960
  url: url2,
@@ -18040,62 +17998,198 @@ function isIPv4(hostname3) {
18040
17998
  }
18041
17999
  function isPrivateIPv4(ip) {
18042
18000
  const parts = ip.split(".").map(Number);
18043
- const [a, b] = parts;
18001
+ const [a, b, c] = parts;
18044
18002
  if (a === 0)
18045
18003
  return true;
18046
18004
  if (a === 10)
18047
18005
  return true;
18006
+ if (a === 100 && b >= 64 && b <= 127)
18007
+ return true;
18048
18008
  if (a === 127)
18049
18009
  return true;
18050
18010
  if (a === 169 && b === 254)
18051
18011
  return true;
18052
18012
  if (a === 172 && b >= 16 && b <= 31)
18053
18013
  return true;
18014
+ if (a === 192 && b === 0 && c === 0)
18015
+ return true;
18054
18016
  if (a === 192 && b === 168)
18055
18017
  return true;
18018
+ if (a === 198 && (b === 18 || b === 19))
18019
+ return true;
18020
+ if (a >= 240)
18021
+ return true;
18056
18022
  return false;
18057
18023
  }
18024
+ function parseIPv6(ip) {
18025
+ let address = ip.toLowerCase();
18026
+ const zoneIndex = address.indexOf("%");
18027
+ if (zoneIndex !== -1) {
18028
+ address = address.slice(0, zoneIndex);
18029
+ }
18030
+ const halves = address.split("::");
18031
+ if (halves.length > 2)
18032
+ return null;
18033
+ const toGroups = (segment) => {
18034
+ if (segment === "")
18035
+ return [];
18036
+ const groups = [];
18037
+ const parts = segment.split(":");
18038
+ for (let i = 0;i < parts.length; i++) {
18039
+ const part = parts[i];
18040
+ if (part.includes(".")) {
18041
+ if (i !== parts.length - 1 || !isIPv4(part))
18042
+ return null;
18043
+ const [a, b, c, d] = part.split(".").map(Number);
18044
+ groups.push(a << 8 | b, c << 8 | d);
18045
+ continue;
18046
+ }
18047
+ if (!/^[0-9a-f]{1,4}$/.test(part))
18048
+ return null;
18049
+ groups.push(parseInt(part, 16));
18050
+ }
18051
+ return groups;
18052
+ };
18053
+ const head = toGroups(halves[0]);
18054
+ if (head === null)
18055
+ return null;
18056
+ if (halves.length === 2) {
18057
+ const tail = toGroups(halves[1]);
18058
+ if (tail === null)
18059
+ return null;
18060
+ const fill = 8 - head.length - tail.length;
18061
+ if (fill < 0)
18062
+ return null;
18063
+ return [...head, ...new Array(fill).fill(0), ...tail];
18064
+ }
18065
+ return head.length === 8 ? head : null;
18066
+ }
18058
18067
  function isPrivateIPv6(ip) {
18059
- const normalized = ip.toLowerCase();
18060
- if (normalized === "::1")
18068
+ const groups = parseIPv6(ip);
18069
+ if (groups === null)
18061
18070
  return true;
18062
- if (normalized === "::")
18071
+ const topZero = (count) => groups.slice(0, count).every((group) => group === 0);
18072
+ if (topZero(7) && (groups[7] === 0 || groups[7] === 1))
18063
18073
  return true;
18064
- if (normalized.startsWith("::ffff:")) {
18065
- const mappedPart = normalized.slice(7);
18066
- if (isIPv4(mappedPart)) {
18067
- return isPrivateIPv4(mappedPart);
18074
+ if ((groups[0] & 65024) === 64512)
18075
+ return true;
18076
+ if ((groups[0] & 65472) === 65152)
18077
+ return true;
18078
+ if ((groups[0] & 65472) === 65216)
18079
+ return true;
18080
+ if ((groups[0] & 65280) === 65280)
18081
+ return true;
18082
+ 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;
18083
+ if (embedsIPv4) {
18084
+ const a = groups[6] >> 8 & 255;
18085
+ const b = groups[6] & 255;
18086
+ const c = groups[7] >> 8 & 255;
18087
+ const d = groups[7] & 255;
18088
+ return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
18089
+ }
18090
+ return false;
18091
+ }
18092
+ async function fetchWithValidatedRedirects({
18093
+ url: url2,
18094
+ headers,
18095
+ abortSignal,
18096
+ maxRedirects = MAX_DOWNLOAD_REDIRECTS
18097
+ }) {
18098
+ const baseInit = { signal: abortSignal };
18099
+ if (headers !== undefined) {
18100
+ baseInit.headers = headers;
18101
+ }
18102
+ let currentUrl = url2;
18103
+ for (let redirectCount = 0;redirectCount <= maxRedirects; redirectCount++) {
18104
+ validateDownloadUrl(currentUrl);
18105
+ const response = await fetch(currentUrl, {
18106
+ ...baseInit,
18107
+ redirect: "manual"
18108
+ });
18109
+ if (response.type === "opaqueredirect") {
18110
+ if (!isBrowserRuntime()) {
18111
+ throw new DownloadError({
18112
+ url: url2,
18113
+ message: `Redirect from ${currentUrl} could not be validated and was blocked`
18114
+ });
18115
+ }
18116
+ return await fetch(currentUrl, { ...baseInit, redirect: "follow" });
18117
+ }
18118
+ const location = response.headers.get("location");
18119
+ if (response.status >= 300 && response.status < 400 && location) {
18120
+ await cancelResponseBody(response);
18121
+ currentUrl = new URL(location, currentUrl).toString();
18122
+ continue;
18123
+ }
18124
+ return response;
18125
+ }
18126
+ throw new DownloadError({
18127
+ url: url2,
18128
+ message: `Too many redirects (max ${maxRedirects})`
18129
+ });
18130
+ }
18131
+ async function readResponseWithSizeLimit({
18132
+ response,
18133
+ url: url2,
18134
+ maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE
18135
+ }) {
18136
+ const contentLength = response.headers.get("content-length");
18137
+ if (contentLength != null) {
18138
+ const length = parseInt(contentLength, 10);
18139
+ if (!isNaN(length) && length > maxBytes) {
18140
+ await cancelResponseBody(response);
18141
+ throw new DownloadError({
18142
+ url: url2,
18143
+ message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
18144
+ });
18068
18145
  }
18069
- const hexParts = mappedPart.split(":");
18070
- if (hexParts.length === 2) {
18071
- const high = parseInt(hexParts[0], 16);
18072
- const low = parseInt(hexParts[1], 16);
18073
- if (!isNaN(high) && !isNaN(low)) {
18074
- const a = high >> 8 & 255;
18075
- const b = high & 255;
18076
- const c = low >> 8 & 255;
18077
- const d = low & 255;
18078
- return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
18146
+ }
18147
+ const body = response.body;
18148
+ if (body == null) {
18149
+ return new Uint8Array(0);
18150
+ }
18151
+ const reader = body.getReader();
18152
+ const chunks = [];
18153
+ let totalBytes = 0;
18154
+ try {
18155
+ while (true) {
18156
+ const { done, value } = await reader.read();
18157
+ if (done) {
18158
+ break;
18079
18159
  }
18160
+ totalBytes += value.length;
18161
+ if (totalBytes > maxBytes) {
18162
+ throw new DownloadError({
18163
+ url: url2,
18164
+ message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes.`
18165
+ });
18166
+ }
18167
+ chunks.push(value);
18168
+ }
18169
+ } finally {
18170
+ try {
18171
+ await reader.cancel();
18172
+ } finally {
18173
+ reader.releaseLock();
18080
18174
  }
18081
18175
  }
18082
- if (normalized.startsWith("fc") || normalized.startsWith("fd"))
18083
- return true;
18084
- if (normalized.startsWith("fe80"))
18085
- return true;
18086
- return false;
18176
+ const result = new Uint8Array(totalBytes);
18177
+ let offset = 0;
18178
+ for (const chunk of chunks) {
18179
+ result.set(chunk, offset);
18180
+ offset += chunk.length;
18181
+ }
18182
+ return result;
18087
18183
  }
18088
18184
  async function downloadBlob(url2, options) {
18089
18185
  var _a22, _b22;
18090
- validateDownloadUrl(url2);
18091
18186
  try {
18092
- const response = await fetch(url2, {
18093
- signal: options == null ? undefined : options.abortSignal
18187
+ const response = await fetchWithValidatedRedirects({
18188
+ url: url2,
18189
+ abortSignal: options == null ? undefined : options.abortSignal
18094
18190
  });
18095
- if (response.redirected) {
18096
- validateDownloadUrl(response.url);
18097
- }
18098
18191
  if (!response.ok) {
18192
+ await cancelResponseBody(response);
18099
18193
  throw new DownloadError({
18100
18194
  url: url2,
18101
18195
  statusCode: response.status,
@@ -19342,6 +19436,68 @@ async function resolve3(value) {
19342
19436
  }
19343
19437
  return Promise.resolve(value);
19344
19438
  }
19439
+ async function retryWithExponentialBackoffInternal(f, {
19440
+ maxRetries,
19441
+ delayInMs,
19442
+ backoffFactor,
19443
+ abortSignal,
19444
+ shouldRetry,
19445
+ getDelayInMs,
19446
+ createRetryError
19447
+ }, errors4 = []) {
19448
+ try {
19449
+ return await f();
19450
+ } catch (error40) {
19451
+ if (isAbortError(error40)) {
19452
+ throw error40;
19453
+ }
19454
+ if (maxRetries === 0) {
19455
+ throw error40;
19456
+ }
19457
+ const errorMessage = getErrorMessage2(error40);
19458
+ const newErrors = [...errors4, error40];
19459
+ const tryNumber = newErrors.length;
19460
+ if (tryNumber > maxRetries) {
19461
+ throw createRetryError({
19462
+ message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
19463
+ reason: "maxRetriesExceeded",
19464
+ errors: newErrors
19465
+ });
19466
+ }
19467
+ if (await shouldRetry(error40) && tryNumber <= maxRetries) {
19468
+ await delay(getDelayInMs({
19469
+ error: error40,
19470
+ exponentialBackoffDelay: delayInMs
19471
+ }), { abortSignal });
19472
+ return retryWithExponentialBackoffInternal(f, {
19473
+ maxRetries,
19474
+ delayInMs: backoffFactor * delayInMs,
19475
+ backoffFactor,
19476
+ abortSignal,
19477
+ shouldRetry,
19478
+ getDelayInMs,
19479
+ createRetryError
19480
+ }, newErrors);
19481
+ }
19482
+ if (tryNumber === 1) {
19483
+ throw error40;
19484
+ }
19485
+ throw createRetryError({
19486
+ message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
19487
+ reason: "errorNotRetryable",
19488
+ errors: newErrors
19489
+ });
19490
+ }
19491
+ }
19492
+ async function readResponseBodyAsText({
19493
+ response,
19494
+ url: url2
19495
+ }) {
19496
+ return textDecoder.decode(await readResponseWithSizeLimit({
19497
+ response,
19498
+ url: url2
19499
+ }));
19500
+ }
19345
19501
  function withoutTrailingSlash(url2) {
19346
19502
  return url2 == null ? undefined : url2.replace(/\/$/, "");
19347
19503
  }
@@ -19409,7 +19565,7 @@ var DelayedPromise = class {
19409
19565
  isPending() {
19410
19566
  return this.status.type === "pending";
19411
19567
  }
19412
- }, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
19568
+ }, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, MAX_DOWNLOAD_REDIRECTS = 10, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
19413
19569
  prefix,
19414
19570
  size = 16,
19415
19571
  alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
@@ -19433,7 +19589,7 @@ var DelayedPromise = class {
19433
19589
  });
19434
19590
  }
19435
19591
  return () => `${prefix}${separator}${generator()}`;
19436
- }, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.27", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
19592
+ }, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.35", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
19437
19593
  url: url2,
19438
19594
  headers = {},
19439
19595
  successfulResponseHandler,
@@ -19819,12 +19975,28 @@ var DelayedPromise = class {
19819
19975
  } catch (error40) {
19820
19976
  throw handleFetchError({ error: error40, url: url2, requestBodyValues: body.values });
19821
19977
  }
19822
- }, createJsonErrorResponseHandler = ({
19978
+ }, retryWithExponentialBackoff = ({
19979
+ maxRetries = 2,
19980
+ initialDelayInMs = 2000,
19981
+ backoffFactor = 2,
19982
+ abortSignal,
19983
+ shouldRetry,
19984
+ getDelayInMs = ({ exponentialBackoffDelay }) => exponentialBackoffDelay,
19985
+ createRetryError = ({ message }) => new Error(message)
19986
+ }) => async (f) => retryWithExponentialBackoffInternal(f, {
19987
+ maxRetries,
19988
+ delayInMs: initialDelayInMs,
19989
+ backoffFactor,
19990
+ abortSignal,
19991
+ shouldRetry,
19992
+ getDelayInMs,
19993
+ createRetryError
19994
+ }), textDecoder, createJsonErrorResponseHandler = ({
19823
19995
  errorSchema,
19824
19996
  errorToMessage,
19825
19997
  isRetryable
19826
19998
  }) => async ({ response, url: url2, requestBodyValues }) => {
19827
- const responseBody = await response.text();
19999
+ const responseBody = await readResponseBodyAsText({ response, url: url2 });
19828
20000
  const responseHeaders = extractResponseHeaders(response);
19829
20001
  if (responseBody.trim() === "") {
19830
20002
  return {
@@ -19885,7 +20057,7 @@ var DelayedPromise = class {
19885
20057
  })
19886
20058
  };
19887
20059
  }, createJsonResponseHandler = (responseSchema) => async ({ response, url: url2, requestBodyValues }) => {
19888
- const responseBody = await response.text();
20060
+ const responseBody = await readResponseBodyAsText({ response, url: url2 });
19889
20061
  const parsedResult = await safeParseJSON({
19890
20062
  text: responseBody,
19891
20063
  schema: responseSchema
@@ -20041,9 +20213,10 @@ var init_dist3 = __esm(() => {
20041
20213
  ZodNull: "null"
20042
20214
  };
20043
20215
  schemaSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
20216
+ textDecoder = new TextDecoder;
20044
20217
  });
20045
20218
 
20046
- // node_modules/@ai-sdk/anthropic/dist/index.mjs
20219
+ // node_modules/.pnpm/@ai-sdk+anthropic@3.0.92_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.mjs
20047
20220
  var exports_dist = {};
20048
20221
  __export(exports_dist, {
20049
20222
  forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep,
@@ -21248,7 +21421,10 @@ async function convertToAnthropicMessagesPrompt({
21248
21421
  }
21249
21422
  }
21250
21423
  }
21251
- messages.push({ role: "assistant", content: anthropicContent });
21424
+ messages.push({
21425
+ role: "assistant",
21426
+ content: moveToolUseBlocksToEnd(anthropicContent)
21427
+ });
21252
21428
  break;
21253
21429
  }
21254
21430
  default: {
@@ -21308,6 +21484,24 @@ function groupIntoBlocks(prompt) {
21308
21484
  }
21309
21485
  return blocks;
21310
21486
  }
21487
+ function moveToolUseBlocksToEnd(content) {
21488
+ const result = [];
21489
+ let segment = [];
21490
+ function flushSegment() {
21491
+ result.push(...segment.filter((part) => part.type !== "tool_use"), ...segment.filter((part) => part.type === "tool_use"));
21492
+ segment = [];
21493
+ }
21494
+ for (const part of content) {
21495
+ if (part.type === "thinking" || part.type === "redacted_thinking") {
21496
+ flushSegment();
21497
+ result.push(part);
21498
+ } else {
21499
+ segment.push(part);
21500
+ }
21501
+ }
21502
+ flushSegment();
21503
+ return result;
21504
+ }
21311
21505
  function mapAnthropicStopReason({
21312
21506
  finishReason,
21313
21507
  isJsonResponseFromTool
@@ -21485,7 +21679,7 @@ function createCitationSource(citation, citationDocuments, generateId3) {
21485
21679
  };
21486
21680
  }
21487
21681
  function getModelCapabilities(modelId) {
21488
- if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5")) {
21682
+ if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5") || modelId.includes("claude-sonnet-5")) {
21489
21683
  return {
21490
21684
  maxOutputTokens: 128000,
21491
21685
  supportsStructuredOutput: true,
@@ -21676,7 +21870,7 @@ function forwardAnthropicContainerIdFromLastStep({
21676
21870
  }
21677
21871
  return;
21678
21872
  }
21679
- var VERSION2 = "3.0.82", anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicStopDetailsSchema, anthropicMessagesResponseSchema, anthropicMessagesChunkSchema, anthropicReasoningMetadataSchema, anthropicFilePartProviderOptions, anthropicLanguageModelOptions, MAX_CACHE_BREAKPOINTS = 4, CacheControlValidator = class {
21873
+ var VERSION2 = "3.0.92", anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicStopDetailsSchema, anthropicMessagesResponseSchema, anthropicMessagesChunkSchema, anthropicReasoningMetadataSchema, anthropicFilePartProviderOptions, anthropicLanguageModelOptions, MAX_CACHE_BREAKPOINTS = 4, CacheControlValidator = class {
21680
21874
  constructor() {
21681
21875
  this.breakpointCount = 0;
21682
21876
  this.warnings = [];
@@ -22828,6 +23022,7 @@ var VERSION2 = "3.0.82", anthropicErrorDataSchema, anthropicFailedResponseHandle
22828
23022
  "bash_code_execution"
22829
23023
  ].includes(part.name)) {
22830
23024
  const providerToolName = part.name === "text_editor_code_execution" || part.name === "bash_code_execution" ? "code_execution" : part.name;
23025
+ const providerToolInputType = part.name === "text_editor_code_execution" || part.name === "bash_code_execution" ? part.name : part.name === "code_execution" ? "programmatic-tool-call" : undefined;
22831
23026
  const customToolName = toolNameMapping.toCustomToolName(providerToolName);
22832
23027
  const finalInput = part.input != null && typeof part.input === "object" && Object.keys(part.input).length > 0 ? JSON.stringify(part.input) : "";
22833
23028
  contentBlocks[value.index] = {
@@ -22837,8 +23032,9 @@ var VERSION2 = "3.0.82", anthropicErrorDataSchema, anthropicFailedResponseHandle
22837
23032
  input: finalInput,
22838
23033
  providerExecuted: true,
22839
23034
  ...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
22840
- firstDelta: true,
22841
- providerToolName
23035
+ firstDelta: finalInput.length === 0,
23036
+ providerToolName,
23037
+ providerToolInputType
22842
23038
  };
22843
23039
  controller.enqueue({
22844
23040
  type: "tool-input-start",
@@ -23256,8 +23452,8 @@ var VERSION2 = "3.0.82", anthropicErrorDataSchema, anthropicFailedResponseHandle
23256
23452
  if ((contentBlock == null ? undefined : contentBlock.type) !== "tool-call") {
23257
23453
  return;
23258
23454
  }
23259
- if (contentBlock.firstDelta && contentBlock.providerToolName === "code_execution") {
23260
- delta = `{"type": "programmatic-tool-call",${delta.substring(1)}`;
23455
+ if (contentBlock.firstDelta && contentBlock.providerToolInputType != null) {
23456
+ delta = `{"type": "${contentBlock.providerToolInputType}",${delta.substring(1)}`;
23261
23457
  }
23262
23458
  controller.enqueue({
23263
23459
  type: "tool-input-delta",
@@ -25025,7 +25221,7 @@ var init_dist4 = __esm(() => {
25025
25221
  anthropic = createAnthropic();
25026
25222
  });
25027
25223
 
25028
- // node_modules/@ai-sdk/openai/dist/index.mjs
25224
+ // node_modules/.pnpm/@ai-sdk+openai@3.0.80_zod@3.25.76/node_modules/@ai-sdk/openai/dist/index.mjs
25029
25225
  var exports_dist2 = {};
25030
25226
  __export(exports_dist2, {
25031
25227
  openai: () => openai,
@@ -25571,7 +25767,7 @@ async function convertToOpenAIResponsesInput({
25571
25767
  hasApplyPatchTool = false,
25572
25768
  customProviderToolNames
25573
25769
  }) {
25574
- var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
25770
+ var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
25575
25771
  let input = [];
25576
25772
  const warnings = [];
25577
25773
  const processedApprovalIds = /* @__PURE__ */ new Set;
@@ -25704,10 +25900,11 @@ async function convertToOpenAIResponsesInput({
25704
25900
  }
25705
25901
  break;
25706
25902
  }
25707
- if (store && id != null) {
25708
- if (hasPreviousResponseId) {
25709
- break;
25710
- }
25903
+ if (hasPreviousResponseId && store && id != null) {
25904
+ break;
25905
+ }
25906
+ const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
25907
+ if (store && id != null && isProviderDefinedToolCall) {
25711
25908
  input.push({ type: "item_reference", id });
25712
25909
  break;
25713
25910
  }
@@ -25778,7 +25975,6 @@ async function convertToOpenAIResponsesInput({
25778
25975
  call_id: part.toolCallId,
25779
25976
  name: resolvedToolName,
25780
25977
  arguments: serializeToolCallArguments2(part.input),
25781
- id,
25782
25978
  ...namespace != null && { namespace }
25783
25979
  });
25784
25980
  break;
@@ -25792,7 +25988,7 @@ async function convertToOpenAIResponsesInput({
25792
25988
  }
25793
25989
  const resolvedResultToolName = toolNameMapping.toProviderToolName(part.toolName);
25794
25990
  if (resolvedResultToolName === "tool_search") {
25795
- const itemId = (_o = (_n = (_m = part.providerOptions) == null ? undefined : _m[providerOptionsName]) == null ? undefined : _n.itemId) != null ? _o : part.toolCallId;
25991
+ const itemId = (_p = (_o = (_n = part.providerOptions) == null ? undefined : _n[providerOptionsName]) == null ? undefined : _o.itemId) != null ? _p : part.toolCallId;
25796
25992
  if (store) {
25797
25993
  input.push({ type: "item_reference", id: itemId });
25798
25994
  } else if (part.output.type === "json") {
@@ -25833,7 +26029,7 @@ async function convertToOpenAIResponsesInput({
25833
26029
  break;
25834
26030
  }
25835
26031
  if (store) {
25836
- const itemId = (_r = (_q = (_p = part.providerOptions) == null ? undefined : _p[providerOptionsName]) == null ? undefined : _q.itemId) != null ? _r : part.toolCallId;
26032
+ const itemId = (_s = (_r = (_q = part.providerOptions) == null ? undefined : _q[providerOptionsName]) == null ? undefined : _r.itemId) != null ? _s : part.toolCallId;
25837
26033
  input.push({ type: "item_reference", id: itemId });
25838
26034
  } else {
25839
26035
  warnings.push({
@@ -25943,7 +26139,7 @@ async function convertToOpenAIResponsesInput({
25943
26139
  }
25944
26140
  const output = part.output;
25945
26141
  if (output.type === "execution-denied") {
25946
- const approvalId = (_t = (_s = output.providerOptions) == null ? undefined : _s.openai) == null ? undefined : _t.approvalId;
26142
+ const approvalId = (_u = (_t = output.providerOptions) == null ? undefined : _t.openai) == null ? undefined : _u.approvalId;
25947
26143
  if (approvalId) {
25948
26144
  continue;
25949
26145
  }
@@ -26015,7 +26211,7 @@ async function convertToOpenAIResponsesInput({
26015
26211
  outputValue = output.value;
26016
26212
  break;
26017
26213
  case "execution-denied":
26018
- outputValue = (_u = output.reason) != null ? _u : "Tool execution denied.";
26214
+ outputValue = (_v = output.reason) != null ? _v : "Tool execution denied.";
26019
26215
  break;
26020
26216
  case "json":
26021
26217
  case "error-json":
@@ -26076,7 +26272,7 @@ async function convertToOpenAIResponsesInput({
26076
26272
  contentValue = output.value;
26077
26273
  break;
26078
26274
  case "execution-denied":
26079
- contentValue = (_v = output.reason) != null ? _v : "Tool execution denied.";
26275
+ contentValue = (_w = output.reason) != null ? _w : "Tool execution denied.";
26080
26276
  break;
26081
26277
  case "json":
26082
26278
  case "error-json":
@@ -26501,6 +26697,31 @@ function extractApprovalRequestIdToToolCallIdMapping(prompt) {
26501
26697
  function isTextDeltaChunk(chunk) {
26502
26698
  return chunk.type === "response.output_text.delta";
26503
26699
  }
26700
+ function isOpenAIChatCompletionChunk(value) {
26701
+ const chunk = asRecord(value);
26702
+ return chunk != null && Array.isArray(chunk.choices) && typeof chunk.type !== "string";
26703
+ }
26704
+ function createOpenAIResponsesChatCompletionsMismatchError({
26705
+ value,
26706
+ cause,
26707
+ url: url2,
26708
+ requestBodyValues,
26709
+ responseHeaders
26710
+ }) {
26711
+ return new APICallError({
26712
+ message: "Received a Chat Completions stream while using the OpenAI Responses API. The default OpenAI provider model uses the Responses API. If your custom baseURL targets a Chat Completions-compatible endpoint, use openai.chat('model-id') or createOpenAI(...).chat('model-id') instead. You can also use @ai-sdk/openai-compatible for OpenAI-compatible providers.",
26713
+ url: url2,
26714
+ requestBodyValues,
26715
+ responseHeaders,
26716
+ responseBody: JSON.stringify(value),
26717
+ cause,
26718
+ data: value,
26719
+ isRetryable: false
26720
+ });
26721
+ }
26722
+ function asRecord(value) {
26723
+ return typeof value === "object" && value != null ? value : undefined;
26724
+ }
26504
26725
  function isResponseOutputItemDoneChunk(chunk) {
26505
26726
  return chunk.type === "response.output_item.done";
26506
26727
  }
@@ -28306,11 +28527,12 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
28306
28527
  providerOptionsName,
28307
28528
  isShellProviderExecuted
28308
28529
  } = await this.getArgs(options);
28530
+ const url2 = this.config.url({
28531
+ path: "/responses",
28532
+ modelId: this.modelId
28533
+ });
28309
28534
  const { responseHeaders, value: response } = await postJsonToApi({
28310
- url: this.config.url({
28311
- path: "/responses",
28312
- modelId: this.modelId
28313
- }),
28535
+ url: url2,
28314
28536
  headers: combineHeaders(this.config.headers(), options.headers),
28315
28537
  body: {
28316
28538
  ...body,
@@ -28349,8 +28571,15 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
28349
28571
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
28350
28572
  }
28351
28573
  if (!chunk.success) {
28574
+ const error40 = isOpenAIChatCompletionChunk(chunk.rawValue) ? createOpenAIResponsesChatCompletionsMismatchError({
28575
+ value: chunk.rawValue,
28576
+ cause: chunk.error,
28577
+ url: url2,
28578
+ requestBodyValues: body,
28579
+ responseHeaders
28580
+ }) : chunk.error;
28352
28581
  finishReason = { unified: "error", raw: undefined };
28353
- controller.enqueue({ type: "error", error: chunk.error });
28582
+ controller.enqueue({ type: "error", error: error40 });
28354
28583
  return;
28355
28584
  }
28356
28585
  const value = chunk.value;
@@ -29338,7 +29567,7 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
29338
29567
  }
29339
29568
  };
29340
29569
  }
29341
- }, VERSION3 = "3.0.69", openai;
29570
+ }, VERSION3 = "3.0.80", openai;
29342
29571
  var init_dist5 = __esm(() => {
29343
29572
  init_dist3();
29344
29573
  init_dist();
@@ -30055,9 +30284,16 @@ var init_dist5 = __esm(() => {
30055
30284
  incomplete_details: exports_external2.object({ reason: exports_external2.string() }).nullish(),
30056
30285
  usage: exports_external2.object({
30057
30286
  input_tokens: exports_external2.number(),
30058
- input_tokens_details: exports_external2.object({ cached_tokens: exports_external2.number().nullish() }).nullish(),
30287
+ input_tokens_details: exports_external2.object({
30288
+ cached_tokens: exports_external2.number().nullish(),
30289
+ orchestration_input_tokens: exports_external2.number().nullish(),
30290
+ orchestration_input_cached_tokens: exports_external2.number().nullish()
30291
+ }).nullish(),
30059
30292
  output_tokens: exports_external2.number(),
30060
- output_tokens_details: exports_external2.object({ reasoning_tokens: exports_external2.number().nullish() }).nullish()
30293
+ output_tokens_details: exports_external2.object({
30294
+ reasoning_tokens: exports_external2.number().nullish(),
30295
+ orchestration_output_tokens: exports_external2.number().nullish()
30296
+ }).nullish()
30061
30297
  }),
30062
30298
  service_tier: exports_external2.string().nullish()
30063
30299
  })
@@ -30072,9 +30308,16 @@ var init_dist5 = __esm(() => {
30072
30308
  incomplete_details: exports_external2.object({ reason: exports_external2.string() }).nullish(),
30073
30309
  usage: exports_external2.object({
30074
30310
  input_tokens: exports_external2.number(),
30075
- input_tokens_details: exports_external2.object({ cached_tokens: exports_external2.number().nullish() }).nullish(),
30311
+ input_tokens_details: exports_external2.object({
30312
+ cached_tokens: exports_external2.number().nullish(),
30313
+ orchestration_input_tokens: exports_external2.number().nullish(),
30314
+ orchestration_input_cached_tokens: exports_external2.number().nullish()
30315
+ }).nullish(),
30076
30316
  output_tokens: exports_external2.number(),
30077
- output_tokens_details: exports_external2.object({ reasoning_tokens: exports_external2.number().nullish() }).nullish()
30317
+ output_tokens_details: exports_external2.object({
30318
+ reasoning_tokens: exports_external2.number().nullish(),
30319
+ orchestration_output_tokens: exports_external2.number().nullish()
30320
+ }).nullish()
30078
30321
  }).nullish(),
30079
30322
  service_tier: exports_external2.string().nullish()
30080
30323
  })
@@ -30811,9 +31054,16 @@ var init_dist5 = __esm(() => {
30811
31054
  incomplete_details: exports_external2.object({ reason: exports_external2.string() }).nullish(),
30812
31055
  usage: exports_external2.object({
30813
31056
  input_tokens: exports_external2.number(),
30814
- input_tokens_details: exports_external2.object({ cached_tokens: exports_external2.number().nullish() }).nullish(),
31057
+ input_tokens_details: exports_external2.object({
31058
+ cached_tokens: exports_external2.number().nullish(),
31059
+ orchestration_input_tokens: exports_external2.number().nullish(),
31060
+ orchestration_input_cached_tokens: exports_external2.number().nullish()
31061
+ }).nullish(),
30815
31062
  output_tokens: exports_external2.number(),
30816
- output_tokens_details: exports_external2.object({ reasoning_tokens: exports_external2.number().nullish() }).nullish()
31063
+ output_tokens_details: exports_external2.object({
31064
+ reasoning_tokens: exports_external2.number().nullish(),
31065
+ orchestration_output_tokens: exports_external2.number().nullish()
31066
+ }).nullish()
30817
31067
  }).optional()
30818
31068
  })));
30819
31069
  openaiResponsesReasoningModelIds = [
@@ -30886,6 +31136,7 @@ var init_dist5 = __esm(() => {
30886
31136
  include: exports_external2.array(exports_external2.enum([
30887
31137
  "reasoning.encrypted_content",
30888
31138
  "file_search_call.results",
31139
+ "web_search_call.results",
30889
31140
  "message.output_text.logprobs"
30890
31141
  ])).nullish(),
30891
31142
  instructions: exports_external2.string().nullish(),
@@ -31008,7 +31259,7 @@ var init_dist5 = __esm(() => {
31008
31259
  openai = createOpenAI();
31009
31260
  });
31010
31261
 
31011
- // node_modules/@ai-sdk/openai-compatible/dist/index.mjs
31262
+ // node_modules/.pnpm/@ai-sdk+openai-compatible@2.0.56_zod@3.25.76/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
31012
31263
  var exports_dist3 = {};
31013
31264
  __export(exports_dist3, {
31014
31265
  createOpenAICompatible: () => createOpenAICompatible,
@@ -32413,7 +32664,7 @@ var openaiCompatibleErrorDataSchema, defaultOpenAICompatibleErrorStructure, open
32413
32664
  }
32414
32665
  };
32415
32666
  }
32416
- }, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.48";
32667
+ }, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.56";
32417
32668
  var init_dist6 = __esm(() => {
32418
32669
  init_dist();
32419
32670
  init_dist3();
@@ -32555,7 +32806,7 @@ var init_dist6 = __esm(() => {
32555
32806
  });
32556
32807
  });
32557
32808
 
32558
- // node_modules/@vercel/oidc/dist/get-context.js
32809
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/get-context.js
32559
32810
  var require_get_context = __commonJS((exports, module) => {
32560
32811
  var __defProp2 = Object.defineProperty;
32561
32812
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -32587,7 +32838,7 @@ var require_get_context = __commonJS((exports, module) => {
32587
32838
  }
32588
32839
  });
32589
32840
 
32590
- // node_modules/@vercel/oidc/dist/token-error.js
32841
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token-error.js
32591
32842
  var require_token_error = __commonJS((exports, module) => {
32592
32843
  var __defProp2 = Object.defineProperty;
32593
32844
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -32627,7 +32878,7 @@ var require_token_error = __commonJS((exports, module) => {
32627
32878
  }
32628
32879
  });
32629
32880
 
32630
- // node_modules/@vercel/oidc/dist/token-io.js
32881
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token-io.js
32631
32882
  var require_token_io = __commonJS((exports, module) => {
32632
32883
  var __create2 = Object.create;
32633
32884
  var __defProp2 = Object.defineProperty;
@@ -32694,7 +32945,7 @@ var require_token_io = __commonJS((exports, module) => {
32694
32945
  }
32695
32946
  });
32696
32947
 
32697
- // node_modules/@vercel/oidc/dist/auth-config.js
32948
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/auth-config.js
32698
32949
  var require_auth_config = __commonJS((exports, module) => {
32699
32950
  var __create2 = Object.create;
32700
32951
  var __defProp2 = Object.defineProperty;
@@ -32767,7 +33018,7 @@ var require_auth_config = __commonJS((exports, module) => {
32767
33018
  }
32768
33019
  });
32769
33020
 
32770
- // node_modules/@vercel/oidc/dist/oauth.js
33021
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/oauth.js
32771
33022
  var require_oauth = __commonJS((exports, module) => {
32772
33023
  var __defProp2 = Object.defineProperty;
32773
33024
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -32853,7 +33104,7 @@ var require_oauth = __commonJS((exports, module) => {
32853
33104
  }
32854
33105
  });
32855
33106
 
32856
- // node_modules/@vercel/oidc/dist/auth-errors.js
33107
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/auth-errors.js
32857
33108
  var require_auth_errors = __commonJS((exports, module) => {
32858
33109
  var __defProp2 = Object.defineProperty;
32859
33110
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -32894,7 +33145,7 @@ var require_auth_errors = __commonJS((exports, module) => {
32894
33145
  }
32895
33146
  });
32896
33147
 
32897
- // node_modules/@vercel/oidc/dist/token-util.js
33148
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token-util.js
32898
33149
  var require_token_util = __commonJS((exports, module) => {
32899
33150
  var __create2 = Object.create;
32900
33151
  var __defProp2 = Object.defineProperty;
@@ -33059,7 +33310,7 @@ var require_token_util = __commonJS((exports, module) => {
33059
33310
  }
33060
33311
  });
33061
33312
 
33062
- // node_modules/@vercel/oidc/dist/token.js
33313
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token.js
33063
33314
  var require_token = __commonJS((exports, module) => {
33064
33315
  var __defProp2 = Object.defineProperty;
33065
33316
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -33116,7 +33367,7 @@ var require_token = __commonJS((exports, module) => {
33116
33367
  }
33117
33368
  });
33118
33369
 
33119
- // node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js
33370
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js
33120
33371
  var require_get_vercel_oidc_token = __commonJS((exports, module) => {
33121
33372
  var __defProp2 = Object.defineProperty;
33122
33373
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -33182,7 +33433,7 @@ ${error40.message}`;
33182
33433
  }
33183
33434
  });
33184
33435
 
33185
- // node_modules/@vercel/oidc/dist/index.js
33436
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/index.js
33186
33437
  var require_dist = __commonJS((exports, module) => {
33187
33438
  var __defProp2 = Object.defineProperty;
33188
33439
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -33217,7 +33468,7 @@ var require_dist = __commonJS((exports, module) => {
33217
33468
  var import_token_util = require_token_util();
33218
33469
  });
33219
33470
 
33220
- // node_modules/@ai-sdk/gateway/dist/index.mjs
33471
+ // node_modules/.pnpm/@ai-sdk+gateway@3.0.143_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.mjs
33221
33472
  async function createGatewayErrorFromResponse({
33222
33473
  response,
33223
33474
  statusCode,
@@ -33225,7 +33476,7 @@ async function createGatewayErrorFromResponse({
33225
33476
  cause,
33226
33477
  authMethod
33227
33478
  }) {
33228
- var _a102;
33479
+ var _a112;
33229
33480
  const parseResult = await safeValidateTypes({
33230
33481
  value: response,
33231
33482
  schema: gatewayErrorResponseSchema
@@ -33244,7 +33495,7 @@ async function createGatewayErrorFromResponse({
33244
33495
  const validatedResponse = parseResult.value;
33245
33496
  const errorType = validatedResponse.error.type;
33246
33497
  const message = validatedResponse.error.message;
33247
- const generationId = (_a102 = validatedResponse.generationId) != null ? _a102 : undefined;
33498
+ const generationId = (_a112 = validatedResponse.generationId) != null ? _a112 : undefined;
33248
33499
  switch (errorType) {
33249
33500
  case "authentication_error":
33250
33501
  return GatewayAuthenticationError.createContextualError({
@@ -33295,6 +33546,13 @@ async function createGatewayErrorFromResponse({
33295
33546
  cause,
33296
33547
  generationId
33297
33548
  });
33549
+ case "forbidden":
33550
+ return new GatewayForbiddenError({
33551
+ message,
33552
+ statusCode,
33553
+ cause,
33554
+ generationId
33555
+ });
33298
33556
  default:
33299
33557
  return new GatewayInternalServerError({
33300
33558
  message,
@@ -33333,7 +33591,7 @@ function isTimeoutError(error40) {
33333
33591
  return false;
33334
33592
  }
33335
33593
  async function asGatewayError(error40, authMethod) {
33336
- var _a102;
33594
+ var _a112;
33337
33595
  if (GatewayError.isInstance(error40)) {
33338
33596
  return error40;
33339
33597
  }
@@ -33352,7 +33610,7 @@ async function asGatewayError(error40, authMethod) {
33352
33610
  }
33353
33611
  return await createGatewayErrorFromResponse({
33354
33612
  response: extractApiCallResponse(error40),
33355
- statusCode: (_a102 = error40.statusCode) != null ? _a102 : 500,
33613
+ statusCode: (_a112 = error40.statusCode) != null ? _a112 : 500,
33356
33614
  defaultMessage: "Gateway request failed",
33357
33615
  cause: error40,
33358
33616
  authMethod
@@ -33392,16 +33650,16 @@ function maybeEncodeVideoFile(file2) {
33392
33650
  return file2;
33393
33651
  }
33394
33652
  async function getVercelRequestId() {
33395
- var _a102;
33396
- return (_a102 = import_oidc.getContext().headers) == null ? undefined : _a102["x-vercel-id"];
33653
+ var _a112;
33654
+ return (_a112 = import_oidc.getContext().headers) == null ? undefined : _a112["x-vercel-id"];
33397
33655
  }
33398
33656
  function createGatewayProvider(options = {}) {
33399
- var _a102, _b102;
33657
+ var _a112, _b112;
33400
33658
  let pendingMetadata = null;
33401
33659
  let metadataCache = null;
33402
- const cacheRefreshMillis = (_a102 = options.metadataCacheRefreshMillis) != null ? _a102 : 1000 * 60 * 5;
33660
+ const cacheRefreshMillis = (_a112 = options.metadataCacheRefreshMillis) != null ? _a112 : 1000 * 60 * 5;
33403
33661
  let lastFetchTime = 0;
33404
- const baseURL = (_b102 = withoutTrailingSlash(options.baseURL)) != null ? _b102 : "https://ai-gateway.vercel.sh/v3/ai";
33662
+ const baseURL = (_b112 = withoutTrailingSlash(options.baseURL)) != null ? _b112 : "https://ai-gateway.vercel.sh/v3/ai";
33405
33663
  const getHeaders = async () => {
33406
33664
  try {
33407
33665
  const auth = await getGatewayAuthToken(options);
@@ -33458,8 +33716,8 @@ function createGatewayProvider(options = {}) {
33458
33716
  });
33459
33717
  };
33460
33718
  const getAvailableModels = async () => {
33461
- var _a112, _b112, _c;
33462
- const now2 = (_c = (_b112 = (_a112 = options._internal) == null ? undefined : _a112.currentDate) == null ? undefined : _b112.call(_a112).getTime()) != null ? _c : Date.now();
33719
+ var _a122, _b122, _c;
33720
+ const now2 = (_c = (_b122 = (_a122 = options._internal) == null ? undefined : _a122.currentDate) == null ? undefined : _b122.call(_a122).getTime()) != null ? _c : Date.now();
33463
33721
  if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
33464
33722
  lastFetchTime = now2;
33465
33723
  pendingMetadata = new GatewayFetchMetadata({
@@ -33554,6 +33812,28 @@ function createGatewayProvider(options = {}) {
33554
33812
  };
33555
33813
  provider.rerankingModel = createRerankingModel;
33556
33814
  provider.reranking = createRerankingModel;
33815
+ const createSpeechModel = (modelId) => {
33816
+ return new GatewaySpeechModel(modelId, {
33817
+ provider: "gateway",
33818
+ baseURL,
33819
+ headers: getHeaders,
33820
+ fetch: options.fetch,
33821
+ o11yHeaders: createO11yHeaders()
33822
+ });
33823
+ };
33824
+ provider.speechModel = createSpeechModel;
33825
+ provider.speech = createSpeechModel;
33826
+ const createTranscriptionModel = (modelId) => {
33827
+ return new GatewayTranscriptionModel(modelId, {
33828
+ provider: "gateway",
33829
+ baseURL,
33830
+ headers: getHeaders,
33831
+ fetch: options.fetch,
33832
+ o11yHeaders: createO11yHeaders()
33833
+ });
33834
+ };
33835
+ provider.transcriptionModel = createTranscriptionModel;
33836
+ provider.transcription = createTranscriptionModel;
33557
33837
  provider.chat = provider.languageModel;
33558
33838
  provider.embedding = provider.embeddingModel;
33559
33839
  provider.image = provider.imageModel;
@@ -33578,7 +33858,7 @@ async function getGatewayAuthToken(options) {
33578
33858
  authMethod: "oidc"
33579
33859
  };
33580
33860
  }
33581
- var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _a17, _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 = "GatewayResponseError", marker82, symbol82, _a82, _b82, GatewayResponseError, gatewayErrorResponseSchema, name82 = "GatewayTimeoutError", marker92, symbol92, _a92, _b92, GatewayTimeoutError, GATEWAY_AUTH_METHOD_HEADER = "ai-gateway-auth-method", gatewayAuthMethodSchema, KNOWN_MODEL_TYPES, GatewayFetchMetadata = class {
33861
+ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _a17, _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 {
33582
33862
  constructor(config2) {
33583
33863
  this.config = config2;
33584
33864
  }
@@ -33824,7 +34104,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
33824
34104
  abortSignal,
33825
34105
  providerOptions
33826
34106
  }) {
33827
- var _a102;
34107
+ var _a112, _b112;
33828
34108
  const resolvedHeaders = await resolve3(this.config.headers());
33829
34109
  try {
33830
34110
  const {
@@ -33848,10 +34128,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
33848
34128
  });
33849
34129
  return {
33850
34130
  embeddings: responseBody.embeddings,
33851
- usage: (_a102 = responseBody.usage) != null ? _a102 : undefined,
34131
+ usage: (_a112 = responseBody.usage) != null ? _a112 : undefined,
33852
34132
  providerMetadata: responseBody.providerMetadata,
33853
34133
  response: { headers: responseHeaders, body: rawValue },
33854
- warnings: []
34134
+ warnings: (_b112 = responseBody.warnings) != null ? _b112 : []
33855
34135
  };
33856
34136
  } catch (error40) {
33857
34137
  throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders));
@@ -33866,7 +34146,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
33866
34146
  "ai-model-id": this.modelId
33867
34147
  };
33868
34148
  }
33869
- }, gatewayEmbeddingResponseSchema, GatewayImageModel = class {
34149
+ }, gatewayEmbeddingWarningSchema, gatewayEmbeddingResponseSchema, GatewayImageModel = class {
33870
34150
  constructor(modelId, config2) {
33871
34151
  this.modelId = modelId;
33872
34152
  this.config = config2;
@@ -33888,7 +34168,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
33888
34168
  headers,
33889
34169
  abortSignal
33890
34170
  }) {
33891
- var _a102, _b102, _c, _d;
34171
+ var _a112, _b112, _c, _d;
33892
34172
  const resolvedHeaders = await resolve3(this.config.headers());
33893
34173
  try {
33894
34174
  const {
@@ -33920,7 +34200,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
33920
34200
  });
33921
34201
  return {
33922
34202
  images: responseBody.images,
33923
- warnings: (_a102 = responseBody.warnings) != null ? _a102 : [],
34203
+ warnings: (_a112 = responseBody.warnings) != null ? _a112 : [],
33924
34204
  providerMetadata: responseBody.providerMetadata,
33925
34205
  response: {
33926
34206
  timestamp: /* @__PURE__ */ new Date,
@@ -33929,7 +34209,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
33929
34209
  },
33930
34210
  ...responseBody.usage != null && {
33931
34211
  usage: {
33932
- inputTokens: (_b102 = responseBody.usage.inputTokens) != null ? _b102 : undefined,
34212
+ inputTokens: (_b112 = responseBody.usage.inputTokens) != null ? _b112 : undefined,
33933
34213
  outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : undefined,
33934
34214
  totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : undefined
33935
34215
  }
@@ -33966,12 +34246,15 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
33966
34246
  duration: duration3,
33967
34247
  fps,
33968
34248
  seed,
34249
+ generateAudio,
33969
34250
  image,
34251
+ frameImages,
34252
+ inputReferences,
33970
34253
  providerOptions,
33971
34254
  headers,
33972
34255
  abortSignal
33973
34256
  }) {
33974
- var _a102;
34257
+ var _a112;
33975
34258
  const resolvedHeaders = await resolve3(this.config.headers());
33976
34259
  try {
33977
34260
  const { responseHeaders, value: responseBody } = await postJsonToApi({
@@ -33985,8 +34268,18 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
33985
34268
  ...duration3 && { duration: duration3 },
33986
34269
  ...fps && { fps },
33987
34270
  ...seed && { seed },
34271
+ ...generateAudio !== undefined && { generateAudio },
33988
34272
  ...providerOptions && { providerOptions },
33989
- ...image && { image: maybeEncodeVideoFile(image) }
34273
+ ...image && { image: maybeEncodeVideoFile(image) },
34274
+ ...frameImages && {
34275
+ frameImages: frameImages.map((frame) => ({
34276
+ ...frame,
34277
+ image: maybeEncodeVideoFile(frame.image)
34278
+ }))
34279
+ },
34280
+ ...inputReferences && {
34281
+ inputReferences: inputReferences.map((reference) => maybeEncodeVideoFile(reference))
34282
+ }
33990
34283
  },
33991
34284
  successfulResponseHandler: async ({
33992
34285
  response,
@@ -34061,7 +34354,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
34061
34354
  });
34062
34355
  return {
34063
34356
  videos: responseBody.videos,
34064
- warnings: (_a102 = responseBody.warnings) != null ? _a102 : [],
34357
+ warnings: (_a112 = responseBody.warnings) != null ? _a112 : [],
34065
34358
  providerMetadata: responseBody.providerMetadata,
34066
34359
  response: {
34067
34360
  timestamp: /* @__PURE__ */ new Date,
@@ -34099,6 +34392,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
34099
34392
  abortSignal,
34100
34393
  providerOptions
34101
34394
  }) {
34395
+ var _a112;
34102
34396
  const resolvedHeaders = await resolve3(this.config.headers());
34103
34397
  try {
34104
34398
  const {
@@ -34126,7 +34420,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
34126
34420
  ranking: responseBody.ranking,
34127
34421
  providerMetadata: responseBody.providerMetadata,
34128
34422
  response: { headers: responseHeaders, body: rawValue },
34129
- warnings: []
34423
+ warnings: (_a112 = responseBody.warnings) != null ? _a112 : []
34130
34424
  };
34131
34425
  } catch (error40) {
34132
34426
  throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders));
@@ -34141,7 +34435,144 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
34141
34435
  "ai-model-id": this.modelId
34142
34436
  };
34143
34437
  }
34144
- }, gatewayRerankingResponseSchema, parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION5 = "3.0.127", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
34438
+ }, gatewayRerankingWarningSchema, gatewayRerankingResponseSchema, GatewaySpeechModel = class {
34439
+ constructor(modelId, config2) {
34440
+ this.modelId = modelId;
34441
+ this.config = config2;
34442
+ this.specificationVersion = "v3";
34443
+ }
34444
+ get provider() {
34445
+ return this.config.provider;
34446
+ }
34447
+ async doGenerate({
34448
+ text,
34449
+ voice,
34450
+ outputFormat,
34451
+ instructions,
34452
+ speed,
34453
+ language,
34454
+ providerOptions,
34455
+ headers,
34456
+ abortSignal
34457
+ }) {
34458
+ var _a112;
34459
+ const resolvedHeaders = await resolve3(this.config.headers());
34460
+ try {
34461
+ const {
34462
+ responseHeaders,
34463
+ value: responseBody,
34464
+ rawValue
34465
+ } = await postJsonToApi({
34466
+ url: this.getUrl(),
34467
+ headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve3(this.config.o11yHeaders)),
34468
+ body: {
34469
+ text,
34470
+ ...voice && { voice },
34471
+ ...outputFormat && { outputFormat },
34472
+ ...instructions && { instructions },
34473
+ ...speed != null && { speed },
34474
+ ...language && { language },
34475
+ ...providerOptions && { providerOptions }
34476
+ },
34477
+ successfulResponseHandler: createJsonResponseHandler(gatewaySpeechResponseSchema),
34478
+ failedResponseHandler: createJsonErrorResponseHandler({
34479
+ errorSchema: exports_external2.any(),
34480
+ errorToMessage: (data) => data
34481
+ }),
34482
+ ...abortSignal && { abortSignal },
34483
+ fetch: this.config.fetch
34484
+ });
34485
+ return {
34486
+ audio: responseBody.audio,
34487
+ warnings: (_a112 = responseBody.warnings) != null ? _a112 : [],
34488
+ providerMetadata: responseBody.providerMetadata,
34489
+ response: {
34490
+ timestamp: /* @__PURE__ */ new Date,
34491
+ modelId: this.modelId,
34492
+ headers: responseHeaders,
34493
+ body: rawValue
34494
+ }
34495
+ };
34496
+ } catch (error40) {
34497
+ throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders != null ? resolvedHeaders : {}));
34498
+ }
34499
+ }
34500
+ getUrl() {
34501
+ return `${this.config.baseURL}/speech-model`;
34502
+ }
34503
+ getModelConfigHeaders() {
34504
+ return {
34505
+ "ai-speech-model-specification-version": "3",
34506
+ "ai-model-id": this.modelId
34507
+ };
34508
+ }
34509
+ }, providerMetadataEntrySchema3, gatewaySpeechWarningSchema, gatewaySpeechResponseSchema, GatewayTranscriptionModel = class {
34510
+ constructor(modelId, config2) {
34511
+ this.modelId = modelId;
34512
+ this.config = config2;
34513
+ this.specificationVersion = "v3";
34514
+ }
34515
+ get provider() {
34516
+ return this.config.provider;
34517
+ }
34518
+ async doGenerate({
34519
+ audio,
34520
+ mediaType,
34521
+ providerOptions,
34522
+ headers,
34523
+ abortSignal
34524
+ }) {
34525
+ var _a112, _b112, _c, _d;
34526
+ const resolvedHeaders = await resolve3(this.config.headers());
34527
+ try {
34528
+ const {
34529
+ responseHeaders,
34530
+ value: responseBody,
34531
+ rawValue
34532
+ } = await postJsonToApi({
34533
+ url: this.getUrl(),
34534
+ headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve3(this.config.o11yHeaders)),
34535
+ body: {
34536
+ audio: audio instanceof Uint8Array ? convertUint8ArrayToBase64(audio) : audio,
34537
+ mediaType,
34538
+ ...providerOptions && { providerOptions }
34539
+ },
34540
+ successfulResponseHandler: createJsonResponseHandler(gatewayTranscriptionResponseSchema),
34541
+ failedResponseHandler: createJsonErrorResponseHandler({
34542
+ errorSchema: exports_external2.any(),
34543
+ errorToMessage: (data) => data
34544
+ }),
34545
+ ...abortSignal && { abortSignal },
34546
+ fetch: this.config.fetch
34547
+ });
34548
+ return {
34549
+ text: responseBody.text,
34550
+ segments: (_a112 = responseBody.segments) != null ? _a112 : [],
34551
+ language: (_b112 = responseBody.language) != null ? _b112 : undefined,
34552
+ durationInSeconds: (_c = responseBody.durationInSeconds) != null ? _c : undefined,
34553
+ warnings: (_d = responseBody.warnings) != null ? _d : [],
34554
+ providerMetadata: responseBody.providerMetadata,
34555
+ response: {
34556
+ timestamp: /* @__PURE__ */ new Date,
34557
+ modelId: this.modelId,
34558
+ headers: responseHeaders,
34559
+ body: rawValue
34560
+ }
34561
+ };
34562
+ } catch (error40) {
34563
+ throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders != null ? resolvedHeaders : {}));
34564
+ }
34565
+ }
34566
+ getUrl() {
34567
+ return `${this.config.baseURL}/transcription-model`;
34568
+ }
34569
+ getModelConfigHeaders() {
34570
+ return {
34571
+ "ai-transcription-model-specification-version": "3",
34572
+ "ai-model-id": this.modelId
34573
+ };
34574
+ }
34575
+ }, providerMetadataEntrySchema4, gatewayTranscriptionWarningSchema, gatewayTranscriptionResponseSchema, exaSearchInputSchema, exaSearchOutputSchema, exaSearchToolFactory, exaSearch = (config2 = {}) => exaSearchToolFactory(config2), parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION5 = "3.0.143", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
34145
34576
  var init_dist7 = __esm(() => {
34146
34577
  init_dist3();
34147
34578
  init_dist();
@@ -34169,6 +34600,12 @@ var init_dist7 = __esm(() => {
34169
34600
  init_dist3();
34170
34601
  init_v4();
34171
34602
  init_dist3();
34603
+ init_v4();
34604
+ init_dist3();
34605
+ init_v4();
34606
+ init_dist3();
34607
+ init_zod();
34608
+ init_dist3();
34172
34609
  init_zod();
34173
34610
  init_dist3();
34174
34611
  init_zod();
@@ -34350,7 +34787,25 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
34350
34787
  };
34351
34788
  marker82 = `vercel.ai.gateway.error.${name72}`;
34352
34789
  symbol82 = Symbol.for(marker82);
34353
- GatewayResponseError = class extends (_b82 = GatewayError, _a82 = symbol82, _b82) {
34790
+ GatewayForbiddenError = class extends (_b82 = GatewayError, _a82 = symbol82, _b82) {
34791
+ constructor({
34792
+ message = "Forbidden",
34793
+ statusCode = 403,
34794
+ cause,
34795
+ generationId
34796
+ } = {}) {
34797
+ super({ message, statusCode, cause, generationId });
34798
+ this[_a82] = true;
34799
+ this.name = name72;
34800
+ this.type = "forbidden";
34801
+ }
34802
+ static isInstance(error40) {
34803
+ return GatewayError.hasMarker(error40) && symbol82 in error40;
34804
+ }
34805
+ };
34806
+ marker92 = `vercel.ai.gateway.error.${name82}`;
34807
+ symbol92 = Symbol.for(marker92);
34808
+ GatewayResponseError = class extends (_b92 = GatewayError, _a92 = symbol92, _b92) {
34354
34809
  constructor({
34355
34810
  message = "Invalid response from Gateway",
34356
34811
  statusCode = 502,
@@ -34360,14 +34815,14 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
34360
34815
  generationId
34361
34816
  } = {}) {
34362
34817
  super({ message, statusCode, cause, generationId });
34363
- this[_a82] = true;
34364
- this.name = name72;
34818
+ this[_a92] = true;
34819
+ this.name = name82;
34365
34820
  this.type = "response_error";
34366
34821
  this.response = response;
34367
34822
  this.validationError = validationError;
34368
34823
  }
34369
34824
  static isInstance(error40) {
34370
- return GatewayError.hasMarker(error40) && symbol82 in error40;
34825
+ return GatewayError.hasMarker(error40) && symbol92 in error40;
34371
34826
  }
34372
34827
  };
34373
34828
  gatewayErrorResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
@@ -34379,9 +34834,9 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
34379
34834
  }),
34380
34835
  generationId: exports_external2.string().nullish()
34381
34836
  })));
34382
- marker92 = `vercel.ai.gateway.error.${name82}`;
34383
- symbol92 = Symbol.for(marker92);
34384
- GatewayTimeoutError = class _GatewayTimeoutError extends (_b92 = GatewayError, _a92 = symbol92, _b92) {
34837
+ marker102 = `vercel.ai.gateway.error.${name92}`;
34838
+ symbol102 = Symbol.for(marker102);
34839
+ GatewayTimeoutError = class _GatewayTimeoutError extends (_b102 = GatewayError, _a102 = symbol102, _b102) {
34385
34840
  constructor({
34386
34841
  message = "Request timed out",
34387
34842
  statusCode = 408,
@@ -34389,12 +34844,12 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
34389
34844
  generationId
34390
34845
  } = {}) {
34391
34846
  super({ message, statusCode, cause, generationId });
34392
- this[_a92] = true;
34393
- this.name = name82;
34847
+ this[_a102] = true;
34848
+ this.name = name92;
34394
34849
  this.type = "timeout_error";
34395
34850
  }
34396
34851
  static isInstance(error40) {
34397
- return GatewayError.hasMarker(error40) && symbol92 in error40;
34852
+ return GatewayError.hasMarker(error40) && symbol102 in error40;
34398
34853
  }
34399
34854
  static createTimeoutError({
34400
34855
  originalMessage,
@@ -34419,6 +34874,8 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
34419
34874
  "image",
34420
34875
  "language",
34421
34876
  "reranking",
34877
+ "speech",
34878
+ "transcription",
34422
34879
  "video"
34423
34880
  ];
34424
34881
  gatewayAvailableModelsResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
@@ -34545,9 +35002,26 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
34545
35002
  billableWebSearchCalls: billable_web_search_calls
34546
35003
  }))
34547
35004
  }).transform(({ data }) => data)));
35005
+ gatewayEmbeddingWarningSchema = exports_external2.discriminatedUnion("type", [
35006
+ exports_external2.object({
35007
+ type: exports_external2.literal("unsupported"),
35008
+ feature: exports_external2.string(),
35009
+ details: exports_external2.string().optional()
35010
+ }),
35011
+ exports_external2.object({
35012
+ type: exports_external2.literal("compatibility"),
35013
+ feature: exports_external2.string(),
35014
+ details: exports_external2.string().optional()
35015
+ }),
35016
+ exports_external2.object({
35017
+ type: exports_external2.literal("other"),
35018
+ message: exports_external2.string()
35019
+ })
35020
+ ]);
34548
35021
  gatewayEmbeddingResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
34549
35022
  embeddings: exports_external2.array(exports_external2.array(exports_external2.number())),
34550
35023
  usage: exports_external2.object({ tokens: exports_external2.number() }).nullish(),
35024
+ warnings: exports_external2.array(gatewayEmbeddingWarningSchema).optional(),
34551
35025
  providerMetadata: exports_external2.record(exports_external2.string(), exports_external2.record(exports_external2.string(), exports_external2.unknown())).optional()
34552
35026
  })));
34553
35027
  providerMetadataEntrySchema = exports_external2.object({
@@ -34626,22 +35100,198 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
34626
35100
  param: exports_external2.unknown().nullable()
34627
35101
  })
34628
35102
  ]);
35103
+ gatewayRerankingWarningSchema = exports_external2.discriminatedUnion("type", [
35104
+ exports_external2.object({
35105
+ type: exports_external2.literal("unsupported"),
35106
+ feature: exports_external2.string(),
35107
+ details: exports_external2.string().optional()
35108
+ }),
35109
+ exports_external2.object({
35110
+ type: exports_external2.literal("compatibility"),
35111
+ feature: exports_external2.string(),
35112
+ details: exports_external2.string().optional()
35113
+ }),
35114
+ exports_external2.object({
35115
+ type: exports_external2.literal("other"),
35116
+ message: exports_external2.string()
35117
+ })
35118
+ ]);
34629
35119
  gatewayRerankingResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
34630
35120
  ranking: exports_external2.array(exports_external2.object({
34631
35121
  index: exports_external2.number(),
34632
35122
  relevanceScore: exports_external2.number()
34633
35123
  })),
35124
+ warnings: exports_external2.array(gatewayRerankingWarningSchema).optional(),
34634
35125
  providerMetadata: exports_external2.record(exports_external2.string(), exports_external2.record(exports_external2.string(), exports_external2.unknown())).optional()
34635
35126
  })));
35127
+ providerMetadataEntrySchema3 = exports_external2.object({}).catchall(exports_external2.unknown());
35128
+ gatewaySpeechWarningSchema = exports_external2.discriminatedUnion("type", [
35129
+ exports_external2.object({
35130
+ type: exports_external2.literal("unsupported"),
35131
+ feature: exports_external2.string(),
35132
+ details: exports_external2.string().optional()
35133
+ }),
35134
+ exports_external2.object({
35135
+ type: exports_external2.literal("compatibility"),
35136
+ feature: exports_external2.string(),
35137
+ details: exports_external2.string().optional()
35138
+ }),
35139
+ exports_external2.object({
35140
+ type: exports_external2.literal("other"),
35141
+ message: exports_external2.string()
35142
+ })
35143
+ ]);
35144
+ gatewaySpeechResponseSchema = exports_external2.object({
35145
+ audio: exports_external2.string(),
35146
+ warnings: exports_external2.array(gatewaySpeechWarningSchema).optional(),
35147
+ providerMetadata: exports_external2.record(exports_external2.string(), providerMetadataEntrySchema3).optional()
35148
+ });
35149
+ providerMetadataEntrySchema4 = exports_external2.object({}).catchall(exports_external2.unknown());
35150
+ gatewayTranscriptionWarningSchema = exports_external2.discriminatedUnion("type", [
35151
+ exports_external2.object({
35152
+ type: exports_external2.literal("unsupported"),
35153
+ feature: exports_external2.string(),
35154
+ details: exports_external2.string().optional()
35155
+ }),
35156
+ exports_external2.object({
35157
+ type: exports_external2.literal("compatibility"),
35158
+ feature: exports_external2.string(),
35159
+ details: exports_external2.string().optional()
35160
+ }),
35161
+ exports_external2.object({
35162
+ type: exports_external2.literal("other"),
35163
+ message: exports_external2.string()
35164
+ })
35165
+ ]);
35166
+ gatewayTranscriptionResponseSchema = exports_external2.object({
35167
+ text: exports_external2.string(),
35168
+ segments: exports_external2.array(exports_external2.object({
35169
+ text: exports_external2.string(),
35170
+ startSecond: exports_external2.number(),
35171
+ endSecond: exports_external2.number()
35172
+ })).optional(),
35173
+ language: exports_external2.string().nullish(),
35174
+ durationInSeconds: exports_external2.number().nullish(),
35175
+ warnings: exports_external2.array(gatewayTranscriptionWarningSchema).optional(),
35176
+ providerMetadata: exports_external2.record(exports_external2.string(), providerMetadataEntrySchema4).optional()
35177
+ });
35178
+ exaSearchInputSchema = lazySchema(() => zodSchema(exports_external.object({
35179
+ query: exports_external.string().describe("Natural-language web search query. This is required."),
35180
+ type: exports_external.enum(["auto", "fast", "instant"]).optional().describe("Search method. Use auto for the default balance of speed and quality."),
35181
+ num_results: exports_external.number().optional().describe("Maximum number of results to return (1-100, default: 10)."),
35182
+ category: exports_external.enum([
35183
+ "company",
35184
+ "people",
35185
+ "research paper",
35186
+ "news",
35187
+ "personal site",
35188
+ "financial report"
35189
+ ]).optional().describe("Optional content category to focus results."),
35190
+ user_location: exports_external.string().optional().describe("Two-letter ISO country code such as 'US'."),
35191
+ include_domains: exports_external.array(exports_external.string()).optional().describe("Only return results from these domains."),
35192
+ exclude_domains: exports_external.array(exports_external.string()).optional().describe("Exclude results from these domains."),
35193
+ start_published_date: exports_external.string().optional().describe("Only return links published after this ISO 8601 date."),
35194
+ end_published_date: exports_external.string().optional().describe("Only return links published before this ISO 8601 date."),
35195
+ contents: exports_external.object({
35196
+ text: exports_external.union([
35197
+ exports_external.boolean(),
35198
+ exports_external.object({
35199
+ max_characters: exports_external.number().optional(),
35200
+ include_html_tags: exports_external.boolean().optional(),
35201
+ verbosity: exports_external.enum(["compact", "standard", "full"]).optional(),
35202
+ include_sections: exports_external.array(exports_external.enum([
35203
+ "header",
35204
+ "navigation",
35205
+ "banner",
35206
+ "body",
35207
+ "sidebar",
35208
+ "footer",
35209
+ "metadata"
35210
+ ])).optional(),
35211
+ exclude_sections: exports_external.array(exports_external.enum([
35212
+ "header",
35213
+ "navigation",
35214
+ "banner",
35215
+ "body",
35216
+ "sidebar",
35217
+ "footer",
35218
+ "metadata"
35219
+ ])).optional()
35220
+ })
35221
+ ]).optional(),
35222
+ highlights: exports_external.union([
35223
+ exports_external.boolean(),
35224
+ exports_external.object({
35225
+ query: exports_external.string().optional(),
35226
+ max_characters: exports_external.number().optional()
35227
+ })
35228
+ ]).optional(),
35229
+ max_age_hours: exports_external.number().optional(),
35230
+ livecrawl_timeout: exports_external.number().optional(),
35231
+ subpages: exports_external.number().optional(),
35232
+ subpage_target: exports_external.union([exports_external.string(), exports_external.array(exports_external.string())]).optional(),
35233
+ extras: exports_external.object({
35234
+ links: exports_external.number().optional(),
35235
+ image_links: exports_external.number().optional()
35236
+ }).optional()
35237
+ }).optional().describe("Controls extracted page content and freshness.")
35238
+ })));
35239
+ exaSearchOutputSchema = lazySchema(() => zodSchema(exports_external.union([
35240
+ exports_external.object({
35241
+ requestId: exports_external.string(),
35242
+ searchType: exports_external.string().optional(),
35243
+ resolvedSearchType: exports_external.string().optional(),
35244
+ results: exports_external.array(exports_external.object({
35245
+ title: exports_external.string(),
35246
+ url: exports_external.string(),
35247
+ id: exports_external.string(),
35248
+ publishedDate: exports_external.string().nullable().optional(),
35249
+ author: exports_external.string().nullable().optional(),
35250
+ image: exports_external.string().nullable().optional(),
35251
+ favicon: exports_external.string().nullable().optional(),
35252
+ text: exports_external.string().optional(),
35253
+ highlights: exports_external.array(exports_external.string()).optional(),
35254
+ highlightScores: exports_external.array(exports_external.number()).optional(),
35255
+ summary: exports_external.string().optional(),
35256
+ subpages: exports_external.array(exports_external.any()).optional(),
35257
+ extras: exports_external.object({
35258
+ links: exports_external.array(exports_external.string()).optional(),
35259
+ imageLinks: exports_external.array(exports_external.string()).optional()
35260
+ }).optional()
35261
+ })),
35262
+ costDollars: exports_external.object({
35263
+ total: exports_external.number().optional(),
35264
+ search: exports_external.record(exports_external.number()).optional()
35265
+ }).optional()
35266
+ }),
35267
+ exports_external.object({
35268
+ error: exports_external.enum([
35269
+ "api_error",
35270
+ "rate_limit",
35271
+ "timeout",
35272
+ "invalid_input",
35273
+ "configuration_error",
35274
+ "execution_error",
35275
+ "unknown"
35276
+ ]),
35277
+ statusCode: exports_external.number().optional(),
35278
+ message: exports_external.string()
35279
+ })
35280
+ ])));
35281
+ exaSearchToolFactory = createProviderToolFactoryWithOutputSchema({
35282
+ id: "gateway.exa_search",
35283
+ inputSchema: exaSearchInputSchema,
35284
+ outputSchema: exaSearchOutputSchema
35285
+ });
34636
35286
  parallelSearchInputSchema = lazySchema(() => zodSchema(exports_external.object({
34637
35287
  objective: exports_external.string().describe("Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."),
34638
35288
  search_queries: exports_external.array(exports_external.string()).optional().describe("Optional search queries to supplement the objective. Maximum 200 characters per query."),
34639
35289
  mode: exports_external.enum(["one-shot", "agentic"]).optional().describe('Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'),
34640
35290
  max_results: exports_external.number().optional().describe("Maximum number of results to return (1-20). Defaults to 10 if not specified."),
34641
35291
  source_policy: exports_external.object({
34642
- include_domains: exports_external.array(exports_external.string()).optional().describe("List of domains to include in search results."),
34643
- exclude_domains: exports_external.array(exports_external.string()).optional().describe("List of domains to exclude from search results."),
34644
- after_date: exports_external.string().optional().describe("Only include results published after this date (ISO 8601 format).")
35292
+ include_domains: exports_external.array(exports_external.string()).optional().describe("Limit results to these domains. Use plain domain names only \u2014 e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."),
35293
+ exclude_domains: exports_external.array(exports_external.string()).optional().describe("Exclude results from these domains. Use plain domain names only \u2014 e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."),
35294
+ after_date: exports_external.string().optional().describe("Only include results published after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time.")
34645
35295
  }).optional().describe("Source policy for controlling which domains to include/exclude and freshness."),
34646
35296
  excerpts: exports_external.object({
34647
35297
  max_chars_per_result: exports_external.number().optional().describe("Maximum characters per result."),
@@ -34723,20 +35373,21 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
34723
35373
  outputSchema: perplexitySearchOutputSchema
34724
35374
  });
34725
35375
  gatewayTools = {
35376
+ exaSearch,
34726
35377
  parallelSearch,
34727
35378
  perplexitySearch
34728
35379
  };
34729
35380
  gateway = createGatewayProvider();
34730
35381
  });
34731
35382
 
34732
- // node_modules/@opentelemetry/api/build/src/version.js
35383
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/version.js
34733
35384
  var require_version = __commonJS((exports) => {
34734
35385
  Object.defineProperty(exports, "__esModule", { value: true });
34735
35386
  exports.VERSION = undefined;
34736
35387
  exports.VERSION = "1.9.1";
34737
35388
  });
34738
35389
 
34739
- // node_modules/@opentelemetry/api/build/src/internal/semver.js
35390
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/internal/semver.js
34740
35391
  var require_semver = __commonJS((exports) => {
34741
35392
  Object.defineProperty(exports, "__esModule", { value: true });
34742
35393
  exports.isCompatible = exports._makeCompatibilityCheck = undefined;
@@ -34807,7 +35458,7 @@ var require_semver = __commonJS((exports) => {
34807
35458
  exports.isCompatible = _makeCompatibilityCheck(version_1.VERSION);
34808
35459
  });
34809
35460
 
34810
- // node_modules/@opentelemetry/api/build/src/internal/global-utils.js
35461
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/internal/global-utils.js
34811
35462
  var require_global_utils = __commonJS((exports) => {
34812
35463
  Object.defineProperty(exports, "__esModule", { value: true });
34813
35464
  exports.unregisterGlobal = exports.getGlobal = exports.registerGlobal = undefined;
@@ -34855,7 +35506,7 @@ var require_global_utils = __commonJS((exports) => {
34855
35506
  exports.unregisterGlobal = unregisterGlobal;
34856
35507
  });
34857
35508
 
34858
- // node_modules/@opentelemetry/api/build/src/diag/ComponentLogger.js
35509
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/ComponentLogger.js
34859
35510
  var require_ComponentLogger = __commonJS((exports) => {
34860
35511
  Object.defineProperty(exports, "__esModule", { value: true });
34861
35512
  exports.DiagComponentLogger = undefined;
@@ -34891,7 +35542,7 @@ var require_ComponentLogger = __commonJS((exports) => {
34891
35542
  }
34892
35543
  });
34893
35544
 
34894
- // node_modules/@opentelemetry/api/build/src/diag/types.js
35545
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/types.js
34895
35546
  var require_types = __commonJS((exports) => {
34896
35547
  Object.defineProperty(exports, "__esModule", { value: true });
34897
35548
  exports.DiagLogLevel = undefined;
@@ -34907,7 +35558,7 @@ var require_types = __commonJS((exports) => {
34907
35558
  })(DiagLogLevel = exports.DiagLogLevel || (exports.DiagLogLevel = {}));
34908
35559
  });
34909
35560
 
34910
- // node_modules/@opentelemetry/api/build/src/diag/internal/logLevelLogger.js
35561
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/internal/logLevelLogger.js
34911
35562
  var require_logLevelLogger = __commonJS((exports) => {
34912
35563
  Object.defineProperty(exports, "__esModule", { value: true });
34913
35564
  exports.createLogLevelDiagLogger = undefined;
@@ -34937,7 +35588,7 @@ var require_logLevelLogger = __commonJS((exports) => {
34937
35588
  exports.createLogLevelDiagLogger = createLogLevelDiagLogger;
34938
35589
  });
34939
35590
 
34940
- // node_modules/@opentelemetry/api/build/src/api/diag.js
35591
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/diag.js
34941
35592
  var require_diag = __commonJS((exports) => {
34942
35593
  Object.defineProperty(exports, "__esModule", { value: true });
34943
35594
  exports.DiagAPI = undefined;
@@ -35002,7 +35653,7 @@ var require_diag = __commonJS((exports) => {
35002
35653
  exports.DiagAPI = DiagAPI;
35003
35654
  });
35004
35655
 
35005
- // node_modules/@opentelemetry/api/build/src/baggage/internal/baggage-impl.js
35656
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/internal/baggage-impl.js
35006
35657
  var require_baggage_impl = __commonJS((exports) => {
35007
35658
  Object.defineProperty(exports, "__esModule", { value: true });
35008
35659
  exports.BaggageImpl = undefined;
@@ -35045,14 +35696,14 @@ var require_baggage_impl = __commonJS((exports) => {
35045
35696
  exports.BaggageImpl = BaggageImpl;
35046
35697
  });
35047
35698
 
35048
- // node_modules/@opentelemetry/api/build/src/baggage/internal/symbol.js
35699
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/internal/symbol.js
35049
35700
  var require_symbol = __commonJS((exports) => {
35050
35701
  Object.defineProperty(exports, "__esModule", { value: true });
35051
35702
  exports.baggageEntryMetadataSymbol = undefined;
35052
35703
  exports.baggageEntryMetadataSymbol = Symbol("BaggageEntryMetadata");
35053
35704
  });
35054
35705
 
35055
- // node_modules/@opentelemetry/api/build/src/baggage/utils.js
35706
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/utils.js
35056
35707
  var require_utils = __commonJS((exports) => {
35057
35708
  Object.defineProperty(exports, "__esModule", { value: true });
35058
35709
  exports.baggageEntryMetadataFromString = exports.createBaggage = undefined;
@@ -35079,7 +35730,7 @@ var require_utils = __commonJS((exports) => {
35079
35730
  exports.baggageEntryMetadataFromString = baggageEntryMetadataFromString;
35080
35731
  });
35081
35732
 
35082
- // node_modules/@opentelemetry/api/build/src/context/context.js
35733
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/context/context.js
35083
35734
  var require_context = __commonJS((exports) => {
35084
35735
  Object.defineProperty(exports, "__esModule", { value: true });
35085
35736
  exports.ROOT_CONTEXT = exports.createContextKey = undefined;
@@ -35108,7 +35759,7 @@ var require_context = __commonJS((exports) => {
35108
35759
  exports.ROOT_CONTEXT = new BaseContext;
35109
35760
  });
35110
35761
 
35111
- // node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js
35762
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js
35112
35763
  var require_consoleLogger = __commonJS((exports) => {
35113
35764
  Object.defineProperty(exports, "__esModule", { value: true });
35114
35765
  exports.DiagConsoleLogger = exports._originalConsoleMethods = undefined;
@@ -35163,7 +35814,7 @@ var require_consoleLogger = __commonJS((exports) => {
35163
35814
  exports.DiagConsoleLogger = DiagConsoleLogger;
35164
35815
  });
35165
35816
 
35166
- // node_modules/@opentelemetry/api/build/src/metrics/NoopMeter.js
35817
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics/NoopMeter.js
35167
35818
  var require_NoopMeter = __commonJS((exports) => {
35168
35819
  Object.defineProperty(exports, "__esModule", { value: true });
35169
35820
  exports.createNoopMeter = exports.NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC = exports.NOOP_OBSERVABLE_GAUGE_METRIC = exports.NOOP_OBSERVABLE_COUNTER_METRIC = exports.NOOP_UP_DOWN_COUNTER_METRIC = exports.NOOP_HISTOGRAM_METRIC = exports.NOOP_GAUGE_METRIC = exports.NOOP_COUNTER_METRIC = exports.NOOP_METER = exports.NoopObservableUpDownCounterMetric = exports.NoopObservableGaugeMetric = exports.NoopObservableCounterMetric = exports.NoopObservableMetric = exports.NoopHistogramMetric = exports.NoopGaugeMetric = exports.NoopUpDownCounterMetric = exports.NoopCounterMetric = exports.NoopMetric = exports.NoopMeter = undefined;
@@ -35251,7 +35902,7 @@ var require_NoopMeter = __commonJS((exports) => {
35251
35902
  exports.createNoopMeter = createNoopMeter;
35252
35903
  });
35253
35904
 
35254
- // node_modules/@opentelemetry/api/build/src/metrics/Metric.js
35905
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics/Metric.js
35255
35906
  var require_Metric = __commonJS((exports) => {
35256
35907
  Object.defineProperty(exports, "__esModule", { value: true });
35257
35908
  exports.ValueType = undefined;
@@ -35262,7 +35913,7 @@ var require_Metric = __commonJS((exports) => {
35262
35913
  })(ValueType = exports.ValueType || (exports.ValueType = {}));
35263
35914
  });
35264
35915
 
35265
- // node_modules/@opentelemetry/api/build/src/propagation/TextMapPropagator.js
35916
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/propagation/TextMapPropagator.js
35266
35917
  var require_TextMapPropagator = __commonJS((exports) => {
35267
35918
  Object.defineProperty(exports, "__esModule", { value: true });
35268
35919
  exports.defaultTextMapSetter = exports.defaultTextMapGetter = undefined;
@@ -35290,7 +35941,7 @@ var require_TextMapPropagator = __commonJS((exports) => {
35290
35941
  };
35291
35942
  });
35292
35943
 
35293
- // node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js
35944
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js
35294
35945
  var require_NoopContextManager = __commonJS((exports) => {
35295
35946
  Object.defineProperty(exports, "__esModule", { value: true });
35296
35947
  exports.NoopContextManager = undefined;
@@ -35316,7 +35967,7 @@ var require_NoopContextManager = __commonJS((exports) => {
35316
35967
  exports.NoopContextManager = NoopContextManager;
35317
35968
  });
35318
35969
 
35319
- // node_modules/@opentelemetry/api/build/src/api/context.js
35970
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/context.js
35320
35971
  var require_context2 = __commonJS((exports) => {
35321
35972
  Object.defineProperty(exports, "__esModule", { value: true });
35322
35973
  exports.ContextAPI = undefined;
@@ -35357,7 +36008,7 @@ var require_context2 = __commonJS((exports) => {
35357
36008
  exports.ContextAPI = ContextAPI;
35358
36009
  });
35359
36010
 
35360
- // node_modules/@opentelemetry/api/build/src/trace/trace_flags.js
36011
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/trace_flags.js
35361
36012
  var require_trace_flags = __commonJS((exports) => {
35362
36013
  Object.defineProperty(exports, "__esModule", { value: true });
35363
36014
  exports.TraceFlags = undefined;
@@ -35368,7 +36019,7 @@ var require_trace_flags = __commonJS((exports) => {
35368
36019
  })(TraceFlags = exports.TraceFlags || (exports.TraceFlags = {}));
35369
36020
  });
35370
36021
 
35371
- // node_modules/@opentelemetry/api/build/src/trace/invalid-span-constants.js
36022
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/invalid-span-constants.js
35372
36023
  var require_invalid_span_constants = __commonJS((exports) => {
35373
36024
  Object.defineProperty(exports, "__esModule", { value: true });
35374
36025
  exports.INVALID_SPAN_CONTEXT = exports.INVALID_TRACEID = exports.INVALID_SPANID = undefined;
@@ -35382,7 +36033,7 @@ var require_invalid_span_constants = __commonJS((exports) => {
35382
36033
  };
35383
36034
  });
35384
36035
 
35385
- // node_modules/@opentelemetry/api/build/src/trace/NonRecordingSpan.js
36036
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/NonRecordingSpan.js
35386
36037
  var require_NonRecordingSpan = __commonJS((exports) => {
35387
36038
  Object.defineProperty(exports, "__esModule", { value: true });
35388
36039
  exports.NonRecordingSpan = undefined;
@@ -35425,7 +36076,7 @@ var require_NonRecordingSpan = __commonJS((exports) => {
35425
36076
  exports.NonRecordingSpan = NonRecordingSpan;
35426
36077
  });
35427
36078
 
35428
- // node_modules/@opentelemetry/api/build/src/trace/context-utils.js
36079
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/context-utils.js
35429
36080
  var require_context_utils = __commonJS((exports) => {
35430
36081
  Object.defineProperty(exports, "__esModule", { value: true });
35431
36082
  exports.getSpanContext = exports.setSpanContext = exports.deleteSpan = exports.setSpan = exports.getActiveSpan = exports.getSpan = undefined;
@@ -35460,7 +36111,7 @@ var require_context_utils = __commonJS((exports) => {
35460
36111
  exports.getSpanContext = getSpanContext;
35461
36112
  });
35462
36113
 
35463
- // node_modules/@opentelemetry/api/build/src/trace/spancontext-utils.js
36114
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/spancontext-utils.js
35464
36115
  var require_spancontext_utils = __commonJS((exports) => {
35465
36116
  Object.defineProperty(exports, "__esModule", { value: true });
35466
36117
  exports.wrapSpanContext = exports.isSpanContextValid = exports.isValidSpanId = exports.isValidTraceId = undefined;
@@ -35598,7 +36249,7 @@ var require_spancontext_utils = __commonJS((exports) => {
35598
36249
  exports.wrapSpanContext = wrapSpanContext;
35599
36250
  });
35600
36251
 
35601
- // node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js
36252
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js
35602
36253
  var require_NoopTracer = __commonJS((exports) => {
35603
36254
  Object.defineProperty(exports, "__esModule", { value: true });
35604
36255
  exports.NoopTracer = undefined;
@@ -35649,7 +36300,7 @@ var require_NoopTracer = __commonJS((exports) => {
35649
36300
  }
35650
36301
  });
35651
36302
 
35652
- // node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js
36303
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js
35653
36304
  var require_ProxyTracer = __commonJS((exports) => {
35654
36305
  Object.defineProperty(exports, "__esModule", { value: true });
35655
36306
  exports.ProxyTracer = undefined;
@@ -35685,7 +36336,7 @@ var require_ProxyTracer = __commonJS((exports) => {
35685
36336
  exports.ProxyTracer = ProxyTracer;
35686
36337
  });
35687
36338
 
35688
- // node_modules/@opentelemetry/api/build/src/trace/NoopTracerProvider.js
36339
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/NoopTracerProvider.js
35689
36340
  var require_NoopTracerProvider = __commonJS((exports) => {
35690
36341
  Object.defineProperty(exports, "__esModule", { value: true });
35691
36342
  exports.NoopTracerProvider = undefined;
@@ -35699,7 +36350,7 @@ var require_NoopTracerProvider = __commonJS((exports) => {
35699
36350
  exports.NoopTracerProvider = NoopTracerProvider;
35700
36351
  });
35701
36352
 
35702
- // node_modules/@opentelemetry/api/build/src/trace/ProxyTracerProvider.js
36353
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/ProxyTracerProvider.js
35703
36354
  var require_ProxyTracerProvider = __commonJS((exports) => {
35704
36355
  Object.defineProperty(exports, "__esModule", { value: true });
35705
36356
  exports.ProxyTracerProvider = undefined;
@@ -35727,7 +36378,7 @@ var require_ProxyTracerProvider = __commonJS((exports) => {
35727
36378
  exports.ProxyTracerProvider = ProxyTracerProvider;
35728
36379
  });
35729
36380
 
35730
- // node_modules/@opentelemetry/api/build/src/trace/SamplingResult.js
36381
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/SamplingResult.js
35731
36382
  var require_SamplingResult = __commonJS((exports) => {
35732
36383
  Object.defineProperty(exports, "__esModule", { value: true });
35733
36384
  exports.SamplingDecision = undefined;
@@ -35739,7 +36390,7 @@ var require_SamplingResult = __commonJS((exports) => {
35739
36390
  })(SamplingDecision = exports.SamplingDecision || (exports.SamplingDecision = {}));
35740
36391
  });
35741
36392
 
35742
- // node_modules/@opentelemetry/api/build/src/trace/span_kind.js
36393
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/span_kind.js
35743
36394
  var require_span_kind = __commonJS((exports) => {
35744
36395
  Object.defineProperty(exports, "__esModule", { value: true });
35745
36396
  exports.SpanKind = undefined;
@@ -35753,7 +36404,7 @@ var require_span_kind = __commonJS((exports) => {
35753
36404
  })(SpanKind = exports.SpanKind || (exports.SpanKind = {}));
35754
36405
  });
35755
36406
 
35756
- // node_modules/@opentelemetry/api/build/src/trace/status.js
36407
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/status.js
35757
36408
  var require_status = __commonJS((exports) => {
35758
36409
  Object.defineProperty(exports, "__esModule", { value: true });
35759
36410
  exports.SpanStatusCode = undefined;
@@ -35765,7 +36416,7 @@ var require_status = __commonJS((exports) => {
35765
36416
  })(SpanStatusCode = exports.SpanStatusCode || (exports.SpanStatusCode = {}));
35766
36417
  });
35767
36418
 
35768
- // node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-validators.js
36419
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-validators.js
35769
36420
  var require_tracestate_validators = __commonJS((exports) => {
35770
36421
  Object.defineProperty(exports, "__esModule", { value: true });
35771
36422
  exports.validateValue = exports.validateKey = undefined;
@@ -35785,7 +36436,7 @@ var require_tracestate_validators = __commonJS((exports) => {
35785
36436
  exports.validateValue = validateValue;
35786
36437
  });
35787
36438
 
35788
- // node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-impl.js
36439
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-impl.js
35789
36440
  var require_tracestate_impl = __commonJS((exports) => {
35790
36441
  Object.defineProperty(exports, "__esModule", { value: true });
35791
36442
  exports.TraceStateImpl = undefined;
@@ -35854,7 +36505,7 @@ var require_tracestate_impl = __commonJS((exports) => {
35854
36505
  exports.TraceStateImpl = TraceStateImpl;
35855
36506
  });
35856
36507
 
35857
- // node_modules/@opentelemetry/api/build/src/trace/internal/utils.js
36508
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/internal/utils.js
35858
36509
  var require_utils2 = __commonJS((exports) => {
35859
36510
  Object.defineProperty(exports, "__esModule", { value: true });
35860
36511
  exports.createTraceState = undefined;
@@ -35865,7 +36516,7 @@ var require_utils2 = __commonJS((exports) => {
35865
36516
  exports.createTraceState = createTraceState;
35866
36517
  });
35867
36518
 
35868
- // node_modules/@opentelemetry/api/build/src/context-api.js
36519
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/context-api.js
35869
36520
  var require_context_api = __commonJS((exports) => {
35870
36521
  Object.defineProperty(exports, "__esModule", { value: true });
35871
36522
  exports.context = undefined;
@@ -35873,7 +36524,7 @@ var require_context_api = __commonJS((exports) => {
35873
36524
  exports.context = context_1.ContextAPI.getInstance();
35874
36525
  });
35875
36526
 
35876
- // node_modules/@opentelemetry/api/build/src/diag-api.js
36527
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag-api.js
35877
36528
  var require_diag_api = __commonJS((exports) => {
35878
36529
  Object.defineProperty(exports, "__esModule", { value: true });
35879
36530
  exports.diag = undefined;
@@ -35881,7 +36532,7 @@ var require_diag_api = __commonJS((exports) => {
35881
36532
  exports.diag = diag_1.DiagAPI.instance();
35882
36533
  });
35883
36534
 
35884
- // node_modules/@opentelemetry/api/build/src/metrics/NoopMeterProvider.js
36535
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics/NoopMeterProvider.js
35885
36536
  var require_NoopMeterProvider = __commonJS((exports) => {
35886
36537
  Object.defineProperty(exports, "__esModule", { value: true });
35887
36538
  exports.NOOP_METER_PROVIDER = exports.NoopMeterProvider = undefined;
@@ -35896,7 +36547,7 @@ var require_NoopMeterProvider = __commonJS((exports) => {
35896
36547
  exports.NOOP_METER_PROVIDER = new NoopMeterProvider;
35897
36548
  });
35898
36549
 
35899
- // node_modules/@opentelemetry/api/build/src/api/metrics.js
36550
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/metrics.js
35900
36551
  var require_metrics = __commonJS((exports) => {
35901
36552
  Object.defineProperty(exports, "__esModule", { value: true });
35902
36553
  exports.MetricsAPI = undefined;
@@ -35929,7 +36580,7 @@ var require_metrics = __commonJS((exports) => {
35929
36580
  exports.MetricsAPI = MetricsAPI;
35930
36581
  });
35931
36582
 
35932
- // node_modules/@opentelemetry/api/build/src/metrics-api.js
36583
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics-api.js
35933
36584
  var require_metrics_api = __commonJS((exports) => {
35934
36585
  Object.defineProperty(exports, "__esModule", { value: true });
35935
36586
  exports.metrics = undefined;
@@ -35937,7 +36588,7 @@ var require_metrics_api = __commonJS((exports) => {
35937
36588
  exports.metrics = metrics_1.MetricsAPI.getInstance();
35938
36589
  });
35939
36590
 
35940
- // node_modules/@opentelemetry/api/build/src/propagation/NoopTextMapPropagator.js
36591
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/propagation/NoopTextMapPropagator.js
35941
36592
  var require_NoopTextMapPropagator = __commonJS((exports) => {
35942
36593
  Object.defineProperty(exports, "__esModule", { value: true });
35943
36594
  exports.NoopTextMapPropagator = undefined;
@@ -35954,7 +36605,7 @@ var require_NoopTextMapPropagator = __commonJS((exports) => {
35954
36605
  exports.NoopTextMapPropagator = NoopTextMapPropagator;
35955
36606
  });
35956
36607
 
35957
- // node_modules/@opentelemetry/api/build/src/baggage/context-helpers.js
36608
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/context-helpers.js
35958
36609
  var require_context_helpers = __commonJS((exports) => {
35959
36610
  Object.defineProperty(exports, "__esModule", { value: true });
35960
36611
  exports.deleteBaggage = exports.setBaggage = exports.getActiveBaggage = exports.getBaggage = undefined;
@@ -35979,7 +36630,7 @@ var require_context_helpers = __commonJS((exports) => {
35979
36630
  exports.deleteBaggage = deleteBaggage;
35980
36631
  });
35981
36632
 
35982
- // node_modules/@opentelemetry/api/build/src/api/propagation.js
36633
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/propagation.js
35983
36634
  var require_propagation = __commonJS((exports) => {
35984
36635
  Object.defineProperty(exports, "__esModule", { value: true });
35985
36636
  exports.PropagationAPI = undefined;
@@ -36028,7 +36679,7 @@ var require_propagation = __commonJS((exports) => {
36028
36679
  exports.PropagationAPI = PropagationAPI;
36029
36680
  });
36030
36681
 
36031
- // node_modules/@opentelemetry/api/build/src/propagation-api.js
36682
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/propagation-api.js
36032
36683
  var require_propagation_api = __commonJS((exports) => {
36033
36684
  Object.defineProperty(exports, "__esModule", { value: true });
36034
36685
  exports.propagation = undefined;
@@ -36036,7 +36687,7 @@ var require_propagation_api = __commonJS((exports) => {
36036
36687
  exports.propagation = propagation_1.PropagationAPI.getInstance();
36037
36688
  });
36038
36689
 
36039
- // node_modules/@opentelemetry/api/build/src/api/trace.js
36690
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/trace.js
36040
36691
  var require_trace = __commonJS((exports) => {
36041
36692
  Object.defineProperty(exports, "__esModule", { value: true });
36042
36693
  exports.TraceAPI = undefined;
@@ -36086,7 +36737,7 @@ var require_trace = __commonJS((exports) => {
36086
36737
  exports.TraceAPI = TraceAPI;
36087
36738
  });
36088
36739
 
36089
- // node_modules/@opentelemetry/api/build/src/trace-api.js
36740
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace-api.js
36090
36741
  var require_trace_api = __commonJS((exports) => {
36091
36742
  Object.defineProperty(exports, "__esModule", { value: true });
36092
36743
  exports.trace = undefined;
@@ -36094,7 +36745,7 @@ var require_trace_api = __commonJS((exports) => {
36094
36745
  exports.trace = trace_1.TraceAPI.getInstance();
36095
36746
  });
36096
36747
 
36097
- // node_modules/@opentelemetry/api/build/src/index.js
36748
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/index.js
36098
36749
  var require_src = __commonJS((exports) => {
36099
36750
  Object.defineProperty(exports, "__esModule", { value: true });
36100
36751
  exports.trace = exports.propagation = exports.metrics = exports.diag = exports.context = exports.INVALID_SPAN_CONTEXT = exports.INVALID_TRACEID = exports.INVALID_SPANID = exports.isValidSpanId = exports.isValidTraceId = exports.isSpanContextValid = exports.createTraceState = exports.TraceFlags = exports.SpanStatusCode = exports.SpanKind = exports.SamplingDecision = exports.ProxyTracerProvider = exports.ProxyTracer = exports.defaultTextMapSetter = exports.defaultTextMapGetter = exports.ValueType = exports.createNoopMeter = exports.DiagLogLevel = exports.DiagConsoleLogger = exports.ROOT_CONTEXT = exports.createContextKey = exports.baggageEntryMetadataFromString = undefined;
@@ -36209,7 +36860,7 @@ var require_src = __commonJS((exports) => {
36209
36860
  };
36210
36861
  });
36211
36862
 
36212
- // node_modules/ai/dist/index.mjs
36863
+ // node_modules/.pnpm/ai@6.0.219_zod@3.25.76/node_modules/ai/dist/index.mjs
36213
36864
  var exports_dist4 = {};
36214
36865
  __export(exports_dist4, {
36215
36866
  zodSchema: () => zodSchema,
@@ -36324,6 +36975,7 @@ __export(exports_dist4, {
36324
36975
  JsonToSseTransformStream: () => JsonToSseTransformStream,
36325
36976
  JSONParseError: () => JSONParseError,
36326
36977
  InvalidToolInputError: () => InvalidToolInputError,
36978
+ InvalidToolApprovalSignatureError: () => InvalidToolApprovalSignatureError,
36327
36979
  InvalidToolApprovalError: () => InvalidToolApprovalError,
36328
36980
  InvalidStreamPartError: () => InvalidStreamPartError,
36329
36981
  InvalidResponseDataError: () => InvalidResponseDataError,
@@ -36567,7 +37219,7 @@ function resolveEmbeddingModel(model) {
36567
37219
  return getGlobalProvider().embeddingModel(model);
36568
37220
  }
36569
37221
  function resolveTranscriptionModel(model) {
36570
- var _a21, _b16;
37222
+ var _a222, _b16;
36571
37223
  if (typeof model !== "string") {
36572
37224
  if (model.specificationVersion !== "v3" && model.specificationVersion !== "v2") {
36573
37225
  const unsupportedModel = model;
@@ -36579,10 +37231,10 @@ function resolveTranscriptionModel(model) {
36579
37231
  }
36580
37232
  return asTranscriptionModelV3(model);
36581
37233
  }
36582
- return (_b16 = (_a21 = getGlobalProvider()).transcriptionModel) == null ? undefined : _b16.call(_a21, model);
37234
+ return (_b16 = (_a222 = getGlobalProvider()).transcriptionModel) == null ? undefined : _b16.call(_a222, model);
36583
37235
  }
36584
37236
  function resolveSpeechModel(model) {
36585
- var _a21, _b16;
37237
+ var _a222, _b16;
36586
37238
  if (typeof model !== "string") {
36587
37239
  if (model.specificationVersion !== "v3" && model.specificationVersion !== "v2") {
36588
37240
  const unsupportedModel = model;
@@ -36594,7 +37246,7 @@ function resolveSpeechModel(model) {
36594
37246
  }
36595
37247
  return asSpeechModelV3(model);
36596
37248
  }
36597
- return (_b16 = (_a21 = getGlobalProvider()).speechModel) == null ? undefined : _b16.call(_a21, model);
37249
+ return (_b16 = (_a222 = getGlobalProvider()).speechModel) == null ? undefined : _b16.call(_a222, model);
36598
37250
  }
36599
37251
  function resolveImageModel(model) {
36600
37252
  if (typeof model !== "string") {
@@ -36649,8 +37301,8 @@ function resolveRerankingModel(model) {
36649
37301
  return model;
36650
37302
  }
36651
37303
  function getGlobalProvider() {
36652
- var _a21;
36653
- return (_a21 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a21 : gateway;
37304
+ var _a222;
37305
+ return (_a222 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a222 : gateway;
36654
37306
  }
36655
37307
  function getTotalTimeoutMs(timeout) {
36656
37308
  if (timeout == null) {
@@ -36975,7 +37627,7 @@ function convertToLanguageModelMessage({
36975
37627
  }
36976
37628
  }
36977
37629
  async function downloadAssets(messages, download2, supportedUrls) {
36978
- var _a21;
37630
+ var _a222;
36979
37631
  const downloadableFiles = [];
36980
37632
  for (const message of messages) {
36981
37633
  if (message.role === "user" && Array.isArray(message.content)) {
@@ -36983,7 +37635,7 @@ async function downloadAssets(messages, download2, supportedUrls) {
36983
37635
  if (part.type === "image" || part.type === "file") {
36984
37636
  downloadableFiles.push({
36985
37637
  data: part.type === "image" ? part.image : part.data,
36986
- mediaType: (_a21 = part.mediaType) != null ? _a21 : part.type === "image" ? "image/*" : undefined
37638
+ mediaType: (_a222 = part.mediaType) != null ? _a222 : part.type === "image" ? "image/*" : undefined
36987
37639
  });
36988
37640
  }
36989
37641
  }
@@ -37029,7 +37681,7 @@ async function downloadAssets(messages, download2, supportedUrls) {
37029
37681
  ]).filter((file2) => file2 != null));
37030
37682
  }
37031
37683
  function convertPartToLanguageModelPart(part, downloadedAssets) {
37032
- var _a21;
37684
+ var _a222;
37033
37685
  if (part.type === "text") {
37034
37686
  return {
37035
37687
  type: "text",
@@ -37062,7 +37714,7 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
37062
37714
  switch (type) {
37063
37715
  case "image": {
37064
37716
  if (data instanceof Uint8Array || typeof data === "string") {
37065
- mediaType = (_a21 = detectMediaType({ data, signatures: imageMediaTypeSignatures })) != null ? _a21 : mediaType;
37717
+ mediaType = (_a222 = detectMediaType({ data, signatures: imageMediaTypeSignatures })) != null ? _a222 : mediaType;
37066
37718
  }
37067
37719
  return {
37068
37720
  type: "file",
@@ -37096,14 +37748,14 @@ function mapToolResultOutput({
37096
37748
  return {
37097
37749
  type: "content",
37098
37750
  value: output.value.map((item) => {
37099
- var _a21, _b16;
37751
+ var _a222, _b16;
37100
37752
  if (item.type === "image-url") {
37101
37753
  const downloadedFile = downloadedAssets[new URL(item.url).toString()];
37102
37754
  if (downloadedFile) {
37103
37755
  return {
37104
37756
  type: "image-data",
37105
37757
  data: convertDataContentToBase64String(downloadedFile.data),
37106
- mediaType: (_a21 = downloadedFile.mediaType) != null ? _a21 : "image/*",
37758
+ mediaType: (_a222 = downloadedFile.mediaType) != null ? _a222 : "image/*",
37107
37759
  providerOptions: item.providerOptions
37108
37760
  };
37109
37761
  }
@@ -37264,9 +37916,9 @@ async function prepareToolsAndToolChoice({
37264
37916
  toolChoice: undefined
37265
37917
  };
37266
37918
  }
37267
- const filteredTools = activeTools != null ? Object.entries(tools).filter(([name21]) => activeTools.includes(name21)) : Object.entries(tools);
37919
+ const filteredTools = activeTools != null ? Object.entries(tools).filter(([name222]) => activeTools.includes(name222)) : Object.entries(tools);
37268
37920
  const languageModelTools = [];
37269
- for (const [name21, tool2] of filteredTools) {
37921
+ for (const [name222, tool2] of filteredTools) {
37270
37922
  const toolType = tool2.type;
37271
37923
  switch (toolType) {
37272
37924
  case undefined:
@@ -37274,7 +37926,7 @@ async function prepareToolsAndToolChoice({
37274
37926
  case "function":
37275
37927
  languageModelTools.push({
37276
37928
  type: "function",
37277
- name: name21,
37929
+ name: name222,
37278
37930
  description: tool2.description,
37279
37931
  inputSchema: await asSchema(tool2.inputSchema).jsonSchema,
37280
37932
  ...tool2.inputExamples != null ? { inputExamples: tool2.inputExamples } : {},
@@ -37285,7 +37937,7 @@ async function prepareToolsAndToolChoice({
37285
37937
  case "provider":
37286
37938
  languageModelTools.push({
37287
37939
  type: "provider",
37288
- name: name21,
37940
+ name: name222,
37289
37941
  id: tool2.id,
37290
37942
  args: tool2.args
37291
37943
  });
@@ -37403,7 +38055,7 @@ function getBaseTelemetryAttributes({
37403
38055
  telemetry,
37404
38056
  headers
37405
38057
  }) {
37406
- var _a21;
38058
+ var _a222;
37407
38059
  return {
37408
38060
  "ai.model.provider": model.provider,
37409
38061
  "ai.model.id": model.modelId,
@@ -37418,7 +38070,7 @@ function getBaseTelemetryAttributes({
37418
38070
  }
37419
38071
  return attributes;
37420
38072
  }, {}),
37421
- ...Object.entries((_a21 = telemetry == null ? undefined : telemetry.metadata) != null ? _a21 : {}).reduce((attributes, [key, value]) => {
38073
+ ...Object.entries((_a222 = telemetry == null ? undefined : telemetry.metadata) != null ? _a222 : {}).reduce((attributes, [key, value]) => {
37422
38074
  attributes[`ai.telemetry.metadata.${key}`] = value;
37423
38075
  return attributes;
37424
38076
  }, {}),
@@ -37443,13 +38095,13 @@ function getTracer({
37443
38095
  return import_api2.trace.getTracer("ai");
37444
38096
  }
37445
38097
  async function recordSpan({
37446
- name: name21,
38098
+ name: name222,
37447
38099
  tracer,
37448
38100
  attributes,
37449
38101
  fn,
37450
38102
  endWhenDone = true
37451
38103
  }) {
37452
- return tracer.startActiveSpan(name21, { attributes: await attributes }, async (span) => {
38104
+ return tracer.startActiveSpan(name222, { attributes: await attributes }, async (span) => {
37453
38105
  const ctx = import_api3.context.active();
37454
38106
  try {
37455
38107
  const result = await import_api3.context.with(ctx, () => fn(span));
@@ -37482,6 +38134,26 @@ function recordErrorOnSpan(span, error40) {
37482
38134
  span.setStatus({ code: import_api3.SpanStatusCode.ERROR });
37483
38135
  }
37484
38136
  }
38137
+ function isPrimitiveAttributeValue(value) {
38138
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
38139
+ }
38140
+ function sanitizeAttributeValue(value) {
38141
+ if (!Array.isArray(value)) {
38142
+ return value;
38143
+ }
38144
+ const primitiveTypes2 = new Set(value.filter(isPrimitiveAttributeValue).map((item) => typeof item));
38145
+ if (primitiveTypes2.size !== 1) {
38146
+ return;
38147
+ }
38148
+ const [primitiveType] = primitiveTypes2;
38149
+ if (primitiveType === "string") {
38150
+ return value.filter((item) => typeof item === "string");
38151
+ }
38152
+ if (primitiveType === "number") {
38153
+ return value.filter((item) => typeof item === "number");
38154
+ }
38155
+ return value.filter((item) => typeof item === "boolean");
38156
+ }
37485
38157
  async function selectTelemetryAttributes({
37486
38158
  telemetry,
37487
38159
  attributes
@@ -37500,7 +38172,9 @@ async function selectTelemetryAttributes({
37500
38172
  }
37501
38173
  const result = await value.input();
37502
38174
  if (result != null) {
37503
- resultAttributes[key] = result;
38175
+ const sanitized2 = sanitizeAttributeValue(result);
38176
+ if (sanitized2 != null)
38177
+ resultAttributes[key] = sanitized2;
37504
38178
  }
37505
38179
  continue;
37506
38180
  }
@@ -37510,11 +38184,15 @@ async function selectTelemetryAttributes({
37510
38184
  }
37511
38185
  const result = await value.output();
37512
38186
  if (result != null) {
37513
- resultAttributes[key] = result;
38187
+ const sanitized2 = sanitizeAttributeValue(result);
38188
+ if (sanitized2 != null)
38189
+ resultAttributes[key] = sanitized2;
37514
38190
  }
37515
38191
  continue;
37516
38192
  }
37517
- resultAttributes[key] = value;
38193
+ const sanitized = sanitizeAttributeValue(value);
38194
+ if (sanitized != null)
38195
+ resultAttributes[key] = sanitized;
37518
38196
  }
37519
38197
  return resultAttributes;
37520
38198
  }
@@ -37534,13 +38212,13 @@ function registerTelemetryIntegration(integration) {
37534
38212
  globalThis.AI_SDK_TELEMETRY_INTEGRATIONS.push(integration);
37535
38213
  }
37536
38214
  function getGlobalTelemetryIntegrations() {
37537
- var _a21;
37538
- return (_a21 = globalThis.AI_SDK_TELEMETRY_INTEGRATIONS) != null ? _a21 : [];
38215
+ var _a222;
38216
+ return (_a222 = globalThis.AI_SDK_TELEMETRY_INTEGRATIONS) != null ? _a222 : [];
37539
38217
  }
37540
38218
  function bindTelemetryIntegration(integration) {
37541
- var _a21, _b16, _c, _d, _e, _f;
38219
+ var _a222, _b16, _c, _d, _e, _f;
37542
38220
  return {
37543
- onStart: (_a21 = integration.onStart) == null ? undefined : _a21.bind(integration),
38221
+ onStart: (_a222 = integration.onStart) == null ? undefined : _a222.bind(integration),
37544
38222
  onStepStart: (_b16 = integration.onStepStart) == null ? undefined : _b16.bind(integration),
37545
38223
  onToolCallStart: (_c = integration.onToolCallStart) == null ? undefined : _c.bind(integration),
37546
38224
  onToolCallFinish: (_d = integration.onToolCallFinish) == null ? undefined : _d.bind(integration),
@@ -37610,11 +38288,11 @@ function createNullLanguageModelUsage() {
37610
38288
  };
37611
38289
  }
37612
38290
  function addLanguageModelUsage(usage1, usage2) {
37613
- var _a21, _b16, _c, _d, _e, _f, _g, _h, _i, _j;
38291
+ var _a222, _b16, _c, _d, _e, _f, _g, _h, _i, _j;
37614
38292
  return {
37615
38293
  inputTokens: addTokenCounts(usage1.inputTokens, usage2.inputTokens),
37616
38294
  inputTokenDetails: {
37617
- noCacheTokens: addTokenCounts((_a21 = usage1.inputTokenDetails) == null ? undefined : _a21.noCacheTokens, (_b16 = usage2.inputTokenDetails) == null ? undefined : _b16.noCacheTokens),
38295
+ noCacheTokens: addTokenCounts((_a222 = usage1.inputTokenDetails) == null ? undefined : _a222.noCacheTokens, (_b16 = usage2.inputTokenDetails) == null ? undefined : _b16.noCacheTokens),
37618
38296
  cacheReadTokens: addTokenCounts((_c = usage1.inputTokenDetails) == null ? undefined : _c.cacheReadTokens, (_d = usage2.inputTokenDetails) == null ? undefined : _d.cacheReadTokens),
37619
38297
  cacheWriteTokens: addTokenCounts((_e = usage1.inputTokenDetails) == null ? undefined : _e.cacheWriteTokens, (_f = usage2.inputTokenDetails) == null ? undefined : _f.cacheWriteTokens)
37620
38298
  },
@@ -37698,53 +38376,6 @@ function getRetryDelayInMs({
37698
38376
  }
37699
38377
  return exponentialBackoffDelay;
37700
38378
  }
37701
- async function _retryWithExponentialBackoff(f, {
37702
- maxRetries,
37703
- delayInMs,
37704
- backoffFactor,
37705
- abortSignal
37706
- }, errors4 = []) {
37707
- try {
37708
- return await f();
37709
- } catch (error40) {
37710
- if (isAbortError(error40)) {
37711
- throw error40;
37712
- }
37713
- if (maxRetries === 0) {
37714
- throw error40;
37715
- }
37716
- const errorMessage = getErrorMessage2(error40);
37717
- const newErrors = [...errors4, error40];
37718
- const tryNumber = newErrors.length;
37719
- if (tryNumber > maxRetries) {
37720
- throw new RetryError({
37721
- message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
37722
- reason: "maxRetriesExceeded",
37723
- errors: newErrors
37724
- });
37725
- }
37726
- if (error40 instanceof Error && (APICallError.isInstance(error40) && error40.isRetryable === true || GatewayError.isInstance(error40) && error40.isRetryable === true) && tryNumber <= maxRetries) {
37727
- await delay(getRetryDelayInMs({
37728
- error: error40,
37729
- exponentialBackoffDelay: delayInMs
37730
- }), { abortSignal });
37731
- return _retryWithExponentialBackoff(f, {
37732
- maxRetries,
37733
- delayInMs: backoffFactor * delayInMs,
37734
- backoffFactor,
37735
- abortSignal
37736
- }, newErrors);
37737
- }
37738
- if (tryNumber === 1) {
37739
- throw error40;
37740
- }
37741
- throw new RetryError({
37742
- message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
37743
- reason: "errorNotRetryable",
37744
- errors: newErrors
37745
- });
37746
- }
37747
- }
37748
38379
  function prepareRetries({
37749
38380
  maxRetries,
37750
38381
  abortSignal
@@ -37846,8 +38477,8 @@ function collectToolApprovals({
37846
38477
  return { approvedToolApprovals, deniedToolApprovals };
37847
38478
  }
37848
38479
  function now2() {
37849
- var _a21, _b16;
37850
- return (_b16 = (_a21 = globalThis == null ? undefined : globalThis.performance) == null ? undefined : _a21.now()) != null ? _b16 : Date.now();
38480
+ var _a222, _b16;
38481
+ return (_b16 = (_a222 = globalThis == null ? undefined : globalThis.performance) == null ? undefined : _a222.now()) != null ? _b16 : Date.now();
37851
38482
  }
37852
38483
  async function executeToolCall({
37853
38484
  toolCall,
@@ -38008,10 +38639,158 @@ async function isApprovalNeeded({
38008
38639
  experimental_context
38009
38640
  });
38010
38641
  }
38642
+ function canonicalJSON(value) {
38643
+ if (value === null || value === undefined) {
38644
+ return JSON.stringify(value);
38645
+ }
38646
+ if (typeof value !== "object") {
38647
+ return JSON.stringify(value);
38648
+ }
38649
+ if (Array.isArray(value)) {
38650
+ return `[${value.map(canonicalJSON).join(",")}]`;
38651
+ }
38652
+ const keys = Object.keys(value).sort();
38653
+ const entries = keys.map((k) => `${JSON.stringify(k)}:${canonicalJSON(value[k])}`);
38654
+ return `{${entries.join(",")}}`;
38655
+ }
38656
+ function toBase64url(bytes) {
38657
+ return convertUint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
38658
+ }
38659
+ function fromBase64url(str) {
38660
+ return convertBase64ToUint8Array(str);
38661
+ }
38662
+ async function importKey(secret) {
38663
+ const keyData = typeof secret === "string" ? encoder.encode(secret) : secret;
38664
+ return crypto.subtle.importKey("raw", keyData, { name: "HMAC", hash: "SHA-256" }, false, ["sign", "verify"]);
38665
+ }
38666
+ async function hashInput(input) {
38667
+ const canonical = canonicalJSON(input);
38668
+ const digest = await crypto.subtle.digest("SHA-256", encoder.encode(canonical));
38669
+ return toBase64url(new Uint8Array(digest));
38670
+ }
38671
+ function buildPayload(approvalId, toolCallId, toolName, inputDigest) {
38672
+ return encoder.encode(`${approvalId}
38673
+ ${toolCallId}
38674
+ ${toolName}
38675
+ ${inputDigest}`);
38676
+ }
38677
+ async function signToolApproval({
38678
+ secret,
38679
+ approvalId,
38680
+ toolCallId,
38681
+ toolName,
38682
+ input
38683
+ }) {
38684
+ const key = await importKey(secret);
38685
+ const inputDigest = await hashInput(input);
38686
+ const payload = buildPayload(approvalId, toolCallId, toolName, inputDigest);
38687
+ const sig = await crypto.subtle.sign("HMAC", key, payload);
38688
+ return toBase64url(new Uint8Array(sig));
38689
+ }
38690
+ async function verifyToolApprovalSignature({
38691
+ secret,
38692
+ signature,
38693
+ approvalId,
38694
+ toolCallId,
38695
+ toolName,
38696
+ input
38697
+ }) {
38698
+ const key = await importKey(secret);
38699
+ const inputDigest = await hashInput(input);
38700
+ const payload = buildPayload(approvalId, toolCallId, toolName, inputDigest);
38701
+ const sigBytes = fromBase64url(signature);
38702
+ return crypto.subtle.verify("HMAC", key, sigBytes, payload);
38703
+ }
38704
+ async function maybeSignApproval({
38705
+ secret,
38706
+ approvalId,
38707
+ toolCallId,
38708
+ toolName,
38709
+ input
38710
+ }) {
38711
+ if (secret == null)
38712
+ return;
38713
+ return signToolApproval({ secret, approvalId, toolCallId, toolName, input });
38714
+ }
38715
+ async function validateApprovedToolApprovals({
38716
+ approvedToolApprovals,
38717
+ tools,
38718
+ messages,
38719
+ experimental_context,
38720
+ toolApprovalSecret
38721
+ }) {
38722
+ var _a222;
38723
+ const approved = [];
38724
+ const denied = [];
38725
+ for (const approval of approvedToolApprovals) {
38726
+ const { toolCall, approvalRequest } = approval;
38727
+ const tool2 = tools == null ? undefined : tools[toolCall.toolName];
38728
+ if (toolApprovalSecret != null) {
38729
+ if (approvalRequest.signature == null) {
38730
+ throw new InvalidToolApprovalSignatureError({
38731
+ approvalId: approvalRequest.approvalId,
38732
+ toolCallId: toolCall.toolCallId,
38733
+ reason: "missing signature"
38734
+ });
38735
+ }
38736
+ const valid = await verifyToolApprovalSignature({
38737
+ secret: toolApprovalSecret,
38738
+ signature: approvalRequest.signature,
38739
+ approvalId: approvalRequest.approvalId,
38740
+ toolCallId: toolCall.toolCallId,
38741
+ toolName: toolCall.toolName,
38742
+ input: toolCall.input
38743
+ });
38744
+ if (!valid) {
38745
+ throw new InvalidToolApprovalSignatureError({
38746
+ approvalId: approvalRequest.approvalId,
38747
+ toolCallId: toolCall.toolCallId,
38748
+ reason: "invalid signature"
38749
+ });
38750
+ }
38751
+ }
38752
+ if (tool2 != null && typeof tool2.execute === "function" && tool2.inputSchema != null) {
38753
+ const validation = await safeValidateTypes({
38754
+ value: toolCall.input,
38755
+ schema: asSchema(tool2.inputSchema)
38756
+ });
38757
+ if (!validation.success) {
38758
+ throw new InvalidToolInputError({
38759
+ toolName: toolCall.toolName,
38760
+ toolInput: JSON.stringify(toolCall.input),
38761
+ cause: validation.error
38762
+ });
38763
+ }
38764
+ }
38765
+ const approvalNeeded = tool2 != null && await isApprovalNeeded({
38766
+ tool: tool2,
38767
+ toolCall,
38768
+ messages,
38769
+ experimental_context
38770
+ });
38771
+ if (approvalNeeded) {
38772
+ approved.push(approval);
38773
+ } else {
38774
+ denied.push({
38775
+ ...approval,
38776
+ approvalResponse: {
38777
+ ...approval.approvalResponse,
38778
+ approved: false,
38779
+ reason: (_a222 = approval.approvalResponse.reason) != null ? _a222 : `Tool "${toolCall.toolName}" does not require approval`
38780
+ }
38781
+ });
38782
+ }
38783
+ }
38784
+ return { approvedToolApprovals: approved, deniedToolApprovals: denied };
38785
+ }
38011
38786
  function fixJson(input) {
38012
38787
  const stack = ["ROOT"];
38013
38788
  let lastValidIndex = -1;
38014
38789
  let literalStart = null;
38790
+ let unicodeEscapeDigits = 0;
38791
+ function isHexDigit(char) {
38792
+ return char >= "0" && char <= "9" || char >= "A" && char <= "F" || char >= "a" && char <= "f";
38793
+ }
38015
38794
  function processValueStart(char, i, swapState) {
38016
38795
  {
38017
38796
  switch (char) {
@@ -38216,7 +38995,22 @@ function fixJson(input) {
38216
38995
  }
38217
38996
  case "INSIDE_STRING_ESCAPE": {
38218
38997
  stack.pop();
38219
- lastValidIndex = i;
38998
+ if (char === "u") {
38999
+ unicodeEscapeDigits = 0;
39000
+ stack.push("INSIDE_STRING_UNICODE_ESCAPE");
39001
+ } else {
39002
+ lastValidIndex = i;
39003
+ }
39004
+ break;
39005
+ }
39006
+ case "INSIDE_STRING_UNICODE_ESCAPE": {
39007
+ if (isHexDigit(char)) {
39008
+ unicodeEscapeDigits++;
39009
+ if (unicodeEscapeDigits === 4) {
39010
+ stack.pop();
39011
+ lastValidIndex = i;
39012
+ }
39013
+ }
38220
39014
  break;
38221
39015
  }
38222
39016
  case "INSIDE_NUMBER": {
@@ -38473,8 +39267,8 @@ function isLoopFinished() {
38473
39267
  }
38474
39268
  function hasToolCall(toolName) {
38475
39269
  return ({ steps }) => {
38476
- var _a21, _b16, _c;
38477
- return (_c = (_b16 = (_a21 = steps[steps.length - 1]) == null ? undefined : _a21.toolCalls) == null ? undefined : _b16.some((toolCall) => toolCall.toolName === toolName)) != null ? _c : false;
39270
+ var _a222, _b16, _c;
39271
+ return (_c = (_b16 = (_a222 = steps[steps.length - 1]) == null ? undefined : _a222.toolCalls) == null ? undefined : _b16.some((toolCall) => toolCall.toolName === toolName)) != null ? _c : false;
38478
39272
  };
38479
39273
  }
38480
39274
  async function isStopConditionMet({
@@ -38570,7 +39364,8 @@ async function toResponseMessages({
38570
39364
  content.push({
38571
39365
  type: "tool-approval-request",
38572
39366
  approvalId: part.approvalId,
38573
- toolCallId: part.toolCall.toolCallId
39367
+ toolCallId: part.toolCall.toolCallId,
39368
+ ...part.signature != null ? { signature: part.signature } : {}
38574
39369
  });
38575
39370
  break;
38576
39371
  }
@@ -38653,6 +39448,7 @@ async function generateText({
38653
39448
  experimental_repairToolCall: repairToolCall,
38654
39449
  experimental_download: download2,
38655
39450
  experimental_context,
39451
+ experimental_toolApprovalSecret,
38656
39452
  experimental_include: include,
38657
39453
  _internal: { generateId: generateId2 = originalGenerateId } = {},
38658
39454
  experimental_onStart: onStart,
@@ -38745,11 +39541,27 @@ async function generateText({
38745
39541
  }),
38746
39542
  tracer,
38747
39543
  fn: async (span) => {
38748
- var _a21, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
39544
+ var _a222, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
38749
39545
  const initialMessages = initialPrompt.messages;
38750
39546
  const responseMessages = [];
38751
- const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
38752
- const localApprovedToolApprovals = approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted);
39547
+ const {
39548
+ approvedToolApprovals,
39549
+ deniedToolApprovals: collectedDeniedToolApprovals
39550
+ } = collectToolApprovals({ messages: initialMessages });
39551
+ const {
39552
+ approvedToolApprovals: localApprovedToolApprovals,
39553
+ deniedToolApprovals: revalidationDeniedToolApprovals
39554
+ } = await validateApprovedToolApprovals({
39555
+ approvedToolApprovals: approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted),
39556
+ tools,
39557
+ messages: initialMessages,
39558
+ experimental_context,
39559
+ toolApprovalSecret: experimental_toolApprovalSecret
39560
+ });
39561
+ const deniedToolApprovals = [
39562
+ ...collectedDeniedToolApprovals,
39563
+ ...revalidationDeniedToolApprovals
39564
+ ];
38753
39565
  if (deniedToolApprovals.length > 0 || localApprovedToolApprovals.length > 0) {
38754
39566
  const toolOutputs = await executeTools({
38755
39567
  toolCalls: localApprovedToolApprovals.map((toolApproval) => toolApproval.toolCall),
@@ -38826,7 +39638,7 @@ async function generateText({
38826
39638
  messages: stepInputMessages,
38827
39639
  experimental_context
38828
39640
  }));
38829
- const stepModel = resolveLanguageModel((_a21 = prepareStepResult == null ? undefined : prepareStepResult.model) != null ? _a21 : model);
39641
+ const stepModel = resolveLanguageModel((_a222 = prepareStepResult == null ? undefined : prepareStepResult.model) != null ? _a222 : model);
38830
39642
  const stepModelInfo = {
38831
39643
  provider: stepModel.provider,
38832
39644
  modelId: stepModel.modelId
@@ -38876,7 +39688,7 @@ async function generateText({
38876
39688
  ]
38877
39689
  });
38878
39690
  currentModelResponse = await retry(() => {
38879
- var _a222;
39691
+ var _a232;
38880
39692
  return recordSpan({
38881
39693
  name: "ai.generateText.doGenerate",
38882
39694
  attributes: selectTelemetryAttributes({
@@ -38904,14 +39716,14 @@ async function generateText({
38904
39716
  "gen_ai.request.max_tokens": settings.maxOutputTokens,
38905
39717
  "gen_ai.request.presence_penalty": settings.presencePenalty,
38906
39718
  "gen_ai.request.stop_sequences": settings.stopSequences,
38907
- "gen_ai.request.temperature": (_a222 = settings.temperature) != null ? _a222 : undefined,
39719
+ "gen_ai.request.temperature": (_a232 = settings.temperature) != null ? _a232 : undefined,
38908
39720
  "gen_ai.request.top_k": settings.topK,
38909
39721
  "gen_ai.request.top_p": settings.topP
38910
39722
  }
38911
39723
  }),
38912
39724
  tracer,
38913
39725
  fn: async (span2) => {
38914
- var _a232, _b23, _c2, _d2, _e2, _f2, _g2, _h2;
39726
+ var _a24, _b23, _c2, _d2, _e2, _f2, _g2, _h2;
38915
39727
  const result = await stepModel.doGenerate({
38916
39728
  ...callSettings2,
38917
39729
  tools: stepTools,
@@ -38923,7 +39735,7 @@ async function generateText({
38923
39735
  headers: headersWithUserAgent
38924
39736
  });
38925
39737
  const responseData = {
38926
- id: (_b23 = (_a232 = result.response) == null ? undefined : _a232.id) != null ? _b23 : generateId2(),
39738
+ id: (_b23 = (_a24 = result.response) == null ? undefined : _a24.id) != null ? _b23 : generateId2(),
38927
39739
  timestamp: (_d2 = (_c2 = result.response) == null ? undefined : _c2.timestamp) != null ? _d2 : /* @__PURE__ */ new Date,
38928
39740
  modelId: (_f2 = (_e2 = result.response) == null ? undefined : _e2.modelId) != null ? _f2 : stepModel.modelId,
38929
39741
  headers: (_g2 = result.response) == null ? undefined : _g2.headers,
@@ -39004,10 +39816,19 @@ async function generateText({
39004
39816
  messages: stepInputMessages,
39005
39817
  experimental_context
39006
39818
  })) {
39819
+ const approvalId = generateId2();
39820
+ const signature = await maybeSignApproval({
39821
+ secret: experimental_toolApprovalSecret,
39822
+ approvalId,
39823
+ toolCallId: toolCall.toolCallId,
39824
+ toolName: toolCall.toolName,
39825
+ input: toolCall.input
39826
+ });
39007
39827
  toolApprovalRequests[toolCall.toolCallId] = {
39008
39828
  type: "tool-approval-request",
39009
- approvalId: generateId2(),
39010
- toolCall
39829
+ approvalId,
39830
+ toolCall,
39831
+ ...signature != null ? { signature } : {}
39011
39832
  };
39012
39833
  }
39013
39834
  }
@@ -39464,6 +40285,9 @@ function getResponseUIMessageId({
39464
40285
  function isDataUIMessageChunk(chunk) {
39465
40286
  return chunk.type.startsWith("data-");
39466
40287
  }
40288
+ function createIdMap() {
40289
+ return /* @__PURE__ */ Object.create(null);
40290
+ }
39467
40291
  function isDataUIPart(part) {
39468
40292
  return part.type.startsWith("data-");
39469
40293
  }
@@ -39502,9 +40326,9 @@ function createStreamingUIMessageState({
39502
40326
  role: "assistant",
39503
40327
  parts: []
39504
40328
  },
39505
- activeTextParts: {},
39506
- activeReasoningParts: {},
39507
- partialToolCalls: {}
40329
+ activeTextParts: createIdMap(),
40330
+ activeReasoningParts: createIdMap(),
40331
+ partialToolCalls: createIdMap()
39508
40332
  };
39509
40333
  }
39510
40334
  function processUIMessageStream({
@@ -39519,7 +40343,7 @@ function processUIMessageStream({
39519
40343
  return stream.pipeThrough(new TransformStream({
39520
40344
  async transform(chunk, controller) {
39521
40345
  await runUpdateMessageJob(async ({ state, write }) => {
39522
- var _a21, _b16, _c, _d;
40346
+ var _a222, _b16, _c, _d;
39523
40347
  function getToolInvocation(toolCallId) {
39524
40348
  const toolInvocations = state.message.parts.filter(isToolUIPart);
39525
40349
  const toolInvocation = toolInvocations.find((invocation) => invocation.toolCallId === toolCallId);
@@ -39533,7 +40357,7 @@ function processUIMessageStream({
39533
40357
  return toolInvocation;
39534
40358
  }
39535
40359
  function updateToolPart(options) {
39536
- var _a222;
40360
+ var _a232;
39537
40361
  const part = state.message.parts.find((part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId);
39538
40362
  const anyOptions = options;
39539
40363
  const anyPart = part;
@@ -39550,7 +40374,7 @@ function processUIMessageStream({
39550
40374
  if (options.toolMetadata !== undefined) {
39551
40375
  anyPart.toolMetadata = options.toolMetadata;
39552
40376
  }
39553
- anyPart.providerExecuted = (_a222 = anyOptions.providerExecuted) != null ? _a222 : part.providerExecuted;
40377
+ anyPart.providerExecuted = (_a232 = anyOptions.providerExecuted) != null ? _a232 : part.providerExecuted;
39554
40378
  const providerMetadata = anyOptions.providerMetadata;
39555
40379
  if (providerMetadata != null) {
39556
40380
  if (options.state === "output-available" || options.state === "output-error") {
@@ -39579,7 +40403,7 @@ function processUIMessageStream({
39579
40403
  }
39580
40404
  }
39581
40405
  function updateDynamicToolPart(options) {
39582
- var _a222, _b23;
40406
+ var _a232, _b23;
39583
40407
  const part = state.message.parts.find((part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId);
39584
40408
  const anyOptions = options;
39585
40409
  const anyPart = part;
@@ -39589,7 +40413,7 @@ function processUIMessageStream({
39589
40413
  anyPart.input = anyOptions.input;
39590
40414
  anyPart.output = anyOptions.output;
39591
40415
  anyPart.errorText = anyOptions.errorText;
39592
- anyPart.rawInput = (_a222 = anyOptions.rawInput) != null ? _a222 : anyPart.rawInput;
40416
+ anyPart.rawInput = (_a232 = anyOptions.rawInput) != null ? _a232 : anyPart.rawInput;
39593
40417
  anyPart.preliminary = anyOptions.preliminary;
39594
40418
  if (options.title !== undefined) {
39595
40419
  anyPart.title = options.title;
@@ -39664,7 +40488,7 @@ function processUIMessageStream({
39664
40488
  });
39665
40489
  }
39666
40490
  textPart.text += chunk.delta;
39667
- textPart.providerMetadata = (_a21 = chunk.providerMetadata) != null ? _a21 : textPart.providerMetadata;
40491
+ textPart.providerMetadata = (_a222 = chunk.providerMetadata) != null ? _a222 : textPart.providerMetadata;
39668
40492
  write();
39669
40493
  break;
39670
40494
  }
@@ -39891,7 +40715,10 @@ function processUIMessageStream({
39891
40715
  case "tool-approval-request": {
39892
40716
  const toolInvocation = getToolInvocation(chunk.toolCallId);
39893
40717
  toolInvocation.state = "approval-requested";
39894
- toolInvocation.approval = { id: chunk.approvalId };
40718
+ toolInvocation.approval = {
40719
+ id: chunk.approvalId,
40720
+ ...chunk.signature != null ? { signature: chunk.signature } : {}
40721
+ };
39895
40722
  write();
39896
40723
  break;
39897
40724
  }
@@ -39969,8 +40796,8 @@ function processUIMessageStream({
39969
40796
  break;
39970
40797
  }
39971
40798
  case "finish-step": {
39972
- state.activeTextParts = {};
39973
- state.activeReasoningParts = {};
40799
+ state.activeTextParts = createIdMap();
40800
+ state.activeReasoningParts = createIdMap();
39974
40801
  break;
39975
40802
  }
39976
40803
  case "start": {
@@ -40162,13 +40989,13 @@ function createAsyncIterableStream(source) {
40162
40989
  const reader = this.getReader();
40163
40990
  let finished = false;
40164
40991
  async function cleanup(cancelStream) {
40165
- var _a21;
40992
+ var _a222;
40166
40993
  if (finished)
40167
40994
  return;
40168
40995
  finished = true;
40169
40996
  try {
40170
40997
  if (cancelStream) {
40171
- await ((_a21 = reader.cancel) == null ? undefined : _a21.call(reader));
40998
+ await ((_a222 = reader.cancel) == null ? undefined : _a222.call(reader));
40172
40999
  }
40173
41000
  } finally {
40174
41001
  try {
@@ -40311,6 +41138,7 @@ function runToolsTransformation({
40311
41138
  abortSignal,
40312
41139
  repairToolCall,
40313
41140
  experimental_context,
41141
+ toolApprovalSecret,
40314
41142
  generateId: generateId2,
40315
41143
  stepNumber,
40316
41144
  model,
@@ -40440,10 +41268,19 @@ function runToolsTransformation({
40440
41268
  messages,
40441
41269
  experimental_context
40442
41270
  })) {
41271
+ const approvalId = generateId2();
41272
+ const signature = await maybeSignApproval({
41273
+ secret: toolApprovalSecret,
41274
+ approvalId,
41275
+ toolCallId: toolCall.toolCallId,
41276
+ toolName: toolCall.toolName,
41277
+ input: toolCall.input
41278
+ });
40443
41279
  toolResultsStreamController.enqueue({
40444
41280
  type: "tool-approval-request",
40445
- approvalId: generateId2(),
40446
- toolCall
41281
+ approvalId,
41282
+ toolCall,
41283
+ ...signature != null ? { signature } : {}
40447
41284
  });
40448
41285
  break;
40449
41286
  }
@@ -40581,6 +41418,7 @@ function streamText({
40581
41418
  experimental_onToolCallStart: onToolCallStart,
40582
41419
  experimental_onToolCallFinish: onToolCallFinish,
40583
41420
  experimental_context,
41421
+ experimental_toolApprovalSecret,
40584
41422
  experimental_include: include,
40585
41423
  _internal: { now: now22 = now2, generateId: generateId2 = originalGenerateId2 } = {},
40586
41424
  ...settings
@@ -40630,6 +41468,7 @@ function streamText({
40630
41468
  now: now22,
40631
41469
  generateId: generateId2,
40632
41470
  experimental_context,
41471
+ experimental_toolApprovalSecret,
40633
41472
  download: download2,
40634
41473
  include
40635
41474
  });
@@ -40657,7 +41496,7 @@ function createOutputTransformStream(output) {
40657
41496
  }
40658
41497
  return new TransformStream({
40659
41498
  async transform(chunk, controller) {
40660
- var _a21;
41499
+ var _a222;
40661
41500
  if (chunk.type === "finish-step" && textChunk.length > 0) {
40662
41501
  publishTextChunk({ controller });
40663
41502
  }
@@ -40684,7 +41523,7 @@ function createOutputTransformStream(output) {
40684
41523
  }
40685
41524
  text2 += chunk.text;
40686
41525
  textChunk += chunk.text;
40687
- textProviderMetadata = (_a21 = chunk.providerMetadata) != null ? _a21 : textProviderMetadata;
41526
+ textProviderMetadata = (_a222 = chunk.providerMetadata) != null ? _a222 : textProviderMetadata;
40688
41527
  const result = await output.parsePartialOutput({ text: text2 });
40689
41528
  if (result !== undefined) {
40690
41529
  const currentValue = typeof result.partial === "string" ? result.partial : JSON.stringify(result.partial);
@@ -40698,7 +41537,7 @@ function createOutputTransformStream(output) {
40698
41537
  }
40699
41538
  function createUIMessageStream({
40700
41539
  execute,
40701
- onError = getErrorMessage2,
41540
+ onError = () => "An error occurred.",
40702
41541
  originalMessages,
40703
41542
  onStepFinish,
40704
41543
  onFinish,
@@ -40781,7 +41620,7 @@ function readUIMessageStream({
40781
41620
  onError,
40782
41621
  terminateOnError = false
40783
41622
  }) {
40784
- var _a21;
41623
+ var _a222;
40785
41624
  let controller;
40786
41625
  let hasErrored = false;
40787
41626
  const outputStream = new ReadableStream({
@@ -40790,7 +41629,7 @@ function readUIMessageStream({
40790
41629
  }
40791
41630
  });
40792
41631
  const state = createStreamingUIMessageState({
40793
- messageId: (_a21 = message == null ? undefined : message.id) != null ? _a21 : "",
41632
+ messageId: (_a222 = message == null ? undefined : message.id) != null ? _a222 : "",
40794
41633
  lastMessage: message
40795
41634
  });
40796
41635
  const handleError = (error40) => {
@@ -40850,7 +41689,7 @@ async function convertToModelMessages(messages, options) {
40850
41689
  modelMessages.push({
40851
41690
  role: "user",
40852
41691
  content: message.parts.map((part) => {
40853
- var _a21;
41692
+ var _a222;
40854
41693
  if (isTextUIPart(part)) {
40855
41694
  return {
40856
41695
  type: "text",
@@ -40868,7 +41707,7 @@ async function convertToModelMessages(messages, options) {
40868
41707
  };
40869
41708
  }
40870
41709
  if (isDataUIPart(part)) {
40871
- return (_a21 = options == null ? undefined : options.convertDataPart) == null ? undefined : _a21.call(options, part);
41710
+ return (_a222 = options == null ? undefined : options.convertDataPart) == null ? undefined : _a222.call(options, part);
40872
41711
  }
40873
41712
  }).filter(isNonNullable)
40874
41713
  });
@@ -40878,7 +41717,7 @@ async function convertToModelMessages(messages, options) {
40878
41717
  if (message.parts != null) {
40879
41718
  let block = [];
40880
41719
  async function processBlock() {
40881
- var _a21, _b16, _c, _d, _e, _f, _g, _h;
41720
+ var _a222, _b16, _c, _d, _e, _f, _g, _h;
40882
41721
  if (block.length === 0) {
40883
41722
  return;
40884
41723
  }
@@ -40911,7 +41750,7 @@ async function convertToModelMessages(messages, options) {
40911
41750
  type: "tool-call",
40912
41751
  toolCallId: part.toolCallId,
40913
41752
  toolName,
40914
- input: part.state === "output-error" ? (_a21 = part.input) != null ? _a21 : ("rawInput" in part) ? part.rawInput : undefined : part.input,
41753
+ input: part.state === "output-error" ? (_a222 = part.input) != null ? _a222 : ("rawInput" in part) ? part.rawInput : undefined : part.input,
40915
41754
  providerExecuted: part.providerExecuted,
40916
41755
  ...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}
40917
41756
  });
@@ -40919,7 +41758,8 @@ async function convertToModelMessages(messages, options) {
40919
41758
  content.push({
40920
41759
  type: "tool-approval-request",
40921
41760
  approvalId: part.approval.id,
40922
- toolCallId: part.toolCallId
41761
+ toolCallId: part.toolCallId,
41762
+ ...part.approval.signature != null ? { signature: part.approval.signature } : {}
40923
41763
  });
40924
41764
  }
40925
41765
  if (part.providerExecuted === true && part.state !== "approval-responded" && (part.state === "output-available" || part.state === "output-error")) {
@@ -40954,8 +41794,8 @@ async function convertToModelMessages(messages, options) {
40954
41794
  content
40955
41795
  });
40956
41796
  const toolParts = block.filter((part) => {
40957
- var _a222;
40958
- return isToolUIPart(part) && (part.providerExecuted !== true || ((_a222 = part.approval) == null ? undefined : _a222.approved) != null);
41797
+ var _a232;
41798
+ return isToolUIPart(part) && (part.providerExecuted !== true || ((_a232 = part.approval) == null ? undefined : _a232.approved) != null);
40959
41799
  });
40960
41800
  if (toolParts.length > 0) {
40961
41801
  {
@@ -41189,7 +42029,7 @@ async function createAgentUIStream({
41189
42029
  onStepFinish,
41190
42030
  ...uiMessageStreamOptions
41191
42031
  }) {
41192
- var _a21;
42032
+ var _a222;
41193
42033
  const validatedMessages = await validateUIMessages({
41194
42034
  messages: uiMessages,
41195
42035
  tools: agent.tools
@@ -41207,7 +42047,7 @@ async function createAgentUIStream({
41207
42047
  });
41208
42048
  return result.toUIMessageStream({
41209
42049
  ...uiMessageStreamOptions,
41210
- originalMessages: (_a21 = uiMessageStreamOptions.originalMessages) != null ? _a21 : validatedMessages
42050
+ originalMessages: (_a222 = uiMessageStreamOptions.originalMessages) != null ? _a222 : validatedMessages
41211
42051
  });
41212
42052
  }
41213
42053
  async function createAgentUIStreamResponse({
@@ -41291,7 +42131,7 @@ async function embed({
41291
42131
  }),
41292
42132
  tracer,
41293
42133
  fn: async (doEmbedSpan) => {
41294
- var _a21, _b16;
42134
+ var _a222, _b16;
41295
42135
  const modelResponse = await model.doEmbed({
41296
42136
  values: [value],
41297
42137
  abortSignal,
@@ -41299,7 +42139,7 @@ async function embed({
41299
42139
  providerOptions
41300
42140
  });
41301
42141
  const embedding2 = modelResponse.embeddings[0];
41302
- const usage2 = (_a21 = modelResponse.usage) != null ? _a21 : { tokens: NaN };
42142
+ const usage2 = (_a222 = modelResponse.usage) != null ? _a222 : { tokens: NaN };
41303
42143
  doEmbedSpan.setAttributes(await selectTelemetryAttributes({
41304
42144
  telemetry,
41305
42145
  attributes: {
@@ -41384,7 +42224,7 @@ async function embedMany({
41384
42224
  }),
41385
42225
  tracer,
41386
42226
  fn: async (span) => {
41387
- var _a21;
42227
+ var _a222;
41388
42228
  const [maxEmbeddingsPerCall, supportsParallelCalls] = await Promise.all([
41389
42229
  model.maxEmbeddingsPerCall,
41390
42230
  model.supportsParallelCalls
@@ -41408,7 +42248,7 @@ async function embedMany({
41408
42248
  }),
41409
42249
  tracer,
41410
42250
  fn: async (doEmbedSpan) => {
41411
- var _a222, _b16;
42251
+ var _a232, _b16;
41412
42252
  const modelResponse = await model.doEmbed({
41413
42253
  values,
41414
42254
  abortSignal,
@@ -41416,7 +42256,7 @@ async function embedMany({
41416
42256
  providerOptions
41417
42257
  });
41418
42258
  const embeddings3 = modelResponse.embeddings;
41419
- const usage2 = (_a222 = modelResponse.usage) != null ? _a222 : { tokens: NaN };
42259
+ const usage2 = (_a232 = modelResponse.usage) != null ? _a232 : { tokens: NaN };
41420
42260
  doEmbedSpan.setAttributes(await selectTelemetryAttributes({
41421
42261
  telemetry,
41422
42262
  attributes: {
@@ -41486,7 +42326,7 @@ async function embedMany({
41486
42326
  }),
41487
42327
  tracer,
41488
42328
  fn: async (doEmbedSpan) => {
41489
- var _a222, _b16;
42329
+ var _a232, _b16;
41490
42330
  const modelResponse = await model.doEmbed({
41491
42331
  values: chunk,
41492
42332
  abortSignal,
@@ -41494,7 +42334,7 @@ async function embedMany({
41494
42334
  providerOptions
41495
42335
  });
41496
42336
  const embeddings2 = modelResponse.embeddings;
41497
- const usage = (_a222 = modelResponse.usage) != null ? _a222 : { tokens: NaN };
42337
+ const usage = (_a232 = modelResponse.usage) != null ? _a232 : { tokens: NaN };
41498
42338
  doEmbedSpan.setAttributes(await selectTelemetryAttributes({
41499
42339
  telemetry,
41500
42340
  attributes: {
@@ -41526,7 +42366,7 @@ async function embedMany({
41526
42366
  } else {
41527
42367
  for (const [providerName, metadata] of Object.entries(result.providerMetadata)) {
41528
42368
  providerMetadata[providerName] = {
41529
- ...(_a21 = providerMetadata[providerName]) != null ? _a21 : {},
42369
+ ...(_a222 = providerMetadata[providerName]) != null ? _a222 : {},
41530
42370
  ...metadata
41531
42371
  };
41532
42372
  }
@@ -41572,14 +42412,14 @@ async function generateImage({
41572
42412
  abortSignal,
41573
42413
  headers
41574
42414
  }) {
41575
- var _a21, _b16;
42415
+ var _a222, _b16;
41576
42416
  const model = resolveImageModel(modelArg);
41577
42417
  const headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION6}`);
41578
42418
  const { retry } = prepareRetries({
41579
42419
  maxRetries: maxRetriesArg,
41580
42420
  abortSignal
41581
42421
  });
41582
- const maxImagesPerCallWithDefault = (_a21 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a21 : 1;
42422
+ const maxImagesPerCallWithDefault = (_a222 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a222 : 1;
41583
42423
  const callCount = Math.ceil(n / maxImagesPerCallWithDefault);
41584
42424
  const callImageCounts = Array.from({ length: callCount }, (_, i) => {
41585
42425
  if (i < callCount - 1) {
@@ -41614,13 +42454,13 @@ async function generateImage({
41614
42454
  };
41615
42455
  for (const result of results) {
41616
42456
  images.push(...result.images.map((image) => {
41617
- var _a222;
42457
+ var _a232;
41618
42458
  return new DefaultGeneratedFile({
41619
42459
  data: image,
41620
- mediaType: (_a222 = detectMediaType({
42460
+ mediaType: (_a232 = detectMediaType({
41621
42461
  data: image,
41622
42462
  signatures: imageMediaTypeSignatures
41623
- })) != null ? _a222 : "image/png"
42463
+ })) != null ? _a232 : "image/png"
41624
42464
  });
41625
42465
  }));
41626
42466
  warnings.push(...result.warnings);
@@ -41971,7 +42811,7 @@ async function generateObject(options) {
41971
42811
  }),
41972
42812
  tracer,
41973
42813
  fn: async (span) => {
41974
- var _a21;
42814
+ var _a222;
41975
42815
  let result;
41976
42816
  let finishReason;
41977
42817
  let usage;
@@ -42016,7 +42856,7 @@ async function generateObject(options) {
42016
42856
  }),
42017
42857
  tracer,
42018
42858
  fn: async (span2) => {
42019
- var _a222, _b16, _c, _d, _e, _f, _g, _h;
42859
+ var _a232, _b16, _c, _d, _e, _f, _g, _h;
42020
42860
  const result2 = await model.doGenerate({
42021
42861
  responseFormat: {
42022
42862
  type: "json",
@@ -42031,7 +42871,7 @@ async function generateObject(options) {
42031
42871
  headers: headersWithUserAgent
42032
42872
  });
42033
42873
  const responseData = {
42034
- id: (_b16 = (_a222 = result2.response) == null ? undefined : _a222.id) != null ? _b16 : generateId2(),
42874
+ id: (_b16 = (_a232 = result2.response) == null ? undefined : _a232.id) != null ? _b16 : generateId2(),
42035
42875
  timestamp: (_d = (_c = result2.response) == null ? undefined : _c.timestamp) != null ? _d : currentDate(),
42036
42876
  modelId: (_f = (_e = result2.response) == null ? undefined : _e.modelId) != null ? _f : model.modelId,
42037
42877
  headers: (_g = result2.response) == null ? undefined : _g.headers,
@@ -42080,7 +42920,7 @@ async function generateObject(options) {
42080
42920
  usage = asLanguageModelUsage(generateResult.usage);
42081
42921
  warnings = generateResult.warnings;
42082
42922
  resultProviderMetadata = generateResult.providerMetadata;
42083
- request = (_a21 = generateResult.request) != null ? _a21 : {};
42923
+ request = (_a222 = generateResult.request) != null ? _a222 : {};
42084
42924
  response = generateResult.responseData;
42085
42925
  reasoning = generateResult.reasoning;
42086
42926
  logWarnings({
@@ -42199,8 +43039,8 @@ function simulateReadableStream({
42199
43039
  chunkDelayInMs = 0,
42200
43040
  _internal
42201
43041
  }) {
42202
- var _a21;
42203
- const delay2 = (_a21 = _internal == null ? undefined : _internal.delay) != null ? _a21 : delay;
43042
+ var _a222;
43043
+ const delay2 = (_a222 = _internal == null ? undefined : _internal.delay) != null ? _a222 : delay;
42204
43044
  let index = 0;
42205
43045
  return new ReadableStream({
42206
43046
  async pull(controller) {
@@ -42294,7 +43134,7 @@ async function generateSpeech({
42294
43134
  abortSignal,
42295
43135
  headers
42296
43136
  }) {
42297
- var _a21;
43137
+ var _a222;
42298
43138
  const resolvedModel = resolveSpeechModel(model);
42299
43139
  if (!resolvedModel) {
42300
43140
  throw new Error("Model could not be resolved");
@@ -42326,10 +43166,10 @@ async function generateSpeech({
42326
43166
  return new DefaultSpeechResult({
42327
43167
  audio: new DefaultGeneratedAudioFile({
42328
43168
  data: result.audio,
42329
- mediaType: (_a21 = detectMediaType({
43169
+ mediaType: (_a222 = detectMediaType({
42330
43170
  data: result.audio,
42331
43171
  signatures: audioMediaTypeSignatures
42332
- })) != null ? _a21 : "audio/mp3"
43172
+ })) != null ? _a222 : "audio/mp3"
42333
43173
  }),
42334
43174
  warnings: result.warnings,
42335
43175
  responses: [result.response],
@@ -42379,27 +43219,44 @@ function pruneMessages({
42379
43219
  }
42380
43220
  }
42381
43221
  }
43222
+ const toolCallIdToToolName = /* @__PURE__ */ new Map;
43223
+ for (const message of messages) {
43224
+ if ((message.role === "assistant" || message.role === "tool") && typeof message.content !== "string") {
43225
+ for (const part of message.content) {
43226
+ if (part.type === "tool-call" || part.type === "tool-result") {
43227
+ toolCallIdToToolName.set(part.toolCallId, part.toolName);
43228
+ }
43229
+ }
43230
+ }
43231
+ }
43232
+ const approvalIdToToolName = /* @__PURE__ */ new Map;
43233
+ for (const message of messages) {
43234
+ if ((message.role === "assistant" || message.role === "tool") && typeof message.content !== "string") {
43235
+ for (const part of message.content) {
43236
+ if (part.type === "tool-approval-request") {
43237
+ const toolName = toolCallIdToToolName.get(part.toolCallId);
43238
+ if (toolName != null) {
43239
+ approvalIdToToolName.set(part.approvalId, toolName);
43240
+ }
43241
+ }
43242
+ }
43243
+ }
43244
+ }
42382
43245
  messages = messages.map((message, messageIndex) => {
42383
43246
  if (message.role !== "assistant" && message.role !== "tool" || typeof message.content === "string" || keepLastMessagesCount && messageIndex >= messages.length - keepLastMessagesCount) {
42384
43247
  return message;
42385
43248
  }
42386
- const toolCallIdToToolName = {};
42387
- const approvalIdToToolName = {};
42388
43249
  return {
42389
43250
  ...message,
42390
43251
  content: message.content.filter((part) => {
42391
43252
  if (part.type !== "tool-call" && part.type !== "tool-result" && part.type !== "tool-approval-request" && part.type !== "tool-approval-response") {
42392
43253
  return true;
42393
43254
  }
42394
- if (part.type === "tool-call") {
42395
- toolCallIdToToolName[part.toolCallId] = part.toolName;
42396
- } else if (part.type === "tool-approval-request") {
42397
- approvalIdToToolName[part.approvalId] = toolCallIdToToolName[part.toolCallId];
42398
- }
42399
43255
  if ((part.type === "tool-call" || part.type === "tool-result") && keptToolCallIds.has(part.toolCallId) || (part.type === "tool-approval-request" || part.type === "tool-approval-response") && keptApprovalIds.has(part.approvalId)) {
42400
43256
  return true;
42401
43257
  }
42402
- return toolCall.tools != null && !toolCall.tools.includes(part.type === "tool-call" || part.type === "tool-result" ? part.toolName : approvalIdToToolName[part.approvalId]);
43258
+ const partToolName = part.type === "tool-call" || part.type === "tool-result" ? part.toolName : approvalIdToToolName.get(part.approvalId);
43259
+ return toolCall.tools != null && partToolName != null && !toolCall.tools.includes(partToolName);
42403
43260
  })
42404
43261
  };
42405
43262
  });
@@ -42507,13 +43364,16 @@ async function experimental_generateVideo({
42507
43364
  duration: duration3,
42508
43365
  fps,
42509
43366
  seed,
43367
+ frameImages,
43368
+ inputReferences,
43369
+ generateAudio,
42510
43370
  providerOptions,
42511
43371
  maxRetries: maxRetriesArg,
42512
43372
  abortSignal,
42513
43373
  headers,
42514
43374
  download: downloadFn = defaultDownload
42515
43375
  }) {
42516
- var _a21;
43376
+ var _a222, _b16;
42517
43377
  const model = resolveVideoModel(modelArg);
42518
43378
  const headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION6}`);
42519
43379
  const { retry } = prepareRetries({
@@ -42521,13 +43381,34 @@ async function experimental_generateVideo({
42521
43381
  abortSignal
42522
43382
  });
42523
43383
  const { prompt, image } = normalizePrompt2(promptArg);
42524
- const maxVideosPerCallWithDefault = (_a21 = maxVideosPerCall != null ? maxVideosPerCall : await invokeModelMaxVideosPerCall(model)) != null ? _a21 : 1;
43384
+ const normalizedFrameImages = frameImages == null ? undefined : frameImages.map((frame) => ({
43385
+ image: normalizeImageData(frame.image),
43386
+ frameType: frame.frameType
43387
+ }));
43388
+ const normalizedInputReferences = inputReferences == null ? undefined : inputReferences.map((reference) => normalizeImageData(reference));
43389
+ const effectiveInputReferences = normalizedFrameImages != null && normalizedFrameImages.length > 0 ? undefined : normalizedInputReferences;
43390
+ const warnings = [];
43391
+ if (normalizedFrameImages != null && normalizedFrameImages.length > 0 && normalizedInputReferences != null && normalizedInputReferences.length > 0) {
43392
+ warnings.push({
43393
+ type: "other",
43394
+ message: "inputReferences were ignored because frameImages were provided; frameImages and inputReferences cannot be combined."
43395
+ });
43396
+ }
43397
+ const firstFrameImage = (_a222 = normalizedFrameImages == null ? undefined : normalizedFrameImages.find((frame) => frame.frameType === "first_frame")) == null ? undefined : _a222.image;
43398
+ if (image != null && firstFrameImage != null) {
43399
+ warnings.push({
43400
+ type: "other",
43401
+ message: "prompt.image was ignored because a first_frame frameImage was provided; the first_frame frameImage takes precedence as the start image."
43402
+ });
43403
+ }
43404
+ const resolvedImage = firstFrameImage != null ? firstFrameImage : image;
43405
+ const maxVideosPerCallWithDefault = (_b16 = maxVideosPerCall != null ? maxVideosPerCall : await invokeModelMaxVideosPerCall(model)) != null ? _b16 : 1;
42525
43406
  const callCount = Math.ceil(n / maxVideosPerCallWithDefault);
42526
43407
  const callVideoCounts = Array.from({ length: callCount }, (_, index) => {
42527
43408
  const remaining = n - index * maxVideosPerCallWithDefault;
42528
43409
  return Math.min(remaining, maxVideosPerCallWithDefault);
42529
43410
  });
42530
- const results = await Promise.all(callVideoCounts.map(async (callVideoCount) => retry(() => model.doGenerate({
43411
+ const results = await Promise.all(callVideoCounts.map(async (callVideoCount) => await retry(() => model.doGenerate({
42531
43412
  prompt,
42532
43413
  n: callVideoCount,
42533
43414
  aspectRatio,
@@ -42535,13 +43416,15 @@ async function experimental_generateVideo({
42535
43416
  duration: duration3,
42536
43417
  fps,
42537
43418
  seed,
42538
- image,
43419
+ image: resolvedImage,
43420
+ frameImages: normalizedFrameImages,
43421
+ inputReferences: effectiveInputReferences,
43422
+ generateAudio,
42539
43423
  providerOptions: providerOptions != null ? providerOptions : {},
42540
43424
  headers: headersWithUserAgent,
42541
43425
  abortSignal
42542
43426
  }))));
42543
43427
  const videos = [];
42544
- const warnings = [];
42545
43428
  const responses = [];
42546
43429
  const providerMetadata = {};
42547
43430
  for (const result of results) {
@@ -42629,56 +43512,49 @@ async function experimental_generateVideo({
42629
43512
  };
42630
43513
  }
42631
43514
  function normalizePrompt2(promptArg) {
42632
- var _a21, _b16;
42633
43515
  if (typeof promptArg === "string") {
42634
43516
  return {
42635
43517
  prompt: promptArg,
42636
43518
  image: undefined
42637
43519
  };
42638
43520
  }
42639
- let image;
42640
- if (promptArg.image != null) {
42641
- const dataContent = promptArg.image;
42642
- if (typeof dataContent === "string") {
42643
- if (dataContent.startsWith("http://") || dataContent.startsWith("https://")) {
42644
- image = {
42645
- type: "url",
42646
- url: dataContent
42647
- };
42648
- } else if (dataContent.startsWith("data:")) {
42649
- const { mediaType, base64Content } = splitDataUrl(dataContent);
42650
- image = {
42651
- type: "file",
42652
- mediaType: mediaType != null ? mediaType : "image/png",
42653
- data: convertBase64ToUint8Array(base64Content != null ? base64Content : "")
42654
- };
42655
- } else {
42656
- const bytes = convertBase64ToUint8Array(dataContent);
42657
- const mediaType = (_a21 = detectMediaType({
42658
- data: bytes,
42659
- signatures: imageMediaTypeSignatures
42660
- })) != null ? _a21 : "image/png";
42661
- image = {
42662
- type: "file",
42663
- mediaType,
42664
- data: bytes
42665
- };
42666
- }
42667
- } else if (dataContent instanceof Uint8Array) {
42668
- const mediaType = (_b16 = detectMediaType({
42669
- data: dataContent,
42670
- signatures: imageMediaTypeSignatures
42671
- })) != null ? _b16 : "image/png";
42672
- image = {
43521
+ return {
43522
+ prompt: promptArg.text,
43523
+ image: promptArg.image != null ? normalizeImageData(promptArg.image) : undefined
43524
+ };
43525
+ }
43526
+ function normalizeImageData(dataContent) {
43527
+ var _a222, _b16;
43528
+ if (typeof dataContent === "string") {
43529
+ if (dataContent.startsWith("http://") || dataContent.startsWith("https://")) {
43530
+ return {
43531
+ type: "url",
43532
+ url: dataContent
43533
+ };
43534
+ }
43535
+ if (dataContent.startsWith("data:")) {
43536
+ const { mediaType, base64Content } = splitDataUrl(dataContent);
43537
+ return {
42673
43538
  type: "file",
42674
- mediaType,
42675
- data: dataContent
43539
+ mediaType: mediaType != null ? mediaType : "image/png",
43540
+ data: convertBase64ToUint8Array(base64Content != null ? base64Content : "")
42676
43541
  };
42677
43542
  }
43543
+ const bytes2 = convertBase64ToUint8Array(dataContent);
43544
+ return {
43545
+ type: "file",
43546
+ mediaType: (_a222 = detectMediaType({
43547
+ data: bytes2,
43548
+ signatures: imageMediaTypeSignatures
43549
+ })) != null ? _a222 : "image/png",
43550
+ data: bytes2
43551
+ };
42678
43552
  }
43553
+ const bytes = convertDataContentToUint8Array(dataContent);
42679
43554
  return {
42680
- prompt: promptArg.text,
42681
- image
43555
+ type: "file",
43556
+ mediaType: (_b16 = detectMediaType({ data: bytes, signatures: imageMediaTypeSignatures })) != null ? _b16 : "image/png",
43557
+ data: bytes
42682
43558
  };
42683
43559
  }
42684
43560
  async function invokeModelMaxVideosPerCall(model) {
@@ -42711,8 +43587,8 @@ function defaultTransform(text2) {
42711
43587
  return text2.replace(/^```(?:json)?\s*\n?/, "").replace(/\n?```\s*$/, "").trim();
42712
43588
  }
42713
43589
  function extractJsonMiddleware(options) {
42714
- var _a21;
42715
- const transform2 = (_a21 = options == null ? undefined : options.transform) != null ? _a21 : defaultTransform;
43590
+ var _a222;
43591
+ const transform2 = (_a222 = options == null ? undefined : options.transform) != null ? _a222 : defaultTransform;
42716
43592
  const hasCustomTransform = (options == null ? undefined : options.transform) !== undefined;
42717
43593
  return {
42718
43594
  specificationVersion: "v3",
@@ -42733,7 +43609,7 @@ function extractJsonMiddleware(options) {
42733
43609
  },
42734
43610
  wrapStream: async ({ doStream }) => {
42735
43611
  const { stream, ...rest } = await doStream();
42736
- const textBlocks = {};
43612
+ const textBlocks = createIdMap();
42737
43613
  const SUFFIX_BUFFER_SIZE = 12;
42738
43614
  return {
42739
43615
  stream: stream.pipeThrough(new TransformStream({
@@ -42887,7 +43763,7 @@ function extractReasoningMiddleware({
42887
43763
  },
42888
43764
  wrapStream: async ({ doStream }) => {
42889
43765
  const { stream, ...rest } = await doStream();
42890
- const reasoningExtractions = {};
43766
+ const reasoningExtractions = createIdMap();
42891
43767
  let delayedTextStart;
42892
43768
  return {
42893
43769
  stream: stream.pipeThrough(new TransformStream({
@@ -43066,13 +43942,13 @@ function addToolInputExamplesMiddleware({
43066
43942
  return {
43067
43943
  specificationVersion: "v3",
43068
43944
  transformParams: async ({ params }) => {
43069
- var _a21;
43070
- if (!((_a21 = params.tools) == null ? undefined : _a21.length)) {
43945
+ var _a222;
43946
+ if (!((_a222 = params.tools) == null ? undefined : _a222.length)) {
43071
43947
  return params;
43072
43948
  }
43073
43949
  const transformedTools = params.tools.map((tool2) => {
43074
- var _a222;
43075
- if (tool2.type !== "function" || !((_a222 = tool2.inputExamples) == null ? undefined : _a222.length)) {
43950
+ var _a232;
43951
+ if (tool2.type !== "function" || !((_a232 = tool2.inputExamples) == null ? undefined : _a232.length)) {
43076
43952
  return tool2;
43077
43953
  }
43078
43954
  const formattedExamples = tool2.inputExamples.map((example, index) => format(example, index)).join(`
@@ -43278,7 +44154,7 @@ async function rerank({
43278
44154
  }),
43279
44155
  tracer,
43280
44156
  fn: async () => {
43281
- var _a21, _b16;
44157
+ var _a222, _b16;
43282
44158
  const { ranking, response, providerMetadata, warnings } = await retry(() => recordSpan({
43283
44159
  name: "ai.rerank.doRerank",
43284
44160
  attributes: selectTelemetryAttributes({
@@ -43337,7 +44213,7 @@ async function rerank({
43337
44213
  providerMetadata,
43338
44214
  response: {
43339
44215
  id: response == null ? undefined : response.id,
43340
- timestamp: (_a21 = response == null ? undefined : response.timestamp) != null ? _a21 : /* @__PURE__ */ new Date,
44216
+ timestamp: (_a222 = response == null ? undefined : response.timestamp) != null ? _a222 : /* @__PURE__ */ new Date,
43341
44217
  modelId: (_b16 = response == null ? undefined : response.modelId) != null ? _b16 : model.modelId,
43342
44218
  headers: response == null ? undefined : response.headers,
43343
44219
  body: response == null ? undefined : response.body
@@ -43366,16 +44242,16 @@ async function transcribe({
43366
44242
  const headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION6}`);
43367
44243
  const audioData = audio instanceof URL ? (await downloadFn({ url: audio, abortSignal })).data : convertDataContentToUint8Array(audio);
43368
44244
  const result = await retry(() => {
43369
- var _a21;
44245
+ var _a222;
43370
44246
  return resolvedModel.doGenerate({
43371
44247
  audio: audioData,
43372
44248
  abortSignal,
43373
44249
  headers: headersWithUserAgent,
43374
44250
  providerOptions,
43375
- mediaType: (_a21 = detectMediaType({
44251
+ mediaType: (_a222 = detectMediaType({
43376
44252
  data: audioData,
43377
44253
  signatures: audioMediaTypeSignatures
43378
- })) != null ? _a21 : "audio/wav"
44254
+ })) != null ? _a222 : "audio/wav"
43379
44255
  });
43380
44256
  });
43381
44257
  logWarnings({
@@ -43424,7 +44300,7 @@ async function callCompletionApi({
43424
44300
  onError,
43425
44301
  fetch: fetch2 = getOriginalFetch3()
43426
44302
  }) {
43427
- var _a21;
44303
+ var _a222;
43428
44304
  try {
43429
44305
  setLoading(true);
43430
44306
  setError(undefined);
@@ -43447,7 +44323,7 @@ async function callCompletionApi({
43447
44323
  throw err;
43448
44324
  });
43449
44325
  if (!response.ok) {
43450
- throw new Error((_a21 = await response.text()) != null ? _a21 : "Failed to fetch the chat response.");
44326
+ throw new Error((_a222 = await response.text()) != null ? _a222 : "Failed to fetch the chat response.");
43451
44327
  }
43452
44328
  if (!response.body) {
43453
44329
  throw new Error("The response body is empty.");
@@ -43522,12 +44398,12 @@ async function convertFileListToFileUIParts(files) {
43522
44398
  throw new Error("FileList is not supported in the current environment");
43523
44399
  }
43524
44400
  return Promise.all(Array.from(files).map(async (file2) => {
43525
- const { name: name21, type } = file2;
44401
+ const { name: name222, type } = file2;
43526
44402
  const dataUrl = await new Promise((resolve32, reject) => {
43527
44403
  const reader = new FileReader;
43528
44404
  reader.onload = (readerEvent) => {
43529
- var _a21;
43530
- resolve32((_a21 = readerEvent.target) == null ? undefined : _a21.result);
44405
+ var _a222;
44406
+ resolve32((_a222 = readerEvent.target) == null ? undefined : _a222.result);
43531
44407
  };
43532
44408
  reader.onerror = (error40) => reject(error40);
43533
44409
  reader.readAsDataURL(file2);
@@ -43535,7 +44411,7 @@ async function convertFileListToFileUIParts(files) {
43535
44411
  return {
43536
44412
  type: "file",
43537
44413
  mediaType: type,
43538
- filename: name21,
44414
+ filename: name222,
43539
44415
  url: dataUrl
43540
44416
  };
43541
44417
  }));
@@ -43592,9 +44468,9 @@ function transformTextToUiMessageStream({
43592
44468
  }));
43593
44469
  }
43594
44470
  var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
43595
- for (var name21 in all)
43596
- __defProp2(target, name21, { get: all[name21], enumerable: true });
43597
- }, name17 = "AI_InvalidArgumentError", marker18, symbol19, _a18, InvalidArgumentError2, name23 = "AI_InvalidStreamPartError", marker23, symbol23, _a23, InvalidStreamPartError, name33 = "AI_InvalidToolApprovalError", marker33, symbol33, _a33, InvalidToolApprovalError, name43 = "AI_InvalidToolInputError", marker43, symbol43, _a43, InvalidToolInputError, name53 = "AI_ToolCallNotFoundForApprovalError", marker53, symbol53, _a53, ToolCallNotFoundForApprovalError, name63 = "AI_MissingToolResultsError", marker63, symbol63, _a63, MissingToolResultsError, name73 = "AI_NoImageGeneratedError", marker73, symbol73, _a73, NoImageGeneratedError, name83 = "AI_NoObjectGeneratedError", marker83, symbol83, _a83, NoObjectGeneratedError, name92 = "AI_NoOutputGeneratedError", marker93, symbol93, _a93, NoOutputGeneratedError, name102 = "AI_NoSpeechGeneratedError", marker102, symbol102, _a102, NoSpeechGeneratedError, name112 = "AI_NoTranscriptGeneratedError", marker112, symbol112, _a112, NoTranscriptGeneratedError, name122 = "AI_NoVideoGeneratedError", marker122, symbol122, _a122, NoVideoGeneratedError, name132 = "AI_NoSuchToolError", marker132, symbol132, _a132, NoSuchToolError, name142 = "AI_ToolCallRepairError", marker142, symbol142, _a142, ToolCallRepairError, UnsupportedModelVersionError, name15 = "AI_UIMessageStreamError", marker152, symbol152, _a152, UIMessageStreamError, name162 = "AI_InvalidDataContentError", marker16, symbol16, _a16, InvalidDataContentError, name172 = "AI_InvalidMessageRoleError", marker172, symbol172, _a172, InvalidMessageRoleError, name18 = "AI_MessageConversionError", marker182, symbol182, _a182, MessageConversionError, name19 = "AI_RetryError", marker19, symbol192, _a19, RetryError, FIRST_WARNING_INFO_MESSAGE = "AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.", hasLoggedBefore = false, logWarnings = (options) => {
44471
+ for (var name222 in all)
44472
+ __defProp2(target, name222, { get: all[name222], enumerable: true });
44473
+ }, name17 = "AI_InvalidArgumentError", marker18, symbol19, _a18, InvalidArgumentError2, name23 = "AI_InvalidStreamPartError", marker23, symbol23, _a23, InvalidStreamPartError, name33 = "AI_InvalidToolApprovalError", marker33, symbol33, _a33, InvalidToolApprovalError, name43 = "AI_InvalidToolApprovalSignatureError", marker43, symbol43, _a43, InvalidToolApprovalSignatureError, name53 = "AI_InvalidToolInputError", marker53, symbol53, _a53, InvalidToolInputError, name63 = "AI_ToolCallNotFoundForApprovalError", marker63, symbol63, _a63, ToolCallNotFoundForApprovalError, name73 = "AI_MissingToolResultsError", marker73, symbol73, _a73, MissingToolResultsError, name83 = "AI_NoImageGeneratedError", marker83, symbol83, _a83, NoImageGeneratedError, name93 = "AI_NoObjectGeneratedError", marker93, symbol93, _a93, NoObjectGeneratedError, name102 = "AI_NoOutputGeneratedError", marker103, symbol103, _a103, NoOutputGeneratedError, name112 = "AI_NoSpeechGeneratedError", marker112, symbol112, _a112, NoSpeechGeneratedError, name122 = "AI_NoTranscriptGeneratedError", marker122, symbol122, _a122, NoTranscriptGeneratedError, name132 = "AI_NoVideoGeneratedError", marker132, symbol132, _a132, NoVideoGeneratedError, name142 = "AI_NoSuchToolError", marker142, symbol142, _a142, NoSuchToolError, name15 = "AI_ToolCallRepairError", marker152, symbol152, _a152, ToolCallRepairError, UnsupportedModelVersionError, name162 = "AI_UIMessageStreamError", marker16, symbol16, _a16, UIMessageStreamError, name172 = "AI_InvalidDataContentError", marker172, symbol172, _a172, InvalidDataContentError, name18 = "AI_InvalidMessageRoleError", marker182, symbol182, _a182, InvalidMessageRoleError, name19 = "AI_MessageConversionError", marker19, symbol192, _a19, MessageConversionError, name20 = "AI_RetryError", marker20, symbol20, _a20, RetryError, FIRST_WARNING_INFO_MESSAGE = "AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.", hasLoggedBefore = false, logWarnings = (options) => {
43598
44474
  if (options.warnings.length === 0) {
43599
44475
  return;
43600
44476
  }
@@ -43621,23 +44497,22 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
43621
44497
  const bytes = typeof data === "string" ? convertBase64ToUint8Array(data) : data;
43622
44498
  const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
43623
44499
  return bytes.slice(id3Size + 10);
43624
- }, VERSION6 = "6.0.199", download = async ({
44500
+ }, VERSION6 = "6.0.219", download = async ({
43625
44501
  url: url2,
43626
44502
  maxBytes,
43627
44503
  abortSignal
43628
44504
  }) => {
43629
- var _a21;
44505
+ var _a222;
43630
44506
  const urlText = url2.toString();
43631
- validateDownloadUrl(urlText);
43632
44507
  try {
43633
- const response = await fetch(urlText, {
43634
- headers: withUserAgentSuffix({}, `ai-sdk/${VERSION6}`, getRuntimeEnvironmentUserAgent()),
43635
- signal: abortSignal
44508
+ const headers = withUserAgentSuffix({}, `ai-sdk/${VERSION6}`, getRuntimeEnvironmentUserAgent());
44509
+ const response = await fetchWithValidatedRedirects({
44510
+ url: urlText,
44511
+ headers,
44512
+ abortSignal
43636
44513
  });
43637
- if (response.redirected) {
43638
- validateDownloadUrl(response.url);
43639
- }
43640
44514
  if (!response.ok) {
44515
+ await cancelResponseBody(response);
43641
44516
  throw new DownloadError({
43642
44517
  url: urlText,
43643
44518
  statusCode: response.status,
@@ -43651,7 +44526,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
43651
44526
  });
43652
44527
  return {
43653
44528
  data,
43654
- mediaType: (_a21 = response.headers.get("content-type")) != null ? _a21 : undefined
44529
+ mediaType: (_a222 = response.headers.get("content-type")) != null ? _a222 : undefined
43655
44530
  };
43656
44531
  } catch (error40) {
43657
44532
  if (DownloadError.isInstance(error40)) {
@@ -43664,11 +44539,17 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
43664
44539
  initialDelayInMs = 2000,
43665
44540
  backoffFactor = 2,
43666
44541
  abortSignal
43667
- } = {}) => async (f) => _retryWithExponentialBackoff(f, {
44542
+ } = {}) => retryWithExponentialBackoff({
43668
44543
  maxRetries,
43669
- delayInMs: initialDelayInMs,
44544
+ initialDelayInMs,
43670
44545
  backoffFactor,
43671
- abortSignal
44546
+ abortSignal,
44547
+ shouldRetry: (error40) => error40 instanceof Error && (APICallError.isInstance(error40) && error40.isRetryable === true || GatewayError.isInstance(error40) && error40.isRetryable === true),
44548
+ getDelayInMs: ({ error: error40, exponentialBackoffDelay }) => getRetryDelayInMs({
44549
+ error: error40,
44550
+ exponentialBackoffDelay
44551
+ }),
44552
+ createRetryError: ({ message, reason, errors: errors4 }) => new RetryError({ message, reason, errors: errors4 })
43672
44553
  }), DefaultGeneratedFile = class {
43673
44554
  constructor({
43674
44555
  data,
@@ -43691,7 +44572,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
43691
44572
  }
43692
44573
  return this.uint8ArrayData;
43693
44574
  }
43694
- }, DefaultGeneratedFileWithType, output_exports, text = () => ({
44575
+ }, DefaultGeneratedFileWithType, encoder, output_exports, text = () => ({
43695
44576
  name: "text",
43696
44577
  responseFormat: Promise.resolve({ type: "text" }),
43697
44578
  async parseCompleteOutput({ text: text2 }) {
@@ -43705,7 +44586,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
43705
44586
  }
43706
44587
  }), object2 = ({
43707
44588
  schema: inputSchema,
43708
- name: name21,
44589
+ name: name222,
43709
44590
  description
43710
44591
  }) => {
43711
44592
  const schema = asSchema(inputSchema);
@@ -43714,7 +44595,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
43714
44595
  responseFormat: resolve3(schema.jsonSchema).then((jsonSchema2) => ({
43715
44596
  type: "json",
43716
44597
  schema: jsonSchema2,
43717
- ...name21 != null && { name: name21 },
44598
+ ...name222 != null && { name: name222 },
43718
44599
  ...description != null && { description }
43719
44600
  })),
43720
44601
  async parseCompleteOutput({ text: text2 }, context2) {
@@ -43766,7 +44647,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
43766
44647
  };
43767
44648
  }, array2 = ({
43768
44649
  element: inputElementSchema,
43769
- name: name21,
44650
+ name: name222,
43770
44651
  description
43771
44652
  }) => {
43772
44653
  const elementSchema = asSchema(inputElementSchema);
@@ -43785,7 +44666,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
43785
44666
  required: ["elements"],
43786
44667
  additionalProperties: false
43787
44668
  },
43788
- ...name21 != null && { name: name21 },
44669
+ ...name222 != null && { name: name222 },
43789
44670
  ...description != null && { description }
43790
44671
  };
43791
44672
  }),
@@ -43876,7 +44757,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
43876
44757
  };
43877
44758
  }, choice = ({
43878
44759
  options: choiceOptions,
43879
- name: name21,
44760
+ name: name222,
43880
44761
  description
43881
44762
  }) => {
43882
44763
  return {
@@ -43892,7 +44773,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
43892
44773
  required: ["result"],
43893
44774
  additionalProperties: false
43894
44775
  },
43895
- ...name21 != null && { name: name21 },
44776
+ ...name222 != null && { name: name222 },
43896
44777
  ...description != null && { description }
43897
44778
  }),
43898
44779
  async parseCompleteOutput({ text: text2 }, context2) {
@@ -43950,14 +44831,14 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
43950
44831
  }
43951
44832
  };
43952
44833
  }, json2 = ({
43953
- name: name21,
44834
+ name: name222,
43954
44835
  description
43955
44836
  } = {}) => {
43956
44837
  return {
43957
44838
  name: "json",
43958
44839
  responseFormat: Promise.resolve({
43959
44840
  type: "json",
43960
- ...name21 != null && { name: name21 },
44841
+ ...name222 != null && { name: name222 },
43961
44842
  ...description != null && { description }
43962
44843
  }),
43963
44844
  async parseCompleteOutput({ text: text2 }, context2) {
@@ -44129,7 +45010,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44129
45010
  }
44130
45011
  return this._output;
44131
45012
  }
44132
- }, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS, toolMetadataSchema, uiMessageChunkSchema, isToolOrDynamicToolUIPart, getToolOrDynamicToolName, originalGenerateId2, DefaultStreamTextResult = class {
45013
+ }, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS, toolMetadataSchema, uiMessageChunkSchema, isToolOrDynamicToolUIPart, getToolOrDynamicToolName, originalGenerateId2, isOutputChunkType, DefaultStreamTextResult = class {
44133
45014
  constructor({
44134
45015
  model,
44135
45016
  telemetry,
@@ -44170,6 +45051,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44170
45051
  onToolCallStart,
44171
45052
  onToolCallFinish,
44172
45053
  experimental_context,
45054
+ experimental_toolApprovalSecret,
44173
45055
  download: download2,
44174
45056
  include
44175
45057
  }) {
@@ -44191,20 +45073,25 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44191
45073
  let recordedRequest = {};
44192
45074
  let recordedWarnings = [];
44193
45075
  const recordedSteps = [];
45076
+ let recordedNoOutputError;
44194
45077
  const pendingDeferredToolCalls = /* @__PURE__ */ new Map;
44195
45078
  let rootSpan;
44196
- let activeTextContent = {};
44197
- let activeReasoningContent = {};
45079
+ let activeTextContent = createIdMap();
45080
+ let activeReasoningContent = createIdMap();
44198
45081
  const eventProcessor = new TransformStream({
44199
45082
  async transform(chunk, controller) {
44200
- var _a21, _b16, _c, _d;
45083
+ var _a222, _b16, _c, _d;
44201
45084
  controller.enqueue(chunk);
44202
45085
  const { part } = chunk;
44203
45086
  if (part.type === "text-delta" || part.type === "reasoning-delta" || part.type === "source" || part.type === "tool-call" || part.type === "tool-result" || part.type === "tool-input-start" || part.type === "tool-input-delta" || part.type === "raw") {
44204
45087
  await (onChunk == null ? undefined : onChunk({ chunk: part }));
44205
45088
  }
44206
45089
  if (part.type === "error") {
44207
- await onError({ error: wrapGatewayError(part.error) });
45090
+ const error40 = wrapGatewayError(part.error);
45091
+ if (NoOutputGeneratedError.isInstance(error40)) {
45092
+ recordedNoOutputError = error40;
45093
+ }
45094
+ await onError({ error: error40 });
44208
45095
  }
44209
45096
  if (part.type === "text-start") {
44210
45097
  activeTextContent[part.id] = {
@@ -44227,7 +45114,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44227
45114
  return;
44228
45115
  }
44229
45116
  activeText.text += part.text;
44230
- activeText.providerMetadata = (_a21 = part.providerMetadata) != null ? _a21 : activeText.providerMetadata;
45117
+ activeText.providerMetadata = (_a222 = part.providerMetadata) != null ? _a222 : activeText.providerMetadata;
44231
45118
  }
44232
45119
  if (part.type === "text-end") {
44233
45120
  const activeText = activeTextContent[part.id];
@@ -44306,8 +45193,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44306
45193
  }
44307
45194
  if (part.type === "start-step") {
44308
45195
  recordedContent = [];
44309
- activeReasoningContent = {};
44310
- activeTextContent = {};
45196
+ activeReasoningContent = createIdMap();
45197
+ activeTextContent = createIdMap();
44311
45198
  recordedRequest = part.request;
44312
45199
  recordedWarnings = part.warnings;
44313
45200
  }
@@ -44353,10 +45240,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44353
45240
  }
44354
45241
  },
44355
45242
  async flush(controller) {
44356
- var _a21, _b16, _c, _d, _e, _f, _g;
45243
+ var _a222, _b16, _c, _d, _e, _f, _g;
44357
45244
  try {
44358
- if (recordedSteps.length === 0) {
44359
- const error40 = (abortSignal == null ? undefined : abortSignal.aborted) ? abortSignal.reason : new NoOutputGeneratedError({
45245
+ if (recordedSteps.length === 0 || recordedNoOutputError != null) {
45246
+ const error40 = (abortSignal == null ? undefined : abortSignal.aborted) ? abortSignal.reason : recordedNoOutputError != null ? recordedNoOutputError : new NoOutputGeneratedError({
44360
45247
  message: "No output generated. Check the stream for errors."
44361
45248
  });
44362
45249
  self2._finishReason.reject(error40);
@@ -44416,13 +45303,13 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44416
45303
  },
44417
45304
  "ai.response.toolCalls": {
44418
45305
  output: () => {
44419
- var _a222;
44420
- return ((_a222 = finalStep.toolCalls) == null ? undefined : _a222.length) ? JSON.stringify(finalStep.toolCalls) : undefined;
45306
+ var _a232;
45307
+ return ((_a232 = finalStep.toolCalls) == null ? undefined : _a232.length) ? JSON.stringify(finalStep.toolCalls) : undefined;
44421
45308
  }
44422
45309
  },
44423
45310
  "ai.response.providerMetadata": JSON.stringify(finalStep.providerMetadata),
44424
45311
  "ai.usage.inputTokens": totalUsage.inputTokens,
44425
- "ai.usage.inputTokenDetails.noCacheTokens": (_a21 = totalUsage.inputTokenDetails) == null ? undefined : _a21.noCacheTokens,
45312
+ "ai.usage.inputTokenDetails.noCacheTokens": (_a222 = totalUsage.inputTokenDetails) == null ? undefined : _a222.noCacheTokens,
44426
45313
  "ai.usage.inputTokenDetails.cacheReadTokens": (_b16 = totalUsage.inputTokenDetails) == null ? undefined : _b16.cacheReadTokens,
44427
45314
  "ai.usage.inputTokenDetails.cacheWriteTokens": (_c = totalUsage.inputTokenDetails) == null ? undefined : _c.cacheWriteTokens,
44428
45315
  "ai.usage.outputTokens": totalUsage.outputTokens,
@@ -44566,8 +45453,20 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44566
45453
  const initialResponseMessages = [];
44567
45454
  const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
44568
45455
  if (deniedToolApprovals.length > 0 || approvedToolApprovals.length > 0) {
44569
- const localApprovedToolApprovals = approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted);
44570
- const localDeniedToolApprovals = deniedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted);
45456
+ const {
45457
+ approvedToolApprovals: localApprovedToolApprovals,
45458
+ deniedToolApprovals: revalidationDeniedToolApprovals
45459
+ } = await validateApprovedToolApprovals({
45460
+ approvedToolApprovals: approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted),
45461
+ tools,
45462
+ messages: initialMessages,
45463
+ experimental_context,
45464
+ toolApprovalSecret: experimental_toolApprovalSecret
45465
+ });
45466
+ const localDeniedToolApprovals = [
45467
+ ...deniedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted),
45468
+ ...revalidationDeniedToolApprovals
45469
+ ];
44571
45470
  const deniedProviderExecutedToolApprovals = deniedToolApprovals.filter((toolApproval) => toolApproval.toolCall.providerExecuted);
44572
45471
  let toolExecutionStepStreamController;
44573
45472
  const toolExecutionStepStream = new ReadableStream({
@@ -44658,7 +45557,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44658
45557
  responseMessages,
44659
45558
  usage
44660
45559
  }) {
44661
- var _a21, _b16, _c, _d, _e, _f, _g, _h, _i;
45560
+ var _a222, _b16, _c, _d, _e, _f, _g, _h, _i;
44662
45561
  const includeRawChunks2 = self2.includeRawChunks;
44663
45562
  const stepTimeoutId = stepTimeoutMs != null ? setTimeout(() => stepAbortController.abort(), stepTimeoutMs) : undefined;
44664
45563
  let chunkTimeoutId = undefined;
@@ -44691,7 +45590,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44691
45590
  messages: stepInputMessages,
44692
45591
  experimental_context
44693
45592
  }));
44694
- const stepModel = resolveLanguageModel((_a21 = prepareStepResult == null ? undefined : prepareStepResult.model) != null ? _a21 : model);
45593
+ const stepModel = resolveLanguageModel((_a222 = prepareStepResult == null ? undefined : prepareStepResult.model) != null ? _a222 : model);
44695
45594
  const stepModelInfo = {
44696
45595
  provider: stepModel.provider,
44697
45596
  modelId: stepModel.modelId
@@ -44803,6 +45702,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44803
45702
  repairToolCall,
44804
45703
  abortSignal,
44805
45704
  experimental_context,
45705
+ toolApprovalSecret: experimental_toolApprovalSecret,
44806
45706
  generateId: generateId2,
44807
45707
  stepNumber: recordedSteps.length,
44808
45708
  model: stepModelInfo,
@@ -44822,6 +45722,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44822
45722
  const activeToolCallToolNames = {};
44823
45723
  let stepFinishReason = "other";
44824
45724
  let stepRawFinishReason = undefined;
45725
+ let hasReceivedTerminalChunk = false;
45726
+ let hasReceivedOutputChunk = false;
44825
45727
  let stepUsage = createNullLanguageModelUsage();
44826
45728
  let stepProviderMetadata;
44827
45729
  let stepFirstChunk = true;
@@ -44833,7 +45735,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44833
45735
  let activeText = "";
44834
45736
  self2.addStream(streamWithToolResults.pipeThrough(new TransformStream({
44835
45737
  async transform(chunk, controller) {
44836
- var _a222, _b23, _c2, _d2, _e2;
45738
+ var _a232, _b23, _c2, _d2, _e2;
44837
45739
  resetChunkTimeout();
44838
45740
  if (chunk.type === "stream-start") {
44839
45741
  warnings = chunk.warnings;
@@ -44855,6 +45757,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44855
45757
  });
44856
45758
  }
44857
45759
  const chunkType = chunk.type;
45760
+ if (isOutputChunkType[chunkType]) {
45761
+ hasReceivedOutputChunk = true;
45762
+ }
44858
45763
  switch (chunkType) {
44859
45764
  case "tool-approval-request":
44860
45765
  case "text-start":
@@ -44907,13 +45812,14 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44907
45812
  }
44908
45813
  case "response-metadata": {
44909
45814
  stepResponse = {
44910
- id: (_a222 = chunk.id) != null ? _a222 : stepResponse.id,
45815
+ id: (_a232 = chunk.id) != null ? _a232 : stepResponse.id,
44911
45816
  timestamp: (_b23 = chunk.timestamp) != null ? _b23 : stepResponse.timestamp,
44912
45817
  modelId: (_c2 = chunk.modelId) != null ? _c2 : stepResponse.modelId
44913
45818
  };
44914
45819
  break;
44915
45820
  }
44916
45821
  case "finish": {
45822
+ hasReceivedTerminalChunk = true;
44917
45823
  stepUsage = chunk.usage;
44918
45824
  stepFinishReason = chunk.finishReason;
44919
45825
  stepRawFinishReason = chunk.rawFinishReason;
@@ -44973,6 +45879,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44973
45879
  break;
44974
45880
  }
44975
45881
  case "error": {
45882
+ hasReceivedTerminalChunk = true;
44976
45883
  controller.enqueue(chunk);
44977
45884
  stepFinishReason = "error";
44978
45885
  break;
@@ -44990,7 +45897,20 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
44990
45897
  }
44991
45898
  },
44992
45899
  async flush(controller) {
44993
- var _a222, _b23, _c2, _d2, _e2, _f2, _g2;
45900
+ var _a232, _b23, _c2, _d2, _e2, _f2, _g2;
45901
+ if (!hasReceivedTerminalChunk && !hasReceivedOutputChunk) {
45902
+ controller.enqueue({
45903
+ type: "error",
45904
+ error: new NoOutputGeneratedError({
45905
+ message: "No output generated. The model stream ended without a finish chunk."
45906
+ })
45907
+ });
45908
+ doStreamSpan.end();
45909
+ clearStepTimeout();
45910
+ clearChunkTimeout();
45911
+ self2.closeStream();
45912
+ return;
45913
+ }
44994
45914
  const stepToolCallsJson = stepToolCalls.length > 0 ? JSON.stringify(stepToolCalls) : undefined;
44995
45915
  try {
44996
45916
  doStreamSpan.setAttributes(await selectTelemetryAttributes({
@@ -45004,7 +45924,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
45004
45924
  "ai.response.model": stepResponse.modelId,
45005
45925
  "ai.response.timestamp": stepResponse.timestamp.toISOString(),
45006
45926
  "ai.usage.inputTokens": stepUsage.inputTokens,
45007
- "ai.usage.inputTokenDetails.noCacheTokens": (_a222 = stepUsage.inputTokenDetails) == null ? undefined : _a222.noCacheTokens,
45927
+ "ai.usage.inputTokenDetails.noCacheTokens": (_a232 = stepUsage.inputTokenDetails) == null ? undefined : _a232.noCacheTokens,
45008
45928
  "ai.usage.inputTokenDetails.cacheReadTokens": (_b23 = stepUsage.inputTokenDetails) == null ? undefined : _b23.cacheReadTokens,
45009
45929
  "ai.usage.inputTokenDetails.cacheWriteTokens": (_c2 = stepUsage.inputTokenDetails) == null ? undefined : _c2.cacheWriteTokens,
45010
45930
  "ai.usage.outputTokens": stepUsage.outputTokens,
@@ -45219,15 +46139,30 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
45219
46139
  }
45220
46140
  })));
45221
46141
  }
46142
+ rejectResultPromises(error40) {
46143
+ if (this._finishReason.isPending())
46144
+ this._finishReason.reject(error40);
46145
+ if (this._rawFinishReason.isPending())
46146
+ this._rawFinishReason.reject(error40);
46147
+ if (this._totalUsage.isPending())
46148
+ this._totalUsage.reject(error40);
46149
+ if (this._steps.isPending())
46150
+ this._steps.reject(error40);
46151
+ }
45222
46152
  async consumeStream(options) {
45223
- var _a21;
46153
+ var _a222;
45224
46154
  try {
45225
46155
  await consumeStream({
45226
46156
  stream: this.fullStream,
45227
- onError: options == null ? undefined : options.onError
46157
+ onError: (error40) => {
46158
+ var _a232;
46159
+ this.rejectResultPromises(error40);
46160
+ (_a232 = options == null ? undefined : options.onError) == null || _a232.call(options, error40);
46161
+ }
45228
46162
  });
45229
46163
  } catch (error40) {
45230
- (_a21 = options == null ? undefined : options.onError) == null || _a21.call(options, error40);
46164
+ this.rejectResultPromises(error40);
46165
+ (_a222 = options == null ? undefined : options.onError) == null || _a222.call(options, error40);
45231
46166
  }
45232
46167
  }
45233
46168
  get experimental_partialOutputStream() {
@@ -45243,8 +46178,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
45243
46178
  })));
45244
46179
  }
45245
46180
  get elementStream() {
45246
- var _a21, _b16, _c;
45247
- const transform2 = (_a21 = this.outputSpecification) == null ? undefined : _a21.createElementStreamTransform();
46181
+ var _a222, _b16, _c;
46182
+ const transform2 = (_a222 = this.outputSpecification) == null ? undefined : _a222.createElementStreamTransform();
45248
46183
  if (transform2 == null) {
45249
46184
  throw new UnsupportedFunctionalityError({
45250
46185
  functionality: `element streams in ${(_c = (_b16 = this.outputSpecification) == null ? undefined : _b16.name) != null ? _c : "text"} mode`
@@ -45254,8 +46189,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
45254
46189
  }
45255
46190
  get output() {
45256
46191
  return this.finalStep.then((step) => {
45257
- var _a21;
45258
- const output = (_a21 = this.outputSpecification) != null ? _a21 : text();
46192
+ var _a222;
46193
+ const output = (_a222 = this.outputSpecification) != null ? _a222 : text();
45259
46194
  return output.parseCompleteOutput({ text: step.text }, {
45260
46195
  response: step.response,
45261
46196
  usage: step.usage,
@@ -45272,15 +46207,15 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
45272
46207
  sendSources = false,
45273
46208
  sendStart = true,
45274
46209
  sendFinish = true,
45275
- onError = getErrorMessage
46210
+ onError = () => "An error occurred."
45276
46211
  } = {}) {
45277
46212
  const responseMessageId = generateMessageId != null ? getResponseUIMessageId({
45278
46213
  originalMessages,
45279
46214
  responseMessageId: generateMessageId
45280
46215
  }) : undefined;
45281
46216
  const isDynamic = (part) => {
45282
- var _a21;
45283
- const tool2 = (_a21 = this.tools) == null ? undefined : _a21[part.toolName];
46217
+ var _a222;
46218
+ const tool2 = (_a222 = this.tools) == null ? undefined : _a222[part.toolName];
45284
46219
  if (tool2 == null) {
45285
46220
  return part.dynamic;
45286
46221
  }
@@ -45425,7 +46360,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
45425
46360
  controller.enqueue({
45426
46361
  type: "tool-approval-request",
45427
46362
  approvalId: part.approvalId,
45428
- toolCallId: part.toolCall.toolCallId
46363
+ toolCallId: part.toolCall.toolCallId,
46364
+ ...part.signature != null ? { signature: part.signature } : {}
45429
46365
  });
45430
46366
  break;
45431
46367
  }
@@ -45434,7 +46370,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
45434
46370
  controller.enqueue({
45435
46371
  type: "tool-output-available",
45436
46372
  toolCallId: part.toolCallId,
45437
- output: part.output,
46373
+ output: part.output === undefined ? null : part.output,
45438
46374
  ...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
45439
46375
  ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
45440
46376
  ...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
@@ -45609,7 +46545,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
45609
46545
  return this.settings.tools;
45610
46546
  }
45611
46547
  async prepareCall(options) {
45612
- var _a21, _b16, _c, _d;
46548
+ var _a222, _b16, _c, _d;
45613
46549
  if (this.settings.callOptionsSchema != null && options.options !== undefined) {
45614
46550
  const validatedOptions = await validateTypes({
45615
46551
  value: options.options,
@@ -45621,7 +46557,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
45621
46557
  const { onStepFinish: _settingsOnStepFinish, ...settingsWithoutCallback } = this.settings;
45622
46558
  const baseCallArgs = {
45623
46559
  ...settingsWithoutCallback,
45624
- stopWhen: (_a21 = this.settings.stopWhen) != null ? _a21 : stepCountIs(20),
46560
+ stopWhen: (_a222 = this.settings.stopWhen) != null ? _a222 : stepCountIs(20),
45625
46561
  ...options
45626
46562
  };
45627
46563
  const preparedCallArgs = (_d = await ((_c = (_b16 = this.settings).prepareCall) == null ? undefined : _c.call(_b16, baseCallArgs))) != null ? _d : baseCallArgs;
@@ -45750,7 +46686,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
45750
46686
  isFirstDelta,
45751
46687
  isFinalDelta
45752
46688
  }) {
45753
- var _a21;
46689
+ var _a222;
45754
46690
  if (!isJSONObject(value) || !isJSONArray(value.elements)) {
45755
46691
  return {
45756
46692
  success: false,
@@ -45773,7 +46709,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
45773
46709
  }
45774
46710
  resultArray.push(result.value);
45775
46711
  }
45776
- const publishedElementCount = (_a21 = latestObject == null ? undefined : latestObject.length) != null ? _a21 : 0;
46712
+ const publishedElementCount = (_a222 = latestObject == null ? undefined : latestObject.length) != null ? _a222 : 0;
45777
46713
  let textDelta = "";
45778
46714
  if (isFirstDelta) {
45779
46715
  textDelta += "[";
@@ -45804,13 +46740,15 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
45804
46740
  };
45805
46741
  }
45806
46742
  const inputArray = value.elements;
46743
+ const resultArray = [];
45807
46744
  for (const element of inputArray) {
45808
46745
  const result = await safeValidateTypes({ value: element, schema });
45809
46746
  if (!result.success) {
45810
46747
  return result;
45811
46748
  }
46749
+ resultArray.push(result.value);
45812
46750
  }
45813
- return { success: true, value: inputArray };
46751
+ return { success: true, value: resultArray };
45814
46752
  },
45815
46753
  createElementStream(originalStream) {
45816
46754
  let publishedElements = 0;
@@ -45915,9 +46853,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
45915
46853
  this.reasoning = options.reasoning;
45916
46854
  }
45917
46855
  toJsonResponse(init) {
45918
- var _a21;
46856
+ var _a222;
45919
46857
  return new Response(JSON.stringify(this.object), {
45920
- status: (_a21 = init == null ? undefined : init.status) != null ? _a21 : 200,
46858
+ status: (_a222 = init == null ? undefined : init.status) != null ? _a222 : 200,
45921
46859
  headers: prepareHeaders(init == null ? undefined : init.headers, {
45922
46860
  "content-type": "application/json; charset=utf-8"
45923
46861
  })
@@ -46125,7 +47063,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46125
47063
  let isFirstDelta = true;
46126
47064
  const transformedStream = stream.pipeThrough(new TransformStream(transformer)).pipeThrough(new TransformStream({
46127
47065
  async transform(chunk, controller) {
46128
- var _a21, _b16, _c;
47066
+ var _a222, _b16, _c;
46129
47067
  if (typeof chunk === "object" && chunk.type === "stream-start") {
46130
47068
  warnings = chunk.warnings;
46131
47069
  return;
@@ -46172,7 +47110,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46172
47110
  switch (chunk.type) {
46173
47111
  case "response-metadata": {
46174
47112
  fullResponse = {
46175
- id: (_a21 = chunk.id) != null ? _a21 : fullResponse.id,
47113
+ id: (_a222 = chunk.id) != null ? _a222 : fullResponse.id,
46176
47114
  timestamp: (_b16 = chunk.timestamp) != null ? _b16 : fullResponse.timestamp,
46177
47115
  modelId: (_c = chunk.modelId) != null ? _c : fullResponse.modelId
46178
47116
  };
@@ -46380,11 +47318,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46380
47318
  }
46381
47319
  }, DefaultGeneratedAudioFile, DefaultSpeechResult = class {
46382
47320
  constructor(options) {
46383
- var _a21;
47321
+ var _a222;
46384
47322
  this.audio = options.audio;
46385
47323
  this.warnings = options.warnings;
46386
47324
  this.responses = options.responses;
46387
- this.providerMetadata = (_a21 = options.providerMetadata) != null ? _a21 : {};
47325
+ this.providerMetadata = (_a222 = options.providerMetadata) != null ? _a222 : {};
46388
47326
  }
46389
47327
  }, CHUNKING_REGEXPS, defaultDownload, wrapLanguageModel = ({
46390
47328
  model,
@@ -46408,7 +47346,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46408
47346
  modelId,
46409
47347
  providerId
46410
47348
  }) => {
46411
- var _a21, _b16, _c;
47349
+ var _a222, _b16, _c;
46412
47350
  async function doTransform({
46413
47351
  params,
46414
47352
  type
@@ -46417,7 +47355,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46417
47355
  }
46418
47356
  return {
46419
47357
  specificationVersion: "v3",
46420
- provider: (_a21 = providerId != null ? providerId : overrideProvider == null ? undefined : overrideProvider({ model })) != null ? _a21 : model.provider,
47358
+ provider: (_a222 = providerId != null ? providerId : overrideProvider == null ? undefined : overrideProvider({ model })) != null ? _a222 : model.provider,
46421
47359
  modelId: (_b16 = modelId != null ? modelId : overrideModelId == null ? undefined : overrideModelId({ model })) != null ? _b16 : model.modelId,
46422
47360
  supportedUrls: (_c = overrideSupportedUrls == null ? undefined : overrideSupportedUrls({ model })) != null ? _c : model.supportedUrls,
46423
47361
  async doGenerate(params) {
@@ -46460,7 +47398,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46460
47398
  modelId,
46461
47399
  providerId
46462
47400
  }) => {
46463
- var _a21, _b16, _c, _d;
47401
+ var _a222, _b16, _c, _d;
46464
47402
  async function doTransform({
46465
47403
  params
46466
47404
  }) {
@@ -46468,7 +47406,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46468
47406
  }
46469
47407
  return {
46470
47408
  specificationVersion: "v3",
46471
- provider: (_a21 = providerId != null ? providerId : overrideProvider == null ? undefined : overrideProvider({ model })) != null ? _a21 : model.provider,
47409
+ provider: (_a222 = providerId != null ? providerId : overrideProvider == null ? undefined : overrideProvider({ model })) != null ? _a222 : model.provider,
46472
47410
  modelId: (_b16 = modelId != null ? modelId : overrideModelId == null ? undefined : overrideModelId({ model })) != null ? _b16 : model.modelId,
46473
47411
  maxEmbeddingsPerCall: (_c = overrideMaxEmbeddingsPerCall == null ? undefined : overrideMaxEmbeddingsPerCall({ model })) != null ? _c : model.maxEmbeddingsPerCall,
46474
47412
  supportsParallelCalls: (_d = overrideSupportsParallelCalls == null ? undefined : overrideSupportsParallelCalls({ model })) != null ? _d : model.supportsParallelCalls,
@@ -46503,11 +47441,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46503
47441
  modelId,
46504
47442
  providerId
46505
47443
  }) => {
46506
- var _a21, _b16, _c;
47444
+ var _a222, _b16, _c;
46507
47445
  async function doTransform({ params }) {
46508
47446
  return transformParams ? await transformParams({ params, model }) : params;
46509
47447
  }
46510
- const maxImagesPerCallRaw = (_a21 = overrideMaxImagesPerCall == null ? undefined : overrideMaxImagesPerCall({ model })) != null ? _a21 : model.maxImagesPerCall;
47448
+ const maxImagesPerCallRaw = (_a222 = overrideMaxImagesPerCall == null ? undefined : overrideMaxImagesPerCall({ model })) != null ? _a222 : model.maxImagesPerCall;
46511
47449
  const maxImagesPerCall = maxImagesPerCallRaw instanceof Function ? maxImagesPerCallRaw.bind(model) : maxImagesPerCallRaw;
46512
47450
  return {
46513
47451
  specificationVersion: "v3",
@@ -46524,7 +47462,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46524
47462
  }) : doGenerate();
46525
47463
  }
46526
47464
  };
46527
- }, experimental_customProvider, name20 = "AI_NoSuchProviderError", marker20, symbol20, _a20, NoSuchProviderError, experimental_createProviderRegistry, DefaultProviderRegistry = class {
47465
+ }, experimental_customProvider, name21 = "AI_NoSuchProviderError", marker21, symbol21, _a21, NoSuchProviderError, experimental_createProviderRegistry, DefaultProviderRegistry = class {
46528
47466
  constructor({
46529
47467
  separator,
46530
47468
  languageModelMiddleware,
@@ -46565,9 +47503,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46565
47503
  return [id.slice(0, index), id.slice(index + this.separator.length)];
46566
47504
  }
46567
47505
  languageModel(id) {
46568
- var _a21, _b16;
47506
+ var _a222, _b16;
46569
47507
  const [providerId, modelId] = this.splitId(id, "languageModel");
46570
- let model = (_b16 = (_a21 = this.getProvider(providerId, "languageModel")).languageModel) == null ? undefined : _b16.call(_a21, modelId);
47508
+ let model = (_b16 = (_a222 = this.getProvider(providerId, "languageModel")).languageModel) == null ? undefined : _b16.call(_a222, modelId);
46571
47509
  if (model == null) {
46572
47510
  throw new NoSuchModelError({ modelId: id, modelType: "languageModel" });
46573
47511
  }
@@ -46580,10 +47518,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46580
47518
  return model;
46581
47519
  }
46582
47520
  embeddingModel(id) {
46583
- var _a21;
47521
+ var _a222;
46584
47522
  const [providerId, modelId] = this.splitId(id, "embeddingModel");
46585
47523
  const provider = this.getProvider(providerId, "embeddingModel");
46586
- const model = (_a21 = provider.embeddingModel) == null ? undefined : _a21.call(provider, modelId);
47524
+ const model = (_a222 = provider.embeddingModel) == null ? undefined : _a222.call(provider, modelId);
46587
47525
  if (model == null) {
46588
47526
  throw new NoSuchModelError({
46589
47527
  modelId: id,
@@ -46593,10 +47531,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46593
47531
  return model;
46594
47532
  }
46595
47533
  imageModel(id) {
46596
- var _a21;
47534
+ var _a222;
46597
47535
  const [providerId, modelId] = this.splitId(id, "imageModel");
46598
47536
  const provider = this.getProvider(providerId, "imageModel");
46599
- let model = (_a21 = provider.imageModel) == null ? undefined : _a21.call(provider, modelId);
47537
+ let model = (_a222 = provider.imageModel) == null ? undefined : _a222.call(provider, modelId);
46600
47538
  if (model == null) {
46601
47539
  throw new NoSuchModelError({ modelId: id, modelType: "imageModel" });
46602
47540
  }
@@ -46609,10 +47547,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46609
47547
  return model;
46610
47548
  }
46611
47549
  transcriptionModel(id) {
46612
- var _a21;
47550
+ var _a222;
46613
47551
  const [providerId, modelId] = this.splitId(id, "transcriptionModel");
46614
47552
  const provider = this.getProvider(providerId, "transcriptionModel");
46615
- const model = (_a21 = provider.transcriptionModel) == null ? undefined : _a21.call(provider, modelId);
47553
+ const model = (_a222 = provider.transcriptionModel) == null ? undefined : _a222.call(provider, modelId);
46616
47554
  if (model == null) {
46617
47555
  throw new NoSuchModelError({
46618
47556
  modelId: id,
@@ -46622,20 +47560,20 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46622
47560
  return model;
46623
47561
  }
46624
47562
  speechModel(id) {
46625
- var _a21;
47563
+ var _a222;
46626
47564
  const [providerId, modelId] = this.splitId(id, "speechModel");
46627
47565
  const provider = this.getProvider(providerId, "speechModel");
46628
- const model = (_a21 = provider.speechModel) == null ? undefined : _a21.call(provider, modelId);
47566
+ const model = (_a222 = provider.speechModel) == null ? undefined : _a222.call(provider, modelId);
46629
47567
  if (model == null) {
46630
47568
  throw new NoSuchModelError({ modelId: id, modelType: "speechModel" });
46631
47569
  }
46632
47570
  return model;
46633
47571
  }
46634
47572
  rerankingModel(id) {
46635
- var _a21;
47573
+ var _a222;
46636
47574
  const [providerId, modelId] = this.splitId(id, "rerankingModel");
46637
47575
  const provider = this.getProvider(providerId, "rerankingModel");
46638
- const model = (_a21 = provider.rerankingModel) == null ? undefined : _a21.call(provider, modelId);
47576
+ const model = (_a222 = provider.rerankingModel) == null ? undefined : _a222.call(provider, modelId);
46639
47577
  if (model == null) {
46640
47578
  throw new NoSuchModelError({ modelId: id, modelType: "rerankingModel" });
46641
47579
  }
@@ -46653,14 +47591,14 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46653
47591
  }
46654
47592
  }, defaultDownload2, DefaultTranscriptionResult = class {
46655
47593
  constructor(options) {
46656
- var _a21;
47594
+ var _a222;
46657
47595
  this.text = options.text;
46658
47596
  this.segments = options.segments;
46659
47597
  this.language = options.language;
46660
47598
  this.durationInSeconds = options.durationInSeconds;
46661
47599
  this.warnings = options.warnings;
46662
47600
  this.responses = options.responses;
46663
- this.providerMetadata = (_a21 = options.providerMetadata) != null ? _a21 : {};
47601
+ this.providerMetadata = (_a222 = options.providerMetadata) != null ? _a222 : {};
46664
47602
  }
46665
47603
  }, getOriginalFetch3 = () => fetch, HttpChatTransport = class {
46666
47604
  constructor({
@@ -46684,7 +47622,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46684
47622
  abortSignal,
46685
47623
  ...options
46686
47624
  }) {
46687
- var _a21, _b16, _c, _d, _e;
47625
+ var _a222, _b16, _c, _d, _e;
46688
47626
  const resolvedBody = await resolve3(this.body);
46689
47627
  const resolvedHeaders = await resolve3(this.headers);
46690
47628
  const resolvedCredentials = await resolve3(this.credentials);
@@ -46692,7 +47630,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46692
47630
  ...normalizeHeaders(resolvedHeaders),
46693
47631
  ...normalizeHeaders(options.headers)
46694
47632
  };
46695
- const preparedRequest = await ((_a21 = this.prepareSendMessagesRequest) == null ? undefined : _a21.call(this, {
47633
+ const preparedRequest = await ((_a222 = this.prepareSendMessagesRequest) == null ? undefined : _a222.call(this, {
46696
47634
  api: this.api,
46697
47635
  id: options.chatId,
46698
47636
  messages: options.messages,
@@ -46734,7 +47672,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46734
47672
  return this.processResponseStream(response.body);
46735
47673
  }
46736
47674
  async reconnectToStream(options) {
46737
- var _a21, _b16, _c, _d, _e;
47675
+ var _a222, _b16, _c, _d, _e;
46738
47676
  const resolvedBody = await resolve3(this.body);
46739
47677
  const resolvedHeaders = await resolve3(this.headers);
46740
47678
  const resolvedCredentials = await resolve3(this.credentials);
@@ -46742,7 +47680,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46742
47680
  ...normalizeHeaders(resolvedHeaders),
46743
47681
  ...normalizeHeaders(options.headers)
46744
47682
  };
46745
- const preparedRequest = await ((_a21 = this.prepareReconnectToStreamRequest) == null ? undefined : _a21.call(this, {
47683
+ const preparedRequest = await ((_a222 = this.prepareReconnectToStreamRequest) == null ? undefined : _a222.call(this, {
46746
47684
  api: this.api,
46747
47685
  id: options.chatId,
46748
47686
  body: { ...resolvedBody, ...options.body },
@@ -46787,11 +47725,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46787
47725
  this.activeResponse = undefined;
46788
47726
  this.jobExecutor = new SerialJobExecutor;
46789
47727
  this.sendMessage = async (message, options) => {
46790
- var _a21, _b16, _c, _d;
47728
+ var _a222, _b16, _c, _d;
46791
47729
  if (message == null) {
46792
47730
  await this.makeRequest({
46793
47731
  trigger: "submit-message",
46794
- messageId: (_a21 = this.lastMessage) == null ? undefined : _a21.id,
47732
+ messageId: (_a222 = this.lastMessage) == null ? undefined : _a222.id,
46795
47733
  ...options
46796
47734
  });
46797
47735
  return;
@@ -46883,11 +47821,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46883
47821
  }
46884
47822
  if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
46885
47823
  this.shouldSendAutomatically().then((shouldSend) => {
46886
- var _a21;
47824
+ var _a222;
46887
47825
  if (shouldSend) {
46888
47826
  this.makeRequest({
46889
47827
  trigger: "submit-message",
46890
- messageId: (_a21 = this.lastMessage) == null ? undefined : _a21.id,
47828
+ messageId: (_a222 = this.lastMessage) == null ? undefined : _a222.id,
46891
47829
  ...options
46892
47830
  });
46893
47831
  }
@@ -46913,11 +47851,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46913
47851
  }
46914
47852
  if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
46915
47853
  this.shouldSendAutomatically().then((shouldSend) => {
46916
- var _a21;
47854
+ var _a222;
46917
47855
  if (shouldSend) {
46918
47856
  this.makeRequest({
46919
47857
  trigger: "submit-message",
46920
- messageId: (_a21 = this.lastMessage) == null ? undefined : _a21.id,
47858
+ messageId: (_a222 = this.lastMessage) == null ? undefined : _a222.id,
46921
47859
  ...options
46922
47860
  });
46923
47861
  }
@@ -46926,10 +47864,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46926
47864
  });
46927
47865
  this.addToolResult = this.addToolOutput;
46928
47866
  this.stop = async () => {
46929
- var _a21;
47867
+ var _a222;
46930
47868
  if (this.status !== "streaming" && this.status !== "submitted")
46931
47869
  return;
46932
- if ((_a21 = this.activeResponse) == null ? undefined : _a21.abortController) {
47870
+ if ((_a222 = this.activeResponse) == null ? undefined : _a222.abortController) {
46933
47871
  this.activeResponse.abortController.abort();
46934
47872
  }
46935
47873
  };
@@ -46987,7 +47925,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
46987
47925
  body,
46988
47926
  messageId
46989
47927
  }) {
46990
- var _a21, _b16, _c;
47928
+ var _a222, _b16, _c;
46991
47929
  let resumeStream;
46992
47930
  if (trigger === "resume-stream") {
46993
47931
  try {
@@ -47044,9 +47982,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47044
47982
  const runUpdateMessageJob = (job) => this.jobExecutor.run(() => job({
47045
47983
  state: activeResponse.state,
47046
47984
  write: () => {
47047
- var _a222;
47985
+ var _a232;
47048
47986
  this.setStatus({ status: "streaming" });
47049
- const replaceLastMessage = activeResponse.state.message.id === ((_a222 = this.lastMessage) == null ? undefined : _a222.id);
47987
+ const replaceLastMessage = activeResponse.state.message.id === ((_a232 = this.lastMessage) == null ? undefined : _a232.id);
47050
47988
  if (replaceLastMessage) {
47051
47989
  this.state.replaceMessage(this.state.messages.length - 1, activeResponse.state.message);
47052
47990
  } else {
@@ -47093,7 +48031,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47093
48031
  isAbort,
47094
48032
  isDisconnect,
47095
48033
  isError,
47096
- finishReason: (_a21 = this.activeResponse) == null ? undefined : _a21.state.finishReason
48034
+ finishReason: (_a222 = this.activeResponse) == null ? undefined : _a222.state.finishReason
47097
48035
  });
47098
48036
  } catch (err) {
47099
48037
  console.error(err);
@@ -47167,6 +48105,7 @@ var init_dist8 = __esm(() => {
47167
48105
  init_dist();
47168
48106
  init_dist();
47169
48107
  init_dist();
48108
+ init_dist();
47170
48109
  init_dist3();
47171
48110
  init_dist();
47172
48111
  init_dist7();
@@ -47192,6 +48131,8 @@ var init_dist8 = __esm(() => {
47192
48131
  init_dist3();
47193
48132
  init_dist3();
47194
48133
  init_dist3();
48134
+ init_dist3();
48135
+ init_dist3();
47195
48136
  init_dist();
47196
48137
  init_dist3();
47197
48138
  init_dist3();
@@ -47287,6 +48228,27 @@ var init_dist8 = __esm(() => {
47287
48228
  _a33 = symbol33;
47288
48229
  marker43 = `vercel.ai.error.${name43}`;
47289
48230
  symbol43 = Symbol.for(marker43);
48231
+ InvalidToolApprovalSignatureError = class extends AISDKError {
48232
+ constructor({
48233
+ approvalId,
48234
+ toolCallId,
48235
+ reason
48236
+ }) {
48237
+ super({
48238
+ name: name43,
48239
+ message: `Tool approval signature verification failed for approval "${approvalId}" (tool call "${toolCallId}"): ${reason}`
48240
+ });
48241
+ this[_a43] = true;
48242
+ this.approvalId = approvalId;
48243
+ this.toolCallId = toolCallId;
48244
+ }
48245
+ static isInstance(error40) {
48246
+ return AISDKError.hasMarker(error40, marker43);
48247
+ }
48248
+ };
48249
+ _a43 = symbol43;
48250
+ marker53 = `vercel.ai.error.${name53}`;
48251
+ symbol53 = Symbol.for(marker53);
47290
48252
  InvalidToolInputError = class extends AISDKError {
47291
48253
  constructor({
47292
48254
  toolInput,
@@ -47294,71 +48256,71 @@ var init_dist8 = __esm(() => {
47294
48256
  cause,
47295
48257
  message = `Invalid input for tool ${toolName}: ${getErrorMessage(cause)}`
47296
48258
  }) {
47297
- super({ name: name43, message, cause });
47298
- this[_a43] = true;
48259
+ super({ name: name53, message, cause });
48260
+ this[_a53] = true;
47299
48261
  this.toolInput = toolInput;
47300
48262
  this.toolName = toolName;
47301
48263
  }
47302
48264
  static isInstance(error40) {
47303
- return AISDKError.hasMarker(error40, marker43);
48265
+ return AISDKError.hasMarker(error40, marker53);
47304
48266
  }
47305
48267
  };
47306
- _a43 = symbol43;
47307
- marker53 = `vercel.ai.error.${name53}`;
47308
- symbol53 = Symbol.for(marker53);
48268
+ _a53 = symbol53;
48269
+ marker63 = `vercel.ai.error.${name63}`;
48270
+ symbol63 = Symbol.for(marker63);
47309
48271
  ToolCallNotFoundForApprovalError = class extends AISDKError {
47310
48272
  constructor({
47311
48273
  toolCallId,
47312
48274
  approvalId
47313
48275
  }) {
47314
48276
  super({
47315
- name: name53,
48277
+ name: name63,
47316
48278
  message: `Tool call "${toolCallId}" not found for approval request "${approvalId}".`
47317
48279
  });
47318
- this[_a53] = true;
48280
+ this[_a63] = true;
47319
48281
  this.toolCallId = toolCallId;
47320
48282
  this.approvalId = approvalId;
47321
48283
  }
47322
48284
  static isInstance(error40) {
47323
- return AISDKError.hasMarker(error40, marker53);
48285
+ return AISDKError.hasMarker(error40, marker63);
47324
48286
  }
47325
48287
  };
47326
- _a53 = symbol53;
47327
- marker63 = `vercel.ai.error.${name63}`;
47328
- symbol63 = Symbol.for(marker63);
48288
+ _a63 = symbol63;
48289
+ marker73 = `vercel.ai.error.${name73}`;
48290
+ symbol73 = Symbol.for(marker73);
47329
48291
  MissingToolResultsError = class extends AISDKError {
47330
48292
  constructor({ toolCallIds }) {
47331
48293
  super({
47332
- name: name63,
48294
+ name: name73,
47333
48295
  message: `Tool result${toolCallIds.length > 1 ? "s are" : " is"} missing for tool call${toolCallIds.length > 1 ? "s" : ""} ${toolCallIds.join(", ")}.`
47334
48296
  });
47335
- this[_a63] = true;
48297
+ this[_a73] = true;
47336
48298
  this.toolCallIds = toolCallIds;
47337
48299
  }
47338
48300
  static isInstance(error40) {
47339
- return AISDKError.hasMarker(error40, marker63);
48301
+ return AISDKError.hasMarker(error40, marker73);
47340
48302
  }
47341
48303
  };
47342
- _a63 = symbol63;
47343
- marker73 = `vercel.ai.error.${name73}`;
47344
- symbol73 = Symbol.for(marker73);
48304
+ _a73 = symbol73;
48305
+ marker83 = `vercel.ai.error.${name83}`;
48306
+ symbol83 = Symbol.for(marker83);
47345
48307
  NoImageGeneratedError = class extends AISDKError {
47346
48308
  constructor({
47347
48309
  message = "No image generated.",
47348
48310
  cause,
47349
48311
  responses
47350
48312
  }) {
47351
- super({ name: name73, message, cause });
47352
- this[_a73] = true;
48313
+ super({ name: name83, message, cause });
48314
+ this[_a83] = true;
47353
48315
  this.responses = responses;
47354
48316
  }
47355
48317
  static isInstance(error40) {
47356
- return AISDKError.hasMarker(error40, marker73);
48318
+ return AISDKError.hasMarker(error40, marker83);
47357
48319
  }
47358
48320
  };
47359
- _a73 = symbol73;
47360
- marker83 = `vercel.ai.error.${name83}`;
47361
- symbol83 = Symbol.for(marker83);
48321
+ _a83 = symbol83;
48322
+ marker93 = `vercel.ai.error.${name93}`;
48323
+ symbol93 = Symbol.for(marker93);
47362
48324
  NoObjectGeneratedError = class extends AISDKError {
47363
48325
  constructor({
47364
48326
  message = "No object generated.",
@@ -47368,82 +48330,82 @@ var init_dist8 = __esm(() => {
47368
48330
  usage,
47369
48331
  finishReason
47370
48332
  }) {
47371
- super({ name: name83, message, cause });
47372
- this[_a83] = true;
48333
+ super({ name: name93, message, cause });
48334
+ this[_a93] = true;
47373
48335
  this.text = text2;
47374
48336
  this.response = response;
47375
48337
  this.usage = usage;
47376
48338
  this.finishReason = finishReason;
47377
48339
  }
47378
48340
  static isInstance(error40) {
47379
- return AISDKError.hasMarker(error40, marker83);
48341
+ return AISDKError.hasMarker(error40, marker93);
47380
48342
  }
47381
48343
  };
47382
- _a83 = symbol83;
47383
- marker93 = `vercel.ai.error.${name92}`;
47384
- symbol93 = Symbol.for(marker93);
48344
+ _a93 = symbol93;
48345
+ marker103 = `vercel.ai.error.${name102}`;
48346
+ symbol103 = Symbol.for(marker103);
47385
48347
  NoOutputGeneratedError = class extends AISDKError {
47386
48348
  constructor({
47387
48349
  message = "No output generated.",
47388
48350
  cause
47389
48351
  } = {}) {
47390
- super({ name: name92, message, cause });
47391
- this[_a93] = true;
48352
+ super({ name: name102, message, cause });
48353
+ this[_a103] = true;
47392
48354
  }
47393
48355
  static isInstance(error40) {
47394
- return AISDKError.hasMarker(error40, marker93);
48356
+ return AISDKError.hasMarker(error40, marker103);
47395
48357
  }
47396
48358
  };
47397
- _a93 = symbol93;
47398
- marker102 = `vercel.ai.error.${name102}`;
47399
- symbol102 = Symbol.for(marker102);
48359
+ _a103 = symbol103;
48360
+ marker112 = `vercel.ai.error.${name112}`;
48361
+ symbol112 = Symbol.for(marker112);
47400
48362
  NoSpeechGeneratedError = class extends AISDKError {
47401
48363
  constructor(options) {
47402
48364
  super({
47403
- name: name102,
48365
+ name: name112,
47404
48366
  message: "No speech audio generated."
47405
48367
  });
47406
- this[_a102] = true;
48368
+ this[_a112] = true;
47407
48369
  this.responses = options.responses;
47408
48370
  }
47409
48371
  static isInstance(error40) {
47410
- return AISDKError.hasMarker(error40, marker102);
48372
+ return AISDKError.hasMarker(error40, marker112);
47411
48373
  }
47412
48374
  };
47413
- _a102 = symbol102;
47414
- marker112 = `vercel.ai.error.${name112}`;
47415
- symbol112 = Symbol.for(marker112);
48375
+ _a112 = symbol112;
48376
+ marker122 = `vercel.ai.error.${name122}`;
48377
+ symbol122 = Symbol.for(marker122);
47416
48378
  NoTranscriptGeneratedError = class extends AISDKError {
47417
48379
  constructor(options) {
47418
48380
  super({
47419
- name: name112,
48381
+ name: name122,
47420
48382
  message: "No transcript generated."
47421
48383
  });
47422
- this[_a112] = true;
48384
+ this[_a122] = true;
47423
48385
  this.responses = options.responses;
47424
48386
  }
47425
48387
  static isInstance(error40) {
47426
- return AISDKError.hasMarker(error40, marker112);
48388
+ return AISDKError.hasMarker(error40, marker122);
47427
48389
  }
47428
48390
  };
47429
- _a112 = symbol112;
47430
- marker122 = `vercel.ai.error.${name122}`;
47431
- symbol122 = Symbol.for(marker122);
48391
+ _a122 = symbol122;
48392
+ marker132 = `vercel.ai.error.${name132}`;
48393
+ symbol132 = Symbol.for(marker132);
47432
48394
  NoVideoGeneratedError = class extends AISDKError {
47433
48395
  constructor({
47434
48396
  message = "No video generated.",
47435
48397
  cause,
47436
48398
  responses
47437
48399
  }) {
47438
- super({ name: name122, message, cause });
47439
- this[_a122] = true;
48400
+ super({ name: name132, message, cause });
48401
+ this[_a132] = true;
47440
48402
  this.responses = responses;
47441
48403
  }
47442
48404
  static isInstance(error40) {
47443
- return AISDKError.hasMarker(error40, marker122);
48405
+ return AISDKError.hasMarker(error40, marker132);
47444
48406
  }
47445
48407
  static isNoVideoGeneratedError(error40) {
47446
- return error40 instanceof Error && error40.name === name122 && typeof error40.responses !== "undefined" ? true : false;
48408
+ return error40 instanceof Error && error40.name === name132 && typeof error40.responses !== "undefined" ? true : false;
47447
48409
  }
47448
48410
  toJSON() {
47449
48411
  return {
@@ -47455,42 +48417,42 @@ var init_dist8 = __esm(() => {
47455
48417
  };
47456
48418
  }
47457
48419
  };
47458
- _a122 = symbol122;
47459
- marker132 = `vercel.ai.error.${name132}`;
47460
- symbol132 = Symbol.for(marker132);
48420
+ _a132 = symbol132;
48421
+ marker142 = `vercel.ai.error.${name142}`;
48422
+ symbol142 = Symbol.for(marker142);
47461
48423
  NoSuchToolError = class extends AISDKError {
47462
48424
  constructor({
47463
48425
  toolName,
47464
48426
  availableTools = undefined,
47465
48427
  message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === undefined ? "No tools are available." : `Available tools: ${availableTools.join(", ")}.`}`
47466
48428
  }) {
47467
- super({ name: name132, message });
47468
- this[_a132] = true;
48429
+ super({ name: name142, message });
48430
+ this[_a142] = true;
47469
48431
  this.toolName = toolName;
47470
48432
  this.availableTools = availableTools;
47471
48433
  }
47472
48434
  static isInstance(error40) {
47473
- return AISDKError.hasMarker(error40, marker132);
48435
+ return AISDKError.hasMarker(error40, marker142);
47474
48436
  }
47475
48437
  };
47476
- _a132 = symbol132;
47477
- marker142 = `vercel.ai.error.${name142}`;
47478
- symbol142 = Symbol.for(marker142);
48438
+ _a142 = symbol142;
48439
+ marker152 = `vercel.ai.error.${name15}`;
48440
+ symbol152 = Symbol.for(marker152);
47479
48441
  ToolCallRepairError = class extends AISDKError {
47480
48442
  constructor({
47481
48443
  cause,
47482
48444
  originalError,
47483
48445
  message = `Error repairing tool call: ${getErrorMessage(cause)}`
47484
48446
  }) {
47485
- super({ name: name142, message, cause });
47486
- this[_a142] = true;
48447
+ super({ name: name15, message, cause });
48448
+ this[_a152] = true;
47487
48449
  this.originalError = originalError;
47488
48450
  }
47489
48451
  static isInstance(error40) {
47490
- return AISDKError.hasMarker(error40, marker142);
48452
+ return AISDKError.hasMarker(error40, marker152);
47491
48453
  }
47492
48454
  };
47493
- _a142 = symbol142;
48455
+ _a152 = symbol152;
47494
48456
  UnsupportedModelVersionError = class extends AISDKError {
47495
48457
  constructor(options) {
47496
48458
  super({
@@ -47502,92 +48464,92 @@ var init_dist8 = __esm(() => {
47502
48464
  this.modelId = options.modelId;
47503
48465
  }
47504
48466
  };
47505
- marker152 = `vercel.ai.error.${name15}`;
47506
- symbol152 = Symbol.for(marker152);
48467
+ marker16 = `vercel.ai.error.${name162}`;
48468
+ symbol16 = Symbol.for(marker16);
47507
48469
  UIMessageStreamError = class extends AISDKError {
47508
48470
  constructor({
47509
48471
  chunkType,
47510
48472
  chunkId,
47511
48473
  message
47512
48474
  }) {
47513
- super({ name: name15, message });
47514
- this[_a152] = true;
48475
+ super({ name: name162, message });
48476
+ this[_a16] = true;
47515
48477
  this.chunkType = chunkType;
47516
48478
  this.chunkId = chunkId;
47517
48479
  }
47518
48480
  static isInstance(error40) {
47519
- return AISDKError.hasMarker(error40, marker152);
48481
+ return AISDKError.hasMarker(error40, marker16);
47520
48482
  }
47521
48483
  };
47522
- _a152 = symbol152;
47523
- marker16 = `vercel.ai.error.${name162}`;
47524
- symbol16 = Symbol.for(marker16);
48484
+ _a16 = symbol16;
48485
+ marker172 = `vercel.ai.error.${name172}`;
48486
+ symbol172 = Symbol.for(marker172);
47525
48487
  InvalidDataContentError = class extends AISDKError {
47526
48488
  constructor({
47527
48489
  content,
47528
48490
  cause,
47529
48491
  message = `Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof content}.`
47530
48492
  }) {
47531
- super({ name: name162, message, cause });
47532
- this[_a16] = true;
48493
+ super({ name: name172, message, cause });
48494
+ this[_a172] = true;
47533
48495
  this.content = content;
47534
48496
  }
47535
48497
  static isInstance(error40) {
47536
- return AISDKError.hasMarker(error40, marker16);
48498
+ return AISDKError.hasMarker(error40, marker172);
47537
48499
  }
47538
48500
  };
47539
- _a16 = symbol16;
47540
- marker172 = `vercel.ai.error.${name172}`;
47541
- symbol172 = Symbol.for(marker172);
48501
+ _a172 = symbol172;
48502
+ marker182 = `vercel.ai.error.${name18}`;
48503
+ symbol182 = Symbol.for(marker182);
47542
48504
  InvalidMessageRoleError = class extends AISDKError {
47543
48505
  constructor({
47544
48506
  role,
47545
48507
  message = `Invalid message role: '${role}'. Must be one of: "system", "user", "assistant", "tool".`
47546
48508
  }) {
47547
- super({ name: name172, message });
47548
- this[_a172] = true;
48509
+ super({ name: name18, message });
48510
+ this[_a182] = true;
47549
48511
  this.role = role;
47550
48512
  }
47551
48513
  static isInstance(error40) {
47552
- return AISDKError.hasMarker(error40, marker172);
48514
+ return AISDKError.hasMarker(error40, marker182);
47553
48515
  }
47554
48516
  };
47555
- _a172 = symbol172;
47556
- marker182 = `vercel.ai.error.${name18}`;
47557
- symbol182 = Symbol.for(marker182);
48517
+ _a182 = symbol182;
48518
+ marker19 = `vercel.ai.error.${name19}`;
48519
+ symbol192 = Symbol.for(marker19);
47558
48520
  MessageConversionError = class extends AISDKError {
47559
48521
  constructor({
47560
48522
  originalMessage,
47561
48523
  message
47562
48524
  }) {
47563
- super({ name: name18, message });
47564
- this[_a182] = true;
48525
+ super({ name: name19, message });
48526
+ this[_a19] = true;
47565
48527
  this.originalMessage = originalMessage;
47566
48528
  }
47567
48529
  static isInstance(error40) {
47568
- return AISDKError.hasMarker(error40, marker182);
48530
+ return AISDKError.hasMarker(error40, marker19);
47569
48531
  }
47570
48532
  };
47571
- _a182 = symbol182;
47572
- marker19 = `vercel.ai.error.${name19}`;
47573
- symbol192 = Symbol.for(marker19);
48533
+ _a19 = symbol192;
48534
+ marker20 = `vercel.ai.error.${name20}`;
48535
+ symbol20 = Symbol.for(marker20);
47574
48536
  RetryError = class extends AISDKError {
47575
48537
  constructor({
47576
48538
  message,
47577
48539
  reason,
47578
48540
  errors: errors4
47579
48541
  }) {
47580
- super({ name: name19, message });
47581
- this[_a19] = true;
48542
+ super({ name: name20, message });
48543
+ this[_a20] = true;
47582
48544
  this.reason = reason;
47583
48545
  this.errors = errors4;
47584
48546
  this.lastError = errors4[errors4.length - 1];
47585
48547
  }
47586
48548
  static isInstance(error40) {
47587
- return AISDKError.hasMarker(error40, marker19);
48549
+ return AISDKError.hasMarker(error40, marker20);
47588
48550
  }
47589
48551
  };
47590
- _a19 = symbol192;
48552
+ _a20 = symbol20;
47591
48553
  imageMediaTypeSignatures = [
47592
48554
  {
47593
48555
  mediaType: "image/gif",
@@ -47771,8 +48733,8 @@ var init_dist8 = __esm(() => {
47771
48733
  exports_external2.instanceof(Uint8Array),
47772
48734
  exports_external2.instanceof(ArrayBuffer),
47773
48735
  exports_external2.custom((value) => {
47774
- var _a21, _b16;
47775
- return (_b16 = (_a21 = globalThis.Buffer) == null ? undefined : _a21.isBuffer(value)) != null ? _b16 : false;
48736
+ var _a222, _b16;
48737
+ return (_b16 = (_a222 = globalThis.Buffer) == null ? undefined : _a222.isBuffer(value)) != null ? _b16 : false;
47776
48738
  }, { message: "Must be a Buffer" })
47777
48739
  ]);
47778
48740
  jsonValueSchema3 = exports_external2.lazy(() => exports_external2.union([
@@ -47955,7 +48917,7 @@ var init_dist8 = __esm(() => {
47955
48917
  startSpan() {
47956
48918
  return noopSpan;
47957
48919
  },
47958
- startActiveSpan(name21, arg1, arg2, arg3) {
48920
+ startActiveSpan(name222, arg1, arg2, arg3) {
47959
48921
  if (typeof arg1 === "function") {
47960
48922
  return arg1(noopSpan);
47961
48923
  }
@@ -48013,6 +48975,7 @@ var init_dist8 = __esm(() => {
48013
48975
  this.type = "file";
48014
48976
  }
48015
48977
  };
48978
+ encoder = new TextEncoder;
48016
48979
  output_exports = {};
48017
48980
  __export2(output_exports, {
48018
48981
  array: () => array2,
@@ -48111,7 +49074,8 @@ var init_dist8 = __esm(() => {
48111
49074
  exports_external2.strictObject({
48112
49075
  type: exports_external2.literal("tool-approval-request"),
48113
49076
  approvalId: exports_external2.string(),
48114
- toolCallId: exports_external2.string()
49077
+ toolCallId: exports_external2.string(),
49078
+ signature: exports_external2.string().optional()
48115
49079
  }),
48116
49080
  exports_external2.strictObject({
48117
49081
  type: exports_external2.literal("tool-output-available"),
@@ -48217,6 +49181,28 @@ var init_dist8 = __esm(() => {
48217
49181
  prefix: "aitxt",
48218
49182
  size: 24
48219
49183
  });
49184
+ isOutputChunkType = {
49185
+ file: true,
49186
+ source: true,
49187
+ "text-start": true,
49188
+ "text-end": true,
49189
+ "text-delta": true,
49190
+ "reasoning-start": true,
49191
+ "reasoning-end": true,
49192
+ "reasoning-delta": true,
49193
+ "tool-input-start": true,
49194
+ "tool-input-end": true,
49195
+ "tool-input-delta": true,
49196
+ "tool-approval-request": true,
49197
+ "tool-call": true,
49198
+ "tool-result": true,
49199
+ "tool-error": true,
49200
+ "stream-start": false,
49201
+ "response-metadata": false,
49202
+ finish: false,
49203
+ error: false,
49204
+ raw: false
49205
+ };
48220
49206
  toolMetadataSchema2 = exports_external2.record(exports_external2.string(), jsonValueSchema3.optional());
48221
49207
  uiMessagesSchema = lazySchema(() => zodSchema(exports_external2.array(exports_external2.object({
48222
49208
  id: exports_external2.string(),
@@ -48305,7 +49291,8 @@ var init_dist8 = __esm(() => {
48305
49291
  approval: exports_external2.object({
48306
49292
  id: exports_external2.string(),
48307
49293
  approved: exports_external2.never().optional(),
48308
- reason: exports_external2.never().optional()
49294
+ reason: exports_external2.never().optional(),
49295
+ signature: exports_external2.string().optional()
48309
49296
  })
48310
49297
  }),
48311
49298
  exports_external2.object({
@@ -48322,7 +49309,8 @@ var init_dist8 = __esm(() => {
48322
49309
  approval: exports_external2.object({
48323
49310
  id: exports_external2.string(),
48324
49311
  approved: exports_external2.boolean(),
48325
- reason: exports_external2.string().optional()
49312
+ reason: exports_external2.string().optional(),
49313
+ signature: exports_external2.string().optional()
48326
49314
  })
48327
49315
  }),
48328
49316
  exports_external2.object({
@@ -48341,7 +49329,8 @@ var init_dist8 = __esm(() => {
48341
49329
  approval: exports_external2.object({
48342
49330
  id: exports_external2.string(),
48343
49331
  approved: exports_external2.literal(true),
48344
- reason: exports_external2.string().optional()
49332
+ reason: exports_external2.string().optional(),
49333
+ signature: exports_external2.string().optional()
48345
49334
  }).optional()
48346
49335
  }),
48347
49336
  exports_external2.object({
@@ -48360,7 +49349,8 @@ var init_dist8 = __esm(() => {
48360
49349
  approval: exports_external2.object({
48361
49350
  id: exports_external2.string(),
48362
49351
  approved: exports_external2.literal(true),
48363
- reason: exports_external2.string().optional()
49352
+ reason: exports_external2.string().optional(),
49353
+ signature: exports_external2.string().optional()
48364
49354
  }).optional()
48365
49355
  }),
48366
49356
  exports_external2.object({
@@ -48377,7 +49367,8 @@ var init_dist8 = __esm(() => {
48377
49367
  approval: exports_external2.object({
48378
49368
  id: exports_external2.string(),
48379
49369
  approved: exports_external2.literal(false),
48380
- reason: exports_external2.string().optional()
49370
+ reason: exports_external2.string().optional(),
49371
+ signature: exports_external2.string().optional()
48381
49372
  })
48382
49373
  }),
48383
49374
  exports_external2.object({
@@ -48417,7 +49408,8 @@ var init_dist8 = __esm(() => {
48417
49408
  approval: exports_external2.object({
48418
49409
  id: exports_external2.string(),
48419
49410
  approved: exports_external2.never().optional(),
48420
- reason: exports_external2.never().optional()
49411
+ reason: exports_external2.never().optional(),
49412
+ signature: exports_external2.string().optional()
48421
49413
  })
48422
49414
  }),
48423
49415
  exports_external2.object({
@@ -48433,7 +49425,8 @@ var init_dist8 = __esm(() => {
48433
49425
  approval: exports_external2.object({
48434
49426
  id: exports_external2.string(),
48435
49427
  approved: exports_external2.boolean(),
48436
- reason: exports_external2.string().optional()
49428
+ reason: exports_external2.string().optional(),
49429
+ signature: exports_external2.string().optional()
48437
49430
  })
48438
49431
  }),
48439
49432
  exports_external2.object({
@@ -48451,7 +49444,8 @@ var init_dist8 = __esm(() => {
48451
49444
  approval: exports_external2.object({
48452
49445
  id: exports_external2.string(),
48453
49446
  approved: exports_external2.literal(true),
48454
- reason: exports_external2.string().optional()
49447
+ reason: exports_external2.string().optional(),
49448
+ signature: exports_external2.string().optional()
48455
49449
  }).optional()
48456
49450
  }),
48457
49451
  exports_external2.object({
@@ -48469,7 +49463,8 @@ var init_dist8 = __esm(() => {
48469
49463
  approval: exports_external2.object({
48470
49464
  id: exports_external2.string(),
48471
49465
  approved: exports_external2.literal(true),
48472
- reason: exports_external2.string().optional()
49466
+ reason: exports_external2.string().optional(),
49467
+ signature: exports_external2.string().optional()
48473
49468
  }).optional()
48474
49469
  }),
48475
49470
  exports_external2.object({
@@ -48485,7 +49480,8 @@ var init_dist8 = __esm(() => {
48485
49480
  approval: exports_external2.object({
48486
49481
  id: exports_external2.string(),
48487
49482
  approved: exports_external2.literal(false),
48488
- reason: exports_external2.string().optional()
49483
+ reason: exports_external2.string().optional(),
49484
+ signature: exports_external2.string().optional()
48489
49485
  })
48490
49486
  })
48491
49487
  ])).nonempty("Message must contain at least one part")
@@ -48546,8 +49542,8 @@ var init_dist8 = __esm(() => {
48546
49542
  };
48547
49543
  defaultDownload = createDownload();
48548
49544
  experimental_customProvider = customProvider;
48549
- marker20 = `vercel.ai.error.${name20}`;
48550
- symbol20 = Symbol.for(marker20);
49545
+ marker21 = `vercel.ai.error.${name21}`;
49546
+ symbol21 = Symbol.for(marker21);
48551
49547
  NoSuchProviderError = class extends NoSuchModelError {
48552
49548
  constructor({
48553
49549
  modelId,
@@ -48556,16 +49552,16 @@ var init_dist8 = __esm(() => {
48556
49552
  availableProviders,
48557
49553
  message = `No such provider: ${providerId} (available providers: ${availableProviders.join()})`
48558
49554
  }) {
48559
- super({ errorName: name20, modelId, modelType, message });
48560
- this[_a20] = true;
49555
+ super({ errorName: name21, modelId, modelType, message });
49556
+ this[_a21] = true;
48561
49557
  this.providerId = providerId;
48562
49558
  this.availableProviders = availableProviders;
48563
49559
  }
48564
49560
  static isInstance(error40) {
48565
- return AISDKError.hasMarker(error40, marker20);
49561
+ return AISDKError.hasMarker(error40, marker21);
48566
49562
  }
48567
49563
  };
48568
- _a20 = symbol20;
49564
+ _a21 = symbol21;
48569
49565
  experimental_createProviderRegistry = createProviderRegistry;
48570
49566
  defaultDownload2 = createDownload();
48571
49567
  DefaultChatTransport = class extends HttpChatTransport {