ai 7.0.86 → 7.0.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __export = (target, all) => {
3
- for (var name24 in all)
4
- __defProp(target, name24, { get: all[name24], enumerable: true });
3
+ for (var name25 in all)
4
+ __defProp(target, name25, { get: all[name25], enumerable: true });
5
5
  };
6
6
 
7
7
  // src/index.ts
@@ -37,7 +37,7 @@ import {
37
37
 
38
38
  // src/error/index.ts
39
39
  import {
40
- AISDKError as AISDKError24,
40
+ AISDKError as AISDKError25,
41
41
  APICallError,
42
42
  EmptyResponseBodyError,
43
43
  InvalidPromptError,
@@ -454,9 +454,39 @@ var ToolCallRepairError = class extends (_b17 = AISDKError17, _a17 = symbol17, _
454
454
  }
455
455
  };
456
456
 
457
+ // src/error/tool-choice-violation-error.ts
458
+ import {
459
+ AISDKError as AISDKError18
460
+ } from "@ai-sdk/provider";
461
+ var name18 = "AI_ToolChoiceViolationError";
462
+ var marker18 = `vercel.ai.error.${name18}`;
463
+ var symbol18 = Symbol.for(marker18);
464
+ var _a18, _b18;
465
+ var ToolChoiceViolationError = class extends (_b18 = AISDKError18, _a18 = symbol18, _b18) {
466
+ constructor({
467
+ toolChoice,
468
+ finishReason,
469
+ provider,
470
+ modelId,
471
+ content,
472
+ message = toolChoice.type === "required" ? "Model response did not contain a tool call even though tool choice was required." : `Model response did not contain a call to the required tool '${toolChoice.toolName}'.`
473
+ }) {
474
+ super({ name: name18, message });
475
+ this[_a18] = true;
476
+ this.toolChoice = toolChoice;
477
+ this.finishReason = finishReason;
478
+ this.provider = provider;
479
+ this.modelId = modelId;
480
+ this.content = content;
481
+ }
482
+ static isInstance(error) {
483
+ return AISDKError18.hasMarker(error, marker18);
484
+ }
485
+ };
486
+
457
487
  // src/error/unsupported-model-version-error.ts
458
- import { AISDKError as AISDKError18 } from "@ai-sdk/provider";
459
- var UnsupportedModelVersionError = class extends AISDKError18 {
488
+ import { AISDKError as AISDKError19 } from "@ai-sdk/provider";
489
+ var UnsupportedModelVersionError = class extends AISDKError19 {
460
490
  constructor(options) {
461
491
  super({
462
492
  name: "AI_UnsupportedModelVersionError",
@@ -469,85 +499,85 @@ var UnsupportedModelVersionError = class extends AISDKError18 {
469
499
  };
470
500
 
471
501
  // src/error/ui-message-stream-error.ts
472
- import { AISDKError as AISDKError19 } from "@ai-sdk/provider";
473
- var name18 = "AI_UIMessageStreamError";
474
- var marker18 = `vercel.ai.error.${name18}`;
475
- var symbol18 = Symbol.for(marker18);
476
- var _a18, _b18;
477
- var UIMessageStreamError = class extends (_b18 = AISDKError19, _a18 = symbol18, _b18) {
502
+ import { AISDKError as AISDKError20 } from "@ai-sdk/provider";
503
+ var name19 = "AI_UIMessageStreamError";
504
+ var marker19 = `vercel.ai.error.${name19}`;
505
+ var symbol19 = Symbol.for(marker19);
506
+ var _a19, _b19;
507
+ var UIMessageStreamError = class extends (_b19 = AISDKError20, _a19 = symbol19, _b19) {
478
508
  constructor({
479
509
  chunkType,
480
510
  chunkId,
481
511
  message
482
512
  }) {
483
- super({ name: name18, message });
484
- this[_a18] = true;
513
+ super({ name: name19, message });
514
+ this[_a19] = true;
485
515
  this.chunkType = chunkType;
486
516
  this.chunkId = chunkId;
487
517
  }
488
518
  static isInstance(error) {
489
- return AISDKError19.hasMarker(error, marker18);
519
+ return AISDKError20.hasMarker(error, marker19);
490
520
  }
491
521
  };
492
522
 
493
523
  // src/prompt/invalid-data-content-error.ts
494
- import { AISDKError as AISDKError20 } from "@ai-sdk/provider";
495
- var name19 = "AI_InvalidDataContentError";
496
- var marker19 = `vercel.ai.error.${name19}`;
497
- var symbol19 = Symbol.for(marker19);
498
- var _a19, _b19;
499
- var InvalidDataContentError = class extends (_b19 = AISDKError20, _a19 = symbol19, _b19) {
524
+ import { AISDKError as AISDKError21 } from "@ai-sdk/provider";
525
+ var name20 = "AI_InvalidDataContentError";
526
+ var marker20 = `vercel.ai.error.${name20}`;
527
+ var symbol20 = Symbol.for(marker20);
528
+ var _a20, _b20;
529
+ var InvalidDataContentError = class extends (_b20 = AISDKError21, _a20 = symbol20, _b20) {
500
530
  constructor({
501
531
  content,
502
532
  cause,
503
533
  message = `Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof content}.`
504
534
  }) {
505
- super({ name: name19, message, cause });
506
- this[_a19] = true;
535
+ super({ name: name20, message, cause });
536
+ this[_a20] = true;
507
537
  this.content = content;
508
538
  }
509
539
  static isInstance(error) {
510
- return AISDKError20.hasMarker(error, marker19);
540
+ return AISDKError21.hasMarker(error, marker20);
511
541
  }
512
542
  };
513
543
 
514
544
  // src/prompt/invalid-message-role-error.ts
515
- import { AISDKError as AISDKError21 } from "@ai-sdk/provider";
516
- var name20 = "AI_InvalidMessageRoleError";
517
- var marker20 = `vercel.ai.error.${name20}`;
518
- var symbol20 = Symbol.for(marker20);
519
- var _a20, _b20;
520
- var InvalidMessageRoleError = class extends (_b20 = AISDKError21, _a20 = symbol20, _b20) {
545
+ import { AISDKError as AISDKError22 } from "@ai-sdk/provider";
546
+ var name21 = "AI_InvalidMessageRoleError";
547
+ var marker21 = `vercel.ai.error.${name21}`;
548
+ var symbol21 = Symbol.for(marker21);
549
+ var _a21, _b21;
550
+ var InvalidMessageRoleError = class extends (_b21 = AISDKError22, _a21 = symbol21, _b21) {
521
551
  constructor({
522
552
  role,
523
553
  message = `Invalid message role: '${role}'. Must be one of: "system", "user", "assistant", "tool".`
524
554
  }) {
525
- super({ name: name20, message });
526
- this[_a20] = true;
555
+ super({ name: name21, message });
556
+ this[_a21] = true;
527
557
  this.role = role;
528
558
  }
529
559
  static isInstance(error) {
530
- return AISDKError21.hasMarker(error, marker20);
560
+ return AISDKError22.hasMarker(error, marker21);
531
561
  }
532
562
  };
533
563
 
534
564
  // src/prompt/message-conversion-error.ts
535
- import { AISDKError as AISDKError22 } from "@ai-sdk/provider";
536
- var name21 = "AI_MessageConversionError";
537
- var marker21 = `vercel.ai.error.${name21}`;
538
- var symbol21 = Symbol.for(marker21);
539
- var _a21, _b21;
540
- var MessageConversionError = class extends (_b21 = AISDKError22, _a21 = symbol21, _b21) {
565
+ import { AISDKError as AISDKError23 } from "@ai-sdk/provider";
566
+ var name22 = "AI_MessageConversionError";
567
+ var marker22 = `vercel.ai.error.${name22}`;
568
+ var symbol22 = Symbol.for(marker22);
569
+ var _a22, _b22;
570
+ var MessageConversionError = class extends (_b22 = AISDKError23, _a22 = symbol22, _b22) {
541
571
  constructor({
542
572
  originalMessage,
543
573
  message
544
574
  }) {
545
- super({ name: name21, message });
546
- this[_a21] = true;
575
+ super({ name: name22, message });
576
+ this[_a22] = true;
547
577
  this.originalMessage = originalMessage;
548
578
  }
549
579
  static isInstance(error) {
550
- return AISDKError22.hasMarker(error, marker21);
580
+ return AISDKError23.hasMarker(error, marker22);
551
581
  }
552
582
  };
553
583
 
@@ -555,25 +585,25 @@ var MessageConversionError = class extends (_b21 = AISDKError22, _a21 = symbol21
555
585
  import { DownloadError } from "@ai-sdk/provider-utils";
556
586
 
557
587
  // src/util/retry-error.ts
558
- import { AISDKError as AISDKError23 } from "@ai-sdk/provider";
559
- var name22 = "AI_RetryError";
560
- var marker22 = `vercel.ai.error.${name22}`;
561
- var symbol22 = Symbol.for(marker22);
562
- var _a22, _b22;
563
- var RetryError = class extends (_b22 = AISDKError23, _a22 = symbol22, _b22) {
588
+ import { AISDKError as AISDKError24 } from "@ai-sdk/provider";
589
+ var name23 = "AI_RetryError";
590
+ var marker23 = `vercel.ai.error.${name23}`;
591
+ var symbol23 = Symbol.for(marker23);
592
+ var _a23, _b23;
593
+ var RetryError = class extends (_b23 = AISDKError24, _a23 = symbol23, _b23) {
564
594
  constructor({
565
595
  message,
566
596
  reason,
567
597
  errors
568
598
  }) {
569
- super({ name: name22, message });
570
- this[_a22] = true;
599
+ super({ name: name23, message });
600
+ this[_a23] = true;
571
601
  this.reason = reason;
572
602
  this.errors = errors;
573
603
  this.lastError = errors[errors.length - 1];
574
604
  }
575
605
  static isInstance(error) {
576
- return AISDKError23.hasMarker(error, marker22);
606
+ return AISDKError24.hasMarker(error, marker23);
577
607
  }
578
608
  };
579
609
 
@@ -984,9 +1014,9 @@ function resolveEmbeddingModel(model) {
984
1014
  return asEmbeddingModelV4(model);
985
1015
  }
986
1016
  function resolveTranscriptionModel(model) {
987
- var _a24, _b24;
1017
+ var _a25, _b25;
988
1018
  if (typeof model === "string") {
989
- return (_b24 = (_a24 = getGlobalProvider()).transcriptionModel) == null ? void 0 : _b24.call(_a24, model);
1019
+ return (_b25 = (_a25 = getGlobalProvider()).transcriptionModel) == null ? void 0 : _b25.call(_a25, model);
990
1020
  }
991
1021
  if (!["v4", "v3", "v2"].includes(model.specificationVersion)) {
992
1022
  const unsupportedModel = model;
@@ -999,9 +1029,9 @@ function resolveTranscriptionModel(model) {
999
1029
  return asTranscriptionModelV4(model);
1000
1030
  }
1001
1031
  function resolveSpeechTranslationModel(model) {
1002
- var _a24;
1032
+ var _a25;
1003
1033
  if (typeof model === "string") {
1004
- const provider = (_a24 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a24 : gateway;
1034
+ const provider = (_a25 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a25 : gateway;
1005
1035
  const speechTranslationModel = provider.speechTranslationModel;
1006
1036
  if (!speechTranslationModel) {
1007
1037
  throw new Error(
@@ -1021,9 +1051,9 @@ function resolveSpeechTranslationModel(model) {
1021
1051
  return model;
1022
1052
  }
1023
1053
  function resolveSpeechModel(model) {
1024
- var _a24, _b24;
1054
+ var _a25, _b25;
1025
1055
  if (typeof model === "string") {
1026
- return (_b24 = (_a24 = getGlobalProvider()).speechModel) == null ? void 0 : _b24.call(_a24, model);
1056
+ return (_b25 = (_a25 = getGlobalProvider()).speechModel) == null ? void 0 : _b25.call(_a25, model);
1027
1057
  }
1028
1058
  if (!["v4", "v3", "v2"].includes(model.specificationVersion)) {
1029
1059
  const unsupportedModel = model;
@@ -1050,9 +1080,9 @@ function resolveImageModel(model) {
1050
1080
  return asImageModelV4(model);
1051
1081
  }
1052
1082
  function resolveVideoModel(model) {
1053
- var _a24;
1083
+ var _a25;
1054
1084
  if (typeof model === "string") {
1055
- const provider = (_a24 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a24 : gateway;
1085
+ const provider = (_a25 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a25 : gateway;
1056
1086
  const videoModel = provider.videoModel;
1057
1087
  if (!videoModel) {
1058
1088
  throw new Error(
@@ -1093,8 +1123,8 @@ function resolveRerankingModel(model) {
1093
1123
  return asRerankingModelV4(model);
1094
1124
  }
1095
1125
  function getGlobalProvider() {
1096
- var _a24;
1097
- const provider = (_a24 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a24 : gateway;
1126
+ var _a25;
1127
+ const provider = (_a25 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a25 : gateway;
1098
1128
  return asProviderV4(provider);
1099
1129
  }
1100
1130
 
@@ -1146,7 +1176,7 @@ import {
1146
1176
  } from "@ai-sdk/provider-utils";
1147
1177
 
1148
1178
  // src/version.ts
1149
- var VERSION = true ? "7.0.86" : "0.0.0-test";
1179
+ var VERSION = true ? "7.0.88" : "0.0.0-test";
1150
1180
 
1151
1181
  // src/util/download/download.ts
1152
1182
  var download = async ({
@@ -1154,7 +1184,7 @@ var download = async ({
1154
1184
  maxBytes,
1155
1185
  abortSignal
1156
1186
  }) => {
1157
- var _a24;
1187
+ var _a25;
1158
1188
  const urlText = url.toString();
1159
1189
  try {
1160
1190
  const headers = withUserAgentSuffix(
@@ -1182,7 +1212,7 @@ var download = async ({
1182
1212
  });
1183
1213
  return {
1184
1214
  data,
1185
- mediaType: (_a24 = response.headers.get("content-type")) != null ? _a24 : void 0
1215
+ mediaType: (_a25 = response.headers.get("content-type")) != null ? _a25 : void 0
1186
1216
  };
1187
1217
  } catch (error) {
1188
1218
  if (DownloadError2.isInstance(error)) {
@@ -1647,14 +1677,14 @@ function convertToLanguageModelMessage({
1647
1677
  }
1648
1678
  }
1649
1679
  function convertImagePartToFilePart(part) {
1650
- var _a24;
1680
+ var _a25;
1651
1681
  if (part.type !== "image") {
1652
1682
  return part;
1653
1683
  }
1654
1684
  return {
1655
1685
  type: "file",
1656
1686
  data: part.image,
1657
- mediaType: (_a24 = part.mediaType) != null ? _a24 : "image",
1687
+ mediaType: (_a25 = part.mediaType) != null ? _a25 : "image",
1658
1688
  providerOptions: part.providerOptions
1659
1689
  };
1660
1690
  }
@@ -1776,7 +1806,7 @@ function mapToolResultOutput({
1776
1806
  return {
1777
1807
  type: "content",
1778
1808
  value: output.value.map((item) => {
1779
- var _a24;
1809
+ var _a25;
1780
1810
  switch (item.type) {
1781
1811
  case "file": {
1782
1812
  const convertedPart = convertPartToLanguageModelPart(
@@ -1805,7 +1835,7 @@ function mapToolResultOutput({
1805
1835
  };
1806
1836
  }
1807
1837
  case "file-url": {
1808
- const mediaType = (_a24 = item.mediaType) != null ? _a24 : getMediaTypeFromUrl(item.url);
1838
+ const mediaType = (_a25 = item.mediaType) != null ? _a25 : getMediaTypeFromUrl(item.url);
1809
1839
  let message = `The "file-url" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'url', url } instead.`;
1810
1840
  if (!item.mediaType) {
1811
1841
  const inferenceSuffix = mediaType === "application/octet-stream" ? `Unable to infer media type from URL. Defaulting to 'application/octet-stream'.` : `Inferred media type '${mediaType}' from URL.`;
@@ -1961,10 +1991,10 @@ var URL_EXTENSION_TO_MEDIA_TYPE = {
1961
1991
  ogg: "audio/ogg"
1962
1992
  };
1963
1993
  function getMediaTypeFromUrl(url, fallbackMediaType = "application/octet-stream") {
1964
- var _a24;
1994
+ var _a25;
1965
1995
  try {
1966
1996
  const pathname = new URL(url).pathname;
1967
- const fileExtension = (_a24 = pathname.split(".").pop()) == null ? void 0 : _a24.toLowerCase();
1997
+ const fileExtension = (_a25 = pathname.split(".").pop()) == null ? void 0 : _a25.toLowerCase();
1968
1998
  if (fileExtension && Object.hasOwn(URL_EXTENSION_TO_MEDIA_TYPE, fileExtension)) {
1969
1999
  return URL_EXTENSION_TO_MEDIA_TYPE[fileExtension];
1970
2000
  }
@@ -2119,7 +2149,7 @@ async function prepareTools({
2119
2149
  return void 0;
2120
2150
  }
2121
2151
  const languageModelTools = [];
2122
- for (const [name24, tool2] of orderToolEntries({ tools, toolOrder })) {
2152
+ for (const [name25, tool2] of orderToolEntries({ tools, toolOrder })) {
2123
2153
  const toolType = tool2.type;
2124
2154
  switch (toolType) {
2125
2155
  case void 0:
@@ -2127,7 +2157,7 @@ async function prepareTools({
2127
2157
  case "function": {
2128
2158
  const description = resolveToolDescription({
2129
2159
  tool: tool2,
2130
- toolName: name24,
2160
+ toolName: name25,
2131
2161
  toolsContext,
2132
2162
  experimental_sandbox: sandbox
2133
2163
  });
@@ -2136,7 +2166,7 @@ async function prepareTools({
2136
2166
  const strict = tool2.strict;
2137
2167
  languageModelTools.push({
2138
2168
  type: "function",
2139
- name: name24,
2169
+ name: name25,
2140
2170
  inputSchema: await asSchema(tool2.inputSchema).jsonSchema,
2141
2171
  ...description != null ? { description } : {},
2142
2172
  ...inputExamples != null ? { inputExamples } : {},
@@ -2148,7 +2178,7 @@ async function prepareTools({
2148
2178
  case "provider": {
2149
2179
  languageModelTools.push({
2150
2180
  type: "provider",
2151
- name: name24,
2181
+ name: name25,
2152
2182
  id: tool2.id,
2153
2183
  args: tool2.args
2154
2184
  });
@@ -2170,10 +2200,10 @@ function orderToolEntries({
2170
2200
  return Object.entries(tools);
2171
2201
  }
2172
2202
  const toolEntries = Object.entries(tools);
2173
- const orderedTools = toolEntries.filter(([name24]) => toolOrder.includes(name24)).sort(
2203
+ const orderedTools = toolEntries.filter(([name25]) => toolOrder.includes(name25)).sort(
2174
2204
  ([nameA], [nameB]) => toolOrder.indexOf(nameA) - toolOrder.indexOf(nameB)
2175
2205
  );
2176
- const unorderedTools = toolEntries.filter(([name24]) => !toolOrder.includes(name24)).sort(([nameA], [nameB]) => nameA < nameB ? -1 : nameA > nameB ? 1 : 0);
2206
+ const unorderedTools = toolEntries.filter(([name25]) => !toolOrder.includes(name25)).sort(([nameA], [nameB]) => nameA < nameB ? -1 : nameA > nameB ? 1 : 0);
2177
2207
  return [...orderedTools, ...unorderedTools];
2178
2208
  }
2179
2209
  function resolveToolDescription({
@@ -2217,11 +2247,11 @@ function getChunkTimeoutMs(timeout) {
2217
2247
  return timeout.chunkMs;
2218
2248
  }
2219
2249
  function getToolTimeoutMs(timeout, toolName) {
2220
- var _a24, _b24;
2250
+ var _a25, _b25;
2221
2251
  if (timeout == null || typeof timeout === "number") {
2222
2252
  return void 0;
2223
2253
  }
2224
- return (_b24 = (_a24 = timeout.tools) == null ? void 0 : _a24[`${toolName}Ms`]) != null ? _b24 : timeout.toolMs;
2254
+ return (_b25 = (_a25 = timeout.tools) == null ? void 0 : _a25[`${toolName}Ms`]) != null ? _b25 : timeout.toolMs;
2225
2255
  }
2226
2256
 
2227
2257
  // src/prompt/standardize-prompt.ts
@@ -2604,13 +2634,13 @@ async function standardizePrompt({
2604
2634
 
2605
2635
  // src/prompt/wrap-gateway-error.ts
2606
2636
  import { GatewayAuthenticationError } from "@ai-sdk/gateway";
2607
- import { AISDKError as AISDKError25 } from "@ai-sdk/provider";
2637
+ import { AISDKError as AISDKError26 } from "@ai-sdk/provider";
2608
2638
  function wrapGatewayError(error) {
2609
2639
  if (!GatewayAuthenticationError.isInstance(error)) return error;
2610
2640
  const isProductionEnv = (process == null ? void 0 : process.env.NODE_ENV) === "production";
2611
2641
  const moreInfoURL = "https://ai-sdk.dev/unauthenticated-ai-gateway";
2612
2642
  if (isProductionEnv) {
2613
- return new AISDKError25({
2643
+ return new AISDKError26({
2614
2644
  name: "GatewayError",
2615
2645
  message: `Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${moreInfoURL}`
2616
2646
  });
@@ -2668,13 +2698,13 @@ function createNullLanguageModelUsage() {
2668
2698
  };
2669
2699
  }
2670
2700
  function addLanguageModelUsage(usage1, usage2) {
2671
- var _a24, _b24, _c, _d, _e, _f, _g, _h, _i, _j;
2701
+ var _a25, _b25, _c, _d, _e, _f, _g, _h, _i, _j;
2672
2702
  return {
2673
2703
  inputTokens: addTokenCounts(usage1.inputTokens, usage2.inputTokens),
2674
2704
  inputTokenDetails: {
2675
2705
  noCacheTokens: addTokenCounts(
2676
- (_a24 = usage1.inputTokenDetails) == null ? void 0 : _a24.noCacheTokens,
2677
- (_b24 = usage2.inputTokenDetails) == null ? void 0 : _b24.noCacheTokens
2706
+ (_a25 = usage1.inputTokenDetails) == null ? void 0 : _a25.noCacheTokens,
2707
+ (_b25 = usage2.inputTokenDetails) == null ? void 0 : _b25.noCacheTokens
2678
2708
  ),
2679
2709
  cacheReadTokens: addTokenCounts(
2680
2710
  (_c = usage1.inputTokenDetails) == null ? void 0 : _c.cacheReadTokens,
@@ -2726,8 +2756,8 @@ function mergeAbortSignals(...signals) {
2726
2756
 
2727
2757
  // src/util/now.ts
2728
2758
  function now() {
2729
- var _a24, _b24;
2730
- return (_b24 = (_a24 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a24.now()) != null ? _b24 : Date.now();
2759
+ var _a25, _b25;
2760
+ return (_b25 = (_a25 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a25.now()) != null ? _b25 : Date.now();
2731
2761
  }
2732
2762
 
2733
2763
  // src/util/notify.ts
@@ -3285,7 +3315,7 @@ function filterActiveTools({
3285
3315
  return tools;
3286
3316
  }
3287
3317
  return Object.fromEntries(
3288
- Object.entries(tools).filter(([name24]) => activeTools.includes(name24))
3318
+ Object.entries(tools).filter(([name25]) => activeTools.includes(name25))
3289
3319
  );
3290
3320
  }
3291
3321
 
@@ -3685,7 +3715,7 @@ var text = () => ({
3685
3715
  });
3686
3716
  var object2 = ({
3687
3717
  schema: inputSchema,
3688
- name: name24,
3718
+ name: name25,
3689
3719
  description
3690
3720
  }) => {
3691
3721
  const schema = asSchema2(inputSchema);
@@ -3694,7 +3724,7 @@ var object2 = ({
3694
3724
  responseFormat: resolve(schema.jsonSchema).then((jsonSchema2) => ({
3695
3725
  type: "json",
3696
3726
  schema: jsonSchema2,
3697
- ...name24 != null && { name: name24 },
3727
+ ...name25 != null && { name: name25 },
3698
3728
  ...description != null && { description }
3699
3729
  })),
3700
3730
  async parseCompleteOutput({ text: text2 }, context) {
@@ -3748,7 +3778,7 @@ var object2 = ({
3748
3778
  };
3749
3779
  var array2 = ({
3750
3780
  element: inputElementSchema,
3751
- name: name24,
3781
+ name: name25,
3752
3782
  description
3753
3783
  }) => {
3754
3784
  const elementSchema = asSchema2(inputElementSchema);
@@ -3775,7 +3805,7 @@ var array2 = ({
3775
3805
  required: ["elements"],
3776
3806
  additionalProperties: false
3777
3807
  },
3778
- ...name24 != null && { name: name24 },
3808
+ ...name25 != null && { name: name25 },
3779
3809
  ...description != null && { description }
3780
3810
  };
3781
3811
  }),
@@ -3869,7 +3899,7 @@ var array2 = ({
3869
3899
  };
3870
3900
  var choice = ({
3871
3901
  options: choiceOptions,
3872
- name: name24,
3902
+ name: name25,
3873
3903
  description
3874
3904
  }) => {
3875
3905
  return {
@@ -3886,7 +3916,7 @@ var choice = ({
3886
3916
  required: ["result"],
3887
3917
  additionalProperties: false
3888
3918
  },
3889
- ...name24 != null && { name: name24 },
3919
+ ...name25 != null && { name: name25 },
3890
3920
  ...description != null && { description }
3891
3921
  }),
3892
3922
  async parseCompleteOutput({ text: text2 }, context) {
@@ -3947,14 +3977,14 @@ var choice = ({
3947
3977
  };
3948
3978
  };
3949
3979
  var json = ({
3950
- name: name24,
3980
+ name: name25,
3951
3981
  description
3952
3982
  } = {}) => {
3953
3983
  return {
3954
3984
  name: "json",
3955
3985
  responseFormat: Promise.resolve({
3956
3986
  type: "json",
3957
- ...name24 != null && { name: name24 },
3987
+ ...name25 != null && { name: name25 },
3958
3988
  ...description != null && { description }
3959
3989
  }),
3960
3990
  async parseCompleteOutput({ text: text2 }, context) {
@@ -4029,8 +4059,8 @@ async function parseToolCall({
4029
4059
  toolCall,
4030
4060
  tools,
4031
4061
  inputSchema: async ({ toolName }) => {
4032
- var _a24;
4033
- const inputSchema = (_a24 = getOwn(tools, toolName)) == null ? void 0 : _a24.inputSchema;
4062
+ var _a25;
4063
+ const inputSchema = (_a25 = getOwn(tools, toolName)) == null ? void 0 : _a25.inputSchema;
4034
4064
  return await asSchema3(inputSchema).jsonSchema;
4035
4065
  },
4036
4066
  instructions,
@@ -4154,10 +4184,10 @@ function prepareStepCallSettings({
4154
4184
  callSettings,
4155
4185
  stepSettings
4156
4186
  }) {
4157
- var _a24, _b24, _c, _d, _e, _f, _g, _h, _i;
4187
+ var _a25, _b25, _c, _d, _e, _f, _g, _h, _i;
4158
4188
  return prepareLanguageModelCallOptions({
4159
- maxOutputTokens: (_a24 = stepSettings == null ? void 0 : stepSettings.maxOutputTokens) != null ? _a24 : callSettings.maxOutputTokens,
4160
- temperature: (_b24 = stepSettings == null ? void 0 : stepSettings.temperature) != null ? _b24 : callSettings.temperature,
4189
+ maxOutputTokens: (_a25 = stepSettings == null ? void 0 : stepSettings.maxOutputTokens) != null ? _a25 : callSettings.maxOutputTokens,
4190
+ temperature: (_b25 = stepSettings == null ? void 0 : stepSettings.temperature) != null ? _b25 : callSettings.temperature,
4161
4191
  topP: (_c = stepSettings == null ? void 0 : stepSettings.topP) != null ? _c : callSettings.topP,
4162
4192
  topK: (_d = stepSettings == null ? void 0 : stepSettings.topK) != null ? _d : callSettings.topK,
4163
4193
  presencePenalty: (_e = stepSettings == null ? void 0 : stepSettings.presencePenalty) != null ? _e : callSettings.presencePenalty,
@@ -4288,8 +4318,8 @@ var AI_SDK_TELEMETRY_TRACING_CHANNEL = "ai:telemetry";
4288
4318
 
4289
4319
  // src/util/is-node-runtime.ts
4290
4320
  function isNodeRuntime() {
4291
- var _a24;
4292
- return typeof process !== "undefined" && ((_a24 = process.release) == null ? void 0 : _a24.name) === "node";
4321
+ var _a25;
4322
+ return typeof process !== "undefined" && ((_a25 = process.release) == null ? void 0 : _a25.name) === "node";
4293
4323
  }
4294
4324
 
4295
4325
  // src/telemetry/tracing-channel-publisher.ts
@@ -4306,18 +4336,18 @@ async function loadDiagnosticsChannel() {
4306
4336
  return diagnosticsChannelPromise;
4307
4337
  }
4308
4338
  function loadBuiltinModule(id) {
4309
- var _a24;
4339
+ var _a25;
4310
4340
  const processWithBuiltins = globalThis.process;
4311
4341
  try {
4312
- return (_a24 = processWithBuiltins == null ? void 0 : processWithBuiltins.getBuiltinModule) == null ? void 0 : _a24.call(processWithBuiltins, id);
4342
+ return (_a25 = processWithBuiltins == null ? void 0 : processWithBuiltins.getBuiltinModule) == null ? void 0 : _a25.call(processWithBuiltins, id);
4313
4343
  } catch (e) {
4314
4344
  return void 0;
4315
4345
  }
4316
4346
  }
4317
4347
  async function runWithTracingChannelSpan(message, execute) {
4318
- var _a24;
4348
+ var _a25;
4319
4349
  const diagnosticsChannel = await loadDiagnosticsChannel();
4320
- const tracingChannel = (_a24 = diagnosticsChannel == null ? void 0 : diagnosticsChannel.tracingChannel) == null ? void 0 : _a24.call(
4350
+ const tracingChannel = (_a25 = diagnosticsChannel == null ? void 0 : diagnosticsChannel.tracingChannel) == null ? void 0 : _a25.call(
4321
4351
  diagnosticsChannel,
4322
4352
  AI_SDK_TELEMETRY_TRACING_CHANNEL
4323
4353
  );
@@ -4368,7 +4398,7 @@ function openTelemetryChannelSpanContext({
4368
4398
  message,
4369
4399
  completion
4370
4400
  }) {
4371
- var _a24;
4401
+ var _a25;
4372
4402
  if (!isNodeRuntime()) {
4373
4403
  return void 0;
4374
4404
  }
@@ -4376,7 +4406,7 @@ function openTelemetryChannelSpanContext({
4376
4406
  "node:diagnostics_channel"
4377
4407
  );
4378
4408
  const asyncHooks = loadBuiltinModule("node:async_hooks");
4379
- const tracingChannel = (_a24 = diagnosticsChannel == null ? void 0 : diagnosticsChannel.tracingChannel) == null ? void 0 : _a24.call(
4409
+ const tracingChannel = (_a25 = diagnosticsChannel == null ? void 0 : diagnosticsChannel.tracingChannel) == null ? void 0 : _a25.call(
4380
4410
  diagnosticsChannel,
4381
4411
  AI_SDK_TELEMETRY_TRACING_CHANNEL
4382
4412
  );
@@ -4434,8 +4464,8 @@ function registerTelemetry(...integrations) {
4434
4464
  globalThis.AI_SDK_TELEMETRY_INTEGRATIONS.push(...integrations);
4435
4465
  }
4436
4466
  function getGlobalTelemetryIntegrations() {
4437
- var _a24;
4438
- return (_a24 = globalThis.AI_SDK_TELEMETRY_INTEGRATIONS) != null ? _a24 : [];
4467
+ var _a25;
4468
+ return (_a25 = globalThis.AI_SDK_TELEMETRY_INTEGRATIONS) != null ? _a25 : [];
4439
4469
  }
4440
4470
 
4441
4471
  // src/telemetry/create-telemetry-dispatcher.ts
@@ -4461,8 +4491,8 @@ function createTelemetryDispatcher({
4461
4491
  };
4462
4492
  const mergeTelemetryCallback = (key) => {
4463
4493
  const integrationCallbacks = integrations.map((integration) => {
4464
- var _a24;
4465
- return (_a24 = integration[key]) == null ? void 0 : _a24.bind(integration);
4494
+ var _a25;
4495
+ return (_a25 = integration[key]) == null ? void 0 : _a25.bind(integration);
4466
4496
  }).filter(Boolean).map(
4467
4497
  (callback) => ((event) => callback(augmentEvent(event, telemetryMetadata)))
4468
4498
  );
@@ -4472,12 +4502,12 @@ function createTelemetryDispatcher({
4472
4502
  };
4473
4503
  };
4474
4504
  const executeLanguageModelCallWrappers = integrations.map((integration) => {
4475
- var _a24;
4476
- return (_a24 = integration.executeLanguageModelCall) == null ? void 0 : _a24.bind(integration);
4505
+ var _a25;
4506
+ return (_a25 = integration.executeLanguageModelCall) == null ? void 0 : _a25.bind(integration);
4477
4507
  }).filter(Boolean);
4478
4508
  const executeToolWrappers = integrations.map((integration) => {
4479
- var _a24;
4480
- return (_a24 = integration.executeTool) == null ? void 0 : _a24.bind(integration);
4509
+ var _a25;
4510
+ return (_a25 = integration.executeTool) == null ? void 0 : _a25.bind(integration);
4481
4511
  }).filter(Boolean);
4482
4512
  return {
4483
4513
  runInTracingChannelSpan: async ({ type, event, execute }) => await runWithTracingChannelSpan(
@@ -4721,8 +4751,8 @@ function createRestrictedTelemetryDispatcher({
4721
4751
  return {
4722
4752
  ...telemetryDispatcher,
4723
4753
  onStart: (event) => {
4724
- var _a24;
4725
- return (_a24 = telemetryDispatcher.onStart) == null ? void 0 : _a24.call(telemetryDispatcher, {
4754
+ var _a25;
4755
+ return (_a25 = telemetryDispatcher.onStart) == null ? void 0 : _a25.call(telemetryDispatcher, {
4726
4756
  ...event,
4727
4757
  runtimeContext: filterIncludedContext({
4728
4758
  context: event.runtimeContext,
@@ -4735,8 +4765,8 @@ function createRestrictedTelemetryDispatcher({
4735
4765
  });
4736
4766
  },
4737
4767
  onStepStart: (event) => {
4738
- var _a24;
4739
- return (_a24 = telemetryDispatcher.onStepStart) == null ? void 0 : _a24.call(telemetryDispatcher, {
4768
+ var _a25;
4769
+ return (_a25 = telemetryDispatcher.onStepStart) == null ? void 0 : _a25.call(telemetryDispatcher, {
4740
4770
  ...event,
4741
4771
  runtimeContext: filterIncludedContext({
4742
4772
  context: event.runtimeContext,
@@ -4756,8 +4786,8 @@ function createRestrictedTelemetryDispatcher({
4756
4786
  });
4757
4787
  },
4758
4788
  onStepEnd: (event) => {
4759
- var _a24;
4760
- return (_a24 = telemetryDispatcher.onStepEnd) == null ? void 0 : _a24.call(
4789
+ var _a25;
4790
+ return (_a25 = telemetryDispatcher.onStepEnd) == null ? void 0 : _a25.call(
4761
4791
  telemetryDispatcher,
4762
4792
  restrictStepResult({
4763
4793
  step: event,
@@ -4767,8 +4797,8 @@ function createRestrictedTelemetryDispatcher({
4767
4797
  );
4768
4798
  },
4769
4799
  onStepFinish: (event) => {
4770
- var _a24;
4771
- return (_a24 = telemetryDispatcher.onStepEnd) == null ? void 0 : _a24.call(
4800
+ var _a25;
4801
+ return (_a25 = telemetryDispatcher.onStepEnd) == null ? void 0 : _a25.call(
4772
4802
  telemetryDispatcher,
4773
4803
  restrictStepResult({
4774
4804
  step: event,
@@ -4778,8 +4808,8 @@ function createRestrictedTelemetryDispatcher({
4778
4808
  );
4779
4809
  },
4780
4810
  onEnd: (event) => {
4781
- var _a24;
4782
- return (_a24 = telemetryDispatcher.onEnd) == null ? void 0 : _a24.call(
4811
+ var _a25;
4812
+ return (_a25 = telemetryDispatcher.onEnd) == null ? void 0 : _a25.call(
4783
4813
  telemetryDispatcher,
4784
4814
  ((restrictedSteps) => {
4785
4815
  return {
@@ -4807,8 +4837,8 @@ function createRestrictedTelemetryDispatcher({
4807
4837
  );
4808
4838
  },
4809
4839
  onAbort: (event) => {
4810
- var _a24;
4811
- return (_a24 = telemetryDispatcher.onAbort) == null ? void 0 : _a24.call(telemetryDispatcher, {
4840
+ var _a25;
4841
+ return (_a25 = telemetryDispatcher.onAbort) == null ? void 0 : _a25.call(telemetryDispatcher, {
4812
4842
  ...event,
4813
4843
  steps: event.steps.map(
4814
4844
  (step) => restrictStepResult({
@@ -4820,8 +4850,8 @@ function createRestrictedTelemetryDispatcher({
4820
4850
  });
4821
4851
  },
4822
4852
  onToolExecutionStart: (event) => {
4823
- var _a24;
4824
- return (_a24 = telemetryDispatcher.onToolExecutionStart) == null ? void 0 : _a24.call(telemetryDispatcher, {
4853
+ var _a25;
4854
+ return (_a25 = telemetryDispatcher.onToolExecutionStart) == null ? void 0 : _a25.call(telemetryDispatcher, {
4825
4855
  ...event,
4826
4856
  toolContext: filterToolContext({
4827
4857
  toolName: event.toolCall.toolName,
@@ -4831,8 +4861,8 @@ function createRestrictedTelemetryDispatcher({
4831
4861
  });
4832
4862
  },
4833
4863
  onToolExecutionEnd: (event) => {
4834
- var _a24;
4835
- return (_a24 = telemetryDispatcher.onToolExecutionEnd) == null ? void 0 : _a24.call(telemetryDispatcher, {
4864
+ var _a25;
4865
+ return (_a25 = telemetryDispatcher.onToolExecutionEnd) == null ? void 0 : _a25.call(telemetryDispatcher, {
4836
4866
  ...event,
4837
4867
  toolContext: filterToolContext({
4838
4868
  toolName: event.toolCall.toolName,
@@ -4853,8 +4883,8 @@ function isLoopFinished() {
4853
4883
  }
4854
4884
  function hasToolCall(...toolName) {
4855
4885
  return ({ steps }) => {
4856
- var _a24, _b24, _c;
4857
- return (_c = (_b24 = (_a24 = steps[steps.length - 1]) == null ? void 0 : _a24.toolCalls) == null ? void 0 : _b24.some(
4886
+ var _a25, _b25, _c;
4887
+ return (_c = (_b25 = (_a25 = steps[steps.length - 1]) == null ? void 0 : _a25.toolCalls) == null ? void 0 : _b25.some(
4858
4888
  (toolCall) => toolName.includes(toolCall.toolName)
4859
4889
  )) != null ? _c : false;
4860
4890
  };
@@ -5119,7 +5149,7 @@ function prepareToolsForToolCallers({
5119
5149
  tools,
5120
5150
  toolCallers
5121
5151
  }) {
5122
- var _a24, _b24;
5152
+ var _a25, _b25;
5123
5153
  if (tools == null || toolCallers == null) {
5124
5154
  return { executionTools: tools, modelTools: tools };
5125
5155
  }
@@ -5152,7 +5182,7 @@ function prepareToolsForToolCallers({
5152
5182
  )
5153
5183
  };
5154
5184
  } else {
5155
- const localTools = (_a24 = localToolsByCaller.get(callerName)) != null ? _a24 : {};
5185
+ const localTools = (_a25 = localToolsByCaller.get(callerName)) != null ? _a25 : {};
5156
5186
  localTools[toolName] = preparedTool;
5157
5187
  localToolsByCaller.set(callerName, localTools);
5158
5188
  }
@@ -5169,7 +5199,7 @@ function prepareToolsForToolCallers({
5169
5199
  if ((caller == null ? void 0 : caller.type) !== "local") {
5170
5200
  continue;
5171
5201
  }
5172
- const boundCaller = caller.bind((_b24 = localToolsByCaller.get(callerName)) != null ? _b24 : {});
5202
+ const boundCaller = caller.bind((_b25 = localToolsByCaller.get(callerName)) != null ? _b25 : {});
5173
5203
  executionTools[callerName] = boundCaller;
5174
5204
  if (Object.prototype.hasOwnProperty.call(modelTools, callerName)) {
5175
5205
  modelTools[callerName] = boundCaller;
@@ -5310,7 +5340,7 @@ async function validateApprovedToolApprovals({
5310
5340
  runtimeContext,
5311
5341
  toolApprovalSecret
5312
5342
  }) {
5313
- var _a24;
5343
+ var _a25;
5314
5344
  const approved = [];
5315
5345
  const denied = [];
5316
5346
  const invalid = [];
@@ -5372,7 +5402,7 @@ async function validateApprovedToolApprovals({
5372
5402
  approvalResponse: {
5373
5403
  ...approval.approvalResponse,
5374
5404
  approved: false,
5375
- reason: (_a24 = approvalStatus.reason) != null ? _a24 : approval.approvalResponse.reason
5405
+ reason: (_a25 = approvalStatus.reason) != null ? _a25 : approval.approvalResponse.reason
5376
5406
  }
5377
5407
  });
5378
5408
  } else {
@@ -5451,10 +5481,10 @@ async function generateText({
5451
5481
  onEnd = onFinish,
5452
5482
  ...settings
5453
5483
  }) {
5454
- var _a24, _b24, _c, _d;
5484
+ var _a25, _b25, _c, _d;
5455
5485
  include = {
5456
- requestBody: (_a24 = include == null ? void 0 : include.requestBody) != null ? _a24 : false,
5457
- requestMessages: (_b24 = include == null ? void 0 : include.requestMessages) != null ? _b24 : false,
5486
+ requestBody: (_a25 = include == null ? void 0 : include.requestBody) != null ? _a25 : false,
5487
+ requestMessages: (_b25 = include == null ? void 0 : include.requestMessages) != null ? _b25 : false,
5458
5488
  responseBody: (_c = include == null ? void 0 : include.responseBody) != null ? _c : false
5459
5489
  };
5460
5490
  const model = resolveLanguageModel(modelArg);
@@ -5552,7 +5582,7 @@ async function generateText({
5552
5582
  toolsContext
5553
5583
  };
5554
5584
  const executeGenerateText = async () => {
5555
- var _a25;
5585
+ var _a26;
5556
5586
  await notify({
5557
5587
  event: generateTextStartEvent,
5558
5588
  callbacks: [resolvedOnStart, telemetryDispatcher.onStart]
@@ -5698,7 +5728,7 @@ async function generateText({
5698
5728
  type: "step",
5699
5729
  event: { callId, stepNumber },
5700
5730
  execute: async () => {
5701
- var _a26, _b25, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
5731
+ var _a27, _b26, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
5702
5732
  const accumulatedResponseMessages = [
5703
5733
  ...initialResponseMessages,
5704
5734
  ...steps.flatMap((step) => step.response.messages)
@@ -5717,9 +5747,9 @@ async function generateText({
5717
5747
  toolsContext,
5718
5748
  experimental_sandbox: sandbox
5719
5749
  }));
5720
- const stepSandbox = (_a26 = prepareStepResult == null ? void 0 : prepareStepResult.experimental_sandbox) != null ? _a26 : sandbox;
5750
+ const stepSandbox = (_a27 = prepareStepResult == null ? void 0 : prepareStepResult.experimental_sandbox) != null ? _a27 : sandbox;
5721
5751
  const stepModel = resolveLanguageModel(
5722
- (_b25 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _b25 : model
5752
+ (_b26 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _b26 : model
5723
5753
  );
5724
5754
  const stepInstructions = (_d2 = (_c2 = prepareStepResult == null ? void 0 : prepareStepResult.instructions) != null ? _c2 : prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _d2 : instructionsForNextStep;
5725
5755
  const promptMessages = await convertToLanguageModelPrompt({
@@ -5812,7 +5842,7 @@ async function generateText({
5812
5842
  });
5813
5843
  const executeLanguageModelCallInTelemetryContext = (_n = telemetryDispatcher.executeLanguageModelCall) != null ? _n : (async ({ execute }) => await execute());
5814
5844
  currentModelResponse = await retry(async () => {
5815
- var _a27, _b26, _c3, _d3, _e2, _f2, _g2, _h2;
5845
+ var _a28, _b27, _c3, _d3, _e2, _f2, _g2, _h2;
5816
5846
  const result = await executeLanguageModelCallInTelemetryContext(
5817
5847
  {
5818
5848
  ...languageModelCallStartEvent,
@@ -5829,7 +5859,7 @@ async function generateText({
5829
5859
  }
5830
5860
  );
5831
5861
  const responseData = {
5832
- id: (_b26 = (_a27 = result.response) == null ? void 0 : _a27.id) != null ? _b26 : generateId4(),
5862
+ id: (_b27 = (_a28 = result.response) == null ? void 0 : _a28.id) != null ? _b27 : generateId4(),
5833
5863
  timestamp: (_d3 = (_c3 = result.response) == null ? void 0 : _c3.timestamp) != null ? _d3 : /* @__PURE__ */ new Date(),
5834
5864
  modelId: (_f2 = (_e2 = result.response) == null ? void 0 : _e2.modelId) != null ? _f2 : stepModel.modelId,
5835
5865
  headers: (_g2 = result.response) == null ? void 0 : _g2.headers,
@@ -5901,6 +5931,18 @@ async function generateText({
5901
5931
  telemetryDispatcher.onLanguageModelCallEnd
5902
5932
  ]
5903
5933
  });
5934
+ const enforcedToolChoice = stepToolChoice.type === "required" || stepToolChoice.type === "tool" ? stepToolChoice : void 0;
5935
+ if (enforcedToolChoice != null && !stepToolCalls.some(
5936
+ (toolCall) => enforcedToolChoice.type === "required" || toolCall.toolName === enforcedToolChoice.toolName
5937
+ )) {
5938
+ throw new ToolChoiceViolationError({
5939
+ toolChoice: enforcedToolChoice,
5940
+ finishReason: currentModelResponse.finishReason.unified,
5941
+ provider: stepModel.provider,
5942
+ modelId: stepModel.modelId,
5943
+ content: currentModelResponse.content
5944
+ });
5945
+ }
5904
5946
  for (const toolCall of stepToolCalls) {
5905
5947
  if (toolCall.invalid) {
5906
5948
  continue;
@@ -6189,8 +6231,8 @@ async function generateText({
6189
6231
  const staticToolResults = steps.flatMap((step) => step.staticToolResults);
6190
6232
  const dynamicToolResults = steps.flatMap((step) => step.dynamicToolResults);
6191
6233
  const warnings = steps.flatMap((step) => {
6192
- var _a26;
6193
- return (_a26 = step.warnings) != null ? _a26 : [];
6234
+ var _a27;
6235
+ return (_a27 = step.warnings) != null ? _a27 : [];
6194
6236
  });
6195
6237
  const onEndEvent = {
6196
6238
  callId,
@@ -6248,7 +6290,7 @@ async function generateText({
6248
6290
  output: resolvedOutput
6249
6291
  });
6250
6292
  } catch (error) {
6251
- await ((_a25 = telemetryDispatcher.onError) == null ? void 0 : _a25.call(telemetryDispatcher, { callId, error }));
6293
+ await ((_a26 = telemetryDispatcher.onError) == null ? void 0 : _a26.call(telemetryDispatcher, { callId, error }));
6252
6294
  throw wrapGatewayError(error);
6253
6295
  }
6254
6296
  };
@@ -6348,8 +6390,8 @@ var DefaultGenerateTextResult = class {
6348
6390
  }
6349
6391
  get warnings() {
6350
6392
  return this.steps.flatMap((step) => {
6351
- var _a24;
6352
- return (_a24 = step.warnings) != null ? _a24 : [];
6393
+ var _a25;
6394
+ return (_a25 = step.warnings) != null ? _a25 : [];
6353
6395
  });
6354
6396
  }
6355
6397
  get providerMetadata() {
@@ -6653,6 +6695,7 @@ var uiMessageChunkSchema = lazySchema(
6653
6695
  type: z.literal("tool-approval-request"),
6654
6696
  approvalId: z.string(),
6655
6697
  toolCallId: z.string(),
6698
+ approvalDescriptor: z.unknown().optional(),
6656
6699
  reason: z.string().optional(),
6657
6700
  isAutomatic: z.boolean().optional(),
6658
6701
  signature: z.string().optional()
@@ -6857,7 +6900,7 @@ function processUIMessageStream({
6857
6900
  new TransformStream({
6858
6901
  async transform(chunk, controller) {
6859
6902
  await runUpdateMessageJob(async ({ state, write }) => {
6860
- var _a24, _b24, _c, _d;
6903
+ var _a25, _b25, _c, _d;
6861
6904
  function getCurrentStepParts() {
6862
6905
  const parts = state.message.parts;
6863
6906
  let currentStepStartIndex = parts.length - 1;
@@ -6897,8 +6940,8 @@ function processUIMessageStream({
6897
6940
  const toolInvocations = state.message.parts.filter(isToolUIPart);
6898
6941
  const toolInvocation = toolInvocations.find(
6899
6942
  (invocation) => {
6900
- var _a25;
6901
- return ((_a25 = invocation.approval) == null ? void 0 : _a25.id) === approvalId;
6943
+ var _a26;
6944
+ return ((_a26 = invocation.approval) == null ? void 0 : _a26.id) === approvalId;
6902
6945
  }
6903
6946
  );
6904
6947
  if (toolInvocation == null) {
@@ -6911,7 +6954,7 @@ function processUIMessageStream({
6911
6954
  return toolInvocation;
6912
6955
  }
6913
6956
  function updateToolPart(options, existingPart) {
6914
- var _a25;
6957
+ var _a26;
6915
6958
  const part = existingPart != null ? existingPart : getCurrentStepParts().find(
6916
6959
  (part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId
6917
6960
  );
@@ -6930,7 +6973,7 @@ function processUIMessageStream({
6930
6973
  if (options.toolMetadata !== void 0) {
6931
6974
  anyPart.toolMetadata = options.toolMetadata;
6932
6975
  }
6933
- anyPart.providerExecuted = (_a25 = anyOptions.providerExecuted) != null ? _a25 : part.providerExecuted;
6976
+ anyPart.providerExecuted = (_a26 = anyOptions.providerExecuted) != null ? _a26 : part.providerExecuted;
6934
6977
  const providerMetadata = anyOptions.providerMetadata;
6935
6978
  if (providerMetadata != null) {
6936
6979
  if (options.state === "output-available" || options.state === "output-error") {
@@ -6959,7 +7002,7 @@ function processUIMessageStream({
6959
7002
  }
6960
7003
  }
6961
7004
  function updateDynamicToolPart(options, existingPart) {
6962
- var _a25, _b25;
7005
+ var _a26, _b26;
6963
7006
  const part = existingPart != null ? existingPart : getCurrentStepParts().find(
6964
7007
  (part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId
6965
7008
  );
@@ -6971,7 +7014,7 @@ function processUIMessageStream({
6971
7014
  anyPart.input = anyOptions.input;
6972
7015
  anyPart.output = anyOptions.output;
6973
7016
  anyPart.errorText = anyOptions.errorText;
6974
- anyPart.rawInput = (_a25 = anyOptions.rawInput) != null ? _a25 : anyPart.rawInput;
7017
+ anyPart.rawInput = (_a26 = anyOptions.rawInput) != null ? _a26 : anyPart.rawInput;
6975
7018
  anyPart.preliminary = anyOptions.preliminary;
6976
7019
  if (options.title !== void 0) {
6977
7020
  anyPart.title = options.title;
@@ -6979,7 +7022,7 @@ function processUIMessageStream({
6979
7022
  if (options.toolMetadata !== void 0) {
6980
7023
  anyPart.toolMetadata = options.toolMetadata;
6981
7024
  }
6982
- anyPart.providerExecuted = (_b25 = anyOptions.providerExecuted) != null ? _b25 : part.providerExecuted;
7025
+ anyPart.providerExecuted = (_b26 = anyOptions.providerExecuted) != null ? _b26 : part.providerExecuted;
6983
7026
  const providerMetadata = anyOptions.providerMetadata;
6984
7027
  if (providerMetadata != null) {
6985
7028
  if (options.state === "output-available" || options.state === "output-error") {
@@ -7046,7 +7089,7 @@ function processUIMessageStream({
7046
7089
  });
7047
7090
  }
7048
7091
  textPart.text += chunk.delta;
7049
- textPart.providerMetadata = (_a24 = chunk.providerMetadata) != null ? _a24 : textPart.providerMetadata;
7092
+ textPart.providerMetadata = (_a25 = chunk.providerMetadata) != null ? _a25 : textPart.providerMetadata;
7050
7093
  write();
7051
7094
  break;
7052
7095
  }
@@ -7060,7 +7103,7 @@ function processUIMessageStream({
7060
7103
  });
7061
7104
  }
7062
7105
  textPart.state = "done";
7063
- textPart.providerMetadata = (_b24 = chunk.providerMetadata) != null ? _b24 : textPart.providerMetadata;
7106
+ textPart.providerMetadata = (_b25 = chunk.providerMetadata) != null ? _b25 : textPart.providerMetadata;
7064
7107
  delete state.activeTextParts[chunk.id];
7065
7108
  write();
7066
7109
  break;
@@ -7289,6 +7332,7 @@ function processUIMessageStream({
7289
7332
  toolInvocation.state = "approval-requested";
7290
7333
  toolInvocation.approval = {
7291
7334
  id: chunk.approvalId,
7335
+ ...chunk.approvalDescriptor != null ? { descriptor: chunk.approvalDescriptor } : {},
7292
7336
  ...chunk.reason != null ? { requestReason: chunk.reason } : {},
7293
7337
  ...chunk.isAutomatic === true ? { isAutomatic: true } : {},
7294
7338
  ...chunk.signature != null ? { signature: chunk.signature } : {}
@@ -7303,12 +7347,10 @@ function processUIMessageStream({
7303
7347
  const approval = toolInvocation.approval == null ? { id: chunk.approvalId } : toolInvocation.approval;
7304
7348
  toolInvocation.state = "approval-responded";
7305
7349
  toolInvocation.approval = {
7350
+ ...approval,
7306
7351
  id: chunk.approvalId,
7307
7352
  approved: chunk.approved,
7308
- ...approval.requestReason != null ? { requestReason: approval.requestReason } : {},
7309
- ...chunk.reason != null ? { reason: chunk.reason } : {},
7310
- ...approval.isAutomatic === true ? { isAutomatic: true } : {},
7311
- ...approval.signature != null ? { signature: approval.signature } : {}
7353
+ ...chunk.reason != null ? { reason: chunk.reason } : {}
7312
7354
  };
7313
7355
  if (chunk.providerExecuted != null) {
7314
7356
  toolInvocation.providerExecuted = chunk.providerExecuted;
@@ -7565,13 +7607,13 @@ function handleUIMessageStreamFinish({
7565
7607
  };
7566
7608
  let finishCalled = false;
7567
7609
  const callOnEnd = async () => {
7568
- var _a24;
7610
+ var _a25;
7569
7611
  if (finishCalled || !resolvedOnEnd) {
7570
7612
  return;
7571
7613
  }
7572
7614
  finishCalled = true;
7573
7615
  const isContinuation = state.message.id === (lastMessage == null ? void 0 : lastMessage.id);
7574
- const declaredOutcome = (_a24 = getOutcome == null ? void 0 : getOutcome()) != null ? _a24 : { status: "unknown" };
7616
+ const declaredOutcome = (_a25 = getOutcome == null ? void 0 : getOutcome()) != null ? _a25 : { status: "unknown" };
7575
7617
  const outcome = hasProcessingFailure ? { status: "failed", error: processingError } : declaredOutcome.status === "unknown" && isAborted ? { status: "aborted" } : declaredOutcome;
7576
7618
  await resolvedOnEnd({
7577
7619
  isAborted: isAborted || outcome.status === "aborted",
@@ -8010,12 +8052,12 @@ function asAsyncIterableStream(stream) {
8010
8052
  const reader = this.getReader();
8011
8053
  let finished = false;
8012
8054
  async function cleanup(cancelStream) {
8013
- var _a24;
8055
+ var _a25;
8014
8056
  if (finished) return;
8015
8057
  finished = true;
8016
8058
  try {
8017
8059
  if (cancelStream) {
8018
- await ((_a24 = reader.cancel) == null ? void 0 : _a24.call(reader));
8060
+ await ((_a25 = reader.cancel) == null ? void 0 : _a25.call(reader));
8019
8061
  }
8020
8062
  } finally {
8021
8063
  try {
@@ -8136,7 +8178,7 @@ function createStitchableStream() {
8136
8178
  controller == null ? void 0 : controller.close();
8137
8179
  };
8138
8180
  const processPull = async () => {
8139
- var _a24;
8181
+ var _a25;
8140
8182
  if (isCancelled) {
8141
8183
  return;
8142
8184
  }
@@ -8169,7 +8211,7 @@ function createStitchableStream() {
8169
8211
  if (isCancelled) {
8170
8212
  return;
8171
8213
  }
8172
- (_a24 = currentStream.onError) == null ? void 0 : _a24.call(currentStream, error);
8214
+ (_a25 = currentStream.onError) == null ? void 0 : _a25.call(currentStream, error);
8173
8215
  controller == null ? void 0 : controller.error(error);
8174
8216
  innerStreams.shift();
8175
8217
  terminate();
@@ -8193,9 +8235,9 @@ function createStitchableStream() {
8193
8235
  }
8194
8236
  }),
8195
8237
  addStream: (innerStream, callbacks) => {
8196
- var _a24;
8238
+ var _a25;
8197
8239
  if (isCancelled) {
8198
- (_a24 = callbacks == null ? void 0 : callbacks.onCancel) == null ? void 0 : _a24.call(callbacks);
8240
+ (_a25 = callbacks == null ? void 0 : callbacks.onCancel) == null ? void 0 : _a25.call(callbacks);
8199
8241
  void innerStream.cancel().catch(() => {
8200
8242
  });
8201
8243
  return;
@@ -8459,11 +8501,11 @@ import {
8459
8501
  } from "@ai-sdk/provider-utils";
8460
8502
 
8461
8503
  // src/prompt/normalize-stream-provider-error.ts
8462
- import { AISDKError as AISDKError26 } from "@ai-sdk/provider";
8504
+ import { AISDKError as AISDKError27 } from "@ai-sdk/provider";
8463
8505
  import { isProviderStreamError } from "@ai-sdk/provider-utils";
8464
8506
  function normalizeStreamProviderError(error) {
8465
- var _a24, _b24, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
8466
- if (isError(error) || AISDKError26.isInstance(error) || StreamProviderError.isInstance(error)) {
8507
+ var _a25, _b25, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
8508
+ if (isError(error) || AISDKError27.isInstance(error) || StreamProviderError.isInstance(error)) {
8467
8509
  return error;
8468
8510
  }
8469
8511
  const outer = asRecord(error);
@@ -8471,7 +8513,7 @@ function normalizeStreamProviderError(error) {
8471
8513
  return error;
8472
8514
  }
8473
8515
  const providerStreamError = isProviderStreamError(error);
8474
- const details = providerStreamError ? outer : (_c = (_b24 = asRecord((_a24 = asRecord(outer.response)) == null ? void 0 : _a24.error)) != null ? _b24 : asRecord(outer.error)) != null ? _c : outer;
8516
+ const details = providerStreamError ? outer : (_c = (_b25 = asRecord((_a25 = asRecord(outer.response)) == null ? void 0 : _a25.error)) != null ? _b25 : asRecord(outer.error)) != null ? _c : outer;
8475
8517
  if (typeof details.message !== "string") {
8476
8518
  return error;
8477
8519
  }
@@ -8681,7 +8723,7 @@ function createLanguageModelV4StreamPartToLanguageModelStreamPartTransform({
8681
8723
  const timeBetweenOutputChunksMs = [];
8682
8724
  return new TransformStream({
8683
8725
  async transform(chunk, controller) {
8684
- var _a24, _b24, _c;
8726
+ var _a25, _b25, _c;
8685
8727
  if (isOutputChunk(chunk)) {
8686
8728
  const outputChunkTimestampMs = now2();
8687
8729
  if (timeToFirstOutputMs == null) {
@@ -8926,7 +8968,7 @@ function createLanguageModelV4StreamPartToLanguageModelStreamPartTransform({
8926
8968
  const tool2 = getOwn(tools, chunk.toolName);
8927
8969
  controller.enqueue({
8928
8970
  ...chunk,
8929
- dynamic: (_a24 = chunk.dynamic) != null ? _a24 : (tool2 == null ? void 0 : tool2.type) === "dynamic",
8971
+ dynamic: (_a25 = chunk.dynamic) != null ? _a25 : (tool2 == null ? void 0 : tool2.type) === "dynamic",
8930
8972
  title: tool2 == null ? void 0 : tool2.title,
8931
8973
  ...(tool2 == null ? void 0 : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}
8932
8974
  });
@@ -8940,7 +8982,7 @@ function createLanguageModelV4StreamPartToLanguageModelStreamPartTransform({
8940
8982
  break;
8941
8983
  }
8942
8984
  case "response-metadata": {
8943
- responseId = (_b24 = chunk.id) != null ? _b24 : responseId;
8985
+ responseId = (_b25 = chunk.id) != null ? _b25 : responseId;
8944
8986
  responseModelId = (_c = chunk.modelId) != null ? _c : responseModelId;
8945
8987
  controller.enqueue({
8946
8988
  type: "model-call-response-metadata",
@@ -9120,7 +9162,7 @@ function streamText({
9120
9162
  } = {},
9121
9163
  ...settings
9122
9164
  }) {
9123
- var _a24, _b24, _c, _d;
9165
+ var _a25, _b25, _c, _d;
9124
9166
  const totalTimeoutMs = getTotalTimeoutMs(timeout);
9125
9167
  const stepTimeoutMs = getStepTimeoutMs(timeout);
9126
9168
  const firstChunkTimeoutMs = getFirstChunkTimeoutMs(timeout);
@@ -9194,8 +9236,8 @@ function streamText({
9194
9236
  download: download2,
9195
9237
  // assign default values to include:
9196
9238
  include: {
9197
- requestBody: (_a24 = include == null ? void 0 : include.requestBody) != null ? _a24 : false,
9198
- requestMessages: (_b24 = include == null ? void 0 : include.requestMessages) != null ? _b24 : false,
9239
+ requestBody: (_a25 = include == null ? void 0 : include.requestBody) != null ? _a25 : false,
9240
+ requestMessages: (_b25 = include == null ? void 0 : include.requestMessages) != null ? _b25 : false,
9199
9241
  rawChunks: (_d = (_c = include == null ? void 0 : include.rawChunks) != null ? _c : includeRawChunks) != null ? _d : false
9200
9242
  }
9201
9243
  });
@@ -9229,7 +9271,7 @@ function createOutputTransformStream(output) {
9229
9271
  }
9230
9272
  return new TransformStream({
9231
9273
  async transform(chunk, controller) {
9232
- var _a24;
9274
+ var _a25;
9233
9275
  if (chunk.type === "finish-step" && textChunk.length > 0) {
9234
9276
  publishTextChunk({ controller });
9235
9277
  }
@@ -9256,7 +9298,7 @@ function createOutputTransformStream(output) {
9256
9298
  }
9257
9299
  text2 += chunk.text;
9258
9300
  textChunk += chunk.text;
9259
- textProviderMetadata = (_a24 = chunk.providerMetadata) != null ? _a24 : textProviderMetadata;
9301
+ textProviderMetadata = (_a25 = chunk.providerMetadata) != null ? _a25 : textProviderMetadata;
9260
9302
  if (chunk.text.length === 0 && chunk.providerMetadata != null) {
9261
9303
  controller.enqueue({ part: chunk, partialOutput: void 0 });
9262
9304
  return;
@@ -9379,7 +9421,7 @@ var DefaultStreamTextResult = class {
9379
9421
  let recordedNoOutputError;
9380
9422
  const eventProcessor = new TransformStream({
9381
9423
  async transform(chunk, controller) {
9382
- var _a24, _b24, _c, _d;
9424
+ var _a25, _b25, _c, _d;
9383
9425
  controller.enqueue(chunk);
9384
9426
  const { part } = chunk;
9385
9427
  await notify({
@@ -9420,7 +9462,7 @@ var DefaultStreamTextResult = class {
9420
9462
  return;
9421
9463
  }
9422
9464
  activeText.text += part.text;
9423
- activeText.providerMetadata = (_a24 = part.providerMetadata) != null ? _a24 : activeText.providerMetadata;
9465
+ activeText.providerMetadata = (_a25 = part.providerMetadata) != null ? _a25 : activeText.providerMetadata;
9424
9466
  }
9425
9467
  if (part.type === "text-end") {
9426
9468
  const activeText = activeTextContent[part.id];
@@ -9434,7 +9476,7 @@ var DefaultStreamTextResult = class {
9434
9476
  });
9435
9477
  return;
9436
9478
  }
9437
- activeText.providerMetadata = (_b24 = part.providerMetadata) != null ? _b24 : activeText.providerMetadata;
9479
+ activeText.providerMetadata = (_b25 = part.providerMetadata) != null ? _b25 : activeText.providerMetadata;
9438
9480
  delete activeTextContent[part.id];
9439
9481
  }
9440
9482
  if (part.type === "reasoning-start") {
@@ -9576,8 +9618,8 @@ var DefaultStreamTextResult = class {
9576
9618
  (step) => step.dynamicToolResults
9577
9619
  );
9578
9620
  const warnings = recordedSteps.flatMap((step) => {
9579
- var _a24;
9580
- return (_a24 = step.warnings) != null ? _a24 : [];
9621
+ var _a25;
9622
+ return (_a25 = step.warnings) != null ? _a25 : [];
9581
9623
  });
9582
9624
  const onEndWithOutput = onEnd == null ? void 0 : async (event) => {
9583
9625
  const parsedOutput = output == null ? void 0 : await self.getOutputPromise().catch(() => void 0);
@@ -9714,7 +9756,7 @@ var DefaultStreamTextResult = class {
9714
9756
  const self = this;
9715
9757
  const callId = generateCallId();
9716
9758
  (async () => {
9717
- var _a24;
9759
+ var _a25;
9718
9760
  const initialPrompt = await standardizePrompt({
9719
9761
  instructions,
9720
9762
  system,
@@ -9750,14 +9792,14 @@ var DefaultStreamTextResult = class {
9750
9792
  runtimeContext,
9751
9793
  toolsContext
9752
9794
  };
9753
- const streamTextTracingChannelContext = (_a24 = telemetryDispatcher.startTracingChannelContext) == null ? void 0 : _a24.call(telemetryDispatcher, {
9795
+ const streamTextTracingChannelContext = (_a25 = telemetryDispatcher.startTracingChannelContext) == null ? void 0 : _a25.call(telemetryDispatcher, {
9754
9796
  type: "streamText",
9755
9797
  event: startEvent,
9756
9798
  completion: self._totalUsage.promise.then(() => void 0)
9757
9799
  });
9758
9800
  const runInStreamTextTracingChannelContext = (execute) => {
9759
- var _a25;
9760
- return (_a25 = streamTextTracingChannelContext == null ? void 0 : streamTextTracingChannelContext.run(execute)) != null ? _a25 : execute();
9801
+ var _a26;
9802
+ return (_a26 = streamTextTracingChannelContext == null ? void 0 : streamTextTracingChannelContext.run(execute)) != null ? _a26 : execute();
9761
9803
  };
9762
9804
  const runInTracingChannelSpanInStreamText = telemetryDispatcher.runInTracingChannelSpan == null ? void 0 : (options) => runInStreamTextTracingChannelContext(
9763
9805
  () => telemetryDispatcher.runInTracingChannelSpan(options)
@@ -9914,7 +9956,7 @@ var DefaultStreamTextResult = class {
9914
9956
  currentStep,
9915
9957
  usage
9916
9958
  }) {
9917
- var _a25, _b24, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
9959
+ var _a26, _b25, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
9918
9960
  const stepTimeoutId = setAbortTimeout({
9919
9961
  abortController: stepAbortController,
9920
9962
  label: "Step",
@@ -9973,14 +10015,14 @@ var DefaultStreamTextResult = class {
9973
10015
  });
9974
10016
  try {
9975
10017
  stepFinish = new DelayedPromise();
9976
- const stepTracingChannelContext = (_a25 = telemetryDispatcher.startTracingChannelContext) == null ? void 0 : _a25.call(telemetryDispatcher, {
10018
+ const stepTracingChannelContext = (_a26 = telemetryDispatcher.startTracingChannelContext) == null ? void 0 : _a26.call(telemetryDispatcher, {
9977
10019
  type: "step",
9978
10020
  event: { callId, stepNumber: currentStep },
9979
10021
  completion: stepFinish.promise
9980
10022
  });
9981
10023
  const runInStepTracingChannelContext = (execute) => {
9982
- var _a26;
9983
- return (_a26 = stepTracingChannelContext == null ? void 0 : stepTracingChannelContext.run(execute)) != null ? _a26 : execute();
10024
+ var _a27;
10025
+ return (_a27 = stepTracingChannelContext == null ? void 0 : stepTracingChannelContext.run(execute)) != null ? _a27 : execute();
9984
10026
  };
9985
10027
  const responseMessagesFromPreviousSteps = recordedSteps.flatMap(
9986
10028
  (step) => step.response.messages
@@ -10006,7 +10048,7 @@ var DefaultStreamTextResult = class {
10006
10048
  runtimeContext,
10007
10049
  experimental_sandbox: sandbox
10008
10050
  }));
10009
- const stepSandbox = (_b24 = prepareStepResult == null ? void 0 : prepareStepResult.experimental_sandbox) != null ? _b24 : sandbox;
10051
+ const stepSandbox = (_b25 = prepareStepResult == null ? void 0 : prepareStepResult.experimental_sandbox) != null ? _b25 : sandbox;
10010
10052
  runtimeContext = (_c = prepareStepResult == null ? void 0 : prepareStepResult.runtimeContext) != null ? _c : runtimeContext;
10011
10053
  toolsContext = (_d = prepareStepResult == null ? void 0 : prepareStepResult.toolsContext) != null ? _d : toolsContext;
10012
10054
  const stepModel = resolveLanguageModel(
@@ -10055,12 +10097,12 @@ var DefaultStreamTextResult = class {
10055
10097
  } = await runInStepTracingChannelContext(
10056
10098
  () => retry(
10057
10099
  async () => {
10058
- var _a26, _b25;
10100
+ var _a27, _b26;
10059
10101
  return streamLanguageModelCall({
10060
- model: (_a26 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a26 : model,
10102
+ model: (_a27 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a27 : model,
10061
10103
  tools: stepModelTools,
10062
10104
  toolOrder: stepToolOrder,
10063
- toolChoice: (_b25 = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _b25 : toolChoice,
10105
+ toolChoice: (_b26 = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _b26 : toolChoice,
10064
10106
  instructions: stepInstructions,
10065
10107
  messages: stepMessages,
10066
10108
  allowSystemInMessages,
@@ -10085,7 +10127,7 @@ var DefaultStreamTextResult = class {
10085
10127
  telemetryDispatcher.onLanguageModelCallEnd
10086
10128
  ),
10087
10129
  onStart: async ({ promptMessages }) => {
10088
- var _a27, _b26;
10130
+ var _a28, _b27;
10089
10131
  await notify({
10090
10132
  event: {
10091
10133
  callId,
@@ -10095,8 +10137,8 @@ var DefaultStreamTextResult = class {
10095
10137
  instructions: stepInstructions,
10096
10138
  messages: stepMessages,
10097
10139
  tools,
10098
- toolChoice: (_a27 = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _a27 : toolChoice,
10099
- activeTools: (_b26 = prepareStepResult == null ? void 0 : prepareStepResult.activeTools) != null ? _b26 : activeTools,
10140
+ toolChoice: (_a28 = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _a28 : toolChoice,
10141
+ activeTools: (_b27 = prepareStepResult == null ? void 0 : prepareStepResult.activeTools) != null ? _b27 : activeTools,
10100
10142
  toolOrder: stepToolOrder,
10101
10143
  steps: [...recordedSteps],
10102
10144
  providerOptions: stepProviderOptions,
@@ -10193,7 +10235,7 @@ var DefaultStreamTextResult = class {
10193
10235
  streamWithToolResults.pipeThrough(
10194
10236
  new TransformStream({
10195
10237
  async transform(chunk, controller) {
10196
- var _a26, _b25, _c2, _d2, _e2, _f2, _g2;
10238
+ var _a27, _b26, _c2, _d2, _e2, _f2, _g2;
10197
10239
  if (chunk.type === "model-call-start") {
10198
10240
  warnings = chunk.warnings;
10199
10241
  return;
@@ -10236,7 +10278,7 @@ var DefaultStreamTextResult = class {
10236
10278
  if (chunk.text.length > 0 || chunk.providerMetadata != null) {
10237
10279
  controller.enqueue({
10238
10280
  ...chunk,
10239
- id: (_a26 = textPartIds.get(chunk.id)) != null ? _a26 : chunk.id
10281
+ id: (_a27 = textPartIds.get(chunk.id)) != null ? _a27 : chunk.id
10240
10282
  });
10241
10283
  }
10242
10284
  break;
@@ -10244,7 +10286,7 @@ var DefaultStreamTextResult = class {
10244
10286
  case "text-end": {
10245
10287
  controller.enqueue({
10246
10288
  ...chunk,
10247
- id: (_b25 = textPartIds.get(chunk.id)) != null ? _b25 : chunk.id
10289
+ id: (_b26 = textPartIds.get(chunk.id)) != null ? _b26 : chunk.id
10248
10290
  });
10249
10291
  textPartIds.delete(chunk.id);
10250
10292
  break;
@@ -10448,8 +10490,8 @@ var DefaultStreamTextResult = class {
10448
10490
  )
10449
10491
  );
10450
10492
  })().catch(async (error) => {
10451
- var _a24;
10452
- await ((_a24 = telemetryDispatcher.onError) == null ? void 0 : _a24.call(telemetryDispatcher, { callId, error }));
10493
+ var _a25;
10494
+ await ((_a25 = telemetryDispatcher.onError) == null ? void 0 : _a25.call(telemetryDispatcher, { callId, error }));
10453
10495
  self._initialResponseMessages.reject(error);
10454
10496
  markPromiseAsHandled(self._initialResponseMessages.promise);
10455
10497
  self.addStream(
@@ -10475,8 +10517,8 @@ var DefaultStreamTextResult = class {
10475
10517
  }
10476
10518
  get warnings() {
10477
10519
  return this.steps.then((steps) => steps.flatMap((step) => {
10478
- var _a24;
10479
- return (_a24 = step.warnings) != null ? _a24 : [];
10520
+ var _a25;
10521
+ return (_a25 = step.warnings) != null ? _a25 : [];
10480
10522
  }));
10481
10523
  }
10482
10524
  get providerMetadata() {
@@ -10605,19 +10647,19 @@ var DefaultStreamTextResult = class {
10605
10647
  }
10606
10648
  }
10607
10649
  async consumeStream(options) {
10608
- var _a24;
10650
+ var _a25;
10609
10651
  try {
10610
10652
  await consumeStream({
10611
10653
  stream: this.stream,
10612
10654
  onError: (error) => {
10613
- var _a25;
10655
+ var _a26;
10614
10656
  this.rejectResultPromises(error);
10615
- (_a25 = options == null ? void 0 : options.onError) == null ? void 0 : _a25.call(options, error);
10657
+ (_a26 = options == null ? void 0 : options.onError) == null ? void 0 : _a26.call(options, error);
10616
10658
  }
10617
10659
  });
10618
10660
  } catch (error) {
10619
10661
  this.rejectResultPromises(error);
10620
- (_a24 = options == null ? void 0 : options.onError) == null ? void 0 : _a24.call(options, error);
10662
+ (_a25 = options == null ? void 0 : options.onError) == null ? void 0 : _a25.call(options, error);
10621
10663
  }
10622
10664
  }
10623
10665
  get experimental_partialOutputStream() {
@@ -10637,11 +10679,11 @@ var DefaultStreamTextResult = class {
10637
10679
  );
10638
10680
  }
10639
10681
  get elementStream() {
10640
- var _a24, _b24, _c;
10641
- const transform = (_a24 = this.outputSpecification) == null ? void 0 : _a24.createElementStreamTransform();
10682
+ var _a25, _b25, _c;
10683
+ const transform = (_a25 = this.outputSpecification) == null ? void 0 : _a25.createElementStreamTransform();
10642
10684
  if (transform == null) {
10643
10685
  throw new UnsupportedFunctionalityError2({
10644
- functionality: `element streams in ${(_c = (_b24 = this.outputSpecification) == null ? void 0 : _b24.name) != null ? _c : "text"} mode`
10686
+ functionality: `element streams in ${(_c = (_b25 = this.outputSpecification) == null ? void 0 : _b25.name) != null ? _c : "text"} mode`
10645
10687
  });
10646
10688
  }
10647
10689
  return createAsyncIterableStream(this.teeStream().pipeThrough(transform));
@@ -10649,8 +10691,8 @@ var DefaultStreamTextResult = class {
10649
10691
  getOutputPromise() {
10650
10692
  if (this.outputPromise == null) {
10651
10693
  this.outputPromise = this.finalStep.then((step) => {
10652
- var _a24;
10653
- const output = (_a24 = this.outputSpecification) != null ? _a24 : text();
10694
+ var _a25;
10695
+ const output = (_a25 = this.outputSpecification) != null ? _a25 : text();
10654
10696
  return output.parseCompleteOutput(
10655
10697
  { text: step.text },
10656
10698
  {
@@ -10786,7 +10828,7 @@ var ToolLoopAgent = class {
10786
10828
  return this.settings.tools;
10787
10829
  }
10788
10830
  async prepareCall(options) {
10789
- var _a24, _b24, _c, _d;
10831
+ var _a25, _b25, _c, _d;
10790
10832
  if (this.settings.callOptionsSchema != null && options.options !== void 0) {
10791
10833
  const validatedOptions = await validateTypes3({
10792
10834
  value: options.options,
@@ -10810,11 +10852,11 @@ var ToolLoopAgent = class {
10810
10852
  } = this.settings;
10811
10853
  const baseCallArgs = {
10812
10854
  ...settingsWithoutCallbacks,
10813
- stopWhen: (_a24 = this.settings.stopWhen) != null ? _a24 : isStepCount(20),
10855
+ stopWhen: (_a25 = this.settings.stopWhen) != null ? _a25 : isStepCount(20),
10814
10856
  ...options
10815
10857
  };
10816
- const preparedCallArgs = (_d = await ((_c = (_b24 = this.settings).prepareCall) == null ? void 0 : _c.call(
10817
- _b24,
10858
+ const preparedCallArgs = (_d = await ((_c = (_b25 = this.settings).prepareCall) == null ? void 0 : _c.call(
10859
+ _b25,
10818
10860
  baseCallArgs
10819
10861
  ))) != null ? _d : baseCallArgs;
10820
10862
  const {
@@ -10849,9 +10891,9 @@ var ToolLoopAgent = class {
10849
10891
  * downstream by generateText/streamText and the provider.
10850
10892
  */
10851
10893
  agentHeaders(preparedCall) {
10852
- var _a24;
10894
+ var _a25;
10853
10895
  return withUserAgentSuffix3(
10854
- (_a24 = preparedCall.headers) != null ? _a24 : {},
10896
+ (_a25 = preparedCall.headers) != null ? _a25 : {},
10855
10897
  "ai-sdk-agent/tool-loop"
10856
10898
  );
10857
10899
  }
@@ -10874,7 +10916,7 @@ var ToolLoopAgent = class {
10874
10916
  onEnd = onFinish,
10875
10917
  ...options
10876
10918
  }) {
10877
- var _a24, _b24, _c;
10919
+ var _a25, _b25, _c;
10878
10920
  const generate = generateText;
10879
10921
  const preparedCall = await this.prepareCall({
10880
10922
  ...options,
@@ -10885,11 +10927,11 @@ var ToolLoopAgent = class {
10885
10927
  timeout: timeout != null ? timeout : preparedCall.timeout,
10886
10928
  experimental_sandbox: sandbox,
10887
10929
  onStart: mergeCallbacks(
10888
- (_a24 = this.settings.onStart) != null ? _a24 : this.settings.experimental_onStart,
10930
+ (_a25 = this.settings.onStart) != null ? _a25 : this.settings.experimental_onStart,
10889
10931
  onStart != null ? onStart : experimental_onStart
10890
10932
  ),
10891
10933
  onStepStart: mergeCallbacks(
10892
- (_b24 = this.settings.onStepStart) != null ? _b24 : this.settings.experimental_onStepStart,
10934
+ (_b25 = this.settings.onStepStart) != null ? _b25 : this.settings.experimental_onStepStart,
10893
10935
  onStepStart != null ? onStepStart : experimental_onStepStart
10894
10936
  ),
10895
10937
  onToolExecutionStart: mergeCallbacks(
@@ -10932,7 +10974,7 @@ var ToolLoopAgent = class {
10932
10974
  onEnd = onFinish,
10933
10975
  ...options
10934
10976
  }) {
10935
- var _a24, _b24, _c;
10977
+ var _a25, _b25, _c;
10936
10978
  const stream = streamText;
10937
10979
  const preparedCall = await this.prepareCall({
10938
10980
  ...options,
@@ -10944,11 +10986,11 @@ var ToolLoopAgent = class {
10944
10986
  experimental_sandbox: sandbox,
10945
10987
  experimental_transform,
10946
10988
  onStart: mergeCallbacks(
10947
- (_a24 = this.settings.onStart) != null ? _a24 : this.settings.experimental_onStart,
10989
+ (_a25 = this.settings.onStart) != null ? _a25 : this.settings.experimental_onStart,
10948
10990
  onStart != null ? onStart : experimental_onStart
10949
10991
  ),
10950
10992
  onStepStart: mergeCallbacks(
10951
- (_b24 = this.settings.onStepStart) != null ? _b24 : this.settings.experimental_onStepStart,
10993
+ (_b25 = this.settings.onStepStart) != null ? _b25 : this.settings.experimental_onStepStart,
10952
10994
  onStepStart != null ? onStepStart : experimental_onStepStart
10953
10995
  ),
10954
10996
  onToolExecutionStart: mergeCallbacks(
@@ -11115,7 +11157,7 @@ function readUIMessageStream({
11115
11157
  onError,
11116
11158
  terminateOnError = false
11117
11159
  }) {
11118
- var _a24;
11160
+ var _a25;
11119
11161
  let controller;
11120
11162
  let hasErrored = false;
11121
11163
  const outputStream = new ReadableStream({
@@ -11124,7 +11166,7 @@ function readUIMessageStream({
11124
11166
  }
11125
11167
  });
11126
11168
  const state = createStreamingUIMessageState({
11127
- messageId: (_a24 = message == null ? void 0 : message.id) != null ? _a24 : "",
11169
+ messageId: (_a25 = message == null ? void 0 : message.id) != null ? _a25 : "",
11128
11170
  lastMessage: message
11129
11171
  });
11130
11172
  const handleError = (error) => {
@@ -11193,7 +11235,7 @@ async function convertToModelMessages(messages, options) {
11193
11235
  modelMessages.push({
11194
11236
  role: "user",
11195
11237
  content: message.parts.map((part) => {
11196
- var _a24;
11238
+ var _a25;
11197
11239
  if (isTextUIPart(part)) {
11198
11240
  return {
11199
11241
  type: "text",
@@ -11214,7 +11256,7 @@ async function convertToModelMessages(messages, options) {
11214
11256
  };
11215
11257
  }
11216
11258
  if (isDataUIPart(part)) {
11217
- return (_a24 = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _a24.call(
11259
+ return (_a25 = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _a25.call(
11218
11260
  options,
11219
11261
  part
11220
11262
  );
@@ -11227,7 +11269,7 @@ async function convertToModelMessages(messages, options) {
11227
11269
  if (message.parts != null) {
11228
11270
  let block = [];
11229
11271
  async function processBlock() {
11230
- var _a24, _b24, _c, _d, _e, _f, _g;
11272
+ var _a25, _b25, _c, _d, _e, _f, _g;
11231
11273
  if (block.length === 0) {
11232
11274
  return;
11233
11275
  }
@@ -11276,7 +11318,7 @@ async function convertToModelMessages(messages, options) {
11276
11318
  type: "tool-call",
11277
11319
  toolCallId: part.toolCallId,
11278
11320
  toolName,
11279
- input: part.state === "output-error" ? (_a24 = part.input) != null ? _a24 : "rawInput" in part ? part.rawInput : void 0 : part.input,
11321
+ input: part.state === "output-error" ? (_a25 = part.input) != null ? _a25 : "rawInput" in part ? part.rawInput : void 0 : part.input,
11280
11322
  providerExecuted: part.providerExecuted,
11281
11323
  ...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}
11282
11324
  });
@@ -11291,7 +11333,7 @@ async function convertToModelMessages(messages, options) {
11291
11333
  });
11292
11334
  }
11293
11335
  if (part.providerExecuted === true && part.state !== "approval-responded" && (part.state === "output-available" || part.state === "output-error")) {
11294
- const resultProviderMetadata = (_b24 = part.resultProviderMetadata) != null ? _b24 : part.callProviderMetadata;
11336
+ const resultProviderMetadata = (_b25 = part.resultProviderMetadata) != null ? _b25 : part.callProviderMetadata;
11295
11337
  content.push({
11296
11338
  type: "tool-result",
11297
11339
  toolCallId: part.toolCallId,
@@ -11328,8 +11370,8 @@ async function convertToModelMessages(messages, options) {
11328
11370
  }
11329
11371
  const toolParts = block.filter(
11330
11372
  (part) => {
11331
- var _a25;
11332
- return isToolUIPart(part) && (part.providerExecuted !== true || ((_a25 = part.approval) == null ? void 0 : _a25.approved) != null);
11373
+ var _a26;
11374
+ return isToolUIPart(part) && (part.providerExecuted !== true || ((_a26 = part.approval) == null ? void 0 : _a26.approved) != null);
11333
11375
  }
11334
11376
  );
11335
11377
  if (toolParts.length > 0) {
@@ -11556,6 +11598,7 @@ var uiMessagesSchema = lazySchema2(
11556
11598
  approval: z.object({
11557
11599
  id: z.string(),
11558
11600
  approved: z.never().optional(),
11601
+ descriptor: z.unknown().optional(),
11559
11602
  requestReason: z.string().optional(),
11560
11603
  reason: z.never().optional(),
11561
11604
  isAutomatic: z.boolean().optional(),
@@ -11576,6 +11619,7 @@ var uiMessagesSchema = lazySchema2(
11576
11619
  approval: z.object({
11577
11620
  id: z.string(),
11578
11621
  approved: z.boolean(),
11622
+ descriptor: z.unknown().optional(),
11579
11623
  requestReason: z.string().optional(),
11580
11624
  reason: z.string().optional(),
11581
11625
  isAutomatic: z.boolean().optional(),
@@ -11598,6 +11642,7 @@ var uiMessagesSchema = lazySchema2(
11598
11642
  approval: z.object({
11599
11643
  id: z.string(),
11600
11644
  approved: z.literal(true),
11645
+ descriptor: z.unknown().optional(),
11601
11646
  requestReason: z.string().optional(),
11602
11647
  reason: z.string().optional(),
11603
11648
  isAutomatic: z.boolean().optional(),
@@ -11620,6 +11665,7 @@ var uiMessagesSchema = lazySchema2(
11620
11665
  approval: z.object({
11621
11666
  id: z.string(),
11622
11667
  approved: z.literal(true),
11668
+ descriptor: z.unknown().optional(),
11623
11669
  requestReason: z.string().optional(),
11624
11670
  reason: z.string().optional(),
11625
11671
  isAutomatic: z.boolean().optional(),
@@ -11640,6 +11686,7 @@ var uiMessagesSchema = lazySchema2(
11640
11686
  approval: z.object({
11641
11687
  id: z.string(),
11642
11688
  approved: z.literal(false),
11689
+ descriptor: z.unknown().optional(),
11643
11690
  requestReason: z.string().optional(),
11644
11691
  reason: z.string().optional(),
11645
11692
  isAutomatic: z.boolean().optional(),
@@ -11683,6 +11730,7 @@ var uiMessagesSchema = lazySchema2(
11683
11730
  approval: z.object({
11684
11731
  id: z.string(),
11685
11732
  approved: z.never().optional(),
11733
+ descriptor: z.unknown().optional(),
11686
11734
  requestReason: z.string().optional(),
11687
11735
  reason: z.never().optional(),
11688
11736
  isAutomatic: z.boolean().optional(),
@@ -11702,6 +11750,7 @@ var uiMessagesSchema = lazySchema2(
11702
11750
  approval: z.object({
11703
11751
  id: z.string(),
11704
11752
  approved: z.boolean(),
11753
+ descriptor: z.unknown().optional(),
11705
11754
  requestReason: z.string().optional(),
11706
11755
  reason: z.string().optional(),
11707
11756
  isAutomatic: z.boolean().optional(),
@@ -11723,6 +11772,7 @@ var uiMessagesSchema = lazySchema2(
11723
11772
  approval: z.object({
11724
11773
  id: z.string(),
11725
11774
  approved: z.literal(true),
11775
+ descriptor: z.unknown().optional(),
11726
11776
  requestReason: z.string().optional(),
11727
11777
  reason: z.string().optional(),
11728
11778
  isAutomatic: z.boolean().optional(),
@@ -11744,6 +11794,7 @@ var uiMessagesSchema = lazySchema2(
11744
11794
  approval: z.object({
11745
11795
  id: z.string(),
11746
11796
  approved: z.literal(true),
11797
+ descriptor: z.unknown().optional(),
11747
11798
  requestReason: z.string().optional(),
11748
11799
  reason: z.string().optional(),
11749
11800
  isAutomatic: z.boolean().optional(),
@@ -11763,6 +11814,7 @@ var uiMessagesSchema = lazySchema2(
11763
11814
  approval: z.object({
11764
11815
  id: z.string(),
11765
11816
  approved: z.literal(false),
11817
+ descriptor: z.unknown().optional(),
11766
11818
  requestReason: z.string().optional(),
11767
11819
  reason: z.string().optional(),
11768
11820
  isAutomatic: z.boolean().optional(),
@@ -11982,7 +12034,7 @@ async function createAgentUIStream({
11982
12034
  onStepFinish,
11983
12035
  ...uiMessageStreamOptions
11984
12036
  }) {
11985
- var _a24;
12037
+ var _a25;
11986
12038
  const validatedMessages = await validateUIMessagesForAgent({
11987
12039
  messages: uiMessages,
11988
12040
  // tools are compatible; the casting is required because the context param is
@@ -12001,7 +12053,7 @@ async function createAgentUIStream({
12001
12053
  experimental_transform,
12002
12054
  onStepEnd: onStepEnd != null ? onStepEnd : onStepFinish
12003
12055
  });
12004
- const originalMessages = (_a24 = uiMessageStreamOptions.originalMessages) != null ? _a24 : validatedMessages;
12056
+ const originalMessages = (_a25 = uiMessageStreamOptions.originalMessages) != null ? _a25 : validatedMessages;
12005
12057
  return createAsyncIterableStream(
12006
12058
  toUIMessageStream({
12007
12059
  ...uiMessageStreamOptions,
@@ -12056,6 +12108,10 @@ import { withUserAgentSuffix as withUserAgentSuffix4 } from "@ai-sdk/provider-ut
12056
12108
  async function startTextBatch({
12057
12109
  model: modelArg,
12058
12110
  requests,
12111
+ tools,
12112
+ toolChoice,
12113
+ toolOrder,
12114
+ toolsContext,
12059
12115
  providerOptions,
12060
12116
  webhookUrl,
12061
12117
  abortSignal,
@@ -12069,6 +12125,12 @@ async function startTextBatch({
12069
12125
  getTotalTimeoutMs(timeout)
12070
12126
  );
12071
12127
  const supportedUrls = await model.supportedUrls;
12128
+ const preparedTools = await prepareTools({
12129
+ tools,
12130
+ toolOrder,
12131
+ toolsContext
12132
+ });
12133
+ const preparedToolChoice = prepareToolChoice({ toolChoice });
12072
12134
  operationAbortSignal == null ? void 0 : operationAbortSignal.throwIfAborted();
12073
12135
  const normalizedRequests = [];
12074
12136
  for (const request of requests) {
@@ -12083,6 +12145,8 @@ async function startTextBatch({
12083
12145
  download: void 0,
12084
12146
  provider: model.provider.split(".")[0]
12085
12147
  }),
12148
+ tools: preparedTools,
12149
+ toolChoice: preparedToolChoice,
12086
12150
  providerOptions: request.providerOptions
12087
12151
  }
12088
12152
  });
@@ -12155,6 +12219,7 @@ async function getBatchStatus({
12155
12219
  function getBatchResults({
12156
12220
  model: modelArg,
12157
12221
  batch,
12222
+ tools,
12158
12223
  providerOptions,
12159
12224
  maxRetries,
12160
12225
  abortSignal,
@@ -12175,7 +12240,7 @@ function getBatchResults({
12175
12240
  });
12176
12241
  const transformer = {
12177
12242
  async transform(item, controller) {
12178
- controller.enqueue(await convertBatchItemResult(item));
12243
+ controller.enqueue(await convertBatchItemResult({ item, tools }));
12179
12244
  },
12180
12245
  cancel(reason) {
12181
12246
  streamAbortController.abort(
@@ -12264,25 +12329,31 @@ function validateBatchReference({
12264
12329
  });
12265
12330
  }
12266
12331
  }
12267
- async function convertBatchItemResult(item) {
12332
+ async function convertBatchItemResult({
12333
+ item,
12334
+ tools
12335
+ }) {
12268
12336
  if (item.status !== "succeeded") {
12269
12337
  return item;
12270
12338
  }
12271
12339
  return {
12272
12340
  id: item.id,
12273
12341
  status: "succeeded",
12274
- ...await convertGenerateResult(item.result)
12342
+ ...await convertGenerateResult({ result: item.result, tools })
12275
12343
  };
12276
12344
  }
12277
- async function convertGenerateResult(result) {
12278
- var _a24;
12345
+ async function convertGenerateResult({
12346
+ result,
12347
+ tools
12348
+ }) {
12349
+ var _a25;
12279
12350
  const toolCalls = await Promise.all(
12280
12351
  result.content.filter(
12281
12352
  (part) => part.type === "tool-call"
12282
12353
  ).map(
12283
12354
  (toolCall) => parseToolCall({
12284
12355
  toolCall,
12285
- tools: void 0,
12356
+ tools,
12286
12357
  repairToolCall: void 0,
12287
12358
  refineToolInput: void 0,
12288
12359
  instructions: void 0,
@@ -12296,11 +12367,11 @@ async function convertGenerateResult(result) {
12296
12367
  toolOutputs: [],
12297
12368
  toolApprovalRequests: [],
12298
12369
  toolApprovalResponses: [],
12299
- tools: void 0
12370
+ tools
12300
12371
  });
12301
12372
  return {
12302
12373
  content,
12303
- text: content.filter(
12374
+ text: result.content.filter(
12304
12375
  (part) => part.type === "text"
12305
12376
  ).map((part) => part.text).join(""),
12306
12377
  finishReason: result.finishReason.unified,
@@ -12309,7 +12380,7 @@ async function convertGenerateResult(result) {
12309
12380
  ...result.response != null ? {
12310
12381
  response: {
12311
12382
  id: result.response.id,
12312
- timestamp: (_a24 = result.response.timestamp) == null ? void 0 : _a24.toISOString(),
12383
+ timestamp: (_a25 = result.response.timestamp) == null ? void 0 : _a25.toISOString(),
12313
12384
  modelId: result.response.modelId
12314
12385
  }
12315
12386
  } : {},
@@ -12341,7 +12412,7 @@ async function embed({
12341
12412
  experimental_onEnd,
12342
12413
  _internal: { generateCallId = originalGenerateCallId4 } = {}
12343
12414
  }) {
12344
- var _a24;
12415
+ var _a25;
12345
12416
  const model = resolveEmbeddingModel(modelArg);
12346
12417
  const { maxRetries, retry } = prepareRetries({
12347
12418
  maxRetries: maxRetriesArg,
@@ -12357,7 +12428,7 @@ async function embed({
12357
12428
  const telemetryDispatcher = createTelemetryDispatcher({
12358
12429
  telemetry
12359
12430
  });
12360
- const runInTracingChannelSpan = (_a24 = telemetryDispatcher.runInTracingChannelSpan) != null ? _a24 : (async ({ execute }) => await execute());
12431
+ const runInTracingChannelSpan = (_a25 = telemetryDispatcher.runInTracingChannelSpan) != null ? _a25 : (async ({ execute }) => await execute());
12361
12432
  const startEvent = {
12362
12433
  callId,
12363
12434
  operationId: "ai.embed",
@@ -12372,14 +12443,14 @@ async function embed({
12372
12443
  type: "embed",
12373
12444
  event: startEvent,
12374
12445
  execute: async () => {
12375
- var _a25;
12446
+ var _a26;
12376
12447
  await notify({
12377
12448
  event: startEvent,
12378
12449
  callbacks: [resolvedOnStart, telemetryDispatcher.onStart]
12379
12450
  });
12380
12451
  try {
12381
12452
  const { embedding, usage, warnings, response, providerMetadata } = await retry(async () => {
12382
- var _a26, _b24;
12453
+ var _a27, _b25;
12383
12454
  const embedCallId = generateCallId();
12384
12455
  await notify({
12385
12456
  event: {
@@ -12399,7 +12470,7 @@ async function embed({
12399
12470
  providerOptions
12400
12471
  });
12401
12472
  const embedding2 = modelResponse.embeddings[0];
12402
- const usage2 = (_a26 = modelResponse.usage) != null ? _a26 : { tokens: NaN };
12473
+ const usage2 = (_a27 = modelResponse.usage) != null ? _a27 : { tokens: NaN };
12403
12474
  await notify({
12404
12475
  event: {
12405
12476
  callId,
@@ -12416,7 +12487,7 @@ async function embed({
12416
12487
  return {
12417
12488
  embedding: embedding2,
12418
12489
  usage: usage2,
12419
- warnings: (_b24 = modelResponse.warnings) != null ? _b24 : [],
12490
+ warnings: (_b25 = modelResponse.warnings) != null ? _b25 : [],
12420
12491
  providerMetadata: modelResponse.providerMetadata,
12421
12492
  response: modelResponse.response
12422
12493
  };
@@ -12450,7 +12521,7 @@ async function embed({
12450
12521
  response
12451
12522
  });
12452
12523
  } catch (error) {
12453
- await ((_a25 = telemetryDispatcher.onError) == null ? void 0 : _a25.call(telemetryDispatcher, { callId, error }));
12524
+ await ((_a26 = telemetryDispatcher.onError) == null ? void 0 : _a26.call(telemetryDispatcher, { callId, error }));
12454
12525
  throw error;
12455
12526
  }
12456
12527
  }
@@ -12512,7 +12583,7 @@ async function embedMany({
12512
12583
  experimental_onEnd,
12513
12584
  _internal: { generateCallId = originalGenerateCallId5 } = {}
12514
12585
  }) {
12515
- var _a24;
12586
+ var _a25;
12516
12587
  const model = resolveEmbeddingModel(modelArg);
12517
12588
  const { maxRetries, retry } = prepareRetries({
12518
12589
  maxRetries: maxRetriesArg,
@@ -12528,7 +12599,7 @@ async function embedMany({
12528
12599
  const telemetryDispatcher = createTelemetryDispatcher({
12529
12600
  telemetry
12530
12601
  });
12531
- const runInTracingChannelSpan = (_a24 = telemetryDispatcher.runInTracingChannelSpan) != null ? _a24 : (async ({ execute }) => await execute());
12602
+ const runInTracingChannelSpan = (_a25 = telemetryDispatcher.runInTracingChannelSpan) != null ? _a25 : (async ({ execute }) => await execute());
12532
12603
  const startEvent = {
12533
12604
  callId,
12534
12605
  operationId: "ai.embedMany",
@@ -12543,7 +12614,7 @@ async function embedMany({
12543
12614
  type: "embedMany",
12544
12615
  event: startEvent,
12545
12616
  execute: async () => {
12546
- var _a25, _b24;
12617
+ var _a26, _b25;
12547
12618
  await notify({
12548
12619
  event: startEvent,
12549
12620
  callbacks: [resolvedOnStart, telemetryDispatcher.onStart]
@@ -12562,7 +12633,7 @@ async function embedMany({
12562
12633
  const hasInputByteLimit = maxInputBytesPerCall != null && maxInputBytesPerCall !== Infinity;
12563
12634
  if (!hasEmbeddingLimit && !hasInputByteLimit) {
12564
12635
  const { embeddings: embeddings2, usage, warnings: warnings2, response, providerMetadata: providerMetadata2 } = await retry(async () => {
12565
- var _a26, _b25;
12636
+ var _a27, _b26;
12566
12637
  const embedCallId = generateCallId();
12567
12638
  await notify({
12568
12639
  event: {
@@ -12582,7 +12653,7 @@ async function embedMany({
12582
12653
  providerOptions
12583
12654
  });
12584
12655
  const embeddings3 = modelResponse.embeddings;
12585
- const usage2 = (_a26 = modelResponse.usage) != null ? _a26 : { tokens: NaN };
12656
+ const usage2 = (_a27 = modelResponse.usage) != null ? _a27 : { tokens: NaN };
12586
12657
  await notify({
12587
12658
  event: {
12588
12659
  callId,
@@ -12599,7 +12670,7 @@ async function embedMany({
12599
12670
  return {
12600
12671
  embeddings: embeddings3,
12601
12672
  usage: usage2,
12602
- warnings: (_b25 = modelResponse.warnings) != null ? _b25 : [],
12673
+ warnings: (_b26 = modelResponse.warnings) != null ? _b26 : [],
12603
12674
  providerMetadata: modelResponse.providerMetadata,
12604
12675
  response: modelResponse.response
12605
12676
  };
@@ -12651,7 +12722,7 @@ async function embedMany({
12651
12722
  const results = await Promise.all(
12652
12723
  parallelChunk.map((chunk) => {
12653
12724
  return retry(async () => {
12654
- var _a26, _b25;
12725
+ var _a27, _b26;
12655
12726
  const embedCallId = generateCallId();
12656
12727
  await notify({
12657
12728
  event: {
@@ -12671,7 +12742,7 @@ async function embedMany({
12671
12742
  providerOptions
12672
12743
  });
12673
12744
  const chunkEmbeddings = modelResponse.embeddings;
12674
- const usage = (_a26 = modelResponse.usage) != null ? _a26 : { tokens: NaN };
12745
+ const usage = (_a27 = modelResponse.usage) != null ? _a27 : { tokens: NaN };
12675
12746
  await notify({
12676
12747
  event: {
12677
12748
  callId,
@@ -12688,7 +12759,7 @@ async function embedMany({
12688
12759
  return {
12689
12760
  embeddings: chunkEmbeddings,
12690
12761
  usage,
12691
- warnings: (_b25 = modelResponse.warnings) != null ? _b25 : [],
12762
+ warnings: (_b26 = modelResponse.warnings) != null ? _b26 : [],
12692
12763
  providerMetadata: modelResponse.providerMetadata,
12693
12764
  response: modelResponse.response
12694
12765
  };
@@ -12708,7 +12779,7 @@ async function embedMany({
12708
12779
  result.providerMetadata
12709
12780
  )) {
12710
12781
  providerMetadata[providerName] = {
12711
- ...(_a25 = providerMetadata[providerName]) != null ? _a25 : {},
12782
+ ...(_a26 = providerMetadata[providerName]) != null ? _a26 : {},
12712
12783
  ...metadata
12713
12784
  };
12714
12785
  }
@@ -12745,7 +12816,7 @@ async function embedMany({
12745
12816
  responses
12746
12817
  });
12747
12818
  } catch (error) {
12748
- await ((_b24 = telemetryDispatcher.onError) == null ? void 0 : _b24.call(telemetryDispatcher, { callId, error }));
12819
+ await ((_b25 = telemetryDispatcher.onError) == null ? void 0 : _b25.call(telemetryDispatcher, { callId, error }));
12749
12820
  throw error;
12750
12821
  }
12751
12822
  }
@@ -12861,7 +12932,7 @@ async function generateImage({
12861
12932
  abortSignal,
12862
12933
  headers
12863
12934
  }) {
12864
- var _a24, _b24;
12935
+ var _a25, _b25;
12865
12936
  const model = resolveImageModel(modelArg);
12866
12937
  const headersWithUserAgent = withUserAgentSuffix7(
12867
12938
  headers != null ? headers : {},
@@ -12871,7 +12942,7 @@ async function generateImage({
12871
12942
  maxRetries: maxRetriesArg,
12872
12943
  abortSignal
12873
12944
  });
12874
- const maxImagesPerCallWithDefault = (_a24 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a24 : 1;
12945
+ const maxImagesPerCallWithDefault = (_a25 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a25 : 1;
12875
12946
  const callCount = Math.ceil(n / maxImagesPerCallWithDefault);
12876
12947
  const callImageCounts = Array.from({ length: callCount }, (_, i) => {
12877
12948
  if (i < callCount - 1) {
@@ -12912,13 +12983,13 @@ async function generateImage({
12912
12983
  for (const result of results) {
12913
12984
  const callImages = result.images.map(
12914
12985
  (image, index) => {
12915
- var _a25;
12986
+ var _a26;
12916
12987
  return new DefaultGeneratedFile({
12917
12988
  data: image,
12918
- mediaType: (_a25 = detectMediaType2({
12989
+ mediaType: (_a26 = detectMediaType2({
12919
12990
  data: image,
12920
12991
  topLevelType: "image"
12921
- })) != null ? _a25 : "image/png",
12992
+ })) != null ? _a26 : "image/png",
12922
12993
  providerMetadata: getImageProviderMetadata(
12923
12994
  result.providerMetadata,
12924
12995
  index
@@ -12970,7 +13041,7 @@ async function generateImage({
12970
13041
  delete providerMetadata[providerName].images;
12971
13042
  }
12972
13043
  } else {
12973
- (_b24 = providerMetadata[providerName]) != null ? _b24 : providerMetadata[providerName] = { images: [] };
13044
+ (_b25 = providerMetadata[providerName]) != null ? _b25 : providerMetadata[providerName] = { images: [] };
12974
13045
  providerMetadata[providerName].images.push(...metadata.images);
12975
13046
  }
12976
13047
  }
@@ -13004,13 +13075,13 @@ var DefaultGenerateImageResult = class {
13004
13075
  }
13005
13076
  };
13006
13077
  function getImageProviderMetadata(providerMetadata, imageIndex) {
13007
- var _a24;
13078
+ var _a25;
13008
13079
  if (providerMetadata == null) {
13009
13080
  return void 0;
13010
13081
  }
13011
13082
  let imageMetadata;
13012
13083
  for (const [providerName, metadata] of Object.entries(providerMetadata)) {
13013
- const value = (_a24 = metadata.images) == null ? void 0 : _a24[imageIndex];
13084
+ const value = (_a25 = metadata.images) == null ? void 0 : _a25[imageIndex];
13014
13085
  if (isJSONObject(value) && !Array.isArray(value)) {
13015
13086
  (imageMetadata != null ? imageMetadata : imageMetadata = {})[providerName] = value;
13016
13087
  }
@@ -13194,7 +13265,7 @@ var arrayOutputStrategy = (schema) => {
13194
13265
  isFirstDelta,
13195
13266
  isFinalDelta
13196
13267
  }) {
13197
- var _a24;
13268
+ var _a25;
13198
13269
  if (!isJSONObject2(value) || !isJSONArray(value.elements)) {
13199
13270
  return {
13200
13271
  success: false,
@@ -13217,7 +13288,7 @@ var arrayOutputStrategy = (schema) => {
13217
13288
  }
13218
13289
  resultArray.push(result.value);
13219
13290
  }
13220
- const publishedElementCount = (_a24 = latestObject == null ? void 0 : latestObject.length) != null ? _a24 : 0;
13291
+ const publishedElementCount = (_a25 = latestObject == null ? void 0 : latestObject.length) != null ? _a25 : 0;
13221
13292
  let textDelta = "";
13222
13293
  if (isFirstDelta) {
13223
13294
  textDelta += "[";
@@ -13561,7 +13632,7 @@ function validateObjectGenerationInput({
13561
13632
  // src/generate-object/generate-object.ts
13562
13633
  var originalGenerateId4 = createIdGenerator6({ prefix: "aiobj", size: 24 });
13563
13634
  async function generateObject(options) {
13564
- var _a24, _b24, _c, _d, _e, _f, _g, _h, _i, _j;
13635
+ var _a25, _b25, _c, _d, _e, _f, _g, _h, _i, _j;
13565
13636
  const {
13566
13637
  model: modelArg,
13567
13638
  output = "object",
@@ -13696,7 +13767,7 @@ async function generateObject(options) {
13696
13767
  })
13697
13768
  );
13698
13769
  const responseData = {
13699
- id: (_b24 = (_a24 = generateResult.response) == null ? void 0 : _a24.id) != null ? _b24 : generateId4(),
13770
+ id: (_b25 = (_a25 = generateResult.response) == null ? void 0 : _a25.id) != null ? _b25 : generateId4(),
13700
13771
  timestamp: (_d = (_c = generateResult.response) == null ? void 0 : _c.timestamp) != null ? _d : currentDate(),
13701
13772
  modelId: (_f = (_e = generateResult.response) == null ? void 0 : _e.modelId) != null ? _f : model.modelId,
13702
13773
  headers: (_g = generateResult.response) == null ? void 0 : _g.headers,
@@ -13794,9 +13865,9 @@ var DefaultGenerateObjectResult = class {
13794
13865
  this.reasoning = options.reasoning;
13795
13866
  }
13796
13867
  toJsonResponse(init) {
13797
- var _a24;
13868
+ var _a25;
13798
13869
  return new Response(JSON.stringify(this.object), {
13799
- status: (_a24 = init == null ? void 0 : init.status) != null ? _a24 : 200,
13870
+ status: (_a25 = init == null ? void 0 : init.status) != null ? _a25 : 200,
13800
13871
  headers: prepareHeaders(init == null ? void 0 : init.headers, {
13801
13872
  "content-type": "application/json; charset=utf-8"
13802
13873
  })
@@ -13922,8 +13993,8 @@ function simulateReadableStream({
13922
13993
  chunkDelayInMs = 0,
13923
13994
  _internal
13924
13995
  }) {
13925
- var _a24;
13926
- const delay = (_a24 = _internal == null ? void 0 : _internal.delay) != null ? _a24 : delayFunction;
13996
+ var _a25;
13997
+ const delay = (_a25 = _internal == null ? void 0 : _internal.delay) != null ? _a25 : delayFunction;
13927
13998
  let index = 0;
13928
13999
  return new ReadableStream({
13929
14000
  async pull(controller) {
@@ -14193,7 +14264,7 @@ var DefaultStreamObjectResult = class {
14193
14264
  const transformedStream = stream.pipeThrough(new TransformStream(transformer)).pipeThrough(
14194
14265
  new TransformStream({
14195
14266
  async transform(chunk, controller) {
14196
- var _a24, _b24, _c;
14267
+ var _a25, _b25, _c;
14197
14268
  if (typeof chunk === "object" && chunk.type === "stream-start") {
14198
14269
  warnings = chunk.warnings;
14199
14270
  return;
@@ -14237,8 +14308,8 @@ var DefaultStreamObjectResult = class {
14237
14308
  switch (chunk.type) {
14238
14309
  case "response-metadata": {
14239
14310
  fullResponse = {
14240
- id: (_a24 = chunk.id) != null ? _a24 : fullResponse.id,
14241
- timestamp: (_b24 = chunk.timestamp) != null ? _b24 : fullResponse.timestamp,
14311
+ id: (_a25 = chunk.id) != null ? _a25 : fullResponse.id,
14312
+ timestamp: (_b25 = chunk.timestamp) != null ? _b25 : fullResponse.timestamp,
14242
14313
  modelId: (_c = chunk.modelId) != null ? _c : fullResponse.modelId
14243
14314
  };
14244
14315
  break;
@@ -14373,9 +14444,9 @@ var DefaultStreamObjectResult = class {
14373
14444
  }
14374
14445
  });
14375
14446
  })().catch(async (error) => {
14376
- var _a24;
14447
+ var _a25;
14377
14448
  self.rejectResultPromises(error);
14378
- await ((_a24 = telemetryDispatcher.onError) == null ? void 0 : _a24.call(telemetryDispatcher, { callId, error }));
14449
+ await ((_a25 = telemetryDispatcher.onError) == null ? void 0 : _a25.call(telemetryDispatcher, { callId, error }));
14379
14450
  stitchableStream.addStream(
14380
14451
  new ReadableStream({
14381
14452
  start(controller) {
@@ -14540,7 +14611,7 @@ async function generateSpeech({
14540
14611
  abortSignal,
14541
14612
  headers
14542
14613
  }) {
14543
- var _a24;
14614
+ var _a25;
14544
14615
  const resolvedModel = resolveSpeechModel(model);
14545
14616
  if (!resolvedModel) {
14546
14617
  throw new Error("Model could not be resolved");
@@ -14577,10 +14648,10 @@ async function generateSpeech({
14577
14648
  return new DefaultSpeechResult({
14578
14649
  audio: new DefaultGeneratedAudioFile({
14579
14650
  data: result.audio,
14580
- mediaType: (_a24 = detectMediaType3({
14651
+ mediaType: (_a25 = detectMediaType3({
14581
14652
  data: result.audio,
14582
14653
  topLevelType: "audio"
14583
- })) != null ? _a24 : "audio/mp3"
14654
+ })) != null ? _a25 : "audio/mp3"
14584
14655
  }),
14585
14656
  warnings: result.warnings,
14586
14657
  responses: [result.response],
@@ -14589,11 +14660,11 @@ async function generateSpeech({
14589
14660
  }
14590
14661
  var DefaultSpeechResult = class {
14591
14662
  constructor(options) {
14592
- var _a24;
14663
+ var _a25;
14593
14664
  this.audio = options.audio;
14594
14665
  this.warnings = options.warnings;
14595
14666
  this.responses = options.responses;
14596
- this.providerMetadata = (_a24 = options.providerMetadata) != null ? _a24 : {};
14667
+ this.providerMetadata = (_a25 = options.providerMetadata) != null ? _a25 : {};
14597
14668
  }
14598
14669
  };
14599
14670
 
@@ -14816,14 +14887,14 @@ function tagDescription(description) {
14816
14887
  }
14817
14888
  async function fingerprintTools(tools) {
14818
14889
  const entries = await Promise.all(
14819
- Object.keys(tools).map(async (name24) => {
14820
- const tool2 = tools[name24];
14890
+ Object.keys(tools).map(async (name25) => {
14891
+ const tool2 = tools[name25];
14821
14892
  const digest = await hashCanonical({
14822
14893
  description: tagDescription(tool2.description),
14823
14894
  inputSchema: await asSchema6(tool2.inputSchema).jsonSchema,
14824
14895
  title: tool2.title
14825
14896
  });
14826
- return [name24, digest];
14897
+ return [name25, digest];
14827
14898
  })
14828
14899
  );
14829
14900
  return Object.fromEntries(entries);
@@ -14832,16 +14903,16 @@ function detectToolDrift(current, baseline) {
14832
14903
  const added = [];
14833
14904
  const removed = [];
14834
14905
  const changed = [];
14835
- for (const name24 of Object.keys(current)) {
14836
- if (!Object.hasOwn(baseline, name24)) {
14837
- added.push(name24);
14838
- } else if (current[name24] !== baseline[name24]) {
14839
- changed.push(name24);
14906
+ for (const name25 of Object.keys(current)) {
14907
+ if (!Object.hasOwn(baseline, name25)) {
14908
+ added.push(name25);
14909
+ } else if (current[name25] !== baseline[name25]) {
14910
+ changed.push(name25);
14840
14911
  }
14841
14912
  }
14842
- for (const name24 of Object.keys(baseline)) {
14843
- if (!Object.hasOwn(current, name24)) {
14844
- removed.push(name24);
14913
+ for (const name25 of Object.keys(baseline)) {
14914
+ if (!Object.hasOwn(current, name25)) {
14915
+ removed.push(name25);
14845
14916
  }
14846
14917
  }
14847
14918
  return { added, removed, changed };
@@ -14877,7 +14948,7 @@ async function experimental_generateVideo({
14877
14948
  poll,
14878
14949
  webhook
14879
14950
  }) {
14880
- var _a24;
14951
+ var _a25;
14881
14952
  const model = resolveVideoModel(modelArg);
14882
14953
  const headersWithUserAgent = withUserAgentSuffix10(
14883
14954
  headers != null ? headers : {},
@@ -14894,7 +14965,7 @@ async function experimental_generateVideo({
14894
14965
  effectiveInputReferences,
14895
14966
  warnings
14896
14967
  } = normalizeVideoCallInputs({ promptArg, frameImages, inputReferences });
14897
- const maxVideosPerCallWithDefault = (_a24 = maxVideosPerCall != null ? maxVideosPerCall : await invokeModelMaxVideosPerCall(model)) != null ? _a24 : 1;
14968
+ const maxVideosPerCallWithDefault = (_a25 = maxVideosPerCall != null ? maxVideosPerCall : await invokeModelMaxVideosPerCall(model)) != null ? _a25 : 1;
14898
14969
  const hasStartStatus = model.doStart != null && model.doStatus != null;
14899
14970
  const useStartStatus = hasStartStatus && (poll != null || webhook != null || model.doGenerate == null);
14900
14971
  if (model.doGenerate == null && !hasStartStatus) {
@@ -15033,7 +15104,7 @@ async function executeStartStatusFlow({
15033
15104
  webhook: webhookFactory,
15034
15105
  retry
15035
15106
  }) {
15036
- var _a24, _b24, _c, _d;
15107
+ var _a25, _b25, _c, _d;
15037
15108
  const earlyWarnings = [];
15038
15109
  let webhookUrl;
15039
15110
  let webhookReceived;
@@ -15052,7 +15123,7 @@ async function executeStartStatusFlow({
15052
15123
  });
15053
15124
  }
15054
15125
  }
15055
- const callerIdempotencyKey = Object.entries((_a24 = callOptions.headers) != null ? _a24 : {}).find(
15126
+ const callerIdempotencyKey = Object.entries((_a25 = callOptions.headers) != null ? _a25 : {}).find(
15056
15127
  ([key, value]) => key.toLowerCase() === "idempotency-key" && value !== void 0
15057
15128
  );
15058
15129
  const startCallOptions = {
@@ -15066,7 +15137,7 @@ async function executeStartStatusFlow({
15066
15137
  const startResult = await retry(() => model.doStart(startCallOptions));
15067
15138
  const allWarnings = [...earlyWarnings, ...startResult.warnings];
15068
15139
  let operationProviderMetadata = startResult.providerMetadata == null ? void 0 : { ...startResult.providerMetadata };
15069
- const intervalMs = (_b24 = pollConfig == null ? void 0 : pollConfig.intervalMs) != null ? _b24 : 5e3;
15140
+ const intervalMs = (_b25 = pollConfig == null ? void 0 : pollConfig.intervalMs) != null ? _b25 : 5e3;
15070
15141
  const timeoutMs = (_c = pollConfig == null ? void 0 : pollConfig.timeoutMs) != null ? _c : 6e5;
15071
15142
  const delay = (_d = pollConfig == null ? void 0 : pollConfig.delay) != null ? _d : defaultDelay;
15072
15143
  const startTime = Date.now();
@@ -15182,7 +15253,7 @@ function normalizeVideoCallInputs({
15182
15253
  frameImages,
15183
15254
  inputReferences
15184
15255
  }) {
15185
- var _a24;
15256
+ var _a25;
15186
15257
  const { prompt, image } = normalizePrompt2(promptArg);
15187
15258
  const normalizedFrameImages = frameImages == null ? void 0 : frameImages.flatMap((frame) => {
15188
15259
  const normalizedImage = normalizeImageData(frame.image);
@@ -15200,9 +15271,9 @@ function normalizeVideoCallInputs({
15200
15271
  message: "inputReferences were ignored because frameImages were provided; frameImages and inputReferences cannot be combined."
15201
15272
  });
15202
15273
  }
15203
- const firstFrameImage = (_a24 = normalizedFrameImages == null ? void 0 : normalizedFrameImages.find(
15274
+ const firstFrameImage = (_a25 = normalizedFrameImages == null ? void 0 : normalizedFrameImages.find(
15204
15275
  (frame) => frame.frameType === "first_frame"
15205
- )) == null ? void 0 : _a24.image;
15276
+ )) == null ? void 0 : _a25.image;
15206
15277
  if (image != null && firstFrameImage != null) {
15207
15278
  warnings.push({
15208
15279
  type: "other",
@@ -15448,8 +15519,8 @@ function stripMarkdownCodeFenceSuffix(text2) {
15448
15519
  return text2.replace(/\n?```\s*$/, "").trimEnd();
15449
15520
  }
15450
15521
  function extractJsonMiddleware(options) {
15451
- var _a24;
15452
- const transform = (_a24 = options == null ? void 0 : options.transform) != null ? _a24 : defaultTransform;
15522
+ var _a25;
15523
+ const transform = (_a25 = options == null ? void 0 : options.transform) != null ? _a25 : defaultTransform;
15453
15524
  const hasCustomTransform = (options == null ? void 0 : options.transform) !== void 0;
15454
15525
  return {
15455
15526
  specificationVersion: "v4",
@@ -15825,13 +15896,13 @@ function addToolInputExamplesMiddleware({
15825
15896
  return {
15826
15897
  specificationVersion: "v4",
15827
15898
  transformParams: async ({ params }) => {
15828
- var _a24;
15829
- if (!((_a24 = params.tools) == null ? void 0 : _a24.length)) {
15899
+ var _a25;
15900
+ if (!((_a25 = params.tools) == null ? void 0 : _a25.length)) {
15830
15901
  return params;
15831
15902
  }
15832
15903
  const transformedTools = params.tools.map((tool2) => {
15833
- var _a25;
15834
- if (tool2.type !== "function" || !((_a25 = tool2.inputExamples) == null ? void 0 : _a25.length)) {
15904
+ var _a26;
15905
+ if (tool2.type !== "function" || !((_a26 = tool2.inputExamples) == null ? void 0 : _a26.length)) {
15835
15906
  return tool2;
15836
15907
  }
15837
15908
  const formattedExamples = tool2.inputExamples.map((example, index) => format(example, index)).join("\n");
@@ -15880,7 +15951,7 @@ var doWrap = ({
15880
15951
  modelId,
15881
15952
  providerId
15882
15953
  }) => {
15883
- var _a24, _b24, _c;
15954
+ var _a25, _b25, _c;
15884
15955
  async function doTransform({
15885
15956
  params,
15886
15957
  type
@@ -15889,8 +15960,8 @@ var doWrap = ({
15889
15960
  }
15890
15961
  return {
15891
15962
  specificationVersion: "v4",
15892
- provider: (_a24 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a24 : model.provider,
15893
- modelId: (_b24 = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b24 : model.modelId,
15963
+ provider: (_a25 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a25 : model.provider,
15964
+ modelId: (_b25 = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b25 : model.modelId,
15894
15965
  supportedUrls: (_c = overrideSupportedUrls == null ? void 0 : overrideSupportedUrls({ model })) != null ? _c : model.supportedUrls,
15895
15966
  async doGenerate(params) {
15896
15967
  const transformedParams = await doTransform({ params, type: "generate" });
@@ -15946,7 +16017,7 @@ var doWrap2 = ({
15946
16017
  modelId,
15947
16018
  providerId
15948
16019
  }) => {
15949
- var _a24, _b24, _c, _d;
16020
+ var _a25, _b25, _c, _d;
15950
16021
  async function doTransform({
15951
16022
  params
15952
16023
  }) {
@@ -15954,8 +16025,8 @@ var doWrap2 = ({
15954
16025
  }
15955
16026
  return {
15956
16027
  specificationVersion: "v4",
15957
- provider: (_a24 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a24 : model.provider,
15958
- modelId: (_b24 = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b24 : model.modelId,
16028
+ provider: (_a25 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a25 : model.provider,
16029
+ modelId: (_b25 = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b25 : model.modelId,
15959
16030
  maxEmbeddingsPerCall: (_c = overrideMaxEmbeddingsPerCall == null ? void 0 : overrideMaxEmbeddingsPerCall({ model })) != null ? _c : model.maxEmbeddingsPerCall,
15960
16031
  [EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL2]: getEmbeddingModelMaxInputBytesPerCall(model),
15961
16032
  supportsParallelCalls: (_d = overrideSupportsParallelCalls == null ? void 0 : overrideSupportsParallelCalls({ model })) != null ? _d : model.supportsParallelCalls,
@@ -15996,15 +16067,15 @@ var doWrap3 = ({
15996
16067
  modelId,
15997
16068
  providerId
15998
16069
  }) => {
15999
- var _a24, _b24, _c;
16070
+ var _a25, _b25, _c;
16000
16071
  async function doTransform({ params }) {
16001
16072
  return transformParams ? await transformParams({ params, model }) : params;
16002
16073
  }
16003
- const maxImagesPerCallRaw = (_a24 = overrideMaxImagesPerCall == null ? void 0 : overrideMaxImagesPerCall({ model })) != null ? _a24 : model.maxImagesPerCall;
16074
+ const maxImagesPerCallRaw = (_a25 = overrideMaxImagesPerCall == null ? void 0 : overrideMaxImagesPerCall({ model })) != null ? _a25 : model.maxImagesPerCall;
16004
16075
  const maxImagesPerCall = maxImagesPerCallRaw instanceof Function ? maxImagesPerCallRaw.bind(model) : maxImagesPerCallRaw;
16005
16076
  return {
16006
16077
  specificationVersion: "v4",
16007
- provider: (_b24 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _b24 : model.provider,
16078
+ provider: (_b25 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _b25 : model.provider,
16008
16079
  modelId: (_c = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _c : model.modelId,
16009
16080
  maxImagesPerCall,
16010
16081
  async doGenerate(params) {
@@ -16102,7 +16173,7 @@ async function getRealtimeToolDefinitions({
16102
16173
  toolsContext = {}
16103
16174
  }) {
16104
16175
  const definitions = [];
16105
- for (const [name24, tool2] of Object.entries(tools)) {
16176
+ for (const [name25, tool2] of Object.entries(tools)) {
16106
16177
  const toolType = tool2.type;
16107
16178
  switch (toolType) {
16108
16179
  case void 0:
@@ -16110,12 +16181,12 @@ async function getRealtimeToolDefinitions({
16110
16181
  case "dynamic": {
16111
16182
  const description = resolveRealtimeToolDescription({
16112
16183
  tool: tool2,
16113
- toolName: name24,
16184
+ toolName: name25,
16114
16185
  toolsContext
16115
16186
  });
16116
16187
  definitions.push({
16117
16188
  type: "function",
16118
- name: name24,
16189
+ name: name25,
16119
16190
  description,
16120
16191
  parameters: await asSchema7(tool2.inputSchema).jsonSchema
16121
16192
  });
@@ -16189,9 +16260,9 @@ var BrowserRealtimeAudio = class {
16189
16260
  this.onCapturingChange(true);
16190
16261
  }
16191
16262
  stopCapture() {
16192
- var _a24, _b24, _c, _d;
16193
- (_a24 = this.captureProcessor) == null ? void 0 : _a24.disconnect();
16194
- (_b24 = this.captureSource) == null ? void 0 : _b24.disconnect();
16263
+ var _a25, _b25, _c, _d;
16264
+ (_a25 = this.captureProcessor) == null ? void 0 : _a25.disconnect();
16265
+ (_b25 = this.captureSource) == null ? void 0 : _b25.disconnect();
16195
16266
  void ((_c = this.captureContext) == null ? void 0 : _c.close());
16196
16267
  (_d = this.captureStream) == null ? void 0 : _d.getTracks().forEach((track) => track.stop());
16197
16268
  this.captureProcessor = null;
@@ -16225,16 +16296,16 @@ var BrowserRealtimeAudio = class {
16225
16296
  return (ctx.currentTime - this.playbackStartTime) * 1e3;
16226
16297
  }
16227
16298
  dispose() {
16228
- var _a24;
16299
+ var _a25;
16229
16300
  this.stopCapture();
16230
16301
  this.stopPlayback();
16231
- void ((_a24 = this.playbackContext) == null ? void 0 : _a24.close());
16302
+ void ((_a25 = this.playbackContext) == null ? void 0 : _a25.close());
16232
16303
  this.playbackContext = null;
16233
16304
  }
16234
16305
  setPlaying(isPlaying) {
16235
- var _a24, _b24;
16306
+ var _a25, _b25;
16236
16307
  if (isPlaying && !this.isPlaying) {
16237
- this.playbackStartTime = (_b24 = (_a24 = this.playbackContext) == null ? void 0 : _a24.currentTime) != null ? _b24 : 0;
16308
+ this.playbackStartTime = (_b25 = (_a25 = this.playbackContext) == null ? void 0 : _a25.currentTime) != null ? _b25 : 0;
16238
16309
  }
16239
16310
  if (this.isPlaying !== isPlaying) {
16240
16311
  this.isPlaying = isPlaying;
@@ -16286,8 +16357,8 @@ var BrowserRealtimeTransport = class {
16286
16357
  url,
16287
16358
  onOpen
16288
16359
  }) {
16289
- var _a24;
16290
- (_a24 = this.ws) == null ? void 0 : _a24.close();
16360
+ var _a25;
16361
+ (_a25 = this.ws) == null ? void 0 : _a25.close();
16291
16362
  this.ws = null;
16292
16363
  const wsConfig = this.model.getWebSocketConfig({ token, url });
16293
16364
  const ws = new WebSocket(wsConfig.url, wsConfig.protocols);
@@ -16310,8 +16381,8 @@ var BrowserRealtimeTransport = class {
16310
16381
  };
16311
16382
  }
16312
16383
  disconnect() {
16313
- var _a24;
16314
- (_a24 = this.ws) == null ? void 0 : _a24.close();
16384
+ var _a25;
16385
+ (_a25 = this.ws) == null ? void 0 : _a25.close();
16315
16386
  this.ws = null;
16316
16387
  }
16317
16388
  sendEvent(event) {
@@ -16327,8 +16398,8 @@ var BrowserRealtimeTransport = class {
16327
16398
  });
16328
16399
  }
16329
16400
  sendRaw(data) {
16330
- var _a24;
16331
- if (((_a24 = this.ws) == null ? void 0 : _a24.readyState) === WebSocket.OPEN) {
16401
+ var _a25;
16402
+ if (((_a25 = this.ws) == null ? void 0 : _a25.readyState) === WebSocket.OPEN) {
16332
16403
  if (typeof data === "string" || data instanceof ArrayBuffer || ArrayBuffer.isView(data) || data instanceof Blob) {
16333
16404
  this.ws.send(data);
16334
16405
  } else {
@@ -16420,7 +16491,7 @@ var RealtimeEventReducer = class {
16420
16491
  };
16421
16492
  }
16422
16493
  async reduceServerEvent(state, event) {
16423
- var _a24;
16494
+ var _a25;
16424
16495
  let nextState = this.pushEvent(state, event);
16425
16496
  const effects = [];
16426
16497
  switch (event.type) {
@@ -16487,7 +16558,7 @@ var RealtimeEventReducer = class {
16487
16558
  const { state: updatedState, messageId } = this.getOrCreateAssistantMessage(nextState);
16488
16559
  nextState = updatedState;
16489
16560
  this.toolCallIdToMessageId.set(event.callId, messageId);
16490
- const acc = (_a24 = this.toolArgAccumulators.get(event.callId)) != null ? _a24 : "";
16561
+ const acc = (_a25 = this.toolArgAccumulators.get(event.callId)) != null ? _a25 : "";
16491
16562
  this.toolArgAccumulators.set(event.callId, acc + event.delta);
16492
16563
  nextState = this.ensureToolPart(nextState, messageId, event.callId);
16493
16564
  break;
@@ -16561,7 +16632,7 @@ var RealtimeEventReducer = class {
16561
16632
  };
16562
16633
  }
16563
16634
  addInputTranscriptionMessage(state, itemId, transcript) {
16564
- var _a24;
16635
+ var _a25;
16565
16636
  const messageId = `user-${itemId}`;
16566
16637
  const existingMessage = state.messages.find(
16567
16638
  (message) => message.id === messageId
@@ -16584,7 +16655,7 @@ var RealtimeEventReducer = class {
16584
16655
  };
16585
16656
  }
16586
16657
  const insertIndex = Math.min(
16587
- (_a24 = this.inputAudioMessageInsertIndex.get(itemId)) != null ? _a24 : state.messages.length,
16658
+ (_a25 = this.inputAudioMessageInsertIndex.get(itemId)) != null ? _a25 : state.messages.length,
16588
16659
  state.messages.length
16589
16660
  );
16590
16661
  const messages = [...state.messages];
@@ -16605,9 +16676,9 @@ var RealtimeEventReducer = class {
16605
16676
  };
16606
16677
  }
16607
16678
  appendTextDelta(state, itemId, delta) {
16608
- var _a24;
16679
+ var _a25;
16609
16680
  const { state: stateWithMessage, messageId } = this.getOrCreateAssistantMessage(state);
16610
- const acc = (_a24 = this.textAccumulators.get(itemId)) != null ? _a24 : "";
16681
+ const acc = (_a25 = this.textAccumulators.get(itemId)) != null ? _a25 : "";
16611
16682
  const text2 = acc + delta;
16612
16683
  this.textAccumulators.set(itemId, text2);
16613
16684
  const location = this.itemIdToPartLocation.get(itemId);
@@ -16636,8 +16707,8 @@ var RealtimeEventReducer = class {
16636
16707
  };
16637
16708
  }
16638
16709
  finalizeText(state, itemId, finalText) {
16639
- var _a24;
16640
- const text2 = (_a24 = finalText != null ? finalText : this.textAccumulators.get(itemId)) != null ? _a24 : "";
16710
+ var _a25;
16711
+ const text2 = (_a25 = finalText != null ? finalText : this.textAccumulators.get(itemId)) != null ? _a25 : "";
16641
16712
  this.textAccumulators.delete(itemId);
16642
16713
  const location = this.itemIdToPartLocation.get(itemId);
16643
16714
  if (location == null) return state;
@@ -16674,7 +16745,7 @@ var RealtimeEventReducer = class {
16674
16745
  })
16675
16746
  };
16676
16747
  }
16677
- markToolInputAvailable(state, messageId, callId, name24, input) {
16748
+ markToolInputAvailable(state, messageId, callId, name25, input) {
16678
16749
  return {
16679
16750
  ...state,
16680
16751
  messages: state.messages.map((message) => {
@@ -16687,7 +16758,7 @@ var RealtimeEventReducer = class {
16687
16758
  if (toolPart.toolCallId !== callId) return part;
16688
16759
  return {
16689
16760
  ...toolPart,
16690
- toolName: name24,
16761
+ toolName: name25,
16691
16762
  state: "input-available",
16692
16763
  input
16693
16764
  };
@@ -16744,25 +16815,25 @@ var AbstractRealtimeSession = class {
16744
16815
  this.toolCallsInResponse = /* @__PURE__ */ new Set();
16745
16816
  this.submittedToolOutputs = /* @__PURE__ */ new Set();
16746
16817
  this.responseToolCallsClosed = false;
16747
- var _a24, _b24, _c, _d, _e, _f, _g, _h;
16818
+ var _a25, _b25, _c, _d, _e, _f, _g, _h;
16748
16819
  this.model = options.model;
16749
16820
  this.api = options.api;
16750
16821
  this.sessionConfig = options.sessionConfig;
16751
- this.maxEvents = (_a24 = options.maxEvents) != null ? _a24 : 500;
16822
+ this.maxEvents = (_a25 = options.maxEvents) != null ? _a25 : 500;
16752
16823
  this.reducer = new RealtimeEventReducer(this.maxEvents);
16753
16824
  this.onToolCall = options.onToolCall;
16754
16825
  this.onEvent = options.onEvent;
16755
16826
  this.onError = options.onError;
16756
- const sampleRate = (_b24 = options.sampleRate) != null ? _b24 : 24e3;
16827
+ const sampleRate = (_b25 = options.sampleRate) != null ? _b25 : 24e3;
16757
16828
  const captureSampleRate = (_e = (_d = (_c = options.sessionConfig) == null ? void 0 : _c.inputAudioFormat) == null ? void 0 : _d.rate) != null ? _e : sampleRate;
16758
16829
  const playbackSampleRate = (_h = (_g = (_f = options.sessionConfig) == null ? void 0 : _f.outputAudioFormat) == null ? void 0 : _g.rate) != null ? _h : sampleRate;
16759
16830
  this.transport = new BrowserRealtimeTransport({
16760
16831
  model: this.model,
16761
16832
  onServerEvent: (event) => this.handleServerEvent(event),
16762
16833
  onError: (error) => {
16763
- var _a25;
16834
+ var _a26;
16764
16835
  this.applyState(this.reducer.setStatus(this.state, "error"));
16765
- (_a25 = this.onError) == null ? void 0 : _a25.call(this, error);
16836
+ (_a26 = this.onError) == null ? void 0 : _a26.call(this, error);
16766
16837
  },
16767
16838
  onClose: () => {
16768
16839
  this.applyState(this.reducer.setStatus(this.state, "disconnected"));
@@ -16782,7 +16853,7 @@ var AbstractRealtimeSession = class {
16782
16853
  }
16783
16854
  // ── Connection ─────────────────────────────────────────────────────
16784
16855
  async connect() {
16785
- var _a24;
16856
+ var _a25;
16786
16857
  this.applyState(this.reducer.setStatus(this.state, "connecting"));
16787
16858
  try {
16788
16859
  const response = await fetch(this.api.token, {
@@ -16812,7 +16883,7 @@ var AbstractRealtimeSession = class {
16812
16883
  });
16813
16884
  } catch (error) {
16814
16885
  this.applyState(this.reducer.setStatus(this.state, "error"));
16815
- (_a24 = this.onError) == null ? void 0 : _a24.call(
16886
+ (_a25 = this.onError) == null ? void 0 : _a25.call(
16816
16887
  this,
16817
16888
  error instanceof Error ? error : new Error(`Connection failed: ${String(error)}`)
16818
16889
  );
@@ -16935,34 +17006,34 @@ var AbstractRealtimeSession = class {
16935
17006
  }
16936
17007
  }
16937
17008
  async executeToolCall({
16938
- name: name24,
17009
+ name: name25,
16939
17010
  args,
16940
17011
  callId
16941
17012
  }) {
16942
- var _a24, _b24;
17013
+ var _a25, _b25;
16943
17014
  if (this.onToolCall == null) {
16944
- (_a24 = this.onError) == null ? void 0 : _a24.call(this, new Error(`No handler provided for tool "${name24}"`));
17015
+ (_a25 = this.onError) == null ? void 0 : _a25.call(this, new Error(`No handler provided for tool "${name25}"`));
16945
17016
  return;
16946
17017
  }
16947
17018
  try {
16948
17019
  const result = await this.onToolCall({
16949
- toolCall: { toolCallId: callId, toolName: name24, args }
17020
+ toolCall: { toolCallId: callId, toolName: name25, args }
16950
17021
  });
16951
17022
  if (result !== void 0) {
16952
17023
  this.addToolOutput(callId, result);
16953
17024
  }
16954
17025
  } catch (error) {
16955
- (_b24 = this.onError) == null ? void 0 : _b24.call(
17026
+ (_b25 = this.onError) == null ? void 0 : _b25.call(
16956
17027
  this,
16957
17028
  error instanceof Error ? error : new Error(`Client tool execution failed: ${String(error)}`)
16958
17029
  );
16959
17030
  }
16960
17031
  }
16961
17032
  async handleServerEvent(event) {
16962
- var _a24;
17033
+ var _a25;
16963
17034
  const result = await this.reducer.reduceServerEvent(this.state, event);
16964
17035
  this.applyState(result.state);
16965
- (_a24 = this.onEvent) == null ? void 0 : _a24.call(this, event);
17036
+ (_a25 = this.onEvent) == null ? void 0 : _a25.call(this, event);
16966
17037
  for (const effect of result.effects) {
16967
17038
  this.handleReducerEffect(effect);
16968
17039
  }
@@ -16972,7 +17043,7 @@ var AbstractRealtimeSession = class {
16972
17043
  }
16973
17044
  }
16974
17045
  handleReducerEffect(effect) {
16975
- var _a24;
17046
+ var _a25;
16976
17047
  switch (effect.type) {
16977
17048
  case "play-audio": {
16978
17049
  this.currentResponseItemId = effect.itemId;
@@ -17004,7 +17075,7 @@ var AbstractRealtimeSession = class {
17004
17075
  break;
17005
17076
  }
17006
17077
  case "error": {
17007
- (_a24 = this.onError) == null ? void 0 : _a24.call(this, effect.error);
17078
+ (_a25 = this.onError) == null ? void 0 : _a25.call(this, effect.error);
17008
17079
  break;
17009
17080
  }
17010
17081
  }
@@ -17117,12 +17188,12 @@ function customProvider({
17117
17188
  }
17118
17189
 
17119
17190
  // src/registry/no-such-provider-error.ts
17120
- import { AISDKError as AISDKError27, NoSuchModelError as NoSuchModelError3 } from "@ai-sdk/provider";
17121
- var name23 = "AI_NoSuchProviderError";
17122
- var marker23 = `vercel.ai.error.${name23}`;
17123
- var symbol23 = Symbol.for(marker23);
17124
- var _a23, _b23;
17125
- var NoSuchProviderError = class extends (_b23 = NoSuchModelError3, _a23 = symbol23, _b23) {
17191
+ import { AISDKError as AISDKError28, NoSuchModelError as NoSuchModelError3 } from "@ai-sdk/provider";
17192
+ var name24 = "AI_NoSuchProviderError";
17193
+ var marker24 = `vercel.ai.error.${name24}`;
17194
+ var symbol24 = Symbol.for(marker24);
17195
+ var _a24, _b24;
17196
+ var NoSuchProviderError = class extends (_b24 = NoSuchModelError3, _a24 = symbol24, _b24) {
17126
17197
  constructor({
17127
17198
  modelId,
17128
17199
  modelType,
@@ -17130,13 +17201,13 @@ var NoSuchProviderError = class extends (_b23 = NoSuchModelError3, _a23 = symbol
17130
17201
  availableProviders,
17131
17202
  message = `No such provider: ${providerId} (available providers: ${availableProviders.join()})`
17132
17203
  }) {
17133
- super({ errorName: name23, modelId, modelType, message });
17134
- this[_a23] = true;
17204
+ super({ errorName: name24, modelId, modelType, message });
17205
+ this[_a24] = true;
17135
17206
  this.providerId = providerId;
17136
17207
  this.availableProviders = availableProviders;
17137
17208
  }
17138
17209
  static isInstance(error) {
17139
- return AISDKError27.hasMarker(error, marker23);
17210
+ return AISDKError28.hasMarker(error, marker24);
17140
17211
  }
17141
17212
  };
17142
17213
 
@@ -17175,9 +17246,9 @@ var DefaultProviderRegistry = class {
17175
17246
  id,
17176
17247
  provider
17177
17248
  }) {
17178
- var _a24;
17249
+ var _a25;
17179
17250
  const providerV4 = asProviderV4(provider);
17180
- const videoModel = (_a24 = provider.videoModel) == null ? void 0 : _a24.bind(provider);
17251
+ const videoModel = (_a25 = provider.videoModel) == null ? void 0 : _a25.bind(provider);
17181
17252
  this.providers[id] = videoModel == null ? providerV4 : Object.assign(Object.create(Object.getPrototypeOf(providerV4)), {
17182
17253
  ...providerV4,
17183
17254
  videoModel: (modelId) => asVideoModelV4(videoModel(modelId))
@@ -17207,10 +17278,10 @@ var DefaultProviderRegistry = class {
17207
17278
  return [id.slice(0, index), id.slice(index + this.separator.length)];
17208
17279
  }
17209
17280
  languageModel(id) {
17210
- var _a24, _b24;
17281
+ var _a25, _b25;
17211
17282
  const [providerId, modelId] = this.splitId(id, "languageModel");
17212
- let model = (_b24 = (_a24 = this.getProvider(providerId, "languageModel")).languageModel) == null ? void 0 : _b24.call(
17213
- _a24,
17283
+ let model = (_b25 = (_a25 = this.getProvider(providerId, "languageModel")).languageModel) == null ? void 0 : _b25.call(
17284
+ _a25,
17214
17285
  modelId
17215
17286
  );
17216
17287
  if (model == null) {
@@ -17225,10 +17296,10 @@ var DefaultProviderRegistry = class {
17225
17296
  return model;
17226
17297
  }
17227
17298
  embeddingModel(id) {
17228
- var _a24;
17299
+ var _a25;
17229
17300
  const [providerId, modelId] = this.splitId(id, "embeddingModel");
17230
17301
  const provider = this.getProvider(providerId, "embeddingModel");
17231
- const model = (_a24 = provider.embeddingModel) == null ? void 0 : _a24.call(provider, modelId);
17302
+ const model = (_a25 = provider.embeddingModel) == null ? void 0 : _a25.call(provider, modelId);
17232
17303
  if (model == null) {
17233
17304
  throw new NoSuchModelError4({
17234
17305
  modelId: id,
@@ -17238,10 +17309,10 @@ var DefaultProviderRegistry = class {
17238
17309
  return model;
17239
17310
  }
17240
17311
  imageModel(id) {
17241
- var _a24;
17312
+ var _a25;
17242
17313
  const [providerId, modelId] = this.splitId(id, "imageModel");
17243
17314
  const provider = this.getProvider(providerId, "imageModel");
17244
- let model = (_a24 = provider.imageModel) == null ? void 0 : _a24.call(provider, modelId);
17315
+ let model = (_a25 = provider.imageModel) == null ? void 0 : _a25.call(provider, modelId);
17245
17316
  if (model == null) {
17246
17317
  throw new NoSuchModelError4({ modelId: id, modelType: "imageModel" });
17247
17318
  }
@@ -17254,10 +17325,10 @@ var DefaultProviderRegistry = class {
17254
17325
  return model;
17255
17326
  }
17256
17327
  transcriptionModel(id) {
17257
- var _a24;
17328
+ var _a25;
17258
17329
  const [providerId, modelId] = this.splitId(id, "transcriptionModel");
17259
17330
  const provider = this.getProvider(providerId, "transcriptionModel");
17260
- const model = (_a24 = provider.transcriptionModel) == null ? void 0 : _a24.call(provider, modelId);
17331
+ const model = (_a25 = provider.transcriptionModel) == null ? void 0 : _a25.call(provider, modelId);
17261
17332
  if (model == null) {
17262
17333
  throw new NoSuchModelError4({
17263
17334
  modelId: id,
@@ -17267,39 +17338,39 @@ var DefaultProviderRegistry = class {
17267
17338
  return model;
17268
17339
  }
17269
17340
  speechModel(id) {
17270
- var _a24;
17341
+ var _a25;
17271
17342
  const [providerId, modelId] = this.splitId(id, "speechModel");
17272
17343
  const provider = this.getProvider(providerId, "speechModel");
17273
- const model = (_a24 = provider.speechModel) == null ? void 0 : _a24.call(provider, modelId);
17344
+ const model = (_a25 = provider.speechModel) == null ? void 0 : _a25.call(provider, modelId);
17274
17345
  if (model == null) {
17275
17346
  throw new NoSuchModelError4({ modelId: id, modelType: "speechModel" });
17276
17347
  }
17277
17348
  return model;
17278
17349
  }
17279
17350
  rerankingModel(id) {
17280
- var _a24;
17351
+ var _a25;
17281
17352
  const [providerId, modelId] = this.splitId(id, "rerankingModel");
17282
17353
  const provider = this.getProvider(providerId, "rerankingModel");
17283
- const model = (_a24 = provider.rerankingModel) == null ? void 0 : _a24.call(provider, modelId);
17354
+ const model = (_a25 = provider.rerankingModel) == null ? void 0 : _a25.call(provider, modelId);
17284
17355
  if (model == null) {
17285
17356
  throw new NoSuchModelError4({ modelId: id, modelType: "rerankingModel" });
17286
17357
  }
17287
17358
  return model;
17288
17359
  }
17289
17360
  videoModel(id) {
17290
- var _a24;
17361
+ var _a25;
17291
17362
  const [providerId, modelId] = this.splitId(id, "videoModel");
17292
17363
  const provider = this.getProvider(providerId, "videoModel");
17293
- const model = (_a24 = provider.videoModel) == null ? void 0 : _a24.call(provider, modelId);
17364
+ const model = (_a25 = provider.videoModel) == null ? void 0 : _a25.call(provider, modelId);
17294
17365
  if (model == null) {
17295
17366
  throw new NoSuchModelError4({ modelId: id, modelType: "videoModel" });
17296
17367
  }
17297
17368
  return asVideoModelV4(model);
17298
17369
  }
17299
17370
  files(id) {
17300
- var _a24;
17371
+ var _a25;
17301
17372
  const provider = this.getProvider(id, "languageModel");
17302
- const files = (_a24 = provider.files) == null ? void 0 : _a24.call(provider);
17373
+ const files = (_a25 = provider.files) == null ? void 0 : _a25.call(provider);
17303
17374
  if (files == null) {
17304
17375
  throw new Error(
17305
17376
  `The provider "${id}" does not support file uploads. Make sure it exposes a files() method.`
@@ -17308,9 +17379,9 @@ var DefaultProviderRegistry = class {
17308
17379
  return files;
17309
17380
  }
17310
17381
  skills(id) {
17311
- var _a24;
17382
+ var _a25;
17312
17383
  const provider = this.getProvider(id, "languageModel");
17313
- const skills = (_a24 = provider.skills) == null ? void 0 : _a24.call(provider);
17384
+ const skills = (_a25 = provider.skills) == null ? void 0 : _a25.call(provider);
17314
17385
  if (skills == null) {
17315
17386
  throw new Error(
17316
17387
  `The provider "${id}" does not support skills. Make sure it exposes a skills() method.`
@@ -17345,7 +17416,7 @@ async function rerank({
17345
17416
  experimental_onEnd,
17346
17417
  _internal: { generateCallId = originalGenerateCallId6 } = {}
17347
17418
  }) {
17348
- var _a24;
17419
+ var _a25;
17349
17420
  const model = resolveRerankingModel(modelArg);
17350
17421
  const callId = generateCallId();
17351
17422
  const resolvedOnStart = onStart != null ? onStart : experimental_onStart;
@@ -17353,7 +17424,7 @@ async function rerank({
17353
17424
  const telemetryDispatcher = createTelemetryDispatcher({
17354
17425
  telemetry
17355
17426
  });
17356
- const runInTracingChannelSpan = (_a24 = telemetryDispatcher.runInTracingChannelSpan) != null ? _a24 : (async ({ execute }) => await execute());
17427
+ const runInTracingChannelSpan = (_a25 = telemetryDispatcher.runInTracingChannelSpan) != null ? _a25 : (async ({ execute }) => await execute());
17357
17428
  if (documents.length === 0) {
17358
17429
  await notify({
17359
17430
  event: {
@@ -17419,7 +17490,7 @@ async function rerank({
17419
17490
  type: "rerank",
17420
17491
  event: startEvent,
17421
17492
  execute: async () => {
17422
- var _a25, _b24, _c, _d, _e;
17493
+ var _a26, _b25, _c, _d, _e;
17423
17494
  await notify({
17424
17495
  event: startEvent,
17425
17496
  callbacks: [resolvedOnStart, telemetryDispatcher.onStart]
@@ -17490,8 +17561,8 @@ async function rerank({
17490
17561
  providerMetadata,
17491
17562
  response: {
17492
17563
  id: response == null ? void 0 : response.id,
17493
- timestamp: (_a25 = response == null ? void 0 : response.timestamp) != null ? _a25 : /* @__PURE__ */ new Date(),
17494
- modelId: (_b24 = response == null ? void 0 : response.modelId) != null ? _b24 : model.modelId,
17564
+ timestamp: (_a26 = response == null ? void 0 : response.timestamp) != null ? _a26 : /* @__PURE__ */ new Date(),
17565
+ modelId: (_b25 = response == null ? void 0 : response.modelId) != null ? _b25 : model.modelId,
17495
17566
  headers: response == null ? void 0 : response.headers,
17496
17567
  body: response == null ? void 0 : response.body
17497
17568
  }
@@ -17563,16 +17634,16 @@ async function transcribe({
17563
17634
  const audioData = audio instanceof URL ? (await downloadFn({ url: audio, abortSignal })).data : convertDataContentToUint8Array(audio);
17564
17635
  const result = await retry(
17565
17636
  () => {
17566
- var _a24;
17637
+ var _a25;
17567
17638
  return resolvedModel.doGenerate({
17568
17639
  audio: audioData,
17569
17640
  abortSignal,
17570
17641
  headers: headersWithUserAgent,
17571
17642
  providerOptions,
17572
- mediaType: (_a24 = detectMediaType5({
17643
+ mediaType: (_a25 = detectMediaType5({
17573
17644
  data: audioData,
17574
17645
  topLevelType: "audio"
17575
- })) != null ? _a24 : "audio/wav"
17646
+ })) != null ? _a25 : "audio/wav"
17576
17647
  });
17577
17648
  }
17578
17649
  );
@@ -17596,14 +17667,14 @@ async function transcribe({
17596
17667
  }
17597
17668
  var DefaultTranscriptionResult = class {
17598
17669
  constructor(options) {
17599
- var _a24;
17670
+ var _a25;
17600
17671
  this.text = options.text;
17601
17672
  this.segments = options.segments;
17602
17673
  this.language = options.language;
17603
17674
  this.durationInSeconds = options.durationInSeconds;
17604
17675
  this.warnings = options.warnings;
17605
17676
  this.responses = options.responses;
17606
- this.providerMetadata = (_a24 = options.providerMetadata) != null ? _a24 : {};
17677
+ this.providerMetadata = (_a25 = options.providerMetadata) != null ? _a25 : {};
17607
17678
  }
17608
17679
  };
17609
17680
 
@@ -17625,12 +17696,12 @@ function streamTranscribe({
17625
17696
  includeRawChunks,
17626
17697
  _internal: { currentDate = () => /* @__PURE__ */ new Date() } = {}
17627
17698
  }) {
17628
- var _a24;
17699
+ var _a25;
17629
17700
  const resolvedModel = resolveTranscriptionModel(model);
17630
17701
  if (!resolvedModel) {
17631
17702
  throw new Error("Model could not be resolved");
17632
17703
  }
17633
- const doStream = (_a24 = resolvedModel.doStream) == null ? void 0 : _a24.bind(resolvedModel);
17704
+ const doStream = (_a25 = resolvedModel.doStream) == null ? void 0 : _a25.bind(resolvedModel);
17634
17705
  if (doStream == null) {
17635
17706
  throw new UnsupportedFunctionalityError5({
17636
17707
  functionality: "streaming transcription",
@@ -17677,7 +17748,7 @@ function streamTranscribe({
17677
17748
  const pipeAbortController = new AbortController();
17678
17749
  const transformer = {
17679
17750
  transform(value, controller) {
17680
- var _a25, _b24, _c, _d;
17751
+ var _a26, _b25, _c, _d;
17681
17752
  switch (value.type) {
17682
17753
  case "stream-start": {
17683
17754
  resolveWarnings(value.warnings);
@@ -17685,8 +17756,8 @@ function streamTranscribe({
17685
17756
  }
17686
17757
  case "response-metadata": {
17687
17758
  response = {
17688
- timestamp: (_a25 = value.timestamp) != null ? _a25 : currentResponseMetadata().timestamp,
17689
- modelId: (_b24 = value.modelId) != null ? _b24 : currentResponseMetadata().modelId,
17759
+ timestamp: (_a26 = value.timestamp) != null ? _a26 : currentResponseMetadata().timestamp,
17760
+ modelId: (_b25 = value.modelId) != null ? _b25 : currentResponseMetadata().modelId,
17690
17761
  headers: (_c = value.headers) != null ? _c : response == null ? void 0 : response.headers
17691
17762
  };
17692
17763
  break;
@@ -17733,7 +17804,7 @@ function streamTranscribe({
17733
17804
  };
17734
17805
  const transform = new TransformStream(transformer);
17735
17806
  void (async () => {
17736
- var _a25, _b24, _c, _d, _e;
17807
+ var _a26, _b25, _c, _d, _e;
17737
17808
  const result = await doStream({
17738
17809
  audio,
17739
17810
  inputAudioFormat,
@@ -17744,7 +17815,7 @@ function streamTranscribe({
17744
17815
  includeRawChunks
17745
17816
  });
17746
17817
  response = {
17747
- timestamp: (_b24 = (_a25 = result.response) == null ? void 0 : _a25.timestamp) != null ? _b24 : startedAt,
17818
+ timestamp: (_b25 = (_a26 = result.response) == null ? void 0 : _a26.timestamp) != null ? _b25 : startedAt,
17748
17819
  modelId: (_d = (_c = result.response) == null ? void 0 : _c.modelId) != null ? _d : resolvedModel.modelId,
17749
17820
  headers: (_e = result.response) == null ? void 0 : _e.headers
17750
17821
  };
@@ -17880,7 +17951,7 @@ function streamTranslate({
17880
17951
  let hasAudioOutput = false;
17881
17952
  const transformer = {
17882
17953
  transform(value, controller) {
17883
- var _a24, _b24, _c, _d;
17954
+ var _a25, _b25, _c, _d;
17884
17955
  switch (value.type) {
17885
17956
  case "stream-start": {
17886
17957
  resolveWarnings(value.warnings);
@@ -17888,8 +17959,8 @@ function streamTranslate({
17888
17959
  }
17889
17960
  case "response-metadata": {
17890
17961
  response = {
17891
- timestamp: (_a24 = value.timestamp) != null ? _a24 : currentResponseMetadata().timestamp,
17892
- modelId: (_b24 = value.modelId) != null ? _b24 : currentResponseMetadata().modelId,
17962
+ timestamp: (_a25 = value.timestamp) != null ? _a25 : currentResponseMetadata().timestamp,
17963
+ modelId: (_b25 = value.modelId) != null ? _b25 : currentResponseMetadata().modelId,
17893
17964
  headers: (_c = value.headers) != null ? _c : response == null ? void 0 : response.headers
17894
17965
  };
17895
17966
  break;
@@ -17947,7 +18018,7 @@ function streamTranslate({
17947
18018
  };
17948
18019
  const transform = new TransformStream(transformer);
17949
18020
  void (async () => {
17950
- var _a24, _b24, _c, _d, _e;
18021
+ var _a25, _b25, _c, _d, _e;
17951
18022
  const result = await doStream({
17952
18023
  audio,
17953
18024
  inputAudioFormat,
@@ -17961,7 +18032,7 @@ function streamTranslate({
17961
18032
  includeRawChunks
17962
18033
  });
17963
18034
  response = {
17964
- timestamp: (_b24 = (_a24 = result.response) == null ? void 0 : _a24.timestamp) != null ? _b24 : startedAt,
18035
+ timestamp: (_b25 = (_a25 = result.response) == null ? void 0 : _a25.timestamp) != null ? _b25 : startedAt,
17965
18036
  modelId: (_d = (_c = result.response) == null ? void 0 : _c.modelId) != null ? _d : resolvedModel.modelId,
17966
18037
  headers: (_e = result.response) == null ? void 0 : _e.headers
17967
18038
  };
@@ -18072,7 +18143,7 @@ async function callCompletionApi({
18072
18143
  onError,
18073
18144
  fetch: fetch2 = getOriginalFetch()
18074
18145
  }) {
18075
- var _a24;
18146
+ var _a25;
18076
18147
  try {
18077
18148
  setLoading(true);
18078
18149
  setError(void 0);
@@ -18100,7 +18171,7 @@ async function callCompletionApi({
18100
18171
  });
18101
18172
  if (!response.ok) {
18102
18173
  throw new Error(
18103
- (_a24 = await response.text()) != null ? _a24 : "Failed to fetch the chat response."
18174
+ (_a25 = await response.text()) != null ? _a25 : "Failed to fetch the chat response."
18104
18175
  );
18105
18176
  }
18106
18177
  if (!response.body) {
@@ -18186,12 +18257,12 @@ async function convertFileListToFileUIParts(files) {
18186
18257
  }
18187
18258
  return Promise.all(
18188
18259
  Array.from(files).map(async (file) => {
18189
- const { name: name24, type } = file;
18260
+ const { name: name25, type } = file;
18190
18261
  const dataUrl = await new Promise((resolve3, reject) => {
18191
18262
  const reader = new FileReader();
18192
18263
  reader.onload = (readerEvent) => {
18193
- var _a24;
18194
- resolve3((_a24 = readerEvent.target) == null ? void 0 : _a24.result);
18264
+ var _a25;
18265
+ resolve3((_a25 = readerEvent.target) == null ? void 0 : _a25.result);
18195
18266
  };
18196
18267
  reader.onerror = (error) => reject(error);
18197
18268
  reader.readAsDataURL(file);
@@ -18199,7 +18270,7 @@ async function convertFileListToFileUIParts(files) {
18199
18270
  return {
18200
18271
  type: "file",
18201
18272
  mediaType: type,
18202
- filename: name24,
18273
+ filename: name25,
18203
18274
  url: dataUrl
18204
18275
  };
18205
18276
  })
@@ -18236,7 +18307,7 @@ var HttpChatTransport = class {
18236
18307
  abortSignal,
18237
18308
  ...options
18238
18309
  }) {
18239
- var _a24, _b24, _c, _d, _e;
18310
+ var _a25, _b25, _c, _d, _e;
18240
18311
  const resolvedBody = await resolve2(this.body);
18241
18312
  const resolvedHeaders = await resolve2(this.headers);
18242
18313
  const resolvedCredentials = await resolve2(this.credentials);
@@ -18244,7 +18315,7 @@ var HttpChatTransport = class {
18244
18315
  ...normalizeHeaders(resolvedHeaders),
18245
18316
  ...normalizeHeaders(options.headers)
18246
18317
  };
18247
- const preparedRequest = await ((_a24 = this.prepareSendMessagesRequest) == null ? void 0 : _a24.call(this, {
18318
+ const preparedRequest = await ((_a25 = this.prepareSendMessagesRequest) == null ? void 0 : _a25.call(this, {
18248
18319
  api: this.api,
18249
18320
  id: options.chatId,
18250
18321
  messages: options.messages,
@@ -18255,7 +18326,7 @@ var HttpChatTransport = class {
18255
18326
  trigger: options.trigger,
18256
18327
  messageId: options.messageId
18257
18328
  }));
18258
- const api = (_b24 = preparedRequest == null ? void 0 : preparedRequest.api) != null ? _b24 : this.api;
18329
+ const api = (_b25 = preparedRequest == null ? void 0 : preparedRequest.api) != null ? _b25 : this.api;
18259
18330
  const headers = (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? normalizeHeaders(preparedRequest.headers) : baseHeaders;
18260
18331
  const body = (preparedRequest == null ? void 0 : preparedRequest.body) !== void 0 ? preparedRequest.body : {
18261
18332
  ...resolvedBody,
@@ -18288,7 +18359,7 @@ var HttpChatTransport = class {
18288
18359
  return this.processResponseStream(response.body);
18289
18360
  }
18290
18361
  async reconnectToStream(options) {
18291
- var _a24, _b24, _c, _d, _e;
18362
+ var _a25, _b25, _c, _d, _e;
18292
18363
  const resolvedBody = await resolve2(this.body);
18293
18364
  const resolvedHeaders = await resolve2(this.headers);
18294
18365
  const resolvedCredentials = await resolve2(this.credentials);
@@ -18296,7 +18367,7 @@ var HttpChatTransport = class {
18296
18367
  ...normalizeHeaders(resolvedHeaders),
18297
18368
  ...normalizeHeaders(options.headers)
18298
18369
  };
18299
- const preparedRequest = await ((_a24 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a24.call(this, {
18370
+ const preparedRequest = await ((_a25 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a25.call(this, {
18300
18371
  api: this.api,
18301
18372
  id: options.chatId,
18302
18373
  body: { ...resolvedBody, ...options.body },
@@ -18304,7 +18375,7 @@ var HttpChatTransport = class {
18304
18375
  credentials: resolvedCredentials,
18305
18376
  requestMetadata: options.metadata
18306
18377
  }));
18307
- const api = (_b24 = preparedRequest == null ? void 0 : preparedRequest.api) != null ? _b24 : `${this.api}/${options.chatId}/stream`;
18378
+ const api = (_b25 = preparedRequest == null ? void 0 : preparedRequest.api) != null ? _b25 : `${this.api}/${options.chatId}/stream`;
18308
18379
  const headers = (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? normalizeHeaders(preparedRequest.headers) : baseHeaders;
18309
18380
  const credentials = (_c = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _c : resolvedCredentials;
18310
18381
  const fetch2 = (_d = this.fetch) != null ? _d : globalThis.fetch;
@@ -18377,11 +18448,11 @@ var AbstractChat = class {
18377
18448
  * If a messageId is provided, the message will be replaced.
18378
18449
  */
18379
18450
  this.sendMessage = async (message, options) => {
18380
- var _a24, _b24, _c, _d;
18451
+ var _a25, _b25, _c, _d;
18381
18452
  if (message == null) {
18382
18453
  await this.makeRequest({
18383
18454
  trigger: "submit-message",
18384
- messageId: (_a24 = this.lastMessage) == null ? void 0 : _a24.id,
18455
+ messageId: (_a25 = this.lastMessage) == null ? void 0 : _a25.id,
18385
18456
  ...options
18386
18457
  });
18387
18458
  return;
@@ -18424,7 +18495,7 @@ var AbstractChat = class {
18424
18495
  this.state.replaceMessage(messageIndex, {
18425
18496
  ...uiMessage,
18426
18497
  id: message.messageId,
18427
- role: (_b24 = uiMessage.role) != null ? _b24 : "user",
18498
+ role: (_b25 = uiMessage.role) != null ? _b25 : "user",
18428
18499
  metadata: message.metadata
18429
18500
  });
18430
18501
  } else {
@@ -18501,11 +18572,11 @@ var AbstractChat = class {
18501
18572
  }
18502
18573
  if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
18503
18574
  this.shouldSendAutomatically().then((shouldSend) => {
18504
- var _a24;
18575
+ var _a25;
18505
18576
  if (shouldSend) {
18506
18577
  this.makeRequest({
18507
18578
  trigger: "submit-message",
18508
- messageId: (_a24 = this.lastMessage) == null ? void 0 : _a24.id,
18579
+ messageId: (_a25 = this.lastMessage) == null ? void 0 : _a25.id,
18509
18580
  ...options
18510
18581
  });
18511
18582
  }
@@ -18531,11 +18602,11 @@ var AbstractChat = class {
18531
18602
  }
18532
18603
  if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
18533
18604
  this.shouldSendAutomatically().then((shouldSend) => {
18534
- var _a24;
18605
+ var _a25;
18535
18606
  if (shouldSend) {
18536
18607
  this.makeRequest({
18537
18608
  trigger: "submit-message",
18538
- messageId: (_a24 = this.lastMessage) == null ? void 0 : _a24.id,
18609
+ messageId: (_a25 = this.lastMessage) == null ? void 0 : _a25.id,
18539
18610
  ...options
18540
18611
  });
18541
18612
  }
@@ -18548,12 +18619,12 @@ var AbstractChat = class {
18548
18619
  * Abort the current request immediately, keep the generated tokens if any.
18549
18620
  */
18550
18621
  this.stop = async () => {
18551
- var _a24, _b24;
18622
+ var _a25, _b25;
18552
18623
  for (const controller of this.pendingMessagePreparations) {
18553
18624
  controller.abort();
18554
18625
  }
18555
- (_a24 = this.activeResumeRequest) == null ? void 0 : _a24.abortController.abort();
18556
- (_b24 = this.activeResponse) == null ? void 0 : _b24.abortController.abort();
18626
+ (_a25 = this.activeResumeRequest) == null ? void 0 : _a25.abortController.abort();
18627
+ (_b25 = this.activeResponse) == null ? void 0 : _b25.abortController.abort();
18557
18628
  };
18558
18629
  this.id = id;
18559
18630
  this.transport = transport;
@@ -18615,11 +18686,11 @@ var AbstractChat = class {
18615
18686
  body,
18616
18687
  messageId
18617
18688
  }) {
18618
- var _a24, _b24, _c;
18689
+ var _a25, _b25, _c;
18619
18690
  const abortController = new AbortController();
18620
18691
  const activeResumeRequest = trigger === "resume-stream" ? { abortController } : void 0;
18621
18692
  if (activeResumeRequest) {
18622
- (_a24 = this.activeResumeRequest) == null ? void 0 : _a24.abortController.abort();
18693
+ (_a25 = this.activeResumeRequest) == null ? void 0 : _a25.abortController.abort();
18623
18694
  this.activeResumeRequest = activeResumeRequest;
18624
18695
  }
18625
18696
  const isCurrentRequest = () => activeResumeRequest == null || this.activeResumeRequest === activeResumeRequest;
@@ -18715,14 +18786,14 @@ var AbstractChat = class {
18715
18786
  return job({
18716
18787
  state: response.state,
18717
18788
  write: ({ updateStatus = true } = {}) => {
18718
- var _a25;
18789
+ var _a26;
18719
18790
  if (response.abortController.signal.aborted) {
18720
18791
  return;
18721
18792
  }
18722
18793
  if (updateStatus) {
18723
18794
  this.setStatus({ status: "streaming" });
18724
18795
  }
18725
- const replaceLastMessage = response.state.message.id === ((_a25 = this.lastMessage) == null ? void 0 : _a25.id);
18796
+ const replaceLastMessage = response.state.message.id === ((_a26 = this.lastMessage) == null ? void 0 : _a26.id);
18726
18797
  if (replaceLastMessage) {
18727
18798
  this.state.replaceMessage(
18728
18799
  this.state.messages.length - 1,
@@ -18783,7 +18854,7 @@ var AbstractChat = class {
18783
18854
  } finally {
18784
18855
  try {
18785
18856
  if (activeResponse) {
18786
- (_b24 = this.onFinish) == null ? void 0 : _b24.call(this, {
18857
+ (_b25 = this.onFinish) == null ? void 0 : _b25.call(this, {
18787
18858
  message: activeResponse.state.message,
18788
18859
  messages: this.state.messages,
18789
18860
  isAbort,
@@ -18948,9 +19019,9 @@ async function uploadFile({
18948
19019
  filename,
18949
19020
  providerOptions
18950
19021
  }) {
18951
- var _a24;
19022
+ var _a25;
18952
19023
  const data = dataArg instanceof Uint8Array || typeof dataArg === "string" ? { type: "data", data: dataArg } : dataArg;
18953
- const mediaType = mediaTypeArg != null ? mediaTypeArg : data.type === "text" ? "text/plain" : (_a24 = detectMediaType6({ data: data.data })) != null ? _a24 : isLikelyText(data.data) ? "text/plain" : "application/octet-stream";
19024
+ const mediaType = mediaTypeArg != null ? mediaTypeArg : data.type === "text" ? "text/plain" : (_a25 = detectMediaType6({ data: data.data })) != null ? _a25 : isLikelyText(data.data) ? "text/plain" : "application/octet-stream";
18954
19025
  const filesApi = "uploadFile" in api ? api : typeof api.files === "function" ? api.files() : (() => {
18955
19026
  throw new Error(
18956
19027
  "The provider does not support file uploads. Make sure it exposes a files() method."
@@ -19020,7 +19091,7 @@ async function uploadSkill({
19020
19091
  return result;
19021
19092
  }
19022
19093
  export {
19023
- AISDKError24 as AISDKError,
19094
+ AISDKError25 as AISDKError,
19024
19095
  AI_SDK_TELEMETRY_TRACING_CHANNEL,
19025
19096
  APICallError,
19026
19097
  AbstractChat,
@@ -19067,6 +19138,7 @@ export {
19067
19138
  TooManyEmbeddingValuesForCallError,
19068
19139
  ToolCallNotFoundForApprovalError,
19069
19140
  ToolCallRepairError,
19141
+ ToolChoiceViolationError,
19070
19142
  ToolLoopAgent,
19071
19143
  TypeValidationError,
19072
19144
  UIMessageStreamError,