@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.
@@ -152,6 +152,7 @@ function translateSql(sql) {
152
152
  });
153
153
  translated = translated.replace(/lower\s*\(\s*hex\s*\(\s*randomblob\s*\(\s*\d+\s*\)\s*\)\s*\)/gi, "gen_random_uuid()::text");
154
154
  translated = translated.replace(/\bIFNULL\s*\(/gi, "COALESCE(");
155
+ translated = translated.replace(/\bINSTR\s*\(/gi, "STRPOS(");
155
156
  if (/INSERT\s+OR\s+IGNORE\s+INTO/i.test(translated)) {
156
157
  translated = translated.replace(/INSERT\s+OR\s+IGNORE\s+INTO/gi, "INSERT INTO");
157
158
  translated = translated.replace(/;?\s*$/, " ON CONFLICT DO NOTHING");
@@ -9665,7 +9666,7 @@ var init_zod = __esm(() => {
9665
9666
  init_external();
9666
9667
  });
9667
9668
 
9668
- // node_modules/@ai-sdk/provider/dist/index.mjs
9669
+ // node_modules/.pnpm/@ai-sdk+provider@3.0.13/node_modules/@ai-sdk/provider/dist/index.mjs
9669
9670
  function getErrorMessage(error) {
9670
9671
  if (error == null) {
9671
9672
  return "unknown error";
@@ -21330,7 +21331,7 @@ var init_v3 = __esm(() => {
21330
21331
  init_external();
21331
21332
  });
21332
21333
 
21333
- // node_modules/@ai-sdk/provider-utils/node_modules/eventsource-parser/dist/index.js
21334
+ // node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/index.js
21334
21335
  function noop(_arg) {}
21335
21336
  function createParser(config2) {
21336
21337
  if (typeof config2 == "function")
@@ -21490,7 +21491,7 @@ var init_dist2 = __esm(() => {
21490
21491
  };
21491
21492
  });
21492
21493
 
21493
- // node_modules/@ai-sdk/provider-utils/node_modules/eventsource-parser/dist/stream.js
21494
+ // node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/stream.js
21494
21495
  var EventSourceParserStream;
21495
21496
  var init_stream = __esm(() => {
21496
21497
  init_dist2();
@@ -21519,7 +21520,7 @@ var init_stream = __esm(() => {
21519
21520
  };
21520
21521
  });
21521
21522
 
21522
- // node_modules/@ai-sdk/provider-utils/dist/index.mjs
21523
+ // node_modules/.pnpm/@ai-sdk+provider-utils@4.0.35_zod@3.25.76/node_modules/@ai-sdk/provider-utils/dist/index.mjs
21523
21524
  function combineHeaders(...headers) {
21524
21525
  return headers.reduce((combinedHeaders, currentHeaders) => ({
21525
21526
  ...combinedHeaders,
@@ -21623,57 +21624,14 @@ function convertToFormData(input, options = {}) {
21623
21624
  }
21624
21625
  return formData;
21625
21626
  }
21626
- async function readResponseWithSizeLimit({
21627
- response,
21628
- url: url2,
21629
- maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE
21630
- }) {
21631
- const contentLength = response.headers.get("content-length");
21632
- if (contentLength != null) {
21633
- const length = parseInt(contentLength, 10);
21634
- if (!isNaN(length) && length > maxBytes) {
21635
- throw new DownloadError({
21636
- url: url2,
21637
- message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
21638
- });
21639
- }
21640
- }
21641
- const body = response.body;
21642
- if (body == null) {
21643
- return new Uint8Array(0);
21644
- }
21645
- const reader = body.getReader();
21646
- const chunks = [];
21647
- let totalBytes = 0;
21627
+ async function cancelResponseBody(response) {
21628
+ var _a22;
21648
21629
  try {
21649
- while (true) {
21650
- const { done, value } = await reader.read();
21651
- if (done) {
21652
- break;
21653
- }
21654
- totalBytes += value.length;
21655
- if (totalBytes > maxBytes) {
21656
- throw new DownloadError({
21657
- url: url2,
21658
- message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes.`
21659
- });
21660
- }
21661
- chunks.push(value);
21662
- }
21663
- } finally {
21664
- try {
21665
- await reader.cancel();
21666
- } finally {
21667
- reader.releaseLock();
21668
- }
21669
- }
21670
- const result = new Uint8Array(totalBytes);
21671
- let offset = 0;
21672
- for (const chunk of chunks) {
21673
- result.set(chunk, offset);
21674
- offset += chunk.length;
21675
- }
21676
- return result;
21630
+ await ((_a22 = response.body) == null ? undefined : _a22.cancel());
21631
+ } catch (e) {}
21632
+ }
21633
+ function isBrowserRuntime(globalThisAny = globalThis) {
21634
+ return globalThisAny.window != null;
21677
21635
  }
21678
21636
  function validateDownloadUrl(url2) {
21679
21637
  let parsed;
@@ -21694,7 +21652,7 @@ function validateDownloadUrl(url2) {
21694
21652
  message: `URL scheme must be http, https, or data, got ${parsed.protocol}`
21695
21653
  });
21696
21654
  }
21697
- const hostname3 = parsed.hostname;
21655
+ const hostname3 = parsed.hostname.toLowerCase().replace(/\.+$/, "");
21698
21656
  if (!hostname3) {
21699
21657
  throw new DownloadError({
21700
21658
  url: url2,
@@ -21738,62 +21696,198 @@ function isIPv4(hostname3) {
21738
21696
  }
21739
21697
  function isPrivateIPv4(ip) {
21740
21698
  const parts = ip.split(".").map(Number);
21741
- const [a, b] = parts;
21699
+ const [a, b, c] = parts;
21742
21700
  if (a === 0)
21743
21701
  return true;
21744
21702
  if (a === 10)
21745
21703
  return true;
21704
+ if (a === 100 && b >= 64 && b <= 127)
21705
+ return true;
21746
21706
  if (a === 127)
21747
21707
  return true;
21748
21708
  if (a === 169 && b === 254)
21749
21709
  return true;
21750
21710
  if (a === 172 && b >= 16 && b <= 31)
21751
21711
  return true;
21712
+ if (a === 192 && b === 0 && c === 0)
21713
+ return true;
21752
21714
  if (a === 192 && b === 168)
21753
21715
  return true;
21716
+ if (a === 198 && (b === 18 || b === 19))
21717
+ return true;
21718
+ if (a >= 240)
21719
+ return true;
21754
21720
  return false;
21755
21721
  }
21722
+ function parseIPv6(ip) {
21723
+ let address = ip.toLowerCase();
21724
+ const zoneIndex = address.indexOf("%");
21725
+ if (zoneIndex !== -1) {
21726
+ address = address.slice(0, zoneIndex);
21727
+ }
21728
+ const halves = address.split("::");
21729
+ if (halves.length > 2)
21730
+ return null;
21731
+ const toGroups = (segment) => {
21732
+ if (segment === "")
21733
+ return [];
21734
+ const groups = [];
21735
+ const parts = segment.split(":");
21736
+ for (let i = 0;i < parts.length; i++) {
21737
+ const part = parts[i];
21738
+ if (part.includes(".")) {
21739
+ if (i !== parts.length - 1 || !isIPv4(part))
21740
+ return null;
21741
+ const [a, b, c, d] = part.split(".").map(Number);
21742
+ groups.push(a << 8 | b, c << 8 | d);
21743
+ continue;
21744
+ }
21745
+ if (!/^[0-9a-f]{1,4}$/.test(part))
21746
+ return null;
21747
+ groups.push(parseInt(part, 16));
21748
+ }
21749
+ return groups;
21750
+ };
21751
+ const head = toGroups(halves[0]);
21752
+ if (head === null)
21753
+ return null;
21754
+ if (halves.length === 2) {
21755
+ const tail = toGroups(halves[1]);
21756
+ if (tail === null)
21757
+ return null;
21758
+ const fill = 8 - head.length - tail.length;
21759
+ if (fill < 0)
21760
+ return null;
21761
+ return [...head, ...new Array(fill).fill(0), ...tail];
21762
+ }
21763
+ return head.length === 8 ? head : null;
21764
+ }
21756
21765
  function isPrivateIPv6(ip) {
21757
- const normalized = ip.toLowerCase();
21758
- if (normalized === "::1")
21766
+ const groups = parseIPv6(ip);
21767
+ if (groups === null)
21759
21768
  return true;
21760
- if (normalized === "::")
21769
+ const topZero = (count) => groups.slice(0, count).every((group) => group === 0);
21770
+ if (topZero(7) && (groups[7] === 0 || groups[7] === 1))
21761
21771
  return true;
21762
- if (normalized.startsWith("::ffff:")) {
21763
- const mappedPart = normalized.slice(7);
21764
- if (isIPv4(mappedPart)) {
21765
- return isPrivateIPv4(mappedPart);
21772
+ if ((groups[0] & 65024) === 64512)
21773
+ return true;
21774
+ if ((groups[0] & 65472) === 65152)
21775
+ return true;
21776
+ if ((groups[0] & 65472) === 65216)
21777
+ return true;
21778
+ if ((groups[0] & 65280) === 65280)
21779
+ return true;
21780
+ 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;
21781
+ if (embedsIPv4) {
21782
+ const a = groups[6] >> 8 & 255;
21783
+ const b = groups[6] & 255;
21784
+ const c = groups[7] >> 8 & 255;
21785
+ const d = groups[7] & 255;
21786
+ return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
21787
+ }
21788
+ return false;
21789
+ }
21790
+ async function fetchWithValidatedRedirects({
21791
+ url: url2,
21792
+ headers,
21793
+ abortSignal,
21794
+ maxRedirects = MAX_DOWNLOAD_REDIRECTS
21795
+ }) {
21796
+ const baseInit = { signal: abortSignal };
21797
+ if (headers !== undefined) {
21798
+ baseInit.headers = headers;
21799
+ }
21800
+ let currentUrl = url2;
21801
+ for (let redirectCount = 0;redirectCount <= maxRedirects; redirectCount++) {
21802
+ validateDownloadUrl(currentUrl);
21803
+ const response = await fetch(currentUrl, {
21804
+ ...baseInit,
21805
+ redirect: "manual"
21806
+ });
21807
+ if (response.type === "opaqueredirect") {
21808
+ if (!isBrowserRuntime()) {
21809
+ throw new DownloadError({
21810
+ url: url2,
21811
+ message: `Redirect from ${currentUrl} could not be validated and was blocked`
21812
+ });
21813
+ }
21814
+ return await fetch(currentUrl, { ...baseInit, redirect: "follow" });
21815
+ }
21816
+ const location = response.headers.get("location");
21817
+ if (response.status >= 300 && response.status < 400 && location) {
21818
+ await cancelResponseBody(response);
21819
+ currentUrl = new URL(location, currentUrl).toString();
21820
+ continue;
21821
+ }
21822
+ return response;
21823
+ }
21824
+ throw new DownloadError({
21825
+ url: url2,
21826
+ message: `Too many redirects (max ${maxRedirects})`
21827
+ });
21828
+ }
21829
+ async function readResponseWithSizeLimit({
21830
+ response,
21831
+ url: url2,
21832
+ maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE
21833
+ }) {
21834
+ const contentLength = response.headers.get("content-length");
21835
+ if (contentLength != null) {
21836
+ const length = parseInt(contentLength, 10);
21837
+ if (!isNaN(length) && length > maxBytes) {
21838
+ await cancelResponseBody(response);
21839
+ throw new DownloadError({
21840
+ url: url2,
21841
+ message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
21842
+ });
21766
21843
  }
21767
- const hexParts = mappedPart.split(":");
21768
- if (hexParts.length === 2) {
21769
- const high = parseInt(hexParts[0], 16);
21770
- const low = parseInt(hexParts[1], 16);
21771
- if (!isNaN(high) && !isNaN(low)) {
21772
- const a = high >> 8 & 255;
21773
- const b = high & 255;
21774
- const c = low >> 8 & 255;
21775
- const d = low & 255;
21776
- return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
21844
+ }
21845
+ const body = response.body;
21846
+ if (body == null) {
21847
+ return new Uint8Array(0);
21848
+ }
21849
+ const reader = body.getReader();
21850
+ const chunks = [];
21851
+ let totalBytes = 0;
21852
+ try {
21853
+ while (true) {
21854
+ const { done, value } = await reader.read();
21855
+ if (done) {
21856
+ break;
21777
21857
  }
21858
+ totalBytes += value.length;
21859
+ if (totalBytes > maxBytes) {
21860
+ throw new DownloadError({
21861
+ url: url2,
21862
+ message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes.`
21863
+ });
21864
+ }
21865
+ chunks.push(value);
21866
+ }
21867
+ } finally {
21868
+ try {
21869
+ await reader.cancel();
21870
+ } finally {
21871
+ reader.releaseLock();
21778
21872
  }
21779
21873
  }
21780
- if (normalized.startsWith("fc") || normalized.startsWith("fd"))
21781
- return true;
21782
- if (normalized.startsWith("fe80"))
21783
- return true;
21784
- return false;
21874
+ const result = new Uint8Array(totalBytes);
21875
+ let offset = 0;
21876
+ for (const chunk of chunks) {
21877
+ result.set(chunk, offset);
21878
+ offset += chunk.length;
21879
+ }
21880
+ return result;
21785
21881
  }
21786
21882
  async function downloadBlob(url2, options) {
21787
21883
  var _a22, _b22;
21788
- validateDownloadUrl(url2);
21789
21884
  try {
21790
- const response = await fetch(url2, {
21791
- signal: options == null ? undefined : options.abortSignal
21885
+ const response = await fetchWithValidatedRedirects({
21886
+ url: url2,
21887
+ abortSignal: options == null ? undefined : options.abortSignal
21792
21888
  });
21793
- if (response.redirected) {
21794
- validateDownloadUrl(response.url);
21795
- }
21796
21889
  if (!response.ok) {
21890
+ await cancelResponseBody(response);
21797
21891
  throw new DownloadError({
21798
21892
  url: url2,
21799
21893
  statusCode: response.status,
@@ -23040,6 +23134,68 @@ async function resolve3(value) {
23040
23134
  }
23041
23135
  return Promise.resolve(value);
23042
23136
  }
23137
+ async function retryWithExponentialBackoffInternal(f, {
23138
+ maxRetries,
23139
+ delayInMs,
23140
+ backoffFactor,
23141
+ abortSignal,
23142
+ shouldRetry,
23143
+ getDelayInMs,
23144
+ createRetryError
23145
+ }, errors4 = []) {
23146
+ try {
23147
+ return await f();
23148
+ } catch (error40) {
23149
+ if (isAbortError(error40)) {
23150
+ throw error40;
23151
+ }
23152
+ if (maxRetries === 0) {
23153
+ throw error40;
23154
+ }
23155
+ const errorMessage = getErrorMessage2(error40);
23156
+ const newErrors = [...errors4, error40];
23157
+ const tryNumber = newErrors.length;
23158
+ if (tryNumber > maxRetries) {
23159
+ throw createRetryError({
23160
+ message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
23161
+ reason: "maxRetriesExceeded",
23162
+ errors: newErrors
23163
+ });
23164
+ }
23165
+ if (await shouldRetry(error40) && tryNumber <= maxRetries) {
23166
+ await delay(getDelayInMs({
23167
+ error: error40,
23168
+ exponentialBackoffDelay: delayInMs
23169
+ }), { abortSignal });
23170
+ return retryWithExponentialBackoffInternal(f, {
23171
+ maxRetries,
23172
+ delayInMs: backoffFactor * delayInMs,
23173
+ backoffFactor,
23174
+ abortSignal,
23175
+ shouldRetry,
23176
+ getDelayInMs,
23177
+ createRetryError
23178
+ }, newErrors);
23179
+ }
23180
+ if (tryNumber === 1) {
23181
+ throw error40;
23182
+ }
23183
+ throw createRetryError({
23184
+ message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
23185
+ reason: "errorNotRetryable",
23186
+ errors: newErrors
23187
+ });
23188
+ }
23189
+ }
23190
+ async function readResponseBodyAsText({
23191
+ response,
23192
+ url: url2
23193
+ }) {
23194
+ return textDecoder.decode(await readResponseWithSizeLimit({
23195
+ response,
23196
+ url: url2
23197
+ }));
23198
+ }
23043
23199
  function withoutTrailingSlash(url2) {
23044
23200
  return url2 == null ? undefined : url2.replace(/\/$/, "");
23045
23201
  }
@@ -23107,7 +23263,7 @@ var DelayedPromise = class {
23107
23263
  isPending() {
23108
23264
  return this.status.type === "pending";
23109
23265
  }
23110
- }, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
23266
+ }, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, MAX_DOWNLOAD_REDIRECTS = 10, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
23111
23267
  prefix,
23112
23268
  size = 16,
23113
23269
  alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
@@ -23131,7 +23287,7 @@ var DelayedPromise = class {
23131
23287
  });
23132
23288
  }
23133
23289
  return () => `${prefix}${separator}${generator()}`;
23134
- }, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.27", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
23290
+ }, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.35", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
23135
23291
  url: url2,
23136
23292
  headers = {},
23137
23293
  successfulResponseHandler,
@@ -23517,12 +23673,28 @@ var DelayedPromise = class {
23517
23673
  } catch (error40) {
23518
23674
  throw handleFetchError({ error: error40, url: url2, requestBodyValues: body.values });
23519
23675
  }
23520
- }, createJsonErrorResponseHandler = ({
23676
+ }, retryWithExponentialBackoff = ({
23677
+ maxRetries = 2,
23678
+ initialDelayInMs = 2000,
23679
+ backoffFactor = 2,
23680
+ abortSignal,
23681
+ shouldRetry,
23682
+ getDelayInMs = ({ exponentialBackoffDelay }) => exponentialBackoffDelay,
23683
+ createRetryError = ({ message }) => new Error(message)
23684
+ }) => async (f) => retryWithExponentialBackoffInternal(f, {
23685
+ maxRetries,
23686
+ delayInMs: initialDelayInMs,
23687
+ backoffFactor,
23688
+ abortSignal,
23689
+ shouldRetry,
23690
+ getDelayInMs,
23691
+ createRetryError
23692
+ }), textDecoder, createJsonErrorResponseHandler = ({
23521
23693
  errorSchema,
23522
23694
  errorToMessage,
23523
23695
  isRetryable
23524
23696
  }) => async ({ response, url: url2, requestBodyValues }) => {
23525
- const responseBody = await response.text();
23697
+ const responseBody = await readResponseBodyAsText({ response, url: url2 });
23526
23698
  const responseHeaders = extractResponseHeaders(response);
23527
23699
  if (responseBody.trim() === "") {
23528
23700
  return {
@@ -23583,7 +23755,7 @@ var DelayedPromise = class {
23583
23755
  })
23584
23756
  };
23585
23757
  }, createJsonResponseHandler = (responseSchema) => async ({ response, url: url2, requestBodyValues }) => {
23586
- const responseBody = await response.text();
23758
+ const responseBody = await readResponseBodyAsText({ response, url: url2 });
23587
23759
  const parsedResult = await safeParseJSON({
23588
23760
  text: responseBody,
23589
23761
  schema: responseSchema
@@ -23739,9 +23911,10 @@ var init_dist3 = __esm(() => {
23739
23911
  ZodNull: "null"
23740
23912
  };
23741
23913
  schemaSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
23914
+ textDecoder = new TextDecoder;
23742
23915
  });
23743
23916
 
23744
- // node_modules/@ai-sdk/anthropic/dist/index.mjs
23917
+ // node_modules/.pnpm/@ai-sdk+anthropic@3.0.92_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.mjs
23745
23918
  var exports_dist = {};
23746
23919
  __export(exports_dist, {
23747
23920
  forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep,
@@ -24946,7 +25119,10 @@ async function convertToAnthropicMessagesPrompt({
24946
25119
  }
24947
25120
  }
24948
25121
  }
24949
- messages.push({ role: "assistant", content: anthropicContent });
25122
+ messages.push({
25123
+ role: "assistant",
25124
+ content: moveToolUseBlocksToEnd(anthropicContent)
25125
+ });
24950
25126
  break;
24951
25127
  }
24952
25128
  default: {
@@ -25006,6 +25182,24 @@ function groupIntoBlocks(prompt) {
25006
25182
  }
25007
25183
  return blocks;
25008
25184
  }
25185
+ function moveToolUseBlocksToEnd(content) {
25186
+ const result = [];
25187
+ let segment = [];
25188
+ function flushSegment() {
25189
+ result.push(...segment.filter((part) => part.type !== "tool_use"), ...segment.filter((part) => part.type === "tool_use"));
25190
+ segment = [];
25191
+ }
25192
+ for (const part of content) {
25193
+ if (part.type === "thinking" || part.type === "redacted_thinking") {
25194
+ flushSegment();
25195
+ result.push(part);
25196
+ } else {
25197
+ segment.push(part);
25198
+ }
25199
+ }
25200
+ flushSegment();
25201
+ return result;
25202
+ }
25009
25203
  function mapAnthropicStopReason({
25010
25204
  finishReason,
25011
25205
  isJsonResponseFromTool
@@ -25183,7 +25377,7 @@ function createCitationSource(citation, citationDocuments, generateId3) {
25183
25377
  };
25184
25378
  }
25185
25379
  function getModelCapabilities(modelId) {
25186
- if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5")) {
25380
+ if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5") || modelId.includes("claude-sonnet-5")) {
25187
25381
  return {
25188
25382
  maxOutputTokens: 128000,
25189
25383
  supportsStructuredOutput: true,
@@ -25374,7 +25568,7 @@ function forwardAnthropicContainerIdFromLastStep({
25374
25568
  }
25375
25569
  return;
25376
25570
  }
25377
- var VERSION2 = "3.0.82", anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicStopDetailsSchema, anthropicMessagesResponseSchema, anthropicMessagesChunkSchema, anthropicReasoningMetadataSchema, anthropicFilePartProviderOptions, anthropicLanguageModelOptions, MAX_CACHE_BREAKPOINTS = 4, CacheControlValidator = class {
25571
+ var VERSION2 = "3.0.92", anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicStopDetailsSchema, anthropicMessagesResponseSchema, anthropicMessagesChunkSchema, anthropicReasoningMetadataSchema, anthropicFilePartProviderOptions, anthropicLanguageModelOptions, MAX_CACHE_BREAKPOINTS = 4, CacheControlValidator = class {
25378
25572
  constructor() {
25379
25573
  this.breakpointCount = 0;
25380
25574
  this.warnings = [];
@@ -26526,6 +26720,7 @@ var VERSION2 = "3.0.82", anthropicErrorDataSchema, anthropicFailedResponseHandle
26526
26720
  "bash_code_execution"
26527
26721
  ].includes(part.name)) {
26528
26722
  const providerToolName = part.name === "text_editor_code_execution" || part.name === "bash_code_execution" ? "code_execution" : part.name;
26723
+ const providerToolInputType = part.name === "text_editor_code_execution" || part.name === "bash_code_execution" ? part.name : part.name === "code_execution" ? "programmatic-tool-call" : undefined;
26529
26724
  const customToolName = toolNameMapping.toCustomToolName(providerToolName);
26530
26725
  const finalInput = part.input != null && typeof part.input === "object" && Object.keys(part.input).length > 0 ? JSON.stringify(part.input) : "";
26531
26726
  contentBlocks[value.index] = {
@@ -26535,8 +26730,9 @@ var VERSION2 = "3.0.82", anthropicErrorDataSchema, anthropicFailedResponseHandle
26535
26730
  input: finalInput,
26536
26731
  providerExecuted: true,
26537
26732
  ...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
26538
- firstDelta: true,
26539
- providerToolName
26733
+ firstDelta: finalInput.length === 0,
26734
+ providerToolName,
26735
+ providerToolInputType
26540
26736
  };
26541
26737
  controller.enqueue({
26542
26738
  type: "tool-input-start",
@@ -26954,8 +27150,8 @@ var VERSION2 = "3.0.82", anthropicErrorDataSchema, anthropicFailedResponseHandle
26954
27150
  if ((contentBlock == null ? undefined : contentBlock.type) !== "tool-call") {
26955
27151
  return;
26956
27152
  }
26957
- if (contentBlock.firstDelta && contentBlock.providerToolName === "code_execution") {
26958
- delta = `{"type": "programmatic-tool-call",${delta.substring(1)}`;
27153
+ if (contentBlock.firstDelta && contentBlock.providerToolInputType != null) {
27154
+ delta = `{"type": "${contentBlock.providerToolInputType}",${delta.substring(1)}`;
26959
27155
  }
26960
27156
  controller.enqueue({
26961
27157
  type: "tool-input-delta",
@@ -28723,7 +28919,7 @@ var init_dist4 = __esm(() => {
28723
28919
  anthropic = createAnthropic();
28724
28920
  });
28725
28921
 
28726
- // node_modules/@ai-sdk/openai/dist/index.mjs
28922
+ // node_modules/.pnpm/@ai-sdk+openai@3.0.80_zod@3.25.76/node_modules/@ai-sdk/openai/dist/index.mjs
28727
28923
  var exports_dist2 = {};
28728
28924
  __export(exports_dist2, {
28729
28925
  openai: () => openai,
@@ -29269,7 +29465,7 @@ async function convertToOpenAIResponsesInput({
29269
29465
  hasApplyPatchTool = false,
29270
29466
  customProviderToolNames
29271
29467
  }) {
29272
- var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
29468
+ var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
29273
29469
  let input = [];
29274
29470
  const warnings = [];
29275
29471
  const processedApprovalIds = /* @__PURE__ */ new Set;
@@ -29402,10 +29598,11 @@ async function convertToOpenAIResponsesInput({
29402
29598
  }
29403
29599
  break;
29404
29600
  }
29405
- if (store && id != null) {
29406
- if (hasPreviousResponseId) {
29407
- break;
29408
- }
29601
+ if (hasPreviousResponseId && store && id != null) {
29602
+ break;
29603
+ }
29604
+ const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
29605
+ if (store && id != null && isProviderDefinedToolCall) {
29409
29606
  input.push({ type: "item_reference", id });
29410
29607
  break;
29411
29608
  }
@@ -29476,7 +29673,6 @@ async function convertToOpenAIResponsesInput({
29476
29673
  call_id: part.toolCallId,
29477
29674
  name: resolvedToolName,
29478
29675
  arguments: serializeToolCallArguments2(part.input),
29479
- id,
29480
29676
  ...namespace != null && { namespace }
29481
29677
  });
29482
29678
  break;
@@ -29490,7 +29686,7 @@ async function convertToOpenAIResponsesInput({
29490
29686
  }
29491
29687
  const resolvedResultToolName = toolNameMapping.toProviderToolName(part.toolName);
29492
29688
  if (resolvedResultToolName === "tool_search") {
29493
- const itemId = (_o = (_n = (_m = part.providerOptions) == null ? undefined : _m[providerOptionsName]) == null ? undefined : _n.itemId) != null ? _o : part.toolCallId;
29689
+ const itemId = (_p = (_o = (_n = part.providerOptions) == null ? undefined : _n[providerOptionsName]) == null ? undefined : _o.itemId) != null ? _p : part.toolCallId;
29494
29690
  if (store) {
29495
29691
  input.push({ type: "item_reference", id: itemId });
29496
29692
  } else if (part.output.type === "json") {
@@ -29531,7 +29727,7 @@ async function convertToOpenAIResponsesInput({
29531
29727
  break;
29532
29728
  }
29533
29729
  if (store) {
29534
- const itemId = (_r = (_q = (_p = part.providerOptions) == null ? undefined : _p[providerOptionsName]) == null ? undefined : _q.itemId) != null ? _r : part.toolCallId;
29730
+ const itemId = (_s = (_r = (_q = part.providerOptions) == null ? undefined : _q[providerOptionsName]) == null ? undefined : _r.itemId) != null ? _s : part.toolCallId;
29535
29731
  input.push({ type: "item_reference", id: itemId });
29536
29732
  } else {
29537
29733
  warnings.push({
@@ -29641,7 +29837,7 @@ async function convertToOpenAIResponsesInput({
29641
29837
  }
29642
29838
  const output = part.output;
29643
29839
  if (output.type === "execution-denied") {
29644
- const approvalId = (_t = (_s = output.providerOptions) == null ? undefined : _s.openai) == null ? undefined : _t.approvalId;
29840
+ const approvalId = (_u = (_t = output.providerOptions) == null ? undefined : _t.openai) == null ? undefined : _u.approvalId;
29645
29841
  if (approvalId) {
29646
29842
  continue;
29647
29843
  }
@@ -29713,7 +29909,7 @@ async function convertToOpenAIResponsesInput({
29713
29909
  outputValue = output.value;
29714
29910
  break;
29715
29911
  case "execution-denied":
29716
- outputValue = (_u = output.reason) != null ? _u : "Tool execution denied.";
29912
+ outputValue = (_v = output.reason) != null ? _v : "Tool execution denied.";
29717
29913
  break;
29718
29914
  case "json":
29719
29915
  case "error-json":
@@ -29774,7 +29970,7 @@ async function convertToOpenAIResponsesInput({
29774
29970
  contentValue = output.value;
29775
29971
  break;
29776
29972
  case "execution-denied":
29777
- contentValue = (_v = output.reason) != null ? _v : "Tool execution denied.";
29973
+ contentValue = (_w = output.reason) != null ? _w : "Tool execution denied.";
29778
29974
  break;
29779
29975
  case "json":
29780
29976
  case "error-json":
@@ -30199,6 +30395,31 @@ function extractApprovalRequestIdToToolCallIdMapping(prompt) {
30199
30395
  function isTextDeltaChunk(chunk) {
30200
30396
  return chunk.type === "response.output_text.delta";
30201
30397
  }
30398
+ function isOpenAIChatCompletionChunk(value) {
30399
+ const chunk = asRecord(value);
30400
+ return chunk != null && Array.isArray(chunk.choices) && typeof chunk.type !== "string";
30401
+ }
30402
+ function createOpenAIResponsesChatCompletionsMismatchError({
30403
+ value,
30404
+ cause,
30405
+ url: url2,
30406
+ requestBodyValues,
30407
+ responseHeaders
30408
+ }) {
30409
+ return new APICallError({
30410
+ 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.",
30411
+ url: url2,
30412
+ requestBodyValues,
30413
+ responseHeaders,
30414
+ responseBody: JSON.stringify(value),
30415
+ cause,
30416
+ data: value,
30417
+ isRetryable: false
30418
+ });
30419
+ }
30420
+ function asRecord(value) {
30421
+ return typeof value === "object" && value != null ? value : undefined;
30422
+ }
30202
30423
  function isResponseOutputItemDoneChunk(chunk) {
30203
30424
  return chunk.type === "response.output_item.done";
30204
30425
  }
@@ -32004,11 +32225,12 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
32004
32225
  providerOptionsName,
32005
32226
  isShellProviderExecuted
32006
32227
  } = await this.getArgs(options);
32228
+ const url2 = this.config.url({
32229
+ path: "/responses",
32230
+ modelId: this.modelId
32231
+ });
32007
32232
  const { responseHeaders, value: response } = await postJsonToApi({
32008
- url: this.config.url({
32009
- path: "/responses",
32010
- modelId: this.modelId
32011
- }),
32233
+ url: url2,
32012
32234
  headers: combineHeaders(this.config.headers(), options.headers),
32013
32235
  body: {
32014
32236
  ...body,
@@ -32047,8 +32269,15 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
32047
32269
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
32048
32270
  }
32049
32271
  if (!chunk.success) {
32272
+ const error40 = isOpenAIChatCompletionChunk(chunk.rawValue) ? createOpenAIResponsesChatCompletionsMismatchError({
32273
+ value: chunk.rawValue,
32274
+ cause: chunk.error,
32275
+ url: url2,
32276
+ requestBodyValues: body,
32277
+ responseHeaders
32278
+ }) : chunk.error;
32050
32279
  finishReason = { unified: "error", raw: undefined };
32051
- controller.enqueue({ type: "error", error: chunk.error });
32280
+ controller.enqueue({ type: "error", error: error40 });
32052
32281
  return;
32053
32282
  }
32054
32283
  const value = chunk.value;
@@ -33036,7 +33265,7 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
33036
33265
  }
33037
33266
  };
33038
33267
  }
33039
- }, VERSION3 = "3.0.69", openai;
33268
+ }, VERSION3 = "3.0.80", openai;
33040
33269
  var init_dist5 = __esm(() => {
33041
33270
  init_dist3();
33042
33271
  init_dist();
@@ -33753,9 +33982,16 @@ var init_dist5 = __esm(() => {
33753
33982
  incomplete_details: exports_external2.object({ reason: exports_external2.string() }).nullish(),
33754
33983
  usage: exports_external2.object({
33755
33984
  input_tokens: exports_external2.number(),
33756
- input_tokens_details: exports_external2.object({ cached_tokens: exports_external2.number().nullish() }).nullish(),
33985
+ input_tokens_details: exports_external2.object({
33986
+ cached_tokens: exports_external2.number().nullish(),
33987
+ orchestration_input_tokens: exports_external2.number().nullish(),
33988
+ orchestration_input_cached_tokens: exports_external2.number().nullish()
33989
+ }).nullish(),
33757
33990
  output_tokens: exports_external2.number(),
33758
- output_tokens_details: exports_external2.object({ reasoning_tokens: exports_external2.number().nullish() }).nullish()
33991
+ output_tokens_details: exports_external2.object({
33992
+ reasoning_tokens: exports_external2.number().nullish(),
33993
+ orchestration_output_tokens: exports_external2.number().nullish()
33994
+ }).nullish()
33759
33995
  }),
33760
33996
  service_tier: exports_external2.string().nullish()
33761
33997
  })
@@ -33770,9 +34006,16 @@ var init_dist5 = __esm(() => {
33770
34006
  incomplete_details: exports_external2.object({ reason: exports_external2.string() }).nullish(),
33771
34007
  usage: exports_external2.object({
33772
34008
  input_tokens: exports_external2.number(),
33773
- input_tokens_details: exports_external2.object({ cached_tokens: exports_external2.number().nullish() }).nullish(),
34009
+ input_tokens_details: exports_external2.object({
34010
+ cached_tokens: exports_external2.number().nullish(),
34011
+ orchestration_input_tokens: exports_external2.number().nullish(),
34012
+ orchestration_input_cached_tokens: exports_external2.number().nullish()
34013
+ }).nullish(),
33774
34014
  output_tokens: exports_external2.number(),
33775
- output_tokens_details: exports_external2.object({ reasoning_tokens: exports_external2.number().nullish() }).nullish()
34015
+ output_tokens_details: exports_external2.object({
34016
+ reasoning_tokens: exports_external2.number().nullish(),
34017
+ orchestration_output_tokens: exports_external2.number().nullish()
34018
+ }).nullish()
33776
34019
  }).nullish(),
33777
34020
  service_tier: exports_external2.string().nullish()
33778
34021
  })
@@ -34509,9 +34752,16 @@ var init_dist5 = __esm(() => {
34509
34752
  incomplete_details: exports_external2.object({ reason: exports_external2.string() }).nullish(),
34510
34753
  usage: exports_external2.object({
34511
34754
  input_tokens: exports_external2.number(),
34512
- input_tokens_details: exports_external2.object({ cached_tokens: exports_external2.number().nullish() }).nullish(),
34755
+ input_tokens_details: exports_external2.object({
34756
+ cached_tokens: exports_external2.number().nullish(),
34757
+ orchestration_input_tokens: exports_external2.number().nullish(),
34758
+ orchestration_input_cached_tokens: exports_external2.number().nullish()
34759
+ }).nullish(),
34513
34760
  output_tokens: exports_external2.number(),
34514
- output_tokens_details: exports_external2.object({ reasoning_tokens: exports_external2.number().nullish() }).nullish()
34761
+ output_tokens_details: exports_external2.object({
34762
+ reasoning_tokens: exports_external2.number().nullish(),
34763
+ orchestration_output_tokens: exports_external2.number().nullish()
34764
+ }).nullish()
34515
34765
  }).optional()
34516
34766
  })));
34517
34767
  openaiResponsesReasoningModelIds = [
@@ -34584,6 +34834,7 @@ var init_dist5 = __esm(() => {
34584
34834
  include: exports_external2.array(exports_external2.enum([
34585
34835
  "reasoning.encrypted_content",
34586
34836
  "file_search_call.results",
34837
+ "web_search_call.results",
34587
34838
  "message.output_text.logprobs"
34588
34839
  ])).nullish(),
34589
34840
  instructions: exports_external2.string().nullish(),
@@ -34706,7 +34957,7 @@ var init_dist5 = __esm(() => {
34706
34957
  openai = createOpenAI();
34707
34958
  });
34708
34959
 
34709
- // node_modules/@ai-sdk/openai-compatible/dist/index.mjs
34960
+ // node_modules/.pnpm/@ai-sdk+openai-compatible@2.0.56_zod@3.25.76/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
34710
34961
  var exports_dist3 = {};
34711
34962
  __export(exports_dist3, {
34712
34963
  createOpenAICompatible: () => createOpenAICompatible,
@@ -36111,7 +36362,7 @@ var openaiCompatibleErrorDataSchema, defaultOpenAICompatibleErrorStructure, open
36111
36362
  }
36112
36363
  };
36113
36364
  }
36114
- }, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.48";
36365
+ }, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.56";
36115
36366
  var init_dist6 = __esm(() => {
36116
36367
  init_dist();
36117
36368
  init_dist3();
@@ -36253,7 +36504,7 @@ var init_dist6 = __esm(() => {
36253
36504
  });
36254
36505
  });
36255
36506
 
36256
- // node_modules/@vercel/oidc/dist/get-context.js
36507
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/get-context.js
36257
36508
  var require_get_context = __commonJS((exports, module) => {
36258
36509
  var __defProp2 = Object.defineProperty;
36259
36510
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -36285,7 +36536,7 @@ var require_get_context = __commonJS((exports, module) => {
36285
36536
  }
36286
36537
  });
36287
36538
 
36288
- // node_modules/@vercel/oidc/dist/token-error.js
36539
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token-error.js
36289
36540
  var require_token_error = __commonJS((exports, module) => {
36290
36541
  var __defProp2 = Object.defineProperty;
36291
36542
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -36325,7 +36576,7 @@ var require_token_error = __commonJS((exports, module) => {
36325
36576
  }
36326
36577
  });
36327
36578
 
36328
- // node_modules/@vercel/oidc/dist/token-io.js
36579
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token-io.js
36329
36580
  var require_token_io = __commonJS((exports, module) => {
36330
36581
  var __create2 = Object.create;
36331
36582
  var __defProp2 = Object.defineProperty;
@@ -36392,7 +36643,7 @@ var require_token_io = __commonJS((exports, module) => {
36392
36643
  }
36393
36644
  });
36394
36645
 
36395
- // node_modules/@vercel/oidc/dist/auth-config.js
36646
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/auth-config.js
36396
36647
  var require_auth_config = __commonJS((exports, module) => {
36397
36648
  var __create2 = Object.create;
36398
36649
  var __defProp2 = Object.defineProperty;
@@ -36465,7 +36716,7 @@ var require_auth_config = __commonJS((exports, module) => {
36465
36716
  }
36466
36717
  });
36467
36718
 
36468
- // node_modules/@vercel/oidc/dist/oauth.js
36719
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/oauth.js
36469
36720
  var require_oauth = __commonJS((exports, module) => {
36470
36721
  var __defProp2 = Object.defineProperty;
36471
36722
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -36551,7 +36802,7 @@ var require_oauth = __commonJS((exports, module) => {
36551
36802
  }
36552
36803
  });
36553
36804
 
36554
- // node_modules/@vercel/oidc/dist/auth-errors.js
36805
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/auth-errors.js
36555
36806
  var require_auth_errors = __commonJS((exports, module) => {
36556
36807
  var __defProp2 = Object.defineProperty;
36557
36808
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -36592,7 +36843,7 @@ var require_auth_errors = __commonJS((exports, module) => {
36592
36843
  }
36593
36844
  });
36594
36845
 
36595
- // node_modules/@vercel/oidc/dist/token-util.js
36846
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token-util.js
36596
36847
  var require_token_util = __commonJS((exports, module) => {
36597
36848
  var __create2 = Object.create;
36598
36849
  var __defProp2 = Object.defineProperty;
@@ -36757,7 +37008,7 @@ var require_token_util = __commonJS((exports, module) => {
36757
37008
  }
36758
37009
  });
36759
37010
 
36760
- // node_modules/@vercel/oidc/dist/token.js
37011
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token.js
36761
37012
  var require_token = __commonJS((exports, module) => {
36762
37013
  var __defProp2 = Object.defineProperty;
36763
37014
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -36814,7 +37065,7 @@ var require_token = __commonJS((exports, module) => {
36814
37065
  }
36815
37066
  });
36816
37067
 
36817
- // node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js
37068
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js
36818
37069
  var require_get_vercel_oidc_token = __commonJS((exports, module) => {
36819
37070
  var __defProp2 = Object.defineProperty;
36820
37071
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -36880,7 +37131,7 @@ ${error40.message}`;
36880
37131
  }
36881
37132
  });
36882
37133
 
36883
- // node_modules/@vercel/oidc/dist/index.js
37134
+ // node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/index.js
36884
37135
  var require_dist = __commonJS((exports, module) => {
36885
37136
  var __defProp2 = Object.defineProperty;
36886
37137
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -36915,7 +37166,7 @@ var require_dist = __commonJS((exports, module) => {
36915
37166
  var import_token_util = require_token_util();
36916
37167
  });
36917
37168
 
36918
- // node_modules/@ai-sdk/gateway/dist/index.mjs
37169
+ // node_modules/.pnpm/@ai-sdk+gateway@3.0.143_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.mjs
36919
37170
  async function createGatewayErrorFromResponse({
36920
37171
  response,
36921
37172
  statusCode,
@@ -36923,7 +37174,7 @@ async function createGatewayErrorFromResponse({
36923
37174
  cause,
36924
37175
  authMethod
36925
37176
  }) {
36926
- var _a102;
37177
+ var _a112;
36927
37178
  const parseResult = await safeValidateTypes({
36928
37179
  value: response,
36929
37180
  schema: gatewayErrorResponseSchema
@@ -36942,7 +37193,7 @@ async function createGatewayErrorFromResponse({
36942
37193
  const validatedResponse = parseResult.value;
36943
37194
  const errorType = validatedResponse.error.type;
36944
37195
  const message = validatedResponse.error.message;
36945
- const generationId = (_a102 = validatedResponse.generationId) != null ? _a102 : undefined;
37196
+ const generationId = (_a112 = validatedResponse.generationId) != null ? _a112 : undefined;
36946
37197
  switch (errorType) {
36947
37198
  case "authentication_error":
36948
37199
  return GatewayAuthenticationError.createContextualError({
@@ -36993,6 +37244,13 @@ async function createGatewayErrorFromResponse({
36993
37244
  cause,
36994
37245
  generationId
36995
37246
  });
37247
+ case "forbidden":
37248
+ return new GatewayForbiddenError({
37249
+ message,
37250
+ statusCode,
37251
+ cause,
37252
+ generationId
37253
+ });
36996
37254
  default:
36997
37255
  return new GatewayInternalServerError({
36998
37256
  message,
@@ -37031,7 +37289,7 @@ function isTimeoutError(error40) {
37031
37289
  return false;
37032
37290
  }
37033
37291
  async function asGatewayError(error40, authMethod) {
37034
- var _a102;
37292
+ var _a112;
37035
37293
  if (GatewayError.isInstance(error40)) {
37036
37294
  return error40;
37037
37295
  }
@@ -37050,7 +37308,7 @@ async function asGatewayError(error40, authMethod) {
37050
37308
  }
37051
37309
  return await createGatewayErrorFromResponse({
37052
37310
  response: extractApiCallResponse(error40),
37053
- statusCode: (_a102 = error40.statusCode) != null ? _a102 : 500,
37311
+ statusCode: (_a112 = error40.statusCode) != null ? _a112 : 500,
37054
37312
  defaultMessage: "Gateway request failed",
37055
37313
  cause: error40,
37056
37314
  authMethod
@@ -37090,16 +37348,16 @@ function maybeEncodeVideoFile(file2) {
37090
37348
  return file2;
37091
37349
  }
37092
37350
  async function getVercelRequestId() {
37093
- var _a102;
37094
- return (_a102 = import_oidc.getContext().headers) == null ? undefined : _a102["x-vercel-id"];
37351
+ var _a112;
37352
+ return (_a112 = import_oidc.getContext().headers) == null ? undefined : _a112["x-vercel-id"];
37095
37353
  }
37096
37354
  function createGatewayProvider(options = {}) {
37097
- var _a102, _b102;
37355
+ var _a112, _b112;
37098
37356
  let pendingMetadata = null;
37099
37357
  let metadataCache = null;
37100
- const cacheRefreshMillis = (_a102 = options.metadataCacheRefreshMillis) != null ? _a102 : 1000 * 60 * 5;
37358
+ const cacheRefreshMillis = (_a112 = options.metadataCacheRefreshMillis) != null ? _a112 : 1000 * 60 * 5;
37101
37359
  let lastFetchTime = 0;
37102
- const baseURL = (_b102 = withoutTrailingSlash(options.baseURL)) != null ? _b102 : "https://ai-gateway.vercel.sh/v3/ai";
37360
+ const baseURL = (_b112 = withoutTrailingSlash(options.baseURL)) != null ? _b112 : "https://ai-gateway.vercel.sh/v3/ai";
37103
37361
  const getHeaders = async () => {
37104
37362
  try {
37105
37363
  const auth = await getGatewayAuthToken(options);
@@ -37156,8 +37414,8 @@ function createGatewayProvider(options = {}) {
37156
37414
  });
37157
37415
  };
37158
37416
  const getAvailableModels = async () => {
37159
- var _a112, _b112, _c;
37160
- const now2 = (_c = (_b112 = (_a112 = options._internal) == null ? undefined : _a112.currentDate) == null ? undefined : _b112.call(_a112).getTime()) != null ? _c : Date.now();
37417
+ var _a122, _b122, _c;
37418
+ const now2 = (_c = (_b122 = (_a122 = options._internal) == null ? undefined : _a122.currentDate) == null ? undefined : _b122.call(_a122).getTime()) != null ? _c : Date.now();
37161
37419
  if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
37162
37420
  lastFetchTime = now2;
37163
37421
  pendingMetadata = new GatewayFetchMetadata({
@@ -37252,6 +37510,28 @@ function createGatewayProvider(options = {}) {
37252
37510
  };
37253
37511
  provider.rerankingModel = createRerankingModel;
37254
37512
  provider.reranking = createRerankingModel;
37513
+ const createSpeechModel = (modelId) => {
37514
+ return new GatewaySpeechModel(modelId, {
37515
+ provider: "gateway",
37516
+ baseURL,
37517
+ headers: getHeaders,
37518
+ fetch: options.fetch,
37519
+ o11yHeaders: createO11yHeaders()
37520
+ });
37521
+ };
37522
+ provider.speechModel = createSpeechModel;
37523
+ provider.speech = createSpeechModel;
37524
+ const createTranscriptionModel = (modelId) => {
37525
+ return new GatewayTranscriptionModel(modelId, {
37526
+ provider: "gateway",
37527
+ baseURL,
37528
+ headers: getHeaders,
37529
+ fetch: options.fetch,
37530
+ o11yHeaders: createO11yHeaders()
37531
+ });
37532
+ };
37533
+ provider.transcriptionModel = createTranscriptionModel;
37534
+ provider.transcription = createTranscriptionModel;
37255
37535
  provider.chat = provider.languageModel;
37256
37536
  provider.embedding = provider.embeddingModel;
37257
37537
  provider.image = provider.imageModel;
@@ -37276,7 +37556,7 @@ async function getGatewayAuthToken(options) {
37276
37556
  authMethod: "oidc"
37277
37557
  };
37278
37558
  }
37279
- 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 {
37559
+ 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 {
37280
37560
  constructor(config2) {
37281
37561
  this.config = config2;
37282
37562
  }
@@ -37522,7 +37802,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
37522
37802
  abortSignal,
37523
37803
  providerOptions
37524
37804
  }) {
37525
- var _a102;
37805
+ var _a112, _b112;
37526
37806
  const resolvedHeaders = await resolve3(this.config.headers());
37527
37807
  try {
37528
37808
  const {
@@ -37546,10 +37826,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
37546
37826
  });
37547
37827
  return {
37548
37828
  embeddings: responseBody.embeddings,
37549
- usage: (_a102 = responseBody.usage) != null ? _a102 : undefined,
37829
+ usage: (_a112 = responseBody.usage) != null ? _a112 : undefined,
37550
37830
  providerMetadata: responseBody.providerMetadata,
37551
37831
  response: { headers: responseHeaders, body: rawValue },
37552
- warnings: []
37832
+ warnings: (_b112 = responseBody.warnings) != null ? _b112 : []
37553
37833
  };
37554
37834
  } catch (error40) {
37555
37835
  throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders));
@@ -37564,7 +37844,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
37564
37844
  "ai-model-id": this.modelId
37565
37845
  };
37566
37846
  }
37567
- }, gatewayEmbeddingResponseSchema, GatewayImageModel = class {
37847
+ }, gatewayEmbeddingWarningSchema, gatewayEmbeddingResponseSchema, GatewayImageModel = class {
37568
37848
  constructor(modelId, config2) {
37569
37849
  this.modelId = modelId;
37570
37850
  this.config = config2;
@@ -37586,7 +37866,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
37586
37866
  headers,
37587
37867
  abortSignal
37588
37868
  }) {
37589
- var _a102, _b102, _c, _d;
37869
+ var _a112, _b112, _c, _d;
37590
37870
  const resolvedHeaders = await resolve3(this.config.headers());
37591
37871
  try {
37592
37872
  const {
@@ -37618,7 +37898,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
37618
37898
  });
37619
37899
  return {
37620
37900
  images: responseBody.images,
37621
- warnings: (_a102 = responseBody.warnings) != null ? _a102 : [],
37901
+ warnings: (_a112 = responseBody.warnings) != null ? _a112 : [],
37622
37902
  providerMetadata: responseBody.providerMetadata,
37623
37903
  response: {
37624
37904
  timestamp: /* @__PURE__ */ new Date,
@@ -37627,7 +37907,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
37627
37907
  },
37628
37908
  ...responseBody.usage != null && {
37629
37909
  usage: {
37630
- inputTokens: (_b102 = responseBody.usage.inputTokens) != null ? _b102 : undefined,
37910
+ inputTokens: (_b112 = responseBody.usage.inputTokens) != null ? _b112 : undefined,
37631
37911
  outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : undefined,
37632
37912
  totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : undefined
37633
37913
  }
@@ -37664,12 +37944,15 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
37664
37944
  duration: duration3,
37665
37945
  fps,
37666
37946
  seed,
37947
+ generateAudio,
37667
37948
  image,
37949
+ frameImages,
37950
+ inputReferences,
37668
37951
  providerOptions,
37669
37952
  headers,
37670
37953
  abortSignal
37671
37954
  }) {
37672
- var _a102;
37955
+ var _a112;
37673
37956
  const resolvedHeaders = await resolve3(this.config.headers());
37674
37957
  try {
37675
37958
  const { responseHeaders, value: responseBody } = await postJsonToApi({
@@ -37683,8 +37966,18 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
37683
37966
  ...duration3 && { duration: duration3 },
37684
37967
  ...fps && { fps },
37685
37968
  ...seed && { seed },
37969
+ ...generateAudio !== undefined && { generateAudio },
37686
37970
  ...providerOptions && { providerOptions },
37687
- ...image && { image: maybeEncodeVideoFile(image) }
37971
+ ...image && { image: maybeEncodeVideoFile(image) },
37972
+ ...frameImages && {
37973
+ frameImages: frameImages.map((frame) => ({
37974
+ ...frame,
37975
+ image: maybeEncodeVideoFile(frame.image)
37976
+ }))
37977
+ },
37978
+ ...inputReferences && {
37979
+ inputReferences: inputReferences.map((reference) => maybeEncodeVideoFile(reference))
37980
+ }
37688
37981
  },
37689
37982
  successfulResponseHandler: async ({
37690
37983
  response,
@@ -37759,7 +38052,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
37759
38052
  });
37760
38053
  return {
37761
38054
  videos: responseBody.videos,
37762
- warnings: (_a102 = responseBody.warnings) != null ? _a102 : [],
38055
+ warnings: (_a112 = responseBody.warnings) != null ? _a112 : [],
37763
38056
  providerMetadata: responseBody.providerMetadata,
37764
38057
  response: {
37765
38058
  timestamp: /* @__PURE__ */ new Date,
@@ -37797,6 +38090,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
37797
38090
  abortSignal,
37798
38091
  providerOptions
37799
38092
  }) {
38093
+ var _a112;
37800
38094
  const resolvedHeaders = await resolve3(this.config.headers());
37801
38095
  try {
37802
38096
  const {
@@ -37824,7 +38118,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
37824
38118
  ranking: responseBody.ranking,
37825
38119
  providerMetadata: responseBody.providerMetadata,
37826
38120
  response: { headers: responseHeaders, body: rawValue },
37827
- warnings: []
38121
+ warnings: (_a112 = responseBody.warnings) != null ? _a112 : []
37828
38122
  };
37829
38123
  } catch (error40) {
37830
38124
  throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders));
@@ -37839,7 +38133,144 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
37839
38133
  "ai-model-id": this.modelId
37840
38134
  };
37841
38135
  }
37842
- }, 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;
38136
+ }, gatewayRerankingWarningSchema, gatewayRerankingResponseSchema, GatewaySpeechModel = class {
38137
+ constructor(modelId, config2) {
38138
+ this.modelId = modelId;
38139
+ this.config = config2;
38140
+ this.specificationVersion = "v3";
38141
+ }
38142
+ get provider() {
38143
+ return this.config.provider;
38144
+ }
38145
+ async doGenerate({
38146
+ text,
38147
+ voice,
38148
+ outputFormat,
38149
+ instructions,
38150
+ speed,
38151
+ language,
38152
+ providerOptions,
38153
+ headers,
38154
+ abortSignal
38155
+ }) {
38156
+ var _a112;
38157
+ const resolvedHeaders = await resolve3(this.config.headers());
38158
+ try {
38159
+ const {
38160
+ responseHeaders,
38161
+ value: responseBody,
38162
+ rawValue
38163
+ } = await postJsonToApi({
38164
+ url: this.getUrl(),
38165
+ headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve3(this.config.o11yHeaders)),
38166
+ body: {
38167
+ text,
38168
+ ...voice && { voice },
38169
+ ...outputFormat && { outputFormat },
38170
+ ...instructions && { instructions },
38171
+ ...speed != null && { speed },
38172
+ ...language && { language },
38173
+ ...providerOptions && { providerOptions }
38174
+ },
38175
+ successfulResponseHandler: createJsonResponseHandler(gatewaySpeechResponseSchema),
38176
+ failedResponseHandler: createJsonErrorResponseHandler({
38177
+ errorSchema: exports_external2.any(),
38178
+ errorToMessage: (data) => data
38179
+ }),
38180
+ ...abortSignal && { abortSignal },
38181
+ fetch: this.config.fetch
38182
+ });
38183
+ return {
38184
+ audio: responseBody.audio,
38185
+ warnings: (_a112 = responseBody.warnings) != null ? _a112 : [],
38186
+ providerMetadata: responseBody.providerMetadata,
38187
+ response: {
38188
+ timestamp: /* @__PURE__ */ new Date,
38189
+ modelId: this.modelId,
38190
+ headers: responseHeaders,
38191
+ body: rawValue
38192
+ }
38193
+ };
38194
+ } catch (error40) {
38195
+ throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders != null ? resolvedHeaders : {}));
38196
+ }
38197
+ }
38198
+ getUrl() {
38199
+ return `${this.config.baseURL}/speech-model`;
38200
+ }
38201
+ getModelConfigHeaders() {
38202
+ return {
38203
+ "ai-speech-model-specification-version": "3",
38204
+ "ai-model-id": this.modelId
38205
+ };
38206
+ }
38207
+ }, providerMetadataEntrySchema3, gatewaySpeechWarningSchema, gatewaySpeechResponseSchema, GatewayTranscriptionModel = class {
38208
+ constructor(modelId, config2) {
38209
+ this.modelId = modelId;
38210
+ this.config = config2;
38211
+ this.specificationVersion = "v3";
38212
+ }
38213
+ get provider() {
38214
+ return this.config.provider;
38215
+ }
38216
+ async doGenerate({
38217
+ audio,
38218
+ mediaType,
38219
+ providerOptions,
38220
+ headers,
38221
+ abortSignal
38222
+ }) {
38223
+ var _a112, _b112, _c, _d;
38224
+ const resolvedHeaders = await resolve3(this.config.headers());
38225
+ try {
38226
+ const {
38227
+ responseHeaders,
38228
+ value: responseBody,
38229
+ rawValue
38230
+ } = await postJsonToApi({
38231
+ url: this.getUrl(),
38232
+ headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve3(this.config.o11yHeaders)),
38233
+ body: {
38234
+ audio: audio instanceof Uint8Array ? convertUint8ArrayToBase64(audio) : audio,
38235
+ mediaType,
38236
+ ...providerOptions && { providerOptions }
38237
+ },
38238
+ successfulResponseHandler: createJsonResponseHandler(gatewayTranscriptionResponseSchema),
38239
+ failedResponseHandler: createJsonErrorResponseHandler({
38240
+ errorSchema: exports_external2.any(),
38241
+ errorToMessage: (data) => data
38242
+ }),
38243
+ ...abortSignal && { abortSignal },
38244
+ fetch: this.config.fetch
38245
+ });
38246
+ return {
38247
+ text: responseBody.text,
38248
+ segments: (_a112 = responseBody.segments) != null ? _a112 : [],
38249
+ language: (_b112 = responseBody.language) != null ? _b112 : undefined,
38250
+ durationInSeconds: (_c = responseBody.durationInSeconds) != null ? _c : undefined,
38251
+ warnings: (_d = responseBody.warnings) != null ? _d : [],
38252
+ providerMetadata: responseBody.providerMetadata,
38253
+ response: {
38254
+ timestamp: /* @__PURE__ */ new Date,
38255
+ modelId: this.modelId,
38256
+ headers: responseHeaders,
38257
+ body: rawValue
38258
+ }
38259
+ };
38260
+ } catch (error40) {
38261
+ throw await asGatewayError(error40, await parseAuthMethod(resolvedHeaders != null ? resolvedHeaders : {}));
38262
+ }
38263
+ }
38264
+ getUrl() {
38265
+ return `${this.config.baseURL}/transcription-model`;
38266
+ }
38267
+ getModelConfigHeaders() {
38268
+ return {
38269
+ "ai-transcription-model-specification-version": "3",
38270
+ "ai-model-id": this.modelId
38271
+ };
38272
+ }
38273
+ }, 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;
37843
38274
  var init_dist7 = __esm(() => {
37844
38275
  init_dist3();
37845
38276
  init_dist();
@@ -37867,6 +38298,12 @@ var init_dist7 = __esm(() => {
37867
38298
  init_dist3();
37868
38299
  init_v4();
37869
38300
  init_dist3();
38301
+ init_v4();
38302
+ init_dist3();
38303
+ init_v4();
38304
+ init_dist3();
38305
+ init_zod();
38306
+ init_dist3();
37870
38307
  init_zod();
37871
38308
  init_dist3();
37872
38309
  init_zod();
@@ -38048,7 +38485,25 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
38048
38485
  };
38049
38486
  marker82 = `vercel.ai.gateway.error.${name72}`;
38050
38487
  symbol82 = Symbol.for(marker82);
38051
- GatewayResponseError = class extends (_b82 = GatewayError, _a82 = symbol82, _b82) {
38488
+ GatewayForbiddenError = class extends (_b82 = GatewayError, _a82 = symbol82, _b82) {
38489
+ constructor({
38490
+ message = "Forbidden",
38491
+ statusCode = 403,
38492
+ cause,
38493
+ generationId
38494
+ } = {}) {
38495
+ super({ message, statusCode, cause, generationId });
38496
+ this[_a82] = true;
38497
+ this.name = name72;
38498
+ this.type = "forbidden";
38499
+ }
38500
+ static isInstance(error40) {
38501
+ return GatewayError.hasMarker(error40) && symbol82 in error40;
38502
+ }
38503
+ };
38504
+ marker92 = `vercel.ai.gateway.error.${name82}`;
38505
+ symbol92 = Symbol.for(marker92);
38506
+ GatewayResponseError = class extends (_b92 = GatewayError, _a92 = symbol92, _b92) {
38052
38507
  constructor({
38053
38508
  message = "Invalid response from Gateway",
38054
38509
  statusCode = 502,
@@ -38058,14 +38513,14 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
38058
38513
  generationId
38059
38514
  } = {}) {
38060
38515
  super({ message, statusCode, cause, generationId });
38061
- this[_a82] = true;
38062
- this.name = name72;
38516
+ this[_a92] = true;
38517
+ this.name = name82;
38063
38518
  this.type = "response_error";
38064
38519
  this.response = response;
38065
38520
  this.validationError = validationError;
38066
38521
  }
38067
38522
  static isInstance(error40) {
38068
- return GatewayError.hasMarker(error40) && symbol82 in error40;
38523
+ return GatewayError.hasMarker(error40) && symbol92 in error40;
38069
38524
  }
38070
38525
  };
38071
38526
  gatewayErrorResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
@@ -38077,9 +38532,9 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
38077
38532
  }),
38078
38533
  generationId: exports_external2.string().nullish()
38079
38534
  })));
38080
- marker92 = `vercel.ai.gateway.error.${name82}`;
38081
- symbol92 = Symbol.for(marker92);
38082
- GatewayTimeoutError = class _GatewayTimeoutError extends (_b92 = GatewayError, _a92 = symbol92, _b92) {
38535
+ marker102 = `vercel.ai.gateway.error.${name92}`;
38536
+ symbol102 = Symbol.for(marker102);
38537
+ GatewayTimeoutError = class _GatewayTimeoutError extends (_b102 = GatewayError, _a102 = symbol102, _b102) {
38083
38538
  constructor({
38084
38539
  message = "Request timed out",
38085
38540
  statusCode = 408,
@@ -38087,12 +38542,12 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
38087
38542
  generationId
38088
38543
  } = {}) {
38089
38544
  super({ message, statusCode, cause, generationId });
38090
- this[_a92] = true;
38091
- this.name = name82;
38545
+ this[_a102] = true;
38546
+ this.name = name92;
38092
38547
  this.type = "timeout_error";
38093
38548
  }
38094
38549
  static isInstance(error40) {
38095
- return GatewayError.hasMarker(error40) && symbol92 in error40;
38550
+ return GatewayError.hasMarker(error40) && symbol102 in error40;
38096
38551
  }
38097
38552
  static createTimeoutError({
38098
38553
  originalMessage,
@@ -38117,6 +38572,8 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
38117
38572
  "image",
38118
38573
  "language",
38119
38574
  "reranking",
38575
+ "speech",
38576
+ "transcription",
38120
38577
  "video"
38121
38578
  ];
38122
38579
  gatewayAvailableModelsResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
@@ -38243,9 +38700,26 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
38243
38700
  billableWebSearchCalls: billable_web_search_calls
38244
38701
  }))
38245
38702
  }).transform(({ data }) => data)));
38703
+ gatewayEmbeddingWarningSchema = exports_external2.discriminatedUnion("type", [
38704
+ exports_external2.object({
38705
+ type: exports_external2.literal("unsupported"),
38706
+ feature: exports_external2.string(),
38707
+ details: exports_external2.string().optional()
38708
+ }),
38709
+ exports_external2.object({
38710
+ type: exports_external2.literal("compatibility"),
38711
+ feature: exports_external2.string(),
38712
+ details: exports_external2.string().optional()
38713
+ }),
38714
+ exports_external2.object({
38715
+ type: exports_external2.literal("other"),
38716
+ message: exports_external2.string()
38717
+ })
38718
+ ]);
38246
38719
  gatewayEmbeddingResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
38247
38720
  embeddings: exports_external2.array(exports_external2.array(exports_external2.number())),
38248
38721
  usage: exports_external2.object({ tokens: exports_external2.number() }).nullish(),
38722
+ warnings: exports_external2.array(gatewayEmbeddingWarningSchema).optional(),
38249
38723
  providerMetadata: exports_external2.record(exports_external2.string(), exports_external2.record(exports_external2.string(), exports_external2.unknown())).optional()
38250
38724
  })));
38251
38725
  providerMetadataEntrySchema = exports_external2.object({
@@ -38324,22 +38798,198 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
38324
38798
  param: exports_external2.unknown().nullable()
38325
38799
  })
38326
38800
  ]);
38801
+ gatewayRerankingWarningSchema = exports_external2.discriminatedUnion("type", [
38802
+ exports_external2.object({
38803
+ type: exports_external2.literal("unsupported"),
38804
+ feature: exports_external2.string(),
38805
+ details: exports_external2.string().optional()
38806
+ }),
38807
+ exports_external2.object({
38808
+ type: exports_external2.literal("compatibility"),
38809
+ feature: exports_external2.string(),
38810
+ details: exports_external2.string().optional()
38811
+ }),
38812
+ exports_external2.object({
38813
+ type: exports_external2.literal("other"),
38814
+ message: exports_external2.string()
38815
+ })
38816
+ ]);
38327
38817
  gatewayRerankingResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
38328
38818
  ranking: exports_external2.array(exports_external2.object({
38329
38819
  index: exports_external2.number(),
38330
38820
  relevanceScore: exports_external2.number()
38331
38821
  })),
38822
+ warnings: exports_external2.array(gatewayRerankingWarningSchema).optional(),
38332
38823
  providerMetadata: exports_external2.record(exports_external2.string(), exports_external2.record(exports_external2.string(), exports_external2.unknown())).optional()
38333
38824
  })));
38825
+ providerMetadataEntrySchema3 = exports_external2.object({}).catchall(exports_external2.unknown());
38826
+ gatewaySpeechWarningSchema = exports_external2.discriminatedUnion("type", [
38827
+ exports_external2.object({
38828
+ type: exports_external2.literal("unsupported"),
38829
+ feature: exports_external2.string(),
38830
+ details: exports_external2.string().optional()
38831
+ }),
38832
+ exports_external2.object({
38833
+ type: exports_external2.literal("compatibility"),
38834
+ feature: exports_external2.string(),
38835
+ details: exports_external2.string().optional()
38836
+ }),
38837
+ exports_external2.object({
38838
+ type: exports_external2.literal("other"),
38839
+ message: exports_external2.string()
38840
+ })
38841
+ ]);
38842
+ gatewaySpeechResponseSchema = exports_external2.object({
38843
+ audio: exports_external2.string(),
38844
+ warnings: exports_external2.array(gatewaySpeechWarningSchema).optional(),
38845
+ providerMetadata: exports_external2.record(exports_external2.string(), providerMetadataEntrySchema3).optional()
38846
+ });
38847
+ providerMetadataEntrySchema4 = exports_external2.object({}).catchall(exports_external2.unknown());
38848
+ gatewayTranscriptionWarningSchema = exports_external2.discriminatedUnion("type", [
38849
+ exports_external2.object({
38850
+ type: exports_external2.literal("unsupported"),
38851
+ feature: exports_external2.string(),
38852
+ details: exports_external2.string().optional()
38853
+ }),
38854
+ exports_external2.object({
38855
+ type: exports_external2.literal("compatibility"),
38856
+ feature: exports_external2.string(),
38857
+ details: exports_external2.string().optional()
38858
+ }),
38859
+ exports_external2.object({
38860
+ type: exports_external2.literal("other"),
38861
+ message: exports_external2.string()
38862
+ })
38863
+ ]);
38864
+ gatewayTranscriptionResponseSchema = exports_external2.object({
38865
+ text: exports_external2.string(),
38866
+ segments: exports_external2.array(exports_external2.object({
38867
+ text: exports_external2.string(),
38868
+ startSecond: exports_external2.number(),
38869
+ endSecond: exports_external2.number()
38870
+ })).optional(),
38871
+ language: exports_external2.string().nullish(),
38872
+ durationInSeconds: exports_external2.number().nullish(),
38873
+ warnings: exports_external2.array(gatewayTranscriptionWarningSchema).optional(),
38874
+ providerMetadata: exports_external2.record(exports_external2.string(), providerMetadataEntrySchema4).optional()
38875
+ });
38876
+ exaSearchInputSchema = lazySchema(() => zodSchema(exports_external.object({
38877
+ query: exports_external.string().describe("Natural-language web search query. This is required."),
38878
+ type: exports_external.enum(["auto", "fast", "instant"]).optional().describe("Search method. Use auto for the default balance of speed and quality."),
38879
+ num_results: exports_external.number().optional().describe("Maximum number of results to return (1-100, default: 10)."),
38880
+ category: exports_external.enum([
38881
+ "company",
38882
+ "people",
38883
+ "research paper",
38884
+ "news",
38885
+ "personal site",
38886
+ "financial report"
38887
+ ]).optional().describe("Optional content category to focus results."),
38888
+ user_location: exports_external.string().optional().describe("Two-letter ISO country code such as 'US'."),
38889
+ include_domains: exports_external.array(exports_external.string()).optional().describe("Only return results from these domains."),
38890
+ exclude_domains: exports_external.array(exports_external.string()).optional().describe("Exclude results from these domains."),
38891
+ start_published_date: exports_external.string().optional().describe("Only return links published after this ISO 8601 date."),
38892
+ end_published_date: exports_external.string().optional().describe("Only return links published before this ISO 8601 date."),
38893
+ contents: exports_external.object({
38894
+ text: exports_external.union([
38895
+ exports_external.boolean(),
38896
+ exports_external.object({
38897
+ max_characters: exports_external.number().optional(),
38898
+ include_html_tags: exports_external.boolean().optional(),
38899
+ verbosity: exports_external.enum(["compact", "standard", "full"]).optional(),
38900
+ include_sections: exports_external.array(exports_external.enum([
38901
+ "header",
38902
+ "navigation",
38903
+ "banner",
38904
+ "body",
38905
+ "sidebar",
38906
+ "footer",
38907
+ "metadata"
38908
+ ])).optional(),
38909
+ exclude_sections: exports_external.array(exports_external.enum([
38910
+ "header",
38911
+ "navigation",
38912
+ "banner",
38913
+ "body",
38914
+ "sidebar",
38915
+ "footer",
38916
+ "metadata"
38917
+ ])).optional()
38918
+ })
38919
+ ]).optional(),
38920
+ highlights: exports_external.union([
38921
+ exports_external.boolean(),
38922
+ exports_external.object({
38923
+ query: exports_external.string().optional(),
38924
+ max_characters: exports_external.number().optional()
38925
+ })
38926
+ ]).optional(),
38927
+ max_age_hours: exports_external.number().optional(),
38928
+ livecrawl_timeout: exports_external.number().optional(),
38929
+ subpages: exports_external.number().optional(),
38930
+ subpage_target: exports_external.union([exports_external.string(), exports_external.array(exports_external.string())]).optional(),
38931
+ extras: exports_external.object({
38932
+ links: exports_external.number().optional(),
38933
+ image_links: exports_external.number().optional()
38934
+ }).optional()
38935
+ }).optional().describe("Controls extracted page content and freshness.")
38936
+ })));
38937
+ exaSearchOutputSchema = lazySchema(() => zodSchema(exports_external.union([
38938
+ exports_external.object({
38939
+ requestId: exports_external.string(),
38940
+ searchType: exports_external.string().optional(),
38941
+ resolvedSearchType: exports_external.string().optional(),
38942
+ results: exports_external.array(exports_external.object({
38943
+ title: exports_external.string(),
38944
+ url: exports_external.string(),
38945
+ id: exports_external.string(),
38946
+ publishedDate: exports_external.string().nullable().optional(),
38947
+ author: exports_external.string().nullable().optional(),
38948
+ image: exports_external.string().nullable().optional(),
38949
+ favicon: exports_external.string().nullable().optional(),
38950
+ text: exports_external.string().optional(),
38951
+ highlights: exports_external.array(exports_external.string()).optional(),
38952
+ highlightScores: exports_external.array(exports_external.number()).optional(),
38953
+ summary: exports_external.string().optional(),
38954
+ subpages: exports_external.array(exports_external.any()).optional(),
38955
+ extras: exports_external.object({
38956
+ links: exports_external.array(exports_external.string()).optional(),
38957
+ imageLinks: exports_external.array(exports_external.string()).optional()
38958
+ }).optional()
38959
+ })),
38960
+ costDollars: exports_external.object({
38961
+ total: exports_external.number().optional(),
38962
+ search: exports_external.record(exports_external.number()).optional()
38963
+ }).optional()
38964
+ }),
38965
+ exports_external.object({
38966
+ error: exports_external.enum([
38967
+ "api_error",
38968
+ "rate_limit",
38969
+ "timeout",
38970
+ "invalid_input",
38971
+ "configuration_error",
38972
+ "execution_error",
38973
+ "unknown"
38974
+ ]),
38975
+ statusCode: exports_external.number().optional(),
38976
+ message: exports_external.string()
38977
+ })
38978
+ ])));
38979
+ exaSearchToolFactory = createProviderToolFactoryWithOutputSchema({
38980
+ id: "gateway.exa_search",
38981
+ inputSchema: exaSearchInputSchema,
38982
+ outputSchema: exaSearchOutputSchema
38983
+ });
38334
38984
  parallelSearchInputSchema = lazySchema(() => zodSchema(exports_external.object({
38335
38985
  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."),
38336
38986
  search_queries: exports_external.array(exports_external.string()).optional().describe("Optional search queries to supplement the objective. Maximum 200 characters per query."),
38337
38987
  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.'),
38338
38988
  max_results: exports_external.number().optional().describe("Maximum number of results to return (1-20). Defaults to 10 if not specified."),
38339
38989
  source_policy: exports_external.object({
38340
- include_domains: exports_external.array(exports_external.string()).optional().describe("List of domains to include in search results."),
38341
- exclude_domains: exports_external.array(exports_external.string()).optional().describe("List of domains to exclude from search results."),
38342
- after_date: exports_external.string().optional().describe("Only include results published after this date (ISO 8601 format).")
38990
+ 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)."),
38991
+ 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)."),
38992
+ 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.")
38343
38993
  }).optional().describe("Source policy for controlling which domains to include/exclude and freshness."),
38344
38994
  excerpts: exports_external.object({
38345
38995
  max_chars_per_result: exports_external.number().optional().describe("Maximum characters per result."),
@@ -38421,20 +39071,21 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
38421
39071
  outputSchema: perplexitySearchOutputSchema
38422
39072
  });
38423
39073
  gatewayTools = {
39074
+ exaSearch,
38424
39075
  parallelSearch,
38425
39076
  perplexitySearch
38426
39077
  };
38427
39078
  gateway = createGatewayProvider();
38428
39079
  });
38429
39080
 
38430
- // node_modules/@opentelemetry/api/build/src/version.js
39081
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/version.js
38431
39082
  var require_version = __commonJS((exports) => {
38432
39083
  Object.defineProperty(exports, "__esModule", { value: true });
38433
39084
  exports.VERSION = undefined;
38434
39085
  exports.VERSION = "1.9.1";
38435
39086
  });
38436
39087
 
38437
- // node_modules/@opentelemetry/api/build/src/internal/semver.js
39088
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/internal/semver.js
38438
39089
  var require_semver = __commonJS((exports) => {
38439
39090
  Object.defineProperty(exports, "__esModule", { value: true });
38440
39091
  exports.isCompatible = exports._makeCompatibilityCheck = undefined;
@@ -38505,7 +39156,7 @@ var require_semver = __commonJS((exports) => {
38505
39156
  exports.isCompatible = _makeCompatibilityCheck(version_1.VERSION);
38506
39157
  });
38507
39158
 
38508
- // node_modules/@opentelemetry/api/build/src/internal/global-utils.js
39159
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/internal/global-utils.js
38509
39160
  var require_global_utils = __commonJS((exports) => {
38510
39161
  Object.defineProperty(exports, "__esModule", { value: true });
38511
39162
  exports.unregisterGlobal = exports.getGlobal = exports.registerGlobal = undefined;
@@ -38553,7 +39204,7 @@ var require_global_utils = __commonJS((exports) => {
38553
39204
  exports.unregisterGlobal = unregisterGlobal;
38554
39205
  });
38555
39206
 
38556
- // node_modules/@opentelemetry/api/build/src/diag/ComponentLogger.js
39207
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/ComponentLogger.js
38557
39208
  var require_ComponentLogger = __commonJS((exports) => {
38558
39209
  Object.defineProperty(exports, "__esModule", { value: true });
38559
39210
  exports.DiagComponentLogger = undefined;
@@ -38589,7 +39240,7 @@ var require_ComponentLogger = __commonJS((exports) => {
38589
39240
  }
38590
39241
  });
38591
39242
 
38592
- // node_modules/@opentelemetry/api/build/src/diag/types.js
39243
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/types.js
38593
39244
  var require_types = __commonJS((exports) => {
38594
39245
  Object.defineProperty(exports, "__esModule", { value: true });
38595
39246
  exports.DiagLogLevel = undefined;
@@ -38605,7 +39256,7 @@ var require_types = __commonJS((exports) => {
38605
39256
  })(DiagLogLevel = exports.DiagLogLevel || (exports.DiagLogLevel = {}));
38606
39257
  });
38607
39258
 
38608
- // node_modules/@opentelemetry/api/build/src/diag/internal/logLevelLogger.js
39259
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/internal/logLevelLogger.js
38609
39260
  var require_logLevelLogger = __commonJS((exports) => {
38610
39261
  Object.defineProperty(exports, "__esModule", { value: true });
38611
39262
  exports.createLogLevelDiagLogger = undefined;
@@ -38635,7 +39286,7 @@ var require_logLevelLogger = __commonJS((exports) => {
38635
39286
  exports.createLogLevelDiagLogger = createLogLevelDiagLogger;
38636
39287
  });
38637
39288
 
38638
- // node_modules/@opentelemetry/api/build/src/api/diag.js
39289
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/diag.js
38639
39290
  var require_diag = __commonJS((exports) => {
38640
39291
  Object.defineProperty(exports, "__esModule", { value: true });
38641
39292
  exports.DiagAPI = undefined;
@@ -38700,7 +39351,7 @@ var require_diag = __commonJS((exports) => {
38700
39351
  exports.DiagAPI = DiagAPI;
38701
39352
  });
38702
39353
 
38703
- // node_modules/@opentelemetry/api/build/src/baggage/internal/baggage-impl.js
39354
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/internal/baggage-impl.js
38704
39355
  var require_baggage_impl = __commonJS((exports) => {
38705
39356
  Object.defineProperty(exports, "__esModule", { value: true });
38706
39357
  exports.BaggageImpl = undefined;
@@ -38743,14 +39394,14 @@ var require_baggage_impl = __commonJS((exports) => {
38743
39394
  exports.BaggageImpl = BaggageImpl;
38744
39395
  });
38745
39396
 
38746
- // node_modules/@opentelemetry/api/build/src/baggage/internal/symbol.js
39397
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/internal/symbol.js
38747
39398
  var require_symbol = __commonJS((exports) => {
38748
39399
  Object.defineProperty(exports, "__esModule", { value: true });
38749
39400
  exports.baggageEntryMetadataSymbol = undefined;
38750
39401
  exports.baggageEntryMetadataSymbol = Symbol("BaggageEntryMetadata");
38751
39402
  });
38752
39403
 
38753
- // node_modules/@opentelemetry/api/build/src/baggage/utils.js
39404
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/utils.js
38754
39405
  var require_utils = __commonJS((exports) => {
38755
39406
  Object.defineProperty(exports, "__esModule", { value: true });
38756
39407
  exports.baggageEntryMetadataFromString = exports.createBaggage = undefined;
@@ -38777,7 +39428,7 @@ var require_utils = __commonJS((exports) => {
38777
39428
  exports.baggageEntryMetadataFromString = baggageEntryMetadataFromString;
38778
39429
  });
38779
39430
 
38780
- // node_modules/@opentelemetry/api/build/src/context/context.js
39431
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/context/context.js
38781
39432
  var require_context = __commonJS((exports) => {
38782
39433
  Object.defineProperty(exports, "__esModule", { value: true });
38783
39434
  exports.ROOT_CONTEXT = exports.createContextKey = undefined;
@@ -38806,7 +39457,7 @@ var require_context = __commonJS((exports) => {
38806
39457
  exports.ROOT_CONTEXT = new BaseContext;
38807
39458
  });
38808
39459
 
38809
- // node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js
39460
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js
38810
39461
  var require_consoleLogger = __commonJS((exports) => {
38811
39462
  Object.defineProperty(exports, "__esModule", { value: true });
38812
39463
  exports.DiagConsoleLogger = exports._originalConsoleMethods = undefined;
@@ -38861,7 +39512,7 @@ var require_consoleLogger = __commonJS((exports) => {
38861
39512
  exports.DiagConsoleLogger = DiagConsoleLogger;
38862
39513
  });
38863
39514
 
38864
- // node_modules/@opentelemetry/api/build/src/metrics/NoopMeter.js
39515
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics/NoopMeter.js
38865
39516
  var require_NoopMeter = __commonJS((exports) => {
38866
39517
  Object.defineProperty(exports, "__esModule", { value: true });
38867
39518
  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;
@@ -38949,7 +39600,7 @@ var require_NoopMeter = __commonJS((exports) => {
38949
39600
  exports.createNoopMeter = createNoopMeter;
38950
39601
  });
38951
39602
 
38952
- // node_modules/@opentelemetry/api/build/src/metrics/Metric.js
39603
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics/Metric.js
38953
39604
  var require_Metric = __commonJS((exports) => {
38954
39605
  Object.defineProperty(exports, "__esModule", { value: true });
38955
39606
  exports.ValueType = undefined;
@@ -38960,7 +39611,7 @@ var require_Metric = __commonJS((exports) => {
38960
39611
  })(ValueType = exports.ValueType || (exports.ValueType = {}));
38961
39612
  });
38962
39613
 
38963
- // node_modules/@opentelemetry/api/build/src/propagation/TextMapPropagator.js
39614
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/propagation/TextMapPropagator.js
38964
39615
  var require_TextMapPropagator = __commonJS((exports) => {
38965
39616
  Object.defineProperty(exports, "__esModule", { value: true });
38966
39617
  exports.defaultTextMapSetter = exports.defaultTextMapGetter = undefined;
@@ -38988,7 +39639,7 @@ var require_TextMapPropagator = __commonJS((exports) => {
38988
39639
  };
38989
39640
  });
38990
39641
 
38991
- // node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js
39642
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js
38992
39643
  var require_NoopContextManager = __commonJS((exports) => {
38993
39644
  Object.defineProperty(exports, "__esModule", { value: true });
38994
39645
  exports.NoopContextManager = undefined;
@@ -39014,7 +39665,7 @@ var require_NoopContextManager = __commonJS((exports) => {
39014
39665
  exports.NoopContextManager = NoopContextManager;
39015
39666
  });
39016
39667
 
39017
- // node_modules/@opentelemetry/api/build/src/api/context.js
39668
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/context.js
39018
39669
  var require_context2 = __commonJS((exports) => {
39019
39670
  Object.defineProperty(exports, "__esModule", { value: true });
39020
39671
  exports.ContextAPI = undefined;
@@ -39055,7 +39706,7 @@ var require_context2 = __commonJS((exports) => {
39055
39706
  exports.ContextAPI = ContextAPI;
39056
39707
  });
39057
39708
 
39058
- // node_modules/@opentelemetry/api/build/src/trace/trace_flags.js
39709
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/trace_flags.js
39059
39710
  var require_trace_flags = __commonJS((exports) => {
39060
39711
  Object.defineProperty(exports, "__esModule", { value: true });
39061
39712
  exports.TraceFlags = undefined;
@@ -39066,7 +39717,7 @@ var require_trace_flags = __commonJS((exports) => {
39066
39717
  })(TraceFlags = exports.TraceFlags || (exports.TraceFlags = {}));
39067
39718
  });
39068
39719
 
39069
- // node_modules/@opentelemetry/api/build/src/trace/invalid-span-constants.js
39720
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/invalid-span-constants.js
39070
39721
  var require_invalid_span_constants = __commonJS((exports) => {
39071
39722
  Object.defineProperty(exports, "__esModule", { value: true });
39072
39723
  exports.INVALID_SPAN_CONTEXT = exports.INVALID_TRACEID = exports.INVALID_SPANID = undefined;
@@ -39080,7 +39731,7 @@ var require_invalid_span_constants = __commonJS((exports) => {
39080
39731
  };
39081
39732
  });
39082
39733
 
39083
- // node_modules/@opentelemetry/api/build/src/trace/NonRecordingSpan.js
39734
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/NonRecordingSpan.js
39084
39735
  var require_NonRecordingSpan = __commonJS((exports) => {
39085
39736
  Object.defineProperty(exports, "__esModule", { value: true });
39086
39737
  exports.NonRecordingSpan = undefined;
@@ -39123,7 +39774,7 @@ var require_NonRecordingSpan = __commonJS((exports) => {
39123
39774
  exports.NonRecordingSpan = NonRecordingSpan;
39124
39775
  });
39125
39776
 
39126
- // node_modules/@opentelemetry/api/build/src/trace/context-utils.js
39777
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/context-utils.js
39127
39778
  var require_context_utils = __commonJS((exports) => {
39128
39779
  Object.defineProperty(exports, "__esModule", { value: true });
39129
39780
  exports.getSpanContext = exports.setSpanContext = exports.deleteSpan = exports.setSpan = exports.getActiveSpan = exports.getSpan = undefined;
@@ -39158,7 +39809,7 @@ var require_context_utils = __commonJS((exports) => {
39158
39809
  exports.getSpanContext = getSpanContext;
39159
39810
  });
39160
39811
 
39161
- // node_modules/@opentelemetry/api/build/src/trace/spancontext-utils.js
39812
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/spancontext-utils.js
39162
39813
  var require_spancontext_utils = __commonJS((exports) => {
39163
39814
  Object.defineProperty(exports, "__esModule", { value: true });
39164
39815
  exports.wrapSpanContext = exports.isSpanContextValid = exports.isValidSpanId = exports.isValidTraceId = undefined;
@@ -39296,7 +39947,7 @@ var require_spancontext_utils = __commonJS((exports) => {
39296
39947
  exports.wrapSpanContext = wrapSpanContext;
39297
39948
  });
39298
39949
 
39299
- // node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js
39950
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js
39300
39951
  var require_NoopTracer = __commonJS((exports) => {
39301
39952
  Object.defineProperty(exports, "__esModule", { value: true });
39302
39953
  exports.NoopTracer = undefined;
@@ -39347,7 +39998,7 @@ var require_NoopTracer = __commonJS((exports) => {
39347
39998
  }
39348
39999
  });
39349
40000
 
39350
- // node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js
40001
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js
39351
40002
  var require_ProxyTracer = __commonJS((exports) => {
39352
40003
  Object.defineProperty(exports, "__esModule", { value: true });
39353
40004
  exports.ProxyTracer = undefined;
@@ -39383,7 +40034,7 @@ var require_ProxyTracer = __commonJS((exports) => {
39383
40034
  exports.ProxyTracer = ProxyTracer;
39384
40035
  });
39385
40036
 
39386
- // node_modules/@opentelemetry/api/build/src/trace/NoopTracerProvider.js
40037
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/NoopTracerProvider.js
39387
40038
  var require_NoopTracerProvider = __commonJS((exports) => {
39388
40039
  Object.defineProperty(exports, "__esModule", { value: true });
39389
40040
  exports.NoopTracerProvider = undefined;
@@ -39397,7 +40048,7 @@ var require_NoopTracerProvider = __commonJS((exports) => {
39397
40048
  exports.NoopTracerProvider = NoopTracerProvider;
39398
40049
  });
39399
40050
 
39400
- // node_modules/@opentelemetry/api/build/src/trace/ProxyTracerProvider.js
40051
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/ProxyTracerProvider.js
39401
40052
  var require_ProxyTracerProvider = __commonJS((exports) => {
39402
40053
  Object.defineProperty(exports, "__esModule", { value: true });
39403
40054
  exports.ProxyTracerProvider = undefined;
@@ -39425,7 +40076,7 @@ var require_ProxyTracerProvider = __commonJS((exports) => {
39425
40076
  exports.ProxyTracerProvider = ProxyTracerProvider;
39426
40077
  });
39427
40078
 
39428
- // node_modules/@opentelemetry/api/build/src/trace/SamplingResult.js
40079
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/SamplingResult.js
39429
40080
  var require_SamplingResult = __commonJS((exports) => {
39430
40081
  Object.defineProperty(exports, "__esModule", { value: true });
39431
40082
  exports.SamplingDecision = undefined;
@@ -39437,7 +40088,7 @@ var require_SamplingResult = __commonJS((exports) => {
39437
40088
  })(SamplingDecision = exports.SamplingDecision || (exports.SamplingDecision = {}));
39438
40089
  });
39439
40090
 
39440
- // node_modules/@opentelemetry/api/build/src/trace/span_kind.js
40091
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/span_kind.js
39441
40092
  var require_span_kind = __commonJS((exports) => {
39442
40093
  Object.defineProperty(exports, "__esModule", { value: true });
39443
40094
  exports.SpanKind = undefined;
@@ -39451,7 +40102,7 @@ var require_span_kind = __commonJS((exports) => {
39451
40102
  })(SpanKind = exports.SpanKind || (exports.SpanKind = {}));
39452
40103
  });
39453
40104
 
39454
- // node_modules/@opentelemetry/api/build/src/trace/status.js
40105
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/status.js
39455
40106
  var require_status = __commonJS((exports) => {
39456
40107
  Object.defineProperty(exports, "__esModule", { value: true });
39457
40108
  exports.SpanStatusCode = undefined;
@@ -39463,7 +40114,7 @@ var require_status = __commonJS((exports) => {
39463
40114
  })(SpanStatusCode = exports.SpanStatusCode || (exports.SpanStatusCode = {}));
39464
40115
  });
39465
40116
 
39466
- // node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-validators.js
40117
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-validators.js
39467
40118
  var require_tracestate_validators = __commonJS((exports) => {
39468
40119
  Object.defineProperty(exports, "__esModule", { value: true });
39469
40120
  exports.validateValue = exports.validateKey = undefined;
@@ -39483,7 +40134,7 @@ var require_tracestate_validators = __commonJS((exports) => {
39483
40134
  exports.validateValue = validateValue;
39484
40135
  });
39485
40136
 
39486
- // node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-impl.js
40137
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/internal/tracestate-impl.js
39487
40138
  var require_tracestate_impl = __commonJS((exports) => {
39488
40139
  Object.defineProperty(exports, "__esModule", { value: true });
39489
40140
  exports.TraceStateImpl = undefined;
@@ -39552,7 +40203,7 @@ var require_tracestate_impl = __commonJS((exports) => {
39552
40203
  exports.TraceStateImpl = TraceStateImpl;
39553
40204
  });
39554
40205
 
39555
- // node_modules/@opentelemetry/api/build/src/trace/internal/utils.js
40206
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace/internal/utils.js
39556
40207
  var require_utils2 = __commonJS((exports) => {
39557
40208
  Object.defineProperty(exports, "__esModule", { value: true });
39558
40209
  exports.createTraceState = undefined;
@@ -39563,7 +40214,7 @@ var require_utils2 = __commonJS((exports) => {
39563
40214
  exports.createTraceState = createTraceState;
39564
40215
  });
39565
40216
 
39566
- // node_modules/@opentelemetry/api/build/src/context-api.js
40217
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/context-api.js
39567
40218
  var require_context_api = __commonJS((exports) => {
39568
40219
  Object.defineProperty(exports, "__esModule", { value: true });
39569
40220
  exports.context = undefined;
@@ -39571,7 +40222,7 @@ var require_context_api = __commonJS((exports) => {
39571
40222
  exports.context = context_1.ContextAPI.getInstance();
39572
40223
  });
39573
40224
 
39574
- // node_modules/@opentelemetry/api/build/src/diag-api.js
40225
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/diag-api.js
39575
40226
  var require_diag_api = __commonJS((exports) => {
39576
40227
  Object.defineProperty(exports, "__esModule", { value: true });
39577
40228
  exports.diag = undefined;
@@ -39579,7 +40230,7 @@ var require_diag_api = __commonJS((exports) => {
39579
40230
  exports.diag = diag_1.DiagAPI.instance();
39580
40231
  });
39581
40232
 
39582
- // node_modules/@opentelemetry/api/build/src/metrics/NoopMeterProvider.js
40233
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics/NoopMeterProvider.js
39583
40234
  var require_NoopMeterProvider = __commonJS((exports) => {
39584
40235
  Object.defineProperty(exports, "__esModule", { value: true });
39585
40236
  exports.NOOP_METER_PROVIDER = exports.NoopMeterProvider = undefined;
@@ -39594,7 +40245,7 @@ var require_NoopMeterProvider = __commonJS((exports) => {
39594
40245
  exports.NOOP_METER_PROVIDER = new NoopMeterProvider;
39595
40246
  });
39596
40247
 
39597
- // node_modules/@opentelemetry/api/build/src/api/metrics.js
40248
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/metrics.js
39598
40249
  var require_metrics = __commonJS((exports) => {
39599
40250
  Object.defineProperty(exports, "__esModule", { value: true });
39600
40251
  exports.MetricsAPI = undefined;
@@ -39627,7 +40278,7 @@ var require_metrics = __commonJS((exports) => {
39627
40278
  exports.MetricsAPI = MetricsAPI;
39628
40279
  });
39629
40280
 
39630
- // node_modules/@opentelemetry/api/build/src/metrics-api.js
40281
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/metrics-api.js
39631
40282
  var require_metrics_api = __commonJS((exports) => {
39632
40283
  Object.defineProperty(exports, "__esModule", { value: true });
39633
40284
  exports.metrics = undefined;
@@ -39635,7 +40286,7 @@ var require_metrics_api = __commonJS((exports) => {
39635
40286
  exports.metrics = metrics_1.MetricsAPI.getInstance();
39636
40287
  });
39637
40288
 
39638
- // node_modules/@opentelemetry/api/build/src/propagation/NoopTextMapPropagator.js
40289
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/propagation/NoopTextMapPropagator.js
39639
40290
  var require_NoopTextMapPropagator = __commonJS((exports) => {
39640
40291
  Object.defineProperty(exports, "__esModule", { value: true });
39641
40292
  exports.NoopTextMapPropagator = undefined;
@@ -39652,7 +40303,7 @@ var require_NoopTextMapPropagator = __commonJS((exports) => {
39652
40303
  exports.NoopTextMapPropagator = NoopTextMapPropagator;
39653
40304
  });
39654
40305
 
39655
- // node_modules/@opentelemetry/api/build/src/baggage/context-helpers.js
40306
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/baggage/context-helpers.js
39656
40307
  var require_context_helpers = __commonJS((exports) => {
39657
40308
  Object.defineProperty(exports, "__esModule", { value: true });
39658
40309
  exports.deleteBaggage = exports.setBaggage = exports.getActiveBaggage = exports.getBaggage = undefined;
@@ -39677,7 +40328,7 @@ var require_context_helpers = __commonJS((exports) => {
39677
40328
  exports.deleteBaggage = deleteBaggage;
39678
40329
  });
39679
40330
 
39680
- // node_modules/@opentelemetry/api/build/src/api/propagation.js
40331
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/propagation.js
39681
40332
  var require_propagation = __commonJS((exports) => {
39682
40333
  Object.defineProperty(exports, "__esModule", { value: true });
39683
40334
  exports.PropagationAPI = undefined;
@@ -39726,7 +40377,7 @@ var require_propagation = __commonJS((exports) => {
39726
40377
  exports.PropagationAPI = PropagationAPI;
39727
40378
  });
39728
40379
 
39729
- // node_modules/@opentelemetry/api/build/src/propagation-api.js
40380
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/propagation-api.js
39730
40381
  var require_propagation_api = __commonJS((exports) => {
39731
40382
  Object.defineProperty(exports, "__esModule", { value: true });
39732
40383
  exports.propagation = undefined;
@@ -39734,7 +40385,7 @@ var require_propagation_api = __commonJS((exports) => {
39734
40385
  exports.propagation = propagation_1.PropagationAPI.getInstance();
39735
40386
  });
39736
40387
 
39737
- // node_modules/@opentelemetry/api/build/src/api/trace.js
40388
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/api/trace.js
39738
40389
  var require_trace = __commonJS((exports) => {
39739
40390
  Object.defineProperty(exports, "__esModule", { value: true });
39740
40391
  exports.TraceAPI = undefined;
@@ -39784,7 +40435,7 @@ var require_trace = __commonJS((exports) => {
39784
40435
  exports.TraceAPI = TraceAPI;
39785
40436
  });
39786
40437
 
39787
- // node_modules/@opentelemetry/api/build/src/trace-api.js
40438
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/trace-api.js
39788
40439
  var require_trace_api = __commonJS((exports) => {
39789
40440
  Object.defineProperty(exports, "__esModule", { value: true });
39790
40441
  exports.trace = undefined;
@@ -39792,7 +40443,7 @@ var require_trace_api = __commonJS((exports) => {
39792
40443
  exports.trace = trace_1.TraceAPI.getInstance();
39793
40444
  });
39794
40445
 
39795
- // node_modules/@opentelemetry/api/build/src/index.js
40446
+ // node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/src/index.js
39796
40447
  var require_src = __commonJS((exports) => {
39797
40448
  Object.defineProperty(exports, "__esModule", { value: true });
39798
40449
  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;
@@ -39907,7 +40558,7 @@ var require_src = __commonJS((exports) => {
39907
40558
  };
39908
40559
  });
39909
40560
 
39910
- // node_modules/ai/dist/index.mjs
40561
+ // node_modules/.pnpm/ai@6.0.219_zod@3.25.76/node_modules/ai/dist/index.mjs
39911
40562
  var exports_dist4 = {};
39912
40563
  __export(exports_dist4, {
39913
40564
  zodSchema: () => zodSchema,
@@ -40022,6 +40673,7 @@ __export(exports_dist4, {
40022
40673
  JsonToSseTransformStream: () => JsonToSseTransformStream,
40023
40674
  JSONParseError: () => JSONParseError,
40024
40675
  InvalidToolInputError: () => InvalidToolInputError,
40676
+ InvalidToolApprovalSignatureError: () => InvalidToolApprovalSignatureError,
40025
40677
  InvalidToolApprovalError: () => InvalidToolApprovalError,
40026
40678
  InvalidStreamPartError: () => InvalidStreamPartError,
40027
40679
  InvalidResponseDataError: () => InvalidResponseDataError,
@@ -40265,7 +40917,7 @@ function resolveEmbeddingModel(model) {
40265
40917
  return getGlobalProvider().embeddingModel(model);
40266
40918
  }
40267
40919
  function resolveTranscriptionModel(model) {
40268
- var _a21, _b16;
40920
+ var _a222, _b16;
40269
40921
  if (typeof model !== "string") {
40270
40922
  if (model.specificationVersion !== "v3" && model.specificationVersion !== "v2") {
40271
40923
  const unsupportedModel = model;
@@ -40277,10 +40929,10 @@ function resolveTranscriptionModel(model) {
40277
40929
  }
40278
40930
  return asTranscriptionModelV3(model);
40279
40931
  }
40280
- return (_b16 = (_a21 = getGlobalProvider()).transcriptionModel) == null ? undefined : _b16.call(_a21, model);
40932
+ return (_b16 = (_a222 = getGlobalProvider()).transcriptionModel) == null ? undefined : _b16.call(_a222, model);
40281
40933
  }
40282
40934
  function resolveSpeechModel(model) {
40283
- var _a21, _b16;
40935
+ var _a222, _b16;
40284
40936
  if (typeof model !== "string") {
40285
40937
  if (model.specificationVersion !== "v3" && model.specificationVersion !== "v2") {
40286
40938
  const unsupportedModel = model;
@@ -40292,7 +40944,7 @@ function resolveSpeechModel(model) {
40292
40944
  }
40293
40945
  return asSpeechModelV3(model);
40294
40946
  }
40295
- return (_b16 = (_a21 = getGlobalProvider()).speechModel) == null ? undefined : _b16.call(_a21, model);
40947
+ return (_b16 = (_a222 = getGlobalProvider()).speechModel) == null ? undefined : _b16.call(_a222, model);
40296
40948
  }
40297
40949
  function resolveImageModel(model) {
40298
40950
  if (typeof model !== "string") {
@@ -40347,8 +40999,8 @@ function resolveRerankingModel(model) {
40347
40999
  return model;
40348
41000
  }
40349
41001
  function getGlobalProvider() {
40350
- var _a21;
40351
- return (_a21 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a21 : gateway;
41002
+ var _a222;
41003
+ return (_a222 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a222 : gateway;
40352
41004
  }
40353
41005
  function getTotalTimeoutMs(timeout) {
40354
41006
  if (timeout == null) {
@@ -40673,7 +41325,7 @@ function convertToLanguageModelMessage({
40673
41325
  }
40674
41326
  }
40675
41327
  async function downloadAssets(messages, download2, supportedUrls) {
40676
- var _a21;
41328
+ var _a222;
40677
41329
  const downloadableFiles = [];
40678
41330
  for (const message of messages) {
40679
41331
  if (message.role === "user" && Array.isArray(message.content)) {
@@ -40681,7 +41333,7 @@ async function downloadAssets(messages, download2, supportedUrls) {
40681
41333
  if (part.type === "image" || part.type === "file") {
40682
41334
  downloadableFiles.push({
40683
41335
  data: part.type === "image" ? part.image : part.data,
40684
- mediaType: (_a21 = part.mediaType) != null ? _a21 : part.type === "image" ? "image/*" : undefined
41336
+ mediaType: (_a222 = part.mediaType) != null ? _a222 : part.type === "image" ? "image/*" : undefined
40685
41337
  });
40686
41338
  }
40687
41339
  }
@@ -40727,7 +41379,7 @@ async function downloadAssets(messages, download2, supportedUrls) {
40727
41379
  ]).filter((file2) => file2 != null));
40728
41380
  }
40729
41381
  function convertPartToLanguageModelPart(part, downloadedAssets) {
40730
- var _a21;
41382
+ var _a222;
40731
41383
  if (part.type === "text") {
40732
41384
  return {
40733
41385
  type: "text",
@@ -40760,7 +41412,7 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
40760
41412
  switch (type) {
40761
41413
  case "image": {
40762
41414
  if (data instanceof Uint8Array || typeof data === "string") {
40763
- mediaType = (_a21 = detectMediaType({ data, signatures: imageMediaTypeSignatures })) != null ? _a21 : mediaType;
41415
+ mediaType = (_a222 = detectMediaType({ data, signatures: imageMediaTypeSignatures })) != null ? _a222 : mediaType;
40764
41416
  }
40765
41417
  return {
40766
41418
  type: "file",
@@ -40794,14 +41446,14 @@ function mapToolResultOutput({
40794
41446
  return {
40795
41447
  type: "content",
40796
41448
  value: output.value.map((item) => {
40797
- var _a21, _b16;
41449
+ var _a222, _b16;
40798
41450
  if (item.type === "image-url") {
40799
41451
  const downloadedFile = downloadedAssets[new URL(item.url).toString()];
40800
41452
  if (downloadedFile) {
40801
41453
  return {
40802
41454
  type: "image-data",
40803
41455
  data: convertDataContentToBase64String(downloadedFile.data),
40804
- mediaType: (_a21 = downloadedFile.mediaType) != null ? _a21 : "image/*",
41456
+ mediaType: (_a222 = downloadedFile.mediaType) != null ? _a222 : "image/*",
40805
41457
  providerOptions: item.providerOptions
40806
41458
  };
40807
41459
  }
@@ -40962,9 +41614,9 @@ async function prepareToolsAndToolChoice({
40962
41614
  toolChoice: undefined
40963
41615
  };
40964
41616
  }
40965
- const filteredTools = activeTools != null ? Object.entries(tools).filter(([name21]) => activeTools.includes(name21)) : Object.entries(tools);
41617
+ const filteredTools = activeTools != null ? Object.entries(tools).filter(([name222]) => activeTools.includes(name222)) : Object.entries(tools);
40966
41618
  const languageModelTools = [];
40967
- for (const [name21, tool2] of filteredTools) {
41619
+ for (const [name222, tool2] of filteredTools) {
40968
41620
  const toolType = tool2.type;
40969
41621
  switch (toolType) {
40970
41622
  case undefined:
@@ -40972,7 +41624,7 @@ async function prepareToolsAndToolChoice({
40972
41624
  case "function":
40973
41625
  languageModelTools.push({
40974
41626
  type: "function",
40975
- name: name21,
41627
+ name: name222,
40976
41628
  description: tool2.description,
40977
41629
  inputSchema: await asSchema(tool2.inputSchema).jsonSchema,
40978
41630
  ...tool2.inputExamples != null ? { inputExamples: tool2.inputExamples } : {},
@@ -40983,7 +41635,7 @@ async function prepareToolsAndToolChoice({
40983
41635
  case "provider":
40984
41636
  languageModelTools.push({
40985
41637
  type: "provider",
40986
- name: name21,
41638
+ name: name222,
40987
41639
  id: tool2.id,
40988
41640
  args: tool2.args
40989
41641
  });
@@ -41101,7 +41753,7 @@ function getBaseTelemetryAttributes({
41101
41753
  telemetry,
41102
41754
  headers
41103
41755
  }) {
41104
- var _a21;
41756
+ var _a222;
41105
41757
  return {
41106
41758
  "ai.model.provider": model.provider,
41107
41759
  "ai.model.id": model.modelId,
@@ -41116,7 +41768,7 @@ function getBaseTelemetryAttributes({
41116
41768
  }
41117
41769
  return attributes;
41118
41770
  }, {}),
41119
- ...Object.entries((_a21 = telemetry == null ? undefined : telemetry.metadata) != null ? _a21 : {}).reduce((attributes, [key, value]) => {
41771
+ ...Object.entries((_a222 = telemetry == null ? undefined : telemetry.metadata) != null ? _a222 : {}).reduce((attributes, [key, value]) => {
41120
41772
  attributes[`ai.telemetry.metadata.${key}`] = value;
41121
41773
  return attributes;
41122
41774
  }, {}),
@@ -41141,13 +41793,13 @@ function getTracer({
41141
41793
  return import_api2.trace.getTracer("ai");
41142
41794
  }
41143
41795
  async function recordSpan({
41144
- name: name21,
41796
+ name: name222,
41145
41797
  tracer,
41146
41798
  attributes,
41147
41799
  fn,
41148
41800
  endWhenDone = true
41149
41801
  }) {
41150
- return tracer.startActiveSpan(name21, { attributes: await attributes }, async (span) => {
41802
+ return tracer.startActiveSpan(name222, { attributes: await attributes }, async (span) => {
41151
41803
  const ctx = import_api3.context.active();
41152
41804
  try {
41153
41805
  const result = await import_api3.context.with(ctx, () => fn(span));
@@ -41180,6 +41832,26 @@ function recordErrorOnSpan(span, error40) {
41180
41832
  span.setStatus({ code: import_api3.SpanStatusCode.ERROR });
41181
41833
  }
41182
41834
  }
41835
+ function isPrimitiveAttributeValue(value) {
41836
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
41837
+ }
41838
+ function sanitizeAttributeValue(value) {
41839
+ if (!Array.isArray(value)) {
41840
+ return value;
41841
+ }
41842
+ const primitiveTypes2 = new Set(value.filter(isPrimitiveAttributeValue).map((item) => typeof item));
41843
+ if (primitiveTypes2.size !== 1) {
41844
+ return;
41845
+ }
41846
+ const [primitiveType] = primitiveTypes2;
41847
+ if (primitiveType === "string") {
41848
+ return value.filter((item) => typeof item === "string");
41849
+ }
41850
+ if (primitiveType === "number") {
41851
+ return value.filter((item) => typeof item === "number");
41852
+ }
41853
+ return value.filter((item) => typeof item === "boolean");
41854
+ }
41183
41855
  async function selectTelemetryAttributes({
41184
41856
  telemetry,
41185
41857
  attributes
@@ -41198,7 +41870,9 @@ async function selectTelemetryAttributes({
41198
41870
  }
41199
41871
  const result = await value.input();
41200
41872
  if (result != null) {
41201
- resultAttributes[key] = result;
41873
+ const sanitized2 = sanitizeAttributeValue(result);
41874
+ if (sanitized2 != null)
41875
+ resultAttributes[key] = sanitized2;
41202
41876
  }
41203
41877
  continue;
41204
41878
  }
@@ -41208,11 +41882,15 @@ async function selectTelemetryAttributes({
41208
41882
  }
41209
41883
  const result = await value.output();
41210
41884
  if (result != null) {
41211
- resultAttributes[key] = result;
41885
+ const sanitized2 = sanitizeAttributeValue(result);
41886
+ if (sanitized2 != null)
41887
+ resultAttributes[key] = sanitized2;
41212
41888
  }
41213
41889
  continue;
41214
41890
  }
41215
- resultAttributes[key] = value;
41891
+ const sanitized = sanitizeAttributeValue(value);
41892
+ if (sanitized != null)
41893
+ resultAttributes[key] = sanitized;
41216
41894
  }
41217
41895
  return resultAttributes;
41218
41896
  }
@@ -41232,13 +41910,13 @@ function registerTelemetryIntegration(integration) {
41232
41910
  globalThis.AI_SDK_TELEMETRY_INTEGRATIONS.push(integration);
41233
41911
  }
41234
41912
  function getGlobalTelemetryIntegrations() {
41235
- var _a21;
41236
- return (_a21 = globalThis.AI_SDK_TELEMETRY_INTEGRATIONS) != null ? _a21 : [];
41913
+ var _a222;
41914
+ return (_a222 = globalThis.AI_SDK_TELEMETRY_INTEGRATIONS) != null ? _a222 : [];
41237
41915
  }
41238
41916
  function bindTelemetryIntegration(integration) {
41239
- var _a21, _b16, _c, _d, _e, _f;
41917
+ var _a222, _b16, _c, _d, _e, _f;
41240
41918
  return {
41241
- onStart: (_a21 = integration.onStart) == null ? undefined : _a21.bind(integration),
41919
+ onStart: (_a222 = integration.onStart) == null ? undefined : _a222.bind(integration),
41242
41920
  onStepStart: (_b16 = integration.onStepStart) == null ? undefined : _b16.bind(integration),
41243
41921
  onToolCallStart: (_c = integration.onToolCallStart) == null ? undefined : _c.bind(integration),
41244
41922
  onToolCallFinish: (_d = integration.onToolCallFinish) == null ? undefined : _d.bind(integration),
@@ -41308,11 +41986,11 @@ function createNullLanguageModelUsage() {
41308
41986
  };
41309
41987
  }
41310
41988
  function addLanguageModelUsage(usage1, usage2) {
41311
- var _a21, _b16, _c, _d, _e, _f, _g, _h, _i, _j;
41989
+ var _a222, _b16, _c, _d, _e, _f, _g, _h, _i, _j;
41312
41990
  return {
41313
41991
  inputTokens: addTokenCounts(usage1.inputTokens, usage2.inputTokens),
41314
41992
  inputTokenDetails: {
41315
- noCacheTokens: addTokenCounts((_a21 = usage1.inputTokenDetails) == null ? undefined : _a21.noCacheTokens, (_b16 = usage2.inputTokenDetails) == null ? undefined : _b16.noCacheTokens),
41993
+ noCacheTokens: addTokenCounts((_a222 = usage1.inputTokenDetails) == null ? undefined : _a222.noCacheTokens, (_b16 = usage2.inputTokenDetails) == null ? undefined : _b16.noCacheTokens),
41316
41994
  cacheReadTokens: addTokenCounts((_c = usage1.inputTokenDetails) == null ? undefined : _c.cacheReadTokens, (_d = usage2.inputTokenDetails) == null ? undefined : _d.cacheReadTokens),
41317
41995
  cacheWriteTokens: addTokenCounts((_e = usage1.inputTokenDetails) == null ? undefined : _e.cacheWriteTokens, (_f = usage2.inputTokenDetails) == null ? undefined : _f.cacheWriteTokens)
41318
41996
  },
@@ -41396,53 +42074,6 @@ function getRetryDelayInMs({
41396
42074
  }
41397
42075
  return exponentialBackoffDelay;
41398
42076
  }
41399
- async function _retryWithExponentialBackoff(f, {
41400
- maxRetries,
41401
- delayInMs,
41402
- backoffFactor,
41403
- abortSignal
41404
- }, errors4 = []) {
41405
- try {
41406
- return await f();
41407
- } catch (error40) {
41408
- if (isAbortError(error40)) {
41409
- throw error40;
41410
- }
41411
- if (maxRetries === 0) {
41412
- throw error40;
41413
- }
41414
- const errorMessage = getErrorMessage2(error40);
41415
- const newErrors = [...errors4, error40];
41416
- const tryNumber = newErrors.length;
41417
- if (tryNumber > maxRetries) {
41418
- throw new RetryError({
41419
- message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
41420
- reason: "maxRetriesExceeded",
41421
- errors: newErrors
41422
- });
41423
- }
41424
- if (error40 instanceof Error && (APICallError.isInstance(error40) && error40.isRetryable === true || GatewayError.isInstance(error40) && error40.isRetryable === true) && tryNumber <= maxRetries) {
41425
- await delay(getRetryDelayInMs({
41426
- error: error40,
41427
- exponentialBackoffDelay: delayInMs
41428
- }), { abortSignal });
41429
- return _retryWithExponentialBackoff(f, {
41430
- maxRetries,
41431
- delayInMs: backoffFactor * delayInMs,
41432
- backoffFactor,
41433
- abortSignal
41434
- }, newErrors);
41435
- }
41436
- if (tryNumber === 1) {
41437
- throw error40;
41438
- }
41439
- throw new RetryError({
41440
- message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
41441
- reason: "errorNotRetryable",
41442
- errors: newErrors
41443
- });
41444
- }
41445
- }
41446
42077
  function prepareRetries({
41447
42078
  maxRetries,
41448
42079
  abortSignal
@@ -41544,8 +42175,8 @@ function collectToolApprovals({
41544
42175
  return { approvedToolApprovals, deniedToolApprovals };
41545
42176
  }
41546
42177
  function now2() {
41547
- var _a21, _b16;
41548
- return (_b16 = (_a21 = globalThis == null ? undefined : globalThis.performance) == null ? undefined : _a21.now()) != null ? _b16 : Date.now();
42178
+ var _a222, _b16;
42179
+ return (_b16 = (_a222 = globalThis == null ? undefined : globalThis.performance) == null ? undefined : _a222.now()) != null ? _b16 : Date.now();
41549
42180
  }
41550
42181
  async function executeToolCall({
41551
42182
  toolCall,
@@ -41706,10 +42337,158 @@ async function isApprovalNeeded({
41706
42337
  experimental_context
41707
42338
  });
41708
42339
  }
42340
+ function canonicalJSON(value) {
42341
+ if (value === null || value === undefined) {
42342
+ return JSON.stringify(value);
42343
+ }
42344
+ if (typeof value !== "object") {
42345
+ return JSON.stringify(value);
42346
+ }
42347
+ if (Array.isArray(value)) {
42348
+ return `[${value.map(canonicalJSON).join(",")}]`;
42349
+ }
42350
+ const keys = Object.keys(value).sort();
42351
+ const entries = keys.map((k) => `${JSON.stringify(k)}:${canonicalJSON(value[k])}`);
42352
+ return `{${entries.join(",")}}`;
42353
+ }
42354
+ function toBase64url(bytes) {
42355
+ return convertUint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
42356
+ }
42357
+ function fromBase64url(str) {
42358
+ return convertBase64ToUint8Array(str);
42359
+ }
42360
+ async function importKey(secret) {
42361
+ const keyData = typeof secret === "string" ? encoder.encode(secret) : secret;
42362
+ return crypto.subtle.importKey("raw", keyData, { name: "HMAC", hash: "SHA-256" }, false, ["sign", "verify"]);
42363
+ }
42364
+ async function hashInput(input) {
42365
+ const canonical = canonicalJSON(input);
42366
+ const digest = await crypto.subtle.digest("SHA-256", encoder.encode(canonical));
42367
+ return toBase64url(new Uint8Array(digest));
42368
+ }
42369
+ function buildPayload(approvalId, toolCallId, toolName, inputDigest) {
42370
+ return encoder.encode(`${approvalId}
42371
+ ${toolCallId}
42372
+ ${toolName}
42373
+ ${inputDigest}`);
42374
+ }
42375
+ async function signToolApproval({
42376
+ secret,
42377
+ approvalId,
42378
+ toolCallId,
42379
+ toolName,
42380
+ input
42381
+ }) {
42382
+ const key = await importKey(secret);
42383
+ const inputDigest = await hashInput(input);
42384
+ const payload = buildPayload(approvalId, toolCallId, toolName, inputDigest);
42385
+ const sig = await crypto.subtle.sign("HMAC", key, payload);
42386
+ return toBase64url(new Uint8Array(sig));
42387
+ }
42388
+ async function verifyToolApprovalSignature({
42389
+ secret,
42390
+ signature,
42391
+ approvalId,
42392
+ toolCallId,
42393
+ toolName,
42394
+ input
42395
+ }) {
42396
+ const key = await importKey(secret);
42397
+ const inputDigest = await hashInput(input);
42398
+ const payload = buildPayload(approvalId, toolCallId, toolName, inputDigest);
42399
+ const sigBytes = fromBase64url(signature);
42400
+ return crypto.subtle.verify("HMAC", key, sigBytes, payload);
42401
+ }
42402
+ async function maybeSignApproval({
42403
+ secret,
42404
+ approvalId,
42405
+ toolCallId,
42406
+ toolName,
42407
+ input
42408
+ }) {
42409
+ if (secret == null)
42410
+ return;
42411
+ return signToolApproval({ secret, approvalId, toolCallId, toolName, input });
42412
+ }
42413
+ async function validateApprovedToolApprovals({
42414
+ approvedToolApprovals,
42415
+ tools,
42416
+ messages,
42417
+ experimental_context,
42418
+ toolApprovalSecret
42419
+ }) {
42420
+ var _a222;
42421
+ const approved = [];
42422
+ const denied = [];
42423
+ for (const approval of approvedToolApprovals) {
42424
+ const { toolCall, approvalRequest } = approval;
42425
+ const tool2 = tools == null ? undefined : tools[toolCall.toolName];
42426
+ if (toolApprovalSecret != null) {
42427
+ if (approvalRequest.signature == null) {
42428
+ throw new InvalidToolApprovalSignatureError({
42429
+ approvalId: approvalRequest.approvalId,
42430
+ toolCallId: toolCall.toolCallId,
42431
+ reason: "missing signature"
42432
+ });
42433
+ }
42434
+ const valid = await verifyToolApprovalSignature({
42435
+ secret: toolApprovalSecret,
42436
+ signature: approvalRequest.signature,
42437
+ approvalId: approvalRequest.approvalId,
42438
+ toolCallId: toolCall.toolCallId,
42439
+ toolName: toolCall.toolName,
42440
+ input: toolCall.input
42441
+ });
42442
+ if (!valid) {
42443
+ throw new InvalidToolApprovalSignatureError({
42444
+ approvalId: approvalRequest.approvalId,
42445
+ toolCallId: toolCall.toolCallId,
42446
+ reason: "invalid signature"
42447
+ });
42448
+ }
42449
+ }
42450
+ if (tool2 != null && typeof tool2.execute === "function" && tool2.inputSchema != null) {
42451
+ const validation = await safeValidateTypes({
42452
+ value: toolCall.input,
42453
+ schema: asSchema(tool2.inputSchema)
42454
+ });
42455
+ if (!validation.success) {
42456
+ throw new InvalidToolInputError({
42457
+ toolName: toolCall.toolName,
42458
+ toolInput: JSON.stringify(toolCall.input),
42459
+ cause: validation.error
42460
+ });
42461
+ }
42462
+ }
42463
+ const approvalNeeded = tool2 != null && await isApprovalNeeded({
42464
+ tool: tool2,
42465
+ toolCall,
42466
+ messages,
42467
+ experimental_context
42468
+ });
42469
+ if (approvalNeeded) {
42470
+ approved.push(approval);
42471
+ } else {
42472
+ denied.push({
42473
+ ...approval,
42474
+ approvalResponse: {
42475
+ ...approval.approvalResponse,
42476
+ approved: false,
42477
+ reason: (_a222 = approval.approvalResponse.reason) != null ? _a222 : `Tool "${toolCall.toolName}" does not require approval`
42478
+ }
42479
+ });
42480
+ }
42481
+ }
42482
+ return { approvedToolApprovals: approved, deniedToolApprovals: denied };
42483
+ }
41709
42484
  function fixJson(input) {
41710
42485
  const stack = ["ROOT"];
41711
42486
  let lastValidIndex = -1;
41712
42487
  let literalStart = null;
42488
+ let unicodeEscapeDigits = 0;
42489
+ function isHexDigit(char) {
42490
+ return char >= "0" && char <= "9" || char >= "A" && char <= "F" || char >= "a" && char <= "f";
42491
+ }
41713
42492
  function processValueStart(char, i, swapState) {
41714
42493
  {
41715
42494
  switch (char) {
@@ -41914,7 +42693,22 @@ function fixJson(input) {
41914
42693
  }
41915
42694
  case "INSIDE_STRING_ESCAPE": {
41916
42695
  stack.pop();
41917
- lastValidIndex = i;
42696
+ if (char === "u") {
42697
+ unicodeEscapeDigits = 0;
42698
+ stack.push("INSIDE_STRING_UNICODE_ESCAPE");
42699
+ } else {
42700
+ lastValidIndex = i;
42701
+ }
42702
+ break;
42703
+ }
42704
+ case "INSIDE_STRING_UNICODE_ESCAPE": {
42705
+ if (isHexDigit(char)) {
42706
+ unicodeEscapeDigits++;
42707
+ if (unicodeEscapeDigits === 4) {
42708
+ stack.pop();
42709
+ lastValidIndex = i;
42710
+ }
42711
+ }
41918
42712
  break;
41919
42713
  }
41920
42714
  case "INSIDE_NUMBER": {
@@ -42171,8 +42965,8 @@ function isLoopFinished() {
42171
42965
  }
42172
42966
  function hasToolCall(toolName) {
42173
42967
  return ({ steps }) => {
42174
- var _a21, _b16, _c;
42175
- return (_c = (_b16 = (_a21 = steps[steps.length - 1]) == null ? undefined : _a21.toolCalls) == null ? undefined : _b16.some((toolCall) => toolCall.toolName === toolName)) != null ? _c : false;
42968
+ var _a222, _b16, _c;
42969
+ return (_c = (_b16 = (_a222 = steps[steps.length - 1]) == null ? undefined : _a222.toolCalls) == null ? undefined : _b16.some((toolCall) => toolCall.toolName === toolName)) != null ? _c : false;
42176
42970
  };
42177
42971
  }
42178
42972
  async function isStopConditionMet({
@@ -42268,7 +43062,8 @@ async function toResponseMessages({
42268
43062
  content.push({
42269
43063
  type: "tool-approval-request",
42270
43064
  approvalId: part.approvalId,
42271
- toolCallId: part.toolCall.toolCallId
43065
+ toolCallId: part.toolCall.toolCallId,
43066
+ ...part.signature != null ? { signature: part.signature } : {}
42272
43067
  });
42273
43068
  break;
42274
43069
  }
@@ -42351,6 +43146,7 @@ async function generateText({
42351
43146
  experimental_repairToolCall: repairToolCall,
42352
43147
  experimental_download: download2,
42353
43148
  experimental_context,
43149
+ experimental_toolApprovalSecret,
42354
43150
  experimental_include: include,
42355
43151
  _internal: { generateId: generateId2 = originalGenerateId } = {},
42356
43152
  experimental_onStart: onStart,
@@ -42443,11 +43239,27 @@ async function generateText({
42443
43239
  }),
42444
43240
  tracer,
42445
43241
  fn: async (span) => {
42446
- var _a21, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
43242
+ var _a222, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
42447
43243
  const initialMessages = initialPrompt.messages;
42448
43244
  const responseMessages = [];
42449
- const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
42450
- const localApprovedToolApprovals = approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted);
43245
+ const {
43246
+ approvedToolApprovals,
43247
+ deniedToolApprovals: collectedDeniedToolApprovals
43248
+ } = collectToolApprovals({ messages: initialMessages });
43249
+ const {
43250
+ approvedToolApprovals: localApprovedToolApprovals,
43251
+ deniedToolApprovals: revalidationDeniedToolApprovals
43252
+ } = await validateApprovedToolApprovals({
43253
+ approvedToolApprovals: approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted),
43254
+ tools,
43255
+ messages: initialMessages,
43256
+ experimental_context,
43257
+ toolApprovalSecret: experimental_toolApprovalSecret
43258
+ });
43259
+ const deniedToolApprovals = [
43260
+ ...collectedDeniedToolApprovals,
43261
+ ...revalidationDeniedToolApprovals
43262
+ ];
42451
43263
  if (deniedToolApprovals.length > 0 || localApprovedToolApprovals.length > 0) {
42452
43264
  const toolOutputs = await executeTools({
42453
43265
  toolCalls: localApprovedToolApprovals.map((toolApproval) => toolApproval.toolCall),
@@ -42524,7 +43336,7 @@ async function generateText({
42524
43336
  messages: stepInputMessages,
42525
43337
  experimental_context
42526
43338
  }));
42527
- const stepModel = resolveLanguageModel((_a21 = prepareStepResult == null ? undefined : prepareStepResult.model) != null ? _a21 : model);
43339
+ const stepModel = resolveLanguageModel((_a222 = prepareStepResult == null ? undefined : prepareStepResult.model) != null ? _a222 : model);
42528
43340
  const stepModelInfo = {
42529
43341
  provider: stepModel.provider,
42530
43342
  modelId: stepModel.modelId
@@ -42574,7 +43386,7 @@ async function generateText({
42574
43386
  ]
42575
43387
  });
42576
43388
  currentModelResponse = await retry(() => {
42577
- var _a222;
43389
+ var _a232;
42578
43390
  return recordSpan({
42579
43391
  name: "ai.generateText.doGenerate",
42580
43392
  attributes: selectTelemetryAttributes({
@@ -42602,14 +43414,14 @@ async function generateText({
42602
43414
  "gen_ai.request.max_tokens": settings.maxOutputTokens,
42603
43415
  "gen_ai.request.presence_penalty": settings.presencePenalty,
42604
43416
  "gen_ai.request.stop_sequences": settings.stopSequences,
42605
- "gen_ai.request.temperature": (_a222 = settings.temperature) != null ? _a222 : undefined,
43417
+ "gen_ai.request.temperature": (_a232 = settings.temperature) != null ? _a232 : undefined,
42606
43418
  "gen_ai.request.top_k": settings.topK,
42607
43419
  "gen_ai.request.top_p": settings.topP
42608
43420
  }
42609
43421
  }),
42610
43422
  tracer,
42611
43423
  fn: async (span2) => {
42612
- var _a232, _b23, _c2, _d2, _e2, _f2, _g2, _h2;
43424
+ var _a24, _b23, _c2, _d2, _e2, _f2, _g2, _h2;
42613
43425
  const result = await stepModel.doGenerate({
42614
43426
  ...callSettings2,
42615
43427
  tools: stepTools,
@@ -42621,7 +43433,7 @@ async function generateText({
42621
43433
  headers: headersWithUserAgent
42622
43434
  });
42623
43435
  const responseData = {
42624
- id: (_b23 = (_a232 = result.response) == null ? undefined : _a232.id) != null ? _b23 : generateId2(),
43436
+ id: (_b23 = (_a24 = result.response) == null ? undefined : _a24.id) != null ? _b23 : generateId2(),
42625
43437
  timestamp: (_d2 = (_c2 = result.response) == null ? undefined : _c2.timestamp) != null ? _d2 : /* @__PURE__ */ new Date,
42626
43438
  modelId: (_f2 = (_e2 = result.response) == null ? undefined : _e2.modelId) != null ? _f2 : stepModel.modelId,
42627
43439
  headers: (_g2 = result.response) == null ? undefined : _g2.headers,
@@ -42702,10 +43514,19 @@ async function generateText({
42702
43514
  messages: stepInputMessages,
42703
43515
  experimental_context
42704
43516
  })) {
43517
+ const approvalId = generateId2();
43518
+ const signature = await maybeSignApproval({
43519
+ secret: experimental_toolApprovalSecret,
43520
+ approvalId,
43521
+ toolCallId: toolCall.toolCallId,
43522
+ toolName: toolCall.toolName,
43523
+ input: toolCall.input
43524
+ });
42705
43525
  toolApprovalRequests[toolCall.toolCallId] = {
42706
43526
  type: "tool-approval-request",
42707
- approvalId: generateId2(),
42708
- toolCall
43527
+ approvalId,
43528
+ toolCall,
43529
+ ...signature != null ? { signature } : {}
42709
43530
  };
42710
43531
  }
42711
43532
  }
@@ -43162,6 +43983,9 @@ function getResponseUIMessageId({
43162
43983
  function isDataUIMessageChunk(chunk) {
43163
43984
  return chunk.type.startsWith("data-");
43164
43985
  }
43986
+ function createIdMap() {
43987
+ return /* @__PURE__ */ Object.create(null);
43988
+ }
43165
43989
  function isDataUIPart(part) {
43166
43990
  return part.type.startsWith("data-");
43167
43991
  }
@@ -43200,9 +44024,9 @@ function createStreamingUIMessageState({
43200
44024
  role: "assistant",
43201
44025
  parts: []
43202
44026
  },
43203
- activeTextParts: {},
43204
- activeReasoningParts: {},
43205
- partialToolCalls: {}
44027
+ activeTextParts: createIdMap(),
44028
+ activeReasoningParts: createIdMap(),
44029
+ partialToolCalls: createIdMap()
43206
44030
  };
43207
44031
  }
43208
44032
  function processUIMessageStream({
@@ -43217,7 +44041,7 @@ function processUIMessageStream({
43217
44041
  return stream.pipeThrough(new TransformStream({
43218
44042
  async transform(chunk, controller) {
43219
44043
  await runUpdateMessageJob(async ({ state, write }) => {
43220
- var _a21, _b16, _c, _d;
44044
+ var _a222, _b16, _c, _d;
43221
44045
  function getToolInvocation(toolCallId) {
43222
44046
  const toolInvocations = state.message.parts.filter(isToolUIPart);
43223
44047
  const toolInvocation = toolInvocations.find((invocation) => invocation.toolCallId === toolCallId);
@@ -43231,7 +44055,7 @@ function processUIMessageStream({
43231
44055
  return toolInvocation;
43232
44056
  }
43233
44057
  function updateToolPart(options) {
43234
- var _a222;
44058
+ var _a232;
43235
44059
  const part = state.message.parts.find((part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId);
43236
44060
  const anyOptions = options;
43237
44061
  const anyPart = part;
@@ -43248,7 +44072,7 @@ function processUIMessageStream({
43248
44072
  if (options.toolMetadata !== undefined) {
43249
44073
  anyPart.toolMetadata = options.toolMetadata;
43250
44074
  }
43251
- anyPart.providerExecuted = (_a222 = anyOptions.providerExecuted) != null ? _a222 : part.providerExecuted;
44075
+ anyPart.providerExecuted = (_a232 = anyOptions.providerExecuted) != null ? _a232 : part.providerExecuted;
43252
44076
  const providerMetadata = anyOptions.providerMetadata;
43253
44077
  if (providerMetadata != null) {
43254
44078
  if (options.state === "output-available" || options.state === "output-error") {
@@ -43277,7 +44101,7 @@ function processUIMessageStream({
43277
44101
  }
43278
44102
  }
43279
44103
  function updateDynamicToolPart(options) {
43280
- var _a222, _b23;
44104
+ var _a232, _b23;
43281
44105
  const part = state.message.parts.find((part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId);
43282
44106
  const anyOptions = options;
43283
44107
  const anyPart = part;
@@ -43287,7 +44111,7 @@ function processUIMessageStream({
43287
44111
  anyPart.input = anyOptions.input;
43288
44112
  anyPart.output = anyOptions.output;
43289
44113
  anyPart.errorText = anyOptions.errorText;
43290
- anyPart.rawInput = (_a222 = anyOptions.rawInput) != null ? _a222 : anyPart.rawInput;
44114
+ anyPart.rawInput = (_a232 = anyOptions.rawInput) != null ? _a232 : anyPart.rawInput;
43291
44115
  anyPart.preliminary = anyOptions.preliminary;
43292
44116
  if (options.title !== undefined) {
43293
44117
  anyPart.title = options.title;
@@ -43362,7 +44186,7 @@ function processUIMessageStream({
43362
44186
  });
43363
44187
  }
43364
44188
  textPart.text += chunk.delta;
43365
- textPart.providerMetadata = (_a21 = chunk.providerMetadata) != null ? _a21 : textPart.providerMetadata;
44189
+ textPart.providerMetadata = (_a222 = chunk.providerMetadata) != null ? _a222 : textPart.providerMetadata;
43366
44190
  write();
43367
44191
  break;
43368
44192
  }
@@ -43589,7 +44413,10 @@ function processUIMessageStream({
43589
44413
  case "tool-approval-request": {
43590
44414
  const toolInvocation = getToolInvocation(chunk.toolCallId);
43591
44415
  toolInvocation.state = "approval-requested";
43592
- toolInvocation.approval = { id: chunk.approvalId };
44416
+ toolInvocation.approval = {
44417
+ id: chunk.approvalId,
44418
+ ...chunk.signature != null ? { signature: chunk.signature } : {}
44419
+ };
43593
44420
  write();
43594
44421
  break;
43595
44422
  }
@@ -43667,8 +44494,8 @@ function processUIMessageStream({
43667
44494
  break;
43668
44495
  }
43669
44496
  case "finish-step": {
43670
- state.activeTextParts = {};
43671
- state.activeReasoningParts = {};
44497
+ state.activeTextParts = createIdMap();
44498
+ state.activeReasoningParts = createIdMap();
43672
44499
  break;
43673
44500
  }
43674
44501
  case "start": {
@@ -43860,13 +44687,13 @@ function createAsyncIterableStream(source) {
43860
44687
  const reader = this.getReader();
43861
44688
  let finished = false;
43862
44689
  async function cleanup(cancelStream) {
43863
- var _a21;
44690
+ var _a222;
43864
44691
  if (finished)
43865
44692
  return;
43866
44693
  finished = true;
43867
44694
  try {
43868
44695
  if (cancelStream) {
43869
- await ((_a21 = reader.cancel) == null ? undefined : _a21.call(reader));
44696
+ await ((_a222 = reader.cancel) == null ? undefined : _a222.call(reader));
43870
44697
  }
43871
44698
  } finally {
43872
44699
  try {
@@ -44009,6 +44836,7 @@ function runToolsTransformation({
44009
44836
  abortSignal,
44010
44837
  repairToolCall,
44011
44838
  experimental_context,
44839
+ toolApprovalSecret,
44012
44840
  generateId: generateId2,
44013
44841
  stepNumber,
44014
44842
  model,
@@ -44138,10 +44966,19 @@ function runToolsTransformation({
44138
44966
  messages,
44139
44967
  experimental_context
44140
44968
  })) {
44969
+ const approvalId = generateId2();
44970
+ const signature = await maybeSignApproval({
44971
+ secret: toolApprovalSecret,
44972
+ approvalId,
44973
+ toolCallId: toolCall.toolCallId,
44974
+ toolName: toolCall.toolName,
44975
+ input: toolCall.input
44976
+ });
44141
44977
  toolResultsStreamController.enqueue({
44142
44978
  type: "tool-approval-request",
44143
- approvalId: generateId2(),
44144
- toolCall
44979
+ approvalId,
44980
+ toolCall,
44981
+ ...signature != null ? { signature } : {}
44145
44982
  });
44146
44983
  break;
44147
44984
  }
@@ -44279,6 +45116,7 @@ function streamText({
44279
45116
  experimental_onToolCallStart: onToolCallStart,
44280
45117
  experimental_onToolCallFinish: onToolCallFinish,
44281
45118
  experimental_context,
45119
+ experimental_toolApprovalSecret,
44282
45120
  experimental_include: include,
44283
45121
  _internal: { now: now22 = now2, generateId: generateId2 = originalGenerateId2 } = {},
44284
45122
  ...settings
@@ -44328,6 +45166,7 @@ function streamText({
44328
45166
  now: now22,
44329
45167
  generateId: generateId2,
44330
45168
  experimental_context,
45169
+ experimental_toolApprovalSecret,
44331
45170
  download: download2,
44332
45171
  include
44333
45172
  });
@@ -44355,7 +45194,7 @@ function createOutputTransformStream(output) {
44355
45194
  }
44356
45195
  return new TransformStream({
44357
45196
  async transform(chunk, controller) {
44358
- var _a21;
45197
+ var _a222;
44359
45198
  if (chunk.type === "finish-step" && textChunk.length > 0) {
44360
45199
  publishTextChunk({ controller });
44361
45200
  }
@@ -44382,7 +45221,7 @@ function createOutputTransformStream(output) {
44382
45221
  }
44383
45222
  text2 += chunk.text;
44384
45223
  textChunk += chunk.text;
44385
- textProviderMetadata = (_a21 = chunk.providerMetadata) != null ? _a21 : textProviderMetadata;
45224
+ textProviderMetadata = (_a222 = chunk.providerMetadata) != null ? _a222 : textProviderMetadata;
44386
45225
  const result = await output.parsePartialOutput({ text: text2 });
44387
45226
  if (result !== undefined) {
44388
45227
  const currentValue = typeof result.partial === "string" ? result.partial : JSON.stringify(result.partial);
@@ -44396,7 +45235,7 @@ function createOutputTransformStream(output) {
44396
45235
  }
44397
45236
  function createUIMessageStream({
44398
45237
  execute,
44399
- onError = getErrorMessage2,
45238
+ onError = () => "An error occurred.",
44400
45239
  originalMessages,
44401
45240
  onStepFinish,
44402
45241
  onFinish,
@@ -44479,7 +45318,7 @@ function readUIMessageStream({
44479
45318
  onError,
44480
45319
  terminateOnError = false
44481
45320
  }) {
44482
- var _a21;
45321
+ var _a222;
44483
45322
  let controller;
44484
45323
  let hasErrored = false;
44485
45324
  const outputStream = new ReadableStream({
@@ -44488,7 +45327,7 @@ function readUIMessageStream({
44488
45327
  }
44489
45328
  });
44490
45329
  const state = createStreamingUIMessageState({
44491
- messageId: (_a21 = message == null ? undefined : message.id) != null ? _a21 : "",
45330
+ messageId: (_a222 = message == null ? undefined : message.id) != null ? _a222 : "",
44492
45331
  lastMessage: message
44493
45332
  });
44494
45333
  const handleError = (error40) => {
@@ -44548,7 +45387,7 @@ async function convertToModelMessages(messages, options) {
44548
45387
  modelMessages.push({
44549
45388
  role: "user",
44550
45389
  content: message.parts.map((part) => {
44551
- var _a21;
45390
+ var _a222;
44552
45391
  if (isTextUIPart(part)) {
44553
45392
  return {
44554
45393
  type: "text",
@@ -44566,7 +45405,7 @@ async function convertToModelMessages(messages, options) {
44566
45405
  };
44567
45406
  }
44568
45407
  if (isDataUIPart(part)) {
44569
- return (_a21 = options == null ? undefined : options.convertDataPart) == null ? undefined : _a21.call(options, part);
45408
+ return (_a222 = options == null ? undefined : options.convertDataPart) == null ? undefined : _a222.call(options, part);
44570
45409
  }
44571
45410
  }).filter(isNonNullable)
44572
45411
  });
@@ -44576,7 +45415,7 @@ async function convertToModelMessages(messages, options) {
44576
45415
  if (message.parts != null) {
44577
45416
  let block = [];
44578
45417
  async function processBlock() {
44579
- var _a21, _b16, _c, _d, _e, _f, _g, _h;
45418
+ var _a222, _b16, _c, _d, _e, _f, _g, _h;
44580
45419
  if (block.length === 0) {
44581
45420
  return;
44582
45421
  }
@@ -44609,7 +45448,7 @@ async function convertToModelMessages(messages, options) {
44609
45448
  type: "tool-call",
44610
45449
  toolCallId: part.toolCallId,
44611
45450
  toolName,
44612
- input: part.state === "output-error" ? (_a21 = part.input) != null ? _a21 : ("rawInput" in part) ? part.rawInput : undefined : part.input,
45451
+ input: part.state === "output-error" ? (_a222 = part.input) != null ? _a222 : ("rawInput" in part) ? part.rawInput : undefined : part.input,
44613
45452
  providerExecuted: part.providerExecuted,
44614
45453
  ...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}
44615
45454
  });
@@ -44617,7 +45456,8 @@ async function convertToModelMessages(messages, options) {
44617
45456
  content.push({
44618
45457
  type: "tool-approval-request",
44619
45458
  approvalId: part.approval.id,
44620
- toolCallId: part.toolCallId
45459
+ toolCallId: part.toolCallId,
45460
+ ...part.approval.signature != null ? { signature: part.approval.signature } : {}
44621
45461
  });
44622
45462
  }
44623
45463
  if (part.providerExecuted === true && part.state !== "approval-responded" && (part.state === "output-available" || part.state === "output-error")) {
@@ -44652,8 +45492,8 @@ async function convertToModelMessages(messages, options) {
44652
45492
  content
44653
45493
  });
44654
45494
  const toolParts = block.filter((part) => {
44655
- var _a222;
44656
- return isToolUIPart(part) && (part.providerExecuted !== true || ((_a222 = part.approval) == null ? undefined : _a222.approved) != null);
45495
+ var _a232;
45496
+ return isToolUIPart(part) && (part.providerExecuted !== true || ((_a232 = part.approval) == null ? undefined : _a232.approved) != null);
44657
45497
  });
44658
45498
  if (toolParts.length > 0) {
44659
45499
  {
@@ -44887,7 +45727,7 @@ async function createAgentUIStream({
44887
45727
  onStepFinish,
44888
45728
  ...uiMessageStreamOptions
44889
45729
  }) {
44890
- var _a21;
45730
+ var _a222;
44891
45731
  const validatedMessages = await validateUIMessages({
44892
45732
  messages: uiMessages,
44893
45733
  tools: agent.tools
@@ -44905,7 +45745,7 @@ async function createAgentUIStream({
44905
45745
  });
44906
45746
  return result.toUIMessageStream({
44907
45747
  ...uiMessageStreamOptions,
44908
- originalMessages: (_a21 = uiMessageStreamOptions.originalMessages) != null ? _a21 : validatedMessages
45748
+ originalMessages: (_a222 = uiMessageStreamOptions.originalMessages) != null ? _a222 : validatedMessages
44909
45749
  });
44910
45750
  }
44911
45751
  async function createAgentUIStreamResponse({
@@ -44989,7 +45829,7 @@ async function embed({
44989
45829
  }),
44990
45830
  tracer,
44991
45831
  fn: async (doEmbedSpan) => {
44992
- var _a21, _b16;
45832
+ var _a222, _b16;
44993
45833
  const modelResponse = await model.doEmbed({
44994
45834
  values: [value],
44995
45835
  abortSignal,
@@ -44997,7 +45837,7 @@ async function embed({
44997
45837
  providerOptions
44998
45838
  });
44999
45839
  const embedding2 = modelResponse.embeddings[0];
45000
- const usage2 = (_a21 = modelResponse.usage) != null ? _a21 : { tokens: NaN };
45840
+ const usage2 = (_a222 = modelResponse.usage) != null ? _a222 : { tokens: NaN };
45001
45841
  doEmbedSpan.setAttributes(await selectTelemetryAttributes({
45002
45842
  telemetry,
45003
45843
  attributes: {
@@ -45082,7 +45922,7 @@ async function embedMany({
45082
45922
  }),
45083
45923
  tracer,
45084
45924
  fn: async (span) => {
45085
- var _a21;
45925
+ var _a222;
45086
45926
  const [maxEmbeddingsPerCall, supportsParallelCalls] = await Promise.all([
45087
45927
  model.maxEmbeddingsPerCall,
45088
45928
  model.supportsParallelCalls
@@ -45106,7 +45946,7 @@ async function embedMany({
45106
45946
  }),
45107
45947
  tracer,
45108
45948
  fn: async (doEmbedSpan) => {
45109
- var _a222, _b16;
45949
+ var _a232, _b16;
45110
45950
  const modelResponse = await model.doEmbed({
45111
45951
  values,
45112
45952
  abortSignal,
@@ -45114,7 +45954,7 @@ async function embedMany({
45114
45954
  providerOptions
45115
45955
  });
45116
45956
  const embeddings3 = modelResponse.embeddings;
45117
- const usage2 = (_a222 = modelResponse.usage) != null ? _a222 : { tokens: NaN };
45957
+ const usage2 = (_a232 = modelResponse.usage) != null ? _a232 : { tokens: NaN };
45118
45958
  doEmbedSpan.setAttributes(await selectTelemetryAttributes({
45119
45959
  telemetry,
45120
45960
  attributes: {
@@ -45184,7 +46024,7 @@ async function embedMany({
45184
46024
  }),
45185
46025
  tracer,
45186
46026
  fn: async (doEmbedSpan) => {
45187
- var _a222, _b16;
46027
+ var _a232, _b16;
45188
46028
  const modelResponse = await model.doEmbed({
45189
46029
  values: chunk,
45190
46030
  abortSignal,
@@ -45192,7 +46032,7 @@ async function embedMany({
45192
46032
  providerOptions
45193
46033
  });
45194
46034
  const embeddings2 = modelResponse.embeddings;
45195
- const usage = (_a222 = modelResponse.usage) != null ? _a222 : { tokens: NaN };
46035
+ const usage = (_a232 = modelResponse.usage) != null ? _a232 : { tokens: NaN };
45196
46036
  doEmbedSpan.setAttributes(await selectTelemetryAttributes({
45197
46037
  telemetry,
45198
46038
  attributes: {
@@ -45224,7 +46064,7 @@ async function embedMany({
45224
46064
  } else {
45225
46065
  for (const [providerName, metadata] of Object.entries(result.providerMetadata)) {
45226
46066
  providerMetadata[providerName] = {
45227
- ...(_a21 = providerMetadata[providerName]) != null ? _a21 : {},
46067
+ ...(_a222 = providerMetadata[providerName]) != null ? _a222 : {},
45228
46068
  ...metadata
45229
46069
  };
45230
46070
  }
@@ -45270,14 +46110,14 @@ async function generateImage({
45270
46110
  abortSignal,
45271
46111
  headers
45272
46112
  }) {
45273
- var _a21, _b16;
46113
+ var _a222, _b16;
45274
46114
  const model = resolveImageModel(modelArg);
45275
46115
  const headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION6}`);
45276
46116
  const { retry } = prepareRetries({
45277
46117
  maxRetries: maxRetriesArg,
45278
46118
  abortSignal
45279
46119
  });
45280
- const maxImagesPerCallWithDefault = (_a21 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a21 : 1;
46120
+ const maxImagesPerCallWithDefault = (_a222 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a222 : 1;
45281
46121
  const callCount = Math.ceil(n / maxImagesPerCallWithDefault);
45282
46122
  const callImageCounts = Array.from({ length: callCount }, (_, i) => {
45283
46123
  if (i < callCount - 1) {
@@ -45312,13 +46152,13 @@ async function generateImage({
45312
46152
  };
45313
46153
  for (const result of results) {
45314
46154
  images.push(...result.images.map((image) => {
45315
- var _a222;
46155
+ var _a232;
45316
46156
  return new DefaultGeneratedFile({
45317
46157
  data: image,
45318
- mediaType: (_a222 = detectMediaType({
46158
+ mediaType: (_a232 = detectMediaType({
45319
46159
  data: image,
45320
46160
  signatures: imageMediaTypeSignatures
45321
- })) != null ? _a222 : "image/png"
46161
+ })) != null ? _a232 : "image/png"
45322
46162
  });
45323
46163
  }));
45324
46164
  warnings.push(...result.warnings);
@@ -45669,7 +46509,7 @@ async function generateObject(options) {
45669
46509
  }),
45670
46510
  tracer,
45671
46511
  fn: async (span) => {
45672
- var _a21;
46512
+ var _a222;
45673
46513
  let result;
45674
46514
  let finishReason;
45675
46515
  let usage;
@@ -45714,7 +46554,7 @@ async function generateObject(options) {
45714
46554
  }),
45715
46555
  tracer,
45716
46556
  fn: async (span2) => {
45717
- var _a222, _b16, _c, _d, _e, _f, _g, _h;
46557
+ var _a232, _b16, _c, _d, _e, _f, _g, _h;
45718
46558
  const result2 = await model.doGenerate({
45719
46559
  responseFormat: {
45720
46560
  type: "json",
@@ -45729,7 +46569,7 @@ async function generateObject(options) {
45729
46569
  headers: headersWithUserAgent
45730
46570
  });
45731
46571
  const responseData = {
45732
- id: (_b16 = (_a222 = result2.response) == null ? undefined : _a222.id) != null ? _b16 : generateId2(),
46572
+ id: (_b16 = (_a232 = result2.response) == null ? undefined : _a232.id) != null ? _b16 : generateId2(),
45733
46573
  timestamp: (_d = (_c = result2.response) == null ? undefined : _c.timestamp) != null ? _d : currentDate(),
45734
46574
  modelId: (_f = (_e = result2.response) == null ? undefined : _e.modelId) != null ? _f : model.modelId,
45735
46575
  headers: (_g = result2.response) == null ? undefined : _g.headers,
@@ -45778,7 +46618,7 @@ async function generateObject(options) {
45778
46618
  usage = asLanguageModelUsage(generateResult.usage);
45779
46619
  warnings = generateResult.warnings;
45780
46620
  resultProviderMetadata = generateResult.providerMetadata;
45781
- request = (_a21 = generateResult.request) != null ? _a21 : {};
46621
+ request = (_a222 = generateResult.request) != null ? _a222 : {};
45782
46622
  response = generateResult.responseData;
45783
46623
  reasoning = generateResult.reasoning;
45784
46624
  logWarnings({
@@ -45897,8 +46737,8 @@ function simulateReadableStream({
45897
46737
  chunkDelayInMs = 0,
45898
46738
  _internal
45899
46739
  }) {
45900
- var _a21;
45901
- const delay2 = (_a21 = _internal == null ? undefined : _internal.delay) != null ? _a21 : delay;
46740
+ var _a222;
46741
+ const delay2 = (_a222 = _internal == null ? undefined : _internal.delay) != null ? _a222 : delay;
45902
46742
  let index = 0;
45903
46743
  return new ReadableStream({
45904
46744
  async pull(controller) {
@@ -45992,7 +46832,7 @@ async function generateSpeech({
45992
46832
  abortSignal,
45993
46833
  headers
45994
46834
  }) {
45995
- var _a21;
46835
+ var _a222;
45996
46836
  const resolvedModel = resolveSpeechModel(model);
45997
46837
  if (!resolvedModel) {
45998
46838
  throw new Error("Model could not be resolved");
@@ -46024,10 +46864,10 @@ async function generateSpeech({
46024
46864
  return new DefaultSpeechResult({
46025
46865
  audio: new DefaultGeneratedAudioFile({
46026
46866
  data: result.audio,
46027
- mediaType: (_a21 = detectMediaType({
46867
+ mediaType: (_a222 = detectMediaType({
46028
46868
  data: result.audio,
46029
46869
  signatures: audioMediaTypeSignatures
46030
- })) != null ? _a21 : "audio/mp3"
46870
+ })) != null ? _a222 : "audio/mp3"
46031
46871
  }),
46032
46872
  warnings: result.warnings,
46033
46873
  responses: [result.response],
@@ -46077,27 +46917,44 @@ function pruneMessages({
46077
46917
  }
46078
46918
  }
46079
46919
  }
46920
+ const toolCallIdToToolName = /* @__PURE__ */ new Map;
46921
+ for (const message of messages) {
46922
+ if ((message.role === "assistant" || message.role === "tool") && typeof message.content !== "string") {
46923
+ for (const part of message.content) {
46924
+ if (part.type === "tool-call" || part.type === "tool-result") {
46925
+ toolCallIdToToolName.set(part.toolCallId, part.toolName);
46926
+ }
46927
+ }
46928
+ }
46929
+ }
46930
+ const approvalIdToToolName = /* @__PURE__ */ new Map;
46931
+ for (const message of messages) {
46932
+ if ((message.role === "assistant" || message.role === "tool") && typeof message.content !== "string") {
46933
+ for (const part of message.content) {
46934
+ if (part.type === "tool-approval-request") {
46935
+ const toolName = toolCallIdToToolName.get(part.toolCallId);
46936
+ if (toolName != null) {
46937
+ approvalIdToToolName.set(part.approvalId, toolName);
46938
+ }
46939
+ }
46940
+ }
46941
+ }
46942
+ }
46080
46943
  messages = messages.map((message, messageIndex) => {
46081
46944
  if (message.role !== "assistant" && message.role !== "tool" || typeof message.content === "string" || keepLastMessagesCount && messageIndex >= messages.length - keepLastMessagesCount) {
46082
46945
  return message;
46083
46946
  }
46084
- const toolCallIdToToolName = {};
46085
- const approvalIdToToolName = {};
46086
46947
  return {
46087
46948
  ...message,
46088
46949
  content: message.content.filter((part) => {
46089
46950
  if (part.type !== "tool-call" && part.type !== "tool-result" && part.type !== "tool-approval-request" && part.type !== "tool-approval-response") {
46090
46951
  return true;
46091
46952
  }
46092
- if (part.type === "tool-call") {
46093
- toolCallIdToToolName[part.toolCallId] = part.toolName;
46094
- } else if (part.type === "tool-approval-request") {
46095
- approvalIdToToolName[part.approvalId] = toolCallIdToToolName[part.toolCallId];
46096
- }
46097
46953
  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)) {
46098
46954
  return true;
46099
46955
  }
46100
- return toolCall.tools != null && !toolCall.tools.includes(part.type === "tool-call" || part.type === "tool-result" ? part.toolName : approvalIdToToolName[part.approvalId]);
46956
+ const partToolName = part.type === "tool-call" || part.type === "tool-result" ? part.toolName : approvalIdToToolName.get(part.approvalId);
46957
+ return toolCall.tools != null && partToolName != null && !toolCall.tools.includes(partToolName);
46101
46958
  })
46102
46959
  };
46103
46960
  });
@@ -46205,13 +47062,16 @@ async function experimental_generateVideo({
46205
47062
  duration: duration3,
46206
47063
  fps,
46207
47064
  seed,
47065
+ frameImages,
47066
+ inputReferences,
47067
+ generateAudio,
46208
47068
  providerOptions,
46209
47069
  maxRetries: maxRetriesArg,
46210
47070
  abortSignal,
46211
47071
  headers,
46212
47072
  download: downloadFn = defaultDownload
46213
47073
  }) {
46214
- var _a21;
47074
+ var _a222, _b16;
46215
47075
  const model = resolveVideoModel(modelArg);
46216
47076
  const headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION6}`);
46217
47077
  const { retry } = prepareRetries({
@@ -46219,13 +47079,34 @@ async function experimental_generateVideo({
46219
47079
  abortSignal
46220
47080
  });
46221
47081
  const { prompt, image } = normalizePrompt2(promptArg);
46222
- const maxVideosPerCallWithDefault = (_a21 = maxVideosPerCall != null ? maxVideosPerCall : await invokeModelMaxVideosPerCall(model)) != null ? _a21 : 1;
47082
+ const normalizedFrameImages = frameImages == null ? undefined : frameImages.map((frame) => ({
47083
+ image: normalizeImageData(frame.image),
47084
+ frameType: frame.frameType
47085
+ }));
47086
+ const normalizedInputReferences = inputReferences == null ? undefined : inputReferences.map((reference) => normalizeImageData(reference));
47087
+ const effectiveInputReferences = normalizedFrameImages != null && normalizedFrameImages.length > 0 ? undefined : normalizedInputReferences;
47088
+ const warnings = [];
47089
+ if (normalizedFrameImages != null && normalizedFrameImages.length > 0 && normalizedInputReferences != null && normalizedInputReferences.length > 0) {
47090
+ warnings.push({
47091
+ type: "other",
47092
+ message: "inputReferences were ignored because frameImages were provided; frameImages and inputReferences cannot be combined."
47093
+ });
47094
+ }
47095
+ const firstFrameImage = (_a222 = normalizedFrameImages == null ? undefined : normalizedFrameImages.find((frame) => frame.frameType === "first_frame")) == null ? undefined : _a222.image;
47096
+ if (image != null && firstFrameImage != null) {
47097
+ warnings.push({
47098
+ type: "other",
47099
+ message: "prompt.image was ignored because a first_frame frameImage was provided; the first_frame frameImage takes precedence as the start image."
47100
+ });
47101
+ }
47102
+ const resolvedImage = firstFrameImage != null ? firstFrameImage : image;
47103
+ const maxVideosPerCallWithDefault = (_b16 = maxVideosPerCall != null ? maxVideosPerCall : await invokeModelMaxVideosPerCall(model)) != null ? _b16 : 1;
46223
47104
  const callCount = Math.ceil(n / maxVideosPerCallWithDefault);
46224
47105
  const callVideoCounts = Array.from({ length: callCount }, (_, index) => {
46225
47106
  const remaining = n - index * maxVideosPerCallWithDefault;
46226
47107
  return Math.min(remaining, maxVideosPerCallWithDefault);
46227
47108
  });
46228
- const results = await Promise.all(callVideoCounts.map(async (callVideoCount) => retry(() => model.doGenerate({
47109
+ const results = await Promise.all(callVideoCounts.map(async (callVideoCount) => await retry(() => model.doGenerate({
46229
47110
  prompt,
46230
47111
  n: callVideoCount,
46231
47112
  aspectRatio,
@@ -46233,13 +47114,15 @@ async function experimental_generateVideo({
46233
47114
  duration: duration3,
46234
47115
  fps,
46235
47116
  seed,
46236
- image,
47117
+ image: resolvedImage,
47118
+ frameImages: normalizedFrameImages,
47119
+ inputReferences: effectiveInputReferences,
47120
+ generateAudio,
46237
47121
  providerOptions: providerOptions != null ? providerOptions : {},
46238
47122
  headers: headersWithUserAgent,
46239
47123
  abortSignal
46240
47124
  }))));
46241
47125
  const videos = [];
46242
- const warnings = [];
46243
47126
  const responses = [];
46244
47127
  const providerMetadata = {};
46245
47128
  for (const result of results) {
@@ -46327,56 +47210,49 @@ async function experimental_generateVideo({
46327
47210
  };
46328
47211
  }
46329
47212
  function normalizePrompt2(promptArg) {
46330
- var _a21, _b16;
46331
47213
  if (typeof promptArg === "string") {
46332
47214
  return {
46333
47215
  prompt: promptArg,
46334
47216
  image: undefined
46335
47217
  };
46336
47218
  }
46337
- let image;
46338
- if (promptArg.image != null) {
46339
- const dataContent = promptArg.image;
46340
- if (typeof dataContent === "string") {
46341
- if (dataContent.startsWith("http://") || dataContent.startsWith("https://")) {
46342
- image = {
46343
- type: "url",
46344
- url: dataContent
46345
- };
46346
- } else if (dataContent.startsWith("data:")) {
46347
- const { mediaType, base64Content } = splitDataUrl(dataContent);
46348
- image = {
46349
- type: "file",
46350
- mediaType: mediaType != null ? mediaType : "image/png",
46351
- data: convertBase64ToUint8Array(base64Content != null ? base64Content : "")
46352
- };
46353
- } else {
46354
- const bytes = convertBase64ToUint8Array(dataContent);
46355
- const mediaType = (_a21 = detectMediaType({
46356
- data: bytes,
46357
- signatures: imageMediaTypeSignatures
46358
- })) != null ? _a21 : "image/png";
46359
- image = {
46360
- type: "file",
46361
- mediaType,
46362
- data: bytes
46363
- };
46364
- }
46365
- } else if (dataContent instanceof Uint8Array) {
46366
- const mediaType = (_b16 = detectMediaType({
46367
- data: dataContent,
46368
- signatures: imageMediaTypeSignatures
46369
- })) != null ? _b16 : "image/png";
46370
- image = {
47219
+ return {
47220
+ prompt: promptArg.text,
47221
+ image: promptArg.image != null ? normalizeImageData(promptArg.image) : undefined
47222
+ };
47223
+ }
47224
+ function normalizeImageData(dataContent) {
47225
+ var _a222, _b16;
47226
+ if (typeof dataContent === "string") {
47227
+ if (dataContent.startsWith("http://") || dataContent.startsWith("https://")) {
47228
+ return {
47229
+ type: "url",
47230
+ url: dataContent
47231
+ };
47232
+ }
47233
+ if (dataContent.startsWith("data:")) {
47234
+ const { mediaType, base64Content } = splitDataUrl(dataContent);
47235
+ return {
46371
47236
  type: "file",
46372
- mediaType,
46373
- data: dataContent
47237
+ mediaType: mediaType != null ? mediaType : "image/png",
47238
+ data: convertBase64ToUint8Array(base64Content != null ? base64Content : "")
46374
47239
  };
46375
47240
  }
47241
+ const bytes2 = convertBase64ToUint8Array(dataContent);
47242
+ return {
47243
+ type: "file",
47244
+ mediaType: (_a222 = detectMediaType({
47245
+ data: bytes2,
47246
+ signatures: imageMediaTypeSignatures
47247
+ })) != null ? _a222 : "image/png",
47248
+ data: bytes2
47249
+ };
46376
47250
  }
47251
+ const bytes = convertDataContentToUint8Array(dataContent);
46377
47252
  return {
46378
- prompt: promptArg.text,
46379
- image
47253
+ type: "file",
47254
+ mediaType: (_b16 = detectMediaType({ data: bytes, signatures: imageMediaTypeSignatures })) != null ? _b16 : "image/png",
47255
+ data: bytes
46380
47256
  };
46381
47257
  }
46382
47258
  async function invokeModelMaxVideosPerCall(model) {
@@ -46409,8 +47285,8 @@ function defaultTransform(text2) {
46409
47285
  return text2.replace(/^```(?:json)?\s*\n?/, "").replace(/\n?```\s*$/, "").trim();
46410
47286
  }
46411
47287
  function extractJsonMiddleware(options) {
46412
- var _a21;
46413
- const transform2 = (_a21 = options == null ? undefined : options.transform) != null ? _a21 : defaultTransform;
47288
+ var _a222;
47289
+ const transform2 = (_a222 = options == null ? undefined : options.transform) != null ? _a222 : defaultTransform;
46414
47290
  const hasCustomTransform = (options == null ? undefined : options.transform) !== undefined;
46415
47291
  return {
46416
47292
  specificationVersion: "v3",
@@ -46431,7 +47307,7 @@ function extractJsonMiddleware(options) {
46431
47307
  },
46432
47308
  wrapStream: async ({ doStream }) => {
46433
47309
  const { stream, ...rest } = await doStream();
46434
- const textBlocks = {};
47310
+ const textBlocks = createIdMap();
46435
47311
  const SUFFIX_BUFFER_SIZE = 12;
46436
47312
  return {
46437
47313
  stream: stream.pipeThrough(new TransformStream({
@@ -46585,7 +47461,7 @@ function extractReasoningMiddleware({
46585
47461
  },
46586
47462
  wrapStream: async ({ doStream }) => {
46587
47463
  const { stream, ...rest } = await doStream();
46588
- const reasoningExtractions = {};
47464
+ const reasoningExtractions = createIdMap();
46589
47465
  let delayedTextStart;
46590
47466
  return {
46591
47467
  stream: stream.pipeThrough(new TransformStream({
@@ -46764,13 +47640,13 @@ function addToolInputExamplesMiddleware({
46764
47640
  return {
46765
47641
  specificationVersion: "v3",
46766
47642
  transformParams: async ({ params }) => {
46767
- var _a21;
46768
- if (!((_a21 = params.tools) == null ? undefined : _a21.length)) {
47643
+ var _a222;
47644
+ if (!((_a222 = params.tools) == null ? undefined : _a222.length)) {
46769
47645
  return params;
46770
47646
  }
46771
47647
  const transformedTools = params.tools.map((tool2) => {
46772
- var _a222;
46773
- if (tool2.type !== "function" || !((_a222 = tool2.inputExamples) == null ? undefined : _a222.length)) {
47648
+ var _a232;
47649
+ if (tool2.type !== "function" || !((_a232 = tool2.inputExamples) == null ? undefined : _a232.length)) {
46774
47650
  return tool2;
46775
47651
  }
46776
47652
  const formattedExamples = tool2.inputExamples.map((example, index) => format(example, index)).join(`
@@ -46976,7 +47852,7 @@ async function rerank({
46976
47852
  }),
46977
47853
  tracer,
46978
47854
  fn: async () => {
46979
- var _a21, _b16;
47855
+ var _a222, _b16;
46980
47856
  const { ranking, response, providerMetadata, warnings } = await retry(() => recordSpan({
46981
47857
  name: "ai.rerank.doRerank",
46982
47858
  attributes: selectTelemetryAttributes({
@@ -47035,7 +47911,7 @@ async function rerank({
47035
47911
  providerMetadata,
47036
47912
  response: {
47037
47913
  id: response == null ? undefined : response.id,
47038
- timestamp: (_a21 = response == null ? undefined : response.timestamp) != null ? _a21 : /* @__PURE__ */ new Date,
47914
+ timestamp: (_a222 = response == null ? undefined : response.timestamp) != null ? _a222 : /* @__PURE__ */ new Date,
47039
47915
  modelId: (_b16 = response == null ? undefined : response.modelId) != null ? _b16 : model.modelId,
47040
47916
  headers: response == null ? undefined : response.headers,
47041
47917
  body: response == null ? undefined : response.body
@@ -47064,16 +47940,16 @@ async function transcribe({
47064
47940
  const headersWithUserAgent = withUserAgentSuffix(headers != null ? headers : {}, `ai/${VERSION6}`);
47065
47941
  const audioData = audio instanceof URL ? (await downloadFn({ url: audio, abortSignal })).data : convertDataContentToUint8Array(audio);
47066
47942
  const result = await retry(() => {
47067
- var _a21;
47943
+ var _a222;
47068
47944
  return resolvedModel.doGenerate({
47069
47945
  audio: audioData,
47070
47946
  abortSignal,
47071
47947
  headers: headersWithUserAgent,
47072
47948
  providerOptions,
47073
- mediaType: (_a21 = detectMediaType({
47949
+ mediaType: (_a222 = detectMediaType({
47074
47950
  data: audioData,
47075
47951
  signatures: audioMediaTypeSignatures
47076
- })) != null ? _a21 : "audio/wav"
47952
+ })) != null ? _a222 : "audio/wav"
47077
47953
  });
47078
47954
  });
47079
47955
  logWarnings({
@@ -47122,7 +47998,7 @@ async function callCompletionApi({
47122
47998
  onError,
47123
47999
  fetch: fetch2 = getOriginalFetch3()
47124
48000
  }) {
47125
- var _a21;
48001
+ var _a222;
47126
48002
  try {
47127
48003
  setLoading(true);
47128
48004
  setError(undefined);
@@ -47145,7 +48021,7 @@ async function callCompletionApi({
47145
48021
  throw err;
47146
48022
  });
47147
48023
  if (!response.ok) {
47148
- throw new Error((_a21 = await response.text()) != null ? _a21 : "Failed to fetch the chat response.");
48024
+ throw new Error((_a222 = await response.text()) != null ? _a222 : "Failed to fetch the chat response.");
47149
48025
  }
47150
48026
  if (!response.body) {
47151
48027
  throw new Error("The response body is empty.");
@@ -47220,12 +48096,12 @@ async function convertFileListToFileUIParts(files) {
47220
48096
  throw new Error("FileList is not supported in the current environment");
47221
48097
  }
47222
48098
  return Promise.all(Array.from(files).map(async (file2) => {
47223
- const { name: name21, type } = file2;
48099
+ const { name: name222, type } = file2;
47224
48100
  const dataUrl = await new Promise((resolve32, reject) => {
47225
48101
  const reader = new FileReader;
47226
48102
  reader.onload = (readerEvent) => {
47227
- var _a21;
47228
- resolve32((_a21 = readerEvent.target) == null ? undefined : _a21.result);
48103
+ var _a222;
48104
+ resolve32((_a222 = readerEvent.target) == null ? undefined : _a222.result);
47229
48105
  };
47230
48106
  reader.onerror = (error40) => reject(error40);
47231
48107
  reader.readAsDataURL(file2);
@@ -47233,7 +48109,7 @@ async function convertFileListToFileUIParts(files) {
47233
48109
  return {
47234
48110
  type: "file",
47235
48111
  mediaType: type,
47236
- filename: name21,
48112
+ filename: name222,
47237
48113
  url: dataUrl
47238
48114
  };
47239
48115
  }));
@@ -47290,9 +48166,9 @@ function transformTextToUiMessageStream({
47290
48166
  }));
47291
48167
  }
47292
48168
  var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47293
- for (var name21 in all)
47294
- __defProp2(target, name21, { get: all[name21], enumerable: true });
47295
- }, 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) => {
48169
+ for (var name222 in all)
48170
+ __defProp2(target, name222, { get: all[name222], enumerable: true });
48171
+ }, 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) => {
47296
48172
  if (options.warnings.length === 0) {
47297
48173
  return;
47298
48174
  }
@@ -47319,23 +48195,22 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47319
48195
  const bytes = typeof data === "string" ? convertBase64ToUint8Array(data) : data;
47320
48196
  const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
47321
48197
  return bytes.slice(id3Size + 10);
47322
- }, VERSION6 = "6.0.199", download = async ({
48198
+ }, VERSION6 = "6.0.219", download = async ({
47323
48199
  url: url2,
47324
48200
  maxBytes,
47325
48201
  abortSignal
47326
48202
  }) => {
47327
- var _a21;
48203
+ var _a222;
47328
48204
  const urlText = url2.toString();
47329
- validateDownloadUrl(urlText);
47330
48205
  try {
47331
- const response = await fetch(urlText, {
47332
- headers: withUserAgentSuffix({}, `ai-sdk/${VERSION6}`, getRuntimeEnvironmentUserAgent()),
47333
- signal: abortSignal
48206
+ const headers = withUserAgentSuffix({}, `ai-sdk/${VERSION6}`, getRuntimeEnvironmentUserAgent());
48207
+ const response = await fetchWithValidatedRedirects({
48208
+ url: urlText,
48209
+ headers,
48210
+ abortSignal
47334
48211
  });
47335
- if (response.redirected) {
47336
- validateDownloadUrl(response.url);
47337
- }
47338
48212
  if (!response.ok) {
48213
+ await cancelResponseBody(response);
47339
48214
  throw new DownloadError({
47340
48215
  url: urlText,
47341
48216
  statusCode: response.status,
@@ -47349,7 +48224,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47349
48224
  });
47350
48225
  return {
47351
48226
  data,
47352
- mediaType: (_a21 = response.headers.get("content-type")) != null ? _a21 : undefined
48227
+ mediaType: (_a222 = response.headers.get("content-type")) != null ? _a222 : undefined
47353
48228
  };
47354
48229
  } catch (error40) {
47355
48230
  if (DownloadError.isInstance(error40)) {
@@ -47362,11 +48237,17 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47362
48237
  initialDelayInMs = 2000,
47363
48238
  backoffFactor = 2,
47364
48239
  abortSignal
47365
- } = {}) => async (f) => _retryWithExponentialBackoff(f, {
48240
+ } = {}) => retryWithExponentialBackoff({
47366
48241
  maxRetries,
47367
- delayInMs: initialDelayInMs,
48242
+ initialDelayInMs,
47368
48243
  backoffFactor,
47369
- abortSignal
48244
+ abortSignal,
48245
+ shouldRetry: (error40) => error40 instanceof Error && (APICallError.isInstance(error40) && error40.isRetryable === true || GatewayError.isInstance(error40) && error40.isRetryable === true),
48246
+ getDelayInMs: ({ error: error40, exponentialBackoffDelay }) => getRetryDelayInMs({
48247
+ error: error40,
48248
+ exponentialBackoffDelay
48249
+ }),
48250
+ createRetryError: ({ message, reason, errors: errors4 }) => new RetryError({ message, reason, errors: errors4 })
47370
48251
  }), DefaultGeneratedFile = class {
47371
48252
  constructor({
47372
48253
  data,
@@ -47389,7 +48270,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47389
48270
  }
47390
48271
  return this.uint8ArrayData;
47391
48272
  }
47392
- }, DefaultGeneratedFileWithType, output_exports, text = () => ({
48273
+ }, DefaultGeneratedFileWithType, encoder, output_exports, text = () => ({
47393
48274
  name: "text",
47394
48275
  responseFormat: Promise.resolve({ type: "text" }),
47395
48276
  async parseCompleteOutput({ text: text2 }) {
@@ -47403,7 +48284,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47403
48284
  }
47404
48285
  }), object2 = ({
47405
48286
  schema: inputSchema,
47406
- name: name21,
48287
+ name: name222,
47407
48288
  description
47408
48289
  }) => {
47409
48290
  const schema = asSchema(inputSchema);
@@ -47412,7 +48293,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47412
48293
  responseFormat: resolve3(schema.jsonSchema).then((jsonSchema2) => ({
47413
48294
  type: "json",
47414
48295
  schema: jsonSchema2,
47415
- ...name21 != null && { name: name21 },
48296
+ ...name222 != null && { name: name222 },
47416
48297
  ...description != null && { description }
47417
48298
  })),
47418
48299
  async parseCompleteOutput({ text: text2 }, context2) {
@@ -47464,7 +48345,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47464
48345
  };
47465
48346
  }, array2 = ({
47466
48347
  element: inputElementSchema,
47467
- name: name21,
48348
+ name: name222,
47468
48349
  description
47469
48350
  }) => {
47470
48351
  const elementSchema = asSchema(inputElementSchema);
@@ -47483,7 +48364,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47483
48364
  required: ["elements"],
47484
48365
  additionalProperties: false
47485
48366
  },
47486
- ...name21 != null && { name: name21 },
48367
+ ...name222 != null && { name: name222 },
47487
48368
  ...description != null && { description }
47488
48369
  };
47489
48370
  }),
@@ -47574,7 +48455,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47574
48455
  };
47575
48456
  }, choice = ({
47576
48457
  options: choiceOptions,
47577
- name: name21,
48458
+ name: name222,
47578
48459
  description
47579
48460
  }) => {
47580
48461
  return {
@@ -47590,7 +48471,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47590
48471
  required: ["result"],
47591
48472
  additionalProperties: false
47592
48473
  },
47593
- ...name21 != null && { name: name21 },
48474
+ ...name222 != null && { name: name222 },
47594
48475
  ...description != null && { description }
47595
48476
  }),
47596
48477
  async parseCompleteOutput({ text: text2 }, context2) {
@@ -47648,14 +48529,14 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47648
48529
  }
47649
48530
  };
47650
48531
  }, json3 = ({
47651
- name: name21,
48532
+ name: name222,
47652
48533
  description
47653
48534
  } = {}) => {
47654
48535
  return {
47655
48536
  name: "json",
47656
48537
  responseFormat: Promise.resolve({
47657
48538
  type: "json",
47658
- ...name21 != null && { name: name21 },
48539
+ ...name222 != null && { name: name222 },
47659
48540
  ...description != null && { description }
47660
48541
  }),
47661
48542
  async parseCompleteOutput({ text: text2 }, context2) {
@@ -47827,7 +48708,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47827
48708
  }
47828
48709
  return this._output;
47829
48710
  }
47830
- }, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS, toolMetadataSchema, uiMessageChunkSchema, isToolOrDynamicToolUIPart, getToolOrDynamicToolName, originalGenerateId2, DefaultStreamTextResult = class {
48711
+ }, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS, toolMetadataSchema, uiMessageChunkSchema, isToolOrDynamicToolUIPart, getToolOrDynamicToolName, originalGenerateId2, isOutputChunkType, DefaultStreamTextResult = class {
47831
48712
  constructor({
47832
48713
  model,
47833
48714
  telemetry,
@@ -47868,6 +48749,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47868
48749
  onToolCallStart,
47869
48750
  onToolCallFinish,
47870
48751
  experimental_context,
48752
+ experimental_toolApprovalSecret,
47871
48753
  download: download2,
47872
48754
  include
47873
48755
  }) {
@@ -47889,20 +48771,25 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47889
48771
  let recordedRequest = {};
47890
48772
  let recordedWarnings = [];
47891
48773
  const recordedSteps = [];
48774
+ let recordedNoOutputError;
47892
48775
  const pendingDeferredToolCalls = /* @__PURE__ */ new Map;
47893
48776
  let rootSpan;
47894
- let activeTextContent = {};
47895
- let activeReasoningContent = {};
48777
+ let activeTextContent = createIdMap();
48778
+ let activeReasoningContent = createIdMap();
47896
48779
  const eventProcessor = new TransformStream({
47897
48780
  async transform(chunk, controller) {
47898
- var _a21, _b16, _c, _d;
48781
+ var _a222, _b16, _c, _d;
47899
48782
  controller.enqueue(chunk);
47900
48783
  const { part } = chunk;
47901
48784
  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") {
47902
48785
  await (onChunk == null ? undefined : onChunk({ chunk: part }));
47903
48786
  }
47904
48787
  if (part.type === "error") {
47905
- await onError({ error: wrapGatewayError(part.error) });
48788
+ const error40 = wrapGatewayError(part.error);
48789
+ if (NoOutputGeneratedError.isInstance(error40)) {
48790
+ recordedNoOutputError = error40;
48791
+ }
48792
+ await onError({ error: error40 });
47906
48793
  }
47907
48794
  if (part.type === "text-start") {
47908
48795
  activeTextContent[part.id] = {
@@ -47925,7 +48812,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
47925
48812
  return;
47926
48813
  }
47927
48814
  activeText.text += part.text;
47928
- activeText.providerMetadata = (_a21 = part.providerMetadata) != null ? _a21 : activeText.providerMetadata;
48815
+ activeText.providerMetadata = (_a222 = part.providerMetadata) != null ? _a222 : activeText.providerMetadata;
47929
48816
  }
47930
48817
  if (part.type === "text-end") {
47931
48818
  const activeText = activeTextContent[part.id];
@@ -48004,8 +48891,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48004
48891
  }
48005
48892
  if (part.type === "start-step") {
48006
48893
  recordedContent = [];
48007
- activeReasoningContent = {};
48008
- activeTextContent = {};
48894
+ activeReasoningContent = createIdMap();
48895
+ activeTextContent = createIdMap();
48009
48896
  recordedRequest = part.request;
48010
48897
  recordedWarnings = part.warnings;
48011
48898
  }
@@ -48051,10 +48938,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48051
48938
  }
48052
48939
  },
48053
48940
  async flush(controller) {
48054
- var _a21, _b16, _c, _d, _e, _f, _g;
48941
+ var _a222, _b16, _c, _d, _e, _f, _g;
48055
48942
  try {
48056
- if (recordedSteps.length === 0) {
48057
- const error40 = (abortSignal == null ? undefined : abortSignal.aborted) ? abortSignal.reason : new NoOutputGeneratedError({
48943
+ if (recordedSteps.length === 0 || recordedNoOutputError != null) {
48944
+ const error40 = (abortSignal == null ? undefined : abortSignal.aborted) ? abortSignal.reason : recordedNoOutputError != null ? recordedNoOutputError : new NoOutputGeneratedError({
48058
48945
  message: "No output generated. Check the stream for errors."
48059
48946
  });
48060
48947
  self2._finishReason.reject(error40);
@@ -48114,13 +49001,13 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48114
49001
  },
48115
49002
  "ai.response.toolCalls": {
48116
49003
  output: () => {
48117
- var _a222;
48118
- return ((_a222 = finalStep.toolCalls) == null ? undefined : _a222.length) ? JSON.stringify(finalStep.toolCalls) : undefined;
49004
+ var _a232;
49005
+ return ((_a232 = finalStep.toolCalls) == null ? undefined : _a232.length) ? JSON.stringify(finalStep.toolCalls) : undefined;
48119
49006
  }
48120
49007
  },
48121
49008
  "ai.response.providerMetadata": JSON.stringify(finalStep.providerMetadata),
48122
49009
  "ai.usage.inputTokens": totalUsage.inputTokens,
48123
- "ai.usage.inputTokenDetails.noCacheTokens": (_a21 = totalUsage.inputTokenDetails) == null ? undefined : _a21.noCacheTokens,
49010
+ "ai.usage.inputTokenDetails.noCacheTokens": (_a222 = totalUsage.inputTokenDetails) == null ? undefined : _a222.noCacheTokens,
48124
49011
  "ai.usage.inputTokenDetails.cacheReadTokens": (_b16 = totalUsage.inputTokenDetails) == null ? undefined : _b16.cacheReadTokens,
48125
49012
  "ai.usage.inputTokenDetails.cacheWriteTokens": (_c = totalUsage.inputTokenDetails) == null ? undefined : _c.cacheWriteTokens,
48126
49013
  "ai.usage.outputTokens": totalUsage.outputTokens,
@@ -48264,8 +49151,20 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48264
49151
  const initialResponseMessages = [];
48265
49152
  const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
48266
49153
  if (deniedToolApprovals.length > 0 || approvedToolApprovals.length > 0) {
48267
- const localApprovedToolApprovals = approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted);
48268
- const localDeniedToolApprovals = deniedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted);
49154
+ const {
49155
+ approvedToolApprovals: localApprovedToolApprovals,
49156
+ deniedToolApprovals: revalidationDeniedToolApprovals
49157
+ } = await validateApprovedToolApprovals({
49158
+ approvedToolApprovals: approvedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted),
49159
+ tools,
49160
+ messages: initialMessages,
49161
+ experimental_context,
49162
+ toolApprovalSecret: experimental_toolApprovalSecret
49163
+ });
49164
+ const localDeniedToolApprovals = [
49165
+ ...deniedToolApprovals.filter((toolApproval) => !toolApproval.toolCall.providerExecuted),
49166
+ ...revalidationDeniedToolApprovals
49167
+ ];
48269
49168
  const deniedProviderExecutedToolApprovals = deniedToolApprovals.filter((toolApproval) => toolApproval.toolCall.providerExecuted);
48270
49169
  let toolExecutionStepStreamController;
48271
49170
  const toolExecutionStepStream = new ReadableStream({
@@ -48356,7 +49255,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48356
49255
  responseMessages,
48357
49256
  usage
48358
49257
  }) {
48359
- var _a21, _b16, _c, _d, _e, _f, _g, _h, _i;
49258
+ var _a222, _b16, _c, _d, _e, _f, _g, _h, _i;
48360
49259
  const includeRawChunks2 = self2.includeRawChunks;
48361
49260
  const stepTimeoutId = stepTimeoutMs != null ? setTimeout(() => stepAbortController.abort(), stepTimeoutMs) : undefined;
48362
49261
  let chunkTimeoutId = undefined;
@@ -48389,7 +49288,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48389
49288
  messages: stepInputMessages,
48390
49289
  experimental_context
48391
49290
  }));
48392
- const stepModel = resolveLanguageModel((_a21 = prepareStepResult == null ? undefined : prepareStepResult.model) != null ? _a21 : model);
49291
+ const stepModel = resolveLanguageModel((_a222 = prepareStepResult == null ? undefined : prepareStepResult.model) != null ? _a222 : model);
48393
49292
  const stepModelInfo = {
48394
49293
  provider: stepModel.provider,
48395
49294
  modelId: stepModel.modelId
@@ -48501,6 +49400,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48501
49400
  repairToolCall,
48502
49401
  abortSignal,
48503
49402
  experimental_context,
49403
+ toolApprovalSecret: experimental_toolApprovalSecret,
48504
49404
  generateId: generateId2,
48505
49405
  stepNumber: recordedSteps.length,
48506
49406
  model: stepModelInfo,
@@ -48520,6 +49420,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48520
49420
  const activeToolCallToolNames = {};
48521
49421
  let stepFinishReason = "other";
48522
49422
  let stepRawFinishReason = undefined;
49423
+ let hasReceivedTerminalChunk = false;
49424
+ let hasReceivedOutputChunk = false;
48523
49425
  let stepUsage = createNullLanguageModelUsage();
48524
49426
  let stepProviderMetadata;
48525
49427
  let stepFirstChunk = true;
@@ -48531,7 +49433,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48531
49433
  let activeText = "";
48532
49434
  self2.addStream(streamWithToolResults.pipeThrough(new TransformStream({
48533
49435
  async transform(chunk, controller) {
48534
- var _a222, _b23, _c2, _d2, _e2;
49436
+ var _a232, _b23, _c2, _d2, _e2;
48535
49437
  resetChunkTimeout();
48536
49438
  if (chunk.type === "stream-start") {
48537
49439
  warnings = chunk.warnings;
@@ -48553,6 +49455,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48553
49455
  });
48554
49456
  }
48555
49457
  const chunkType = chunk.type;
49458
+ if (isOutputChunkType[chunkType]) {
49459
+ hasReceivedOutputChunk = true;
49460
+ }
48556
49461
  switch (chunkType) {
48557
49462
  case "tool-approval-request":
48558
49463
  case "text-start":
@@ -48605,13 +49510,14 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48605
49510
  }
48606
49511
  case "response-metadata": {
48607
49512
  stepResponse = {
48608
- id: (_a222 = chunk.id) != null ? _a222 : stepResponse.id,
49513
+ id: (_a232 = chunk.id) != null ? _a232 : stepResponse.id,
48609
49514
  timestamp: (_b23 = chunk.timestamp) != null ? _b23 : stepResponse.timestamp,
48610
49515
  modelId: (_c2 = chunk.modelId) != null ? _c2 : stepResponse.modelId
48611
49516
  };
48612
49517
  break;
48613
49518
  }
48614
49519
  case "finish": {
49520
+ hasReceivedTerminalChunk = true;
48615
49521
  stepUsage = chunk.usage;
48616
49522
  stepFinishReason = chunk.finishReason;
48617
49523
  stepRawFinishReason = chunk.rawFinishReason;
@@ -48671,6 +49577,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48671
49577
  break;
48672
49578
  }
48673
49579
  case "error": {
49580
+ hasReceivedTerminalChunk = true;
48674
49581
  controller.enqueue(chunk);
48675
49582
  stepFinishReason = "error";
48676
49583
  break;
@@ -48688,7 +49595,20 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48688
49595
  }
48689
49596
  },
48690
49597
  async flush(controller) {
48691
- var _a222, _b23, _c2, _d2, _e2, _f2, _g2;
49598
+ var _a232, _b23, _c2, _d2, _e2, _f2, _g2;
49599
+ if (!hasReceivedTerminalChunk && !hasReceivedOutputChunk) {
49600
+ controller.enqueue({
49601
+ type: "error",
49602
+ error: new NoOutputGeneratedError({
49603
+ message: "No output generated. The model stream ended without a finish chunk."
49604
+ })
49605
+ });
49606
+ doStreamSpan.end();
49607
+ clearStepTimeout();
49608
+ clearChunkTimeout();
49609
+ self2.closeStream();
49610
+ return;
49611
+ }
48692
49612
  const stepToolCallsJson = stepToolCalls.length > 0 ? JSON.stringify(stepToolCalls) : undefined;
48693
49613
  try {
48694
49614
  doStreamSpan.setAttributes(await selectTelemetryAttributes({
@@ -48702,7 +49622,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48702
49622
  "ai.response.model": stepResponse.modelId,
48703
49623
  "ai.response.timestamp": stepResponse.timestamp.toISOString(),
48704
49624
  "ai.usage.inputTokens": stepUsage.inputTokens,
48705
- "ai.usage.inputTokenDetails.noCacheTokens": (_a222 = stepUsage.inputTokenDetails) == null ? undefined : _a222.noCacheTokens,
49625
+ "ai.usage.inputTokenDetails.noCacheTokens": (_a232 = stepUsage.inputTokenDetails) == null ? undefined : _a232.noCacheTokens,
48706
49626
  "ai.usage.inputTokenDetails.cacheReadTokens": (_b23 = stepUsage.inputTokenDetails) == null ? undefined : _b23.cacheReadTokens,
48707
49627
  "ai.usage.inputTokenDetails.cacheWriteTokens": (_c2 = stepUsage.inputTokenDetails) == null ? undefined : _c2.cacheWriteTokens,
48708
49628
  "ai.usage.outputTokens": stepUsage.outputTokens,
@@ -48917,15 +49837,30 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48917
49837
  }
48918
49838
  })));
48919
49839
  }
49840
+ rejectResultPromises(error40) {
49841
+ if (this._finishReason.isPending())
49842
+ this._finishReason.reject(error40);
49843
+ if (this._rawFinishReason.isPending())
49844
+ this._rawFinishReason.reject(error40);
49845
+ if (this._totalUsage.isPending())
49846
+ this._totalUsage.reject(error40);
49847
+ if (this._steps.isPending())
49848
+ this._steps.reject(error40);
49849
+ }
48920
49850
  async consumeStream(options) {
48921
- var _a21;
49851
+ var _a222;
48922
49852
  try {
48923
49853
  await consumeStream({
48924
49854
  stream: this.fullStream,
48925
- onError: options == null ? undefined : options.onError
49855
+ onError: (error40) => {
49856
+ var _a232;
49857
+ this.rejectResultPromises(error40);
49858
+ (_a232 = options == null ? undefined : options.onError) == null || _a232.call(options, error40);
49859
+ }
48926
49860
  });
48927
49861
  } catch (error40) {
48928
- (_a21 = options == null ? undefined : options.onError) == null || _a21.call(options, error40);
49862
+ this.rejectResultPromises(error40);
49863
+ (_a222 = options == null ? undefined : options.onError) == null || _a222.call(options, error40);
48929
49864
  }
48930
49865
  }
48931
49866
  get experimental_partialOutputStream() {
@@ -48941,8 +49876,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48941
49876
  })));
48942
49877
  }
48943
49878
  get elementStream() {
48944
- var _a21, _b16, _c;
48945
- const transform2 = (_a21 = this.outputSpecification) == null ? undefined : _a21.createElementStreamTransform();
49879
+ var _a222, _b16, _c;
49880
+ const transform2 = (_a222 = this.outputSpecification) == null ? undefined : _a222.createElementStreamTransform();
48946
49881
  if (transform2 == null) {
48947
49882
  throw new UnsupportedFunctionalityError({
48948
49883
  functionality: `element streams in ${(_c = (_b16 = this.outputSpecification) == null ? undefined : _b16.name) != null ? _c : "text"} mode`
@@ -48952,8 +49887,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48952
49887
  }
48953
49888
  get output() {
48954
49889
  return this.finalStep.then((step) => {
48955
- var _a21;
48956
- const output = (_a21 = this.outputSpecification) != null ? _a21 : text();
49890
+ var _a222;
49891
+ const output = (_a222 = this.outputSpecification) != null ? _a222 : text();
48957
49892
  return output.parseCompleteOutput({ text: step.text }, {
48958
49893
  response: step.response,
48959
49894
  usage: step.usage,
@@ -48970,15 +49905,15 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
48970
49905
  sendSources = false,
48971
49906
  sendStart = true,
48972
49907
  sendFinish = true,
48973
- onError = getErrorMessage
49908
+ onError = () => "An error occurred."
48974
49909
  } = {}) {
48975
49910
  const responseMessageId = generateMessageId != null ? getResponseUIMessageId({
48976
49911
  originalMessages,
48977
49912
  responseMessageId: generateMessageId
48978
49913
  }) : undefined;
48979
49914
  const isDynamic = (part) => {
48980
- var _a21;
48981
- const tool2 = (_a21 = this.tools) == null ? undefined : _a21[part.toolName];
49915
+ var _a222;
49916
+ const tool2 = (_a222 = this.tools) == null ? undefined : _a222[part.toolName];
48982
49917
  if (tool2 == null) {
48983
49918
  return part.dynamic;
48984
49919
  }
@@ -49123,7 +50058,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49123
50058
  controller.enqueue({
49124
50059
  type: "tool-approval-request",
49125
50060
  approvalId: part.approvalId,
49126
- toolCallId: part.toolCall.toolCallId
50061
+ toolCallId: part.toolCall.toolCallId,
50062
+ ...part.signature != null ? { signature: part.signature } : {}
49127
50063
  });
49128
50064
  break;
49129
50065
  }
@@ -49132,7 +50068,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49132
50068
  controller.enqueue({
49133
50069
  type: "tool-output-available",
49134
50070
  toolCallId: part.toolCallId,
49135
- output: part.output,
50071
+ output: part.output === undefined ? null : part.output,
49136
50072
  ...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
49137
50073
  ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
49138
50074
  ...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
@@ -49307,7 +50243,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49307
50243
  return this.settings.tools;
49308
50244
  }
49309
50245
  async prepareCall(options) {
49310
- var _a21, _b16, _c, _d;
50246
+ var _a222, _b16, _c, _d;
49311
50247
  if (this.settings.callOptionsSchema != null && options.options !== undefined) {
49312
50248
  const validatedOptions = await validateTypes({
49313
50249
  value: options.options,
@@ -49319,7 +50255,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49319
50255
  const { onStepFinish: _settingsOnStepFinish, ...settingsWithoutCallback } = this.settings;
49320
50256
  const baseCallArgs = {
49321
50257
  ...settingsWithoutCallback,
49322
- stopWhen: (_a21 = this.settings.stopWhen) != null ? _a21 : stepCountIs(20),
50258
+ stopWhen: (_a222 = this.settings.stopWhen) != null ? _a222 : stepCountIs(20),
49323
50259
  ...options
49324
50260
  };
49325
50261
  const preparedCallArgs = (_d = await ((_c = (_b16 = this.settings).prepareCall) == null ? undefined : _c.call(_b16, baseCallArgs))) != null ? _d : baseCallArgs;
@@ -49448,7 +50384,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49448
50384
  isFirstDelta,
49449
50385
  isFinalDelta
49450
50386
  }) {
49451
- var _a21;
50387
+ var _a222;
49452
50388
  if (!isJSONObject(value) || !isJSONArray(value.elements)) {
49453
50389
  return {
49454
50390
  success: false,
@@ -49471,7 +50407,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49471
50407
  }
49472
50408
  resultArray.push(result.value);
49473
50409
  }
49474
- const publishedElementCount = (_a21 = latestObject == null ? undefined : latestObject.length) != null ? _a21 : 0;
50410
+ const publishedElementCount = (_a222 = latestObject == null ? undefined : latestObject.length) != null ? _a222 : 0;
49475
50411
  let textDelta = "";
49476
50412
  if (isFirstDelta) {
49477
50413
  textDelta += "[";
@@ -49502,13 +50438,15 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49502
50438
  };
49503
50439
  }
49504
50440
  const inputArray = value.elements;
50441
+ const resultArray = [];
49505
50442
  for (const element of inputArray) {
49506
50443
  const result = await safeValidateTypes({ value: element, schema });
49507
50444
  if (!result.success) {
49508
50445
  return result;
49509
50446
  }
50447
+ resultArray.push(result.value);
49510
50448
  }
49511
- return { success: true, value: inputArray };
50449
+ return { success: true, value: resultArray };
49512
50450
  },
49513
50451
  createElementStream(originalStream) {
49514
50452
  let publishedElements = 0;
@@ -49613,9 +50551,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49613
50551
  this.reasoning = options.reasoning;
49614
50552
  }
49615
50553
  toJsonResponse(init) {
49616
- var _a21;
50554
+ var _a222;
49617
50555
  return new Response(JSON.stringify(this.object), {
49618
- status: (_a21 = init == null ? undefined : init.status) != null ? _a21 : 200,
50556
+ status: (_a222 = init == null ? undefined : init.status) != null ? _a222 : 200,
49619
50557
  headers: prepareHeaders(init == null ? undefined : init.headers, {
49620
50558
  "content-type": "application/json; charset=utf-8"
49621
50559
  })
@@ -49823,7 +50761,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49823
50761
  let isFirstDelta = true;
49824
50762
  const transformedStream = stream.pipeThrough(new TransformStream(transformer)).pipeThrough(new TransformStream({
49825
50763
  async transform(chunk, controller) {
49826
- var _a21, _b16, _c;
50764
+ var _a222, _b16, _c;
49827
50765
  if (typeof chunk === "object" && chunk.type === "stream-start") {
49828
50766
  warnings = chunk.warnings;
49829
50767
  return;
@@ -49870,7 +50808,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
49870
50808
  switch (chunk.type) {
49871
50809
  case "response-metadata": {
49872
50810
  fullResponse = {
49873
- id: (_a21 = chunk.id) != null ? _a21 : fullResponse.id,
50811
+ id: (_a222 = chunk.id) != null ? _a222 : fullResponse.id,
49874
50812
  timestamp: (_b16 = chunk.timestamp) != null ? _b16 : fullResponse.timestamp,
49875
50813
  modelId: (_c = chunk.modelId) != null ? _c : fullResponse.modelId
49876
50814
  };
@@ -50078,11 +51016,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50078
51016
  }
50079
51017
  }, DefaultGeneratedAudioFile, DefaultSpeechResult = class {
50080
51018
  constructor(options) {
50081
- var _a21;
51019
+ var _a222;
50082
51020
  this.audio = options.audio;
50083
51021
  this.warnings = options.warnings;
50084
51022
  this.responses = options.responses;
50085
- this.providerMetadata = (_a21 = options.providerMetadata) != null ? _a21 : {};
51023
+ this.providerMetadata = (_a222 = options.providerMetadata) != null ? _a222 : {};
50086
51024
  }
50087
51025
  }, CHUNKING_REGEXPS, defaultDownload, wrapLanguageModel = ({
50088
51026
  model,
@@ -50106,7 +51044,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50106
51044
  modelId,
50107
51045
  providerId
50108
51046
  }) => {
50109
- var _a21, _b16, _c;
51047
+ var _a222, _b16, _c;
50110
51048
  async function doTransform({
50111
51049
  params,
50112
51050
  type
@@ -50115,7 +51053,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50115
51053
  }
50116
51054
  return {
50117
51055
  specificationVersion: "v3",
50118
- provider: (_a21 = providerId != null ? providerId : overrideProvider == null ? undefined : overrideProvider({ model })) != null ? _a21 : model.provider,
51056
+ provider: (_a222 = providerId != null ? providerId : overrideProvider == null ? undefined : overrideProvider({ model })) != null ? _a222 : model.provider,
50119
51057
  modelId: (_b16 = modelId != null ? modelId : overrideModelId == null ? undefined : overrideModelId({ model })) != null ? _b16 : model.modelId,
50120
51058
  supportedUrls: (_c = overrideSupportedUrls == null ? undefined : overrideSupportedUrls({ model })) != null ? _c : model.supportedUrls,
50121
51059
  async doGenerate(params) {
@@ -50158,7 +51096,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50158
51096
  modelId,
50159
51097
  providerId
50160
51098
  }) => {
50161
- var _a21, _b16, _c, _d;
51099
+ var _a222, _b16, _c, _d;
50162
51100
  async function doTransform({
50163
51101
  params
50164
51102
  }) {
@@ -50166,7 +51104,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50166
51104
  }
50167
51105
  return {
50168
51106
  specificationVersion: "v3",
50169
- provider: (_a21 = providerId != null ? providerId : overrideProvider == null ? undefined : overrideProvider({ model })) != null ? _a21 : model.provider,
51107
+ provider: (_a222 = providerId != null ? providerId : overrideProvider == null ? undefined : overrideProvider({ model })) != null ? _a222 : model.provider,
50170
51108
  modelId: (_b16 = modelId != null ? modelId : overrideModelId == null ? undefined : overrideModelId({ model })) != null ? _b16 : model.modelId,
50171
51109
  maxEmbeddingsPerCall: (_c = overrideMaxEmbeddingsPerCall == null ? undefined : overrideMaxEmbeddingsPerCall({ model })) != null ? _c : model.maxEmbeddingsPerCall,
50172
51110
  supportsParallelCalls: (_d = overrideSupportsParallelCalls == null ? undefined : overrideSupportsParallelCalls({ model })) != null ? _d : model.supportsParallelCalls,
@@ -50201,11 +51139,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50201
51139
  modelId,
50202
51140
  providerId
50203
51141
  }) => {
50204
- var _a21, _b16, _c;
51142
+ var _a222, _b16, _c;
50205
51143
  async function doTransform({ params }) {
50206
51144
  return transformParams ? await transformParams({ params, model }) : params;
50207
51145
  }
50208
- const maxImagesPerCallRaw = (_a21 = overrideMaxImagesPerCall == null ? undefined : overrideMaxImagesPerCall({ model })) != null ? _a21 : model.maxImagesPerCall;
51146
+ const maxImagesPerCallRaw = (_a222 = overrideMaxImagesPerCall == null ? undefined : overrideMaxImagesPerCall({ model })) != null ? _a222 : model.maxImagesPerCall;
50209
51147
  const maxImagesPerCall = maxImagesPerCallRaw instanceof Function ? maxImagesPerCallRaw.bind(model) : maxImagesPerCallRaw;
50210
51148
  return {
50211
51149
  specificationVersion: "v3",
@@ -50222,7 +51160,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50222
51160
  }) : doGenerate();
50223
51161
  }
50224
51162
  };
50225
- }, experimental_customProvider, name20 = "AI_NoSuchProviderError", marker20, symbol20, _a20, NoSuchProviderError, experimental_createProviderRegistry, DefaultProviderRegistry = class {
51163
+ }, experimental_customProvider, name21 = "AI_NoSuchProviderError", marker21, symbol21, _a21, NoSuchProviderError, experimental_createProviderRegistry, DefaultProviderRegistry = class {
50226
51164
  constructor({
50227
51165
  separator,
50228
51166
  languageModelMiddleware,
@@ -50263,9 +51201,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50263
51201
  return [id.slice(0, index), id.slice(index + this.separator.length)];
50264
51202
  }
50265
51203
  languageModel(id) {
50266
- var _a21, _b16;
51204
+ var _a222, _b16;
50267
51205
  const [providerId, modelId] = this.splitId(id, "languageModel");
50268
- let model = (_b16 = (_a21 = this.getProvider(providerId, "languageModel")).languageModel) == null ? undefined : _b16.call(_a21, modelId);
51206
+ let model = (_b16 = (_a222 = this.getProvider(providerId, "languageModel")).languageModel) == null ? undefined : _b16.call(_a222, modelId);
50269
51207
  if (model == null) {
50270
51208
  throw new NoSuchModelError({ modelId: id, modelType: "languageModel" });
50271
51209
  }
@@ -50278,10 +51216,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50278
51216
  return model;
50279
51217
  }
50280
51218
  embeddingModel(id) {
50281
- var _a21;
51219
+ var _a222;
50282
51220
  const [providerId, modelId] = this.splitId(id, "embeddingModel");
50283
51221
  const provider = this.getProvider(providerId, "embeddingModel");
50284
- const model = (_a21 = provider.embeddingModel) == null ? undefined : _a21.call(provider, modelId);
51222
+ const model = (_a222 = provider.embeddingModel) == null ? undefined : _a222.call(provider, modelId);
50285
51223
  if (model == null) {
50286
51224
  throw new NoSuchModelError({
50287
51225
  modelId: id,
@@ -50291,10 +51229,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50291
51229
  return model;
50292
51230
  }
50293
51231
  imageModel(id) {
50294
- var _a21;
51232
+ var _a222;
50295
51233
  const [providerId, modelId] = this.splitId(id, "imageModel");
50296
51234
  const provider = this.getProvider(providerId, "imageModel");
50297
- let model = (_a21 = provider.imageModel) == null ? undefined : _a21.call(provider, modelId);
51235
+ let model = (_a222 = provider.imageModel) == null ? undefined : _a222.call(provider, modelId);
50298
51236
  if (model == null) {
50299
51237
  throw new NoSuchModelError({ modelId: id, modelType: "imageModel" });
50300
51238
  }
@@ -50307,10 +51245,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50307
51245
  return model;
50308
51246
  }
50309
51247
  transcriptionModel(id) {
50310
- var _a21;
51248
+ var _a222;
50311
51249
  const [providerId, modelId] = this.splitId(id, "transcriptionModel");
50312
51250
  const provider = this.getProvider(providerId, "transcriptionModel");
50313
- const model = (_a21 = provider.transcriptionModel) == null ? undefined : _a21.call(provider, modelId);
51251
+ const model = (_a222 = provider.transcriptionModel) == null ? undefined : _a222.call(provider, modelId);
50314
51252
  if (model == null) {
50315
51253
  throw new NoSuchModelError({
50316
51254
  modelId: id,
@@ -50320,20 +51258,20 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50320
51258
  return model;
50321
51259
  }
50322
51260
  speechModel(id) {
50323
- var _a21;
51261
+ var _a222;
50324
51262
  const [providerId, modelId] = this.splitId(id, "speechModel");
50325
51263
  const provider = this.getProvider(providerId, "speechModel");
50326
- const model = (_a21 = provider.speechModel) == null ? undefined : _a21.call(provider, modelId);
51264
+ const model = (_a222 = provider.speechModel) == null ? undefined : _a222.call(provider, modelId);
50327
51265
  if (model == null) {
50328
51266
  throw new NoSuchModelError({ modelId: id, modelType: "speechModel" });
50329
51267
  }
50330
51268
  return model;
50331
51269
  }
50332
51270
  rerankingModel(id) {
50333
- var _a21;
51271
+ var _a222;
50334
51272
  const [providerId, modelId] = this.splitId(id, "rerankingModel");
50335
51273
  const provider = this.getProvider(providerId, "rerankingModel");
50336
- const model = (_a21 = provider.rerankingModel) == null ? undefined : _a21.call(provider, modelId);
51274
+ const model = (_a222 = provider.rerankingModel) == null ? undefined : _a222.call(provider, modelId);
50337
51275
  if (model == null) {
50338
51276
  throw new NoSuchModelError({ modelId: id, modelType: "rerankingModel" });
50339
51277
  }
@@ -50351,14 +51289,14 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50351
51289
  }
50352
51290
  }, defaultDownload2, DefaultTranscriptionResult = class {
50353
51291
  constructor(options) {
50354
- var _a21;
51292
+ var _a222;
50355
51293
  this.text = options.text;
50356
51294
  this.segments = options.segments;
50357
51295
  this.language = options.language;
50358
51296
  this.durationInSeconds = options.durationInSeconds;
50359
51297
  this.warnings = options.warnings;
50360
51298
  this.responses = options.responses;
50361
- this.providerMetadata = (_a21 = options.providerMetadata) != null ? _a21 : {};
51299
+ this.providerMetadata = (_a222 = options.providerMetadata) != null ? _a222 : {};
50362
51300
  }
50363
51301
  }, getOriginalFetch3 = () => fetch, HttpChatTransport = class {
50364
51302
  constructor({
@@ -50382,7 +51320,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50382
51320
  abortSignal,
50383
51321
  ...options
50384
51322
  }) {
50385
- var _a21, _b16, _c, _d, _e;
51323
+ var _a222, _b16, _c, _d, _e;
50386
51324
  const resolvedBody = await resolve3(this.body);
50387
51325
  const resolvedHeaders = await resolve3(this.headers);
50388
51326
  const resolvedCredentials = await resolve3(this.credentials);
@@ -50390,7 +51328,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50390
51328
  ...normalizeHeaders(resolvedHeaders),
50391
51329
  ...normalizeHeaders(options.headers)
50392
51330
  };
50393
- const preparedRequest = await ((_a21 = this.prepareSendMessagesRequest) == null ? undefined : _a21.call(this, {
51331
+ const preparedRequest = await ((_a222 = this.prepareSendMessagesRequest) == null ? undefined : _a222.call(this, {
50394
51332
  api: this.api,
50395
51333
  id: options.chatId,
50396
51334
  messages: options.messages,
@@ -50432,7 +51370,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50432
51370
  return this.processResponseStream(response.body);
50433
51371
  }
50434
51372
  async reconnectToStream(options) {
50435
- var _a21, _b16, _c, _d, _e;
51373
+ var _a222, _b16, _c, _d, _e;
50436
51374
  const resolvedBody = await resolve3(this.body);
50437
51375
  const resolvedHeaders = await resolve3(this.headers);
50438
51376
  const resolvedCredentials = await resolve3(this.credentials);
@@ -50440,7 +51378,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50440
51378
  ...normalizeHeaders(resolvedHeaders),
50441
51379
  ...normalizeHeaders(options.headers)
50442
51380
  };
50443
- const preparedRequest = await ((_a21 = this.prepareReconnectToStreamRequest) == null ? undefined : _a21.call(this, {
51381
+ const preparedRequest = await ((_a222 = this.prepareReconnectToStreamRequest) == null ? undefined : _a222.call(this, {
50444
51382
  api: this.api,
50445
51383
  id: options.chatId,
50446
51384
  body: { ...resolvedBody, ...options.body },
@@ -50485,11 +51423,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50485
51423
  this.activeResponse = undefined;
50486
51424
  this.jobExecutor = new SerialJobExecutor;
50487
51425
  this.sendMessage = async (message, options) => {
50488
- var _a21, _b16, _c, _d;
51426
+ var _a222, _b16, _c, _d;
50489
51427
  if (message == null) {
50490
51428
  await this.makeRequest({
50491
51429
  trigger: "submit-message",
50492
- messageId: (_a21 = this.lastMessage) == null ? undefined : _a21.id,
51430
+ messageId: (_a222 = this.lastMessage) == null ? undefined : _a222.id,
50493
51431
  ...options
50494
51432
  });
50495
51433
  return;
@@ -50581,11 +51519,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50581
51519
  }
50582
51520
  if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
50583
51521
  this.shouldSendAutomatically().then((shouldSend) => {
50584
- var _a21;
51522
+ var _a222;
50585
51523
  if (shouldSend) {
50586
51524
  this.makeRequest({
50587
51525
  trigger: "submit-message",
50588
- messageId: (_a21 = this.lastMessage) == null ? undefined : _a21.id,
51526
+ messageId: (_a222 = this.lastMessage) == null ? undefined : _a222.id,
50589
51527
  ...options
50590
51528
  });
50591
51529
  }
@@ -50611,11 +51549,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50611
51549
  }
50612
51550
  if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
50613
51551
  this.shouldSendAutomatically().then((shouldSend) => {
50614
- var _a21;
51552
+ var _a222;
50615
51553
  if (shouldSend) {
50616
51554
  this.makeRequest({
50617
51555
  trigger: "submit-message",
50618
- messageId: (_a21 = this.lastMessage) == null ? undefined : _a21.id,
51556
+ messageId: (_a222 = this.lastMessage) == null ? undefined : _a222.id,
50619
51557
  ...options
50620
51558
  });
50621
51559
  }
@@ -50624,10 +51562,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50624
51562
  });
50625
51563
  this.addToolResult = this.addToolOutput;
50626
51564
  this.stop = async () => {
50627
- var _a21;
51565
+ var _a222;
50628
51566
  if (this.status !== "streaming" && this.status !== "submitted")
50629
51567
  return;
50630
- if ((_a21 = this.activeResponse) == null ? undefined : _a21.abortController) {
51568
+ if ((_a222 = this.activeResponse) == null ? undefined : _a222.abortController) {
50631
51569
  this.activeResponse.abortController.abort();
50632
51570
  }
50633
51571
  };
@@ -50685,7 +51623,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50685
51623
  body,
50686
51624
  messageId
50687
51625
  }) {
50688
- var _a21, _b16, _c;
51626
+ var _a222, _b16, _c;
50689
51627
  let resumeStream;
50690
51628
  if (trigger === "resume-stream") {
50691
51629
  try {
@@ -50742,9 +51680,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50742
51680
  const runUpdateMessageJob = (job) => this.jobExecutor.run(() => job({
50743
51681
  state: activeResponse.state,
50744
51682
  write: () => {
50745
- var _a222;
51683
+ var _a232;
50746
51684
  this.setStatus({ status: "streaming" });
50747
- const replaceLastMessage = activeResponse.state.message.id === ((_a222 = this.lastMessage) == null ? undefined : _a222.id);
51685
+ const replaceLastMessage = activeResponse.state.message.id === ((_a232 = this.lastMessage) == null ? undefined : _a232.id);
50748
51686
  if (replaceLastMessage) {
50749
51687
  this.state.replaceMessage(this.state.messages.length - 1, activeResponse.state.message);
50750
51688
  } else {
@@ -50791,7 +51729,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
50791
51729
  isAbort,
50792
51730
  isDisconnect,
50793
51731
  isError,
50794
- finishReason: (_a21 = this.activeResponse) == null ? undefined : _a21.state.finishReason
51732
+ finishReason: (_a222 = this.activeResponse) == null ? undefined : _a222.state.finishReason
50795
51733
  });
50796
51734
  } catch (err) {
50797
51735
  console.error(err);
@@ -50865,6 +51803,7 @@ var init_dist8 = __esm(() => {
50865
51803
  init_dist();
50866
51804
  init_dist();
50867
51805
  init_dist();
51806
+ init_dist();
50868
51807
  init_dist3();
50869
51808
  init_dist();
50870
51809
  init_dist7();
@@ -50890,6 +51829,8 @@ var init_dist8 = __esm(() => {
50890
51829
  init_dist3();
50891
51830
  init_dist3();
50892
51831
  init_dist3();
51832
+ init_dist3();
51833
+ init_dist3();
50893
51834
  init_dist();
50894
51835
  init_dist3();
50895
51836
  init_dist3();
@@ -50985,6 +51926,27 @@ var init_dist8 = __esm(() => {
50985
51926
  _a33 = symbol33;
50986
51927
  marker43 = `vercel.ai.error.${name43}`;
50987
51928
  symbol43 = Symbol.for(marker43);
51929
+ InvalidToolApprovalSignatureError = class extends AISDKError {
51930
+ constructor({
51931
+ approvalId,
51932
+ toolCallId,
51933
+ reason
51934
+ }) {
51935
+ super({
51936
+ name: name43,
51937
+ message: `Tool approval signature verification failed for approval "${approvalId}" (tool call "${toolCallId}"): ${reason}`
51938
+ });
51939
+ this[_a43] = true;
51940
+ this.approvalId = approvalId;
51941
+ this.toolCallId = toolCallId;
51942
+ }
51943
+ static isInstance(error40) {
51944
+ return AISDKError.hasMarker(error40, marker43);
51945
+ }
51946
+ };
51947
+ _a43 = symbol43;
51948
+ marker53 = `vercel.ai.error.${name53}`;
51949
+ symbol53 = Symbol.for(marker53);
50988
51950
  InvalidToolInputError = class extends AISDKError {
50989
51951
  constructor({
50990
51952
  toolInput,
@@ -50992,71 +51954,71 @@ var init_dist8 = __esm(() => {
50992
51954
  cause,
50993
51955
  message = `Invalid input for tool ${toolName}: ${getErrorMessage(cause)}`
50994
51956
  }) {
50995
- super({ name: name43, message, cause });
50996
- this[_a43] = true;
51957
+ super({ name: name53, message, cause });
51958
+ this[_a53] = true;
50997
51959
  this.toolInput = toolInput;
50998
51960
  this.toolName = toolName;
50999
51961
  }
51000
51962
  static isInstance(error40) {
51001
- return AISDKError.hasMarker(error40, marker43);
51963
+ return AISDKError.hasMarker(error40, marker53);
51002
51964
  }
51003
51965
  };
51004
- _a43 = symbol43;
51005
- marker53 = `vercel.ai.error.${name53}`;
51006
- symbol53 = Symbol.for(marker53);
51966
+ _a53 = symbol53;
51967
+ marker63 = `vercel.ai.error.${name63}`;
51968
+ symbol63 = Symbol.for(marker63);
51007
51969
  ToolCallNotFoundForApprovalError = class extends AISDKError {
51008
51970
  constructor({
51009
51971
  toolCallId,
51010
51972
  approvalId
51011
51973
  }) {
51012
51974
  super({
51013
- name: name53,
51975
+ name: name63,
51014
51976
  message: `Tool call "${toolCallId}" not found for approval request "${approvalId}".`
51015
51977
  });
51016
- this[_a53] = true;
51978
+ this[_a63] = true;
51017
51979
  this.toolCallId = toolCallId;
51018
51980
  this.approvalId = approvalId;
51019
51981
  }
51020
51982
  static isInstance(error40) {
51021
- return AISDKError.hasMarker(error40, marker53);
51983
+ return AISDKError.hasMarker(error40, marker63);
51022
51984
  }
51023
51985
  };
51024
- _a53 = symbol53;
51025
- marker63 = `vercel.ai.error.${name63}`;
51026
- symbol63 = Symbol.for(marker63);
51986
+ _a63 = symbol63;
51987
+ marker73 = `vercel.ai.error.${name73}`;
51988
+ symbol73 = Symbol.for(marker73);
51027
51989
  MissingToolResultsError = class extends AISDKError {
51028
51990
  constructor({ toolCallIds }) {
51029
51991
  super({
51030
- name: name63,
51992
+ name: name73,
51031
51993
  message: `Tool result${toolCallIds.length > 1 ? "s are" : " is"} missing for tool call${toolCallIds.length > 1 ? "s" : ""} ${toolCallIds.join(", ")}.`
51032
51994
  });
51033
- this[_a63] = true;
51995
+ this[_a73] = true;
51034
51996
  this.toolCallIds = toolCallIds;
51035
51997
  }
51036
51998
  static isInstance(error40) {
51037
- return AISDKError.hasMarker(error40, marker63);
51999
+ return AISDKError.hasMarker(error40, marker73);
51038
52000
  }
51039
52001
  };
51040
- _a63 = symbol63;
51041
- marker73 = `vercel.ai.error.${name73}`;
51042
- symbol73 = Symbol.for(marker73);
52002
+ _a73 = symbol73;
52003
+ marker83 = `vercel.ai.error.${name83}`;
52004
+ symbol83 = Symbol.for(marker83);
51043
52005
  NoImageGeneratedError = class extends AISDKError {
51044
52006
  constructor({
51045
52007
  message = "No image generated.",
51046
52008
  cause,
51047
52009
  responses
51048
52010
  }) {
51049
- super({ name: name73, message, cause });
51050
- this[_a73] = true;
52011
+ super({ name: name83, message, cause });
52012
+ this[_a83] = true;
51051
52013
  this.responses = responses;
51052
52014
  }
51053
52015
  static isInstance(error40) {
51054
- return AISDKError.hasMarker(error40, marker73);
52016
+ return AISDKError.hasMarker(error40, marker83);
51055
52017
  }
51056
52018
  };
51057
- _a73 = symbol73;
51058
- marker83 = `vercel.ai.error.${name83}`;
51059
- symbol83 = Symbol.for(marker83);
52019
+ _a83 = symbol83;
52020
+ marker93 = `vercel.ai.error.${name93}`;
52021
+ symbol93 = Symbol.for(marker93);
51060
52022
  NoObjectGeneratedError = class extends AISDKError {
51061
52023
  constructor({
51062
52024
  message = "No object generated.",
@@ -51066,82 +52028,82 @@ var init_dist8 = __esm(() => {
51066
52028
  usage,
51067
52029
  finishReason
51068
52030
  }) {
51069
- super({ name: name83, message, cause });
51070
- this[_a83] = true;
52031
+ super({ name: name93, message, cause });
52032
+ this[_a93] = true;
51071
52033
  this.text = text2;
51072
52034
  this.response = response;
51073
52035
  this.usage = usage;
51074
52036
  this.finishReason = finishReason;
51075
52037
  }
51076
52038
  static isInstance(error40) {
51077
- return AISDKError.hasMarker(error40, marker83);
52039
+ return AISDKError.hasMarker(error40, marker93);
51078
52040
  }
51079
52041
  };
51080
- _a83 = symbol83;
51081
- marker93 = `vercel.ai.error.${name92}`;
51082
- symbol93 = Symbol.for(marker93);
52042
+ _a93 = symbol93;
52043
+ marker103 = `vercel.ai.error.${name102}`;
52044
+ symbol103 = Symbol.for(marker103);
51083
52045
  NoOutputGeneratedError = class extends AISDKError {
51084
52046
  constructor({
51085
52047
  message = "No output generated.",
51086
52048
  cause
51087
52049
  } = {}) {
51088
- super({ name: name92, message, cause });
51089
- this[_a93] = true;
52050
+ super({ name: name102, message, cause });
52051
+ this[_a103] = true;
51090
52052
  }
51091
52053
  static isInstance(error40) {
51092
- return AISDKError.hasMarker(error40, marker93);
52054
+ return AISDKError.hasMarker(error40, marker103);
51093
52055
  }
51094
52056
  };
51095
- _a93 = symbol93;
51096
- marker102 = `vercel.ai.error.${name102}`;
51097
- symbol102 = Symbol.for(marker102);
52057
+ _a103 = symbol103;
52058
+ marker112 = `vercel.ai.error.${name112}`;
52059
+ symbol112 = Symbol.for(marker112);
51098
52060
  NoSpeechGeneratedError = class extends AISDKError {
51099
52061
  constructor(options) {
51100
52062
  super({
51101
- name: name102,
52063
+ name: name112,
51102
52064
  message: "No speech audio generated."
51103
52065
  });
51104
- this[_a102] = true;
52066
+ this[_a112] = true;
51105
52067
  this.responses = options.responses;
51106
52068
  }
51107
52069
  static isInstance(error40) {
51108
- return AISDKError.hasMarker(error40, marker102);
52070
+ return AISDKError.hasMarker(error40, marker112);
51109
52071
  }
51110
52072
  };
51111
- _a102 = symbol102;
51112
- marker112 = `vercel.ai.error.${name112}`;
51113
- symbol112 = Symbol.for(marker112);
52073
+ _a112 = symbol112;
52074
+ marker122 = `vercel.ai.error.${name122}`;
52075
+ symbol122 = Symbol.for(marker122);
51114
52076
  NoTranscriptGeneratedError = class extends AISDKError {
51115
52077
  constructor(options) {
51116
52078
  super({
51117
- name: name112,
52079
+ name: name122,
51118
52080
  message: "No transcript generated."
51119
52081
  });
51120
- this[_a112] = true;
52082
+ this[_a122] = true;
51121
52083
  this.responses = options.responses;
51122
52084
  }
51123
52085
  static isInstance(error40) {
51124
- return AISDKError.hasMarker(error40, marker112);
52086
+ return AISDKError.hasMarker(error40, marker122);
51125
52087
  }
51126
52088
  };
51127
- _a112 = symbol112;
51128
- marker122 = `vercel.ai.error.${name122}`;
51129
- symbol122 = Symbol.for(marker122);
52089
+ _a122 = symbol122;
52090
+ marker132 = `vercel.ai.error.${name132}`;
52091
+ symbol132 = Symbol.for(marker132);
51130
52092
  NoVideoGeneratedError = class extends AISDKError {
51131
52093
  constructor({
51132
52094
  message = "No video generated.",
51133
52095
  cause,
51134
52096
  responses
51135
52097
  }) {
51136
- super({ name: name122, message, cause });
51137
- this[_a122] = true;
52098
+ super({ name: name132, message, cause });
52099
+ this[_a132] = true;
51138
52100
  this.responses = responses;
51139
52101
  }
51140
52102
  static isInstance(error40) {
51141
- return AISDKError.hasMarker(error40, marker122);
52103
+ return AISDKError.hasMarker(error40, marker132);
51142
52104
  }
51143
52105
  static isNoVideoGeneratedError(error40) {
51144
- return error40 instanceof Error && error40.name === name122 && typeof error40.responses !== "undefined" ? true : false;
52106
+ return error40 instanceof Error && error40.name === name132 && typeof error40.responses !== "undefined" ? true : false;
51145
52107
  }
51146
52108
  toJSON() {
51147
52109
  return {
@@ -51153,42 +52115,42 @@ var init_dist8 = __esm(() => {
51153
52115
  };
51154
52116
  }
51155
52117
  };
51156
- _a122 = symbol122;
51157
- marker132 = `vercel.ai.error.${name132}`;
51158
- symbol132 = Symbol.for(marker132);
52118
+ _a132 = symbol132;
52119
+ marker142 = `vercel.ai.error.${name142}`;
52120
+ symbol142 = Symbol.for(marker142);
51159
52121
  NoSuchToolError = class extends AISDKError {
51160
52122
  constructor({
51161
52123
  toolName,
51162
52124
  availableTools = undefined,
51163
52125
  message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === undefined ? "No tools are available." : `Available tools: ${availableTools.join(", ")}.`}`
51164
52126
  }) {
51165
- super({ name: name132, message });
51166
- this[_a132] = true;
52127
+ super({ name: name142, message });
52128
+ this[_a142] = true;
51167
52129
  this.toolName = toolName;
51168
52130
  this.availableTools = availableTools;
51169
52131
  }
51170
52132
  static isInstance(error40) {
51171
- return AISDKError.hasMarker(error40, marker132);
52133
+ return AISDKError.hasMarker(error40, marker142);
51172
52134
  }
51173
52135
  };
51174
- _a132 = symbol132;
51175
- marker142 = `vercel.ai.error.${name142}`;
51176
- symbol142 = Symbol.for(marker142);
52136
+ _a142 = symbol142;
52137
+ marker152 = `vercel.ai.error.${name15}`;
52138
+ symbol152 = Symbol.for(marker152);
51177
52139
  ToolCallRepairError = class extends AISDKError {
51178
52140
  constructor({
51179
52141
  cause,
51180
52142
  originalError,
51181
52143
  message = `Error repairing tool call: ${getErrorMessage(cause)}`
51182
52144
  }) {
51183
- super({ name: name142, message, cause });
51184
- this[_a142] = true;
52145
+ super({ name: name15, message, cause });
52146
+ this[_a152] = true;
51185
52147
  this.originalError = originalError;
51186
52148
  }
51187
52149
  static isInstance(error40) {
51188
- return AISDKError.hasMarker(error40, marker142);
52150
+ return AISDKError.hasMarker(error40, marker152);
51189
52151
  }
51190
52152
  };
51191
- _a142 = symbol142;
52153
+ _a152 = symbol152;
51192
52154
  UnsupportedModelVersionError = class extends AISDKError {
51193
52155
  constructor(options) {
51194
52156
  super({
@@ -51200,92 +52162,92 @@ var init_dist8 = __esm(() => {
51200
52162
  this.modelId = options.modelId;
51201
52163
  }
51202
52164
  };
51203
- marker152 = `vercel.ai.error.${name15}`;
51204
- symbol152 = Symbol.for(marker152);
52165
+ marker16 = `vercel.ai.error.${name162}`;
52166
+ symbol16 = Symbol.for(marker16);
51205
52167
  UIMessageStreamError = class extends AISDKError {
51206
52168
  constructor({
51207
52169
  chunkType,
51208
52170
  chunkId,
51209
52171
  message
51210
52172
  }) {
51211
- super({ name: name15, message });
51212
- this[_a152] = true;
52173
+ super({ name: name162, message });
52174
+ this[_a16] = true;
51213
52175
  this.chunkType = chunkType;
51214
52176
  this.chunkId = chunkId;
51215
52177
  }
51216
52178
  static isInstance(error40) {
51217
- return AISDKError.hasMarker(error40, marker152);
52179
+ return AISDKError.hasMarker(error40, marker16);
51218
52180
  }
51219
52181
  };
51220
- _a152 = symbol152;
51221
- marker16 = `vercel.ai.error.${name162}`;
51222
- symbol16 = Symbol.for(marker16);
52182
+ _a16 = symbol16;
52183
+ marker172 = `vercel.ai.error.${name172}`;
52184
+ symbol172 = Symbol.for(marker172);
51223
52185
  InvalidDataContentError = class extends AISDKError {
51224
52186
  constructor({
51225
52187
  content,
51226
52188
  cause,
51227
52189
  message = `Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof content}.`
51228
52190
  }) {
51229
- super({ name: name162, message, cause });
51230
- this[_a16] = true;
52191
+ super({ name: name172, message, cause });
52192
+ this[_a172] = true;
51231
52193
  this.content = content;
51232
52194
  }
51233
52195
  static isInstance(error40) {
51234
- return AISDKError.hasMarker(error40, marker16);
52196
+ return AISDKError.hasMarker(error40, marker172);
51235
52197
  }
51236
52198
  };
51237
- _a16 = symbol16;
51238
- marker172 = `vercel.ai.error.${name172}`;
51239
- symbol172 = Symbol.for(marker172);
52199
+ _a172 = symbol172;
52200
+ marker182 = `vercel.ai.error.${name18}`;
52201
+ symbol182 = Symbol.for(marker182);
51240
52202
  InvalidMessageRoleError = class extends AISDKError {
51241
52203
  constructor({
51242
52204
  role,
51243
52205
  message = `Invalid message role: '${role}'. Must be one of: "system", "user", "assistant", "tool".`
51244
52206
  }) {
51245
- super({ name: name172, message });
51246
- this[_a172] = true;
52207
+ super({ name: name18, message });
52208
+ this[_a182] = true;
51247
52209
  this.role = role;
51248
52210
  }
51249
52211
  static isInstance(error40) {
51250
- return AISDKError.hasMarker(error40, marker172);
52212
+ return AISDKError.hasMarker(error40, marker182);
51251
52213
  }
51252
52214
  };
51253
- _a172 = symbol172;
51254
- marker182 = `vercel.ai.error.${name18}`;
51255
- symbol182 = Symbol.for(marker182);
52215
+ _a182 = symbol182;
52216
+ marker19 = `vercel.ai.error.${name19}`;
52217
+ symbol192 = Symbol.for(marker19);
51256
52218
  MessageConversionError = class extends AISDKError {
51257
52219
  constructor({
51258
52220
  originalMessage,
51259
52221
  message
51260
52222
  }) {
51261
- super({ name: name18, message });
51262
- this[_a182] = true;
52223
+ super({ name: name19, message });
52224
+ this[_a19] = true;
51263
52225
  this.originalMessage = originalMessage;
51264
52226
  }
51265
52227
  static isInstance(error40) {
51266
- return AISDKError.hasMarker(error40, marker182);
52228
+ return AISDKError.hasMarker(error40, marker19);
51267
52229
  }
51268
52230
  };
51269
- _a182 = symbol182;
51270
- marker19 = `vercel.ai.error.${name19}`;
51271
- symbol192 = Symbol.for(marker19);
52231
+ _a19 = symbol192;
52232
+ marker20 = `vercel.ai.error.${name20}`;
52233
+ symbol20 = Symbol.for(marker20);
51272
52234
  RetryError = class extends AISDKError {
51273
52235
  constructor({
51274
52236
  message,
51275
52237
  reason,
51276
52238
  errors: errors4
51277
52239
  }) {
51278
- super({ name: name19, message });
51279
- this[_a19] = true;
52240
+ super({ name: name20, message });
52241
+ this[_a20] = true;
51280
52242
  this.reason = reason;
51281
52243
  this.errors = errors4;
51282
52244
  this.lastError = errors4[errors4.length - 1];
51283
52245
  }
51284
52246
  static isInstance(error40) {
51285
- return AISDKError.hasMarker(error40, marker19);
52247
+ return AISDKError.hasMarker(error40, marker20);
51286
52248
  }
51287
52249
  };
51288
- _a19 = symbol192;
52250
+ _a20 = symbol20;
51289
52251
  imageMediaTypeSignatures = [
51290
52252
  {
51291
52253
  mediaType: "image/gif",
@@ -51469,8 +52431,8 @@ var init_dist8 = __esm(() => {
51469
52431
  exports_external2.instanceof(Uint8Array),
51470
52432
  exports_external2.instanceof(ArrayBuffer),
51471
52433
  exports_external2.custom((value) => {
51472
- var _a21, _b16;
51473
- return (_b16 = (_a21 = globalThis.Buffer) == null ? undefined : _a21.isBuffer(value)) != null ? _b16 : false;
52434
+ var _a222, _b16;
52435
+ return (_b16 = (_a222 = globalThis.Buffer) == null ? undefined : _a222.isBuffer(value)) != null ? _b16 : false;
51474
52436
  }, { message: "Must be a Buffer" })
51475
52437
  ]);
51476
52438
  jsonValueSchema3 = exports_external2.lazy(() => exports_external2.union([
@@ -51653,7 +52615,7 @@ var init_dist8 = __esm(() => {
51653
52615
  startSpan() {
51654
52616
  return noopSpan;
51655
52617
  },
51656
- startActiveSpan(name21, arg1, arg2, arg3) {
52618
+ startActiveSpan(name222, arg1, arg2, arg3) {
51657
52619
  if (typeof arg1 === "function") {
51658
52620
  return arg1(noopSpan);
51659
52621
  }
@@ -51711,6 +52673,7 @@ var init_dist8 = __esm(() => {
51711
52673
  this.type = "file";
51712
52674
  }
51713
52675
  };
52676
+ encoder = new TextEncoder;
51714
52677
  output_exports = {};
51715
52678
  __export2(output_exports, {
51716
52679
  array: () => array2,
@@ -51809,7 +52772,8 @@ var init_dist8 = __esm(() => {
51809
52772
  exports_external2.strictObject({
51810
52773
  type: exports_external2.literal("tool-approval-request"),
51811
52774
  approvalId: exports_external2.string(),
51812
- toolCallId: exports_external2.string()
52775
+ toolCallId: exports_external2.string(),
52776
+ signature: exports_external2.string().optional()
51813
52777
  }),
51814
52778
  exports_external2.strictObject({
51815
52779
  type: exports_external2.literal("tool-output-available"),
@@ -51915,6 +52879,28 @@ var init_dist8 = __esm(() => {
51915
52879
  prefix: "aitxt",
51916
52880
  size: 24
51917
52881
  });
52882
+ isOutputChunkType = {
52883
+ file: true,
52884
+ source: true,
52885
+ "text-start": true,
52886
+ "text-end": true,
52887
+ "text-delta": true,
52888
+ "reasoning-start": true,
52889
+ "reasoning-end": true,
52890
+ "reasoning-delta": true,
52891
+ "tool-input-start": true,
52892
+ "tool-input-end": true,
52893
+ "tool-input-delta": true,
52894
+ "tool-approval-request": true,
52895
+ "tool-call": true,
52896
+ "tool-result": true,
52897
+ "tool-error": true,
52898
+ "stream-start": false,
52899
+ "response-metadata": false,
52900
+ finish: false,
52901
+ error: false,
52902
+ raw: false
52903
+ };
51918
52904
  toolMetadataSchema2 = exports_external2.record(exports_external2.string(), jsonValueSchema3.optional());
51919
52905
  uiMessagesSchema = lazySchema(() => zodSchema(exports_external2.array(exports_external2.object({
51920
52906
  id: exports_external2.string(),
@@ -52003,7 +52989,8 @@ var init_dist8 = __esm(() => {
52003
52989
  approval: exports_external2.object({
52004
52990
  id: exports_external2.string(),
52005
52991
  approved: exports_external2.never().optional(),
52006
- reason: exports_external2.never().optional()
52992
+ reason: exports_external2.never().optional(),
52993
+ signature: exports_external2.string().optional()
52007
52994
  })
52008
52995
  }),
52009
52996
  exports_external2.object({
@@ -52020,7 +53007,8 @@ var init_dist8 = __esm(() => {
52020
53007
  approval: exports_external2.object({
52021
53008
  id: exports_external2.string(),
52022
53009
  approved: exports_external2.boolean(),
52023
- reason: exports_external2.string().optional()
53010
+ reason: exports_external2.string().optional(),
53011
+ signature: exports_external2.string().optional()
52024
53012
  })
52025
53013
  }),
52026
53014
  exports_external2.object({
@@ -52039,7 +53027,8 @@ var init_dist8 = __esm(() => {
52039
53027
  approval: exports_external2.object({
52040
53028
  id: exports_external2.string(),
52041
53029
  approved: exports_external2.literal(true),
52042
- reason: exports_external2.string().optional()
53030
+ reason: exports_external2.string().optional(),
53031
+ signature: exports_external2.string().optional()
52043
53032
  }).optional()
52044
53033
  }),
52045
53034
  exports_external2.object({
@@ -52058,7 +53047,8 @@ var init_dist8 = __esm(() => {
52058
53047
  approval: exports_external2.object({
52059
53048
  id: exports_external2.string(),
52060
53049
  approved: exports_external2.literal(true),
52061
- reason: exports_external2.string().optional()
53050
+ reason: exports_external2.string().optional(),
53051
+ signature: exports_external2.string().optional()
52062
53052
  }).optional()
52063
53053
  }),
52064
53054
  exports_external2.object({
@@ -52075,7 +53065,8 @@ var init_dist8 = __esm(() => {
52075
53065
  approval: exports_external2.object({
52076
53066
  id: exports_external2.string(),
52077
53067
  approved: exports_external2.literal(false),
52078
- reason: exports_external2.string().optional()
53068
+ reason: exports_external2.string().optional(),
53069
+ signature: exports_external2.string().optional()
52079
53070
  })
52080
53071
  }),
52081
53072
  exports_external2.object({
@@ -52115,7 +53106,8 @@ var init_dist8 = __esm(() => {
52115
53106
  approval: exports_external2.object({
52116
53107
  id: exports_external2.string(),
52117
53108
  approved: exports_external2.never().optional(),
52118
- reason: exports_external2.never().optional()
53109
+ reason: exports_external2.never().optional(),
53110
+ signature: exports_external2.string().optional()
52119
53111
  })
52120
53112
  }),
52121
53113
  exports_external2.object({
@@ -52131,7 +53123,8 @@ var init_dist8 = __esm(() => {
52131
53123
  approval: exports_external2.object({
52132
53124
  id: exports_external2.string(),
52133
53125
  approved: exports_external2.boolean(),
52134
- reason: exports_external2.string().optional()
53126
+ reason: exports_external2.string().optional(),
53127
+ signature: exports_external2.string().optional()
52135
53128
  })
52136
53129
  }),
52137
53130
  exports_external2.object({
@@ -52149,7 +53142,8 @@ var init_dist8 = __esm(() => {
52149
53142
  approval: exports_external2.object({
52150
53143
  id: exports_external2.string(),
52151
53144
  approved: exports_external2.literal(true),
52152
- reason: exports_external2.string().optional()
53145
+ reason: exports_external2.string().optional(),
53146
+ signature: exports_external2.string().optional()
52153
53147
  }).optional()
52154
53148
  }),
52155
53149
  exports_external2.object({
@@ -52167,7 +53161,8 @@ var init_dist8 = __esm(() => {
52167
53161
  approval: exports_external2.object({
52168
53162
  id: exports_external2.string(),
52169
53163
  approved: exports_external2.literal(true),
52170
- reason: exports_external2.string().optional()
53164
+ reason: exports_external2.string().optional(),
53165
+ signature: exports_external2.string().optional()
52171
53166
  }).optional()
52172
53167
  }),
52173
53168
  exports_external2.object({
@@ -52183,7 +53178,8 @@ var init_dist8 = __esm(() => {
52183
53178
  approval: exports_external2.object({
52184
53179
  id: exports_external2.string(),
52185
53180
  approved: exports_external2.literal(false),
52186
- reason: exports_external2.string().optional()
53181
+ reason: exports_external2.string().optional(),
53182
+ signature: exports_external2.string().optional()
52187
53183
  })
52188
53184
  })
52189
53185
  ])).nonempty("Message must contain at least one part")
@@ -52244,8 +53240,8 @@ var init_dist8 = __esm(() => {
52244
53240
  };
52245
53241
  defaultDownload = createDownload();
52246
53242
  experimental_customProvider = customProvider;
52247
- marker20 = `vercel.ai.error.${name20}`;
52248
- symbol20 = Symbol.for(marker20);
53243
+ marker21 = `vercel.ai.error.${name21}`;
53244
+ symbol21 = Symbol.for(marker21);
52249
53245
  NoSuchProviderError = class extends NoSuchModelError {
52250
53246
  constructor({
52251
53247
  modelId,
@@ -52254,16 +53250,16 @@ var init_dist8 = __esm(() => {
52254
53250
  availableProviders,
52255
53251
  message = `No such provider: ${providerId} (available providers: ${availableProviders.join()})`
52256
53252
  }) {
52257
- super({ errorName: name20, modelId, modelType, message });
52258
- this[_a20] = true;
53253
+ super({ errorName: name21, modelId, modelType, message });
53254
+ this[_a21] = true;
52259
53255
  this.providerId = providerId;
52260
53256
  this.availableProviders = availableProviders;
52261
53257
  }
52262
53258
  static isInstance(error40) {
52263
- return AISDKError.hasMarker(error40, marker20);
53259
+ return AISDKError.hasMarker(error40, marker21);
52264
53260
  }
52265
53261
  };
52266
- _a20 = symbol20;
53262
+ _a21 = symbol21;
52267
53263
  experimental_createProviderRegistry = createProviderRegistry;
52268
53264
  defaultDownload2 = createDownload();
52269
53265
  DefaultChatTransport = class extends HttpChatTransport {
@@ -52334,8 +53330,8 @@ function buildOpenApiDocument(version2) {
52334
53330
  for (const route of routes) {
52335
53331
  const p = toV1Path(route.path);
52336
53332
  const method = route.method.toLowerCase();
52337
- const params = route.paramNames.map((name21) => ({
52338
- name: name21,
53333
+ const params = route.paramNames.map((name24) => ({
53334
+ name: name24,
52339
53335
  in: "path",
52340
53336
  required: true,
52341
53337
  schema: { type: "string" }
@@ -58964,10 +59960,10 @@ function startServer(port) {
58964
59960
  if (routePath === "/api/memories/stream" && req.method === "GET") {
58965
59961
  const stream = new ReadableStream({
58966
59962
  start(controller) {
58967
- const encoder = new TextEncoder;
59963
+ const encoder2 = new TextEncoder;
58968
59964
  let lastSeen = new Date().toISOString();
58969
59965
  const send = (data) => {
58970
- controller.enqueue(encoder.encode(`data: ${JSON.stringify(data)}
59966
+ controller.enqueue(encoder2.encode(`data: ${JSON.stringify(data)}
58971
59967
 
58972
59968
  `));
58973
59969
  };