@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/mcp/index.js CHANGED
@@ -218,6 +218,7 @@ function translateSql(sql) {
218
218
  });
219
219
  translated = translated.replace(/lower\s*\(\s*hex\s*\(\s*randomblob\s*\(\s*\d+\s*\)\s*\)\s*\)/gi, "gen_random_uuid()::text");
220
220
  translated = translated.replace(/\bIFNULL\s*\(/gi, "COALESCE(");
221
+ translated = translated.replace(/\bINSTR\s*\(/gi, "STRPOS(");
221
222
  if (/INSERT\s+OR\s+IGNORE\s+INTO/i.test(translated)) {
222
223
  translated = translated.replace(/INSERT\s+OR\s+IGNORE\s+INTO/gi, "INSERT INTO");
223
224
  translated = translated.replace(/;?\s*$/, " ON CONFLICT DO NOTHING");
@@ -12553,7 +12554,7 @@ var init_pg_migrate = __esm(() => {
12553
12554
  init_pg_migrations();
12554
12555
  });
12555
12556
 
12556
- // node_modules/@ai-sdk/provider/dist/index.mjs
12557
+ // node_modules/.pnpm/@ai-sdk+provider@3.0.13/node_modules/@ai-sdk/provider/dist/index.mjs
12557
12558
  function getErrorMessage(error) {
12558
12559
  if (error == null) {
12559
12560
  return "unknown error";
@@ -24218,7 +24219,7 @@ var init_v3 = __esm(() => {
24218
24219
  init_external();
24219
24220
  });
24220
24221
 
24221
- // node_modules/@ai-sdk/provider-utils/node_modules/eventsource-parser/dist/index.js
24222
+ // node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/index.js
24222
24223
  function noop(_arg) {}
24223
24224
  function createParser(config2) {
24224
24225
  if (typeof config2 == "function")
@@ -24378,7 +24379,7 @@ var init_dist2 = __esm(() => {
24378
24379
  };
24379
24380
  });
24380
24381
 
24381
- // node_modules/@ai-sdk/provider-utils/node_modules/eventsource-parser/dist/stream.js
24382
+ // node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/stream.js
24382
24383
  var EventSourceParserStream;
24383
24384
  var init_stream = __esm(() => {
24384
24385
  init_dist2();
@@ -24407,7 +24408,7 @@ var init_stream = __esm(() => {
24407
24408
  };
24408
24409
  });
24409
24410
 
24410
- // node_modules/@ai-sdk/provider-utils/dist/index.mjs
24411
+ // node_modules/.pnpm/@ai-sdk+provider-utils@4.0.35_zod@3.25.76/node_modules/@ai-sdk/provider-utils/dist/index.mjs
24411
24412
  function combineHeaders(...headers) {
24412
24413
  return headers.reduce((combinedHeaders, currentHeaders) => ({
24413
24414
  ...combinedHeaders,
@@ -24511,57 +24512,14 @@ function convertToFormData(input, options = {}) {
24511
24512
  }
24512
24513
  return formData;
24513
24514
  }
24514
- async function readResponseWithSizeLimit({
24515
- response,
24516
- url: url2,
24517
- maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE
24518
- }) {
24519
- const contentLength = response.headers.get("content-length");
24520
- if (contentLength != null) {
24521
- const length = parseInt(contentLength, 10);
24522
- if (!isNaN(length) && length > maxBytes) {
24523
- throw new DownloadError({
24524
- url: url2,
24525
- message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
24526
- });
24527
- }
24528
- }
24529
- const body = response.body;
24530
- if (body == null) {
24531
- return new Uint8Array(0);
24532
- }
24533
- const reader = body.getReader();
24534
- const chunks = [];
24535
- let totalBytes = 0;
24515
+ async function cancelResponseBody(response) {
24516
+ var _a22;
24536
24517
  try {
24537
- while (true) {
24538
- const { done, value } = await reader.read();
24539
- if (done) {
24540
- break;
24541
- }
24542
- totalBytes += value.length;
24543
- if (totalBytes > maxBytes) {
24544
- throw new DownloadError({
24545
- url: url2,
24546
- message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes.`
24547
- });
24548
- }
24549
- chunks.push(value);
24550
- }
24551
- } finally {
24552
- try {
24553
- await reader.cancel();
24554
- } finally {
24555
- reader.releaseLock();
24556
- }
24557
- }
24558
- const result = new Uint8Array(totalBytes);
24559
- let offset = 0;
24560
- for (const chunk of chunks) {
24561
- result.set(chunk, offset);
24562
- offset += chunk.length;
24563
- }
24564
- return result;
24518
+ await ((_a22 = response.body) == null ? undefined : _a22.cancel());
24519
+ } catch (e) {}
24520
+ }
24521
+ function isBrowserRuntime(globalThisAny = globalThis) {
24522
+ return globalThisAny.window != null;
24565
24523
  }
24566
24524
  function validateDownloadUrl(url2) {
24567
24525
  let parsed;
@@ -24582,7 +24540,7 @@ function validateDownloadUrl(url2) {
24582
24540
  message: `URL scheme must be http, https, or data, got ${parsed.protocol}`
24583
24541
  });
24584
24542
  }
24585
- const hostname3 = parsed.hostname;
24543
+ const hostname3 = parsed.hostname.toLowerCase().replace(/\.+$/, "");
24586
24544
  if (!hostname3) {
24587
24545
  throw new DownloadError({
24588
24546
  url: url2,
@@ -24626,62 +24584,198 @@ function isIPv4(hostname3) {
24626
24584
  }
24627
24585
  function isPrivateIPv4(ip) {
24628
24586
  const parts = ip.split(".").map(Number);
24629
- const [a, b] = parts;
24587
+ const [a, b, c] = parts;
24630
24588
  if (a === 0)
24631
24589
  return true;
24632
24590
  if (a === 10)
24633
24591
  return true;
24592
+ if (a === 100 && b >= 64 && b <= 127)
24593
+ return true;
24634
24594
  if (a === 127)
24635
24595
  return true;
24636
24596
  if (a === 169 && b === 254)
24637
24597
  return true;
24638
24598
  if (a === 172 && b >= 16 && b <= 31)
24639
24599
  return true;
24600
+ if (a === 192 && b === 0 && c === 0)
24601
+ return true;
24640
24602
  if (a === 192 && b === 168)
24641
24603
  return true;
24604
+ if (a === 198 && (b === 18 || b === 19))
24605
+ return true;
24606
+ if (a >= 240)
24607
+ return true;
24642
24608
  return false;
24643
24609
  }
24610
+ function parseIPv6(ip) {
24611
+ let address = ip.toLowerCase();
24612
+ const zoneIndex = address.indexOf("%");
24613
+ if (zoneIndex !== -1) {
24614
+ address = address.slice(0, zoneIndex);
24615
+ }
24616
+ const halves = address.split("::");
24617
+ if (halves.length > 2)
24618
+ return null;
24619
+ const toGroups = (segment) => {
24620
+ if (segment === "")
24621
+ return [];
24622
+ const groups = [];
24623
+ const parts = segment.split(":");
24624
+ for (let i = 0;i < parts.length; i++) {
24625
+ const part = parts[i];
24626
+ if (part.includes(".")) {
24627
+ if (i !== parts.length - 1 || !isIPv4(part))
24628
+ return null;
24629
+ const [a, b, c, d] = part.split(".").map(Number);
24630
+ groups.push(a << 8 | b, c << 8 | d);
24631
+ continue;
24632
+ }
24633
+ if (!/^[0-9a-f]{1,4}$/.test(part))
24634
+ return null;
24635
+ groups.push(parseInt(part, 16));
24636
+ }
24637
+ return groups;
24638
+ };
24639
+ const head = toGroups(halves[0]);
24640
+ if (head === null)
24641
+ return null;
24642
+ if (halves.length === 2) {
24643
+ const tail = toGroups(halves[1]);
24644
+ if (tail === null)
24645
+ return null;
24646
+ const fill = 8 - head.length - tail.length;
24647
+ if (fill < 0)
24648
+ return null;
24649
+ return [...head, ...new Array(fill).fill(0), ...tail];
24650
+ }
24651
+ return head.length === 8 ? head : null;
24652
+ }
24644
24653
  function isPrivateIPv6(ip) {
24645
- const normalized = ip.toLowerCase();
24646
- if (normalized === "::1")
24654
+ const groups = parseIPv6(ip);
24655
+ if (groups === null)
24647
24656
  return true;
24648
- if (normalized === "::")
24657
+ const topZero = (count) => groups.slice(0, count).every((group) => group === 0);
24658
+ if (topZero(7) && (groups[7] === 0 || groups[7] === 1))
24649
24659
  return true;
24650
- if (normalized.startsWith("::ffff:")) {
24651
- const mappedPart = normalized.slice(7);
24652
- if (isIPv4(mappedPart)) {
24653
- return isPrivateIPv4(mappedPart);
24660
+ if ((groups[0] & 65024) === 64512)
24661
+ return true;
24662
+ if ((groups[0] & 65472) === 65152)
24663
+ return true;
24664
+ if ((groups[0] & 65472) === 65216)
24665
+ return true;
24666
+ if ((groups[0] & 65280) === 65280)
24667
+ return true;
24668
+ 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;
24669
+ if (embedsIPv4) {
24670
+ const a = groups[6] >> 8 & 255;
24671
+ const b = groups[6] & 255;
24672
+ const c = groups[7] >> 8 & 255;
24673
+ const d = groups[7] & 255;
24674
+ return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
24675
+ }
24676
+ return false;
24677
+ }
24678
+ async function fetchWithValidatedRedirects({
24679
+ url: url2,
24680
+ headers,
24681
+ abortSignal,
24682
+ maxRedirects = MAX_DOWNLOAD_REDIRECTS
24683
+ }) {
24684
+ const baseInit = { signal: abortSignal };
24685
+ if (headers !== undefined) {
24686
+ baseInit.headers = headers;
24687
+ }
24688
+ let currentUrl = url2;
24689
+ for (let redirectCount = 0;redirectCount <= maxRedirects; redirectCount++) {
24690
+ validateDownloadUrl(currentUrl);
24691
+ const response = await fetch(currentUrl, {
24692
+ ...baseInit,
24693
+ redirect: "manual"
24694
+ });
24695
+ if (response.type === "opaqueredirect") {
24696
+ if (!isBrowserRuntime()) {
24697
+ throw new DownloadError({
24698
+ url: url2,
24699
+ message: `Redirect from ${currentUrl} could not be validated and was blocked`
24700
+ });
24701
+ }
24702
+ return await fetch(currentUrl, { ...baseInit, redirect: "follow" });
24703
+ }
24704
+ const location = response.headers.get("location");
24705
+ if (response.status >= 300 && response.status < 400 && location) {
24706
+ await cancelResponseBody(response);
24707
+ currentUrl = new URL(location, currentUrl).toString();
24708
+ continue;
24709
+ }
24710
+ return response;
24711
+ }
24712
+ throw new DownloadError({
24713
+ url: url2,
24714
+ message: `Too many redirects (max ${maxRedirects})`
24715
+ });
24716
+ }
24717
+ async function readResponseWithSizeLimit({
24718
+ response,
24719
+ url: url2,
24720
+ maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE
24721
+ }) {
24722
+ const contentLength = response.headers.get("content-length");
24723
+ if (contentLength != null) {
24724
+ const length = parseInt(contentLength, 10);
24725
+ if (!isNaN(length) && length > maxBytes) {
24726
+ await cancelResponseBody(response);
24727
+ throw new DownloadError({
24728
+ url: url2,
24729
+ message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
24730
+ });
24654
24731
  }
24655
- const hexParts = mappedPart.split(":");
24656
- if (hexParts.length === 2) {
24657
- const high = parseInt(hexParts[0], 16);
24658
- const low = parseInt(hexParts[1], 16);
24659
- if (!isNaN(high) && !isNaN(low)) {
24660
- const a = high >> 8 & 255;
24661
- const b = high & 255;
24662
- const c = low >> 8 & 255;
24663
- const d = low & 255;
24664
- return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
24732
+ }
24733
+ const body = response.body;
24734
+ if (body == null) {
24735
+ return new Uint8Array(0);
24736
+ }
24737
+ const reader = body.getReader();
24738
+ const chunks = [];
24739
+ let totalBytes = 0;
24740
+ try {
24741
+ while (true) {
24742
+ const { done, value } = await reader.read();
24743
+ if (done) {
24744
+ break;
24745
+ }
24746
+ totalBytes += value.length;
24747
+ if (totalBytes > maxBytes) {
24748
+ throw new DownloadError({
24749
+ url: url2,
24750
+ message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes.`
24751
+ });
24665
24752
  }
24753
+ chunks.push(value);
24754
+ }
24755
+ } finally {
24756
+ try {
24757
+ await reader.cancel();
24758
+ } finally {
24759
+ reader.releaseLock();
24666
24760
  }
24667
24761
  }
24668
- if (normalized.startsWith("fc") || normalized.startsWith("fd"))
24669
- return true;
24670
- if (normalized.startsWith("fe80"))
24671
- return true;
24672
- return false;
24762
+ const result = new Uint8Array(totalBytes);
24763
+ let offset = 0;
24764
+ for (const chunk of chunks) {
24765
+ result.set(chunk, offset);
24766
+ offset += chunk.length;
24767
+ }
24768
+ return result;
24673
24769
  }
24674
24770
  async function downloadBlob(url2, options) {
24675
24771
  var _a22, _b22;
24676
- validateDownloadUrl(url2);
24677
24772
  try {
24678
- const response = await fetch(url2, {
24679
- signal: options == null ? undefined : options.abortSignal
24773
+ const response = await fetchWithValidatedRedirects({
24774
+ url: url2,
24775
+ abortSignal: options == null ? undefined : options.abortSignal
24680
24776
  });
24681
- if (response.redirected) {
24682
- validateDownloadUrl(response.url);
24683
- }
24684
24777
  if (!response.ok) {
24778
+ await cancelResponseBody(response);
24685
24779
  throw new DownloadError({
24686
24780
  url: url2,
24687
24781
  statusCode: response.status,
@@ -25928,6 +26022,68 @@ async function resolve5(value) {
25928
26022
  }
25929
26023
  return Promise.resolve(value);
25930
26024
  }
26025
+ async function retryWithExponentialBackoffInternal(f, {
26026
+ maxRetries,
26027
+ delayInMs,
26028
+ backoffFactor,
26029
+ abortSignal,
26030
+ shouldRetry,
26031
+ getDelayInMs,
26032
+ createRetryError
26033
+ }, errors4 = []) {
26034
+ try {
26035
+ return await f();
26036
+ } catch (error40) {
26037
+ if (isAbortError(error40)) {
26038
+ throw error40;
26039
+ }
26040
+ if (maxRetries === 0) {
26041
+ throw error40;
26042
+ }
26043
+ const errorMessage = getErrorMessage2(error40);
26044
+ const newErrors = [...errors4, error40];
26045
+ const tryNumber = newErrors.length;
26046
+ if (tryNumber > maxRetries) {
26047
+ throw createRetryError({
26048
+ message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
26049
+ reason: "maxRetriesExceeded",
26050
+ errors: newErrors
26051
+ });
26052
+ }
26053
+ if (await shouldRetry(error40) && tryNumber <= maxRetries) {
26054
+ await delay(getDelayInMs({
26055
+ error: error40,
26056
+ exponentialBackoffDelay: delayInMs
26057
+ }), { abortSignal });
26058
+ return retryWithExponentialBackoffInternal(f, {
26059
+ maxRetries,
26060
+ delayInMs: backoffFactor * delayInMs,
26061
+ backoffFactor,
26062
+ abortSignal,
26063
+ shouldRetry,
26064
+ getDelayInMs,
26065
+ createRetryError
26066
+ }, newErrors);
26067
+ }
26068
+ if (tryNumber === 1) {
26069
+ throw error40;
26070
+ }
26071
+ throw createRetryError({
26072
+ message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
26073
+ reason: "errorNotRetryable",
26074
+ errors: newErrors
26075
+ });
26076
+ }
26077
+ }
26078
+ async function readResponseBodyAsText({
26079
+ response,
26080
+ url: url2
26081
+ }) {
26082
+ return textDecoder.decode(await readResponseWithSizeLimit({
26083
+ response,
26084
+ url: url2
26085
+ }));
26086
+ }
25931
26087
  function withoutTrailingSlash(url2) {
25932
26088
  return url2 == null ? undefined : url2.replace(/\/$/, "");
25933
26089
  }
@@ -25995,7 +26151,7 @@ var DelayedPromise = class {
25995
26151
  isPending() {
25996
26152
  return this.status.type === "pending";
25997
26153
  }
25998
- }, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
26154
+ }, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, MAX_DOWNLOAD_REDIRECTS = 10, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
25999
26155
  prefix,
26000
26156
  size = 16,
26001
26157
  alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
@@ -26019,7 +26175,7 @@ var DelayedPromise = class {
26019
26175
  });
26020
26176
  }
26021
26177
  return () => `${prefix}${separator}${generator()}`;
26022
- }, generateId2, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.27", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
26178
+ }, generateId2, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.35", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
26023
26179
  url: url2,
26024
26180
  headers = {},
26025
26181
  successfulResponseHandler,
@@ -26405,12 +26561,28 @@ var DelayedPromise = class {
26405
26561
  } catch (error40) {
26406
26562
  throw handleFetchError({ error: error40, url: url2, requestBodyValues: body.values });
26407
26563
  }
26408
- }, createJsonErrorResponseHandler = ({
26564
+ }, retryWithExponentialBackoff = ({
26565
+ maxRetries = 2,
26566
+ initialDelayInMs = 2000,
26567
+ backoffFactor = 2,
26568
+ abortSignal,
26569
+ shouldRetry,
26570
+ getDelayInMs = ({ exponentialBackoffDelay }) => exponentialBackoffDelay,
26571
+ createRetryError = ({ message }) => new Error(message)
26572
+ }) => async (f) => retryWithExponentialBackoffInternal(f, {
26573
+ maxRetries,
26574
+ delayInMs: initialDelayInMs,
26575
+ backoffFactor,
26576
+ abortSignal,
26577
+ shouldRetry,
26578
+ getDelayInMs,
26579
+ createRetryError
26580
+ }), textDecoder, createJsonErrorResponseHandler = ({
26409
26581
  errorSchema,
26410
26582
  errorToMessage,
26411
26583
  isRetryable
26412
26584
  }) => async ({ response, url: url2, requestBodyValues }) => {
26413
- const responseBody = await response.text();
26585
+ const responseBody = await readResponseBodyAsText({ response, url: url2 });
26414
26586
  const responseHeaders = extractResponseHeaders(response);
26415
26587
  if (responseBody.trim() === "") {
26416
26588
  return {
@@ -26471,7 +26643,7 @@ var DelayedPromise = class {
26471
26643
  })
26472
26644
  };
26473
26645
  }, createJsonResponseHandler = (responseSchema) => async ({ response, url: url2, requestBodyValues }) => {
26474
- const responseBody = await response.text();
26646
+ const responseBody = await readResponseBodyAsText({ response, url: url2 });
26475
26647
  const parsedResult = await safeParseJSON({
26476
26648
  text: responseBody,
26477
26649
  schema: responseSchema
@@ -26627,9 +26799,10 @@ var init_dist3 = __esm(() => {
26627
26799
  ZodNull: "null"
26628
26800
  };
26629
26801
  schemaSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
26802
+ textDecoder = new TextDecoder;
26630
26803
  });
26631
26804
 
26632
- // node_modules/@ai-sdk/anthropic/dist/index.mjs
26805
+ // node_modules/.pnpm/@ai-sdk+anthropic@3.0.92_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.mjs
26633
26806
  var exports_dist = {};
26634
26807
  __export(exports_dist, {
26635
26808
  forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep,
@@ -27834,7 +28007,10 @@ async function convertToAnthropicMessagesPrompt({
27834
28007
  }
27835
28008
  }
27836
28009
  }
27837
- messages.push({ role: "assistant", content: anthropicContent });
28010
+ messages.push({
28011
+ role: "assistant",
28012
+ content: moveToolUseBlocksToEnd(anthropicContent)
28013
+ });
27838
28014
  break;
27839
28015
  }
27840
28016
  default: {
@@ -27894,6 +28070,24 @@ function groupIntoBlocks(prompt) {
27894
28070
  }
27895
28071
  return blocks;
27896
28072
  }
28073
+ function moveToolUseBlocksToEnd(content) {
28074
+ const result = [];
28075
+ let segment = [];
28076
+ function flushSegment() {
28077
+ result.push(...segment.filter((part) => part.type !== "tool_use"), ...segment.filter((part) => part.type === "tool_use"));
28078
+ segment = [];
28079
+ }
28080
+ for (const part of content) {
28081
+ if (part.type === "thinking" || part.type === "redacted_thinking") {
28082
+ flushSegment();
28083
+ result.push(part);
28084
+ } else {
28085
+ segment.push(part);
28086
+ }
28087
+ }
28088
+ flushSegment();
28089
+ return result;
28090
+ }
27897
28091
  function mapAnthropicStopReason({
27898
28092
  finishReason,
27899
28093
  isJsonResponseFromTool
@@ -28071,7 +28265,7 @@ function createCitationSource(citation, citationDocuments, generateId3) {
28071
28265
  };
28072
28266
  }
28073
28267
  function getModelCapabilities(modelId) {
28074
- if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5")) {
28268
+ if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5") || modelId.includes("claude-sonnet-5")) {
28075
28269
  return {
28076
28270
  maxOutputTokens: 128000,
28077
28271
  supportsStructuredOutput: true,
@@ -28262,7 +28456,7 @@ function forwardAnthropicContainerIdFromLastStep({
28262
28456
  }
28263
28457
  return;
28264
28458
  }
28265
- var VERSION2 = "3.0.82", anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicStopDetailsSchema, anthropicMessagesResponseSchema, anthropicMessagesChunkSchema, anthropicReasoningMetadataSchema, anthropicFilePartProviderOptions, anthropicLanguageModelOptions, MAX_CACHE_BREAKPOINTS = 4, CacheControlValidator = class {
28459
+ var VERSION2 = "3.0.92", anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicStopDetailsSchema, anthropicMessagesResponseSchema, anthropicMessagesChunkSchema, anthropicReasoningMetadataSchema, anthropicFilePartProviderOptions, anthropicLanguageModelOptions, MAX_CACHE_BREAKPOINTS = 4, CacheControlValidator = class {
28266
28460
  constructor() {
28267
28461
  this.breakpointCount = 0;
28268
28462
  this.warnings = [];
@@ -29414,6 +29608,7 @@ var VERSION2 = "3.0.82", anthropicErrorDataSchema, anthropicFailedResponseHandle
29414
29608
  "bash_code_execution"
29415
29609
  ].includes(part.name)) {
29416
29610
  const providerToolName = part.name === "text_editor_code_execution" || part.name === "bash_code_execution" ? "code_execution" : part.name;
29611
+ const providerToolInputType = part.name === "text_editor_code_execution" || part.name === "bash_code_execution" ? part.name : part.name === "code_execution" ? "programmatic-tool-call" : undefined;
29417
29612
  const customToolName = toolNameMapping.toCustomToolName(providerToolName);
29418
29613
  const finalInput = part.input != null && typeof part.input === "object" && Object.keys(part.input).length > 0 ? JSON.stringify(part.input) : "";
29419
29614
  contentBlocks[value.index] = {
@@ -29423,8 +29618,9 @@ var VERSION2 = "3.0.82", anthropicErrorDataSchema, anthropicFailedResponseHandle
29423
29618
  input: finalInput,
29424
29619
  providerExecuted: true,
29425
29620
  ...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
29426
- firstDelta: true,
29427
- providerToolName
29621
+ firstDelta: finalInput.length === 0,
29622
+ providerToolName,
29623
+ providerToolInputType
29428
29624
  };
29429
29625
  controller.enqueue({
29430
29626
  type: "tool-input-start",
@@ -29842,8 +30038,8 @@ var VERSION2 = "3.0.82", anthropicErrorDataSchema, anthropicFailedResponseHandle
29842
30038
  if ((contentBlock == null ? undefined : contentBlock.type) !== "tool-call") {
29843
30039
  return;
29844
30040
  }
29845
- if (contentBlock.firstDelta && contentBlock.providerToolName === "code_execution") {
29846
- delta = `{"type": "programmatic-tool-call",${delta.substring(1)}`;
30041
+ if (contentBlock.firstDelta && contentBlock.providerToolInputType != null) {
30042
+ delta = `{"type": "${contentBlock.providerToolInputType}",${delta.substring(1)}`;
29847
30043
  }
29848
30044
  controller.enqueue({
29849
30045
  type: "tool-input-delta",
@@ -31611,7 +31807,7 @@ var init_dist4 = __esm(() => {
31611
31807
  anthropic = createAnthropic();
31612
31808
  });
31613
31809
 
31614
- // node_modules/@ai-sdk/openai/dist/index.mjs
31810
+ // node_modules/.pnpm/@ai-sdk+openai@3.0.80_zod@3.25.76/node_modules/@ai-sdk/openai/dist/index.mjs
31615
31811
  var exports_dist2 = {};
31616
31812
  __export(exports_dist2, {
31617
31813
  openai: () => openai,
@@ -32157,7 +32353,7 @@ async function convertToOpenAIResponsesInput({
32157
32353
  hasApplyPatchTool = false,
32158
32354
  customProviderToolNames
32159
32355
  }) {
32160
- var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
32356
+ var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
32161
32357
  let input = [];
32162
32358
  const warnings = [];
32163
32359
  const processedApprovalIds = /* @__PURE__ */ new Set;
@@ -32290,10 +32486,11 @@ async function convertToOpenAIResponsesInput({
32290
32486
  }
32291
32487
  break;
32292
32488
  }
32293
- if (store && id != null) {
32294
- if (hasPreviousResponseId) {
32295
- break;
32296
- }
32489
+ if (hasPreviousResponseId && store && id != null) {
32490
+ break;
32491
+ }
32492
+ const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
32493
+ if (store && id != null && isProviderDefinedToolCall) {
32297
32494
  input.push({ type: "item_reference", id });
32298
32495
  break;
32299
32496
  }
@@ -32364,7 +32561,6 @@ async function convertToOpenAIResponsesInput({
32364
32561
  call_id: part.toolCallId,
32365
32562
  name: resolvedToolName,
32366
32563
  arguments: serializeToolCallArguments2(part.input),
32367
- id,
32368
32564
  ...namespace != null && { namespace }
32369
32565
  });
32370
32566
  break;
@@ -32378,7 +32574,7 @@ async function convertToOpenAIResponsesInput({
32378
32574
  }
32379
32575
  const resolvedResultToolName = toolNameMapping.toProviderToolName(part.toolName);
32380
32576
  if (resolvedResultToolName === "tool_search") {
32381
- const itemId = (_o = (_n = (_m = part.providerOptions) == null ? undefined : _m[providerOptionsName]) == null ? undefined : _n.itemId) != null ? _o : part.toolCallId;
32577
+ const itemId = (_p = (_o = (_n = part.providerOptions) == null ? undefined : _n[providerOptionsName]) == null ? undefined : _o.itemId) != null ? _p : part.toolCallId;
32382
32578
  if (store) {
32383
32579
  input.push({ type: "item_reference", id: itemId });
32384
32580
  } else if (part.output.type === "json") {
@@ -32419,7 +32615,7 @@ async function convertToOpenAIResponsesInput({
32419
32615
  break;
32420
32616
  }
32421
32617
  if (store) {
32422
- const itemId = (_r = (_q = (_p = part.providerOptions) == null ? undefined : _p[providerOptionsName]) == null ? undefined : _q.itemId) != null ? _r : part.toolCallId;
32618
+ const itemId = (_s = (_r = (_q = part.providerOptions) == null ? undefined : _q[providerOptionsName]) == null ? undefined : _r.itemId) != null ? _s : part.toolCallId;
32423
32619
  input.push({ type: "item_reference", id: itemId });
32424
32620
  } else {
32425
32621
  warnings.push({
@@ -32529,7 +32725,7 @@ async function convertToOpenAIResponsesInput({
32529
32725
  }
32530
32726
  const output = part.output;
32531
32727
  if (output.type === "execution-denied") {
32532
- const approvalId = (_t = (_s = output.providerOptions) == null ? undefined : _s.openai) == null ? undefined : _t.approvalId;
32728
+ const approvalId = (_u = (_t = output.providerOptions) == null ? undefined : _t.openai) == null ? undefined : _u.approvalId;
32533
32729
  if (approvalId) {
32534
32730
  continue;
32535
32731
  }
@@ -32601,7 +32797,7 @@ async function convertToOpenAIResponsesInput({
32601
32797
  outputValue = output.value;
32602
32798
  break;
32603
32799
  case "execution-denied":
32604
- outputValue = (_u = output.reason) != null ? _u : "Tool execution denied.";
32800
+ outputValue = (_v = output.reason) != null ? _v : "Tool execution denied.";
32605
32801
  break;
32606
32802
  case "json":
32607
32803
  case "error-json":
@@ -32662,7 +32858,7 @@ async function convertToOpenAIResponsesInput({
32662
32858
  contentValue = output.value;
32663
32859
  break;
32664
32860
  case "execution-denied":
32665
- contentValue = (_v = output.reason) != null ? _v : "Tool execution denied.";
32861
+ contentValue = (_w = output.reason) != null ? _w : "Tool execution denied.";
32666
32862
  break;
32667
32863
  case "json":
32668
32864
  case "error-json":
@@ -33087,6 +33283,31 @@ function extractApprovalRequestIdToToolCallIdMapping(prompt) {
33087
33283
  function isTextDeltaChunk(chunk) {
33088
33284
  return chunk.type === "response.output_text.delta";
33089
33285
  }
33286
+ function isOpenAIChatCompletionChunk(value) {
33287
+ const chunk = asRecord(value);
33288
+ return chunk != null && Array.isArray(chunk.choices) && typeof chunk.type !== "string";
33289
+ }
33290
+ function createOpenAIResponsesChatCompletionsMismatchError({
33291
+ value,
33292
+ cause,
33293
+ url: url2,
33294
+ requestBodyValues,
33295
+ responseHeaders
33296
+ }) {
33297
+ return new APICallError({
33298
+ 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.",
33299
+ url: url2,
33300
+ requestBodyValues,
33301
+ responseHeaders,
33302
+ responseBody: JSON.stringify(value),
33303
+ cause,
33304
+ data: value,
33305
+ isRetryable: false
33306
+ });
33307
+ }
33308
+ function asRecord(value) {
33309
+ return typeof value === "object" && value != null ? value : undefined;
33310
+ }
33090
33311
  function isResponseOutputItemDoneChunk(chunk) {
33091
33312
  return chunk.type === "response.output_item.done";
33092
33313
  }
@@ -34892,11 +35113,12 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
34892
35113
  providerOptionsName,
34893
35114
  isShellProviderExecuted
34894
35115
  } = await this.getArgs(options);
35116
+ const url2 = this.config.url({
35117
+ path: "/responses",
35118
+ modelId: this.modelId
35119
+ });
34895
35120
  const { responseHeaders, value: response } = await postJsonToApi({
34896
- url: this.config.url({
34897
- path: "/responses",
34898
- modelId: this.modelId
34899
- }),
35121
+ url: url2,
34900
35122
  headers: combineHeaders(this.config.headers(), options.headers),
34901
35123
  body: {
34902
35124
  ...body,
@@ -34935,8 +35157,15 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
34935
35157
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
34936
35158
  }
34937
35159
  if (!chunk.success) {
35160
+ const error40 = isOpenAIChatCompletionChunk(chunk.rawValue) ? createOpenAIResponsesChatCompletionsMismatchError({
35161
+ value: chunk.rawValue,
35162
+ cause: chunk.error,
35163
+ url: url2,
35164
+ requestBodyValues: body,
35165
+ responseHeaders
35166
+ }) : chunk.error;
34938
35167
  finishReason = { unified: "error", raw: undefined };
34939
- controller.enqueue({ type: "error", error: chunk.error });
35168
+ controller.enqueue({ type: "error", error: error40 });
34940
35169
  return;
34941
35170
  }
34942
35171
  const value = chunk.value;
@@ -35924,7 +36153,7 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
35924
36153
  }
35925
36154
  };
35926
36155
  }
35927
- }, VERSION3 = "3.0.69", openai;
36156
+ }, VERSION3 = "3.0.80", openai;
35928
36157
  var init_dist5 = __esm(() => {
35929
36158
  init_dist3();
35930
36159
  init_dist();
@@ -36641,9 +36870,16 @@ var init_dist5 = __esm(() => {
36641
36870
  incomplete_details: exports_external2.object({ reason: exports_external2.string() }).nullish(),
36642
36871
  usage: exports_external2.object({
36643
36872
  input_tokens: exports_external2.number(),
36644
- input_tokens_details: exports_external2.object({ cached_tokens: exports_external2.number().nullish() }).nullish(),
36873
+ input_tokens_details: exports_external2.object({
36874
+ cached_tokens: exports_external2.number().nullish(),
36875
+ orchestration_input_tokens: exports_external2.number().nullish(),
36876
+ orchestration_input_cached_tokens: exports_external2.number().nullish()
36877
+ }).nullish(),
36645
36878
  output_tokens: exports_external2.number(),
36646
- output_tokens_details: exports_external2.object({ reasoning_tokens: exports_external2.number().nullish() }).nullish()
36879
+ output_tokens_details: exports_external2.object({
36880
+ reasoning_tokens: exports_external2.number().nullish(),
36881
+ orchestration_output_tokens: exports_external2.number().nullish()
36882
+ }).nullish()
36647
36883
  }),
36648
36884
  service_tier: exports_external2.string().nullish()
36649
36885
  })
@@ -36658,9 +36894,16 @@ var init_dist5 = __esm(() => {
36658
36894
  incomplete_details: exports_external2.object({ reason: exports_external2.string() }).nullish(),
36659
36895
  usage: exports_external2.object({
36660
36896
  input_tokens: exports_external2.number(),
36661
- input_tokens_details: exports_external2.object({ cached_tokens: exports_external2.number().nullish() }).nullish(),
36897
+ input_tokens_details: exports_external2.object({
36898
+ cached_tokens: exports_external2.number().nullish(),
36899
+ orchestration_input_tokens: exports_external2.number().nullish(),
36900
+ orchestration_input_cached_tokens: exports_external2.number().nullish()
36901
+ }).nullish(),
36662
36902
  output_tokens: exports_external2.number(),
36663
- output_tokens_details: exports_external2.object({ reasoning_tokens: exports_external2.number().nullish() }).nullish()
36903
+ output_tokens_details: exports_external2.object({
36904
+ reasoning_tokens: exports_external2.number().nullish(),
36905
+ orchestration_output_tokens: exports_external2.number().nullish()
36906
+ }).nullish()
36664
36907
  }).nullish(),
36665
36908
  service_tier: exports_external2.string().nullish()
36666
36909
  })
@@ -37397,9 +37640,16 @@ var init_dist5 = __esm(() => {
37397
37640
  incomplete_details: exports_external2.object({ reason: exports_external2.string() }).nullish(),
37398
37641
  usage: exports_external2.object({
37399
37642
  input_tokens: exports_external2.number(),
37400
- input_tokens_details: exports_external2.object({ cached_tokens: exports_external2.number().nullish() }).nullish(),
37643
+ input_tokens_details: exports_external2.object({
37644
+ cached_tokens: exports_external2.number().nullish(),
37645
+ orchestration_input_tokens: exports_external2.number().nullish(),
37646
+ orchestration_input_cached_tokens: exports_external2.number().nullish()
37647
+ }).nullish(),
37401
37648
  output_tokens: exports_external2.number(),
37402
- output_tokens_details: exports_external2.object({ reasoning_tokens: exports_external2.number().nullish() }).nullish()
37649
+ output_tokens_details: exports_external2.object({
37650
+ reasoning_tokens: exports_external2.number().nullish(),
37651
+ orchestration_output_tokens: exports_external2.number().nullish()
37652
+ }).nullish()
37403
37653
  }).optional()
37404
37654
  })));
37405
37655
  openaiResponsesReasoningModelIds = [
@@ -37472,6 +37722,7 @@ var init_dist5 = __esm(() => {
37472
37722
  include: exports_external2.array(exports_external2.enum([
37473
37723
  "reasoning.encrypted_content",
37474
37724
  "file_search_call.results",
37725
+ "web_search_call.results",
37475
37726
  "message.output_text.logprobs"
37476
37727
  ])).nullish(),
37477
37728
  instructions: exports_external2.string().nullish(),
@@ -37594,7 +37845,7 @@ var init_dist5 = __esm(() => {
37594
37845
  openai = createOpenAI();
37595
37846
  });
37596
37847
 
37597
- // node_modules/@ai-sdk/openai-compatible/dist/index.mjs
37848
+ // node_modules/.pnpm/@ai-sdk+openai-compatible@2.0.56_zod@3.25.76/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
37598
37849
  var exports_dist3 = {};
37599
37850
  __export(exports_dist3, {
37600
37851
  createOpenAICompatible: () => createOpenAICompatible,
@@ -38999,7 +39250,7 @@ var openaiCompatibleErrorDataSchema, defaultOpenAICompatibleErrorStructure, open
38999
39250
  }
39000
39251
  };
39001
39252
  }
39002
- }, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.48";
39253
+ }, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.56";
39003
39254
  var init_dist6 = __esm(() => {
39004
39255
  init_dist();
39005
39256
  init_dist3();
@@ -39141,7 +39392,7 @@ var init_dist6 = __esm(() => {
39141
39392
  });
39142
39393
  });
39143
39394
 
39144
- // node_modules/@vercel/oidc/dist/get-context.js
39395
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/get-context.js
39145
39396
  var require_get_context = __commonJS((exports, module) => {
39146
39397
  var __defProp2 = Object.defineProperty;
39147
39398
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -39173,7 +39424,7 @@ var require_get_context = __commonJS((exports, module) => {
39173
39424
  }
39174
39425
  });
39175
39426
 
39176
- // node_modules/@vercel/oidc/dist/token-error.js
39427
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token-error.js
39177
39428
  var require_token_error = __commonJS((exports, module) => {
39178
39429
  var __defProp2 = Object.defineProperty;
39179
39430
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -39213,7 +39464,7 @@ var require_token_error = __commonJS((exports, module) => {
39213
39464
  }
39214
39465
  });
39215
39466
 
39216
- // node_modules/@vercel/oidc/dist/token-io.js
39467
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token-io.js
39217
39468
  var require_token_io = __commonJS((exports, module) => {
39218
39469
  var __create2 = Object.create;
39219
39470
  var __defProp2 = Object.defineProperty;
@@ -39280,7 +39531,7 @@ var require_token_io = __commonJS((exports, module) => {
39280
39531
  }
39281
39532
  });
39282
39533
 
39283
- // node_modules/@vercel/oidc/dist/auth-config.js
39534
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/auth-config.js
39284
39535
  var require_auth_config = __commonJS((exports, module) => {
39285
39536
  var __create2 = Object.create;
39286
39537
  var __defProp2 = Object.defineProperty;
@@ -39353,7 +39604,7 @@ var require_auth_config = __commonJS((exports, module) => {
39353
39604
  }
39354
39605
  });
39355
39606
 
39356
- // node_modules/@vercel/oidc/dist/oauth.js
39607
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/oauth.js
39357
39608
  var require_oauth = __commonJS((exports, module) => {
39358
39609
  var __defProp2 = Object.defineProperty;
39359
39610
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -39439,7 +39690,7 @@ var require_oauth = __commonJS((exports, module) => {
39439
39690
  }
39440
39691
  });
39441
39692
 
39442
- // node_modules/@vercel/oidc/dist/auth-errors.js
39693
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/auth-errors.js
39443
39694
  var require_auth_errors = __commonJS((exports, module) => {
39444
39695
  var __defProp2 = Object.defineProperty;
39445
39696
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -39480,7 +39731,7 @@ var require_auth_errors = __commonJS((exports, module) => {
39480
39731
  }
39481
39732
  });
39482
39733
 
39483
- // node_modules/@vercel/oidc/dist/token-util.js
39734
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token-util.js
39484
39735
  var require_token_util = __commonJS((exports, module) => {
39485
39736
  var __create2 = Object.create;
39486
39737
  var __defProp2 = Object.defineProperty;
@@ -39645,7 +39896,7 @@ var require_token_util = __commonJS((exports, module) => {
39645
39896
  }
39646
39897
  });
39647
39898
 
39648
- // node_modules/@vercel/oidc/dist/token.js
39899
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token.js
39649
39900
  var require_token = __commonJS((exports, module) => {
39650
39901
  var __defProp2 = Object.defineProperty;
39651
39902
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -39702,7 +39953,7 @@ var require_token = __commonJS((exports, module) => {
39702
39953
  }
39703
39954
  });
39704
39955
 
39705
- // node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js
39956
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js
39706
39957
  var require_get_vercel_oidc_token = __commonJS((exports, module) => {
39707
39958
  var __defProp2 = Object.defineProperty;
39708
39959
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -39768,7 +40019,7 @@ ${error40.message}`;
39768
40019
  }
39769
40020
  });
39770
40021
 
39771
- // node_modules/@vercel/oidc/dist/index.js
40022
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/index.js
39772
40023
  var require_dist = __commonJS((exports, module) => {
39773
40024
  var __defProp2 = Object.defineProperty;
39774
40025
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -39803,7 +40054,7 @@ var require_dist = __commonJS((exports, module) => {
39803
40054
  var import_token_util = require_token_util();
39804
40055
  });
39805
40056
 
39806
- // node_modules/@ai-sdk/gateway/dist/index.mjs
40057
+ // node_modules/.pnpm/@ai-sdk+gateway@3.0.143_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.mjs
39807
40058
  async function createGatewayErrorFromResponse({
39808
40059
  response,
39809
40060
  statusCode,
@@ -39811,7 +40062,7 @@ async function createGatewayErrorFromResponse({
39811
40062
  cause,
39812
40063
  authMethod
39813
40064
  }) {
39814
- var _a102;
40065
+ var _a112;
39815
40066
  const parseResult = await safeValidateTypes({
39816
40067
  value: response,
39817
40068
  schema: gatewayErrorResponseSchema
@@ -39830,7 +40081,7 @@ async function createGatewayErrorFromResponse({
39830
40081
  const validatedResponse = parseResult.value;
39831
40082
  const errorType = validatedResponse.error.type;
39832
40083
  const message = validatedResponse.error.message;
39833
- const generationId = (_a102 = validatedResponse.generationId) != null ? _a102 : undefined;
40084
+ const generationId = (_a112 = validatedResponse.generationId) != null ? _a112 : undefined;
39834
40085
  switch (errorType) {
39835
40086
  case "authentication_error":
39836
40087
  return GatewayAuthenticationError.createContextualError({
@@ -39881,6 +40132,13 @@ async function createGatewayErrorFromResponse({
39881
40132
  cause,
39882
40133
  generationId
39883
40134
  });
40135
+ case "forbidden":
40136
+ return new GatewayForbiddenError({
40137
+ message,
40138
+ statusCode,
40139
+ cause,
40140
+ generationId
40141
+ });
39884
40142
  default:
39885
40143
  return new GatewayInternalServerError({
39886
40144
  message,
@@ -39919,7 +40177,7 @@ function isTimeoutError(error40) {
39919
40177
  return false;
39920
40178
  }
39921
40179
  async function asGatewayError(error40, authMethod) {
39922
- var _a102;
40180
+ var _a112;
39923
40181
  if (GatewayError.isInstance(error40)) {
39924
40182
  return error40;
39925
40183
  }
@@ -39938,7 +40196,7 @@ async function asGatewayError(error40, authMethod) {
39938
40196
  }
39939
40197
  return await createGatewayErrorFromResponse({
39940
40198
  response: extractApiCallResponse(error40),
39941
- statusCode: (_a102 = error40.statusCode) != null ? _a102 : 500,
40199
+ statusCode: (_a112 = error40.statusCode) != null ? _a112 : 500,
39942
40200
  defaultMessage: "Gateway request failed",
39943
40201
  cause: error40,
39944
40202
  authMethod
@@ -39978,16 +40236,16 @@ function maybeEncodeVideoFile(file2) {
39978
40236
  return file2;
39979
40237
  }
39980
40238
  async function getVercelRequestId() {
39981
- var _a102;
39982
- return (_a102 = import_oidc.getContext().headers) == null ? undefined : _a102["x-vercel-id"];
40239
+ var _a112;
40240
+ return (_a112 = import_oidc.getContext().headers) == null ? undefined : _a112["x-vercel-id"];
39983
40241
  }
39984
40242
  function createGatewayProvider(options = {}) {
39985
- var _a102, _b102;
40243
+ var _a112, _b112;
39986
40244
  let pendingMetadata = null;
39987
40245
  let metadataCache = null;
39988
- const cacheRefreshMillis = (_a102 = options.metadataCacheRefreshMillis) != null ? _a102 : 1000 * 60 * 5;
40246
+ const cacheRefreshMillis = (_a112 = options.metadataCacheRefreshMillis) != null ? _a112 : 1000 * 60 * 5;
39989
40247
  let lastFetchTime = 0;
39990
- const baseURL = (_b102 = withoutTrailingSlash(options.baseURL)) != null ? _b102 : "https://ai-gateway.vercel.sh/v3/ai";
40248
+ const baseURL = (_b112 = withoutTrailingSlash(options.baseURL)) != null ? _b112 : "https://ai-gateway.vercel.sh/v3/ai";
39991
40249
  const getHeaders = async () => {
39992
40250
  try {
39993
40251
  const auth = await getGatewayAuthToken(options);
@@ -40044,8 +40302,8 @@ function createGatewayProvider(options = {}) {
40044
40302
  });
40045
40303
  };
40046
40304
  const getAvailableModels = async () => {
40047
- var _a112, _b112, _c;
40048
- const now3 = (_c = (_b112 = (_a112 = options._internal) == null ? undefined : _a112.currentDate) == null ? undefined : _b112.call(_a112).getTime()) != null ? _c : Date.now();
40305
+ var _a122, _b122, _c;
40306
+ const now3 = (_c = (_b122 = (_a122 = options._internal) == null ? undefined : _a122.currentDate) == null ? undefined : _b122.call(_a122).getTime()) != null ? _c : Date.now();
40049
40307
  if (!pendingMetadata || now3 - lastFetchTime > cacheRefreshMillis) {
40050
40308
  lastFetchTime = now3;
40051
40309
  pendingMetadata = new GatewayFetchMetadata({
@@ -40140,6 +40398,28 @@ function createGatewayProvider(options = {}) {
40140
40398
  };
40141
40399
  provider.rerankingModel = createRerankingModel;
40142
40400
  provider.reranking = createRerankingModel;
40401
+ const createSpeechModel = (modelId) => {
40402
+ return new GatewaySpeechModel(modelId, {
40403
+ provider: "gateway",
40404
+ baseURL,
40405
+ headers: getHeaders,
40406
+ fetch: options.fetch,
40407
+ o11yHeaders: createO11yHeaders()
40408
+ });
40409
+ };
40410
+ provider.speechModel = createSpeechModel;
40411
+ provider.speech = createSpeechModel;
40412
+ const createTranscriptionModel = (modelId) => {
40413
+ return new GatewayTranscriptionModel(modelId, {
40414
+ provider: "gateway",
40415
+ baseURL,
40416
+ headers: getHeaders,
40417
+ fetch: options.fetch,
40418
+ o11yHeaders: createO11yHeaders()
40419
+ });
40420
+ };
40421
+ provider.transcriptionModel = createTranscriptionModel;
40422
+ provider.transcription = createTranscriptionModel;
40143
40423
  provider.chat = provider.languageModel;
40144
40424
  provider.embedding = provider.embeddingModel;
40145
40425
  provider.image = provider.imageModel;
@@ -40164,7 +40444,7 @@ async function getGatewayAuthToken(options) {
40164
40444
  authMethod: "oidc"
40165
40445
  };
40166
40446
  }
40167
- 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 {
40447
+ 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 {
40168
40448
  constructor(config2) {
40169
40449
  this.config = config2;
40170
40450
  }
@@ -40410,7 +40690,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
40410
40690
  abortSignal,
40411
40691
  providerOptions
40412
40692
  }) {
40413
- var _a102;
40693
+ var _a112, _b112;
40414
40694
  const resolvedHeaders = await resolve5(this.config.headers());
40415
40695
  try {
40416
40696
  const {
@@ -40434,10 +40714,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
40434
40714
  });
40435
40715
  return {
40436
40716
  embeddings: responseBody.embeddings,
40437
- usage: (_a102 = responseBody.usage) != null ? _a102 : undefined,
40717
+ usage: (_a112 = responseBody.usage) != null ? _a112 : undefined,
40438
40718
  providerMetadata: responseBody.providerMetadata,
40439
40719
  response: { headers: responseHeaders, body: rawValue },
40440
- warnings: []
40720
+ warnings: (_b112 = responseBody.warnings) != null ? _b112 : []
40441
40721
  };
40442
40722
  } catch (error40) {
40443
40723
  throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders));
@@ -40452,7 +40732,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
40452
40732
  "ai-model-id": this.modelId
40453
40733
  };
40454
40734
  }
40455
- }, gatewayEmbeddingResponseSchema, GatewayImageModel = class {
40735
+ }, gatewayEmbeddingWarningSchema, gatewayEmbeddingResponseSchema, GatewayImageModel = class {
40456
40736
  constructor(modelId, config2) {
40457
40737
  this.modelId = modelId;
40458
40738
  this.config = config2;
@@ -40474,7 +40754,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
40474
40754
  headers,
40475
40755
  abortSignal
40476
40756
  }) {
40477
- var _a102, _b102, _c, _d;
40757
+ var _a112, _b112, _c, _d;
40478
40758
  const resolvedHeaders = await resolve5(this.config.headers());
40479
40759
  try {
40480
40760
  const {
@@ -40506,7 +40786,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
40506
40786
  });
40507
40787
  return {
40508
40788
  images: responseBody.images,
40509
- warnings: (_a102 = responseBody.warnings) != null ? _a102 : [],
40789
+ warnings: (_a112 = responseBody.warnings) != null ? _a112 : [],
40510
40790
  providerMetadata: responseBody.providerMetadata,
40511
40791
  response: {
40512
40792
  timestamp: /* @__PURE__ */ new Date,
@@ -40515,7 +40795,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
40515
40795
  },
40516
40796
  ...responseBody.usage != null && {
40517
40797
  usage: {
40518
- inputTokens: (_b102 = responseBody.usage.inputTokens) != null ? _b102 : undefined,
40798
+ inputTokens: (_b112 = responseBody.usage.inputTokens) != null ? _b112 : undefined,
40519
40799
  outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : undefined,
40520
40800
  totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : undefined
40521
40801
  }
@@ -40552,12 +40832,15 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
40552
40832
  duration: duration3,
40553
40833
  fps,
40554
40834
  seed,
40835
+ generateAudio,
40555
40836
  image,
40837
+ frameImages,
40838
+ inputReferences,
40556
40839
  providerOptions,
40557
40840
  headers,
40558
40841
  abortSignal
40559
40842
  }) {
40560
- var _a102;
40843
+ var _a112;
40561
40844
  const resolvedHeaders = await resolve5(this.config.headers());
40562
40845
  try {
40563
40846
  const { responseHeaders, value: responseBody } = await postJsonToApi({
@@ -40571,8 +40854,18 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
40571
40854
  ...duration3 && { duration: duration3 },
40572
40855
  ...fps && { fps },
40573
40856
  ...seed && { seed },
40857
+ ...generateAudio !== undefined && { generateAudio },
40574
40858
  ...providerOptions && { providerOptions },
40575
- ...image && { image: maybeEncodeVideoFile(image) }
40859
+ ...image && { image: maybeEncodeVideoFile(image) },
40860
+ ...frameImages && {
40861
+ frameImages: frameImages.map((frame) => ({
40862
+ ...frame,
40863
+ image: maybeEncodeVideoFile(frame.image)
40864
+ }))
40865
+ },
40866
+ ...inputReferences && {
40867
+ inputReferences: inputReferences.map((reference) => maybeEncodeVideoFile(reference))
40868
+ }
40576
40869
  },
40577
40870
  successfulResponseHandler: async ({
40578
40871
  response,
@@ -40647,7 +40940,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
40647
40940
  });
40648
40941
  return {
40649
40942
  videos: responseBody.videos,
40650
- warnings: (_a102 = responseBody.warnings) != null ? _a102 : [],
40943
+ warnings: (_a112 = responseBody.warnings) != null ? _a112 : [],
40651
40944
  providerMetadata: responseBody.providerMetadata,
40652
40945
  response: {
40653
40946
  timestamp: /* @__PURE__ */ new Date,
@@ -40685,6 +40978,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
40685
40978
  abortSignal,
40686
40979
  providerOptions
40687
40980
  }) {
40981
+ var _a112;
40688
40982
  const resolvedHeaders = await resolve5(this.config.headers());
40689
40983
  try {
40690
40984
  const {
@@ -40712,7 +41006,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
40712
41006
  ranking: responseBody.ranking,
40713
41007
  providerMetadata: responseBody.providerMetadata,
40714
41008
  response: { headers: responseHeaders, body: rawValue },
40715
- warnings: []
41009
+ warnings: (_a112 = responseBody.warnings) != null ? _a112 : []
40716
41010
  };
40717
41011
  } catch (error40) {
40718
41012
  throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders));
@@ -40727,7 +41021,144 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
40727
41021
  "ai-model-id": this.modelId
40728
41022
  };
40729
41023
  }
40730
- }, 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;
41024
+ }, gatewayRerankingWarningSchema, gatewayRerankingResponseSchema, GatewaySpeechModel = class {
41025
+ constructor(modelId, config2) {
41026
+ this.modelId = modelId;
41027
+ this.config = config2;
41028
+ this.specificationVersion = "v3";
41029
+ }
41030
+ get provider() {
41031
+ return this.config.provider;
41032
+ }
41033
+ async doGenerate({
41034
+ text: text2,
41035
+ voice,
41036
+ outputFormat,
41037
+ instructions,
41038
+ speed,
41039
+ language,
41040
+ providerOptions,
41041
+ headers,
41042
+ abortSignal
41043
+ }) {
41044
+ var _a112;
41045
+ const resolvedHeaders = await resolve5(this.config.headers());
41046
+ try {
41047
+ const {
41048
+ responseHeaders,
41049
+ value: responseBody,
41050
+ rawValue
41051
+ } = await postJsonToApi({
41052
+ url: this.getUrl(),
41053
+ headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve5(this.config.o11yHeaders)),
41054
+ body: {
41055
+ text: text2,
41056
+ ...voice && { voice },
41057
+ ...outputFormat && { outputFormat },
41058
+ ...instructions && { instructions },
41059
+ ...speed != null && { speed },
41060
+ ...language && { language },
41061
+ ...providerOptions && { providerOptions }
41062
+ },
41063
+ successfulResponseHandler: createJsonResponseHandler(gatewaySpeechResponseSchema),
41064
+ failedResponseHandler: createJsonErrorResponseHandler({
41065
+ errorSchema: exports_external2.any(),
41066
+ errorToMessage: (data) => data
41067
+ }),
41068
+ ...abortSignal && { abortSignal },
41069
+ fetch: this.config.fetch
41070
+ });
41071
+ return {
41072
+ audio: responseBody.audio,
41073
+ warnings: (_a112 = responseBody.warnings) != null ? _a112 : [],
41074
+ providerMetadata: responseBody.providerMetadata,
41075
+ response: {
41076
+ timestamp: /* @__PURE__ */ new Date,
41077
+ modelId: this.modelId,
41078
+ headers: responseHeaders,
41079
+ body: rawValue
41080
+ }
41081
+ };
41082
+ } catch (error40) {
41083
+ throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders != null ? resolvedHeaders : {}));
41084
+ }
41085
+ }
41086
+ getUrl() {
41087
+ return `${this.config.baseURL}/speech-model`;
41088
+ }
41089
+ getModelConfigHeaders() {
41090
+ return {
41091
+ "ai-speech-model-specification-version": "3",
41092
+ "ai-model-id": this.modelId
41093
+ };
41094
+ }
41095
+ }, providerMetadataEntrySchema3, gatewaySpeechWarningSchema, gatewaySpeechResponseSchema, GatewayTranscriptionModel = class {
41096
+ constructor(modelId, config2) {
41097
+ this.modelId = modelId;
41098
+ this.config = config2;
41099
+ this.specificationVersion = "v3";
41100
+ }
41101
+ get provider() {
41102
+ return this.config.provider;
41103
+ }
41104
+ async doGenerate({
41105
+ audio,
41106
+ mediaType,
41107
+ providerOptions,
41108
+ headers,
41109
+ abortSignal
41110
+ }) {
41111
+ var _a112, _b112, _c, _d;
41112
+ const resolvedHeaders = await resolve5(this.config.headers());
41113
+ try {
41114
+ const {
41115
+ responseHeaders,
41116
+ value: responseBody,
41117
+ rawValue
41118
+ } = await postJsonToApi({
41119
+ url: this.getUrl(),
41120
+ headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve5(this.config.o11yHeaders)),
41121
+ body: {
41122
+ audio: audio instanceof Uint8Array ? convertUint8ArrayToBase64(audio) : audio,
41123
+ mediaType,
41124
+ ...providerOptions && { providerOptions }
41125
+ },
41126
+ successfulResponseHandler: createJsonResponseHandler(gatewayTranscriptionResponseSchema),
41127
+ failedResponseHandler: createJsonErrorResponseHandler({
41128
+ errorSchema: exports_external2.any(),
41129
+ errorToMessage: (data) => data
41130
+ }),
41131
+ ...abortSignal && { abortSignal },
41132
+ fetch: this.config.fetch
41133
+ });
41134
+ return {
41135
+ text: responseBody.text,
41136
+ segments: (_a112 = responseBody.segments) != null ? _a112 : [],
41137
+ language: (_b112 = responseBody.language) != null ? _b112 : undefined,
41138
+ durationInSeconds: (_c = responseBody.durationInSeconds) != null ? _c : undefined,
41139
+ warnings: (_d = responseBody.warnings) != null ? _d : [],
41140
+ providerMetadata: responseBody.providerMetadata,
41141
+ response: {
41142
+ timestamp: /* @__PURE__ */ new Date,
41143
+ modelId: this.modelId,
41144
+ headers: responseHeaders,
41145
+ body: rawValue
41146
+ }
41147
+ };
41148
+ } catch (error40) {
41149
+ throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders != null ? resolvedHeaders : {}));
41150
+ }
41151
+ }
41152
+ getUrl() {
41153
+ return `${this.config.baseURL}/transcription-model`;
41154
+ }
41155
+ getModelConfigHeaders() {
41156
+ return {
41157
+ "ai-transcription-model-specification-version": "3",
41158
+ "ai-model-id": this.modelId
41159
+ };
41160
+ }
41161
+ }, 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;
40731
41162
  var init_dist7 = __esm(() => {
40732
41163
  init_dist3();
40733
41164
  init_dist();
@@ -40755,6 +41186,12 @@ var init_dist7 = __esm(() => {
40755
41186
  init_dist3();
40756
41187
  init_v4();
40757
41188
  init_dist3();
41189
+ init_v4();
41190
+ init_dist3();
41191
+ init_v4();
41192
+ init_dist3();
41193
+ init_zod();
41194
+ init_dist3();
40758
41195
  init_zod();
40759
41196
  init_dist3();
40760
41197
  init_zod();
@@ -40936,7 +41373,25 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
40936
41373
  };
40937
41374
  marker82 = `vercel.ai.gateway.error.${name72}`;
40938
41375
  symbol82 = Symbol.for(marker82);
40939
- GatewayResponseError = class extends (_b82 = GatewayError, _a82 = symbol82, _b82) {
41376
+ GatewayForbiddenError = class extends (_b82 = GatewayError, _a82 = symbol82, _b82) {
41377
+ constructor({
41378
+ message = "Forbidden",
41379
+ statusCode = 403,
41380
+ cause,
41381
+ generationId
41382
+ } = {}) {
41383
+ super({ message, statusCode, cause, generationId });
41384
+ this[_a82] = true;
41385
+ this.name = name72;
41386
+ this.type = "forbidden";
41387
+ }
41388
+ static isInstance(error40) {
41389
+ return GatewayError.hasMarker(error40) && symbol82 in error40;
41390
+ }
41391
+ };
41392
+ marker92 = `vercel.ai.gateway.error.${name82}`;
41393
+ symbol92 = Symbol.for(marker92);
41394
+ GatewayResponseError = class extends (_b92 = GatewayError, _a92 = symbol92, _b92) {
40940
41395
  constructor({
40941
41396
  message = "Invalid response from Gateway",
40942
41397
  statusCode = 502,
@@ -40946,14 +41401,14 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
40946
41401
  generationId
40947
41402
  } = {}) {
40948
41403
  super({ message, statusCode, cause, generationId });
40949
- this[_a82] = true;
40950
- this.name = name72;
41404
+ this[_a92] = true;
41405
+ this.name = name82;
40951
41406
  this.type = "response_error";
40952
41407
  this.response = response;
40953
41408
  this.validationError = validationError;
40954
41409
  }
40955
41410
  static isInstance(error40) {
40956
- return GatewayError.hasMarker(error40) && symbol82 in error40;
41411
+ return GatewayError.hasMarker(error40) && symbol92 in error40;
40957
41412
  }
40958
41413
  };
40959
41414
  gatewayErrorResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
@@ -40965,9 +41420,9 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
40965
41420
  }),
40966
41421
  generationId: exports_external2.string().nullish()
40967
41422
  })));
40968
- marker92 = `vercel.ai.gateway.error.${name82}`;
40969
- symbol92 = Symbol.for(marker92);
40970
- GatewayTimeoutError = class _GatewayTimeoutError extends (_b92 = GatewayError, _a92 = symbol92, _b92) {
41423
+ marker102 = `vercel.ai.gateway.error.${name92}`;
41424
+ symbol102 = Symbol.for(marker102);
41425
+ GatewayTimeoutError = class _GatewayTimeoutError extends (_b102 = GatewayError, _a102 = symbol102, _b102) {
40971
41426
  constructor({
40972
41427
  message = "Request timed out",
40973
41428
  statusCode = 408,
@@ -40975,12 +41430,12 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
40975
41430
  generationId
40976
41431
  } = {}) {
40977
41432
  super({ message, statusCode, cause, generationId });
40978
- this[_a92] = true;
40979
- this.name = name82;
41433
+ this[_a102] = true;
41434
+ this.name = name92;
40980
41435
  this.type = "timeout_error";
40981
41436
  }
40982
41437
  static isInstance(error40) {
40983
- return GatewayError.hasMarker(error40) && symbol92 in error40;
41438
+ return GatewayError.hasMarker(error40) && symbol102 in error40;
40984
41439
  }
40985
41440
  static createTimeoutError({
40986
41441
  originalMessage,
@@ -41005,6 +41460,8 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
41005
41460
  "image",
41006
41461
  "language",
41007
41462
  "reranking",
41463
+ "speech",
41464
+ "transcription",
41008
41465
  "video"
41009
41466
  ];
41010
41467
  gatewayAvailableModelsResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
@@ -41131,9 +41588,26 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
41131
41588
  billableWebSearchCalls: billable_web_search_calls
41132
41589
  }))
41133
41590
  }).transform(({ data }) => data)));
41591
+ gatewayEmbeddingWarningSchema = exports_external2.discriminatedUnion("type", [
41592
+ exports_external2.object({
41593
+ type: exports_external2.literal("unsupported"),
41594
+ feature: exports_external2.string(),
41595
+ details: exports_external2.string().optional()
41596
+ }),
41597
+ exports_external2.object({
41598
+ type: exports_external2.literal("compatibility"),
41599
+ feature: exports_external2.string(),
41600
+ details: exports_external2.string().optional()
41601
+ }),
41602
+ exports_external2.object({
41603
+ type: exports_external2.literal("other"),
41604
+ message: exports_external2.string()
41605
+ })
41606
+ ]);
41134
41607
  gatewayEmbeddingResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
41135
41608
  embeddings: exports_external2.array(exports_external2.array(exports_external2.number())),
41136
41609
  usage: exports_external2.object({ tokens: exports_external2.number() }).nullish(),
41610
+ warnings: exports_external2.array(gatewayEmbeddingWarningSchema).optional(),
41137
41611
  providerMetadata: exports_external2.record(exports_external2.string(), exports_external2.record(exports_external2.string(), exports_external2.unknown())).optional()
41138
41612
  })));
41139
41613
  providerMetadataEntrySchema = exports_external2.object({
@@ -41212,22 +41686,198 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
41212
41686
  param: exports_external2.unknown().nullable()
41213
41687
  })
41214
41688
  ]);
41689
+ gatewayRerankingWarningSchema = exports_external2.discriminatedUnion("type", [
41690
+ exports_external2.object({
41691
+ type: exports_external2.literal("unsupported"),
41692
+ feature: exports_external2.string(),
41693
+ details: exports_external2.string().optional()
41694
+ }),
41695
+ exports_external2.object({
41696
+ type: exports_external2.literal("compatibility"),
41697
+ feature: exports_external2.string(),
41698
+ details: exports_external2.string().optional()
41699
+ }),
41700
+ exports_external2.object({
41701
+ type: exports_external2.literal("other"),
41702
+ message: exports_external2.string()
41703
+ })
41704
+ ]);
41215
41705
  gatewayRerankingResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
41216
41706
  ranking: exports_external2.array(exports_external2.object({
41217
41707
  index: exports_external2.number(),
41218
41708
  relevanceScore: exports_external2.number()
41219
41709
  })),
41710
+ warnings: exports_external2.array(gatewayRerankingWarningSchema).optional(),
41220
41711
  providerMetadata: exports_external2.record(exports_external2.string(), exports_external2.record(exports_external2.string(), exports_external2.unknown())).optional()
41221
41712
  })));
41713
+ providerMetadataEntrySchema3 = exports_external2.object({}).catchall(exports_external2.unknown());
41714
+ gatewaySpeechWarningSchema = exports_external2.discriminatedUnion("type", [
41715
+ exports_external2.object({
41716
+ type: exports_external2.literal("unsupported"),
41717
+ feature: exports_external2.string(),
41718
+ details: exports_external2.string().optional()
41719
+ }),
41720
+ exports_external2.object({
41721
+ type: exports_external2.literal("compatibility"),
41722
+ feature: exports_external2.string(),
41723
+ details: exports_external2.string().optional()
41724
+ }),
41725
+ exports_external2.object({
41726
+ type: exports_external2.literal("other"),
41727
+ message: exports_external2.string()
41728
+ })
41729
+ ]);
41730
+ gatewaySpeechResponseSchema = exports_external2.object({
41731
+ audio: exports_external2.string(),
41732
+ warnings: exports_external2.array(gatewaySpeechWarningSchema).optional(),
41733
+ providerMetadata: exports_external2.record(exports_external2.string(), providerMetadataEntrySchema3).optional()
41734
+ });
41735
+ providerMetadataEntrySchema4 = exports_external2.object({}).catchall(exports_external2.unknown());
41736
+ gatewayTranscriptionWarningSchema = exports_external2.discriminatedUnion("type", [
41737
+ exports_external2.object({
41738
+ type: exports_external2.literal("unsupported"),
41739
+ feature: exports_external2.string(),
41740
+ details: exports_external2.string().optional()
41741
+ }),
41742
+ exports_external2.object({
41743
+ type: exports_external2.literal("compatibility"),
41744
+ feature: exports_external2.string(),
41745
+ details: exports_external2.string().optional()
41746
+ }),
41747
+ exports_external2.object({
41748
+ type: exports_external2.literal("other"),
41749
+ message: exports_external2.string()
41750
+ })
41751
+ ]);
41752
+ gatewayTranscriptionResponseSchema = exports_external2.object({
41753
+ text: exports_external2.string(),
41754
+ segments: exports_external2.array(exports_external2.object({
41755
+ text: exports_external2.string(),
41756
+ startSecond: exports_external2.number(),
41757
+ endSecond: exports_external2.number()
41758
+ })).optional(),
41759
+ language: exports_external2.string().nullish(),
41760
+ durationInSeconds: exports_external2.number().nullish(),
41761
+ warnings: exports_external2.array(gatewayTranscriptionWarningSchema).optional(),
41762
+ providerMetadata: exports_external2.record(exports_external2.string(), providerMetadataEntrySchema4).optional()
41763
+ });
41764
+ exaSearchInputSchema = lazySchema(() => zodSchema(exports_external.object({
41765
+ query: exports_external.string().describe("Natural-language web search query. This is required."),
41766
+ type: exports_external.enum(["auto", "fast", "instant"]).optional().describe("Search method. Use auto for the default balance of speed and quality."),
41767
+ num_results: exports_external.number().optional().describe("Maximum number of results to return (1-100, default: 10)."),
41768
+ category: exports_external.enum([
41769
+ "company",
41770
+ "people",
41771
+ "research paper",
41772
+ "news",
41773
+ "personal site",
41774
+ "financial report"
41775
+ ]).optional().describe("Optional content category to focus results."),
41776
+ user_location: exports_external.string().optional().describe("Two-letter ISO country code such as 'US'."),
41777
+ include_domains: exports_external.array(exports_external.string()).optional().describe("Only return results from these domains."),
41778
+ exclude_domains: exports_external.array(exports_external.string()).optional().describe("Exclude results from these domains."),
41779
+ start_published_date: exports_external.string().optional().describe("Only return links published after this ISO 8601 date."),
41780
+ end_published_date: exports_external.string().optional().describe("Only return links published before this ISO 8601 date."),
41781
+ contents: exports_external.object({
41782
+ text: exports_external.union([
41783
+ exports_external.boolean(),
41784
+ exports_external.object({
41785
+ max_characters: exports_external.number().optional(),
41786
+ include_html_tags: exports_external.boolean().optional(),
41787
+ verbosity: exports_external.enum(["compact", "standard", "full"]).optional(),
41788
+ include_sections: exports_external.array(exports_external.enum([
41789
+ "header",
41790
+ "navigation",
41791
+ "banner",
41792
+ "body",
41793
+ "sidebar",
41794
+ "footer",
41795
+ "metadata"
41796
+ ])).optional(),
41797
+ exclude_sections: exports_external.array(exports_external.enum([
41798
+ "header",
41799
+ "navigation",
41800
+ "banner",
41801
+ "body",
41802
+ "sidebar",
41803
+ "footer",
41804
+ "metadata"
41805
+ ])).optional()
41806
+ })
41807
+ ]).optional(),
41808
+ highlights: exports_external.union([
41809
+ exports_external.boolean(),
41810
+ exports_external.object({
41811
+ query: exports_external.string().optional(),
41812
+ max_characters: exports_external.number().optional()
41813
+ })
41814
+ ]).optional(),
41815
+ max_age_hours: exports_external.number().optional(),
41816
+ livecrawl_timeout: exports_external.number().optional(),
41817
+ subpages: exports_external.number().optional(),
41818
+ subpage_target: exports_external.union([exports_external.string(), exports_external.array(exports_external.string())]).optional(),
41819
+ extras: exports_external.object({
41820
+ links: exports_external.number().optional(),
41821
+ image_links: exports_external.number().optional()
41822
+ }).optional()
41823
+ }).optional().describe("Controls extracted page content and freshness.")
41824
+ })));
41825
+ exaSearchOutputSchema = lazySchema(() => zodSchema(exports_external.union([
41826
+ exports_external.object({
41827
+ requestId: exports_external.string(),
41828
+ searchType: exports_external.string().optional(),
41829
+ resolvedSearchType: exports_external.string().optional(),
41830
+ results: exports_external.array(exports_external.object({
41831
+ title: exports_external.string(),
41832
+ url: exports_external.string(),
41833
+ id: exports_external.string(),
41834
+ publishedDate: exports_external.string().nullable().optional(),
41835
+ author: exports_external.string().nullable().optional(),
41836
+ image: exports_external.string().nullable().optional(),
41837
+ favicon: exports_external.string().nullable().optional(),
41838
+ text: exports_external.string().optional(),
41839
+ highlights: exports_external.array(exports_external.string()).optional(),
41840
+ highlightScores: exports_external.array(exports_external.number()).optional(),
41841
+ summary: exports_external.string().optional(),
41842
+ subpages: exports_external.array(exports_external.any()).optional(),
41843
+ extras: exports_external.object({
41844
+ links: exports_external.array(exports_external.string()).optional(),
41845
+ imageLinks: exports_external.array(exports_external.string()).optional()
41846
+ }).optional()
41847
+ })),
41848
+ costDollars: exports_external.object({
41849
+ total: exports_external.number().optional(),
41850
+ search: exports_external.record(exports_external.number()).optional()
41851
+ }).optional()
41852
+ }),
41853
+ exports_external.object({
41854
+ error: exports_external.enum([
41855
+ "api_error",
41856
+ "rate_limit",
41857
+ "timeout",
41858
+ "invalid_input",
41859
+ "configuration_error",
41860
+ "execution_error",
41861
+ "unknown"
41862
+ ]),
41863
+ statusCode: exports_external.number().optional(),
41864
+ message: exports_external.string()
41865
+ })
41866
+ ])));
41867
+ exaSearchToolFactory = createProviderToolFactoryWithOutputSchema({
41868
+ id: "gateway.exa_search",
41869
+ inputSchema: exaSearchInputSchema,
41870
+ outputSchema: exaSearchOutputSchema
41871
+ });
41222
41872
  parallelSearchInputSchema = lazySchema(() => zodSchema(exports_external.object({
41223
41873
  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."),
41224
41874
  search_queries: exports_external.array(exports_external.string()).optional().describe("Optional search queries to supplement the objective. Maximum 200 characters per query."),
41225
41875
  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.'),
41226
41876
  max_results: exports_external.number().optional().describe("Maximum number of results to return (1-20). Defaults to 10 if not specified."),
41227
41877
  source_policy: exports_external.object({
41228
- include_domains: exports_external.array(exports_external.string()).optional().describe("List of domains to include in search results."),
41229
- exclude_domains: exports_external.array(exports_external.string()).optional().describe("List of domains to exclude from search results."),
41230
- after_date: exports_external.string().optional().describe("Only include results published after this date (ISO 8601 format).")
41878
+ 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)."),
41879
+ 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)."),
41880
+ 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.")
41231
41881
  }).optional().describe("Source policy for controlling which domains to include/exclude and freshness."),
41232
41882
  excerpts: exports_external.object({
41233
41883
  max_chars_per_result: exports_external.number().optional().describe("Maximum characters per result."),
@@ -41309,20 +41959,21 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
41309
41959
  outputSchema: perplexitySearchOutputSchema
41310
41960
  });
41311
41961
  gatewayTools = {
41962
+ exaSearch,
41312
41963
  parallelSearch,
41313
41964
  perplexitySearch
41314
41965
  };
41315
41966
  gateway = createGatewayProvider();
41316
41967
  });
41317
41968
 
41318
- // node_modules/@opentelemetry/api/build/src/version.js
41969
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/version.js
41319
41970
  var require_version = __commonJS((exports) => {
41320
41971
  Object.defineProperty(exports, "__esModule", { value: true });
41321
41972
  exports.VERSION = undefined;
41322
41973
  exports.VERSION = "1.9.1";
41323
41974
  });
41324
41975
 
41325
- // node_modules/@opentelemetry/api/build/src/internal/semver.js
41976
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/internal/semver.js
41326
41977
  var require_semver = __commonJS((exports) => {
41327
41978
  Object.defineProperty(exports, "__esModule", { value: true });
41328
41979
  exports.isCompatible = exports._makeCompatibilityCheck = undefined;
@@ -41393,7 +42044,7 @@ var require_semver = __commonJS((exports) => {
41393
42044
  exports.isCompatible = _makeCompatibilityCheck(version_1.VERSION);
41394
42045
  });
41395
42046
 
41396
- // node_modules/@opentelemetry/api/build/src/internal/global-utils.js
42047
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/internal/global-utils.js
41397
42048
  var require_global_utils = __commonJS((exports) => {
41398
42049
  Object.defineProperty(exports, "__esModule", { value: true });
41399
42050
  exports.unregisterGlobal = exports.getGlobal = exports.registerGlobal = undefined;
@@ -41441,7 +42092,7 @@ var require_global_utils = __commonJS((exports) => {
41441
42092
  exports.unregisterGlobal = unregisterGlobal;
41442
42093
  });
41443
42094
 
41444
- // node_modules/@opentelemetry/api/build/src/diag/ComponentLogger.js
42095
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/ComponentLogger.js
41445
42096
  var require_ComponentLogger = __commonJS((exports) => {
41446
42097
  Object.defineProperty(exports, "__esModule", { value: true });
41447
42098
  exports.DiagComponentLogger = undefined;
@@ -41477,7 +42128,7 @@ var require_ComponentLogger = __commonJS((exports) => {
41477
42128
  }
41478
42129
  });
41479
42130
 
41480
- // node_modules/@opentelemetry/api/build/src/diag/types.js
42131
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/types.js
41481
42132
  var require_types = __commonJS((exports) => {
41482
42133
  Object.defineProperty(exports, "__esModule", { value: true });
41483
42134
  exports.DiagLogLevel = undefined;
@@ -41493,7 +42144,7 @@ var require_types = __commonJS((exports) => {
41493
42144
  })(DiagLogLevel = exports.DiagLogLevel || (exports.DiagLogLevel = {}));
41494
42145
  });
41495
42146
 
41496
- // node_modules/@opentelemetry/api/build/src/diag/internal/logLevelLogger.js
42147
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/internal/logLevelLogger.js
41497
42148
  var require_logLevelLogger = __commonJS((exports) => {
41498
42149
  Object.defineProperty(exports, "__esModule", { value: true });
41499
42150
  exports.createLogLevelDiagLogger = undefined;
@@ -41523,7 +42174,7 @@ var require_logLevelLogger = __commonJS((exports) => {
41523
42174
  exports.createLogLevelDiagLogger = createLogLevelDiagLogger;
41524
42175
  });
41525
42176
 
41526
- // node_modules/@opentelemetry/api/build/src/api/diag.js
42177
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/diag.js
41527
42178
  var require_diag = __commonJS((exports) => {
41528
42179
  Object.defineProperty(exports, "__esModule", { value: true });
41529
42180
  exports.DiagAPI = undefined;
@@ -41588,7 +42239,7 @@ var require_diag = __commonJS((exports) => {
41588
42239
  exports.DiagAPI = DiagAPI;
41589
42240
  });
41590
42241
 
41591
- // node_modules/@opentelemetry/api/build/src/baggage/internal/baggage-impl.js
42242
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/internal/baggage-impl.js
41592
42243
  var require_baggage_impl = __commonJS((exports) => {
41593
42244
  Object.defineProperty(exports, "__esModule", { value: true });
41594
42245
  exports.BaggageImpl = undefined;
@@ -41631,14 +42282,14 @@ var require_baggage_impl = __commonJS((exports) => {
41631
42282
  exports.BaggageImpl = BaggageImpl;
41632
42283
  });
41633
42284
 
41634
- // node_modules/@opentelemetry/api/build/src/baggage/internal/symbol.js
42285
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/internal/symbol.js
41635
42286
  var require_symbol = __commonJS((exports) => {
41636
42287
  Object.defineProperty(exports, "__esModule", { value: true });
41637
42288
  exports.baggageEntryMetadataSymbol = undefined;
41638
42289
  exports.baggageEntryMetadataSymbol = Symbol("BaggageEntryMetadata");
41639
42290
  });
41640
42291
 
41641
- // node_modules/@opentelemetry/api/build/src/baggage/utils.js
42292
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/utils.js
41642
42293
  var require_utils = __commonJS((exports) => {
41643
42294
  Object.defineProperty(exports, "__esModule", { value: true });
41644
42295
  exports.baggageEntryMetadataFromString = exports.createBaggage = undefined;
@@ -41665,7 +42316,7 @@ var require_utils = __commonJS((exports) => {
41665
42316
  exports.baggageEntryMetadataFromString = baggageEntryMetadataFromString;
41666
42317
  });
41667
42318
 
41668
- // node_modules/@opentelemetry/api/build/src/context/context.js
42319
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/context/context.js
41669
42320
  var require_context = __commonJS((exports) => {
41670
42321
  Object.defineProperty(exports, "__esModule", { value: true });
41671
42322
  exports.ROOT_CONTEXT = exports.createContextKey = undefined;
@@ -41694,7 +42345,7 @@ var require_context = __commonJS((exports) => {
41694
42345
  exports.ROOT_CONTEXT = new BaseContext;
41695
42346
  });
41696
42347
 
41697
- // node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js
42348
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js
41698
42349
  var require_consoleLogger = __commonJS((exports) => {
41699
42350
  Object.defineProperty(exports, "__esModule", { value: true });
41700
42351
  exports.DiagConsoleLogger = exports._originalConsoleMethods = undefined;
@@ -41749,7 +42400,7 @@ var require_consoleLogger = __commonJS((exports) => {
41749
42400
  exports.DiagConsoleLogger = DiagConsoleLogger;
41750
42401
  });
41751
42402
 
41752
- // node_modules/@opentelemetry/api/build/src/metrics/NoopMeter.js
42403
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics/NoopMeter.js
41753
42404
  var require_NoopMeter = __commonJS((exports) => {
41754
42405
  Object.defineProperty(exports, "__esModule", { value: true });
41755
42406
  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;
@@ -41837,7 +42488,7 @@ var require_NoopMeter = __commonJS((exports) => {
41837
42488
  exports.createNoopMeter = createNoopMeter;
41838
42489
  });
41839
42490
 
41840
- // node_modules/@opentelemetry/api/build/src/metrics/Metric.js
42491
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics/Metric.js
41841
42492
  var require_Metric = __commonJS((exports) => {
41842
42493
  Object.defineProperty(exports, "__esModule", { value: true });
41843
42494
  exports.ValueType = undefined;
@@ -41848,7 +42499,7 @@ var require_Metric = __commonJS((exports) => {
41848
42499
  })(ValueType = exports.ValueType || (exports.ValueType = {}));
41849
42500
  });
41850
42501
 
41851
- // node_modules/@opentelemetry/api/build/src/propagation/TextMapPropagator.js
42502
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/propagation/TextMapPropagator.js
41852
42503
  var require_TextMapPropagator = __commonJS((exports) => {
41853
42504
  Object.defineProperty(exports, "__esModule", { value: true });
41854
42505
  exports.defaultTextMapSetter = exports.defaultTextMapGetter = undefined;
@@ -41876,7 +42527,7 @@ var require_TextMapPropagator = __commonJS((exports) => {
41876
42527
  };
41877
42528
  });
41878
42529
 
41879
- // node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js
42530
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js
41880
42531
  var require_NoopContextManager = __commonJS((exports) => {
41881
42532
  Object.defineProperty(exports, "__esModule", { value: true });
41882
42533
  exports.NoopContextManager = undefined;
@@ -41902,7 +42553,7 @@ var require_NoopContextManager = __commonJS((exports) => {
41902
42553
  exports.NoopContextManager = NoopContextManager;
41903
42554
  });
41904
42555
 
41905
- // node_modules/@opentelemetry/api/build/src/api/context.js
42556
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/context.js
41906
42557
  var require_context2 = __commonJS((exports) => {
41907
42558
  Object.defineProperty(exports, "__esModule", { value: true });
41908
42559
  exports.ContextAPI = undefined;
@@ -41943,7 +42594,7 @@ var require_context2 = __commonJS((exports) => {
41943
42594
  exports.ContextAPI = ContextAPI;
41944
42595
  });
41945
42596
 
41946
- // node_modules/@opentelemetry/api/build/src/trace/trace_flags.js
42597
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/trace_flags.js
41947
42598
  var require_trace_flags = __commonJS((exports) => {
41948
42599
  Object.defineProperty(exports, "__esModule", { value: true });
41949
42600
  exports.TraceFlags = undefined;
@@ -41954,7 +42605,7 @@ var require_trace_flags = __commonJS((exports) => {
41954
42605
  })(TraceFlags = exports.TraceFlags || (exports.TraceFlags = {}));
41955
42606
  });
41956
42607
 
41957
- // node_modules/@opentelemetry/api/build/src/trace/invalid-span-constants.js
42608
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/invalid-span-constants.js
41958
42609
  var require_invalid_span_constants = __commonJS((exports) => {
41959
42610
  Object.defineProperty(exports, "__esModule", { value: true });
41960
42611
  exports.INVALID_SPAN_CONTEXT = exports.INVALID_TRACEID = exports.INVALID_SPANID = undefined;
@@ -41968,7 +42619,7 @@ var require_invalid_span_constants = __commonJS((exports) => {
41968
42619
  };
41969
42620
  });
41970
42621
 
41971
- // node_modules/@opentelemetry/api/build/src/trace/NonRecordingSpan.js
42622
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/NonRecordingSpan.js
41972
42623
  var require_NonRecordingSpan = __commonJS((exports) => {
41973
42624
  Object.defineProperty(exports, "__esModule", { value: true });
41974
42625
  exports.NonRecordingSpan = undefined;
@@ -42011,7 +42662,7 @@ var require_NonRecordingSpan = __commonJS((exports) => {
42011
42662
  exports.NonRecordingSpan = NonRecordingSpan;
42012
42663
  });
42013
42664
 
42014
- // node_modules/@opentelemetry/api/build/src/trace/context-utils.js
42665
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/context-utils.js
42015
42666
  var require_context_utils = __commonJS((exports) => {
42016
42667
  Object.defineProperty(exports, "__esModule", { value: true });
42017
42668
  exports.getSpanContext = exports.setSpanContext = exports.deleteSpan = exports.setSpan = exports.getActiveSpan = exports.getSpan = undefined;
@@ -42046,7 +42697,7 @@ var require_context_utils = __commonJS((exports) => {
42046
42697
  exports.getSpanContext = getSpanContext;
42047
42698
  });
42048
42699
 
42049
- // node_modules/@opentelemetry/api/build/src/trace/spancontext-utils.js
42700
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/spancontext-utils.js
42050
42701
  var require_spancontext_utils = __commonJS((exports) => {
42051
42702
  Object.defineProperty(exports, "__esModule", { value: true });
42052
42703
  exports.wrapSpanContext = exports.isSpanContextValid = exports.isValidSpanId = exports.isValidTraceId = undefined;
@@ -42184,7 +42835,7 @@ var require_spancontext_utils = __commonJS((exports) => {
42184
42835
  exports.wrapSpanContext = wrapSpanContext;
42185
42836
  });
42186
42837
 
42187
- // node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js
42838
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js
42188
42839
  var require_NoopTracer = __commonJS((exports) => {
42189
42840
  Object.defineProperty(exports, "__esModule", { value: true });
42190
42841
  exports.NoopTracer = undefined;
@@ -42235,7 +42886,7 @@ var require_NoopTracer = __commonJS((exports) => {
42235
42886
  }
42236
42887
  });
42237
42888
 
42238
- // node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js
42889
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js
42239
42890
  var require_ProxyTracer = __commonJS((exports) => {
42240
42891
  Object.defineProperty(exports, "__esModule", { value: true });
42241
42892
  exports.ProxyTracer = undefined;
@@ -42271,7 +42922,7 @@ var require_ProxyTracer = __commonJS((exports) => {
42271
42922
  exports.ProxyTracer = ProxyTracer;
42272
42923
  });
42273
42924
 
42274
- // node_modules/@opentelemetry/api/build/src/trace/NoopTracerProvider.js
42925
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/NoopTracerProvider.js
42275
42926
  var require_NoopTracerProvider = __commonJS((exports) => {
42276
42927
  Object.defineProperty(exports, "__esModule", { value: true });
42277
42928
  exports.NoopTracerProvider = undefined;
@@ -42285,7 +42936,7 @@ var require_NoopTracerProvider = __commonJS((exports) => {
42285
42936
  exports.NoopTracerProvider = NoopTracerProvider;
42286
42937
  });
42287
42938
 
42288
- // node_modules/@opentelemetry/api/build/src/trace/ProxyTracerProvider.js
42939
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/ProxyTracerProvider.js
42289
42940
  var require_ProxyTracerProvider = __commonJS((exports) => {
42290
42941
  Object.defineProperty(exports, "__esModule", { value: true });
42291
42942
  exports.ProxyTracerProvider = undefined;
@@ -42313,7 +42964,7 @@ var require_ProxyTracerProvider = __commonJS((exports) => {
42313
42964
  exports.ProxyTracerProvider = ProxyTracerProvider;
42314
42965
  });
42315
42966
 
42316
- // node_modules/@opentelemetry/api/build/src/trace/SamplingResult.js
42967
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/SamplingResult.js
42317
42968
  var require_SamplingResult = __commonJS((exports) => {
42318
42969
  Object.defineProperty(exports, "__esModule", { value: true });
42319
42970
  exports.SamplingDecision = undefined;
@@ -42325,7 +42976,7 @@ var require_SamplingResult = __commonJS((exports) => {
42325
42976
  })(SamplingDecision = exports.SamplingDecision || (exports.SamplingDecision = {}));
42326
42977
  });
42327
42978
 
42328
- // node_modules/@opentelemetry/api/build/src/trace/span_kind.js
42979
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/span_kind.js
42329
42980
  var require_span_kind = __commonJS((exports) => {
42330
42981
  Object.defineProperty(exports, "__esModule", { value: true });
42331
42982
  exports.SpanKind = undefined;
@@ -42339,7 +42990,7 @@ var require_span_kind = __commonJS((exports) => {
42339
42990
  })(SpanKind = exports.SpanKind || (exports.SpanKind = {}));
42340
42991
  });
42341
42992
 
42342
- // node_modules/@opentelemetry/api/build/src/trace/status.js
42993
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/status.js
42343
42994
  var require_status = __commonJS((exports) => {
42344
42995
  Object.defineProperty(exports, "__esModule", { value: true });
42345
42996
  exports.SpanStatusCode = undefined;
@@ -42351,7 +43002,7 @@ var require_status = __commonJS((exports) => {
42351
43002
  })(SpanStatusCode = exports.SpanStatusCode || (exports.SpanStatusCode = {}));
42352
43003
  });
42353
43004
 
42354
- // node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-validators.js
43005
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-validators.js
42355
43006
  var require_tracestate_validators = __commonJS((exports) => {
42356
43007
  Object.defineProperty(exports, "__esModule", { value: true });
42357
43008
  exports.validateValue = exports.validateKey = undefined;
@@ -42371,7 +43022,7 @@ var require_tracestate_validators = __commonJS((exports) => {
42371
43022
  exports.validateValue = validateValue;
42372
43023
  });
42373
43024
 
42374
- // node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-impl.js
43025
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-impl.js
42375
43026
  var require_tracestate_impl = __commonJS((exports) => {
42376
43027
  Object.defineProperty(exports, "__esModule", { value: true });
42377
43028
  exports.TraceStateImpl = undefined;
@@ -42440,7 +43091,7 @@ var require_tracestate_impl = __commonJS((exports) => {
42440
43091
  exports.TraceStateImpl = TraceStateImpl;
42441
43092
  });
42442
43093
 
42443
- // node_modules/@opentelemetry/api/build/src/trace/internal/utils.js
43094
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/internal/utils.js
42444
43095
  var require_utils2 = __commonJS((exports) => {
42445
43096
  Object.defineProperty(exports, "__esModule", { value: true });
42446
43097
  exports.createTraceState = undefined;
@@ -42451,7 +43102,7 @@ var require_utils2 = __commonJS((exports) => {
42451
43102
  exports.createTraceState = createTraceState;
42452
43103
  });
42453
43104
 
42454
- // node_modules/@opentelemetry/api/build/src/context-api.js
43105
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/context-api.js
42455
43106
  var require_context_api = __commonJS((exports) => {
42456
43107
  Object.defineProperty(exports, "__esModule", { value: true });
42457
43108
  exports.context = undefined;
@@ -42459,7 +43110,7 @@ var require_context_api = __commonJS((exports) => {
42459
43110
  exports.context = context_1.ContextAPI.getInstance();
42460
43111
  });
42461
43112
 
42462
- // node_modules/@opentelemetry/api/build/src/diag-api.js
43113
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag-api.js
42463
43114
  var require_diag_api = __commonJS((exports) => {
42464
43115
  Object.defineProperty(exports, "__esModule", { value: true });
42465
43116
  exports.diag = undefined;
@@ -42467,7 +43118,7 @@ var require_diag_api = __commonJS((exports) => {
42467
43118
  exports.diag = diag_1.DiagAPI.instance();
42468
43119
  });
42469
43120
 
42470
- // node_modules/@opentelemetry/api/build/src/metrics/NoopMeterProvider.js
43121
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics/NoopMeterProvider.js
42471
43122
  var require_NoopMeterProvider = __commonJS((exports) => {
42472
43123
  Object.defineProperty(exports, "__esModule", { value: true });
42473
43124
  exports.NOOP_METER_PROVIDER = exports.NoopMeterProvider = undefined;
@@ -42482,7 +43133,7 @@ var require_NoopMeterProvider = __commonJS((exports) => {
42482
43133
  exports.NOOP_METER_PROVIDER = new NoopMeterProvider;
42483
43134
  });
42484
43135
 
42485
- // node_modules/@opentelemetry/api/build/src/api/metrics.js
43136
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/metrics.js
42486
43137
  var require_metrics = __commonJS((exports) => {
42487
43138
  Object.defineProperty(exports, "__esModule", { value: true });
42488
43139
  exports.MetricsAPI = undefined;
@@ -42515,7 +43166,7 @@ var require_metrics = __commonJS((exports) => {
42515
43166
  exports.MetricsAPI = MetricsAPI;
42516
43167
  });
42517
43168
 
42518
- // node_modules/@opentelemetry/api/build/src/metrics-api.js
43169
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics-api.js
42519
43170
  var require_metrics_api = __commonJS((exports) => {
42520
43171
  Object.defineProperty(exports, "__esModule", { value: true });
42521
43172
  exports.metrics = undefined;
@@ -42523,7 +43174,7 @@ var require_metrics_api = __commonJS((exports) => {
42523
43174
  exports.metrics = metrics_1.MetricsAPI.getInstance();
42524
43175
  });
42525
43176
 
42526
- // node_modules/@opentelemetry/api/build/src/propagation/NoopTextMapPropagator.js
43177
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/propagation/NoopTextMapPropagator.js
42527
43178
  var require_NoopTextMapPropagator = __commonJS((exports) => {
42528
43179
  Object.defineProperty(exports, "__esModule", { value: true });
42529
43180
  exports.NoopTextMapPropagator = undefined;
@@ -42540,7 +43191,7 @@ var require_NoopTextMapPropagator = __commonJS((exports) => {
42540
43191
  exports.NoopTextMapPropagator = NoopTextMapPropagator;
42541
43192
  });
42542
43193
 
42543
- // node_modules/@opentelemetry/api/build/src/baggage/context-helpers.js
43194
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/context-helpers.js
42544
43195
  var require_context_helpers = __commonJS((exports) => {
42545
43196
  Object.defineProperty(exports, "__esModule", { value: true });
42546
43197
  exports.deleteBaggage = exports.setBaggage = exports.getActiveBaggage = exports.getBaggage = undefined;
@@ -42565,7 +43216,7 @@ var require_context_helpers = __commonJS((exports) => {
42565
43216
  exports.deleteBaggage = deleteBaggage;
42566
43217
  });
42567
43218
 
42568
- // node_modules/@opentelemetry/api/build/src/api/propagation.js
43219
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/propagation.js
42569
43220
  var require_propagation = __commonJS((exports) => {
42570
43221
  Object.defineProperty(exports, "__esModule", { value: true });
42571
43222
  exports.PropagationAPI = undefined;
@@ -42614,7 +43265,7 @@ var require_propagation = __commonJS((exports) => {
42614
43265
  exports.PropagationAPI = PropagationAPI;
42615
43266
  });
42616
43267
 
42617
- // node_modules/@opentelemetry/api/build/src/propagation-api.js
43268
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/propagation-api.js
42618
43269
  var require_propagation_api = __commonJS((exports) => {
42619
43270
  Object.defineProperty(exports, "__esModule", { value: true });
42620
43271
  exports.propagation = undefined;
@@ -42622,7 +43273,7 @@ var require_propagation_api = __commonJS((exports) => {
42622
43273
  exports.propagation = propagation_1.PropagationAPI.getInstance();
42623
43274
  });
42624
43275
 
42625
- // node_modules/@opentelemetry/api/build/src/api/trace.js
43276
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/trace.js
42626
43277
  var require_trace = __commonJS((exports) => {
42627
43278
  Object.defineProperty(exports, "__esModule", { value: true });
42628
43279
  exports.TraceAPI = undefined;
@@ -42672,7 +43323,7 @@ var require_trace = __commonJS((exports) => {
42672
43323
  exports.TraceAPI = TraceAPI;
42673
43324
  });
42674
43325
 
42675
- // node_modules/@opentelemetry/api/build/src/trace-api.js
43326
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace-api.js
42676
43327
  var require_trace_api = __commonJS((exports) => {
42677
43328
  Object.defineProperty(exports, "__esModule", { value: true });
42678
43329
  exports.trace = undefined;
@@ -42680,7 +43331,7 @@ var require_trace_api = __commonJS((exports) => {
42680
43331
  exports.trace = trace_1.TraceAPI.getInstance();
42681
43332
  });
42682
43333
 
42683
- // node_modules/@opentelemetry/api/build/src/index.js
43334
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/index.js
42684
43335
  var require_src = __commonJS((exports) => {
42685
43336
  Object.defineProperty(exports, "__esModule", { value: true });
42686
43337
  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;
@@ -42795,7 +43446,7 @@ var require_src = __commonJS((exports) => {
42795
43446
  };
42796
43447
  });
42797
43448
 
42798
- // node_modules/ai/dist/index.mjs
43449
+ // node_modules/.pnpm/ai@6.0.219_zod@3.25.76/node_modules/ai/dist/index.mjs
42799
43450
  var exports_dist4 = {};
42800
43451
  __export(exports_dist4, {
42801
43452
  zodSchema: () => zodSchema,
@@ -42910,6 +43561,7 @@ __export(exports_dist4, {
42910
43561
  JsonToSseTransformStream: () => JsonToSseTransformStream,
42911
43562
  JSONParseError: () => JSONParseError,
42912
43563
  InvalidToolInputError: () => InvalidToolInputError,
43564
+ InvalidToolApprovalSignatureError: () => InvalidToolApprovalSignatureError,
42913
43565
  InvalidToolApprovalError: () => InvalidToolApprovalError,
42914
43566
  InvalidStreamPartError: () => InvalidStreamPartError,
42915
43567
  InvalidResponseDataError: () => InvalidResponseDataError,
@@ -43153,7 +43805,7 @@ function resolveEmbeddingModel(model) {
43153
43805
  return getGlobalProvider().embeddingModel(model);
43154
43806
  }
43155
43807
  function resolveTranscriptionModel(model) {
43156
- var _a21, _b16;
43808
+ var _a222, _b16;
43157
43809
  if (typeof model !== "string") {
43158
43810
  if (model.specificationVersion !== "v3" && model.specificationVersion !== "v2") {
43159
43811
  const unsupportedModel = model;
@@ -43165,10 +43817,10 @@ function resolveTranscriptionModel(model) {
43165
43817
  }
43166
43818
  return asTranscriptionModelV3(model);
43167
43819
  }
43168
- return (_b16 = (_a21 = getGlobalProvider()).transcriptionModel) == null ? undefined : _b16.call(_a21, model);
43820
+ return (_b16 = (_a222 = getGlobalProvider()).transcriptionModel) == null ? undefined : _b16.call(_a222, model);
43169
43821
  }
43170
43822
  function resolveSpeechModel(model) {
43171
- var _a21, _b16;
43823
+ var _a222, _b16;
43172
43824
  if (typeof model !== "string") {
43173
43825
  if (model.specificationVersion !== "v3" && model.specificationVersion !== "v2") {
43174
43826
  const unsupportedModel = model;
@@ -43180,7 +43832,7 @@ function resolveSpeechModel(model) {
43180
43832
  }
43181
43833
  return asSpeechModelV3(model);
43182
43834
  }
43183
- return (_b16 = (_a21 = getGlobalProvider()).speechModel) == null ? undefined : _b16.call(_a21, model);
43835
+ return (_b16 = (_a222 = getGlobalProvider()).speechModel) == null ? undefined : _b16.call(_a222, model);
43184
43836
  }
43185
43837
  function resolveImageModel(model) {
43186
43838
  if (typeof model !== "string") {
@@ -43235,8 +43887,8 @@ function resolveRerankingModel(model) {
43235
43887
  return model;
43236
43888
  }
43237
43889
  function getGlobalProvider() {
43238
- var _a21;
43239
- return (_a21 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a21 : gateway;
43890
+ var _a222;
43891
+ return (_a222 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a222 : gateway;
43240
43892
  }
43241
43893
  function getTotalTimeoutMs(timeout) {
43242
43894
  if (timeout == null) {
@@ -43561,7 +44213,7 @@ function convertToLanguageModelMessage({
43561
44213
  }
43562
44214
  }
43563
44215
  async function downloadAssets(messages, download2, supportedUrls) {
43564
- var _a21;
44216
+ var _a222;
43565
44217
  const downloadableFiles = [];
43566
44218
  for (const message of messages) {
43567
44219
  if (message.role === "user" && Array.isArray(message.content)) {
@@ -43569,7 +44221,7 @@ async function downloadAssets(messages, download2, supportedUrls) {
43569
44221
  if (part.type === "image" || part.type === "file") {
43570
44222
  downloadableFiles.push({
43571
44223
  data: part.type === "image" ? part.image : part.data,
43572
- mediaType: (_a21 = part.mediaType) != null ? _a21 : part.type === "image" ? "image/*" : undefined
44224
+ mediaType: (_a222 = part.mediaType) != null ? _a222 : part.type === "image" ? "image/*" : undefined
43573
44225
  });
43574
44226
  }
43575
44227
  }
@@ -43615,7 +44267,7 @@ async function downloadAssets(messages, download2, supportedUrls) {
43615
44267
  ]).filter((file2) => file2 != null));
43616
44268
  }
43617
44269
  function convertPartToLanguageModelPart(part, downloadedAssets) {
43618
- var _a21;
44270
+ var _a222;
43619
44271
  if (part.type === "text") {
43620
44272
  return {
43621
44273
  type: "text",
@@ -43648,7 +44300,7 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
43648
44300
  switch (type) {
43649
44301
  case "image": {
43650
44302
  if (data instanceof Uint8Array || typeof data === "string") {
43651
- mediaType = (_a21 = detectMediaType({ data, signatures: imageMediaTypeSignatures })) != null ? _a21 : mediaType;
44303
+ mediaType = (_a222 = detectMediaType({ data, signatures: imageMediaTypeSignatures })) != null ? _a222 : mediaType;
43652
44304
  }
43653
44305
  return {
43654
44306
  type: "file",
@@ -43682,14 +44334,14 @@ function mapToolResultOutput({
43682
44334
  return {
43683
44335
  type: "content",
43684
44336
  value: output.value.map((item) => {
43685
- var _a21, _b16;
44337
+ var _a222, _b16;
43686
44338
  if (item.type === "image-url") {
43687
44339
  const downloadedFile = downloadedAssets[new URL(item.url).toString()];
43688
44340
  if (downloadedFile) {
43689
44341
  return {
43690
44342
  type: "image-data",
43691
44343
  data: convertDataContentToBase64String(downloadedFile.data),
43692
- mediaType: (_a21 = downloadedFile.mediaType) != null ? _a21 : "image/*",
44344
+ mediaType: (_a222 = downloadedFile.mediaType) != null ? _a222 : "image/*",
43693
44345
  providerOptions: item.providerOptions
43694
44346
  };
43695
44347
  }
@@ -43850,9 +44502,9 @@ async function prepareToolsAndToolChoice({
43850
44502
  toolChoice: undefined
43851
44503
  };
43852
44504
  }
43853
- const filteredTools = activeTools != null ? Object.entries(tools).filter(([name21]) => activeTools.includes(name21)) : Object.entries(tools);
44505
+ const filteredTools = activeTools != null ? Object.entries(tools).filter(([name222]) => activeTools.includes(name222)) : Object.entries(tools);
43854
44506
  const languageModelTools = [];
43855
- for (const [name21, tool2] of filteredTools) {
44507
+ for (const [name222, tool2] of filteredTools) {
43856
44508
  const toolType = tool2.type;
43857
44509
  switch (toolType) {
43858
44510
  case undefined:
@@ -43860,7 +44512,7 @@ async function prepareToolsAndToolChoice({
43860
44512
  case "function":
43861
44513
  languageModelTools.push({
43862
44514
  type: "function",
43863
- name: name21,
44515
+ name: name222,
43864
44516
  description: tool2.description,
43865
44517
  inputSchema: await asSchema(tool2.inputSchema).jsonSchema,
43866
44518
  ...tool2.inputExamples != null ? { inputExamples: tool2.inputExamples } : {},
@@ -43871,7 +44523,7 @@ async function prepareToolsAndToolChoice({
43871
44523
  case "provider":
43872
44524
  languageModelTools.push({
43873
44525
  type: "provider",
43874
- name: name21,
44526
+ name: name222,
43875
44527
  id: tool2.id,
43876
44528
  args: tool2.args
43877
44529
  });
@@ -43989,7 +44641,7 @@ function getBaseTelemetryAttributes({
43989
44641
  telemetry,
43990
44642
  headers
43991
44643
  }) {
43992
- var _a21;
44644
+ var _a222;
43993
44645
  return {
43994
44646
  "ai.model.provider": model.provider,
43995
44647
  "ai.model.id": model.modelId,
@@ -44004,7 +44656,7 @@ function getBaseTelemetryAttributes({
44004
44656
  }
44005
44657
  return attributes;
44006
44658
  }, {}),
44007
- ...Object.entries((_a21 = telemetry == null ? undefined : telemetry.metadata) != null ? _a21 : {}).reduce((attributes, [key, value]) => {
44659
+ ...Object.entries((_a222 = telemetry == null ? undefined : telemetry.metadata) != null ? _a222 : {}).reduce((attributes, [key, value]) => {
44008
44660
  attributes[`ai.telemetry.metadata.${key}`] = value;
44009
44661
  return attributes;
44010
44662
  }, {}),
@@ -44029,13 +44681,13 @@ function getTracer({
44029
44681
  return import_api2.trace.getTracer("ai");
44030
44682
  }
44031
44683
  async function recordSpan({
44032
- name: name21,
44684
+ name: name222,
44033
44685
  tracer,
44034
44686
  attributes,
44035
44687
  fn,
44036
44688
  endWhenDone = true
44037
44689
  }) {
44038
- return tracer.startActiveSpan(name21, { attributes: await attributes }, async (span) => {
44690
+ return tracer.startActiveSpan(name222, { attributes: await attributes }, async (span) => {
44039
44691
  const ctx = import_api3.context.active();
44040
44692
  try {
44041
44693
  const result = await import_api3.context.with(ctx, () => fn(span));
@@ -44068,6 +44720,26 @@ function recordErrorOnSpan(span, error40) {
44068
44720
  span.setStatus({ code: import_api3.SpanStatusCode.ERROR });
44069
44721
  }
44070
44722
  }
44723
+ function isPrimitiveAttributeValue(value) {
44724
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
44725
+ }
44726
+ function sanitizeAttributeValue(value) {
44727
+ if (!Array.isArray(value)) {
44728
+ return value;
44729
+ }
44730
+ const primitiveTypes2 = new Set(value.filter(isPrimitiveAttributeValue).map((item) => typeof item));
44731
+ if (primitiveTypes2.size !== 1) {
44732
+ return;
44733
+ }
44734
+ const [primitiveType] = primitiveTypes2;
44735
+ if (primitiveType === "string") {
44736
+ return value.filter((item) => typeof item === "string");
44737
+ }
44738
+ if (primitiveType === "number") {
44739
+ return value.filter((item) => typeof item === "number");
44740
+ }
44741
+ return value.filter((item) => typeof item === "boolean");
44742
+ }
44071
44743
  async function selectTelemetryAttributes({
44072
44744
  telemetry,
44073
44745
  attributes
@@ -44086,7 +44758,9 @@ async function selectTelemetryAttributes({
44086
44758
  }
44087
44759
  const result = await value.input();
44088
44760
  if (result != null) {
44089
- resultAttributes[key] = result;
44761
+ const sanitized2 = sanitizeAttributeValue(result);
44762
+ if (sanitized2 != null)
44763
+ resultAttributes[key] = sanitized2;
44090
44764
  }
44091
44765
  continue;
44092
44766
  }
@@ -44096,11 +44770,15 @@ async function selectTelemetryAttributes({
44096
44770
  }
44097
44771
  const result = await value.output();
44098
44772
  if (result != null) {
44099
- resultAttributes[key] = result;
44773
+ const sanitized2 = sanitizeAttributeValue(result);
44774
+ if (sanitized2 != null)
44775
+ resultAttributes[key] = sanitized2;
44100
44776
  }
44101
44777
  continue;
44102
44778
  }
44103
- resultAttributes[key] = value;
44779
+ const sanitized = sanitizeAttributeValue(value);
44780
+ if (sanitized != null)
44781
+ resultAttributes[key] = sanitized;
44104
44782
  }
44105
44783
  return resultAttributes;
44106
44784
  }
@@ -44120,13 +44798,13 @@ function registerTelemetryIntegration(integration) {
44120
44798
  globalThis.AI_SDK_TELEMETRY_INTEGRATIONS.push(integration);
44121
44799
  }
44122
44800
  function getGlobalTelemetryIntegrations() {
44123
- var _a21;
44124
- return (_a21 = globalThis.AI_SDK_TELEMETRY_INTEGRATIONS) != null ? _a21 : [];
44801
+ var _a222;
44802
+ return (_a222 = globalThis.AI_SDK_TELEMETRY_INTEGRATIONS) != null ? _a222 : [];
44125
44803
  }
44126
44804
  function bindTelemetryIntegration(integration) {
44127
- var _a21, _b16, _c, _d, _e, _f;
44805
+ var _a222, _b16, _c, _d, _e, _f;
44128
44806
  return {
44129
- onStart: (_a21 = integration.onStart) == null ? undefined : _a21.bind(integration),
44807
+ onStart: (_a222 = integration.onStart) == null ? undefined : _a222.bind(integration),
44130
44808
  onStepStart: (_b16 = integration.onStepStart) == null ? undefined : _b16.bind(integration),
44131
44809
  onToolCallStart: (_c = integration.onToolCallStart) == null ? undefined : _c.bind(integration),
44132
44810
  onToolCallFinish: (_d = integration.onToolCallFinish) == null ? undefined : _d.bind(integration),
@@ -44196,11 +44874,11 @@ function createNullLanguageModelUsage() {
44196
44874
  };
44197
44875
  }
44198
44876
  function addLanguageModelUsage(usage1, usage2) {
44199
- var _a21, _b16, _c, _d, _e, _f, _g, _h, _i, _j;
44877
+ var _a222, _b16, _c, _d, _e, _f, _g, _h, _i, _j;
44200
44878
  return {
44201
44879
  inputTokens: addTokenCounts(usage1.inputTokens, usage2.inputTokens),
44202
44880
  inputTokenDetails: {
44203
- noCacheTokens: addTokenCounts((_a21 = usage1.inputTokenDetails) == null ? undefined : _a21.noCacheTokens, (_b16 = usage2.inputTokenDetails) == null ? undefined : _b16.noCacheTokens),
44881
+ noCacheTokens: addTokenCounts((_a222 = usage1.inputTokenDetails) == null ? undefined : _a222.noCacheTokens, (_b16 = usage2.inputTokenDetails) == null ? undefined : _b16.noCacheTokens),
44204
44882
  cacheReadTokens: addTokenCounts((_c = usage1.inputTokenDetails) == null ? undefined : _c.cacheReadTokens, (_d = usage2.inputTokenDetails) == null ? undefined : _d.cacheReadTokens),
44205
44883
  cacheWriteTokens: addTokenCounts((_e = usage1.inputTokenDetails) == null ? undefined : _e.cacheWriteTokens, (_f = usage2.inputTokenDetails) == null ? undefined : _f.cacheWriteTokens)
44206
44884
  },
@@ -44284,53 +44962,6 @@ function getRetryDelayInMs({
44284
44962
  }
44285
44963
  return exponentialBackoffDelay;
44286
44964
  }
44287
- async function _retryWithExponentialBackoff(f, {
44288
- maxRetries,
44289
- delayInMs,
44290
- backoffFactor,
44291
- abortSignal
44292
- }, errors4 = []) {
44293
- try {
44294
- return await f();
44295
- } catch (error40) {
44296
- if (isAbortError(error40)) {
44297
- throw error40;
44298
- }
44299
- if (maxRetries === 0) {
44300
- throw error40;
44301
- }
44302
- const errorMessage = getErrorMessage2(error40);
44303
- const newErrors = [...errors4, error40];
44304
- const tryNumber = newErrors.length;
44305
- if (tryNumber > maxRetries) {
44306
- throw new RetryError({
44307
- message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
44308
- reason: "maxRetriesExceeded",
44309
- errors: newErrors
44310
- });
44311
- }
44312
- if (error40 instanceof Error && (APICallError.isInstance(error40) && error40.isRetryable === true || GatewayError.isInstance(error40) && error40.isRetryable === true) && tryNumber <= maxRetries) {
44313
- await delay(getRetryDelayInMs({
44314
- error: error40,
44315
- exponentialBackoffDelay: delayInMs
44316
- }), { abortSignal });
44317
- return _retryWithExponentialBackoff(f, {
44318
- maxRetries,
44319
- delayInMs: backoffFactor * delayInMs,
44320
- backoffFactor,
44321
- abortSignal
44322
- }, newErrors);
44323
- }
44324
- if (tryNumber === 1) {
44325
- throw error40;
44326
- }
44327
- throw new RetryError({
44328
- message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
44329
- reason: "errorNotRetryable",
44330
- errors: newErrors
44331
- });
44332
- }
44333
- }
44334
44965
  function prepareRetries({
44335
44966
  maxRetries,
44336
44967
  abortSignal
@@ -44432,8 +45063,8 @@ function collectToolApprovals({
44432
45063
  return { approvedToolApprovals, deniedToolApprovals };
44433
45064
  }
44434
45065
  function now3() {
44435
- var _a21, _b16;
44436
- return (_b16 = (_a21 = globalThis == null ? undefined : globalThis.performance) == null ? undefined : _a21.now()) != null ? _b16 : Date.now();
45066
+ var _a222, _b16;
45067
+ return (_b16 = (_a222 = globalThis == null ? undefined : globalThis.performance) == null ? undefined : _a222.now()) != null ? _b16 : Date.now();
44437
45068
  }
44438
45069
  async function executeToolCall({
44439
45070
  toolCall,
@@ -44594,10 +45225,158 @@ async function isApprovalNeeded({
44594
45225
  experimental_context
44595
45226
  });
44596
45227
  }
45228
+ function canonicalJSON(value) {
45229
+ if (value === null || value === undefined) {
45230
+ return JSON.stringify(value);
45231
+ }
45232
+ if (typeof value !== "object") {
45233
+ return JSON.stringify(value);
45234
+ }
45235
+ if (Array.isArray(value)) {
45236
+ return `[${value.map(canonicalJSON).join(",")}]`;
45237
+ }
45238
+ const keys = Object.keys(value).sort();
45239
+ const entries = keys.map((k) => `${JSON.stringify(k)}:${canonicalJSON(value[k])}`);
45240
+ return `{${entries.join(",")}}`;
45241
+ }
45242
+ function toBase64url(bytes) {
45243
+ return convertUint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
45244
+ }
45245
+ function fromBase64url(str) {
45246
+ return convertBase64ToUint8Array(str);
45247
+ }
45248
+ async function importKey(secret) {
45249
+ const keyData = typeof secret === "string" ? encoder.encode(secret) : secret;
45250
+ return crypto.subtle.importKey("raw", keyData, { name: "HMAC", hash: "SHA-256" }, false, ["sign", "verify"]);
45251
+ }
45252
+ async function hashInput(input) {
45253
+ const canonical = canonicalJSON(input);
45254
+ const digest = await crypto.subtle.digest("SHA-256", encoder.encode(canonical));
45255
+ return toBase64url(new Uint8Array(digest));
45256
+ }
45257
+ function buildPayload(approvalId, toolCallId, toolName, inputDigest) {
45258
+ return encoder.encode(`${approvalId}
45259
+ ${toolCallId}
45260
+ ${toolName}
45261
+ ${inputDigest}`);
45262
+ }
45263
+ async function signToolApproval({
45264
+ secret,
45265
+ approvalId,
45266
+ toolCallId,
45267
+ toolName,
45268
+ input
45269
+ }) {
45270
+ const key = await importKey(secret);
45271
+ const inputDigest = await hashInput(input);
45272
+ const payload = buildPayload(approvalId, toolCallId, toolName, inputDigest);
45273
+ const sig = await crypto.subtle.sign("HMAC", key, payload);
45274
+ return toBase64url(new Uint8Array(sig));
45275
+ }
45276
+ async function verifyToolApprovalSignature({
45277
+ secret,
45278
+ signature,
45279
+ approvalId,
45280
+ toolCallId,
45281
+ toolName,
45282
+ input
45283
+ }) {
45284
+ const key = await importKey(secret);
45285
+ const inputDigest = await hashInput(input);
45286
+ const payload = buildPayload(approvalId, toolCallId, toolName, inputDigest);
45287
+ const sigBytes = fromBase64url(signature);
45288
+ return crypto.subtle.verify("HMAC", key, sigBytes, payload);
45289
+ }
45290
+ async function maybeSignApproval({
45291
+ secret,
45292
+ approvalId,
45293
+ toolCallId,
45294
+ toolName,
45295
+ input
45296
+ }) {
45297
+ if (secret == null)
45298
+ return;
45299
+ return signToolApproval({ secret, approvalId, toolCallId, toolName, input });
45300
+ }
45301
+ async function validateApprovedToolApprovals({
45302
+ approvedToolApprovals,
45303
+ tools,
45304
+ messages,
45305
+ experimental_context,
45306
+ toolApprovalSecret
45307
+ }) {
45308
+ var _a222;
45309
+ const approved = [];
45310
+ const denied = [];
45311
+ for (const approval of approvedToolApprovals) {
45312
+ const { toolCall, approvalRequest } = approval;
45313
+ const tool2 = tools == null ? undefined : tools[toolCall.toolName];
45314
+ if (toolApprovalSecret != null) {
45315
+ if (approvalRequest.signature == null) {
45316
+ throw new InvalidToolApprovalSignatureError({
45317
+ approvalId: approvalRequest.approvalId,
45318
+ toolCallId: toolCall.toolCallId,
45319
+ reason: "missing signature"
45320
+ });
45321
+ }
45322
+ const valid = await verifyToolApprovalSignature({
45323
+ secret: toolApprovalSecret,
45324
+ signature: approvalRequest.signature,
45325
+ approvalId: approvalRequest.approvalId,
45326
+ toolCallId: toolCall.toolCallId,
45327
+ toolName: toolCall.toolName,
45328
+ input: toolCall.input
45329
+ });
45330
+ if (!valid) {
45331
+ throw new InvalidToolApprovalSignatureError({
45332
+ approvalId: approvalRequest.approvalId,
45333
+ toolCallId: toolCall.toolCallId,
45334
+ reason: "invalid signature"
45335
+ });
45336
+ }
45337
+ }
45338
+ if (tool2 != null && typeof tool2.execute === "function" && tool2.inputSchema != null) {
45339
+ const validation = await safeValidateTypes({
45340
+ value: toolCall.input,
45341
+ schema: asSchema(tool2.inputSchema)
45342
+ });
45343
+ if (!validation.success) {
45344
+ throw new InvalidToolInputError({
45345
+ toolName: toolCall.toolName,
45346
+ toolInput: JSON.stringify(toolCall.input),
45347
+ cause: validation.error
45348
+ });
45349
+ }
45350
+ }
45351
+ const approvalNeeded = tool2 != null && await isApprovalNeeded({
45352
+ tool: tool2,
45353
+ toolCall,
45354
+ messages,
45355
+ experimental_context
45356
+ });
45357
+ if (approvalNeeded) {
45358
+ approved.push(approval);
45359
+ } else {
45360
+ denied.push({
45361
+ ...approval,
45362
+ approvalResponse: {
45363
+ ...approval.approvalResponse,
45364
+ approved: false,
45365
+ reason: (_a222 = approval.approvalResponse.reason) != null ? _a222 : `Tool "${toolCall.toolName}" does not require approval`
45366
+ }
45367
+ });
45368
+ }
45369
+ }
45370
+ return { approvedToolApprovals: approved, deniedToolApprovals: denied };
45371
+ }
44597
45372
  function fixJson(input) {
44598
45373
  const stack = ["ROOT"];
44599
45374
  let lastValidIndex = -1;
44600
45375
  let literalStart = null;
45376
+ let unicodeEscapeDigits = 0;
45377
+ function isHexDigit(char) {
45378
+ return char >= "0" && char <= "9" || char >= "A" && char <= "F" || char >= "a" && char <= "f";
45379
+ }
44601
45380
  function processValueStart(char, i, swapState) {
44602
45381
  {
44603
45382
  switch (char) {
@@ -44802,7 +45581,22 @@ function fixJson(input) {
44802
45581
  }
44803
45582
  case "INSIDE_STRING_ESCAPE": {
44804
45583
  stack.pop();
44805
- lastValidIndex = i;
45584
+ if (char === "u") {
45585
+ unicodeEscapeDigits = 0;
45586
+ stack.push("INSIDE_STRING_UNICODE_ESCAPE");
45587
+ } else {
45588
+ lastValidIndex = i;
45589
+ }
45590
+ break;
45591
+ }
45592
+ case "INSIDE_STRING_UNICODE_ESCAPE": {
45593
+ if (isHexDigit(char)) {
45594
+ unicodeEscapeDigits++;
45595
+ if (unicodeEscapeDigits === 4) {
45596
+ stack.pop();
45597
+ lastValidIndex = i;
45598
+ }
45599
+ }
44806
45600
  break;
44807
45601
  }
44808
45602
  case "INSIDE_NUMBER": {
@@ -45059,8 +45853,8 @@ function isLoopFinished() {
45059
45853
  }
45060
45854
  function hasToolCall(toolName) {
45061
45855
  return ({ steps }) => {
45062
- var _a21, _b16, _c;
45063
- return (_c = (_b16 = (_a21 = steps[steps.length - 1]) == null ? undefined : _a21.toolCalls) == null ? undefined : _b16.some((toolCall) => toolCall.toolName === toolName)) != null ? _c : false;
45856
+ var _a222, _b16, _c;
45857
+ return (_c = (_b16 = (_a222 = steps[steps.length - 1]) == null ? undefined : _a222.toolCalls) == null ? undefined : _b16.some((toolCall) => toolCall.toolName === toolName)) != null ? _c : false;
45064
45858
  };
45065
45859
  }
45066
45860
  async function isStopConditionMet({
@@ -45156,7 +45950,8 @@ async function toResponseMessages({
45156
45950
  content.push({
45157
45951
  type: "tool-approval-request",
45158
45952
  approvalId: part.approvalId,
45159
- toolCallId: part.toolCall.toolCallId
45953
+ toolCallId: part.toolCall.toolCallId,
45954
+ ...part.signature != null ? { signature: part.signature } : {}
45160
45955
  });
45161
45956
  break;
45162
45957
  }
@@ -45239,6 +46034,7 @@ async function generateText({
45239
46034
  experimental_repairToolCall: repairToolCall,
45240
46035
  experimental_download: download2,
45241
46036
  experimental_context,
46037
+ experimental_toolApprovalSecret,
45242
46038
  experimental_include: include,
45243
46039
  _internal: { generateId: generateId22 = originalGenerateId } = {},
45244
46040
  experimental_onStart: onStart,
@@ -45331,11 +46127,27 @@ async function generateText({
45331
46127
  }),
45332
46128
  tracer,
45333
46129
  fn: async (span) => {
45334
- var _a21, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
46130
+ var _a222, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
45335
46131
  const initialMessages = initialPrompt.messages;
45336
46132
  const responseMessages = [];
45337
- const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
45338
- const localApprovedToolApprovals = approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted);
46133
+ const {
46134
+ approvedToolApprovals,
46135
+ deniedToolApprovals: collectedDeniedToolApprovals
46136
+ } = collectToolApprovals({ messages: initialMessages });
46137
+ const {
46138
+ approvedToolApprovals: localApprovedToolApprovals,
46139
+ deniedToolApprovals: revalidationDeniedToolApprovals
46140
+ } = await validateApprovedToolApprovals({
46141
+ approvedToolApprovals: approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted),
46142
+ tools,
46143
+ messages: initialMessages,
46144
+ experimental_context,
46145
+ toolApprovalSecret: experimental_toolApprovalSecret
46146
+ });
46147
+ const deniedToolApprovals = [
46148
+ ...collectedDeniedToolApprovals,
46149
+ ...revalidationDeniedToolApprovals
46150
+ ];
45339
46151
  if (deniedToolApprovals.length > 0 || localApprovedToolApprovals.length > 0) {
45340
46152
  const toolOutputs = await executeTools({
45341
46153
  toolCalls: localApprovedToolApprovals.map((toolApproval) => toolApproval.toolCall),
@@ -45412,7 +46224,7 @@ async function generateText({
45412
46224
  messages: stepInputMessages,
45413
46225
  experimental_context
45414
46226
  }));
45415
- const stepModel = resolveLanguageModel((_a21 = prepareStepResult == null ? undefined : prepareStepResult.model) != null ? _a21 : model);
46227
+ const stepModel = resolveLanguageModel((_a222 = prepareStepResult == null ? undefined : prepareStepResult.model) != null ? _a222 : model);
45416
46228
  const stepModelInfo = {
45417
46229
  provider: stepModel.provider,
45418
46230
  modelId: stepModel.modelId
@@ -45462,7 +46274,7 @@ async function generateText({
45462
46274
  ]
45463
46275
  });
45464
46276
  currentModelResponse = await retry(() => {
45465
- var _a222;
46277
+ var _a232;
45466
46278
  return recordSpan({
45467
46279
  name: "ai.generateText.doGenerate",
45468
46280
  attributes: selectTelemetryAttributes({
@@ -45490,14 +46302,14 @@ async function generateText({
45490
46302
  "gen_ai.request.max_tokens": settings.maxOutputTokens,
45491
46303
  "gen_ai.request.presence_penalty": settings.presencePenalty,
45492
46304
  "gen_ai.request.stop_sequences": settings.stopSequences,
45493
- "gen_ai.request.temperature": (_a222 = settings.temperature) != null ? _a222 : undefined,
46305
+ "gen_ai.request.temperature": (_a232 = settings.temperature) != null ? _a232 : undefined,
45494
46306
  "gen_ai.request.top_k": settings.topK,
45495
46307
  "gen_ai.request.top_p": settings.topP
45496
46308
  }
45497
46309
  }),
45498
46310
  tracer,
45499
46311
  fn: async (span2) => {
45500
- var _a232, _b23, _c2, _d2, _e2, _f2, _g2, _h2;
46312
+ var _a24, _b23, _c2, _d2, _e2, _f2, _g2, _h2;
45501
46313
  const result = await stepModel.doGenerate({
45502
46314
  ...callSettings2,
45503
46315
  tools: stepTools,
@@ -45509,7 +46321,7 @@ async function generateText({
45509
46321
  headers: headersWithUserAgent
45510
46322
  });
45511
46323
  const responseData = {
45512
- id: (_b23 = (_a232 = result.response) == null ? undefined : _a232.id) != null ? _b23 : generateId22(),
46324
+ id: (_b23 = (_a24 = result.response) == null ? undefined : _a24.id) != null ? _b23 : generateId22(),
45513
46325
  timestamp: (_d2 = (_c2 = result.response) == null ? undefined : _c2.timestamp) != null ? _d2 : /* @__PURE__ */ new Date,
45514
46326
  modelId: (_f2 = (_e2 = result.response) == null ? undefined : _e2.modelId) != null ? _f2 : stepModel.modelId,
45515
46327
  headers: (_g2 = result.response) == null ? undefined : _g2.headers,
@@ -45590,10 +46402,19 @@ async function generateText({
45590
46402
  messages: stepInputMessages,
45591
46403
  experimental_context
45592
46404
  })) {
46405
+ const approvalId = generateId22();
46406
+ const signature = await maybeSignApproval({
46407
+ secret: experimental_toolApprovalSecret,
46408
+ approvalId,
46409
+ toolCallId: toolCall.toolCallId,
46410
+ toolName: toolCall.toolName,
46411
+ input: toolCall.input
46412
+ });
45593
46413
  toolApprovalRequests[toolCall.toolCallId] = {
45594
46414
  type: "tool-approval-request",
45595
- approvalId: generateId22(),
45596
- toolCall
46415
+ approvalId,
46416
+ toolCall,
46417
+ ...signature != null ? { signature } : {}
45597
46418
  };
45598
46419
  }
45599
46420
  }
@@ -46050,6 +46871,9 @@ function getResponseUIMessageId({
46050
46871
  function isDataUIMessageChunk(chunk) {
46051
46872
  return chunk.type.startsWith("data-");
46052
46873
  }
46874
+ function createIdMap() {
46875
+ return /* @__PURE__ */ Object.create(null);
46876
+ }
46053
46877
  function isDataUIPart(part) {
46054
46878
  return part.type.startsWith("data-");
46055
46879
  }
@@ -46088,9 +46912,9 @@ function createStreamingUIMessageState({
46088
46912
  role: "assistant",
46089
46913
  parts: []
46090
46914
  },
46091
- activeTextParts: {},
46092
- activeReasoningParts: {},
46093
- partialToolCalls: {}
46915
+ activeTextParts: createIdMap(),
46916
+ activeReasoningParts: createIdMap(),
46917
+ partialToolCalls: createIdMap()
46094
46918
  };
46095
46919
  }
46096
46920
  function processUIMessageStream({
@@ -46105,7 +46929,7 @@ function processUIMessageStream({
46105
46929
  return stream.pipeThrough(new TransformStream({
46106
46930
  async transform(chunk, controller) {
46107
46931
  await runUpdateMessageJob(async ({ state, write }) => {
46108
- var _a21, _b16, _c, _d;
46932
+ var _a222, _b16, _c, _d;
46109
46933
  function getToolInvocation(toolCallId) {
46110
46934
  const toolInvocations = state.message.parts.filter(isToolUIPart);
46111
46935
  const toolInvocation = toolInvocations.find((invocation) => invocation.toolCallId === toolCallId);
@@ -46119,7 +46943,7 @@ function processUIMessageStream({
46119
46943
  return toolInvocation;
46120
46944
  }
46121
46945
  function updateToolPart(options) {
46122
- var _a222;
46946
+ var _a232;
46123
46947
  const part = state.message.parts.find((part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId);
46124
46948
  const anyOptions = options;
46125
46949
  const anyPart = part;
@@ -46136,7 +46960,7 @@ function processUIMessageStream({
46136
46960
  if (options.toolMetadata !== undefined) {
46137
46961
  anyPart.toolMetadata = options.toolMetadata;
46138
46962
  }
46139
- anyPart.providerExecuted = (_a222 = anyOptions.providerExecuted) != null ? _a222 : part.providerExecuted;
46963
+ anyPart.providerExecuted = (_a232 = anyOptions.providerExecuted) != null ? _a232 : part.providerExecuted;
46140
46964
  const providerMetadata = anyOptions.providerMetadata;
46141
46965
  if (providerMetadata != null) {
46142
46966
  if (options.state === "output-available" || options.state === "output-error") {
@@ -46165,7 +46989,7 @@ function processUIMessageStream({
46165
46989
  }
46166
46990
  }
46167
46991
  function updateDynamicToolPart(options) {
46168
- var _a222, _b23;
46992
+ var _a232, _b23;
46169
46993
  const part = state.message.parts.find((part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId);
46170
46994
  const anyOptions = options;
46171
46995
  const anyPart = part;
@@ -46175,7 +46999,7 @@ function processUIMessageStream({
46175
46999
  anyPart.input = anyOptions.input;
46176
47000
  anyPart.output = anyOptions.output;
46177
47001
  anyPart.errorText = anyOptions.errorText;
46178
- anyPart.rawInput = (_a222 = anyOptions.rawInput) != null ? _a222 : anyPart.rawInput;
47002
+ anyPart.rawInput = (_a232 = anyOptions.rawInput) != null ? _a232 : anyPart.rawInput;
46179
47003
  anyPart.preliminary = anyOptions.preliminary;
46180
47004
  if (options.title !== undefined) {
46181
47005
  anyPart.title = options.title;
@@ -46250,7 +47074,7 @@ function processUIMessageStream({
46250
47074
  });
46251
47075
  }
46252
47076
  textPart.text += chunk.delta;
46253
- textPart.providerMetadata = (_a21 = chunk.providerMetadata) != null ? _a21 : textPart.providerMetadata;
47077
+ textPart.providerMetadata = (_a222 = chunk.providerMetadata) != null ? _a222 : textPart.providerMetadata;
46254
47078
  write();
46255
47079
  break;
46256
47080
  }
@@ -46477,7 +47301,10 @@ function processUIMessageStream({
46477
47301
  case "tool-approval-request": {
46478
47302
  const toolInvocation = getToolInvocation(chunk.toolCallId);
46479
47303
  toolInvocation.state = "approval-requested";
46480
- toolInvocation.approval = { id: chunk.approvalId };
47304
+ toolInvocation.approval = {
47305
+ id: chunk.approvalId,
47306
+ ...chunk.signature != null ? { signature: chunk.signature } : {}
47307
+ };
46481
47308
  write();
46482
47309
  break;
46483
47310
  }
@@ -46555,8 +47382,8 @@ function processUIMessageStream({
46555
47382
  break;
46556
47383
  }
46557
47384
  case "finish-step": {
46558
- state.activeTextParts = {};
46559
- state.activeReasoningParts = {};
47385
+ state.activeTextParts = createIdMap();
47386
+ state.activeReasoningParts = createIdMap();
46560
47387
  break;
46561
47388
  }
46562
47389
  case "start": {
@@ -46748,13 +47575,13 @@ function createAsyncIterableStream(source) {
46748
47575
  const reader = this.getReader();
46749
47576
  let finished = false;
46750
47577
  async function cleanup(cancelStream) {
46751
- var _a21;
47578
+ var _a222;
46752
47579
  if (finished)
46753
47580
  return;
46754
47581
  finished = true;
46755
47582
  try {
46756
47583
  if (cancelStream) {
46757
- await ((_a21 = reader.cancel) == null ? undefined : _a21.call(reader));
47584
+ await ((_a222 = reader.cancel) == null ? undefined : _a222.call(reader));
46758
47585
  }
46759
47586
  } finally {
46760
47587
  try {
@@ -46897,6 +47724,7 @@ function runToolsTransformation({
46897
47724
  abortSignal,
46898
47725
  repairToolCall,
46899
47726
  experimental_context,
47727
+ toolApprovalSecret,
46900
47728
  generateId: generateId22,
46901
47729
  stepNumber,
46902
47730
  model,
@@ -47026,10 +47854,19 @@ function runToolsTransformation({
47026
47854
  messages,
47027
47855
  experimental_context
47028
47856
  })) {
47857
+ const approvalId = generateId22();
47858
+ const signature = await maybeSignApproval({
47859
+ secret: toolApprovalSecret,
47860
+ approvalId,
47861
+ toolCallId: toolCall.toolCallId,
47862
+ toolName: toolCall.toolName,
47863
+ input: toolCall.input
47864
+ });
47029
47865
  toolResultsStreamController.enqueue({
47030
47866
  type: "tool-approval-request",
47031
- approvalId: generateId22(),
47032
- toolCall
47867
+ approvalId,
47868
+ toolCall,
47869
+ ...signature != null ? { signature } : {}
47033
47870
  });
47034
47871
  break;
47035
47872
  }
@@ -47167,6 +48004,7 @@ function streamText({
47167
48004
  experimental_onToolCallStart: onToolCallStart,
47168
48005
  experimental_onToolCallFinish: onToolCallFinish,
47169
48006
  experimental_context,
48007
+ experimental_toolApprovalSecret,
47170
48008
  experimental_include: include,
47171
48009
  _internal: { now: now22 = now3, generateId: generateId22 = originalGenerateId2 } = {},
47172
48010
  ...settings
@@ -47216,6 +48054,7 @@ function streamText({
47216
48054
  now: now22,
47217
48055
  generateId: generateId22,
47218
48056
  experimental_context,
48057
+ experimental_toolApprovalSecret,
47219
48058
  download: download2,
47220
48059
  include
47221
48060
  });
@@ -47243,7 +48082,7 @@ function createOutputTransformStream(output) {
47243
48082
  }
47244
48083
  return new TransformStream({
47245
48084
  async transform(chunk, controller) {
47246
- var _a21;
48085
+ var _a222;
47247
48086
  if (chunk.type === "finish-step" && textChunk.length > 0) {
47248
48087
  publishTextChunk({ controller });
47249
48088
  }
@@ -47270,7 +48109,7 @@ function createOutputTransformStream(output) {
47270
48109
  }
47271
48110
  text22 += chunk.text;
47272
48111
  textChunk += chunk.text;
47273
- textProviderMetadata = (_a21 = chunk.providerMetadata) != null ? _a21 : textProviderMetadata;
48112
+ textProviderMetadata = (_a222 = chunk.providerMetadata) != null ? _a222 : textProviderMetadata;
47274
48113
  const result = await output.parsePartialOutput({ text: text22 });
47275
48114
  if (result !== undefined) {
47276
48115
  const currentValue = typeof result.partial === "string" ? result.partial : JSON.stringify(result.partial);
@@ -47284,7 +48123,7 @@ function createOutputTransformStream(output) {
47284
48123
  }
47285
48124
  function createUIMessageStream({
47286
48125
  execute,
47287
- onError = getErrorMessage2,
48126
+ onError = () => "An error occurred.",
47288
48127
  originalMessages,
47289
48128
  onStepFinish,
47290
48129
  onFinish,
@@ -47367,7 +48206,7 @@ function readUIMessageStream({
47367
48206
  onError,
47368
48207
  terminateOnError = false
47369
48208
  }) {
47370
- var _a21;
48209
+ var _a222;
47371
48210
  let controller;
47372
48211
  let hasErrored = false;
47373
48212
  const outputStream = new ReadableStream({
@@ -47376,7 +48215,7 @@ function readUIMessageStream({
47376
48215
  }
47377
48216
  });
47378
48217
  const state = createStreamingUIMessageState({
47379
- messageId: (_a21 = message == null ? undefined : message.id) != null ? _a21 : "",
48218
+ messageId: (_a222 = message == null ? undefined : message.id) != null ? _a222 : "",
47380
48219
  lastMessage: message
47381
48220
  });
47382
48221
  const handleError = (error40) => {
@@ -47436,7 +48275,7 @@ async function convertToModelMessages(messages, options) {
47436
48275
  modelMessages.push({
47437
48276
  role: "user",
47438
48277
  content: message.parts.map((part) => {
47439
- var _a21;
48278
+ var _a222;
47440
48279
  if (isTextUIPart(part)) {
47441
48280
  return {
47442
48281
  type: "text",
@@ -47454,7 +48293,7 @@ async function convertToModelMessages(messages, options) {
47454
48293
  };
47455
48294
  }
47456
48295
  if (isDataUIPart(part)) {
47457
- return (_a21 = options == null ? undefined : options.convertDataPart) == null ? undefined : _a21.call(options, part);
48296
+ return (_a222 = options == null ? undefined : options.convertDataPart) == null ? undefined : _a222.call(options, part);
47458
48297
  }
47459
48298
  }).filter(isNonNullable)
47460
48299
  });
@@ -47464,7 +48303,7 @@ async function convertToModelMessages(messages, options) {
47464
48303
  if (message.parts != null) {
47465
48304
  let block = [];
47466
48305
  async function processBlock() {
47467
- var _a21, _b16, _c, _d, _e, _f, _g, _h;
48306
+ var _a222, _b16, _c, _d, _e, _f, _g, _h;
47468
48307
  if (block.length === 0) {
47469
48308
  return;
47470
48309
  }
@@ -47497,7 +48336,7 @@ async function convertToModelMessages(messages, options) {
47497
48336
  type: "tool-call",
47498
48337
  toolCallId: part.toolCallId,
47499
48338
  toolName,
47500
- input: part.state === "output-error" ? (_a21 = part.input) != null ? _a21 : ("rawInput" in part) ? part.rawInput : undefined : part.input,
48339
+ input: part.state === "output-error" ? (_a222 = part.input) != null ? _a222 : ("rawInput" in part) ? part.rawInput : undefined : part.input,
47501
48340
  providerExecuted: part.providerExecuted,
47502
48341
  ...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}
47503
48342
  });
@@ -47505,7 +48344,8 @@ async function convertToModelMessages(messages, options) {
47505
48344
  content.push({
47506
48345
  type: "tool-approval-request",
47507
48346
  approvalId: part.approval.id,
47508
- toolCallId: part.toolCallId
48347
+ toolCallId: part.toolCallId,
48348
+ ...part.approval.signature != null ? { signature: part.approval.signature } : {}
47509
48349
  });
47510
48350
  }
47511
48351
  if (part.providerExecuted === true && part.state !== "approval-responded" && (part.state === "output-available" || part.state === "output-error")) {
@@ -47540,8 +48380,8 @@ async function convertToModelMessages(messages, options) {
47540
48380
  content
47541
48381
  });
47542
48382
  const toolParts = block.filter((part) => {
47543
- var _a222;
47544
- return isToolUIPart(part) && (part.providerExecuted !== true || ((_a222 = part.approval) == null ? undefined : _a222.approved) != null);
48383
+ var _a232;
48384
+ return isToolUIPart(part) && (part.providerExecuted !== true || ((_a232 = part.approval) == null ? undefined : _a232.approved) != null);
47545
48385
  });
47546
48386
  if (toolParts.length > 0) {
47547
48387
  {
@@ -47775,7 +48615,7 @@ async function createAgentUIStream({
47775
48615
  onStepFinish,
47776
48616
  ...uiMessageStreamOptions
47777
48617
  }) {
47778
- var _a21;
48618
+ var _a222;
47779
48619
  const validatedMessages = await validateUIMessages({
47780
48620
  messages: uiMessages,
47781
48621
  tools: agent.tools
@@ -47793,7 +48633,7 @@ async function createAgentUIStream({
47793
48633
  });
47794
48634
  return result.toUIMessageStream({
47795
48635
  ...uiMessageStreamOptions,
47796
- originalMessages: (_a21 = uiMessageStreamOptions.originalMessages) != null ? _a21 : validatedMessages
48636
+ originalMessages: (_a222 = uiMessageStreamOptions.originalMessages) != null ? _a222 : validatedMessages
47797
48637
  });
47798
48638
  }
47799
48639
  async function createAgentUIStreamResponse({
@@ -47877,7 +48717,7 @@ async function embed({
47877
48717
  }),
47878
48718
  tracer,
47879
48719
  fn: async (doEmbedSpan) => {
47880
- var _a21, _b16;
48720
+ var _a222, _b16;
47881
48721
  const modelResponse = await model.doEmbed({
47882
48722
  values: [value],
47883
48723
  abortSignal,
@@ -47885,7 +48725,7 @@ async function embed({
47885
48725
  providerOptions
47886
48726
  });
47887
48727
  const embedding2 = modelResponse.embeddings[0];
47888
- const usage2 = (_a21 = modelResponse.usage) != null ? _a21 : { tokens: NaN };
48728
+ const usage2 = (_a222 = modelResponse.usage) != null ? _a222 : { tokens: NaN };
47889
48729
  doEmbedSpan.setAttributes(await selectTelemetryAttributes({
47890
48730
  telemetry,
47891
48731
  attributes: {
@@ -47970,7 +48810,7 @@ async function embedMany({
47970
48810
  }),
47971
48811
  tracer,
47972
48812
  fn: async (span) => {
47973
- var _a21;
48813
+ var _a222;
47974
48814
  const [maxEmbeddingsPerCall, supportsParallelCalls] = await Promise.all([
47975
48815
  model.maxEmbeddingsPerCall,
47976
48816
  model.supportsParallelCalls
@@ -47994,7 +48834,7 @@ async function embedMany({
47994
48834
  }),
47995
48835
  tracer,
47996
48836
  fn: async (doEmbedSpan) => {
47997
- var _a222, _b16;
48837
+ var _a232, _b16;
47998
48838
  const modelResponse = await model.doEmbed({
47999
48839
  values,
48000
48840
  abortSignal,
@@ -48002,7 +48842,7 @@ async function embedMany({
48002
48842
  providerOptions
48003
48843
  });
48004
48844
  const embeddings3 = modelResponse.embeddings;
48005
- const usage2 = (_a222 = modelResponse.usage) != null ? _a222 : { tokens: NaN };
48845
+ const usage2 = (_a232 = modelResponse.usage) != null ? _a232 : { tokens: NaN };
48006
48846
  doEmbedSpan.setAttributes(await selectTelemetryAttributes({
48007
48847
  telemetry,
48008
48848
  attributes: {
@@ -48072,7 +48912,7 @@ async function embedMany({
48072
48912
  }),
48073
48913
  tracer,
48074
48914
  fn: async (doEmbedSpan) => {
48075
- var _a222, _b16;
48915
+ var _a232, _b16;
48076
48916
  const modelResponse = await model.doEmbed({
48077
48917
  values: chunk,
48078
48918
  abortSignal,
@@ -48080,7 +48920,7 @@ async function embedMany({
48080
48920
  providerOptions
48081
48921
  });
48082
48922
  const embeddings2 = modelResponse.embeddings;
48083
- const usage = (_a222 = modelResponse.usage) != null ? _a222 : { tokens: NaN };
48923
+ const usage = (_a232 = modelResponse.usage) != null ? _a232 : { tokens: NaN };
48084
48924
  doEmbedSpan.setAttributes(await selectTelemetryAttributes({
48085
48925
  telemetry,
48086
48926
  attributes: {
@@ -48112,7 +48952,7 @@ async function embedMany({
48112
48952
  } else {
48113
48953
  for (const [providerName, metadata] of Object.entries(result.providerMetadata)) {
48114
48954
  providerMetadata[providerName] = {
48115
- ...(_a21 = providerMetadata[providerName]) != null ? _a21 : {},
48955
+ ...(_a222 = providerMetadata[providerName]) != null ? _a222 : {},
48116
48956
  ...metadata
48117
48957
  };
48118
48958
  }
@@ -48158,14 +48998,14 @@ async function generateImage({
48158
48998
  abortSignal,
48159
48999
  headers
48160
49000
  }) {
48161
- var _a21, _b16;
49001
+ var _a222, _b16;
48162
49002
  const model = resolveImageModel(modelArg);
48163
49003
  const headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION6}`);
48164
49004
  const { retry } = prepareRetries({
48165
49005
  maxRetries: maxRetriesArg,
48166
49006
  abortSignal
48167
49007
  });
48168
- const maxImagesPerCallWithDefault = (_a21 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a21 : 1;
49008
+ const maxImagesPerCallWithDefault = (_a222 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a222 : 1;
48169
49009
  const callCount = Math.ceil(n / maxImagesPerCallWithDefault);
48170
49010
  const callImageCounts = Array.from({ length: callCount }, (_, i) => {
48171
49011
  if (i < callCount - 1) {
@@ -48200,13 +49040,13 @@ async function generateImage({
48200
49040
  };
48201
49041
  for (const result of results) {
48202
49042
  images.push(...result.images.map((image) => {
48203
- var _a222;
49043
+ var _a232;
48204
49044
  return new DefaultGeneratedFile({
48205
49045
  data: image,
48206
- mediaType: (_a222 = detectMediaType({
49046
+ mediaType: (_a232 = detectMediaType({
48207
49047
  data: image,
48208
49048
  signatures: imageMediaTypeSignatures
48209
- })) != null ? _a222 : "image/png"
49049
+ })) != null ? _a232 : "image/png"
48210
49050
  });
48211
49051
  }));
48212
49052
  warnings.push(...result.warnings);
@@ -48557,7 +49397,7 @@ async function generateObject(options) {
48557
49397
  }),
48558
49398
  tracer,
48559
49399
  fn: async (span) => {
48560
- var _a21;
49400
+ var _a222;
48561
49401
  let result;
48562
49402
  let finishReason;
48563
49403
  let usage;
@@ -48602,7 +49442,7 @@ async function generateObject(options) {
48602
49442
  }),
48603
49443
  tracer,
48604
49444
  fn: async (span2) => {
48605
- var _a222, _b16, _c, _d, _e, _f, _g, _h;
49445
+ var _a232, _b16, _c, _d, _e, _f, _g, _h;
48606
49446
  const result2 = await model.doGenerate({
48607
49447
  responseFormat: {
48608
49448
  type: "json",
@@ -48617,7 +49457,7 @@ async function generateObject(options) {
48617
49457
  headers: headersWithUserAgent
48618
49458
  });
48619
49459
  const responseData = {
48620
- id: (_b16 = (_a222 = result2.response) == null ? undefined : _a222.id) != null ? _b16 : generateId22(),
49460
+ id: (_b16 = (_a232 = result2.response) == null ? undefined : _a232.id) != null ? _b16 : generateId22(),
48621
49461
  timestamp: (_d = (_c = result2.response) == null ? undefined : _c.timestamp) != null ? _d : currentDate(),
48622
49462
  modelId: (_f = (_e = result2.response) == null ? undefined : _e.modelId) != null ? _f : model.modelId,
48623
49463
  headers: (_g = result2.response) == null ? undefined : _g.headers,
@@ -48666,7 +49506,7 @@ async function generateObject(options) {
48666
49506
  usage = asLanguageModelUsage(generateResult.usage);
48667
49507
  warnings = generateResult.warnings;
48668
49508
  resultProviderMetadata = generateResult.providerMetadata;
48669
- request = (_a21 = generateResult.request) != null ? _a21 : {};
49509
+ request = (_a222 = generateResult.request) != null ? _a222 : {};
48670
49510
  response = generateResult.responseData;
48671
49511
  reasoning = generateResult.reasoning;
48672
49512
  logWarnings({
@@ -48785,8 +49625,8 @@ function simulateReadableStream({
48785
49625
  chunkDelayInMs = 0,
48786
49626
  _internal
48787
49627
  }) {
48788
- var _a21;
48789
- const delay2 = (_a21 = _internal == null ? undefined : _internal.delay) != null ? _a21 : delay;
49628
+ var _a222;
49629
+ const delay2 = (_a222 = _internal == null ? undefined : _internal.delay) != null ? _a222 : delay;
48790
49630
  let index = 0;
48791
49631
  return new ReadableStream({
48792
49632
  async pull(controller) {
@@ -48880,7 +49720,7 @@ async function generateSpeech({
48880
49720
  abortSignal,
48881
49721
  headers
48882
49722
  }) {
48883
- var _a21;
49723
+ var _a222;
48884
49724
  const resolvedModel = resolveSpeechModel(model);
48885
49725
  if (!resolvedModel) {
48886
49726
  throw new Error("Model could not be resolved");
@@ -48912,10 +49752,10 @@ async function generateSpeech({
48912
49752
  return new DefaultSpeechResult({
48913
49753
  audio: new DefaultGeneratedAudioFile({
48914
49754
  data: result.audio,
48915
- mediaType: (_a21 = detectMediaType({
49755
+ mediaType: (_a222 = detectMediaType({
48916
49756
  data: result.audio,
48917
49757
  signatures: audioMediaTypeSignatures
48918
- })) != null ? _a21 : "audio/mp3"
49758
+ })) != null ? _a222 : "audio/mp3"
48919
49759
  }),
48920
49760
  warnings: result.warnings,
48921
49761
  responses: [result.response],
@@ -48965,27 +49805,44 @@ function pruneMessages({
48965
49805
  }
48966
49806
  }
48967
49807
  }
49808
+ const toolCallIdToToolName = /* @__PURE__ */ new Map;
49809
+ for (const message of messages) {
49810
+ if ((message.role === "assistant" || message.role === "tool") && typeof message.content !== "string") {
49811
+ for (const part of message.content) {
49812
+ if (part.type === "tool-call" || part.type === "tool-result") {
49813
+ toolCallIdToToolName.set(part.toolCallId, part.toolName);
49814
+ }
49815
+ }
49816
+ }
49817
+ }
49818
+ const approvalIdToToolName = /* @__PURE__ */ new Map;
49819
+ for (const message of messages) {
49820
+ if ((message.role === "assistant" || message.role === "tool") && typeof message.content !== "string") {
49821
+ for (const part of message.content) {
49822
+ if (part.type === "tool-approval-request") {
49823
+ const toolName = toolCallIdToToolName.get(part.toolCallId);
49824
+ if (toolName != null) {
49825
+ approvalIdToToolName.set(part.approvalId, toolName);
49826
+ }
49827
+ }
49828
+ }
49829
+ }
49830
+ }
48968
49831
  messages = messages.map((message, messageIndex) => {
48969
49832
  if (message.role !== "assistant" && message.role !== "tool" || typeof message.content === "string" || keepLastMessagesCount && messageIndex >= messages.length - keepLastMessagesCount) {
48970
49833
  return message;
48971
49834
  }
48972
- const toolCallIdToToolName = {};
48973
- const approvalIdToToolName = {};
48974
49835
  return {
48975
49836
  ...message,
48976
49837
  content: message.content.filter((part) => {
48977
49838
  if (part.type !== "tool-call" && part.type !== "tool-result" && part.type !== "tool-approval-request" && part.type !== "tool-approval-response") {
48978
49839
  return true;
48979
49840
  }
48980
- if (part.type === "tool-call") {
48981
- toolCallIdToToolName[part.toolCallId] = part.toolName;
48982
- } else if (part.type === "tool-approval-request") {
48983
- approvalIdToToolName[part.approvalId] = toolCallIdToToolName[part.toolCallId];
48984
- }
48985
49841
  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)) {
48986
49842
  return true;
48987
49843
  }
48988
- return toolCall.tools != null && !toolCall.tools.includes(part.type === "tool-call" || part.type === "tool-result" ? part.toolName : approvalIdToToolName[part.approvalId]);
49844
+ const partToolName = part.type === "tool-call" || part.type === "tool-result" ? part.toolName : approvalIdToToolName.get(part.approvalId);
49845
+ return toolCall.tools != null && partToolName != null && !toolCall.tools.includes(partToolName);
48989
49846
  })
48990
49847
  };
48991
49848
  });
@@ -49093,13 +49950,16 @@ async function experimental_generateVideo({
49093
49950
  duration: duration3,
49094
49951
  fps,
49095
49952
  seed,
49953
+ frameImages,
49954
+ inputReferences,
49955
+ generateAudio,
49096
49956
  providerOptions,
49097
49957
  maxRetries: maxRetriesArg,
49098
49958
  abortSignal,
49099
49959
  headers,
49100
49960
  download: downloadFn = defaultDownload
49101
49961
  }) {
49102
- var _a21;
49962
+ var _a222, _b16;
49103
49963
  const model = resolveVideoModel(modelArg);
49104
49964
  const headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION6}`);
49105
49965
  const { retry } = prepareRetries({
@@ -49107,13 +49967,34 @@ async function experimental_generateVideo({
49107
49967
  abortSignal
49108
49968
  });
49109
49969
  const { prompt, image } = normalizePrompt2(promptArg);
49110
- const maxVideosPerCallWithDefault = (_a21 = maxVideosPerCall != null ? maxVideosPerCall : await invokeModelMaxVideosPerCall(model)) != null ? _a21 : 1;
49970
+ const normalizedFrameImages = frameImages == null ? undefined : frameImages.map((frame) => ({
49971
+ image: normalizeImageData(frame.image),
49972
+ frameType: frame.frameType
49973
+ }));
49974
+ const normalizedInputReferences = inputReferences == null ? undefined : inputReferences.map((reference) => normalizeImageData(reference));
49975
+ const effectiveInputReferences = normalizedFrameImages != null && normalizedFrameImages.length > 0 ? undefined : normalizedInputReferences;
49976
+ const warnings = [];
49977
+ if (normalizedFrameImages != null && normalizedFrameImages.length > 0 && normalizedInputReferences != null && normalizedInputReferences.length > 0) {
49978
+ warnings.push({
49979
+ type: "other",
49980
+ message: "inputReferences were ignored because frameImages were provided; frameImages and inputReferences cannot be combined."
49981
+ });
49982
+ }
49983
+ const firstFrameImage = (_a222 = normalizedFrameImages == null ? undefined : normalizedFrameImages.find((frame) => frame.frameType === "first_frame")) == null ? undefined : _a222.image;
49984
+ if (image != null && firstFrameImage != null) {
49985
+ warnings.push({
49986
+ type: "other",
49987
+ message: "prompt.image was ignored because a first_frame frameImage was provided; the first_frame frameImage takes precedence as the start image."
49988
+ });
49989
+ }
49990
+ const resolvedImage = firstFrameImage != null ? firstFrameImage : image;
49991
+ const maxVideosPerCallWithDefault = (_b16 = maxVideosPerCall != null ? maxVideosPerCall : await invokeModelMaxVideosPerCall(model)) != null ? _b16 : 1;
49111
49992
  const callCount = Math.ceil(n / maxVideosPerCallWithDefault);
49112
49993
  const callVideoCounts = Array.from({ length: callCount }, (_, index) => {
49113
49994
  const remaining = n - index * maxVideosPerCallWithDefault;
49114
49995
  return Math.min(remaining, maxVideosPerCallWithDefault);
49115
49996
  });
49116
- const results = await Promise.all(callVideoCounts.map(async (callVideoCount) => retry(() => model.doGenerate({
49997
+ const results = await Promise.all(callVideoCounts.map(async (callVideoCount) => await retry(() => model.doGenerate({
49117
49998
  prompt,
49118
49999
  n: callVideoCount,
49119
50000
  aspectRatio,
@@ -49121,13 +50002,15 @@ async function experimental_generateVideo({
49121
50002
  duration: duration3,
49122
50003
  fps,
49123
50004
  seed,
49124
- image,
50005
+ image: resolvedImage,
50006
+ frameImages: normalizedFrameImages,
50007
+ inputReferences: effectiveInputReferences,
50008
+ generateAudio,
49125
50009
  providerOptions: providerOptions != null ? providerOptions : {},
49126
50010
  headers: headersWithUserAgent,
49127
50011
  abortSignal
49128
50012
  }))));
49129
50013
  const videos = [];
49130
- const warnings = [];
49131
50014
  const responses = [];
49132
50015
  const providerMetadata = {};
49133
50016
  for (const result of results) {
@@ -49215,56 +50098,49 @@ async function experimental_generateVideo({
49215
50098
  };
49216
50099
  }
49217
50100
  function normalizePrompt2(promptArg) {
49218
- var _a21, _b16;
49219
50101
  if (typeof promptArg === "string") {
49220
50102
  return {
49221
50103
  prompt: promptArg,
49222
50104
  image: undefined
49223
50105
  };
49224
50106
  }
49225
- let image;
49226
- if (promptArg.image != null) {
49227
- const dataContent = promptArg.image;
49228
- if (typeof dataContent === "string") {
49229
- if (dataContent.startsWith("http://") || dataContent.startsWith("https://")) {
49230
- image = {
49231
- type: "url",
49232
- url: dataContent
49233
- };
49234
- } else if (dataContent.startsWith("data:")) {
49235
- const { mediaType, base64Content } = splitDataUrl(dataContent);
49236
- image = {
49237
- type: "file",
49238
- mediaType: mediaType != null ? mediaType : "image/png",
49239
- data: convertBase64ToUint8Array(base64Content != null ? base64Content : "")
49240
- };
49241
- } else {
49242
- const bytes = convertBase64ToUint8Array(dataContent);
49243
- const mediaType = (_a21 = detectMediaType({
49244
- data: bytes,
49245
- signatures: imageMediaTypeSignatures
49246
- })) != null ? _a21 : "image/png";
49247
- image = {
49248
- type: "file",
49249
- mediaType,
49250
- data: bytes
49251
- };
49252
- }
49253
- } else if (dataContent instanceof Uint8Array) {
49254
- const mediaType = (_b16 = detectMediaType({
49255
- data: dataContent,
49256
- signatures: imageMediaTypeSignatures
49257
- })) != null ? _b16 : "image/png";
49258
- image = {
50107
+ return {
50108
+ prompt: promptArg.text,
50109
+ image: promptArg.image != null ? normalizeImageData(promptArg.image) : undefined
50110
+ };
50111
+ }
50112
+ function normalizeImageData(dataContent) {
50113
+ var _a222, _b16;
50114
+ if (typeof dataContent === "string") {
50115
+ if (dataContent.startsWith("http://") || dataContent.startsWith("https://")) {
50116
+ return {
50117
+ type: "url",
50118
+ url: dataContent
50119
+ };
50120
+ }
50121
+ if (dataContent.startsWith("data:")) {
50122
+ const { mediaType, base64Content } = splitDataUrl(dataContent);
50123
+ return {
49259
50124
  type: "file",
49260
- mediaType,
49261
- data: dataContent
50125
+ mediaType: mediaType != null ? mediaType : "image/png",
50126
+ data: convertBase64ToUint8Array(base64Content != null ? base64Content : "")
49262
50127
  };
49263
50128
  }
50129
+ const bytes2 = convertBase64ToUint8Array(dataContent);
50130
+ return {
50131
+ type: "file",
50132
+ mediaType: (_a222 = detectMediaType({
50133
+ data: bytes2,
50134
+ signatures: imageMediaTypeSignatures
50135
+ })) != null ? _a222 : "image/png",
50136
+ data: bytes2
50137
+ };
49264
50138
  }
50139
+ const bytes = convertDataContentToUint8Array(dataContent);
49265
50140
  return {
49266
- prompt: promptArg.text,
49267
- image
50141
+ type: "file",
50142
+ mediaType: (_b16 = detectMediaType({ data: bytes, signatures: imageMediaTypeSignatures })) != null ? _b16 : "image/png",
50143
+ data: bytes
49268
50144
  };
49269
50145
  }
49270
50146
  async function invokeModelMaxVideosPerCall(model) {
@@ -49297,8 +50173,8 @@ function defaultTransform(text22) {
49297
50173
  return text22.replace(/^```(?:json)?\s*\n?/, "").replace(/\n?```\s*$/, "").trim();
49298
50174
  }
49299
50175
  function extractJsonMiddleware(options) {
49300
- var _a21;
49301
- const transform2 = (_a21 = options == null ? undefined : options.transform) != null ? _a21 : defaultTransform;
50176
+ var _a222;
50177
+ const transform2 = (_a222 = options == null ? undefined : options.transform) != null ? _a222 : defaultTransform;
49302
50178
  const hasCustomTransform = (options == null ? undefined : options.transform) !== undefined;
49303
50179
  return {
49304
50180
  specificationVersion: "v3",
@@ -49319,7 +50195,7 @@ function extractJsonMiddleware(options) {
49319
50195
  },
49320
50196
  wrapStream: async ({ doStream }) => {
49321
50197
  const { stream, ...rest } = await doStream();
49322
- const textBlocks = {};
50198
+ const textBlocks = createIdMap();
49323
50199
  const SUFFIX_BUFFER_SIZE = 12;
49324
50200
  return {
49325
50201
  stream: stream.pipeThrough(new TransformStream({
@@ -49473,7 +50349,7 @@ function extractReasoningMiddleware({
49473
50349
  },
49474
50350
  wrapStream: async ({ doStream }) => {
49475
50351
  const { stream, ...rest } = await doStream();
49476
- const reasoningExtractions = {};
50352
+ const reasoningExtractions = createIdMap();
49477
50353
  let delayedTextStart;
49478
50354
  return {
49479
50355
  stream: stream.pipeThrough(new TransformStream({
@@ -49652,13 +50528,13 @@ function addToolInputExamplesMiddleware({
49652
50528
  return {
49653
50529
  specificationVersion: "v3",
49654
50530
  transformParams: async ({ params }) => {
49655
- var _a21;
49656
- if (!((_a21 = params.tools) == null ? undefined : _a21.length)) {
50531
+ var _a222;
50532
+ if (!((_a222 = params.tools) == null ? undefined : _a222.length)) {
49657
50533
  return params;
49658
50534
  }
49659
50535
  const transformedTools = params.tools.map((tool2) => {
49660
- var _a222;
49661
- if (tool2.type !== "function" || !((_a222 = tool2.inputExamples) == null ? undefined : _a222.length)) {
50536
+ var _a232;
50537
+ if (tool2.type !== "function" || !((_a232 = tool2.inputExamples) == null ? undefined : _a232.length)) {
49662
50538
  return tool2;
49663
50539
  }
49664
50540
  const formattedExamples = tool2.inputExamples.map((example, index) => format(example, index)).join(`
@@ -49864,7 +50740,7 @@ async function rerank({
49864
50740
  }),
49865
50741
  tracer,
49866
50742
  fn: async () => {
49867
- var _a21, _b16;
50743
+ var _a222, _b16;
49868
50744
  const { ranking, response, providerMetadata, warnings } = await retry(() => recordSpan({
49869
50745
  name: "ai.rerank.doRerank",
49870
50746
  attributes: selectTelemetryAttributes({
@@ -49923,7 +50799,7 @@ async function rerank({
49923
50799
  providerMetadata,
49924
50800
  response: {
49925
50801
  id: response == null ? undefined : response.id,
49926
- timestamp: (_a21 = response == null ? undefined : response.timestamp) != null ? _a21 : /* @__PURE__ */ new Date,
50802
+ timestamp: (_a222 = response == null ? undefined : response.timestamp) != null ? _a222 : /* @__PURE__ */ new Date,
49927
50803
  modelId: (_b16 = response == null ? undefined : response.modelId) != null ? _b16 : model.modelId,
49928
50804
  headers: response == null ? undefined : response.headers,
49929
50805
  body: response == null ? undefined : response.body
@@ -49952,16 +50828,16 @@ async function transcribe({
49952
50828
  const headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION6}`);
49953
50829
  const audioData = audio instanceof URL ? (await downloadFn({ url: audio, abortSignal })).data : convertDataContentToUint8Array(audio);
49954
50830
  const result = await retry(() => {
49955
- var _a21;
50831
+ var _a222;
49956
50832
  return resolvedModel.doGenerate({
49957
50833
  audio: audioData,
49958
50834
  abortSignal,
49959
50835
  headers: headersWithUserAgent,
49960
50836
  providerOptions,
49961
- mediaType: (_a21 = detectMediaType({
50837
+ mediaType: (_a222 = detectMediaType({
49962
50838
  data: audioData,
49963
50839
  signatures: audioMediaTypeSignatures
49964
- })) != null ? _a21 : "audio/wav"
50840
+ })) != null ? _a222 : "audio/wav"
49965
50841
  });
49966
50842
  });
49967
50843
  logWarnings({
@@ -50010,7 +50886,7 @@ async function callCompletionApi({
50010
50886
  onError,
50011
50887
  fetch: fetch2 = getOriginalFetch3()
50012
50888
  }) {
50013
- var _a21;
50889
+ var _a222;
50014
50890
  try {
50015
50891
  setLoading(true);
50016
50892
  setError(undefined);
@@ -50033,7 +50909,7 @@ async function callCompletionApi({
50033
50909
  throw err;
50034
50910
  });
50035
50911
  if (!response.ok) {
50036
- throw new Error((_a21 = await response.text()) != null ? _a21 : "Failed to fetch the chat response.");
50912
+ throw new Error((_a222 = await response.text()) != null ? _a222 : "Failed to fetch the chat response.");
50037
50913
  }
50038
50914
  if (!response.body) {
50039
50915
  throw new Error("The response body is empty.");
@@ -50108,12 +50984,12 @@ async function convertFileListToFileUIParts(files) {
50108
50984
  throw new Error("FileList is not supported in the current environment");
50109
50985
  }
50110
50986
  return Promise.all(Array.from(files).map(async (file2) => {
50111
- const { name: name21, type } = file2;
50987
+ const { name: name222, type } = file2;
50112
50988
  const dataUrl = await new Promise((resolve32, reject) => {
50113
50989
  const reader = new FileReader;
50114
50990
  reader.onload = (readerEvent) => {
50115
- var _a21;
50116
- resolve32((_a21 = readerEvent.target) == null ? undefined : _a21.result);
50991
+ var _a222;
50992
+ resolve32((_a222 = readerEvent.target) == null ? undefined : _a222.result);
50117
50993
  };
50118
50994
  reader.onerror = (error40) => reject(error40);
50119
50995
  reader.readAsDataURL(file2);
@@ -50121,7 +50997,7 @@ async function convertFileListToFileUIParts(files) {
50121
50997
  return {
50122
50998
  type: "file",
50123
50999
  mediaType: type,
50124
- filename: name21,
51000
+ filename: name222,
50125
51001
  url: dataUrl
50126
51002
  };
50127
51003
  }));
@@ -50178,9 +51054,9 @@ function transformTextToUiMessageStream({
50178
51054
  }));
50179
51055
  }
50180
51056
  var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50181
- for (var name21 in all)
50182
- __defProp2(target, name21, { get: all[name21], enumerable: true });
50183
- }, 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) => {
51057
+ for (var name222 in all)
51058
+ __defProp2(target, name222, { get: all[name222], enumerable: true });
51059
+ }, 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) => {
50184
51060
  if (options.warnings.length === 0) {
50185
51061
  return;
50186
51062
  }
@@ -50207,23 +51083,22 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50207
51083
  const bytes = typeof data === "string" ? convertBase64ToUint8Array(data) : data;
50208
51084
  const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
50209
51085
  return bytes.slice(id3Size + 10);
50210
- }, VERSION6 = "6.0.199", download = async ({
51086
+ }, VERSION6 = "6.0.219", download = async ({
50211
51087
  url: url2,
50212
51088
  maxBytes,
50213
51089
  abortSignal
50214
51090
  }) => {
50215
- var _a21;
51091
+ var _a222;
50216
51092
  const urlText = url2.toString();
50217
- validateDownloadUrl(urlText);
50218
51093
  try {
50219
- const response = await fetch(urlText, {
50220
- headers: withUserAgentSuffix({}, `ai-sdk/${VERSION6}`, getRuntimeEnvironmentUserAgent()),
50221
- signal: abortSignal
51094
+ const headers = withUserAgentSuffix({}, `ai-sdk/${VERSION6}`, getRuntimeEnvironmentUserAgent());
51095
+ const response = await fetchWithValidatedRedirects({
51096
+ url: urlText,
51097
+ headers,
51098
+ abortSignal
50222
51099
  });
50223
- if (response.redirected) {
50224
- validateDownloadUrl(response.url);
50225
- }
50226
51100
  if (!response.ok) {
51101
+ await cancelResponseBody(response);
50227
51102
  throw new DownloadError({
50228
51103
  url: urlText,
50229
51104
  statusCode: response.status,
@@ -50237,7 +51112,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50237
51112
  });
50238
51113
  return {
50239
51114
  data,
50240
- mediaType: (_a21 = response.headers.get("content-type")) != null ? _a21 : undefined
51115
+ mediaType: (_a222 = response.headers.get("content-type")) != null ? _a222 : undefined
50241
51116
  };
50242
51117
  } catch (error40) {
50243
51118
  if (DownloadError.isInstance(error40)) {
@@ -50250,11 +51125,17 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50250
51125
  initialDelayInMs = 2000,
50251
51126
  backoffFactor = 2,
50252
51127
  abortSignal
50253
- } = {}) => async (f) => _retryWithExponentialBackoff(f, {
51128
+ } = {}) => retryWithExponentialBackoff({
50254
51129
  maxRetries,
50255
- delayInMs: initialDelayInMs,
51130
+ initialDelayInMs,
50256
51131
  backoffFactor,
50257
- abortSignal
51132
+ abortSignal,
51133
+ shouldRetry: (error40) => error40 instanceof Error && (APICallError.isInstance(error40) && error40.isRetryable === true || GatewayError.isInstance(error40) && error40.isRetryable === true),
51134
+ getDelayInMs: ({ error: error40, exponentialBackoffDelay }) => getRetryDelayInMs({
51135
+ error: error40,
51136
+ exponentialBackoffDelay
51137
+ }),
51138
+ createRetryError: ({ message, reason, errors: errors4 }) => new RetryError({ message, reason, errors: errors4 })
50258
51139
  }), DefaultGeneratedFile = class {
50259
51140
  constructor({
50260
51141
  data,
@@ -50277,7 +51158,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50277
51158
  }
50278
51159
  return this.uint8ArrayData;
50279
51160
  }
50280
- }, DefaultGeneratedFileWithType, output_exports, text2 = () => ({
51161
+ }, DefaultGeneratedFileWithType, encoder, output_exports, text2 = () => ({
50281
51162
  name: "text",
50282
51163
  responseFormat: Promise.resolve({ type: "text" }),
50283
51164
  async parseCompleteOutput({ text: text22 }) {
@@ -50291,7 +51172,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50291
51172
  }
50292
51173
  }), object2 = ({
50293
51174
  schema: inputSchema,
50294
- name: name21,
51175
+ name: name222,
50295
51176
  description
50296
51177
  }) => {
50297
51178
  const schema = asSchema(inputSchema);
@@ -50300,7 +51181,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50300
51181
  responseFormat: resolve5(schema.jsonSchema).then((jsonSchema2) => ({
50301
51182
  type: "json",
50302
51183
  schema: jsonSchema2,
50303
- ...name21 != null && { name: name21 },
51184
+ ...name222 != null && { name: name222 },
50304
51185
  ...description != null && { description }
50305
51186
  })),
50306
51187
  async parseCompleteOutput({ text: text22 }, context2) {
@@ -50352,7 +51233,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50352
51233
  };
50353
51234
  }, array2 = ({
50354
51235
  element: inputElementSchema,
50355
- name: name21,
51236
+ name: name222,
50356
51237
  description
50357
51238
  }) => {
50358
51239
  const elementSchema = asSchema(inputElementSchema);
@@ -50371,7 +51252,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50371
51252
  required: ["elements"],
50372
51253
  additionalProperties: false
50373
51254
  },
50374
- ...name21 != null && { name: name21 },
51255
+ ...name222 != null && { name: name222 },
50375
51256
  ...description != null && { description }
50376
51257
  };
50377
51258
  }),
@@ -50462,7 +51343,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50462
51343
  };
50463
51344
  }, choice = ({
50464
51345
  options: choiceOptions,
50465
- name: name21,
51346
+ name: name222,
50466
51347
  description
50467
51348
  }) => {
50468
51349
  return {
@@ -50478,7 +51359,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50478
51359
  required: ["result"],
50479
51360
  additionalProperties: false
50480
51361
  },
50481
- ...name21 != null && { name: name21 },
51362
+ ...name222 != null && { name: name222 },
50482
51363
  ...description != null && { description }
50483
51364
  }),
50484
51365
  async parseCompleteOutput({ text: text22 }, context2) {
@@ -50536,14 +51417,14 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50536
51417
  }
50537
51418
  };
50538
51419
  }, json2 = ({
50539
- name: name21,
51420
+ name: name222,
50540
51421
  description
50541
51422
  } = {}) => {
50542
51423
  return {
50543
51424
  name: "json",
50544
51425
  responseFormat: Promise.resolve({
50545
51426
  type: "json",
50546
- ...name21 != null && { name: name21 },
51427
+ ...name222 != null && { name: name222 },
50547
51428
  ...description != null && { description }
50548
51429
  }),
50549
51430
  async parseCompleteOutput({ text: text22 }, context2) {
@@ -50715,7 +51596,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50715
51596
  }
50716
51597
  return this._output;
50717
51598
  }
50718
- }, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS, toolMetadataSchema, uiMessageChunkSchema, isToolOrDynamicToolUIPart, getToolOrDynamicToolName, originalGenerateId2, DefaultStreamTextResult = class {
51599
+ }, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS, toolMetadataSchema, uiMessageChunkSchema, isToolOrDynamicToolUIPart, getToolOrDynamicToolName, originalGenerateId2, isOutputChunkType, DefaultStreamTextResult = class {
50719
51600
  constructor({
50720
51601
  model,
50721
51602
  telemetry,
@@ -50756,6 +51637,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50756
51637
  onToolCallStart,
50757
51638
  onToolCallFinish,
50758
51639
  experimental_context,
51640
+ experimental_toolApprovalSecret,
50759
51641
  download: download2,
50760
51642
  include
50761
51643
  }) {
@@ -50777,20 +51659,25 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50777
51659
  let recordedRequest = {};
50778
51660
  let recordedWarnings = [];
50779
51661
  const recordedSteps = [];
51662
+ let recordedNoOutputError;
50780
51663
  const pendingDeferredToolCalls = /* @__PURE__ */ new Map;
50781
51664
  let rootSpan;
50782
- let activeTextContent = {};
50783
- let activeReasoningContent = {};
51665
+ let activeTextContent = createIdMap();
51666
+ let activeReasoningContent = createIdMap();
50784
51667
  const eventProcessor = new TransformStream({
50785
51668
  async transform(chunk, controller) {
50786
- var _a21, _b16, _c, _d;
51669
+ var _a222, _b16, _c, _d;
50787
51670
  controller.enqueue(chunk);
50788
51671
  const { part } = chunk;
50789
51672
  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") {
50790
51673
  await (onChunk == null ? undefined : onChunk({ chunk: part }));
50791
51674
  }
50792
51675
  if (part.type === "error") {
50793
- await onError({ error: wrapGatewayError(part.error) });
51676
+ const error40 = wrapGatewayError(part.error);
51677
+ if (NoOutputGeneratedError.isInstance(error40)) {
51678
+ recordedNoOutputError = error40;
51679
+ }
51680
+ await onError({ error: error40 });
50794
51681
  }
50795
51682
  if (part.type === "text-start") {
50796
51683
  activeTextContent[part.id] = {
@@ -50813,7 +51700,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50813
51700
  return;
50814
51701
  }
50815
51702
  activeText.text += part.text;
50816
- activeText.providerMetadata = (_a21 = part.providerMetadata) != null ? _a21 : activeText.providerMetadata;
51703
+ activeText.providerMetadata = (_a222 = part.providerMetadata) != null ? _a222 : activeText.providerMetadata;
50817
51704
  }
50818
51705
  if (part.type === "text-end") {
50819
51706
  const activeText = activeTextContent[part.id];
@@ -50892,8 +51779,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50892
51779
  }
50893
51780
  if (part.type === "start-step") {
50894
51781
  recordedContent = [];
50895
- activeReasoningContent = {};
50896
- activeTextContent = {};
51782
+ activeReasoningContent = createIdMap();
51783
+ activeTextContent = createIdMap();
50897
51784
  recordedRequest = part.request;
50898
51785
  recordedWarnings = part.warnings;
50899
51786
  }
@@ -50939,10 +51826,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50939
51826
  }
50940
51827
  },
50941
51828
  async flush(controller) {
50942
- var _a21, _b16, _c, _d, _e, _f, _g;
51829
+ var _a222, _b16, _c, _d, _e, _f, _g;
50943
51830
  try {
50944
- if (recordedSteps.length === 0) {
50945
- const error40 = (abortSignal == null ? undefined : abortSignal.aborted) ? abortSignal.reason : new NoOutputGeneratedError({
51831
+ if (recordedSteps.length === 0 || recordedNoOutputError != null) {
51832
+ const error40 = (abortSignal == null ? undefined : abortSignal.aborted) ? abortSignal.reason : recordedNoOutputError != null ? recordedNoOutputError : new NoOutputGeneratedError({
50946
51833
  message: "No output generated. Check the stream for errors."
50947
51834
  });
50948
51835
  self2._finishReason.reject(error40);
@@ -51002,13 +51889,13 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51002
51889
  },
51003
51890
  "ai.response.toolCalls": {
51004
51891
  output: () => {
51005
- var _a222;
51006
- return ((_a222 = finalStep.toolCalls) == null ? undefined : _a222.length) ? JSON.stringify(finalStep.toolCalls) : undefined;
51892
+ var _a232;
51893
+ return ((_a232 = finalStep.toolCalls) == null ? undefined : _a232.length) ? JSON.stringify(finalStep.toolCalls) : undefined;
51007
51894
  }
51008
51895
  },
51009
51896
  "ai.response.providerMetadata": JSON.stringify(finalStep.providerMetadata),
51010
51897
  "ai.usage.inputTokens": totalUsage.inputTokens,
51011
- "ai.usage.inputTokenDetails.noCacheTokens": (_a21 = totalUsage.inputTokenDetails) == null ? undefined : _a21.noCacheTokens,
51898
+ "ai.usage.inputTokenDetails.noCacheTokens": (_a222 = totalUsage.inputTokenDetails) == null ? undefined : _a222.noCacheTokens,
51012
51899
  "ai.usage.inputTokenDetails.cacheReadTokens": (_b16 = totalUsage.inputTokenDetails) == null ? undefined : _b16.cacheReadTokens,
51013
51900
  "ai.usage.inputTokenDetails.cacheWriteTokens": (_c = totalUsage.inputTokenDetails) == null ? undefined : _c.cacheWriteTokens,
51014
51901
  "ai.usage.outputTokens": totalUsage.outputTokens,
@@ -51152,8 +52039,20 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51152
52039
  const initialResponseMessages = [];
51153
52040
  const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
51154
52041
  if (deniedToolApprovals.length > 0 || approvedToolApprovals.length > 0) {
51155
- const localApprovedToolApprovals = approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted);
51156
- const localDeniedToolApprovals = deniedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted);
52042
+ const {
52043
+ approvedToolApprovals: localApprovedToolApprovals,
52044
+ deniedToolApprovals: revalidationDeniedToolApprovals
52045
+ } = await validateApprovedToolApprovals({
52046
+ approvedToolApprovals: approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted),
52047
+ tools,
52048
+ messages: initialMessages,
52049
+ experimental_context,
52050
+ toolApprovalSecret: experimental_toolApprovalSecret
52051
+ });
52052
+ const localDeniedToolApprovals = [
52053
+ ...deniedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted),
52054
+ ...revalidationDeniedToolApprovals
52055
+ ];
51157
52056
  const deniedProviderExecutedToolApprovals = deniedToolApprovals.filter((toolApproval) => toolApproval.toolCall.providerExecuted);
51158
52057
  let toolExecutionStepStreamController;
51159
52058
  const toolExecutionStepStream = new ReadableStream({
@@ -51244,7 +52143,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51244
52143
  responseMessages,
51245
52144
  usage
51246
52145
  }) {
51247
- var _a21, _b16, _c, _d, _e, _f, _g, _h, _i;
52146
+ var _a222, _b16, _c, _d, _e, _f, _g, _h, _i;
51248
52147
  const includeRawChunks2 = self2.includeRawChunks;
51249
52148
  const stepTimeoutId = stepTimeoutMs != null ? setTimeout(() => stepAbortController.abort(), stepTimeoutMs) : undefined;
51250
52149
  let chunkTimeoutId = undefined;
@@ -51277,7 +52176,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51277
52176
  messages: stepInputMessages,
51278
52177
  experimental_context
51279
52178
  }));
51280
- const stepModel = resolveLanguageModel((_a21 = prepareStepResult == null ? undefined : prepareStepResult.model) != null ? _a21 : model);
52179
+ const stepModel = resolveLanguageModel((_a222 = prepareStepResult == null ? undefined : prepareStepResult.model) != null ? _a222 : model);
51281
52180
  const stepModelInfo = {
51282
52181
  provider: stepModel.provider,
51283
52182
  modelId: stepModel.modelId
@@ -51389,6 +52288,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51389
52288
  repairToolCall,
51390
52289
  abortSignal,
51391
52290
  experimental_context,
52291
+ toolApprovalSecret: experimental_toolApprovalSecret,
51392
52292
  generateId: generateId22,
51393
52293
  stepNumber: recordedSteps.length,
51394
52294
  model: stepModelInfo,
@@ -51408,6 +52308,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51408
52308
  const activeToolCallToolNames = {};
51409
52309
  let stepFinishReason = "other";
51410
52310
  let stepRawFinishReason = undefined;
52311
+ let hasReceivedTerminalChunk = false;
52312
+ let hasReceivedOutputChunk = false;
51411
52313
  let stepUsage = createNullLanguageModelUsage();
51412
52314
  let stepProviderMetadata;
51413
52315
  let stepFirstChunk = true;
@@ -51419,7 +52321,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51419
52321
  let activeText = "";
51420
52322
  self2.addStream(streamWithToolResults.pipeThrough(new TransformStream({
51421
52323
  async transform(chunk, controller) {
51422
- var _a222, _b23, _c2, _d2, _e2;
52324
+ var _a232, _b23, _c2, _d2, _e2;
51423
52325
  resetChunkTimeout();
51424
52326
  if (chunk.type === "stream-start") {
51425
52327
  warnings = chunk.warnings;
@@ -51441,6 +52343,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51441
52343
  });
51442
52344
  }
51443
52345
  const chunkType = chunk.type;
52346
+ if (isOutputChunkType[chunkType]) {
52347
+ hasReceivedOutputChunk = true;
52348
+ }
51444
52349
  switch (chunkType) {
51445
52350
  case "tool-approval-request":
51446
52351
  case "text-start":
@@ -51493,13 +52398,14 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51493
52398
  }
51494
52399
  case "response-metadata": {
51495
52400
  stepResponse = {
51496
- id: (_a222 = chunk.id) != null ? _a222 : stepResponse.id,
52401
+ id: (_a232 = chunk.id) != null ? _a232 : stepResponse.id,
51497
52402
  timestamp: (_b23 = chunk.timestamp) != null ? _b23 : stepResponse.timestamp,
51498
52403
  modelId: (_c2 = chunk.modelId) != null ? _c2 : stepResponse.modelId
51499
52404
  };
51500
52405
  break;
51501
52406
  }
51502
52407
  case "finish": {
52408
+ hasReceivedTerminalChunk = true;
51503
52409
  stepUsage = chunk.usage;
51504
52410
  stepFinishReason = chunk.finishReason;
51505
52411
  stepRawFinishReason = chunk.rawFinishReason;
@@ -51559,6 +52465,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51559
52465
  break;
51560
52466
  }
51561
52467
  case "error": {
52468
+ hasReceivedTerminalChunk = true;
51562
52469
  controller.enqueue(chunk);
51563
52470
  stepFinishReason = "error";
51564
52471
  break;
@@ -51576,7 +52483,20 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51576
52483
  }
51577
52484
  },
51578
52485
  async flush(controller) {
51579
- var _a222, _b23, _c2, _d2, _e2, _f2, _g2;
52486
+ var _a232, _b23, _c2, _d2, _e2, _f2, _g2;
52487
+ if (!hasReceivedTerminalChunk && !hasReceivedOutputChunk) {
52488
+ controller.enqueue({
52489
+ type: "error",
52490
+ error: new NoOutputGeneratedError({
52491
+ message: "No output generated. The model stream ended without a finish chunk."
52492
+ })
52493
+ });
52494
+ doStreamSpan.end();
52495
+ clearStepTimeout();
52496
+ clearChunkTimeout();
52497
+ self2.closeStream();
52498
+ return;
52499
+ }
51580
52500
  const stepToolCallsJson = stepToolCalls.length > 0 ? JSON.stringify(stepToolCalls) : undefined;
51581
52501
  try {
51582
52502
  doStreamSpan.setAttributes(await selectTelemetryAttributes({
@@ -51590,7 +52510,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51590
52510
  "ai.response.model": stepResponse.modelId,
51591
52511
  "ai.response.timestamp": stepResponse.timestamp.toISOString(),
51592
52512
  "ai.usage.inputTokens": stepUsage.inputTokens,
51593
- "ai.usage.inputTokenDetails.noCacheTokens": (_a222 = stepUsage.inputTokenDetails) == null ? undefined : _a222.noCacheTokens,
52513
+ "ai.usage.inputTokenDetails.noCacheTokens": (_a232 = stepUsage.inputTokenDetails) == null ? undefined : _a232.noCacheTokens,
51594
52514
  "ai.usage.inputTokenDetails.cacheReadTokens": (_b23 = stepUsage.inputTokenDetails) == null ? undefined : _b23.cacheReadTokens,
51595
52515
  "ai.usage.inputTokenDetails.cacheWriteTokens": (_c2 = stepUsage.inputTokenDetails) == null ? undefined : _c2.cacheWriteTokens,
51596
52516
  "ai.usage.outputTokens": stepUsage.outputTokens,
@@ -51805,15 +52725,30 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51805
52725
  }
51806
52726
  })));
51807
52727
  }
52728
+ rejectResultPromises(error40) {
52729
+ if (this._finishReason.isPending())
52730
+ this._finishReason.reject(error40);
52731
+ if (this._rawFinishReason.isPending())
52732
+ this._rawFinishReason.reject(error40);
52733
+ if (this._totalUsage.isPending())
52734
+ this._totalUsage.reject(error40);
52735
+ if (this._steps.isPending())
52736
+ this._steps.reject(error40);
52737
+ }
51808
52738
  async consumeStream(options) {
51809
- var _a21;
52739
+ var _a222;
51810
52740
  try {
51811
52741
  await consumeStream({
51812
52742
  stream: this.fullStream,
51813
- onError: options == null ? undefined : options.onError
52743
+ onError: (error40) => {
52744
+ var _a232;
52745
+ this.rejectResultPromises(error40);
52746
+ (_a232 = options == null ? undefined : options.onError) == null || _a232.call(options, error40);
52747
+ }
51814
52748
  });
51815
52749
  } catch (error40) {
51816
- (_a21 = options == null ? undefined : options.onError) == null || _a21.call(options, error40);
52750
+ this.rejectResultPromises(error40);
52751
+ (_a222 = options == null ? undefined : options.onError) == null || _a222.call(options, error40);
51817
52752
  }
51818
52753
  }
51819
52754
  get experimental_partialOutputStream() {
@@ -51829,8 +52764,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51829
52764
  })));
51830
52765
  }
51831
52766
  get elementStream() {
51832
- var _a21, _b16, _c;
51833
- const transform2 = (_a21 = this.outputSpecification) == null ? undefined : _a21.createElementStreamTransform();
52767
+ var _a222, _b16, _c;
52768
+ const transform2 = (_a222 = this.outputSpecification) == null ? undefined : _a222.createElementStreamTransform();
51834
52769
  if (transform2 == null) {
51835
52770
  throw new UnsupportedFunctionalityError({
51836
52771
  functionality: `element streams in ${(_c = (_b16 = this.outputSpecification) == null ? undefined : _b16.name) != null ? _c : "text"} mode`
@@ -51840,8 +52775,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51840
52775
  }
51841
52776
  get output() {
51842
52777
  return this.finalStep.then((step) => {
51843
- var _a21;
51844
- const output = (_a21 = this.outputSpecification) != null ? _a21 : text2();
52778
+ var _a222;
52779
+ const output = (_a222 = this.outputSpecification) != null ? _a222 : text2();
51845
52780
  return output.parseCompleteOutput({ text: step.text }, {
51846
52781
  response: step.response,
51847
52782
  usage: step.usage,
@@ -51858,15 +52793,15 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
51858
52793
  sendSources = false,
51859
52794
  sendStart = true,
51860
52795
  sendFinish = true,
51861
- onError = getErrorMessage
52796
+ onError = () => "An error occurred."
51862
52797
  } = {}) {
51863
52798
  const responseMessageId = generateMessageId != null ? getResponseUIMessageId({
51864
52799
  originalMessages,
51865
52800
  responseMessageId: generateMessageId
51866
52801
  }) : undefined;
51867
52802
  const isDynamic = (part) => {
51868
- var _a21;
51869
- const tool2 = (_a21 = this.tools) == null ? undefined : _a21[part.toolName];
52803
+ var _a222;
52804
+ const tool2 = (_a222 = this.tools) == null ? undefined : _a222[part.toolName];
51870
52805
  if (tool2 == null) {
51871
52806
  return part.dynamic;
51872
52807
  }
@@ -52011,7 +52946,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
52011
52946
  controller.enqueue({
52012
52947
  type: "tool-approval-request",
52013
52948
  approvalId: part.approvalId,
52014
- toolCallId: part.toolCall.toolCallId
52949
+ toolCallId: part.toolCall.toolCallId,
52950
+ ...part.signature != null ? { signature: part.signature } : {}
52015
52951
  });
52016
52952
  break;
52017
52953
  }
@@ -52020,7 +52956,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
52020
52956
  controller.enqueue({
52021
52957
  type: "tool-output-available",
52022
52958
  toolCallId: part.toolCallId,
52023
- output: part.output,
52959
+ output: part.output === undefined ? null : part.output,
52024
52960
  ...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
52025
52961
  ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
52026
52962
  ...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
@@ -52195,7 +53131,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
52195
53131
  return this.settings.tools;
52196
53132
  }
52197
53133
  async prepareCall(options) {
52198
- var _a21, _b16, _c, _d;
53134
+ var _a222, _b16, _c, _d;
52199
53135
  if (this.settings.callOptionsSchema != null && options.options !== undefined) {
52200
53136
  const validatedOptions = await validateTypes({
52201
53137
  value: options.options,
@@ -52207,7 +53143,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
52207
53143
  const { onStepFinish: _settingsOnStepFinish, ...settingsWithoutCallback } = this.settings;
52208
53144
  const baseCallArgs = {
52209
53145
  ...settingsWithoutCallback,
52210
- stopWhen: (_a21 = this.settings.stopWhen) != null ? _a21 : stepCountIs(20),
53146
+ stopWhen: (_a222 = this.settings.stopWhen) != null ? _a222 : stepCountIs(20),
52211
53147
  ...options
52212
53148
  };
52213
53149
  const preparedCallArgs = (_d = await ((_c = (_b16 = this.settings).prepareCall) == null ? undefined : _c.call(_b16, baseCallArgs))) != null ? _d : baseCallArgs;
@@ -52336,7 +53272,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
52336
53272
  isFirstDelta,
52337
53273
  isFinalDelta
52338
53274
  }) {
52339
- var _a21;
53275
+ var _a222;
52340
53276
  if (!isJSONObject(value) || !isJSONArray(value.elements)) {
52341
53277
  return {
52342
53278
  success: false,
@@ -52359,7 +53295,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
52359
53295
  }
52360
53296
  resultArray.push(result.value);
52361
53297
  }
52362
- const publishedElementCount = (_a21 = latestObject == null ? undefined : latestObject.length) != null ? _a21 : 0;
53298
+ const publishedElementCount = (_a222 = latestObject == null ? undefined : latestObject.length) != null ? _a222 : 0;
52363
53299
  let textDelta = "";
52364
53300
  if (isFirstDelta) {
52365
53301
  textDelta += "[";
@@ -52390,13 +53326,15 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
52390
53326
  };
52391
53327
  }
52392
53328
  const inputArray = value.elements;
53329
+ const resultArray = [];
52393
53330
  for (const element of inputArray) {
52394
53331
  const result = await safeValidateTypes({ value: element, schema });
52395
53332
  if (!result.success) {
52396
53333
  return result;
52397
53334
  }
53335
+ resultArray.push(result.value);
52398
53336
  }
52399
- return { success: true, value: inputArray };
53337
+ return { success: true, value: resultArray };
52400
53338
  },
52401
53339
  createElementStream(originalStream) {
52402
53340
  let publishedElements = 0;
@@ -52501,9 +53439,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
52501
53439
  this.reasoning = options.reasoning;
52502
53440
  }
52503
53441
  toJsonResponse(init) {
52504
- var _a21;
53442
+ var _a222;
52505
53443
  return new Response(JSON.stringify(this.object), {
52506
- status: (_a21 = init == null ? undefined : init.status) != null ? _a21 : 200,
53444
+ status: (_a222 = init == null ? undefined : init.status) != null ? _a222 : 200,
52507
53445
  headers: prepareHeaders(init == null ? undefined : init.headers, {
52508
53446
  "content-type": "application/json; charset=utf-8"
52509
53447
  })
@@ -52711,7 +53649,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
52711
53649
  let isFirstDelta = true;
52712
53650
  const transformedStream = stream.pipeThrough(new TransformStream(transformer)).pipeThrough(new TransformStream({
52713
53651
  async transform(chunk, controller) {
52714
- var _a21, _b16, _c;
53652
+ var _a222, _b16, _c;
52715
53653
  if (typeof chunk === "object" && chunk.type === "stream-start") {
52716
53654
  warnings = chunk.warnings;
52717
53655
  return;
@@ -52758,7 +53696,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
52758
53696
  switch (chunk.type) {
52759
53697
  case "response-metadata": {
52760
53698
  fullResponse = {
52761
- id: (_a21 = chunk.id) != null ? _a21 : fullResponse.id,
53699
+ id: (_a222 = chunk.id) != null ? _a222 : fullResponse.id,
52762
53700
  timestamp: (_b16 = chunk.timestamp) != null ? _b16 : fullResponse.timestamp,
52763
53701
  modelId: (_c = chunk.modelId) != null ? _c : fullResponse.modelId
52764
53702
  };
@@ -52966,11 +53904,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
52966
53904
  }
52967
53905
  }, DefaultGeneratedAudioFile, DefaultSpeechResult = class {
52968
53906
  constructor(options) {
52969
- var _a21;
53907
+ var _a222;
52970
53908
  this.audio = options.audio;
52971
53909
  this.warnings = options.warnings;
52972
53910
  this.responses = options.responses;
52973
- this.providerMetadata = (_a21 = options.providerMetadata) != null ? _a21 : {};
53911
+ this.providerMetadata = (_a222 = options.providerMetadata) != null ? _a222 : {};
52974
53912
  }
52975
53913
  }, CHUNKING_REGEXPS, defaultDownload, wrapLanguageModel = ({
52976
53914
  model,
@@ -52994,7 +53932,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
52994
53932
  modelId,
52995
53933
  providerId
52996
53934
  }) => {
52997
- var _a21, _b16, _c;
53935
+ var _a222, _b16, _c;
52998
53936
  async function doTransform({
52999
53937
  params,
53000
53938
  type
@@ -53003,7 +53941,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53003
53941
  }
53004
53942
  return {
53005
53943
  specificationVersion: "v3",
53006
- provider: (_a21 = providerId != null ? providerId : overrideProvider == null ? undefined : overrideProvider({ model })) != null ? _a21 : model.provider,
53944
+ provider: (_a222 = providerId != null ? providerId : overrideProvider == null ? undefined : overrideProvider({ model })) != null ? _a222 : model.provider,
53007
53945
  modelId: (_b16 = modelId != null ? modelId : overrideModelId == null ? undefined : overrideModelId({ model })) != null ? _b16 : model.modelId,
53008
53946
  supportedUrls: (_c = overrideSupportedUrls == null ? undefined : overrideSupportedUrls({ model })) != null ? _c : model.supportedUrls,
53009
53947
  async doGenerate(params) {
@@ -53046,7 +53984,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53046
53984
  modelId,
53047
53985
  providerId
53048
53986
  }) => {
53049
- var _a21, _b16, _c, _d;
53987
+ var _a222, _b16, _c, _d;
53050
53988
  async function doTransform({
53051
53989
  params
53052
53990
  }) {
@@ -53054,7 +53992,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53054
53992
  }
53055
53993
  return {
53056
53994
  specificationVersion: "v3",
53057
- provider: (_a21 = providerId != null ? providerId : overrideProvider == null ? undefined : overrideProvider({ model })) != null ? _a21 : model.provider,
53995
+ provider: (_a222 = providerId != null ? providerId : overrideProvider == null ? undefined : overrideProvider({ model })) != null ? _a222 : model.provider,
53058
53996
  modelId: (_b16 = modelId != null ? modelId : overrideModelId == null ? undefined : overrideModelId({ model })) != null ? _b16 : model.modelId,
53059
53997
  maxEmbeddingsPerCall: (_c = overrideMaxEmbeddingsPerCall == null ? undefined : overrideMaxEmbeddingsPerCall({ model })) != null ? _c : model.maxEmbeddingsPerCall,
53060
53998
  supportsParallelCalls: (_d = overrideSupportsParallelCalls == null ? undefined : overrideSupportsParallelCalls({ model })) != null ? _d : model.supportsParallelCalls,
@@ -53089,11 +54027,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53089
54027
  modelId,
53090
54028
  providerId
53091
54029
  }) => {
53092
- var _a21, _b16, _c;
54030
+ var _a222, _b16, _c;
53093
54031
  async function doTransform({ params }) {
53094
54032
  return transformParams ? await transformParams({ params, model }) : params;
53095
54033
  }
53096
- const maxImagesPerCallRaw = (_a21 = overrideMaxImagesPerCall == null ? undefined : overrideMaxImagesPerCall({ model })) != null ? _a21 : model.maxImagesPerCall;
54034
+ const maxImagesPerCallRaw = (_a222 = overrideMaxImagesPerCall == null ? undefined : overrideMaxImagesPerCall({ model })) != null ? _a222 : model.maxImagesPerCall;
53097
54035
  const maxImagesPerCall = maxImagesPerCallRaw instanceof Function ? maxImagesPerCallRaw.bind(model) : maxImagesPerCallRaw;
53098
54036
  return {
53099
54037
  specificationVersion: "v3",
@@ -53110,7 +54048,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53110
54048
  }) : doGenerate();
53111
54049
  }
53112
54050
  };
53113
- }, experimental_customProvider, name20 = "AI_NoSuchProviderError", marker20, symbol20, _a20, NoSuchProviderError, experimental_createProviderRegistry, DefaultProviderRegistry = class {
54051
+ }, experimental_customProvider, name21 = "AI_NoSuchProviderError", marker21, symbol21, _a21, NoSuchProviderError, experimental_createProviderRegistry, DefaultProviderRegistry = class {
53114
54052
  constructor({
53115
54053
  separator,
53116
54054
  languageModelMiddleware,
@@ -53151,9 +54089,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53151
54089
  return [id.slice(0, index), id.slice(index + this.separator.length)];
53152
54090
  }
53153
54091
  languageModel(id) {
53154
- var _a21, _b16;
54092
+ var _a222, _b16;
53155
54093
  const [providerId, modelId] = this.splitId(id, "languageModel");
53156
- let model = (_b16 = (_a21 = this.getProvider(providerId, "languageModel")).languageModel) == null ? undefined : _b16.call(_a21, modelId);
54094
+ let model = (_b16 = (_a222 = this.getProvider(providerId, "languageModel")).languageModel) == null ? undefined : _b16.call(_a222, modelId);
53157
54095
  if (model == null) {
53158
54096
  throw new NoSuchModelError({ modelId: id, modelType: "languageModel" });
53159
54097
  }
@@ -53166,10 +54104,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53166
54104
  return model;
53167
54105
  }
53168
54106
  embeddingModel(id) {
53169
- var _a21;
54107
+ var _a222;
53170
54108
  const [providerId, modelId] = this.splitId(id, "embeddingModel");
53171
54109
  const provider = this.getProvider(providerId, "embeddingModel");
53172
- const model = (_a21 = provider.embeddingModel) == null ? undefined : _a21.call(provider, modelId);
54110
+ const model = (_a222 = provider.embeddingModel) == null ? undefined : _a222.call(provider, modelId);
53173
54111
  if (model == null) {
53174
54112
  throw new NoSuchModelError({
53175
54113
  modelId: id,
@@ -53179,10 +54117,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53179
54117
  return model;
53180
54118
  }
53181
54119
  imageModel(id) {
53182
- var _a21;
54120
+ var _a222;
53183
54121
  const [providerId, modelId] = this.splitId(id, "imageModel");
53184
54122
  const provider = this.getProvider(providerId, "imageModel");
53185
- let model = (_a21 = provider.imageModel) == null ? undefined : _a21.call(provider, modelId);
54123
+ let model = (_a222 = provider.imageModel) == null ? undefined : _a222.call(provider, modelId);
53186
54124
  if (model == null) {
53187
54125
  throw new NoSuchModelError({ modelId: id, modelType: "imageModel" });
53188
54126
  }
@@ -53195,10 +54133,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53195
54133
  return model;
53196
54134
  }
53197
54135
  transcriptionModel(id) {
53198
- var _a21;
54136
+ var _a222;
53199
54137
  const [providerId, modelId] = this.splitId(id, "transcriptionModel");
53200
54138
  const provider = this.getProvider(providerId, "transcriptionModel");
53201
- const model = (_a21 = provider.transcriptionModel) == null ? undefined : _a21.call(provider, modelId);
54139
+ const model = (_a222 = provider.transcriptionModel) == null ? undefined : _a222.call(provider, modelId);
53202
54140
  if (model == null) {
53203
54141
  throw new NoSuchModelError({
53204
54142
  modelId: id,
@@ -53208,20 +54146,20 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53208
54146
  return model;
53209
54147
  }
53210
54148
  speechModel(id) {
53211
- var _a21;
54149
+ var _a222;
53212
54150
  const [providerId, modelId] = this.splitId(id, "speechModel");
53213
54151
  const provider = this.getProvider(providerId, "speechModel");
53214
- const model = (_a21 = provider.speechModel) == null ? undefined : _a21.call(provider, modelId);
54152
+ const model = (_a222 = provider.speechModel) == null ? undefined : _a222.call(provider, modelId);
53215
54153
  if (model == null) {
53216
54154
  throw new NoSuchModelError({ modelId: id, modelType: "speechModel" });
53217
54155
  }
53218
54156
  return model;
53219
54157
  }
53220
54158
  rerankingModel(id) {
53221
- var _a21;
54159
+ var _a222;
53222
54160
  const [providerId, modelId] = this.splitId(id, "rerankingModel");
53223
54161
  const provider = this.getProvider(providerId, "rerankingModel");
53224
- const model = (_a21 = provider.rerankingModel) == null ? undefined : _a21.call(provider, modelId);
54162
+ const model = (_a222 = provider.rerankingModel) == null ? undefined : _a222.call(provider, modelId);
53225
54163
  if (model == null) {
53226
54164
  throw new NoSuchModelError({ modelId: id, modelType: "rerankingModel" });
53227
54165
  }
@@ -53239,14 +54177,14 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53239
54177
  }
53240
54178
  }, defaultDownload2, DefaultTranscriptionResult = class {
53241
54179
  constructor(options) {
53242
- var _a21;
54180
+ var _a222;
53243
54181
  this.text = options.text;
53244
54182
  this.segments = options.segments;
53245
54183
  this.language = options.language;
53246
54184
  this.durationInSeconds = options.durationInSeconds;
53247
54185
  this.warnings = options.warnings;
53248
54186
  this.responses = options.responses;
53249
- this.providerMetadata = (_a21 = options.providerMetadata) != null ? _a21 : {};
54187
+ this.providerMetadata = (_a222 = options.providerMetadata) != null ? _a222 : {};
53250
54188
  }
53251
54189
  }, getOriginalFetch3 = () => fetch, HttpChatTransport = class {
53252
54190
  constructor({
@@ -53270,7 +54208,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53270
54208
  abortSignal,
53271
54209
  ...options
53272
54210
  }) {
53273
- var _a21, _b16, _c, _d, _e;
54211
+ var _a222, _b16, _c, _d, _e;
53274
54212
  const resolvedBody = await resolve5(this.body);
53275
54213
  const resolvedHeaders = await resolve5(this.headers);
53276
54214
  const resolvedCredentials = await resolve5(this.credentials);
@@ -53278,7 +54216,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53278
54216
  ...normalizeHeaders(resolvedHeaders),
53279
54217
  ...normalizeHeaders(options.headers)
53280
54218
  };
53281
- const preparedRequest = await ((_a21 = this.prepareSendMessagesRequest) == null ? undefined : _a21.call(this, {
54219
+ const preparedRequest = await ((_a222 = this.prepareSendMessagesRequest) == null ? undefined : _a222.call(this, {
53282
54220
  api: this.api,
53283
54221
  id: options.chatId,
53284
54222
  messages: options.messages,
@@ -53320,7 +54258,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53320
54258
  return this.processResponseStream(response.body);
53321
54259
  }
53322
54260
  async reconnectToStream(options) {
53323
- var _a21, _b16, _c, _d, _e;
54261
+ var _a222, _b16, _c, _d, _e;
53324
54262
  const resolvedBody = await resolve5(this.body);
53325
54263
  const resolvedHeaders = await resolve5(this.headers);
53326
54264
  const resolvedCredentials = await resolve5(this.credentials);
@@ -53328,7 +54266,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53328
54266
  ...normalizeHeaders(resolvedHeaders),
53329
54267
  ...normalizeHeaders(options.headers)
53330
54268
  };
53331
- const preparedRequest = await ((_a21 = this.prepareReconnectToStreamRequest) == null ? undefined : _a21.call(this, {
54269
+ const preparedRequest = await ((_a222 = this.prepareReconnectToStreamRequest) == null ? undefined : _a222.call(this, {
53332
54270
  api: this.api,
53333
54271
  id: options.chatId,
53334
54272
  body: { ...resolvedBody, ...options.body },
@@ -53373,11 +54311,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53373
54311
  this.activeResponse = undefined;
53374
54312
  this.jobExecutor = new SerialJobExecutor;
53375
54313
  this.sendMessage = async (message, options) => {
53376
- var _a21, _b16, _c, _d;
54314
+ var _a222, _b16, _c, _d;
53377
54315
  if (message == null) {
53378
54316
  await this.makeRequest({
53379
54317
  trigger: "submit-message",
53380
- messageId: (_a21 = this.lastMessage) == null ? undefined : _a21.id,
54318
+ messageId: (_a222 = this.lastMessage) == null ? undefined : _a222.id,
53381
54319
  ...options
53382
54320
  });
53383
54321
  return;
@@ -53469,11 +54407,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53469
54407
  }
53470
54408
  if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
53471
54409
  this.shouldSendAutomatically().then((shouldSend) => {
53472
- var _a21;
54410
+ var _a222;
53473
54411
  if (shouldSend) {
53474
54412
  this.makeRequest({
53475
54413
  trigger: "submit-message",
53476
- messageId: (_a21 = this.lastMessage) == null ? undefined : _a21.id,
54414
+ messageId: (_a222 = this.lastMessage) == null ? undefined : _a222.id,
53477
54415
  ...options
53478
54416
  });
53479
54417
  }
@@ -53499,11 +54437,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53499
54437
  }
53500
54438
  if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
53501
54439
  this.shouldSendAutomatically().then((shouldSend) => {
53502
- var _a21;
54440
+ var _a222;
53503
54441
  if (shouldSend) {
53504
54442
  this.makeRequest({
53505
54443
  trigger: "submit-message",
53506
- messageId: (_a21 = this.lastMessage) == null ? undefined : _a21.id,
54444
+ messageId: (_a222 = this.lastMessage) == null ? undefined : _a222.id,
53507
54445
  ...options
53508
54446
  });
53509
54447
  }
@@ -53512,10 +54450,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53512
54450
  });
53513
54451
  this.addToolResult = this.addToolOutput;
53514
54452
  this.stop = async () => {
53515
- var _a21;
54453
+ var _a222;
53516
54454
  if (this.status !== "streaming" && this.status !== "submitted")
53517
54455
  return;
53518
- if ((_a21 = this.activeResponse) == null ? undefined : _a21.abortController) {
54456
+ if ((_a222 = this.activeResponse) == null ? undefined : _a222.abortController) {
53519
54457
  this.activeResponse.abortController.abort();
53520
54458
  }
53521
54459
  };
@@ -53573,7 +54511,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53573
54511
  body,
53574
54512
  messageId
53575
54513
  }) {
53576
- var _a21, _b16, _c;
54514
+ var _a222, _b16, _c;
53577
54515
  let resumeStream;
53578
54516
  if (trigger === "resume-stream") {
53579
54517
  try {
@@ -53630,9 +54568,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53630
54568
  const runUpdateMessageJob = (job) => this.jobExecutor.run(() => job({
53631
54569
  state: activeResponse.state,
53632
54570
  write: () => {
53633
- var _a222;
54571
+ var _a232;
53634
54572
  this.setStatus({ status: "streaming" });
53635
- const replaceLastMessage = activeResponse.state.message.id === ((_a222 = this.lastMessage) == null ? undefined : _a222.id);
54573
+ const replaceLastMessage = activeResponse.state.message.id === ((_a232 = this.lastMessage) == null ? undefined : _a232.id);
53636
54574
  if (replaceLastMessage) {
53637
54575
  this.state.replaceMessage(this.state.messages.length - 1, activeResponse.state.message);
53638
54576
  } else {
@@ -53679,7 +54617,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
53679
54617
  isAbort,
53680
54618
  isDisconnect,
53681
54619
  isError,
53682
- finishReason: (_a21 = this.activeResponse) == null ? undefined : _a21.state.finishReason
54620
+ finishReason: (_a222 = this.activeResponse) == null ? undefined : _a222.state.finishReason
53683
54621
  });
53684
54622
  } catch (err) {
53685
54623
  console.error(err);
@@ -53753,6 +54691,7 @@ var init_dist8 = __esm(() => {
53753
54691
  init_dist();
53754
54692
  init_dist();
53755
54693
  init_dist();
54694
+ init_dist();
53756
54695
  init_dist3();
53757
54696
  init_dist();
53758
54697
  init_dist7();
@@ -53778,6 +54717,8 @@ var init_dist8 = __esm(() => {
53778
54717
  init_dist3();
53779
54718
  init_dist3();
53780
54719
  init_dist3();
54720
+ init_dist3();
54721
+ init_dist3();
53781
54722
  init_dist();
53782
54723
  init_dist3();
53783
54724
  init_dist3();
@@ -53873,6 +54814,27 @@ var init_dist8 = __esm(() => {
53873
54814
  _a33 = symbol33;
53874
54815
  marker43 = `vercel.ai.error.${name43}`;
53875
54816
  symbol43 = Symbol.for(marker43);
54817
+ InvalidToolApprovalSignatureError = class extends AISDKError {
54818
+ constructor({
54819
+ approvalId,
54820
+ toolCallId,
54821
+ reason
54822
+ }) {
54823
+ super({
54824
+ name: name43,
54825
+ message: `Tool approval signature verification failed for approval "${approvalId}" (tool call "${toolCallId}"): ${reason}`
54826
+ });
54827
+ this[_a43] = true;
54828
+ this.approvalId = approvalId;
54829
+ this.toolCallId = toolCallId;
54830
+ }
54831
+ static isInstance(error40) {
54832
+ return AISDKError.hasMarker(error40, marker43);
54833
+ }
54834
+ };
54835
+ _a43 = symbol43;
54836
+ marker53 = `vercel.ai.error.${name53}`;
54837
+ symbol53 = Symbol.for(marker53);
53876
54838
  InvalidToolInputError = class extends AISDKError {
53877
54839
  constructor({
53878
54840
  toolInput,
@@ -53880,71 +54842,71 @@ var init_dist8 = __esm(() => {
53880
54842
  cause,
53881
54843
  message = `Invalid input for tool ${toolName}: ${getErrorMessage(cause)}`
53882
54844
  }) {
53883
- super({ name: name43, message, cause });
53884
- this[_a43] = true;
54845
+ super({ name: name53, message, cause });
54846
+ this[_a53] = true;
53885
54847
  this.toolInput = toolInput;
53886
54848
  this.toolName = toolName;
53887
54849
  }
53888
54850
  static isInstance(error40) {
53889
- return AISDKError.hasMarker(error40, marker43);
54851
+ return AISDKError.hasMarker(error40, marker53);
53890
54852
  }
53891
54853
  };
53892
- _a43 = symbol43;
53893
- marker53 = `vercel.ai.error.${name53}`;
53894
- symbol53 = Symbol.for(marker53);
54854
+ _a53 = symbol53;
54855
+ marker63 = `vercel.ai.error.${name63}`;
54856
+ symbol63 = Symbol.for(marker63);
53895
54857
  ToolCallNotFoundForApprovalError = class extends AISDKError {
53896
54858
  constructor({
53897
54859
  toolCallId,
53898
54860
  approvalId
53899
54861
  }) {
53900
54862
  super({
53901
- name: name53,
54863
+ name: name63,
53902
54864
  message: `Tool call "${toolCallId}" not found for approval request "${approvalId}".`
53903
54865
  });
53904
- this[_a53] = true;
54866
+ this[_a63] = true;
53905
54867
  this.toolCallId = toolCallId;
53906
54868
  this.approvalId = approvalId;
53907
54869
  }
53908
54870
  static isInstance(error40) {
53909
- return AISDKError.hasMarker(error40, marker53);
54871
+ return AISDKError.hasMarker(error40, marker63);
53910
54872
  }
53911
54873
  };
53912
- _a53 = symbol53;
53913
- marker63 = `vercel.ai.error.${name63}`;
53914
- symbol63 = Symbol.for(marker63);
54874
+ _a63 = symbol63;
54875
+ marker73 = `vercel.ai.error.${name73}`;
54876
+ symbol73 = Symbol.for(marker73);
53915
54877
  MissingToolResultsError = class extends AISDKError {
53916
54878
  constructor({ toolCallIds }) {
53917
54879
  super({
53918
- name: name63,
54880
+ name: name73,
53919
54881
  message: `Tool result${toolCallIds.length > 1 ? "s are" : " is"} missing for tool call${toolCallIds.length > 1 ? "s" : ""} ${toolCallIds.join(", ")}.`
53920
54882
  });
53921
- this[_a63] = true;
54883
+ this[_a73] = true;
53922
54884
  this.toolCallIds = toolCallIds;
53923
54885
  }
53924
54886
  static isInstance(error40) {
53925
- return AISDKError.hasMarker(error40, marker63);
54887
+ return AISDKError.hasMarker(error40, marker73);
53926
54888
  }
53927
54889
  };
53928
- _a63 = symbol63;
53929
- marker73 = `vercel.ai.error.${name73}`;
53930
- symbol73 = Symbol.for(marker73);
54890
+ _a73 = symbol73;
54891
+ marker83 = `vercel.ai.error.${name83}`;
54892
+ symbol83 = Symbol.for(marker83);
53931
54893
  NoImageGeneratedError = class extends AISDKError {
53932
54894
  constructor({
53933
54895
  message = "No image generated.",
53934
54896
  cause,
53935
54897
  responses
53936
54898
  }) {
53937
- super({ name: name73, message, cause });
53938
- this[_a73] = true;
54899
+ super({ name: name83, message, cause });
54900
+ this[_a83] = true;
53939
54901
  this.responses = responses;
53940
54902
  }
53941
54903
  static isInstance(error40) {
53942
- return AISDKError.hasMarker(error40, marker73);
54904
+ return AISDKError.hasMarker(error40, marker83);
53943
54905
  }
53944
54906
  };
53945
- _a73 = symbol73;
53946
- marker83 = `vercel.ai.error.${name83}`;
53947
- symbol83 = Symbol.for(marker83);
54907
+ _a83 = symbol83;
54908
+ marker93 = `vercel.ai.error.${name93}`;
54909
+ symbol93 = Symbol.for(marker93);
53948
54910
  NoObjectGeneratedError = class extends AISDKError {
53949
54911
  constructor({
53950
54912
  message = "No object generated.",
@@ -53954,82 +54916,82 @@ var init_dist8 = __esm(() => {
53954
54916
  usage,
53955
54917
  finishReason
53956
54918
  }) {
53957
- super({ name: name83, message, cause });
53958
- this[_a83] = true;
54919
+ super({ name: name93, message, cause });
54920
+ this[_a93] = true;
53959
54921
  this.text = text2;
53960
54922
  this.response = response;
53961
54923
  this.usage = usage;
53962
54924
  this.finishReason = finishReason;
53963
54925
  }
53964
54926
  static isInstance(error40) {
53965
- return AISDKError.hasMarker(error40, marker83);
54927
+ return AISDKError.hasMarker(error40, marker93);
53966
54928
  }
53967
54929
  };
53968
- _a83 = symbol83;
53969
- marker93 = `vercel.ai.error.${name92}`;
53970
- symbol93 = Symbol.for(marker93);
54930
+ _a93 = symbol93;
54931
+ marker103 = `vercel.ai.error.${name102}`;
54932
+ symbol103 = Symbol.for(marker103);
53971
54933
  NoOutputGeneratedError = class extends AISDKError {
53972
54934
  constructor({
53973
54935
  message = "No output generated.",
53974
54936
  cause
53975
54937
  } = {}) {
53976
- super({ name: name92, message, cause });
53977
- this[_a93] = true;
54938
+ super({ name: name102, message, cause });
54939
+ this[_a103] = true;
53978
54940
  }
53979
54941
  static isInstance(error40) {
53980
- return AISDKError.hasMarker(error40, marker93);
54942
+ return AISDKError.hasMarker(error40, marker103);
53981
54943
  }
53982
54944
  };
53983
- _a93 = symbol93;
53984
- marker102 = `vercel.ai.error.${name102}`;
53985
- symbol102 = Symbol.for(marker102);
54945
+ _a103 = symbol103;
54946
+ marker112 = `vercel.ai.error.${name112}`;
54947
+ symbol112 = Symbol.for(marker112);
53986
54948
  NoSpeechGeneratedError = class extends AISDKError {
53987
54949
  constructor(options) {
53988
54950
  super({
53989
- name: name102,
54951
+ name: name112,
53990
54952
  message: "No speech audio generated."
53991
54953
  });
53992
- this[_a102] = true;
54954
+ this[_a112] = true;
53993
54955
  this.responses = options.responses;
53994
54956
  }
53995
54957
  static isInstance(error40) {
53996
- return AISDKError.hasMarker(error40, marker102);
54958
+ return AISDKError.hasMarker(error40, marker112);
53997
54959
  }
53998
54960
  };
53999
- _a102 = symbol102;
54000
- marker112 = `vercel.ai.error.${name112}`;
54001
- symbol112 = Symbol.for(marker112);
54961
+ _a112 = symbol112;
54962
+ marker122 = `vercel.ai.error.${name122}`;
54963
+ symbol122 = Symbol.for(marker122);
54002
54964
  NoTranscriptGeneratedError = class extends AISDKError {
54003
54965
  constructor(options) {
54004
54966
  super({
54005
- name: name112,
54967
+ name: name122,
54006
54968
  message: "No transcript generated."
54007
54969
  });
54008
- this[_a112] = true;
54970
+ this[_a122] = true;
54009
54971
  this.responses = options.responses;
54010
54972
  }
54011
54973
  static isInstance(error40) {
54012
- return AISDKError.hasMarker(error40, marker112);
54974
+ return AISDKError.hasMarker(error40, marker122);
54013
54975
  }
54014
54976
  };
54015
- _a112 = symbol112;
54016
- marker122 = `vercel.ai.error.${name122}`;
54017
- symbol122 = Symbol.for(marker122);
54977
+ _a122 = symbol122;
54978
+ marker132 = `vercel.ai.error.${name132}`;
54979
+ symbol132 = Symbol.for(marker132);
54018
54980
  NoVideoGeneratedError = class extends AISDKError {
54019
54981
  constructor({
54020
54982
  message = "No video generated.",
54021
54983
  cause,
54022
54984
  responses
54023
54985
  }) {
54024
- super({ name: name122, message, cause });
54025
- this[_a122] = true;
54986
+ super({ name: name132, message, cause });
54987
+ this[_a132] = true;
54026
54988
  this.responses = responses;
54027
54989
  }
54028
54990
  static isInstance(error40) {
54029
- return AISDKError.hasMarker(error40, marker122);
54991
+ return AISDKError.hasMarker(error40, marker132);
54030
54992
  }
54031
54993
  static isNoVideoGeneratedError(error40) {
54032
- return error40 instanceof Error && error40.name === name122 && typeof error40.responses !== "undefined" ? true : false;
54994
+ return error40 instanceof Error && error40.name === name132 && typeof error40.responses !== "undefined" ? true : false;
54033
54995
  }
54034
54996
  toJSON() {
54035
54997
  return {
@@ -54041,42 +55003,42 @@ var init_dist8 = __esm(() => {
54041
55003
  };
54042
55004
  }
54043
55005
  };
54044
- _a122 = symbol122;
54045
- marker132 = `vercel.ai.error.${name132}`;
54046
- symbol132 = Symbol.for(marker132);
55006
+ _a132 = symbol132;
55007
+ marker142 = `vercel.ai.error.${name142}`;
55008
+ symbol142 = Symbol.for(marker142);
54047
55009
  NoSuchToolError = class extends AISDKError {
54048
55010
  constructor({
54049
55011
  toolName,
54050
55012
  availableTools = undefined,
54051
55013
  message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === undefined ? "No tools are available." : `Available tools: ${availableTools.join(", ")}.`}`
54052
55014
  }) {
54053
- super({ name: name132, message });
54054
- this[_a132] = true;
55015
+ super({ name: name142, message });
55016
+ this[_a142] = true;
54055
55017
  this.toolName = toolName;
54056
55018
  this.availableTools = availableTools;
54057
55019
  }
54058
55020
  static isInstance(error40) {
54059
- return AISDKError.hasMarker(error40, marker132);
55021
+ return AISDKError.hasMarker(error40, marker142);
54060
55022
  }
54061
55023
  };
54062
- _a132 = symbol132;
54063
- marker142 = `vercel.ai.error.${name142}`;
54064
- symbol142 = Symbol.for(marker142);
55024
+ _a142 = symbol142;
55025
+ marker152 = `vercel.ai.error.${name15}`;
55026
+ symbol152 = Symbol.for(marker152);
54065
55027
  ToolCallRepairError = class extends AISDKError {
54066
55028
  constructor({
54067
55029
  cause,
54068
55030
  originalError,
54069
55031
  message = `Error repairing tool call: ${getErrorMessage(cause)}`
54070
55032
  }) {
54071
- super({ name: name142, message, cause });
54072
- this[_a142] = true;
55033
+ super({ name: name15, message, cause });
55034
+ this[_a152] = true;
54073
55035
  this.originalError = originalError;
54074
55036
  }
54075
55037
  static isInstance(error40) {
54076
- return AISDKError.hasMarker(error40, marker142);
55038
+ return AISDKError.hasMarker(error40, marker152);
54077
55039
  }
54078
55040
  };
54079
- _a142 = symbol142;
55041
+ _a152 = symbol152;
54080
55042
  UnsupportedModelVersionError = class extends AISDKError {
54081
55043
  constructor(options) {
54082
55044
  super({
@@ -54088,92 +55050,92 @@ var init_dist8 = __esm(() => {
54088
55050
  this.modelId = options.modelId;
54089
55051
  }
54090
55052
  };
54091
- marker152 = `vercel.ai.error.${name15}`;
54092
- symbol152 = Symbol.for(marker152);
55053
+ marker16 = `vercel.ai.error.${name162}`;
55054
+ symbol16 = Symbol.for(marker16);
54093
55055
  UIMessageStreamError = class extends AISDKError {
54094
55056
  constructor({
54095
55057
  chunkType,
54096
55058
  chunkId,
54097
55059
  message
54098
55060
  }) {
54099
- super({ name: name15, message });
54100
- this[_a152] = true;
55061
+ super({ name: name162, message });
55062
+ this[_a16] = true;
54101
55063
  this.chunkType = chunkType;
54102
55064
  this.chunkId = chunkId;
54103
55065
  }
54104
55066
  static isInstance(error40) {
54105
- return AISDKError.hasMarker(error40, marker152);
55067
+ return AISDKError.hasMarker(error40, marker16);
54106
55068
  }
54107
55069
  };
54108
- _a152 = symbol152;
54109
- marker16 = `vercel.ai.error.${name162}`;
54110
- symbol16 = Symbol.for(marker16);
55070
+ _a16 = symbol16;
55071
+ marker172 = `vercel.ai.error.${name172}`;
55072
+ symbol172 = Symbol.for(marker172);
54111
55073
  InvalidDataContentError = class extends AISDKError {
54112
55074
  constructor({
54113
55075
  content,
54114
55076
  cause,
54115
55077
  message = `Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof content}.`
54116
55078
  }) {
54117
- super({ name: name162, message, cause });
54118
- this[_a16] = true;
55079
+ super({ name: name172, message, cause });
55080
+ this[_a172] = true;
54119
55081
  this.content = content;
54120
55082
  }
54121
55083
  static isInstance(error40) {
54122
- return AISDKError.hasMarker(error40, marker16);
55084
+ return AISDKError.hasMarker(error40, marker172);
54123
55085
  }
54124
55086
  };
54125
- _a16 = symbol16;
54126
- marker172 = `vercel.ai.error.${name172}`;
54127
- symbol172 = Symbol.for(marker172);
55087
+ _a172 = symbol172;
55088
+ marker182 = `vercel.ai.error.${name18}`;
55089
+ symbol182 = Symbol.for(marker182);
54128
55090
  InvalidMessageRoleError = class extends AISDKError {
54129
55091
  constructor({
54130
55092
  role,
54131
55093
  message = `Invalid message role: '${role}'. Must be one of: "system", "user", "assistant", "tool".`
54132
55094
  }) {
54133
- super({ name: name172, message });
54134
- this[_a172] = true;
55095
+ super({ name: name18, message });
55096
+ this[_a182] = true;
54135
55097
  this.role = role;
54136
55098
  }
54137
55099
  static isInstance(error40) {
54138
- return AISDKError.hasMarker(error40, marker172);
55100
+ return AISDKError.hasMarker(error40, marker182);
54139
55101
  }
54140
55102
  };
54141
- _a172 = symbol172;
54142
- marker182 = `vercel.ai.error.${name18}`;
54143
- symbol182 = Symbol.for(marker182);
55103
+ _a182 = symbol182;
55104
+ marker19 = `vercel.ai.error.${name19}`;
55105
+ symbol192 = Symbol.for(marker19);
54144
55106
  MessageConversionError = class extends AISDKError {
54145
55107
  constructor({
54146
55108
  originalMessage,
54147
55109
  message
54148
55110
  }) {
54149
- super({ name: name18, message });
54150
- this[_a182] = true;
55111
+ super({ name: name19, message });
55112
+ this[_a19] = true;
54151
55113
  this.originalMessage = originalMessage;
54152
55114
  }
54153
55115
  static isInstance(error40) {
54154
- return AISDKError.hasMarker(error40, marker182);
55116
+ return AISDKError.hasMarker(error40, marker19);
54155
55117
  }
54156
55118
  };
54157
- _a182 = symbol182;
54158
- marker19 = `vercel.ai.error.${name19}`;
54159
- symbol192 = Symbol.for(marker19);
55119
+ _a19 = symbol192;
55120
+ marker20 = `vercel.ai.error.${name20}`;
55121
+ symbol20 = Symbol.for(marker20);
54160
55122
  RetryError = class extends AISDKError {
54161
55123
  constructor({
54162
55124
  message,
54163
55125
  reason,
54164
55126
  errors: errors4
54165
55127
  }) {
54166
- super({ name: name19, message });
54167
- this[_a19] = true;
55128
+ super({ name: name20, message });
55129
+ this[_a20] = true;
54168
55130
  this.reason = reason;
54169
55131
  this.errors = errors4;
54170
55132
  this.lastError = errors4[errors4.length - 1];
54171
55133
  }
54172
55134
  static isInstance(error40) {
54173
- return AISDKError.hasMarker(error40, marker19);
55135
+ return AISDKError.hasMarker(error40, marker20);
54174
55136
  }
54175
55137
  };
54176
- _a19 = symbol192;
55138
+ _a20 = symbol20;
54177
55139
  imageMediaTypeSignatures = [
54178
55140
  {
54179
55141
  mediaType: "image/gif",
@@ -54357,8 +55319,8 @@ var init_dist8 = __esm(() => {
54357
55319
  exports_external2.instanceof(Uint8Array),
54358
55320
  exports_external2.instanceof(ArrayBuffer),
54359
55321
  exports_external2.custom((value) => {
54360
- var _a21, _b16;
54361
- return (_b16 = (_a21 = globalThis.Buffer) == null ? undefined : _a21.isBuffer(value)) != null ? _b16 : false;
55322
+ var _a222, _b16;
55323
+ return (_b16 = (_a222 = globalThis.Buffer) == null ? undefined : _a222.isBuffer(value)) != null ? _b16 : false;
54362
55324
  }, { message: "Must be a Buffer" })
54363
55325
  ]);
54364
55326
  jsonValueSchema3 = exports_external2.lazy(() => exports_external2.union([
@@ -54541,7 +55503,7 @@ var init_dist8 = __esm(() => {
54541
55503
  startSpan() {
54542
55504
  return noopSpan;
54543
55505
  },
54544
- startActiveSpan(name21, arg1, arg2, arg3) {
55506
+ startActiveSpan(name222, arg1, arg2, arg3) {
54545
55507
  if (typeof arg1 === "function") {
54546
55508
  return arg1(noopSpan);
54547
55509
  }
@@ -54599,6 +55561,7 @@ var init_dist8 = __esm(() => {
54599
55561
  this.type = "file";
54600
55562
  }
54601
55563
  };
55564
+ encoder = new TextEncoder;
54602
55565
  output_exports = {};
54603
55566
  __export2(output_exports, {
54604
55567
  array: () => array2,
@@ -54697,7 +55660,8 @@ var init_dist8 = __esm(() => {
54697
55660
  exports_external2.strictObject({
54698
55661
  type: exports_external2.literal("tool-approval-request"),
54699
55662
  approvalId: exports_external2.string(),
54700
- toolCallId: exports_external2.string()
55663
+ toolCallId: exports_external2.string(),
55664
+ signature: exports_external2.string().optional()
54701
55665
  }),
54702
55666
  exports_external2.strictObject({
54703
55667
  type: exports_external2.literal("tool-output-available"),
@@ -54803,6 +55767,28 @@ var init_dist8 = __esm(() => {
54803
55767
  prefix: "aitxt",
54804
55768
  size: 24
54805
55769
  });
55770
+ isOutputChunkType = {
55771
+ file: true,
55772
+ source: true,
55773
+ "text-start": true,
55774
+ "text-end": true,
55775
+ "text-delta": true,
55776
+ "reasoning-start": true,
55777
+ "reasoning-end": true,
55778
+ "reasoning-delta": true,
55779
+ "tool-input-start": true,
55780
+ "tool-input-end": true,
55781
+ "tool-input-delta": true,
55782
+ "tool-approval-request": true,
55783
+ "tool-call": true,
55784
+ "tool-result": true,
55785
+ "tool-error": true,
55786
+ "stream-start": false,
55787
+ "response-metadata": false,
55788
+ finish: false,
55789
+ error: false,
55790
+ raw: false
55791
+ };
54806
55792
  toolMetadataSchema2 = exports_external2.record(exports_external2.string(), jsonValueSchema3.optional());
54807
55793
  uiMessagesSchema = lazySchema(() => zodSchema(exports_external2.array(exports_external2.object({
54808
55794
  id: exports_external2.string(),
@@ -54891,7 +55877,8 @@ var init_dist8 = __esm(() => {
54891
55877
  approval: exports_external2.object({
54892
55878
  id: exports_external2.string(),
54893
55879
  approved: exports_external2.never().optional(),
54894
- reason: exports_external2.never().optional()
55880
+ reason: exports_external2.never().optional(),
55881
+ signature: exports_external2.string().optional()
54895
55882
  })
54896
55883
  }),
54897
55884
  exports_external2.object({
@@ -54908,7 +55895,8 @@ var init_dist8 = __esm(() => {
54908
55895
  approval: exports_external2.object({
54909
55896
  id: exports_external2.string(),
54910
55897
  approved: exports_external2.boolean(),
54911
- reason: exports_external2.string().optional()
55898
+ reason: exports_external2.string().optional(),
55899
+ signature: exports_external2.string().optional()
54912
55900
  })
54913
55901
  }),
54914
55902
  exports_external2.object({
@@ -54927,7 +55915,8 @@ var init_dist8 = __esm(() => {
54927
55915
  approval: exports_external2.object({
54928
55916
  id: exports_external2.string(),
54929
55917
  approved: exports_external2.literal(true),
54930
- reason: exports_external2.string().optional()
55918
+ reason: exports_external2.string().optional(),
55919
+ signature: exports_external2.string().optional()
54931
55920
  }).optional()
54932
55921
  }),
54933
55922
  exports_external2.object({
@@ -54946,7 +55935,8 @@ var init_dist8 = __esm(() => {
54946
55935
  approval: exports_external2.object({
54947
55936
  id: exports_external2.string(),
54948
55937
  approved: exports_external2.literal(true),
54949
- reason: exports_external2.string().optional()
55938
+ reason: exports_external2.string().optional(),
55939
+ signature: exports_external2.string().optional()
54950
55940
  }).optional()
54951
55941
  }),
54952
55942
  exports_external2.object({
@@ -54963,7 +55953,8 @@ var init_dist8 = __esm(() => {
54963
55953
  approval: exports_external2.object({
54964
55954
  id: exports_external2.string(),
54965
55955
  approved: exports_external2.literal(false),
54966
- reason: exports_external2.string().optional()
55956
+ reason: exports_external2.string().optional(),
55957
+ signature: exports_external2.string().optional()
54967
55958
  })
54968
55959
  }),
54969
55960
  exports_external2.object({
@@ -55003,7 +55994,8 @@ var init_dist8 = __esm(() => {
55003
55994
  approval: exports_external2.object({
55004
55995
  id: exports_external2.string(),
55005
55996
  approved: exports_external2.never().optional(),
55006
- reason: exports_external2.never().optional()
55997
+ reason: exports_external2.never().optional(),
55998
+ signature: exports_external2.string().optional()
55007
55999
  })
55008
56000
  }),
55009
56001
  exports_external2.object({
@@ -55019,7 +56011,8 @@ var init_dist8 = __esm(() => {
55019
56011
  approval: exports_external2.object({
55020
56012
  id: exports_external2.string(),
55021
56013
  approved: exports_external2.boolean(),
55022
- reason: exports_external2.string().optional()
56014
+ reason: exports_external2.string().optional(),
56015
+ signature: exports_external2.string().optional()
55023
56016
  })
55024
56017
  }),
55025
56018
  exports_external2.object({
@@ -55037,7 +56030,8 @@ var init_dist8 = __esm(() => {
55037
56030
  approval: exports_external2.object({
55038
56031
  id: exports_external2.string(),
55039
56032
  approved: exports_external2.literal(true),
55040
- reason: exports_external2.string().optional()
56033
+ reason: exports_external2.string().optional(),
56034
+ signature: exports_external2.string().optional()
55041
56035
  }).optional()
55042
56036
  }),
55043
56037
  exports_external2.object({
@@ -55055,7 +56049,8 @@ var init_dist8 = __esm(() => {
55055
56049
  approval: exports_external2.object({
55056
56050
  id: exports_external2.string(),
55057
56051
  approved: exports_external2.literal(true),
55058
- reason: exports_external2.string().optional()
56052
+ reason: exports_external2.string().optional(),
56053
+ signature: exports_external2.string().optional()
55059
56054
  }).optional()
55060
56055
  }),
55061
56056
  exports_external2.object({
@@ -55071,7 +56066,8 @@ var init_dist8 = __esm(() => {
55071
56066
  approval: exports_external2.object({
55072
56067
  id: exports_external2.string(),
55073
56068
  approved: exports_external2.literal(false),
55074
- reason: exports_external2.string().optional()
56069
+ reason: exports_external2.string().optional(),
56070
+ signature: exports_external2.string().optional()
55075
56071
  })
55076
56072
  })
55077
56073
  ])).nonempty("Message must contain at least one part")
@@ -55132,8 +56128,8 @@ var init_dist8 = __esm(() => {
55132
56128
  };
55133
56129
  defaultDownload = createDownload();
55134
56130
  experimental_customProvider = customProvider;
55135
- marker20 = `vercel.ai.error.${name20}`;
55136
- symbol20 = Symbol.for(marker20);
56131
+ marker21 = `vercel.ai.error.${name21}`;
56132
+ symbol21 = Symbol.for(marker21);
55137
56133
  NoSuchProviderError = class extends NoSuchModelError {
55138
56134
  constructor({
55139
56135
  modelId,
@@ -55142,16 +56138,16 @@ var init_dist8 = __esm(() => {
55142
56138
  availableProviders,
55143
56139
  message = `No such provider: ${providerId} (available providers: ${availableProviders.join()})`
55144
56140
  }) {
55145
- super({ errorName: name20, modelId, modelType, message });
55146
- this[_a20] = true;
56141
+ super({ errorName: name21, modelId, modelType, message });
56142
+ this[_a21] = true;
55147
56143
  this.providerId = providerId;
55148
56144
  this.availableProviders = availableProviders;
55149
56145
  }
55150
56146
  static isInstance(error40) {
55151
- return AISDKError.hasMarker(error40, marker20);
56147
+ return AISDKError.hasMarker(error40, marker21);
55152
56148
  }
55153
56149
  };
55154
- _a20 = symbol20;
56150
+ _a21 = symbol21;
55155
56151
  experimental_createProviderRegistry = createProviderRegistry;
55156
56152
  defaultDownload2 = createDownload();
55157
56153
  DefaultChatTransport = class extends HttpChatTransport {