ai 7.0.37 → 7.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.d.ts +263 -40
  3. package/dist/index.js +684 -423
  4. package/dist/index.js.map +1 -1
  5. package/dist/internal/index.js +1 -1
  6. package/dist/internal/index.js.map +1 -1
  7. package/dist/test/index.d.ts +14 -2
  8. package/dist/test/index.js +15 -0
  9. package/dist/test/index.js.map +1 -1
  10. package/docs/03-ai-sdk-core/36-transcription.mdx +40 -35
  11. package/docs/03-ai-sdk-core/36-translation.mdx +196 -0
  12. package/docs/03-ai-sdk-core/index.mdx +5 -0
  13. package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +1 -1
  14. package/docs/07-reference/01-ai-sdk-core/11-stream-translate.mdx +176 -0
  15. package/docs/07-reference/01-ai-sdk-core/index.mdx +5 -0
  16. package/docs/07-reference/05-ai-sdk-errors/ai-no-translation-generated-error.mdx +26 -0
  17. package/docs/07-reference/05-ai-sdk-errors/index.mdx +1 -0
  18. package/package.json +4 -4
  19. package/src/error/index.ts +1 -0
  20. package/src/error/no-translation-generated-error.ts +28 -0
  21. package/src/generate-text/generate-text.ts +4 -1
  22. package/src/generate-text/stream-language-model-call.ts +14 -12
  23. package/src/generate-text/stream-text-result.ts +3 -2
  24. package/src/index.ts +1 -0
  25. package/src/model/resolve-model.ts +35 -0
  26. package/src/test/mock-speech-translation-model-v4.ts +24 -0
  27. package/src/transcribe/stream-transcribe.ts +2 -11
  28. package/src/translate/index.ts +5 -0
  29. package/src/translate/stream-translate-result.ts +146 -0
  30. package/src/translate/stream-translate.ts +374 -0
  31. package/src/types/speech-translation-model-response-metadata.ts +22 -0
  32. package/src/types/speech-translation-model.ts +11 -0
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __export = (target, all) => {
3
- for (var name22 in all)
4
- __defProp(target, name22, { get: all[name22], enumerable: true });
3
+ for (var name23 in all)
4
+ __defProp(target, name23, { get: all[name23], enumerable: true });
5
5
  };
6
6
 
7
7
  // src/index.ts
@@ -33,7 +33,7 @@ import {
33
33
 
34
34
  // src/error/index.ts
35
35
  import {
36
- AISDKError as AISDKError22,
36
+ AISDKError as AISDKError23,
37
37
  APICallError,
38
38
  EmptyResponseBodyError,
39
39
  InvalidPromptError,
@@ -328,30 +328,51 @@ var NoTranscriptGeneratedError = class extends AISDKError12 {
328
328
  };
329
329
  _a12 = symbol12;
330
330
 
331
- // src/error/no-video-generated-error.ts
331
+ // src/error/no-translation-generated-error.ts
332
332
  import { AISDKError as AISDKError13 } from "@ai-sdk/provider";
333
- var name13 = "AI_NoVideoGeneratedError";
333
+ var name13 = "AI_NoTranslationGeneratedError";
334
334
  var marker13 = `vercel.ai.error.${name13}`;
335
335
  var symbol13 = Symbol.for(marker13);
336
336
  var _a13;
337
- var NoVideoGeneratedError = class extends AISDKError13 {
337
+ var NoTranslationGeneratedError = class extends AISDKError13 {
338
+ constructor(options) {
339
+ super({
340
+ name: name13,
341
+ message: "No translation generated."
342
+ });
343
+ this[_a13] = true;
344
+ this.response = options.response;
345
+ }
346
+ static isInstance(error) {
347
+ return AISDKError13.hasMarker(error, marker13);
348
+ }
349
+ };
350
+ _a13 = symbol13;
351
+
352
+ // src/error/no-video-generated-error.ts
353
+ import { AISDKError as AISDKError14 } from "@ai-sdk/provider";
354
+ var name14 = "AI_NoVideoGeneratedError";
355
+ var marker14 = `vercel.ai.error.${name14}`;
356
+ var symbol14 = Symbol.for(marker14);
357
+ var _a14;
358
+ var NoVideoGeneratedError = class extends AISDKError14 {
338
359
  constructor({
339
360
  message = "No video generated.",
340
361
  cause,
341
362
  responses
342
363
  }) {
343
- super({ name: name13, message, cause });
344
- this[_a13] = true;
364
+ super({ name: name14, message, cause });
365
+ this[_a14] = true;
345
366
  this.responses = responses;
346
367
  }
347
368
  static isInstance(error) {
348
- return AISDKError13.hasMarker(error, marker13);
369
+ return AISDKError14.hasMarker(error, marker14);
349
370
  }
350
371
  /**
351
372
  * @deprecated use `isInstance` instead
352
373
  */
353
374
  static isNoVideoGeneratedError(error) {
354
- return error instanceof Error && error.name === name13 && typeof error.responses !== "undefined" ? true : false;
375
+ return error instanceof Error && error.name === name14 && typeof error.responses !== "undefined" ? true : false;
355
376
  }
356
377
  /**
357
378
  * @deprecated Do not use this method. It will be removed in the next major version.
@@ -366,56 +387,56 @@ var NoVideoGeneratedError = class extends AISDKError13 {
366
387
  };
367
388
  }
368
389
  };
369
- _a13 = symbol13;
390
+ _a14 = symbol14;
370
391
 
371
392
  // src/error/no-such-tool-error.ts
372
- import { AISDKError as AISDKError14 } from "@ai-sdk/provider";
373
- var name14 = "AI_NoSuchToolError";
374
- var marker14 = `vercel.ai.error.${name14}`;
375
- var symbol14 = Symbol.for(marker14);
376
- var _a14;
377
- var NoSuchToolError = class extends AISDKError14 {
393
+ import { AISDKError as AISDKError15 } from "@ai-sdk/provider";
394
+ var name15 = "AI_NoSuchToolError";
395
+ var marker15 = `vercel.ai.error.${name15}`;
396
+ var symbol15 = Symbol.for(marker15);
397
+ var _a15;
398
+ var NoSuchToolError = class extends AISDKError15 {
378
399
  constructor({
379
400
  toolName,
380
401
  availableTools = void 0,
381
402
  message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === void 0 ? "No tools are available." : `Available tools: ${availableTools.join(", ")}.`}`
382
403
  }) {
383
- super({ name: name14, message });
384
- this[_a14] = true;
404
+ super({ name: name15, message });
405
+ this[_a15] = true;
385
406
  this.toolName = toolName;
386
407
  this.availableTools = availableTools;
387
408
  }
388
409
  static isInstance(error) {
389
- return AISDKError14.hasMarker(error, marker14);
410
+ return AISDKError15.hasMarker(error, marker15);
390
411
  }
391
412
  };
392
- _a14 = symbol14;
413
+ _a15 = symbol15;
393
414
 
394
415
  // src/error/tool-call-repair-error.ts
395
- import { AISDKError as AISDKError15, getErrorMessage as getErrorMessage2 } from "@ai-sdk/provider";
396
- var name15 = "AI_ToolCallRepairError";
397
- var marker15 = `vercel.ai.error.${name15}`;
398
- var symbol15 = Symbol.for(marker15);
399
- var _a15;
400
- var ToolCallRepairError = class extends AISDKError15 {
416
+ import { AISDKError as AISDKError16, getErrorMessage as getErrorMessage2 } from "@ai-sdk/provider";
417
+ var name16 = "AI_ToolCallRepairError";
418
+ var marker16 = `vercel.ai.error.${name16}`;
419
+ var symbol16 = Symbol.for(marker16);
420
+ var _a16;
421
+ var ToolCallRepairError = class extends AISDKError16 {
401
422
  constructor({
402
423
  cause,
403
424
  originalError,
404
425
  message = `Error repairing tool call: ${getErrorMessage2(cause)}`
405
426
  }) {
406
- super({ name: name15, message, cause });
407
- this[_a15] = true;
427
+ super({ name: name16, message, cause });
428
+ this[_a16] = true;
408
429
  this.originalError = originalError;
409
430
  }
410
431
  static isInstance(error) {
411
- return AISDKError15.hasMarker(error, marker15);
432
+ return AISDKError16.hasMarker(error, marker16);
412
433
  }
413
434
  };
414
- _a15 = symbol15;
435
+ _a16 = symbol16;
415
436
 
416
437
  // src/error/unsupported-model-version-error.ts
417
- import { AISDKError as AISDKError16 } from "@ai-sdk/provider";
418
- var UnsupportedModelVersionError = class extends AISDKError16 {
438
+ import { AISDKError as AISDKError17 } from "@ai-sdk/provider";
439
+ var UnsupportedModelVersionError = class extends AISDKError17 {
419
440
  constructor(options) {
420
441
  super({
421
442
  name: "AI_UnsupportedModelVersionError",
@@ -428,118 +449,118 @@ var UnsupportedModelVersionError = class extends AISDKError16 {
428
449
  };
429
450
 
430
451
  // src/error/ui-message-stream-error.ts
431
- import { AISDKError as AISDKError17 } from "@ai-sdk/provider";
432
- var name16 = "AI_UIMessageStreamError";
433
- var marker16 = `vercel.ai.error.${name16}`;
434
- var symbol16 = Symbol.for(marker16);
435
- var _a16;
436
- var UIMessageStreamError = class extends AISDKError17 {
452
+ import { AISDKError as AISDKError18 } from "@ai-sdk/provider";
453
+ var name17 = "AI_UIMessageStreamError";
454
+ var marker17 = `vercel.ai.error.${name17}`;
455
+ var symbol17 = Symbol.for(marker17);
456
+ var _a17;
457
+ var UIMessageStreamError = class extends AISDKError18 {
437
458
  constructor({
438
459
  chunkType,
439
460
  chunkId,
440
461
  message
441
462
  }) {
442
- super({ name: name16, message });
443
- this[_a16] = true;
463
+ super({ name: name17, message });
464
+ this[_a17] = true;
444
465
  this.chunkType = chunkType;
445
466
  this.chunkId = chunkId;
446
467
  }
447
468
  static isInstance(error) {
448
- return AISDKError17.hasMarker(error, marker16);
469
+ return AISDKError18.hasMarker(error, marker17);
449
470
  }
450
471
  };
451
- _a16 = symbol16;
472
+ _a17 = symbol17;
452
473
 
453
474
  // src/prompt/invalid-data-content-error.ts
454
- import { AISDKError as AISDKError18 } from "@ai-sdk/provider";
455
- var name17 = "AI_InvalidDataContentError";
456
- var marker17 = `vercel.ai.error.${name17}`;
457
- var symbol17 = Symbol.for(marker17);
458
- var _a17;
459
- var InvalidDataContentError = class extends AISDKError18 {
475
+ import { AISDKError as AISDKError19 } from "@ai-sdk/provider";
476
+ var name18 = "AI_InvalidDataContentError";
477
+ var marker18 = `vercel.ai.error.${name18}`;
478
+ var symbol18 = Symbol.for(marker18);
479
+ var _a18;
480
+ var InvalidDataContentError = class extends AISDKError19 {
460
481
  constructor({
461
482
  content,
462
483
  cause,
463
484
  message = `Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof content}.`
464
485
  }) {
465
- super({ name: name17, message, cause });
466
- this[_a17] = true;
486
+ super({ name: name18, message, cause });
487
+ this[_a18] = true;
467
488
  this.content = content;
468
489
  }
469
490
  static isInstance(error) {
470
- return AISDKError18.hasMarker(error, marker17);
491
+ return AISDKError19.hasMarker(error, marker18);
471
492
  }
472
493
  };
473
- _a17 = symbol17;
494
+ _a18 = symbol18;
474
495
 
475
496
  // src/prompt/invalid-message-role-error.ts
476
- import { AISDKError as AISDKError19 } from "@ai-sdk/provider";
477
- var name18 = "AI_InvalidMessageRoleError";
478
- var marker18 = `vercel.ai.error.${name18}`;
479
- var symbol18 = Symbol.for(marker18);
480
- var _a18;
481
- var InvalidMessageRoleError = class extends AISDKError19 {
497
+ import { AISDKError as AISDKError20 } from "@ai-sdk/provider";
498
+ var name19 = "AI_InvalidMessageRoleError";
499
+ var marker19 = `vercel.ai.error.${name19}`;
500
+ var symbol19 = Symbol.for(marker19);
501
+ var _a19;
502
+ var InvalidMessageRoleError = class extends AISDKError20 {
482
503
  constructor({
483
504
  role,
484
505
  message = `Invalid message role: '${role}'. Must be one of: "system", "user", "assistant", "tool".`
485
506
  }) {
486
- super({ name: name18, message });
487
- this[_a18] = true;
507
+ super({ name: name19, message });
508
+ this[_a19] = true;
488
509
  this.role = role;
489
510
  }
490
511
  static isInstance(error) {
491
- return AISDKError19.hasMarker(error, marker18);
512
+ return AISDKError20.hasMarker(error, marker19);
492
513
  }
493
514
  };
494
- _a18 = symbol18;
515
+ _a19 = symbol19;
495
516
 
496
517
  // src/prompt/message-conversion-error.ts
497
- import { AISDKError as AISDKError20 } from "@ai-sdk/provider";
498
- var name19 = "AI_MessageConversionError";
499
- var marker19 = `vercel.ai.error.${name19}`;
500
- var symbol19 = Symbol.for(marker19);
501
- var _a19;
502
- var MessageConversionError = class extends AISDKError20 {
518
+ import { AISDKError as AISDKError21 } from "@ai-sdk/provider";
519
+ var name20 = "AI_MessageConversionError";
520
+ var marker20 = `vercel.ai.error.${name20}`;
521
+ var symbol20 = Symbol.for(marker20);
522
+ var _a20;
523
+ var MessageConversionError = class extends AISDKError21 {
503
524
  constructor({
504
525
  originalMessage,
505
526
  message
506
527
  }) {
507
- super({ name: name19, message });
508
- this[_a19] = true;
528
+ super({ name: name20, message });
529
+ this[_a20] = true;
509
530
  this.originalMessage = originalMessage;
510
531
  }
511
532
  static isInstance(error) {
512
- return AISDKError20.hasMarker(error, marker19);
533
+ return AISDKError21.hasMarker(error, marker20);
513
534
  }
514
535
  };
515
- _a19 = symbol19;
536
+ _a20 = symbol20;
516
537
 
517
538
  // src/error/index.ts
518
539
  import { DownloadError } from "@ai-sdk/provider-utils";
519
540
 
520
541
  // src/util/retry-error.ts
521
- import { AISDKError as AISDKError21 } from "@ai-sdk/provider";
522
- var name20 = "AI_RetryError";
523
- var marker20 = `vercel.ai.error.${name20}`;
524
- var symbol20 = Symbol.for(marker20);
525
- var _a20;
526
- var RetryError = class extends AISDKError21 {
542
+ import { AISDKError as AISDKError22 } from "@ai-sdk/provider";
543
+ var name21 = "AI_RetryError";
544
+ var marker21 = `vercel.ai.error.${name21}`;
545
+ var symbol21 = Symbol.for(marker21);
546
+ var _a21;
547
+ var RetryError = class extends AISDKError22 {
527
548
  constructor({
528
549
  message,
529
550
  reason,
530
551
  errors
531
552
  }) {
532
- super({ name: name20, message });
533
- this[_a20] = true;
553
+ super({ name: name21, message });
554
+ this[_a21] = true;
534
555
  this.reason = reason;
535
556
  this.errors = errors;
536
557
  this.lastError = errors[errors.length - 1];
537
558
  }
538
559
  static isInstance(error) {
539
- return AISDKError21.hasMarker(error, marker20);
560
+ return AISDKError22.hasMarker(error, marker21);
540
561
  }
541
562
  };
542
- _a20 = symbol20;
563
+ _a21 = symbol21;
543
564
 
544
565
  // src/logger/log-warnings.ts
545
566
  function formatWarning({
@@ -949,9 +970,9 @@ function resolveEmbeddingModel(model) {
949
970
  return asEmbeddingModelV4(model);
950
971
  }
951
972
  function resolveTranscriptionModel(model) {
952
- var _a22, _b;
973
+ var _a23, _b;
953
974
  if (typeof model === "string") {
954
- return (_b = (_a22 = getGlobalProvider()).transcriptionModel) == null ? void 0 : _b.call(_a22, model);
975
+ return (_b = (_a23 = getGlobalProvider()).transcriptionModel) == null ? void 0 : _b.call(_a23, model);
955
976
  }
956
977
  if (!["v4", "v3", "v2"].includes(model.specificationVersion)) {
957
978
  const unsupportedModel = model;
@@ -963,10 +984,32 @@ function resolveTranscriptionModel(model) {
963
984
  }
964
985
  return asTranscriptionModelV4(model);
965
986
  }
987
+ function resolveSpeechTranslationModel(model) {
988
+ var _a23;
989
+ if (typeof model === "string") {
990
+ const provider = (_a23 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a23 : gateway;
991
+ const speechTranslationModel = provider.speechTranslationModel;
992
+ if (!speechTranslationModel) {
993
+ throw new Error(
994
+ "The default provider does not support speech translation models. Please pass a provider model instance that implements the experimental speech translation model specification."
995
+ );
996
+ }
997
+ return speechTranslationModel(model);
998
+ }
999
+ if (model.specificationVersion !== "v4") {
1000
+ const unsupportedModel = model;
1001
+ throw new UnsupportedModelVersionError({
1002
+ version: unsupportedModel.specificationVersion,
1003
+ provider: unsupportedModel.provider,
1004
+ modelId: unsupportedModel.modelId
1005
+ });
1006
+ }
1007
+ return model;
1008
+ }
966
1009
  function resolveSpeechModel(model) {
967
- var _a22, _b;
1010
+ var _a23, _b;
968
1011
  if (typeof model === "string") {
969
- return (_b = (_a22 = getGlobalProvider()).speechModel) == null ? void 0 : _b.call(_a22, model);
1012
+ return (_b = (_a23 = getGlobalProvider()).speechModel) == null ? void 0 : _b.call(_a23, model);
970
1013
  }
971
1014
  if (!["v4", "v3", "v2"].includes(model.specificationVersion)) {
972
1015
  const unsupportedModel = model;
@@ -993,9 +1036,9 @@ function resolveImageModel(model) {
993
1036
  return asImageModelV4(model);
994
1037
  }
995
1038
  function resolveVideoModel(model) {
996
- var _a22;
1039
+ var _a23;
997
1040
  if (typeof model === "string") {
998
- const provider = (_a22 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a22 : gateway;
1041
+ const provider = (_a23 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a23 : gateway;
999
1042
  const videoModel = provider.videoModel;
1000
1043
  if (!videoModel) {
1001
1044
  throw new Error(
@@ -1036,8 +1079,8 @@ function resolveRerankingModel(model) {
1036
1079
  return asRerankingModelV4(model);
1037
1080
  }
1038
1081
  function getGlobalProvider() {
1039
- var _a22;
1040
- const provider = (_a22 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a22 : gateway;
1082
+ var _a23;
1083
+ const provider = (_a23 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a23 : gateway;
1041
1084
  return asProviderV4(provider);
1042
1085
  }
1043
1086
 
@@ -1089,7 +1132,7 @@ import {
1089
1132
  } from "@ai-sdk/provider-utils";
1090
1133
 
1091
1134
  // src/version.ts
1092
- var VERSION = true ? "7.0.37" : "0.0.0-test";
1135
+ var VERSION = true ? "7.0.38" : "0.0.0-test";
1093
1136
 
1094
1137
  // src/util/download/download.ts
1095
1138
  var download = async ({
@@ -1097,7 +1140,7 @@ var download = async ({
1097
1140
  maxBytes,
1098
1141
  abortSignal
1099
1142
  }) => {
1100
- var _a22;
1143
+ var _a23;
1101
1144
  const urlText = url.toString();
1102
1145
  try {
1103
1146
  const headers = withUserAgentSuffix(
@@ -1125,7 +1168,7 @@ var download = async ({
1125
1168
  });
1126
1169
  return {
1127
1170
  data,
1128
- mediaType: (_a22 = response.headers.get("content-type")) != null ? _a22 : void 0
1171
+ mediaType: (_a23 = response.headers.get("content-type")) != null ? _a23 : void 0
1129
1172
  };
1130
1173
  } catch (error) {
1131
1174
  if (DownloadError2.isInstance(error)) {
@@ -1592,14 +1635,14 @@ function convertToLanguageModelMessage({
1592
1635
  }
1593
1636
  }
1594
1637
  function convertImagePartToFilePart(part) {
1595
- var _a22;
1638
+ var _a23;
1596
1639
  if (part.type !== "image") {
1597
1640
  return part;
1598
1641
  }
1599
1642
  return {
1600
1643
  type: "file",
1601
1644
  data: part.image,
1602
- mediaType: (_a22 = part.mediaType) != null ? _a22 : "image",
1645
+ mediaType: (_a23 = part.mediaType) != null ? _a23 : "image",
1603
1646
  providerOptions: part.providerOptions
1604
1647
  };
1605
1648
  }
@@ -1721,7 +1764,7 @@ function mapToolResultOutput({
1721
1764
  return {
1722
1765
  type: "content",
1723
1766
  value: output.value.map((item) => {
1724
- var _a22;
1767
+ var _a23;
1725
1768
  switch (item.type) {
1726
1769
  case "file": {
1727
1770
  const convertedPart = convertPartToLanguageModelPart(
@@ -1750,7 +1793,7 @@ function mapToolResultOutput({
1750
1793
  };
1751
1794
  }
1752
1795
  case "file-url": {
1753
- const mediaType = (_a22 = item.mediaType) != null ? _a22 : getMediaTypeFromUrl(item.url);
1796
+ const mediaType = (_a23 = item.mediaType) != null ? _a23 : getMediaTypeFromUrl(item.url);
1754
1797
  let message = `The "file-url" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'url', url } instead.`;
1755
1798
  if (!item.mediaType) {
1756
1799
  const inferenceSuffix = mediaType === "application/octet-stream" ? `Unable to infer media type from URL. Defaulting to 'application/octet-stream'.` : `Inferred media type '${mediaType}' from URL.`;
@@ -1904,10 +1947,10 @@ var URL_EXTENSION_TO_MEDIA_TYPE = {
1904
1947
  ogg: "audio/ogg"
1905
1948
  };
1906
1949
  function getMediaTypeFromUrl(url, fallbackMediaType = "application/octet-stream") {
1907
- var _a22;
1950
+ var _a23;
1908
1951
  try {
1909
1952
  const pathname = new URL(url).pathname;
1910
- const fileExtension = (_a22 = pathname.split(".").pop()) == null ? void 0 : _a22.toLowerCase();
1953
+ const fileExtension = (_a23 = pathname.split(".").pop()) == null ? void 0 : _a23.toLowerCase();
1911
1954
  if (fileExtension && Object.hasOwn(URL_EXTENSION_TO_MEDIA_TYPE, fileExtension)) {
1912
1955
  return URL_EXTENSION_TO_MEDIA_TYPE[fileExtension];
1913
1956
  }
@@ -2062,7 +2105,7 @@ async function prepareTools({
2062
2105
  return void 0;
2063
2106
  }
2064
2107
  const languageModelTools = [];
2065
- for (const [name22, tool2] of orderToolEntries({ tools, toolOrder })) {
2108
+ for (const [name23, tool2] of orderToolEntries({ tools, toolOrder })) {
2066
2109
  const toolType = tool2.type;
2067
2110
  switch (toolType) {
2068
2111
  case void 0:
@@ -2070,7 +2113,7 @@ async function prepareTools({
2070
2113
  case "function": {
2071
2114
  const description = resolveToolDescription({
2072
2115
  tool: tool2,
2073
- toolName: name22,
2116
+ toolName: name23,
2074
2117
  toolsContext,
2075
2118
  experimental_sandbox: sandbox
2076
2119
  });
@@ -2079,7 +2122,7 @@ async function prepareTools({
2079
2122
  const strict = tool2.strict;
2080
2123
  languageModelTools.push({
2081
2124
  type: "function",
2082
- name: name22,
2125
+ name: name23,
2083
2126
  inputSchema: await asSchema(tool2.inputSchema).jsonSchema,
2084
2127
  ...description != null ? { description } : {},
2085
2128
  ...inputExamples != null ? { inputExamples } : {},
@@ -2091,7 +2134,7 @@ async function prepareTools({
2091
2134
  case "provider": {
2092
2135
  languageModelTools.push({
2093
2136
  type: "provider",
2094
- name: name22,
2137
+ name: name23,
2095
2138
  id: tool2.id,
2096
2139
  args: tool2.args
2097
2140
  });
@@ -2113,10 +2156,10 @@ function orderToolEntries({
2113
2156
  return Object.entries(tools);
2114
2157
  }
2115
2158
  const toolEntries = Object.entries(tools);
2116
- const orderedTools = toolEntries.filter(([name22]) => toolOrder.includes(name22)).sort(
2159
+ const orderedTools = toolEntries.filter(([name23]) => toolOrder.includes(name23)).sort(
2117
2160
  ([nameA], [nameB]) => toolOrder.indexOf(nameA) - toolOrder.indexOf(nameB)
2118
2161
  );
2119
- const unorderedTools = toolEntries.filter(([name22]) => !toolOrder.includes(name22)).sort(([nameA], [nameB]) => nameA < nameB ? -1 : nameA > nameB ? 1 : 0);
2162
+ const unorderedTools = toolEntries.filter(([name23]) => !toolOrder.includes(name23)).sort(([nameA], [nameB]) => nameA < nameB ? -1 : nameA > nameB ? 1 : 0);
2120
2163
  return [...orderedTools, ...unorderedTools];
2121
2164
  }
2122
2165
  function resolveToolDescription({
@@ -2160,11 +2203,11 @@ function getChunkTimeoutMs(timeout) {
2160
2203
  return timeout.chunkMs;
2161
2204
  }
2162
2205
  function getToolTimeoutMs(timeout, toolName) {
2163
- var _a22, _b;
2206
+ var _a23, _b;
2164
2207
  if (timeout == null || typeof timeout === "number") {
2165
2208
  return void 0;
2166
2209
  }
2167
- return (_b = (_a22 = timeout.tools) == null ? void 0 : _a22[`${toolName}Ms`]) != null ? _b : timeout.toolMs;
2210
+ return (_b = (_a23 = timeout.tools) == null ? void 0 : _a23[`${toolName}Ms`]) != null ? _b : timeout.toolMs;
2168
2211
  }
2169
2212
 
2170
2213
  // src/prompt/standardize-prompt.ts
@@ -2515,14 +2558,14 @@ async function standardizePrompt({
2515
2558
 
2516
2559
  // src/prompt/wrap-gateway-error.ts
2517
2560
  import { GatewayAuthenticationError } from "@ai-sdk/gateway";
2518
- import { AISDKError as AISDKError23 } from "@ai-sdk/provider";
2561
+ import { AISDKError as AISDKError24 } from "@ai-sdk/provider";
2519
2562
  function wrapGatewayError(error) {
2520
2563
  if (!GatewayAuthenticationError.isInstance(error))
2521
2564
  return error;
2522
2565
  const isProductionEnv = (process == null ? void 0 : process.env.NODE_ENV) === "production";
2523
2566
  const moreInfoURL = "https://ai-sdk.dev/unauthenticated-ai-gateway";
2524
2567
  if (isProductionEnv) {
2525
- return new AISDKError23({
2568
+ return new AISDKError24({
2526
2569
  name: "GatewayError",
2527
2570
  message: `Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${moreInfoURL}`
2528
2571
  });
@@ -2580,12 +2623,12 @@ function createNullLanguageModelUsage() {
2580
2623
  };
2581
2624
  }
2582
2625
  function addLanguageModelUsage(usage1, usage2) {
2583
- var _a22, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2626
+ var _a23, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2584
2627
  return {
2585
2628
  inputTokens: addTokenCounts(usage1.inputTokens, usage2.inputTokens),
2586
2629
  inputTokenDetails: {
2587
2630
  noCacheTokens: addTokenCounts(
2588
- (_a22 = usage1.inputTokenDetails) == null ? void 0 : _a22.noCacheTokens,
2631
+ (_a23 = usage1.inputTokenDetails) == null ? void 0 : _a23.noCacheTokens,
2589
2632
  (_b = usage2.inputTokenDetails) == null ? void 0 : _b.noCacheTokens
2590
2633
  ),
2591
2634
  cacheReadTokens: addTokenCounts(
@@ -2638,8 +2681,8 @@ function mergeAbortSignals(...signals) {
2638
2681
 
2639
2682
  // src/util/now.ts
2640
2683
  function now() {
2641
- var _a22, _b;
2642
- return (_b = (_a22 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a22.now()) != null ? _b : Date.now();
2684
+ var _a23, _b;
2685
+ return (_b = (_a23 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a23.now()) != null ? _b : Date.now();
2643
2686
  }
2644
2687
 
2645
2688
  // src/util/notify.ts
@@ -3013,7 +3056,7 @@ function filterActiveTools({
3013
3056
  return tools;
3014
3057
  }
3015
3058
  return Object.fromEntries(
3016
- Object.entries(tools).filter(([name22]) => activeTools.includes(name22))
3059
+ Object.entries(tools).filter(([name23]) => activeTools.includes(name23))
3017
3060
  );
3018
3061
  }
3019
3062
 
@@ -3445,7 +3488,7 @@ var text = () => ({
3445
3488
  });
3446
3489
  var object = ({
3447
3490
  schema: inputSchema,
3448
- name: name22,
3491
+ name: name23,
3449
3492
  description
3450
3493
  }) => {
3451
3494
  const schema = asSchema2(inputSchema);
@@ -3454,7 +3497,7 @@ var object = ({
3454
3497
  responseFormat: resolve(schema.jsonSchema).then((jsonSchema2) => ({
3455
3498
  type: "json",
3456
3499
  schema: jsonSchema2,
3457
- ...name22 != null && { name: name22 },
3500
+ ...name23 != null && { name: name23 },
3458
3501
  ...description != null && { description }
3459
3502
  })),
3460
3503
  async parseCompleteOutput({ text: text2 }, context) {
@@ -3508,7 +3551,7 @@ var object = ({
3508
3551
  };
3509
3552
  var array = ({
3510
3553
  element: inputElementSchema,
3511
- name: name22,
3554
+ name: name23,
3512
3555
  description
3513
3556
  }) => {
3514
3557
  const elementSchema = asSchema2(inputElementSchema);
@@ -3528,7 +3571,7 @@ var array = ({
3528
3571
  required: ["elements"],
3529
3572
  additionalProperties: false
3530
3573
  },
3531
- ...name22 != null && { name: name22 },
3574
+ ...name23 != null && { name: name23 },
3532
3575
  ...description != null && { description }
3533
3576
  };
3534
3577
  }),
@@ -3622,7 +3665,7 @@ var array = ({
3622
3665
  };
3623
3666
  var choice = ({
3624
3667
  options: choiceOptions,
3625
- name: name22,
3668
+ name: name23,
3626
3669
  description
3627
3670
  }) => {
3628
3671
  return {
@@ -3639,7 +3682,7 @@ var choice = ({
3639
3682
  required: ["result"],
3640
3683
  additionalProperties: false
3641
3684
  },
3642
- ...name22 != null && { name: name22 },
3685
+ ...name23 != null && { name: name23 },
3643
3686
  ...description != null && { description }
3644
3687
  }),
3645
3688
  async parseCompleteOutput({ text: text2 }, context) {
@@ -3700,14 +3743,14 @@ var choice = ({
3700
3743
  };
3701
3744
  };
3702
3745
  var json = ({
3703
- name: name22,
3746
+ name: name23,
3704
3747
  description
3705
3748
  } = {}) => {
3706
3749
  return {
3707
3750
  name: "json",
3708
3751
  responseFormat: Promise.resolve({
3709
3752
  type: "json",
3710
- ...name22 != null && { name: name22 },
3753
+ ...name23 != null && { name: name23 },
3711
3754
  ...description != null && { description }
3712
3755
  }),
3713
3756
  async parseCompleteOutput({ text: text2 }, context) {
@@ -3782,8 +3825,8 @@ async function parseToolCall({
3782
3825
  toolCall,
3783
3826
  tools,
3784
3827
  inputSchema: async ({ toolName }) => {
3785
- var _a22;
3786
- const inputSchema = (_a22 = getOwn(tools, toolName)) == null ? void 0 : _a22.inputSchema;
3828
+ var _a23;
3829
+ const inputSchema = (_a23 = getOwn(tools, toolName)) == null ? void 0 : _a23.inputSchema;
3787
3830
  return await asSchema3(inputSchema).jsonSchema;
3788
3831
  },
3789
3832
  instructions,
@@ -4022,8 +4065,8 @@ var AI_SDK_TELEMETRY_TRACING_CHANNEL = "ai:telemetry";
4022
4065
 
4023
4066
  // src/util/is-node-runtime.ts
4024
4067
  function isNodeRuntime() {
4025
- var _a22;
4026
- return typeof process !== "undefined" && ((_a22 = process.release) == null ? void 0 : _a22.name) === "node";
4068
+ var _a23;
4069
+ return typeof process !== "undefined" && ((_a23 = process.release) == null ? void 0 : _a23.name) === "node";
4027
4070
  }
4028
4071
 
4029
4072
  // src/telemetry/tracing-channel-publisher.ts
@@ -4040,18 +4083,18 @@ async function loadDiagnosticsChannel() {
4040
4083
  return diagnosticsChannelPromise;
4041
4084
  }
4042
4085
  function loadBuiltinModule(id) {
4043
- var _a22;
4086
+ var _a23;
4044
4087
  const processWithBuiltins = globalThis.process;
4045
4088
  try {
4046
- return (_a22 = processWithBuiltins == null ? void 0 : processWithBuiltins.getBuiltinModule) == null ? void 0 : _a22.call(processWithBuiltins, id);
4089
+ return (_a23 = processWithBuiltins == null ? void 0 : processWithBuiltins.getBuiltinModule) == null ? void 0 : _a23.call(processWithBuiltins, id);
4047
4090
  } catch (e) {
4048
4091
  return void 0;
4049
4092
  }
4050
4093
  }
4051
4094
  async function runWithTracingChannelSpan(message, execute) {
4052
- var _a22;
4095
+ var _a23;
4053
4096
  const diagnosticsChannel = await loadDiagnosticsChannel();
4054
- const tracingChannel = (_a22 = diagnosticsChannel == null ? void 0 : diagnosticsChannel.tracingChannel) == null ? void 0 : _a22.call(
4097
+ const tracingChannel = (_a23 = diagnosticsChannel == null ? void 0 : diagnosticsChannel.tracingChannel) == null ? void 0 : _a23.call(
4055
4098
  diagnosticsChannel,
4056
4099
  AI_SDK_TELEMETRY_TRACING_CHANNEL
4057
4100
  );
@@ -4102,7 +4145,7 @@ function openTelemetryChannelSpanContext({
4102
4145
  message,
4103
4146
  completion
4104
4147
  }) {
4105
- var _a22;
4148
+ var _a23;
4106
4149
  if (!isNodeRuntime()) {
4107
4150
  return void 0;
4108
4151
  }
@@ -4110,7 +4153,7 @@ function openTelemetryChannelSpanContext({
4110
4153
  "node:diagnostics_channel"
4111
4154
  );
4112
4155
  const asyncHooks = loadBuiltinModule("node:async_hooks");
4113
- const tracingChannel = (_a22 = diagnosticsChannel == null ? void 0 : diagnosticsChannel.tracingChannel) == null ? void 0 : _a22.call(
4156
+ const tracingChannel = (_a23 = diagnosticsChannel == null ? void 0 : diagnosticsChannel.tracingChannel) == null ? void 0 : _a23.call(
4114
4157
  diagnosticsChannel,
4115
4158
  AI_SDK_TELEMETRY_TRACING_CHANNEL
4116
4159
  );
@@ -4168,8 +4211,8 @@ function registerTelemetry(...integrations) {
4168
4211
  globalThis.AI_SDK_TELEMETRY_INTEGRATIONS.push(...integrations);
4169
4212
  }
4170
4213
  function getGlobalTelemetryIntegrations() {
4171
- var _a22;
4172
- return (_a22 = globalThis.AI_SDK_TELEMETRY_INTEGRATIONS) != null ? _a22 : [];
4214
+ var _a23;
4215
+ return (_a23 = globalThis.AI_SDK_TELEMETRY_INTEGRATIONS) != null ? _a23 : [];
4173
4216
  }
4174
4217
 
4175
4218
  // src/telemetry/create-telemetry-dispatcher.ts
@@ -4195,8 +4238,8 @@ function createTelemetryDispatcher({
4195
4238
  };
4196
4239
  const mergeTelemetryCallback = (key) => {
4197
4240
  const integrationCallbacks = integrations.map((integration) => {
4198
- var _a22;
4199
- return (_a22 = integration[key]) == null ? void 0 : _a22.bind(integration);
4241
+ var _a23;
4242
+ return (_a23 = integration[key]) == null ? void 0 : _a23.bind(integration);
4200
4243
  }).filter(Boolean).map(
4201
4244
  (callback) => (event) => callback(augmentEvent(event, telemetryMetadata))
4202
4245
  );
@@ -4206,12 +4249,12 @@ function createTelemetryDispatcher({
4206
4249
  };
4207
4250
  };
4208
4251
  const executeLanguageModelCallWrappers = integrations.map((integration) => {
4209
- var _a22;
4210
- return (_a22 = integration.executeLanguageModelCall) == null ? void 0 : _a22.bind(integration);
4252
+ var _a23;
4253
+ return (_a23 = integration.executeLanguageModelCall) == null ? void 0 : _a23.bind(integration);
4211
4254
  }).filter(Boolean);
4212
4255
  const executeToolWrappers = integrations.map((integration) => {
4213
- var _a22;
4214
- return (_a22 = integration.executeTool) == null ? void 0 : _a22.bind(integration);
4256
+ var _a23;
4257
+ return (_a23 = integration.executeTool) == null ? void 0 : _a23.bind(integration);
4215
4258
  }).filter(Boolean);
4216
4259
  return {
4217
4260
  runInTracingChannelSpan: async ({ type, event, execute }) => await runWithTracingChannelSpan(
@@ -4455,8 +4498,8 @@ function createRestrictedTelemetryDispatcher({
4455
4498
  return {
4456
4499
  ...telemetryDispatcher,
4457
4500
  onStart: (event) => {
4458
- var _a22;
4459
- return (_a22 = telemetryDispatcher.onStart) == null ? void 0 : _a22.call(telemetryDispatcher, {
4501
+ var _a23;
4502
+ return (_a23 = telemetryDispatcher.onStart) == null ? void 0 : _a23.call(telemetryDispatcher, {
4460
4503
  ...event,
4461
4504
  runtimeContext: filterIncludedContext({
4462
4505
  context: event.runtimeContext,
@@ -4469,8 +4512,8 @@ function createRestrictedTelemetryDispatcher({
4469
4512
  });
4470
4513
  },
4471
4514
  onStepStart: (event) => {
4472
- var _a22;
4473
- return (_a22 = telemetryDispatcher.onStepStart) == null ? void 0 : _a22.call(telemetryDispatcher, {
4515
+ var _a23;
4516
+ return (_a23 = telemetryDispatcher.onStepStart) == null ? void 0 : _a23.call(telemetryDispatcher, {
4474
4517
  ...event,
4475
4518
  runtimeContext: filterIncludedContext({
4476
4519
  context: event.runtimeContext,
@@ -4490,8 +4533,8 @@ function createRestrictedTelemetryDispatcher({
4490
4533
  });
4491
4534
  },
4492
4535
  onStepEnd: (event) => {
4493
- var _a22;
4494
- return (_a22 = telemetryDispatcher.onStepEnd) == null ? void 0 : _a22.call(
4536
+ var _a23;
4537
+ return (_a23 = telemetryDispatcher.onStepEnd) == null ? void 0 : _a23.call(
4495
4538
  telemetryDispatcher,
4496
4539
  restrictStepResult({
4497
4540
  step: event,
@@ -4501,8 +4544,8 @@ function createRestrictedTelemetryDispatcher({
4501
4544
  );
4502
4545
  },
4503
4546
  onStepFinish: (event) => {
4504
- var _a22;
4505
- return (_a22 = telemetryDispatcher.onStepEnd) == null ? void 0 : _a22.call(
4547
+ var _a23;
4548
+ return (_a23 = telemetryDispatcher.onStepEnd) == null ? void 0 : _a23.call(
4506
4549
  telemetryDispatcher,
4507
4550
  restrictStepResult({
4508
4551
  step: event,
@@ -4512,8 +4555,8 @@ function createRestrictedTelemetryDispatcher({
4512
4555
  );
4513
4556
  },
4514
4557
  onEnd: (event) => {
4515
- var _a22;
4516
- return (_a22 = telemetryDispatcher.onEnd) == null ? void 0 : _a22.call(
4558
+ var _a23;
4559
+ return (_a23 = telemetryDispatcher.onEnd) == null ? void 0 : _a23.call(
4517
4560
  telemetryDispatcher,
4518
4561
  ((restrictedSteps) => {
4519
4562
  return {
@@ -4541,8 +4584,8 @@ function createRestrictedTelemetryDispatcher({
4541
4584
  );
4542
4585
  },
4543
4586
  onAbort: (event) => {
4544
- var _a22;
4545
- return (_a22 = telemetryDispatcher.onAbort) == null ? void 0 : _a22.call(telemetryDispatcher, {
4587
+ var _a23;
4588
+ return (_a23 = telemetryDispatcher.onAbort) == null ? void 0 : _a23.call(telemetryDispatcher, {
4546
4589
  ...event,
4547
4590
  steps: event.steps.map(
4548
4591
  (step) => restrictStepResult({
@@ -4554,8 +4597,8 @@ function createRestrictedTelemetryDispatcher({
4554
4597
  });
4555
4598
  },
4556
4599
  onToolExecutionStart: (event) => {
4557
- var _a22;
4558
- return (_a22 = telemetryDispatcher.onToolExecutionStart) == null ? void 0 : _a22.call(telemetryDispatcher, {
4600
+ var _a23;
4601
+ return (_a23 = telemetryDispatcher.onToolExecutionStart) == null ? void 0 : _a23.call(telemetryDispatcher, {
4559
4602
  ...event,
4560
4603
  toolContext: filterToolContext({
4561
4604
  toolName: event.toolCall.toolName,
@@ -4565,8 +4608,8 @@ function createRestrictedTelemetryDispatcher({
4565
4608
  });
4566
4609
  },
4567
4610
  onToolExecutionEnd: (event) => {
4568
- var _a22;
4569
- return (_a22 = telemetryDispatcher.onToolExecutionEnd) == null ? void 0 : _a22.call(telemetryDispatcher, {
4611
+ var _a23;
4612
+ return (_a23 = telemetryDispatcher.onToolExecutionEnd) == null ? void 0 : _a23.call(telemetryDispatcher, {
4570
4613
  ...event,
4571
4614
  toolContext: filterToolContext({
4572
4615
  toolName: event.toolCall.toolName,
@@ -4587,8 +4630,8 @@ function isLoopFinished() {
4587
4630
  }
4588
4631
  function hasToolCall(...toolName) {
4589
4632
  return ({ steps }) => {
4590
- var _a22, _b, _c;
4591
- return (_c = (_b = (_a22 = steps[steps.length - 1]) == null ? void 0 : _a22.toolCalls) == null ? void 0 : _b.some(
4633
+ var _a23, _b, _c;
4634
+ return (_c = (_b = (_a23 = steps[steps.length - 1]) == null ? void 0 : _a23.toolCalls) == null ? void 0 : _b.some(
4592
4635
  (toolCall) => toolName.includes(toolCall.toolName)
4593
4636
  )) != null ? _c : false;
4594
4637
  };
@@ -4937,7 +4980,7 @@ async function validateApprovedToolApprovals({
4937
4980
  runtimeContext,
4938
4981
  toolApprovalSecret
4939
4982
  }) {
4940
- var _a22;
4983
+ var _a23;
4941
4984
  const approved = [];
4942
4985
  const denied = [];
4943
4986
  for (const approval of approvedToolApprovals) {
@@ -4994,7 +5037,7 @@ async function validateApprovedToolApprovals({
4994
5037
  approvalResponse: {
4995
5038
  ...approval.approvalResponse,
4996
5039
  approved: false,
4997
- reason: (_a22 = approvalStatus.reason) != null ? _a22 : approval.approvalResponse.reason
5040
+ reason: (_a23 = approvalStatus.reason) != null ? _a23 : approval.approvalResponse.reason
4998
5041
  }
4999
5042
  });
5000
5043
  } else {
@@ -5068,9 +5111,9 @@ async function generateText({
5068
5111
  onEnd = onFinish,
5069
5112
  ...settings
5070
5113
  }) {
5071
- var _a22, _b, _c, _d;
5114
+ var _a23, _b, _c, _d;
5072
5115
  include = {
5073
- requestBody: (_a22 = include == null ? void 0 : include.requestBody) != null ? _a22 : false,
5116
+ requestBody: (_a23 = include == null ? void 0 : include.requestBody) != null ? _a23 : false,
5074
5117
  requestMessages: (_b = include == null ? void 0 : include.requestMessages) != null ? _b : false,
5075
5118
  responseBody: (_c = include == null ? void 0 : include.responseBody) != null ? _c : false
5076
5119
  };
@@ -5143,7 +5186,7 @@ async function generateText({
5143
5186
  toolsContext
5144
5187
  };
5145
5188
  const executeGenerateText = async () => {
5146
- var _a23;
5189
+ var _a24;
5147
5190
  await notify({
5148
5191
  event: generateTextStartEvent,
5149
5192
  callbacks: [resolvedOnStart, telemetryDispatcher.onStart]
@@ -5274,7 +5317,7 @@ async function generateText({
5274
5317
  type: "step",
5275
5318
  event: { callId, stepNumber },
5276
5319
  execute: async () => {
5277
- var _a24, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
5320
+ var _a25, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
5278
5321
  const accumulatedResponseMessages = [
5279
5322
  ...initialResponseMessages,
5280
5323
  ...steps.flatMap((step) => step.response.messages)
@@ -5293,7 +5336,7 @@ async function generateText({
5293
5336
  toolsContext,
5294
5337
  experimental_sandbox: sandbox
5295
5338
  }));
5296
- const stepSandbox = (_a24 = prepareStepResult == null ? void 0 : prepareStepResult.experimental_sandbox) != null ? _a24 : sandbox;
5339
+ const stepSandbox = (_a25 = prepareStepResult == null ? void 0 : prepareStepResult.experimental_sandbox) != null ? _a25 : sandbox;
5297
5340
  const stepModel = resolveLanguageModel(
5298
5341
  (_b2 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _b2 : model
5299
5342
  );
@@ -5377,7 +5420,7 @@ async function generateText({
5377
5420
  });
5378
5421
  const executeLanguageModelCallInTelemetryContext = (_n = telemetryDispatcher.executeLanguageModelCall) != null ? _n : async ({ execute }) => await execute();
5379
5422
  currentModelResponse = await retry(async () => {
5380
- var _a25, _b3, _c3, _d3, _e2, _f2, _g2, _h2;
5423
+ var _a26, _b3, _c3, _d3, _e2, _f2, _g2, _h2;
5381
5424
  const result = await executeLanguageModelCallInTelemetryContext(
5382
5425
  {
5383
5426
  ...languageModelCallStartEvent,
@@ -5394,7 +5437,7 @@ async function generateText({
5394
5437
  }
5395
5438
  );
5396
5439
  const responseData = {
5397
- id: (_b3 = (_a25 = result.response) == null ? void 0 : _a25.id) != null ? _b3 : generateId2(),
5440
+ id: (_b3 = (_a26 = result.response) == null ? void 0 : _a26.id) != null ? _b3 : generateId2(),
5398
5441
  timestamp: (_d3 = (_c3 = result.response) == null ? void 0 : _c3.timestamp) != null ? _d3 : /* @__PURE__ */ new Date(),
5399
5442
  modelId: (_f2 = (_e2 = result.response) == null ? void 0 : _e2.modelId) != null ? _f2 : stepModel.modelId,
5400
5443
  headers: (_g2 = result.response) == null ? void 0 : _g2.headers,
@@ -5558,7 +5601,7 @@ async function generateText({
5558
5601
  }
5559
5602
  }
5560
5603
  const invalidToolCalls = stepToolCalls.filter(
5561
- (toolCall) => toolCall.invalid && toolCall.dynamic
5604
+ (toolCall) => toolCall.invalid && toolCall.dynamic && !toolCall.providerExecuted
5562
5605
  );
5563
5606
  clientToolOutputs = [];
5564
5607
  for (const toolCall of invalidToolCalls) {
@@ -5750,8 +5793,8 @@ async function generateText({
5750
5793
  const staticToolResults = steps.flatMap((step) => step.staticToolResults);
5751
5794
  const dynamicToolResults = steps.flatMap((step) => step.dynamicToolResults);
5752
5795
  const warnings = steps.flatMap((step) => {
5753
- var _a24;
5754
- return (_a24 = step.warnings) != null ? _a24 : [];
5796
+ var _a25;
5797
+ return (_a25 = step.warnings) != null ? _a25 : [];
5755
5798
  });
5756
5799
  const onEndEvent = {
5757
5800
  callId,
@@ -5809,7 +5852,7 @@ async function generateText({
5809
5852
  output: resolvedOutput
5810
5853
  });
5811
5854
  } catch (error) {
5812
- await ((_a23 = telemetryDispatcher.onError) == null ? void 0 : _a23.call(telemetryDispatcher, { callId, error }));
5855
+ await ((_a24 = telemetryDispatcher.onError) == null ? void 0 : _a24.call(telemetryDispatcher, { callId, error }));
5813
5856
  throw wrapGatewayError(error);
5814
5857
  }
5815
5858
  };
@@ -5909,8 +5952,8 @@ var DefaultGenerateTextResult = class {
5909
5952
  }
5910
5953
  get warnings() {
5911
5954
  return this.steps.flatMap((step) => {
5912
- var _a22;
5913
- return (_a22 = step.warnings) != null ? _a22 : [];
5955
+ var _a23;
5956
+ return (_a23 = step.warnings) != null ? _a23 : [];
5914
5957
  });
5915
5958
  }
5916
5959
  get providerMetadata() {
@@ -6556,7 +6599,7 @@ function processUIMessageStream({
6556
6599
  new TransformStream({
6557
6600
  async transform(chunk, controller) {
6558
6601
  await runUpdateMessageJob(async ({ state, write }) => {
6559
- var _a22, _b, _c, _d;
6602
+ var _a23, _b, _c, _d;
6560
6603
  function getCurrentStepParts() {
6561
6604
  const parts = state.message.parts;
6562
6605
  let currentStepStartIndex = parts.length - 1;
@@ -6596,8 +6639,8 @@ function processUIMessageStream({
6596
6639
  const toolInvocations = state.message.parts.filter(isToolUIPart);
6597
6640
  const toolInvocation = toolInvocations.find(
6598
6641
  (invocation) => {
6599
- var _a23;
6600
- return ((_a23 = invocation.approval) == null ? void 0 : _a23.id) === approvalId;
6642
+ var _a24;
6643
+ return ((_a24 = invocation.approval) == null ? void 0 : _a24.id) === approvalId;
6601
6644
  }
6602
6645
  );
6603
6646
  if (toolInvocation == null) {
@@ -6610,7 +6653,7 @@ function processUIMessageStream({
6610
6653
  return toolInvocation;
6611
6654
  }
6612
6655
  function updateToolPart(options, existingPart) {
6613
- var _a23;
6656
+ var _a24;
6614
6657
  const part = existingPart != null ? existingPart : getCurrentStepParts().find(
6615
6658
  (part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId
6616
6659
  );
@@ -6629,7 +6672,7 @@ function processUIMessageStream({
6629
6672
  if (options.toolMetadata !== void 0) {
6630
6673
  anyPart.toolMetadata = options.toolMetadata;
6631
6674
  }
6632
- anyPart.providerExecuted = (_a23 = anyOptions.providerExecuted) != null ? _a23 : part.providerExecuted;
6675
+ anyPart.providerExecuted = (_a24 = anyOptions.providerExecuted) != null ? _a24 : part.providerExecuted;
6633
6676
  const providerMetadata = anyOptions.providerMetadata;
6634
6677
  if (providerMetadata != null) {
6635
6678
  if (options.state === "output-available" || options.state === "output-error") {
@@ -6658,7 +6701,7 @@ function processUIMessageStream({
6658
6701
  }
6659
6702
  }
6660
6703
  function updateDynamicToolPart(options, existingPart) {
6661
- var _a23, _b2;
6704
+ var _a24, _b2;
6662
6705
  const part = existingPart != null ? existingPart : getCurrentStepParts().find(
6663
6706
  (part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId
6664
6707
  );
@@ -6670,7 +6713,7 @@ function processUIMessageStream({
6670
6713
  anyPart.input = anyOptions.input;
6671
6714
  anyPart.output = anyOptions.output;
6672
6715
  anyPart.errorText = anyOptions.errorText;
6673
- anyPart.rawInput = (_a23 = anyOptions.rawInput) != null ? _a23 : anyPart.rawInput;
6716
+ anyPart.rawInput = (_a24 = anyOptions.rawInput) != null ? _a24 : anyPart.rawInput;
6674
6717
  anyPart.preliminary = anyOptions.preliminary;
6675
6718
  if (options.title !== void 0) {
6676
6719
  anyPart.title = options.title;
@@ -6745,7 +6788,7 @@ function processUIMessageStream({
6745
6788
  });
6746
6789
  }
6747
6790
  textPart.text += chunk.delta;
6748
- textPart.providerMetadata = (_a22 = chunk.providerMetadata) != null ? _a22 : textPart.providerMetadata;
6791
+ textPart.providerMetadata = (_a23 = chunk.providerMetadata) != null ? _a23 : textPart.providerMetadata;
6749
6792
  write();
6750
6793
  break;
6751
6794
  }
@@ -7603,13 +7646,13 @@ function asAsyncIterableStream(stream) {
7603
7646
  const reader = this.getReader();
7604
7647
  let finished = false;
7605
7648
  async function cleanup(cancelStream) {
7606
- var _a22;
7649
+ var _a23;
7607
7650
  if (finished)
7608
7651
  return;
7609
7652
  finished = true;
7610
7653
  try {
7611
7654
  if (cancelStream) {
7612
- await ((_a22 = reader.cancel) == null ? void 0 : _a22.call(reader));
7655
+ await ((_a23 = reader.cancel) == null ? void 0 : _a23.call(reader));
7613
7656
  }
7614
7657
  } finally {
7615
7658
  try {
@@ -7709,7 +7752,7 @@ function createStitchableStream() {
7709
7752
  controller == null ? void 0 : controller.close();
7710
7753
  };
7711
7754
  const processPull = async () => {
7712
- var _a22;
7755
+ var _a23;
7713
7756
  if (isClosed && innerStreams.length === 0) {
7714
7757
  controller == null ? void 0 : controller.close();
7715
7758
  return;
@@ -7733,7 +7776,7 @@ function createStitchableStream() {
7733
7776
  controller == null ? void 0 : controller.enqueue(value);
7734
7777
  }
7735
7778
  } catch (error) {
7736
- (_a22 = currentStream.onError) == null ? void 0 : _a22.call(currentStream, error);
7779
+ (_a23 = currentStream.onError) == null ? void 0 : _a23.call(currentStream, error);
7737
7780
  controller == null ? void 0 : controller.error(error);
7738
7781
  innerStreams.shift();
7739
7782
  terminate();
@@ -8158,7 +8201,7 @@ function createLanguageModelV4StreamPartToLanguageModelStreamPartTransform({
8158
8201
  const timeBetweenOutputChunksMs = [];
8159
8202
  return new TransformStream({
8160
8203
  async transform(chunk, controller) {
8161
- var _a22, _b;
8204
+ var _a23, _b;
8162
8205
  if (isOutputChunk(chunk)) {
8163
8206
  const outputChunkTimestampMs = now2();
8164
8207
  if (timeToFirstOutputMs == null) {
@@ -8324,16 +8367,18 @@ function createLanguageModelV4StreamPartToLanguageModelStreamPartTransform({
8324
8367
  controller.enqueue(toolCall);
8325
8368
  modelCallContent.push(toolCall);
8326
8369
  if (toolCall.invalid) {
8327
- controller.enqueue({
8328
- type: "tool-error",
8329
- toolCallId: toolCall.toolCallId,
8330
- toolName: toolCall.toolName,
8331
- input: toolCall.input,
8332
- error: getErrorMessage5(toolCall.error),
8333
- dynamic: true,
8334
- title: toolCall.title,
8335
- ...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
8336
- });
8370
+ if (!toolCall.providerExecuted) {
8371
+ controller.enqueue({
8372
+ type: "tool-error",
8373
+ toolCallId: toolCall.toolCallId,
8374
+ toolName: toolCall.toolName,
8375
+ input: toolCall.input,
8376
+ error: getErrorMessage5(toolCall.error),
8377
+ dynamic: true,
8378
+ title: toolCall.title,
8379
+ ...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
8380
+ });
8381
+ }
8337
8382
  break;
8338
8383
  }
8339
8384
  } catch (error) {
@@ -8394,7 +8439,7 @@ function createLanguageModelV4StreamPartToLanguageModelStreamPartTransform({
8394
8439
  const tool2 = getOwn(tools, chunk.toolName);
8395
8440
  controller.enqueue({
8396
8441
  ...chunk,
8397
- dynamic: (_a22 = chunk.dynamic) != null ? _a22 : (tool2 == null ? void 0 : tool2.type) === "dynamic",
8442
+ dynamic: (_a23 = chunk.dynamic) != null ? _a23 : (tool2 == null ? void 0 : tool2.type) === "dynamic",
8398
8443
  title: tool2 == null ? void 0 : tool2.title,
8399
8444
  ...(tool2 == null ? void 0 : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}
8400
8445
  });
@@ -8586,7 +8631,7 @@ function streamText({
8586
8631
  } = {},
8587
8632
  ...settings
8588
8633
  }) {
8589
- var _a22, _b, _c, _d;
8634
+ var _a23, _b, _c, _d;
8590
8635
  const totalTimeoutMs = getTotalTimeoutMs(timeout);
8591
8636
  const stepTimeoutMs = getStepTimeoutMs(timeout);
8592
8637
  const firstChunkTimeoutMs = getFirstChunkTimeoutMs(timeout);
@@ -8659,7 +8704,7 @@ function streamText({
8659
8704
  download: download2,
8660
8705
  // assign default values to include:
8661
8706
  include: {
8662
- requestBody: (_a22 = include == null ? void 0 : include.requestBody) != null ? _a22 : false,
8707
+ requestBody: (_a23 = include == null ? void 0 : include.requestBody) != null ? _a23 : false,
8663
8708
  requestMessages: (_b = include == null ? void 0 : include.requestMessages) != null ? _b : false,
8664
8709
  rawChunks: (_d = (_c = include == null ? void 0 : include.rawChunks) != null ? _c : includeRawChunks) != null ? _d : false
8665
8710
  }
@@ -8694,7 +8739,7 @@ function createOutputTransformStream(output) {
8694
8739
  }
8695
8740
  return new TransformStream({
8696
8741
  async transform(chunk, controller) {
8697
- var _a22;
8742
+ var _a23;
8698
8743
  if (chunk.type === "finish-step" && textChunk.length > 0) {
8699
8744
  publishTextChunk({ controller });
8700
8745
  }
@@ -8721,7 +8766,7 @@ function createOutputTransformStream(output) {
8721
8766
  }
8722
8767
  text2 += chunk.text;
8723
8768
  textChunk += chunk.text;
8724
- textProviderMetadata = (_a22 = chunk.providerMetadata) != null ? _a22 : textProviderMetadata;
8769
+ textProviderMetadata = (_a23 = chunk.providerMetadata) != null ? _a23 : textProviderMetadata;
8725
8770
  const result = await output.parsePartialOutput({ text: text2 });
8726
8771
  if (result !== void 0) {
8727
8772
  const currentValue = typeof result.partial === "string" ? result.partial : JSON.stringify(result.partial);
@@ -8816,7 +8861,7 @@ var DefaultStreamTextResult = class {
8816
8861
  let recordedNoOutputError;
8817
8862
  const eventProcessor = new TransformStream({
8818
8863
  async transform(chunk, controller) {
8819
- var _a22, _b, _c, _d;
8864
+ var _a23, _b, _c, _d;
8820
8865
  controller.enqueue(chunk);
8821
8866
  const { part } = chunk;
8822
8867
  await (onChunk == null ? void 0 : onChunk({ chunk: part }));
@@ -8851,7 +8896,7 @@ var DefaultStreamTextResult = class {
8851
8896
  return;
8852
8897
  }
8853
8898
  activeText.text += part.text;
8854
- activeText.providerMetadata = (_a22 = part.providerMetadata) != null ? _a22 : activeText.providerMetadata;
8899
+ activeText.providerMetadata = (_a23 = part.providerMetadata) != null ? _a23 : activeText.providerMetadata;
8855
8900
  }
8856
8901
  if (part.type === "text-end") {
8857
8902
  const activeText = activeTextContent[part.id];
@@ -9007,8 +9052,8 @@ var DefaultStreamTextResult = class {
9007
9052
  (step) => step.dynamicToolResults
9008
9053
  );
9009
9054
  const warnings = recordedSteps.flatMap((step) => {
9010
- var _a22;
9011
- return (_a22 = step.warnings) != null ? _a22 : [];
9055
+ var _a23;
9056
+ return (_a23 = step.warnings) != null ? _a23 : [];
9012
9057
  });
9013
9058
  await notify({
9014
9059
  event: {
@@ -9131,7 +9176,7 @@ var DefaultStreamTextResult = class {
9131
9176
  const self = this;
9132
9177
  const callId = generateCallId();
9133
9178
  (async () => {
9134
- var _a22;
9179
+ var _a23;
9135
9180
  const initialPrompt = await standardizePrompt({
9136
9181
  instructions,
9137
9182
  system,
@@ -9167,14 +9212,14 @@ var DefaultStreamTextResult = class {
9167
9212
  runtimeContext,
9168
9213
  toolsContext
9169
9214
  };
9170
- const streamTextTracingChannelContext = (_a22 = telemetryDispatcher.startTracingChannelContext) == null ? void 0 : _a22.call(telemetryDispatcher, {
9215
+ const streamTextTracingChannelContext = (_a23 = telemetryDispatcher.startTracingChannelContext) == null ? void 0 : _a23.call(telemetryDispatcher, {
9171
9216
  type: "streamText",
9172
9217
  event: startEvent,
9173
9218
  completion: self._totalUsage.promise.then(() => void 0)
9174
9219
  });
9175
9220
  const runInStreamTextTracingChannelContext = (execute) => {
9176
- var _a23;
9177
- return (_a23 = streamTextTracingChannelContext == null ? void 0 : streamTextTracingChannelContext.run(execute)) != null ? _a23 : execute();
9221
+ var _a24;
9222
+ return (_a24 = streamTextTracingChannelContext == null ? void 0 : streamTextTracingChannelContext.run(execute)) != null ? _a24 : execute();
9178
9223
  };
9179
9224
  const runInTracingChannelSpanInStreamText = telemetryDispatcher.runInTracingChannelSpan == null ? void 0 : (options) => runInStreamTextTracingChannelContext(
9180
9225
  () => telemetryDispatcher.runInTracingChannelSpan(options)
@@ -9304,7 +9349,7 @@ var DefaultStreamTextResult = class {
9304
9349
  currentStep,
9305
9350
  usage
9306
9351
  }) {
9307
- var _a23, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
9352
+ var _a24, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
9308
9353
  const stepTimeoutId = setAbortTimeout({
9309
9354
  abortController: stepAbortController,
9310
9355
  label: "Step",
@@ -9363,14 +9408,14 @@ var DefaultStreamTextResult = class {
9363
9408
  });
9364
9409
  try {
9365
9410
  stepFinish = new DelayedPromise();
9366
- const stepTracingChannelContext = (_a23 = telemetryDispatcher.startTracingChannelContext) == null ? void 0 : _a23.call(telemetryDispatcher, {
9411
+ const stepTracingChannelContext = (_a24 = telemetryDispatcher.startTracingChannelContext) == null ? void 0 : _a24.call(telemetryDispatcher, {
9367
9412
  type: "step",
9368
9413
  event: { callId, stepNumber: currentStep },
9369
9414
  completion: stepFinish.promise
9370
9415
  });
9371
9416
  const runInStepTracingChannelContext = (execute) => {
9372
- var _a24;
9373
- return (_a24 = stepTracingChannelContext == null ? void 0 : stepTracingChannelContext.run(execute)) != null ? _a24 : execute();
9417
+ var _a25;
9418
+ return (_a25 = stepTracingChannelContext == null ? void 0 : stepTracingChannelContext.run(execute)) != null ? _a25 : execute();
9374
9419
  };
9375
9420
  const responseMessagesFromPreviousSteps = recordedSteps.flatMap(
9376
9421
  (step) => step.response.messages
@@ -9434,9 +9479,9 @@ var DefaultStreamTextResult = class {
9434
9479
  } = await runInStepTracingChannelContext(
9435
9480
  () => retry(
9436
9481
  async () => {
9437
- var _a24, _b2;
9482
+ var _a25, _b2;
9438
9483
  return streamLanguageModelCall({
9439
- model: (_a24 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a24 : model,
9484
+ model: (_a25 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a25 : model,
9440
9485
  tools: stepActiveTools,
9441
9486
  toolOrder: stepToolOrder,
9442
9487
  toolChoice: (_b2 = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _b2 : toolChoice,
@@ -9464,7 +9509,7 @@ var DefaultStreamTextResult = class {
9464
9509
  telemetryDispatcher.onLanguageModelCallEnd
9465
9510
  ),
9466
9511
  onStart: async ({ promptMessages }) => {
9467
- var _a25, _b3;
9512
+ var _a26, _b3;
9468
9513
  await notify({
9469
9514
  event: {
9470
9515
  callId,
@@ -9474,7 +9519,7 @@ var DefaultStreamTextResult = class {
9474
9519
  instructions: stepInstructions,
9475
9520
  messages: stepMessages,
9476
9521
  tools,
9477
- toolChoice: (_a25 = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _a25 : toolChoice,
9522
+ toolChoice: (_a26 = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _a26 : toolChoice,
9478
9523
  activeTools: (_b3 = prepareStepResult == null ? void 0 : prepareStepResult.activeTools) != null ? _b3 : activeTools,
9479
9524
  toolOrder: stepToolOrder,
9480
9525
  steps: [...recordedSteps],
@@ -9570,7 +9615,7 @@ var DefaultStreamTextResult = class {
9570
9615
  streamWithToolResults.pipeThrough(
9571
9616
  new TransformStream({
9572
9617
  async transform(chunk, controller) {
9573
- var _a24, _b2, _c2;
9618
+ var _a25, _b2, _c2;
9574
9619
  if (chunk.type === "model-call-start") {
9575
9620
  warnings = chunk.warnings;
9576
9621
  return;
@@ -9642,7 +9687,7 @@ var DefaultStreamTextResult = class {
9642
9687
  }
9643
9688
  case "model-call-response-metadata": {
9644
9689
  stepResponse = {
9645
- id: (_a24 = chunk.id) != null ? _a24 : stepResponse.id,
9690
+ id: (_a25 = chunk.id) != null ? _a25 : stepResponse.id,
9646
9691
  timestamp: (_b2 = chunk.timestamp) != null ? _b2 : stepResponse.timestamp,
9647
9692
  modelId: (_c2 = chunk.modelId) != null ? _c2 : stepResponse.modelId
9648
9693
  };
@@ -9794,8 +9839,8 @@ var DefaultStreamTextResult = class {
9794
9839
  )
9795
9840
  );
9796
9841
  })().catch(async (error) => {
9797
- var _a22;
9798
- await ((_a22 = telemetryDispatcher.onError) == null ? void 0 : _a22.call(telemetryDispatcher, { callId, error }));
9842
+ var _a23;
9843
+ await ((_a23 = telemetryDispatcher.onError) == null ? void 0 : _a23.call(telemetryDispatcher, { callId, error }));
9799
9844
  self._initialResponseMessages.reject(error);
9800
9845
  markPromiseAsHandled(self._initialResponseMessages.promise);
9801
9846
  self.addStream(
@@ -9821,8 +9866,8 @@ var DefaultStreamTextResult = class {
9821
9866
  }
9822
9867
  get warnings() {
9823
9868
  return this.steps.then((steps) => steps.flatMap((step) => {
9824
- var _a22;
9825
- return (_a22 = step.warnings) != null ? _a22 : [];
9869
+ var _a23;
9870
+ return (_a23 = step.warnings) != null ? _a23 : [];
9826
9871
  }));
9827
9872
  }
9828
9873
  get providerMetadata() {
@@ -9951,19 +9996,19 @@ var DefaultStreamTextResult = class {
9951
9996
  }
9952
9997
  }
9953
9998
  async consumeStream(options) {
9954
- var _a22;
9999
+ var _a23;
9955
10000
  try {
9956
10001
  await consumeStream({
9957
10002
  stream: this.stream,
9958
10003
  onError: (error) => {
9959
- var _a23;
10004
+ var _a24;
9960
10005
  this.rejectResultPromises(error);
9961
- (_a23 = options == null ? void 0 : options.onError) == null ? void 0 : _a23.call(options, error);
10006
+ (_a24 = options == null ? void 0 : options.onError) == null ? void 0 : _a24.call(options, error);
9962
10007
  }
9963
10008
  });
9964
10009
  } catch (error) {
9965
10010
  this.rejectResultPromises(error);
9966
- (_a22 = options == null ? void 0 : options.onError) == null ? void 0 : _a22.call(options, error);
10011
+ (_a23 = options == null ? void 0 : options.onError) == null ? void 0 : _a23.call(options, error);
9967
10012
  }
9968
10013
  }
9969
10014
  get experimental_partialOutputStream() {
@@ -9983,8 +10028,8 @@ var DefaultStreamTextResult = class {
9983
10028
  );
9984
10029
  }
9985
10030
  get elementStream() {
9986
- var _a22, _b, _c;
9987
- const transform = (_a22 = this.outputSpecification) == null ? void 0 : _a22.createElementStreamTransform();
10031
+ var _a23, _b, _c;
10032
+ const transform = (_a23 = this.outputSpecification) == null ? void 0 : _a23.createElementStreamTransform();
9988
10033
  if (transform == null) {
9989
10034
  throw new UnsupportedFunctionalityError2({
9990
10035
  functionality: `element streams in ${(_c = (_b = this.outputSpecification) == null ? void 0 : _b.name) != null ? _c : "text"} mode`
@@ -9994,8 +10039,8 @@ var DefaultStreamTextResult = class {
9994
10039
  }
9995
10040
  get output() {
9996
10041
  return this.finalStep.then((step) => {
9997
- var _a22;
9998
- const output = (_a22 = this.outputSpecification) != null ? _a22 : text();
10042
+ var _a23;
10043
+ const output = (_a23 = this.outputSpecification) != null ? _a23 : text();
9999
10044
  return output.parseCompleteOutput(
10000
10045
  { text: step.text },
10001
10046
  {
@@ -10126,7 +10171,7 @@ var ToolLoopAgent = class {
10126
10171
  return this.settings.tools;
10127
10172
  }
10128
10173
  async prepareCall(options) {
10129
- var _a22, _b, _c, _d;
10174
+ var _a23, _b, _c, _d;
10130
10175
  if (this.settings.callOptionsSchema != null && options.options !== void 0) {
10131
10176
  const validatedOptions = await validateTypes3({
10132
10177
  value: options.options,
@@ -10150,7 +10195,7 @@ var ToolLoopAgent = class {
10150
10195
  } = this.settings;
10151
10196
  const baseCallArgs = {
10152
10197
  ...settingsWithoutCallbacks,
10153
- stopWhen: (_a22 = this.settings.stopWhen) != null ? _a22 : isStepCount(20),
10198
+ stopWhen: (_a23 = this.settings.stopWhen) != null ? _a23 : isStepCount(20),
10154
10199
  ...options
10155
10200
  };
10156
10201
  const preparedCallArgs = (_d = await ((_c = (_b = this.settings).prepareCall) == null ? void 0 : _c.call(
@@ -10189,9 +10234,9 @@ var ToolLoopAgent = class {
10189
10234
  * downstream by generateText/streamText and the provider.
10190
10235
  */
10191
10236
  agentHeaders(preparedCall) {
10192
- var _a22;
10237
+ var _a23;
10193
10238
  return withUserAgentSuffix3(
10194
- (_a22 = preparedCall.headers) != null ? _a22 : {},
10239
+ (_a23 = preparedCall.headers) != null ? _a23 : {},
10195
10240
  "ai-sdk-agent/tool-loop"
10196
10241
  );
10197
10242
  }
@@ -10214,7 +10259,7 @@ var ToolLoopAgent = class {
10214
10259
  onEnd = onFinish,
10215
10260
  ...options
10216
10261
  }) {
10217
- var _a22, _b, _c;
10262
+ var _a23, _b, _c;
10218
10263
  const generate = generateText;
10219
10264
  const preparedCall = await this.prepareCall({
10220
10265
  ...options,
@@ -10225,7 +10270,7 @@ var ToolLoopAgent = class {
10225
10270
  timeout,
10226
10271
  experimental_sandbox: sandbox,
10227
10272
  onStart: mergeCallbacks(
10228
- (_a22 = this.settings.onStart) != null ? _a22 : this.settings.experimental_onStart,
10273
+ (_a23 = this.settings.onStart) != null ? _a23 : this.settings.experimental_onStart,
10229
10274
  onStart != null ? onStart : experimental_onStart
10230
10275
  ),
10231
10276
  onStepStart: mergeCallbacks(
@@ -10272,7 +10317,7 @@ var ToolLoopAgent = class {
10272
10317
  onEnd = onFinish,
10273
10318
  ...options
10274
10319
  }) {
10275
- var _a22, _b, _c;
10320
+ var _a23, _b, _c;
10276
10321
  const stream = streamText;
10277
10322
  const preparedCall = await this.prepareCall({
10278
10323
  ...options,
@@ -10284,7 +10329,7 @@ var ToolLoopAgent = class {
10284
10329
  experimental_sandbox: sandbox,
10285
10330
  experimental_transform,
10286
10331
  onStart: mergeCallbacks(
10287
- (_a22 = this.settings.onStart) != null ? _a22 : this.settings.experimental_onStart,
10332
+ (_a23 = this.settings.onStart) != null ? _a23 : this.settings.experimental_onStart,
10288
10333
  onStart != null ? onStart : experimental_onStart
10289
10334
  ),
10290
10335
  onStepStart: mergeCallbacks(
@@ -10413,7 +10458,7 @@ function readUIMessageStream({
10413
10458
  onError,
10414
10459
  terminateOnError = false
10415
10460
  }) {
10416
- var _a22;
10461
+ var _a23;
10417
10462
  let controller;
10418
10463
  let hasErrored = false;
10419
10464
  const outputStream = new ReadableStream({
@@ -10422,7 +10467,7 @@ function readUIMessageStream({
10422
10467
  }
10423
10468
  });
10424
10469
  const state = createStreamingUIMessageState({
10425
- messageId: (_a22 = message == null ? void 0 : message.id) != null ? _a22 : "",
10470
+ messageId: (_a23 = message == null ? void 0 : message.id) != null ? _a23 : "",
10426
10471
  lastMessage: message
10427
10472
  });
10428
10473
  const handleError = (error) => {
@@ -10491,7 +10536,7 @@ async function convertToModelMessages(messages, options) {
10491
10536
  modelMessages.push({
10492
10537
  role: "user",
10493
10538
  content: message.parts.map((part) => {
10494
- var _a22;
10539
+ var _a23;
10495
10540
  if (isTextUIPart(part)) {
10496
10541
  return {
10497
10542
  type: "text",
@@ -10512,7 +10557,7 @@ async function convertToModelMessages(messages, options) {
10512
10557
  };
10513
10558
  }
10514
10559
  if (isDataUIPart(part)) {
10515
- return (_a22 = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _a22.call(
10560
+ return (_a23 = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _a23.call(
10516
10561
  options,
10517
10562
  part
10518
10563
  );
@@ -10525,7 +10570,7 @@ async function convertToModelMessages(messages, options) {
10525
10570
  if (message.parts != null) {
10526
10571
  let block = [];
10527
10572
  async function processBlock() {
10528
- var _a22, _b, _c, _d, _e, _f, _g;
10573
+ var _a23, _b, _c, _d, _e, _f, _g;
10529
10574
  if (block.length === 0) {
10530
10575
  return;
10531
10576
  }
@@ -10574,7 +10619,7 @@ async function convertToModelMessages(messages, options) {
10574
10619
  type: "tool-call",
10575
10620
  toolCallId: part.toolCallId,
10576
10621
  toolName,
10577
- input: part.state === "output-error" ? (_a22 = part.input) != null ? _a22 : "rawInput" in part ? part.rawInput : void 0 : part.input,
10622
+ input: part.state === "output-error" ? (_a23 = part.input) != null ? _a23 : "rawInput" in part ? part.rawInput : void 0 : part.input,
10578
10623
  providerExecuted: part.providerExecuted,
10579
10624
  ...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}
10580
10625
  });
@@ -10625,8 +10670,8 @@ async function convertToModelMessages(messages, options) {
10625
10670
  }
10626
10671
  const toolParts = block.filter(
10627
10672
  (part) => {
10628
- var _a23;
10629
- return isToolUIPart(part) && (part.providerExecuted !== true || ((_a23 = part.approval) == null ? void 0 : _a23.approved) != null);
10673
+ var _a24;
10674
+ return isToolUIPart(part) && (part.providerExecuted !== true || ((_a24 = part.approval) == null ? void 0 : _a24.approved) != null);
10630
10675
  }
10631
10676
  );
10632
10677
  if (toolParts.length > 0) {
@@ -11215,7 +11260,7 @@ async function createAgentUIStream({
11215
11260
  onStepFinish,
11216
11261
  ...uiMessageStreamOptions
11217
11262
  }) {
11218
- var _a22;
11263
+ var _a23;
11219
11264
  const validatedMessages = await validateUIMessages({
11220
11265
  messages: uiMessages,
11221
11266
  // tools are compatible; the casting is required because the context param is
@@ -11234,7 +11279,7 @@ async function createAgentUIStream({
11234
11279
  experimental_transform,
11235
11280
  onStepEnd: onStepEnd != null ? onStepEnd : onStepFinish
11236
11281
  });
11237
- const originalMessages = (_a22 = uiMessageStreamOptions.originalMessages) != null ? _a22 : validatedMessages;
11282
+ const originalMessages = (_a23 = uiMessageStreamOptions.originalMessages) != null ? _a23 : validatedMessages;
11238
11283
  return createAsyncIterableStream(
11239
11284
  toUIMessageStream({
11240
11285
  ...uiMessageStreamOptions,
@@ -11305,7 +11350,7 @@ async function embed({
11305
11350
  experimental_onEnd,
11306
11351
  _internal: { generateCallId = originalGenerateCallId4 } = {}
11307
11352
  }) {
11308
- var _a22;
11353
+ var _a23;
11309
11354
  const model = resolveEmbeddingModel(modelArg);
11310
11355
  const { maxRetries, retry } = prepareRetries({
11311
11356
  maxRetries: maxRetriesArg,
@@ -11321,7 +11366,7 @@ async function embed({
11321
11366
  const telemetryDispatcher = createTelemetryDispatcher({
11322
11367
  telemetry
11323
11368
  });
11324
- const runInTracingChannelSpan = (_a22 = telemetryDispatcher.runInTracingChannelSpan) != null ? _a22 : async ({ execute }) => await execute();
11369
+ const runInTracingChannelSpan = (_a23 = telemetryDispatcher.runInTracingChannelSpan) != null ? _a23 : async ({ execute }) => await execute();
11325
11370
  const startEvent = {
11326
11371
  callId,
11327
11372
  operationId: "ai.embed",
@@ -11336,14 +11381,14 @@ async function embed({
11336
11381
  type: "embed",
11337
11382
  event: startEvent,
11338
11383
  execute: async () => {
11339
- var _a23;
11384
+ var _a24;
11340
11385
  await notify({
11341
11386
  event: startEvent,
11342
11387
  callbacks: [resolvedOnStart, telemetryDispatcher.onStart]
11343
11388
  });
11344
11389
  try {
11345
11390
  const { embedding, usage, warnings, response, providerMetadata } = await retry(async () => {
11346
- var _a24, _b;
11391
+ var _a25, _b;
11347
11392
  const embedCallId = generateCallId();
11348
11393
  await notify({
11349
11394
  event: {
@@ -11363,7 +11408,7 @@ async function embed({
11363
11408
  providerOptions
11364
11409
  });
11365
11410
  const embedding2 = modelResponse.embeddings[0];
11366
- const usage2 = (_a24 = modelResponse.usage) != null ? _a24 : { tokens: NaN };
11411
+ const usage2 = (_a25 = modelResponse.usage) != null ? _a25 : { tokens: NaN };
11367
11412
  await notify({
11368
11413
  event: {
11369
11414
  callId,
@@ -11414,7 +11459,7 @@ async function embed({
11414
11459
  response
11415
11460
  });
11416
11461
  } catch (error) {
11417
- await ((_a23 = telemetryDispatcher.onError) == null ? void 0 : _a23.call(telemetryDispatcher, { callId, error }));
11462
+ await ((_a24 = telemetryDispatcher.onError) == null ? void 0 : _a24.call(telemetryDispatcher, { callId, error }));
11418
11463
  throw error;
11419
11464
  }
11420
11465
  }
@@ -11470,7 +11515,7 @@ async function embedMany({
11470
11515
  experimental_onEnd,
11471
11516
  _internal: { generateCallId = originalGenerateCallId5 } = {}
11472
11517
  }) {
11473
- var _a22;
11518
+ var _a23;
11474
11519
  const model = resolveEmbeddingModel(modelArg);
11475
11520
  const { maxRetries, retry } = prepareRetries({
11476
11521
  maxRetries: maxRetriesArg,
@@ -11486,7 +11531,7 @@ async function embedMany({
11486
11531
  const telemetryDispatcher = createTelemetryDispatcher({
11487
11532
  telemetry
11488
11533
  });
11489
- const runInTracingChannelSpan = (_a22 = telemetryDispatcher.runInTracingChannelSpan) != null ? _a22 : async ({ execute }) => await execute();
11534
+ const runInTracingChannelSpan = (_a23 = telemetryDispatcher.runInTracingChannelSpan) != null ? _a23 : async ({ execute }) => await execute();
11490
11535
  const startEvent = {
11491
11536
  callId,
11492
11537
  operationId: "ai.embedMany",
@@ -11501,7 +11546,7 @@ async function embedMany({
11501
11546
  type: "embedMany",
11502
11547
  event: startEvent,
11503
11548
  execute: async () => {
11504
- var _a23, _b;
11549
+ var _a24, _b;
11505
11550
  await notify({
11506
11551
  event: startEvent,
11507
11552
  callbacks: [resolvedOnStart, telemetryDispatcher.onStart]
@@ -11512,7 +11557,7 @@ async function embedMany({
11512
11557
  );
11513
11558
  if (maxEmbeddingsPerCall == null || maxEmbeddingsPerCall === Infinity) {
11514
11559
  const { embeddings: embeddings2, usage, warnings: warnings2, response, providerMetadata: providerMetadata2 } = await retry(async () => {
11515
- var _a24, _b2;
11560
+ var _a25, _b2;
11516
11561
  const embedCallId = generateCallId();
11517
11562
  await notify({
11518
11563
  event: {
@@ -11532,7 +11577,7 @@ async function embedMany({
11532
11577
  providerOptions
11533
11578
  });
11534
11579
  const embeddings3 = modelResponse.embeddings;
11535
- const usage2 = (_a24 = modelResponse.usage) != null ? _a24 : { tokens: NaN };
11580
+ const usage2 = (_a25 = modelResponse.usage) != null ? _a25 : { tokens: NaN };
11536
11581
  await notify({
11537
11582
  event: {
11538
11583
  callId,
@@ -11597,7 +11642,7 @@ async function embedMany({
11597
11642
  const results = await Promise.all(
11598
11643
  parallelChunk.map((chunk) => {
11599
11644
  return retry(async () => {
11600
- var _a24, _b2;
11645
+ var _a25, _b2;
11601
11646
  const embedCallId = generateCallId();
11602
11647
  await notify({
11603
11648
  event: {
@@ -11617,7 +11662,7 @@ async function embedMany({
11617
11662
  providerOptions
11618
11663
  });
11619
11664
  const chunkEmbeddings = modelResponse.embeddings;
11620
- const usage = (_a24 = modelResponse.usage) != null ? _a24 : { tokens: NaN };
11665
+ const usage = (_a25 = modelResponse.usage) != null ? _a25 : { tokens: NaN };
11621
11666
  await notify({
11622
11667
  event: {
11623
11668
  callId,
@@ -11654,7 +11699,7 @@ async function embedMany({
11654
11699
  result.providerMetadata
11655
11700
  )) {
11656
11701
  providerMetadata[providerName] = {
11657
- ...(_a23 = providerMetadata[providerName]) != null ? _a23 : {},
11702
+ ...(_a24 = providerMetadata[providerName]) != null ? _a24 : {},
11658
11703
  ...metadata
11659
11704
  };
11660
11705
  }
@@ -11764,7 +11809,7 @@ async function generateImage({
11764
11809
  abortSignal,
11765
11810
  headers
11766
11811
  }) {
11767
- var _a22, _b;
11812
+ var _a23, _b;
11768
11813
  const model = resolveImageModel(modelArg);
11769
11814
  const headersWithUserAgent = withUserAgentSuffix6(
11770
11815
  headers != null ? headers : {},
@@ -11774,7 +11819,7 @@ async function generateImage({
11774
11819
  maxRetries: maxRetriesArg,
11775
11820
  abortSignal
11776
11821
  });
11777
- const maxImagesPerCallWithDefault = (_a22 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a22 : 1;
11822
+ const maxImagesPerCallWithDefault = (_a23 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a23 : 1;
11778
11823
  const callCount = Math.ceil(n / maxImagesPerCallWithDefault);
11779
11824
  const callImageCounts = Array.from({ length: callCount }, (_, i) => {
11780
11825
  if (i < callCount - 1) {
@@ -11815,13 +11860,13 @@ async function generateImage({
11815
11860
  images.push(
11816
11861
  ...result.images.map(
11817
11862
  (image) => {
11818
- var _a23;
11863
+ var _a24;
11819
11864
  return new DefaultGeneratedFile({
11820
11865
  data: image,
11821
- mediaType: (_a23 = detectMediaType2({
11866
+ mediaType: (_a24 = detectMediaType2({
11822
11867
  data: image,
11823
11868
  topLevelType: "image"
11824
- })) != null ? _a23 : "image/png"
11869
+ })) != null ? _a24 : "image/png"
11825
11870
  });
11826
11871
  }
11827
11872
  )
@@ -12037,7 +12082,7 @@ var arrayOutputStrategy = (schema) => {
12037
12082
  isFirstDelta,
12038
12083
  isFinalDelta
12039
12084
  }) {
12040
- var _a22;
12085
+ var _a23;
12041
12086
  if (!isJSONObject(value) || !isJSONArray(value.elements)) {
12042
12087
  return {
12043
12088
  success: false,
@@ -12060,7 +12105,7 @@ var arrayOutputStrategy = (schema) => {
12060
12105
  }
12061
12106
  resultArray.push(result.value);
12062
12107
  }
12063
- const publishedElementCount = (_a22 = latestObject == null ? void 0 : latestObject.length) != null ? _a22 : 0;
12108
+ const publishedElementCount = (_a23 = latestObject == null ? void 0 : latestObject.length) != null ? _a23 : 0;
12064
12109
  let textDelta = "";
12065
12110
  if (isFirstDelta) {
12066
12111
  textDelta += "[";
@@ -12404,7 +12449,7 @@ function validateObjectGenerationInput({
12404
12449
  // src/generate-object/generate-object.ts
12405
12450
  var originalGenerateId4 = createIdGenerator6({ prefix: "aiobj", size: 24 });
12406
12451
  async function generateObject(options) {
12407
- var _a22, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12452
+ var _a23, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12408
12453
  const {
12409
12454
  model: modelArg,
12410
12455
  output = "object",
@@ -12538,7 +12583,7 @@ async function generateObject(options) {
12538
12583
  })
12539
12584
  );
12540
12585
  const responseData = {
12541
- id: (_b = (_a22 = generateResult.response) == null ? void 0 : _a22.id) != null ? _b : generateId2(),
12586
+ id: (_b = (_a23 = generateResult.response) == null ? void 0 : _a23.id) != null ? _b : generateId2(),
12542
12587
  timestamp: (_d = (_c = generateResult.response) == null ? void 0 : _c.timestamp) != null ? _d : currentDate(),
12543
12588
  modelId: (_f = (_e = generateResult.response) == null ? void 0 : _e.modelId) != null ? _f : model.modelId,
12544
12589
  headers: (_g = generateResult.response) == null ? void 0 : _g.headers,
@@ -12636,9 +12681,9 @@ var DefaultGenerateObjectResult = class {
12636
12681
  this.reasoning = options.reasoning;
12637
12682
  }
12638
12683
  toJsonResponse(init) {
12639
- var _a22;
12684
+ var _a23;
12640
12685
  return new Response(JSON.stringify(this.object), {
12641
- status: (_a22 = init == null ? void 0 : init.status) != null ? _a22 : 200,
12686
+ status: (_a23 = init == null ? void 0 : init.status) != null ? _a23 : 200,
12642
12687
  headers: prepareHeaders(init == null ? void 0 : init.headers, {
12643
12688
  "content-type": "application/json; charset=utf-8"
12644
12689
  })
@@ -12772,8 +12817,8 @@ function simulateReadableStream({
12772
12817
  chunkDelayInMs = 0,
12773
12818
  _internal
12774
12819
  }) {
12775
- var _a22;
12776
- const delay = (_a22 = _internal == null ? void 0 : _internal.delay) != null ? _a22 : delayFunction;
12820
+ var _a23;
12821
+ const delay = (_a23 = _internal == null ? void 0 : _internal.delay) != null ? _a23 : delayFunction;
12777
12822
  let index = 0;
12778
12823
  return new ReadableStream({
12779
12824
  async pull(controller) {
@@ -13032,7 +13077,7 @@ var DefaultStreamObjectResult = class {
13032
13077
  const transformedStream = stream.pipeThrough(new TransformStream(transformer)).pipeThrough(
13033
13078
  new TransformStream({
13034
13079
  async transform(chunk, controller) {
13035
- var _a22, _b, _c;
13080
+ var _a23, _b, _c;
13036
13081
  if (typeof chunk === "object" && chunk.type === "stream-start") {
13037
13082
  warnings = chunk.warnings;
13038
13083
  return;
@@ -13076,7 +13121,7 @@ var DefaultStreamObjectResult = class {
13076
13121
  switch (chunk.type) {
13077
13122
  case "response-metadata": {
13078
13123
  fullResponse = {
13079
- id: (_a22 = chunk.id) != null ? _a22 : fullResponse.id,
13124
+ id: (_a23 = chunk.id) != null ? _a23 : fullResponse.id,
13080
13125
  timestamp: (_b = chunk.timestamp) != null ? _b : fullResponse.timestamp,
13081
13126
  modelId: (_c = chunk.modelId) != null ? _c : fullResponse.modelId
13082
13127
  };
@@ -13189,8 +13234,8 @@ var DefaultStreamObjectResult = class {
13189
13234
  );
13190
13235
  stitchableStream.addStream(transformedStream);
13191
13236
  })().catch(async (error) => {
13192
- var _a22;
13193
- await ((_a22 = telemetryDispatcher.onError) == null ? void 0 : _a22.call(telemetryDispatcher, { callId, error }));
13237
+ var _a23;
13238
+ await ((_a23 = telemetryDispatcher.onError) == null ? void 0 : _a23.call(telemetryDispatcher, { callId, error }));
13194
13239
  stitchableStream.addStream(
13195
13240
  new ReadableStream({
13196
13241
  start(controller) {
@@ -13337,7 +13382,7 @@ async function generateSpeech({
13337
13382
  abortSignal,
13338
13383
  headers
13339
13384
  }) {
13340
- var _a22;
13385
+ var _a23;
13341
13386
  const resolvedModel = resolveSpeechModel(model);
13342
13387
  if (!resolvedModel) {
13343
13388
  throw new Error("Model could not be resolved");
@@ -13374,10 +13419,10 @@ async function generateSpeech({
13374
13419
  return new DefaultSpeechResult({
13375
13420
  audio: new DefaultGeneratedAudioFile({
13376
13421
  data: result.audio,
13377
- mediaType: (_a22 = detectMediaType3({
13422
+ mediaType: (_a23 = detectMediaType3({
13378
13423
  data: result.audio,
13379
13424
  topLevelType: "audio"
13380
- })) != null ? _a22 : "audio/mp3"
13425
+ })) != null ? _a23 : "audio/mp3"
13381
13426
  }),
13382
13427
  warnings: result.warnings,
13383
13428
  responses: [result.response],
@@ -13386,11 +13431,11 @@ async function generateSpeech({
13386
13431
  }
13387
13432
  var DefaultSpeechResult = class {
13388
13433
  constructor(options) {
13389
- var _a22;
13434
+ var _a23;
13390
13435
  this.audio = options.audio;
13391
13436
  this.warnings = options.warnings;
13392
13437
  this.responses = options.responses;
13393
- this.providerMetadata = (_a22 = options.providerMetadata) != null ? _a22 : {};
13438
+ this.providerMetadata = (_a23 = options.providerMetadata) != null ? _a23 : {};
13394
13439
  }
13395
13440
  };
13396
13441
 
@@ -13604,14 +13649,14 @@ function tagDescription(description) {
13604
13649
  }
13605
13650
  async function fingerprintTools(tools) {
13606
13651
  const entries = await Promise.all(
13607
- Object.keys(tools).map(async (name22) => {
13608
- const tool2 = tools[name22];
13652
+ Object.keys(tools).map(async (name23) => {
13653
+ const tool2 = tools[name23];
13609
13654
  const digest = await hashCanonical({
13610
13655
  description: tagDescription(tool2.description),
13611
13656
  inputSchema: await asSchema6(tool2.inputSchema).jsonSchema,
13612
13657
  title: tool2.title
13613
13658
  });
13614
- return [name22, digest];
13659
+ return [name23, digest];
13615
13660
  })
13616
13661
  );
13617
13662
  return Object.fromEntries(entries);
@@ -13620,16 +13665,16 @@ function detectToolDrift(current, baseline) {
13620
13665
  const added = [];
13621
13666
  const removed = [];
13622
13667
  const changed = [];
13623
- for (const name22 of Object.keys(current)) {
13624
- if (!Object.hasOwn(baseline, name22)) {
13625
- added.push(name22);
13626
- } else if (current[name22] !== baseline[name22]) {
13627
- changed.push(name22);
13668
+ for (const name23 of Object.keys(current)) {
13669
+ if (!Object.hasOwn(baseline, name23)) {
13670
+ added.push(name23);
13671
+ } else if (current[name23] !== baseline[name23]) {
13672
+ changed.push(name23);
13628
13673
  }
13629
13674
  }
13630
- for (const name22 of Object.keys(baseline)) {
13631
- if (!Object.hasOwn(current, name22)) {
13632
- removed.push(name22);
13675
+ for (const name23 of Object.keys(baseline)) {
13676
+ if (!Object.hasOwn(current, name23)) {
13677
+ removed.push(name23);
13633
13678
  }
13634
13679
  }
13635
13680
  return { added, removed, changed };
@@ -13661,7 +13706,7 @@ async function experimental_generateVideo({
13661
13706
  headers,
13662
13707
  download: downloadFn = defaultDownload
13663
13708
  }) {
13664
- var _a22, _b;
13709
+ var _a23, _b;
13665
13710
  const model = resolveVideoModel(modelArg);
13666
13711
  const headersWithUserAgent = withUserAgentSuffix9(
13667
13712
  headers != null ? headers : {},
@@ -13688,9 +13733,9 @@ async function experimental_generateVideo({
13688
13733
  message: "inputReferences were ignored because frameImages were provided; frameImages and inputReferences cannot be combined."
13689
13734
  });
13690
13735
  }
13691
- const firstFrameImage = (_a22 = normalizedFrameImages == null ? void 0 : normalizedFrameImages.find(
13736
+ const firstFrameImage = (_a23 = normalizedFrameImages == null ? void 0 : normalizedFrameImages.find(
13692
13737
  (frame) => frame.frameType === "first_frame"
13693
- )) == null ? void 0 : _a22.image;
13738
+ )) == null ? void 0 : _a23.image;
13694
13739
  if (image != null && firstFrameImage != null) {
13695
13740
  warnings.push({
13696
13741
  type: "other",
@@ -13928,8 +13973,8 @@ function stripMarkdownCodeFenceSuffix(text2) {
13928
13973
  return text2.replace(/\n?```\s*$/, "").trimEnd();
13929
13974
  }
13930
13975
  function extractJsonMiddleware(options) {
13931
- var _a22;
13932
- const transform = (_a22 = options == null ? void 0 : options.transform) != null ? _a22 : defaultTransform;
13976
+ var _a23;
13977
+ const transform = (_a23 = options == null ? void 0 : options.transform) != null ? _a23 : defaultTransform;
13933
13978
  const hasCustomTransform = (options == null ? void 0 : options.transform) !== void 0;
13934
13979
  return {
13935
13980
  specificationVersion: "v4",
@@ -14305,13 +14350,13 @@ function addToolInputExamplesMiddleware({
14305
14350
  return {
14306
14351
  specificationVersion: "v4",
14307
14352
  transformParams: async ({ params }) => {
14308
- var _a22;
14309
- if (!((_a22 = params.tools) == null ? void 0 : _a22.length)) {
14353
+ var _a23;
14354
+ if (!((_a23 = params.tools) == null ? void 0 : _a23.length)) {
14310
14355
  return params;
14311
14356
  }
14312
14357
  const transformedTools = params.tools.map((tool2) => {
14313
- var _a23;
14314
- if (tool2.type !== "function" || !((_a23 = tool2.inputExamples) == null ? void 0 : _a23.length)) {
14358
+ var _a24;
14359
+ if (tool2.type !== "function" || !((_a24 = tool2.inputExamples) == null ? void 0 : _a24.length)) {
14315
14360
  return tool2;
14316
14361
  }
14317
14362
  const formattedExamples = tool2.inputExamples.map((example, index) => format(example, index)).join("\n");
@@ -14360,7 +14405,7 @@ var doWrap = ({
14360
14405
  modelId,
14361
14406
  providerId
14362
14407
  }) => {
14363
- var _a22, _b, _c;
14408
+ var _a23, _b, _c;
14364
14409
  async function doTransform({
14365
14410
  params,
14366
14411
  type
@@ -14369,7 +14414,7 @@ var doWrap = ({
14369
14414
  }
14370
14415
  return {
14371
14416
  specificationVersion: "v4",
14372
- provider: (_a22 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a22 : model.provider,
14417
+ provider: (_a23 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a23 : model.provider,
14373
14418
  modelId: (_b = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b : model.modelId,
14374
14419
  supportedUrls: (_c = overrideSupportedUrls == null ? void 0 : overrideSupportedUrls({ model })) != null ? _c : model.supportedUrls,
14375
14420
  async doGenerate(params) {
@@ -14423,7 +14468,7 @@ var doWrap2 = ({
14423
14468
  modelId,
14424
14469
  providerId
14425
14470
  }) => {
14426
- var _a22, _b, _c, _d;
14471
+ var _a23, _b, _c, _d;
14427
14472
  async function doTransform({
14428
14473
  params
14429
14474
  }) {
@@ -14431,7 +14476,7 @@ var doWrap2 = ({
14431
14476
  }
14432
14477
  return {
14433
14478
  specificationVersion: "v4",
14434
- provider: (_a22 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a22 : model.provider,
14479
+ provider: (_a23 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a23 : model.provider,
14435
14480
  modelId: (_b = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b : model.modelId,
14436
14481
  maxEmbeddingsPerCall: (_c = overrideMaxEmbeddingsPerCall == null ? void 0 : overrideMaxEmbeddingsPerCall({ model })) != null ? _c : model.maxEmbeddingsPerCall,
14437
14482
  supportsParallelCalls: (_d = overrideSupportsParallelCalls == null ? void 0 : overrideSupportsParallelCalls({ model })) != null ? _d : model.supportsParallelCalls,
@@ -14472,11 +14517,11 @@ var doWrap3 = ({
14472
14517
  modelId,
14473
14518
  providerId
14474
14519
  }) => {
14475
- var _a22, _b, _c;
14520
+ var _a23, _b, _c;
14476
14521
  async function doTransform({ params }) {
14477
14522
  return transformParams ? await transformParams({ params, model }) : params;
14478
14523
  }
14479
- const maxImagesPerCallRaw = (_a22 = overrideMaxImagesPerCall == null ? void 0 : overrideMaxImagesPerCall({ model })) != null ? _a22 : model.maxImagesPerCall;
14524
+ const maxImagesPerCallRaw = (_a23 = overrideMaxImagesPerCall == null ? void 0 : overrideMaxImagesPerCall({ model })) != null ? _a23 : model.maxImagesPerCall;
14480
14525
  const maxImagesPerCall = maxImagesPerCallRaw instanceof Function ? maxImagesPerCallRaw.bind(model) : maxImagesPerCallRaw;
14481
14526
  return {
14482
14527
  specificationVersion: "v4",
@@ -14578,7 +14623,7 @@ async function getRealtimeToolDefinitions({
14578
14623
  toolsContext = {}
14579
14624
  }) {
14580
14625
  const definitions = [];
14581
- for (const [name22, tool2] of Object.entries(tools)) {
14626
+ for (const [name23, tool2] of Object.entries(tools)) {
14582
14627
  const toolType = tool2.type;
14583
14628
  switch (toolType) {
14584
14629
  case void 0:
@@ -14586,12 +14631,12 @@ async function getRealtimeToolDefinitions({
14586
14631
  case "dynamic": {
14587
14632
  const description = resolveRealtimeToolDescription({
14588
14633
  tool: tool2,
14589
- toolName: name22,
14634
+ toolName: name23,
14590
14635
  toolsContext
14591
14636
  });
14592
14637
  definitions.push({
14593
14638
  type: "function",
14594
- name: name22,
14639
+ name: name23,
14595
14640
  description,
14596
14641
  parameters: await asSchema7(tool2.inputSchema).jsonSchema
14597
14642
  });
@@ -14665,8 +14710,8 @@ var BrowserRealtimeAudio = class {
14665
14710
  this.onCapturingChange(true);
14666
14711
  }
14667
14712
  stopCapture() {
14668
- var _a22, _b, _c, _d;
14669
- (_a22 = this.captureProcessor) == null ? void 0 : _a22.disconnect();
14713
+ var _a23, _b, _c, _d;
14714
+ (_a23 = this.captureProcessor) == null ? void 0 : _a23.disconnect();
14670
14715
  (_b = this.captureSource) == null ? void 0 : _b.disconnect();
14671
14716
  void ((_c = this.captureContext) == null ? void 0 : _c.close());
14672
14717
  (_d = this.captureStream) == null ? void 0 : _d.getTracks().forEach((track) => track.stop());
@@ -14702,16 +14747,16 @@ var BrowserRealtimeAudio = class {
14702
14747
  return (ctx.currentTime - this.playbackStartTime) * 1e3;
14703
14748
  }
14704
14749
  dispose() {
14705
- var _a22;
14750
+ var _a23;
14706
14751
  this.stopCapture();
14707
14752
  this.stopPlayback();
14708
- void ((_a22 = this.playbackContext) == null ? void 0 : _a22.close());
14753
+ void ((_a23 = this.playbackContext) == null ? void 0 : _a23.close());
14709
14754
  this.playbackContext = null;
14710
14755
  }
14711
14756
  setPlaying(isPlaying) {
14712
- var _a22, _b;
14757
+ var _a23, _b;
14713
14758
  if (isPlaying && !this.isPlaying) {
14714
- this.playbackStartTime = (_b = (_a22 = this.playbackContext) == null ? void 0 : _a22.currentTime) != null ? _b : 0;
14759
+ this.playbackStartTime = (_b = (_a23 = this.playbackContext) == null ? void 0 : _a23.currentTime) != null ? _b : 0;
14715
14760
  }
14716
14761
  if (this.isPlaying !== isPlaying) {
14717
14762
  this.isPlaying = isPlaying;
@@ -14764,8 +14809,8 @@ var BrowserRealtimeTransport = class {
14764
14809
  url,
14765
14810
  onOpen
14766
14811
  }) {
14767
- var _a22;
14768
- (_a22 = this.ws) == null ? void 0 : _a22.close();
14812
+ var _a23;
14813
+ (_a23 = this.ws) == null ? void 0 : _a23.close();
14769
14814
  this.ws = null;
14770
14815
  const wsConfig = this.model.getWebSocketConfig({ token, url });
14771
14816
  const ws = new WebSocket(wsConfig.url, wsConfig.protocols);
@@ -14789,8 +14834,8 @@ var BrowserRealtimeTransport = class {
14789
14834
  };
14790
14835
  }
14791
14836
  disconnect() {
14792
- var _a22;
14793
- (_a22 = this.ws) == null ? void 0 : _a22.close();
14837
+ var _a23;
14838
+ (_a23 = this.ws) == null ? void 0 : _a23.close();
14794
14839
  this.ws = null;
14795
14840
  }
14796
14841
  sendEvent(event) {
@@ -14806,8 +14851,8 @@ var BrowserRealtimeTransport = class {
14806
14851
  });
14807
14852
  }
14808
14853
  sendRaw(data) {
14809
- var _a22;
14810
- if (((_a22 = this.ws) == null ? void 0 : _a22.readyState) === WebSocket.OPEN) {
14854
+ var _a23;
14855
+ if (((_a23 = this.ws) == null ? void 0 : _a23.readyState) === WebSocket.OPEN) {
14811
14856
  if (typeof data === "string" || data instanceof ArrayBuffer || ArrayBuffer.isView(data) || data instanceof Blob) {
14812
14857
  this.ws.send(data);
14813
14858
  } else {
@@ -14900,7 +14945,7 @@ var RealtimeEventReducer = class {
14900
14945
  };
14901
14946
  }
14902
14947
  async reduceServerEvent(state, event) {
14903
- var _a22;
14948
+ var _a23;
14904
14949
  let nextState = this.pushEvent(state, event);
14905
14950
  const effects = [];
14906
14951
  switch (event.type) {
@@ -14967,7 +15012,7 @@ var RealtimeEventReducer = class {
14967
15012
  const { state: updatedState, messageId } = this.getOrCreateAssistantMessage(nextState);
14968
15013
  nextState = updatedState;
14969
15014
  this.toolCallIdToMessageId.set(event.callId, messageId);
14970
- const acc = (_a22 = this.toolArgAccumulators.get(event.callId)) != null ? _a22 : "";
15015
+ const acc = (_a23 = this.toolArgAccumulators.get(event.callId)) != null ? _a23 : "";
14971
15016
  this.toolArgAccumulators.set(event.callId, acc + event.delta);
14972
15017
  nextState = this.ensureToolPart(nextState, messageId, event.callId);
14973
15018
  break;
@@ -15041,7 +15086,7 @@ var RealtimeEventReducer = class {
15041
15086
  };
15042
15087
  }
15043
15088
  addInputTranscriptionMessage(state, itemId, transcript) {
15044
- var _a22;
15089
+ var _a23;
15045
15090
  const messageId = `user-${itemId}`;
15046
15091
  const existingMessage = state.messages.find(
15047
15092
  (message) => message.id === messageId
@@ -15064,7 +15109,7 @@ var RealtimeEventReducer = class {
15064
15109
  };
15065
15110
  }
15066
15111
  const insertIndex = Math.min(
15067
- (_a22 = this.inputAudioMessageInsertIndex.get(itemId)) != null ? _a22 : state.messages.length,
15112
+ (_a23 = this.inputAudioMessageInsertIndex.get(itemId)) != null ? _a23 : state.messages.length,
15068
15113
  state.messages.length
15069
15114
  );
15070
15115
  const messages = [...state.messages];
@@ -15085,9 +15130,9 @@ var RealtimeEventReducer = class {
15085
15130
  };
15086
15131
  }
15087
15132
  appendTextDelta(state, itemId, delta) {
15088
- var _a22;
15133
+ var _a23;
15089
15134
  const { state: stateWithMessage, messageId } = this.getOrCreateAssistantMessage(state);
15090
- const acc = (_a22 = this.textAccumulators.get(itemId)) != null ? _a22 : "";
15135
+ const acc = (_a23 = this.textAccumulators.get(itemId)) != null ? _a23 : "";
15091
15136
  const text2 = acc + delta;
15092
15137
  this.textAccumulators.set(itemId, text2);
15093
15138
  const location = this.itemIdToPartLocation.get(itemId);
@@ -15117,8 +15162,8 @@ var RealtimeEventReducer = class {
15117
15162
  };
15118
15163
  }
15119
15164
  finalizeText(state, itemId, finalText) {
15120
- var _a22;
15121
- const text2 = (_a22 = finalText != null ? finalText : this.textAccumulators.get(itemId)) != null ? _a22 : "";
15165
+ var _a23;
15166
+ const text2 = (_a23 = finalText != null ? finalText : this.textAccumulators.get(itemId)) != null ? _a23 : "";
15122
15167
  this.textAccumulators.delete(itemId);
15123
15168
  const location = this.itemIdToPartLocation.get(itemId);
15124
15169
  if (location == null)
@@ -15158,7 +15203,7 @@ var RealtimeEventReducer = class {
15158
15203
  })
15159
15204
  };
15160
15205
  }
15161
- markToolInputAvailable(state, messageId, callId, name22, input) {
15206
+ markToolInputAvailable(state, messageId, callId, name23, input) {
15162
15207
  return {
15163
15208
  ...state,
15164
15209
  messages: state.messages.map((message) => {
@@ -15174,7 +15219,7 @@ var RealtimeEventReducer = class {
15174
15219
  return part;
15175
15220
  return {
15176
15221
  ...toolPart,
15177
- toolName: name22,
15222
+ toolName: name23,
15178
15223
  state: "input-available",
15179
15224
  input
15180
15225
  };
@@ -15236,11 +15281,11 @@ var AbstractRealtimeSession = class {
15236
15281
  this.toolCallsInResponse = /* @__PURE__ */ new Set();
15237
15282
  this.submittedToolOutputs = /* @__PURE__ */ new Set();
15238
15283
  this.responseToolCallsClosed = false;
15239
- var _a22, _b, _c, _d, _e, _f, _g, _h;
15284
+ var _a23, _b, _c, _d, _e, _f, _g, _h;
15240
15285
  this.model = options.model;
15241
15286
  this.api = options.api;
15242
15287
  this.sessionConfig = options.sessionConfig;
15243
- this.maxEvents = (_a22 = options.maxEvents) != null ? _a22 : 500;
15288
+ this.maxEvents = (_a23 = options.maxEvents) != null ? _a23 : 500;
15244
15289
  this.reducer = new RealtimeEventReducer(this.maxEvents);
15245
15290
  this.onToolCall = options.onToolCall;
15246
15291
  this.onEvent = options.onEvent;
@@ -15252,9 +15297,9 @@ var AbstractRealtimeSession = class {
15252
15297
  model: this.model,
15253
15298
  onServerEvent: (event) => this.handleServerEvent(event),
15254
15299
  onError: (error) => {
15255
- var _a23;
15300
+ var _a24;
15256
15301
  this.applyState(this.reducer.setStatus(this.state, "error"));
15257
- (_a23 = this.onError) == null ? void 0 : _a23.call(this, error);
15302
+ (_a24 = this.onError) == null ? void 0 : _a24.call(this, error);
15258
15303
  },
15259
15304
  onClose: () => {
15260
15305
  this.applyState(this.reducer.setStatus(this.state, "disconnected"));
@@ -15274,7 +15319,7 @@ var AbstractRealtimeSession = class {
15274
15319
  }
15275
15320
  // ── Connection ─────────────────────────────────────────────────────
15276
15321
  async connect() {
15277
- var _a22;
15322
+ var _a23;
15278
15323
  this.applyState(this.reducer.setStatus(this.state, "connecting"));
15279
15324
  try {
15280
15325
  const response = await fetch(this.api.token, {
@@ -15304,7 +15349,7 @@ var AbstractRealtimeSession = class {
15304
15349
  });
15305
15350
  } catch (error) {
15306
15351
  this.applyState(this.reducer.setStatus(this.state, "error"));
15307
- (_a22 = this.onError) == null ? void 0 : _a22.call(
15352
+ (_a23 = this.onError) == null ? void 0 : _a23.call(
15308
15353
  this,
15309
15354
  error instanceof Error ? error : new Error(`Connection failed: ${String(error)}`)
15310
15355
  );
@@ -15430,18 +15475,18 @@ var AbstractRealtimeSession = class {
15430
15475
  }
15431
15476
  }
15432
15477
  async executeToolCall({
15433
- name: name22,
15478
+ name: name23,
15434
15479
  args,
15435
15480
  callId
15436
15481
  }) {
15437
- var _a22, _b;
15482
+ var _a23, _b;
15438
15483
  if (this.onToolCall == null) {
15439
- (_a22 = this.onError) == null ? void 0 : _a22.call(this, new Error(`No handler provided for tool "${name22}"`));
15484
+ (_a23 = this.onError) == null ? void 0 : _a23.call(this, new Error(`No handler provided for tool "${name23}"`));
15440
15485
  return;
15441
15486
  }
15442
15487
  try {
15443
15488
  const result = await this.onToolCall({
15444
- toolCall: { toolCallId: callId, toolName: name22, args }
15489
+ toolCall: { toolCallId: callId, toolName: name23, args }
15445
15490
  });
15446
15491
  if (result !== void 0) {
15447
15492
  this.addToolOutput(callId, result);
@@ -15454,10 +15499,10 @@ var AbstractRealtimeSession = class {
15454
15499
  }
15455
15500
  }
15456
15501
  async handleServerEvent(event) {
15457
- var _a22;
15502
+ var _a23;
15458
15503
  const result = await this.reducer.reduceServerEvent(this.state, event);
15459
15504
  this.applyState(result.state);
15460
- (_a22 = this.onEvent) == null ? void 0 : _a22.call(this, event);
15505
+ (_a23 = this.onEvent) == null ? void 0 : _a23.call(this, event);
15461
15506
  for (const effect of result.effects) {
15462
15507
  this.handleReducerEffect(effect);
15463
15508
  }
@@ -15467,7 +15512,7 @@ var AbstractRealtimeSession = class {
15467
15512
  }
15468
15513
  }
15469
15514
  handleReducerEffect(effect) {
15470
- var _a22;
15515
+ var _a23;
15471
15516
  switch (effect.type) {
15472
15517
  case "play-audio": {
15473
15518
  this.currentResponseItemId = effect.itemId;
@@ -15499,7 +15544,7 @@ var AbstractRealtimeSession = class {
15499
15544
  break;
15500
15545
  }
15501
15546
  case "error": {
15502
- (_a22 = this.onError) == null ? void 0 : _a22.call(this, effect.error);
15547
+ (_a23 = this.onError) == null ? void 0 : _a23.call(this, effect.error);
15503
15548
  break;
15504
15549
  }
15505
15550
  }
@@ -15612,11 +15657,11 @@ function customProvider({
15612
15657
  }
15613
15658
 
15614
15659
  // src/registry/no-such-provider-error.ts
15615
- import { AISDKError as AISDKError24, NoSuchModelError as NoSuchModelError3 } from "@ai-sdk/provider";
15616
- var name21 = "AI_NoSuchProviderError";
15617
- var marker21 = `vercel.ai.error.${name21}`;
15618
- var symbol21 = Symbol.for(marker21);
15619
- var _a21;
15660
+ import { AISDKError as AISDKError25, NoSuchModelError as NoSuchModelError3 } from "@ai-sdk/provider";
15661
+ var name22 = "AI_NoSuchProviderError";
15662
+ var marker22 = `vercel.ai.error.${name22}`;
15663
+ var symbol22 = Symbol.for(marker22);
15664
+ var _a22;
15620
15665
  var NoSuchProviderError = class extends NoSuchModelError3 {
15621
15666
  constructor({
15622
15667
  modelId,
@@ -15625,16 +15670,16 @@ var NoSuchProviderError = class extends NoSuchModelError3 {
15625
15670
  availableProviders,
15626
15671
  message = `No such provider: ${providerId} (available providers: ${availableProviders.join()})`
15627
15672
  }) {
15628
- super({ errorName: name21, modelId, modelType, message });
15629
- this[_a21] = true;
15673
+ super({ errorName: name22, modelId, modelType, message });
15674
+ this[_a22] = true;
15630
15675
  this.providerId = providerId;
15631
15676
  this.availableProviders = availableProviders;
15632
15677
  }
15633
15678
  static isInstance(error) {
15634
- return AISDKError24.hasMarker(error, marker21);
15679
+ return AISDKError25.hasMarker(error, marker22);
15635
15680
  }
15636
15681
  };
15637
- _a21 = symbol21;
15682
+ _a22 = symbol22;
15638
15683
 
15639
15684
  // src/registry/provider-registry.ts
15640
15685
  import {
@@ -15671,9 +15716,9 @@ var DefaultProviderRegistry = class {
15671
15716
  id,
15672
15717
  provider
15673
15718
  }) {
15674
- var _a22;
15719
+ var _a23;
15675
15720
  const providerV4 = asProviderV4(provider);
15676
- const videoModel = (_a22 = provider.videoModel) == null ? void 0 : _a22.bind(provider);
15721
+ const videoModel = (_a23 = provider.videoModel) == null ? void 0 : _a23.bind(provider);
15677
15722
  this.providers[id] = videoModel == null ? providerV4 : Object.assign(Object.create(Object.getPrototypeOf(providerV4)), {
15678
15723
  ...providerV4,
15679
15724
  videoModel: (modelId) => asVideoModelV4(videoModel(modelId))
@@ -15703,10 +15748,10 @@ var DefaultProviderRegistry = class {
15703
15748
  return [id.slice(0, index), id.slice(index + this.separator.length)];
15704
15749
  }
15705
15750
  languageModel(id) {
15706
- var _a22, _b;
15751
+ var _a23, _b;
15707
15752
  const [providerId, modelId] = this.splitId(id, "languageModel");
15708
- let model = (_b = (_a22 = this.getProvider(providerId, "languageModel")).languageModel) == null ? void 0 : _b.call(
15709
- _a22,
15753
+ let model = (_b = (_a23 = this.getProvider(providerId, "languageModel")).languageModel) == null ? void 0 : _b.call(
15754
+ _a23,
15710
15755
  modelId
15711
15756
  );
15712
15757
  if (model == null) {
@@ -15721,10 +15766,10 @@ var DefaultProviderRegistry = class {
15721
15766
  return model;
15722
15767
  }
15723
15768
  embeddingModel(id) {
15724
- var _a22;
15769
+ var _a23;
15725
15770
  const [providerId, modelId] = this.splitId(id, "embeddingModel");
15726
15771
  const provider = this.getProvider(providerId, "embeddingModel");
15727
- const model = (_a22 = provider.embeddingModel) == null ? void 0 : _a22.call(provider, modelId);
15772
+ const model = (_a23 = provider.embeddingModel) == null ? void 0 : _a23.call(provider, modelId);
15728
15773
  if (model == null) {
15729
15774
  throw new NoSuchModelError4({
15730
15775
  modelId: id,
@@ -15734,10 +15779,10 @@ var DefaultProviderRegistry = class {
15734
15779
  return model;
15735
15780
  }
15736
15781
  imageModel(id) {
15737
- var _a22;
15782
+ var _a23;
15738
15783
  const [providerId, modelId] = this.splitId(id, "imageModel");
15739
15784
  const provider = this.getProvider(providerId, "imageModel");
15740
- let model = (_a22 = provider.imageModel) == null ? void 0 : _a22.call(provider, modelId);
15785
+ let model = (_a23 = provider.imageModel) == null ? void 0 : _a23.call(provider, modelId);
15741
15786
  if (model == null) {
15742
15787
  throw new NoSuchModelError4({ modelId: id, modelType: "imageModel" });
15743
15788
  }
@@ -15750,10 +15795,10 @@ var DefaultProviderRegistry = class {
15750
15795
  return model;
15751
15796
  }
15752
15797
  transcriptionModel(id) {
15753
- var _a22;
15798
+ var _a23;
15754
15799
  const [providerId, modelId] = this.splitId(id, "transcriptionModel");
15755
15800
  const provider = this.getProvider(providerId, "transcriptionModel");
15756
- const model = (_a22 = provider.transcriptionModel) == null ? void 0 : _a22.call(provider, modelId);
15801
+ const model = (_a23 = provider.transcriptionModel) == null ? void 0 : _a23.call(provider, modelId);
15757
15802
  if (model == null) {
15758
15803
  throw new NoSuchModelError4({
15759
15804
  modelId: id,
@@ -15763,39 +15808,39 @@ var DefaultProviderRegistry = class {
15763
15808
  return model;
15764
15809
  }
15765
15810
  speechModel(id) {
15766
- var _a22;
15811
+ var _a23;
15767
15812
  const [providerId, modelId] = this.splitId(id, "speechModel");
15768
15813
  const provider = this.getProvider(providerId, "speechModel");
15769
- const model = (_a22 = provider.speechModel) == null ? void 0 : _a22.call(provider, modelId);
15814
+ const model = (_a23 = provider.speechModel) == null ? void 0 : _a23.call(provider, modelId);
15770
15815
  if (model == null) {
15771
15816
  throw new NoSuchModelError4({ modelId: id, modelType: "speechModel" });
15772
15817
  }
15773
15818
  return model;
15774
15819
  }
15775
15820
  rerankingModel(id) {
15776
- var _a22;
15821
+ var _a23;
15777
15822
  const [providerId, modelId] = this.splitId(id, "rerankingModel");
15778
15823
  const provider = this.getProvider(providerId, "rerankingModel");
15779
- const model = (_a22 = provider.rerankingModel) == null ? void 0 : _a22.call(provider, modelId);
15824
+ const model = (_a23 = provider.rerankingModel) == null ? void 0 : _a23.call(provider, modelId);
15780
15825
  if (model == null) {
15781
15826
  throw new NoSuchModelError4({ modelId: id, modelType: "rerankingModel" });
15782
15827
  }
15783
15828
  return model;
15784
15829
  }
15785
15830
  videoModel(id) {
15786
- var _a22;
15831
+ var _a23;
15787
15832
  const [providerId, modelId] = this.splitId(id, "videoModel");
15788
15833
  const provider = this.getProvider(providerId, "videoModel");
15789
- const model = (_a22 = provider.videoModel) == null ? void 0 : _a22.call(provider, modelId);
15834
+ const model = (_a23 = provider.videoModel) == null ? void 0 : _a23.call(provider, modelId);
15790
15835
  if (model == null) {
15791
15836
  throw new NoSuchModelError4({ modelId: id, modelType: "videoModel" });
15792
15837
  }
15793
15838
  return asVideoModelV4(model);
15794
15839
  }
15795
15840
  files(id) {
15796
- var _a22;
15841
+ var _a23;
15797
15842
  const provider = this.getProvider(id, "languageModel");
15798
- const files = (_a22 = provider.files) == null ? void 0 : _a22.call(provider);
15843
+ const files = (_a23 = provider.files) == null ? void 0 : _a23.call(provider);
15799
15844
  if (files == null) {
15800
15845
  throw new Error(
15801
15846
  `The provider "${id}" does not support file uploads. Make sure it exposes a files() method.`
@@ -15804,9 +15849,9 @@ var DefaultProviderRegistry = class {
15804
15849
  return files;
15805
15850
  }
15806
15851
  skills(id) {
15807
- var _a22;
15852
+ var _a23;
15808
15853
  const provider = this.getProvider(id, "languageModel");
15809
- const skills = (_a22 = provider.skills) == null ? void 0 : _a22.call(provider);
15854
+ const skills = (_a23 = provider.skills) == null ? void 0 : _a23.call(provider);
15810
15855
  if (skills == null) {
15811
15856
  throw new Error(
15812
15857
  `The provider "${id}" does not support skills. Make sure it exposes a skills() method.`
@@ -15841,7 +15886,7 @@ async function rerank({
15841
15886
  experimental_onEnd,
15842
15887
  _internal: { generateCallId = originalGenerateCallId6 } = {}
15843
15888
  }) {
15844
- var _a22;
15889
+ var _a23;
15845
15890
  const model = resolveRerankingModel(modelArg);
15846
15891
  const callId = generateCallId();
15847
15892
  const resolvedOnStart = onStart != null ? onStart : experimental_onStart;
@@ -15849,7 +15894,7 @@ async function rerank({
15849
15894
  const telemetryDispatcher = createTelemetryDispatcher({
15850
15895
  telemetry
15851
15896
  });
15852
- const runInTracingChannelSpan = (_a22 = telemetryDispatcher.runInTracingChannelSpan) != null ? _a22 : async ({ execute }) => await execute();
15897
+ const runInTracingChannelSpan = (_a23 = telemetryDispatcher.runInTracingChannelSpan) != null ? _a23 : async ({ execute }) => await execute();
15853
15898
  if (documents.length === 0) {
15854
15899
  await notify({
15855
15900
  event: {
@@ -15915,7 +15960,7 @@ async function rerank({
15915
15960
  type: "rerank",
15916
15961
  event: startEvent,
15917
15962
  execute: async () => {
15918
- var _a23, _b, _c, _d, _e;
15963
+ var _a24, _b, _c, _d, _e;
15919
15964
  await notify({
15920
15965
  event: startEvent,
15921
15966
  callbacks: [resolvedOnStart, telemetryDispatcher.onStart]
@@ -15986,7 +16031,7 @@ async function rerank({
15986
16031
  providerMetadata,
15987
16032
  response: {
15988
16033
  id: response == null ? void 0 : response.id,
15989
- timestamp: (_a23 = response == null ? void 0 : response.timestamp) != null ? _a23 : /* @__PURE__ */ new Date(),
16034
+ timestamp: (_a24 = response == null ? void 0 : response.timestamp) != null ? _a24 : /* @__PURE__ */ new Date(),
15990
16035
  modelId: (_b = response == null ? void 0 : response.modelId) != null ? _b : model.modelId,
15991
16036
  headers: response == null ? void 0 : response.headers,
15992
16037
  body: response == null ? void 0 : response.body
@@ -16059,16 +16104,16 @@ async function transcribe({
16059
16104
  const audioData = audio instanceof URL ? (await downloadFn({ url: audio, abortSignal })).data : convertDataContentToUint8Array(audio);
16060
16105
  const result = await retry(
16061
16106
  () => {
16062
- var _a22;
16107
+ var _a23;
16063
16108
  return resolvedModel.doGenerate({
16064
16109
  audio: audioData,
16065
16110
  abortSignal,
16066
16111
  headers: headersWithUserAgent,
16067
16112
  providerOptions,
16068
- mediaType: (_a22 = detectMediaType5({
16113
+ mediaType: (_a23 = detectMediaType5({
16069
16114
  data: audioData,
16070
16115
  topLevelType: "audio"
16071
- })) != null ? _a22 : "audio/wav"
16116
+ })) != null ? _a23 : "audio/wav"
16072
16117
  });
16073
16118
  }
16074
16119
  );
@@ -16092,14 +16137,14 @@ async function transcribe({
16092
16137
  }
16093
16138
  var DefaultTranscriptionResult = class {
16094
16139
  constructor(options) {
16095
- var _a22;
16140
+ var _a23;
16096
16141
  this.text = options.text;
16097
16142
  this.segments = options.segments;
16098
16143
  this.language = options.language;
16099
16144
  this.durationInSeconds = options.durationInSeconds;
16100
16145
  this.warnings = options.warnings;
16101
16146
  this.responses = options.responses;
16102
- this.providerMetadata = (_a22 = options.providerMetadata) != null ? _a22 : {};
16147
+ this.providerMetadata = (_a23 = options.providerMetadata) != null ? _a23 : {};
16103
16148
  }
16104
16149
  };
16105
16150
 
@@ -16121,12 +16166,12 @@ function streamTranscribe({
16121
16166
  includeRawChunks,
16122
16167
  _internal: { currentDate = () => /* @__PURE__ */ new Date() } = {}
16123
16168
  }) {
16124
- var _a22;
16169
+ var _a23;
16125
16170
  const resolvedModel = resolveTranscriptionModel(model);
16126
16171
  if (!resolvedModel) {
16127
16172
  throw new Error("Model could not be resolved");
16128
16173
  }
16129
- const doStream = (_a22 = resolvedModel.doStream) == null ? void 0 : _a22.bind(resolvedModel);
16174
+ const doStream = (_a23 = resolvedModel.doStream) == null ? void 0 : _a23.bind(resolvedModel);
16130
16175
  if (doStream == null) {
16131
16176
  throw new UnsupportedFunctionalityError4({
16132
16177
  functionality: "streaming transcription",
@@ -16173,7 +16218,7 @@ function streamTranscribe({
16173
16218
  const pipeAbortController = new AbortController();
16174
16219
  const transformer = {
16175
16220
  transform(value, controller) {
16176
- var _a23, _b, _c, _d;
16221
+ var _a24, _b, _c, _d;
16177
16222
  switch (value.type) {
16178
16223
  case "stream-start": {
16179
16224
  resolveWarnings(value.warnings);
@@ -16181,7 +16226,7 @@ function streamTranscribe({
16181
16226
  }
16182
16227
  case "response-metadata": {
16183
16228
  response = {
16184
- timestamp: (_a23 = value.timestamp) != null ? _a23 : currentResponseMetadata().timestamp,
16229
+ timestamp: (_a24 = value.timestamp) != null ? _a24 : currentResponseMetadata().timestamp,
16185
16230
  modelId: (_b = value.modelId) != null ? _b : currentResponseMetadata().modelId,
16186
16231
  headers: (_c = value.headers) != null ? _c : response == null ? void 0 : response.headers
16187
16232
  };
@@ -16229,7 +16274,7 @@ function streamTranscribe({
16229
16274
  };
16230
16275
  const transform = new TransformStream(transformer);
16231
16276
  void (async () => {
16232
- var _a23, _b, _c, _d, _e;
16277
+ var _a24, _b, _c, _d, _e;
16233
16278
  const result = await doStream({
16234
16279
  audio,
16235
16280
  inputAudioFormat,
@@ -16240,7 +16285,7 @@ function streamTranscribe({
16240
16285
  includeRawChunks
16241
16286
  });
16242
16287
  response = {
16243
- timestamp: (_b = (_a23 = result.response) == null ? void 0 : _a23.timestamp) != null ? _b : startedAt,
16288
+ timestamp: (_b = (_a24 = result.response) == null ? void 0 : _a24.timestamp) != null ? _b : startedAt,
16244
16289
  modelId: (_d = (_c = result.response) == null ? void 0 : _c.modelId) != null ? _d : resolvedModel.modelId,
16245
16290
  headers: (_e = result.response) == null ? void 0 : _e.headers
16246
16291
  };
@@ -16315,10 +16360,224 @@ function streamTranscribe({
16315
16360
  // src/transcribe/index.ts
16316
16361
  var experimental_transcribe = transcribe;
16317
16362
 
16363
+ // src/translate/stream-translate.ts
16364
+ import {
16365
+ DelayedPromise as DelayedPromise4,
16366
+ withUserAgentSuffix as withUserAgentSuffix12
16367
+ } from "@ai-sdk/provider-utils";
16368
+ function streamTranslate({
16369
+ model,
16370
+ audio,
16371
+ inputAudioFormat,
16372
+ targetLanguage,
16373
+ sourceLanguage,
16374
+ outputAudioFormat,
16375
+ providerOptions = {},
16376
+ abortSignal,
16377
+ headers,
16378
+ includeRawChunks,
16379
+ _internal: { currentDate = () => /* @__PURE__ */ new Date() } = {}
16380
+ }) {
16381
+ const resolvedModel = resolveSpeechTranslationModel(model);
16382
+ const doStream = resolvedModel.doStream.bind(resolvedModel);
16383
+ const headersWithUserAgent = withUserAgentSuffix12(
16384
+ headers != null ? headers : {},
16385
+ `ai/${VERSION}`
16386
+ );
16387
+ const sourceTextPromise = new DelayedPromise4();
16388
+ const translationTextPromise = new DelayedPromise4();
16389
+ const durationInSecondsPromise = new DelayedPromise4();
16390
+ const usagePromise = new DelayedPromise4();
16391
+ const warningsPromise = new DelayedPromise4();
16392
+ const responsePromise = new DelayedPromise4();
16393
+ const providerMetadataPromise = new DelayedPromise4();
16394
+ const rejectPendingPromises = (error) => {
16395
+ for (const promise of [
16396
+ sourceTextPromise,
16397
+ translationTextPromise,
16398
+ durationInSecondsPromise,
16399
+ usagePromise,
16400
+ warningsPromise,
16401
+ responsePromise,
16402
+ providerMetadataPromise
16403
+ ]) {
16404
+ if (promise.isPending()) {
16405
+ promise.reject(error);
16406
+ }
16407
+ }
16408
+ };
16409
+ const startedAt = currentDate();
16410
+ let response;
16411
+ const currentResponseMetadata = () => response != null ? response : { timestamp: startedAt, modelId: resolvedModel.modelId };
16412
+ const resolveWarnings = (warnings) => {
16413
+ warningsPromise.resolve(warnings);
16414
+ logWarnings({
16415
+ warnings,
16416
+ provider: resolvedModel.provider,
16417
+ model: resolvedModel.modelId
16418
+ });
16419
+ };
16420
+ const pipeAbortController = new AbortController();
16421
+ let hasAudioOutput = false;
16422
+ const transformer = {
16423
+ transform(value, controller) {
16424
+ var _a23, _b, _c, _d;
16425
+ switch (value.type) {
16426
+ case "stream-start": {
16427
+ resolveWarnings(value.warnings);
16428
+ break;
16429
+ }
16430
+ case "response-metadata": {
16431
+ response = {
16432
+ timestamp: (_a23 = value.timestamp) != null ? _a23 : currentResponseMetadata().timestamp,
16433
+ modelId: (_b = value.modelId) != null ? _b : currentResponseMetadata().modelId,
16434
+ headers: (_c = value.headers) != null ? _c : response == null ? void 0 : response.headers
16435
+ };
16436
+ break;
16437
+ }
16438
+ case "audio": {
16439
+ hasAudioOutput = true;
16440
+ controller.enqueue(value);
16441
+ break;
16442
+ }
16443
+ case "output-text-delta":
16444
+ case "output-text-final":
16445
+ case "source-transcript-delta":
16446
+ case "source-transcript-partial":
16447
+ case "source-transcript-final":
16448
+ case "raw":
16449
+ case "error": {
16450
+ controller.enqueue(value);
16451
+ break;
16452
+ }
16453
+ case "finish": {
16454
+ if (!warningsPromise.isResolved()) {
16455
+ resolveWarnings([]);
16456
+ }
16457
+ if (!hasAudioOutput && !value.outputText) {
16458
+ throw new NoTranslationGeneratedError({
16459
+ response: currentResponseMetadata()
16460
+ });
16461
+ }
16462
+ sourceTextPromise.resolve(value.sourceText);
16463
+ translationTextPromise.resolve(value.outputText);
16464
+ durationInSecondsPromise.resolve(value.durationInSeconds);
16465
+ usagePromise.resolve(value.usage);
16466
+ responsePromise.resolve(currentResponseMetadata());
16467
+ providerMetadataPromise.resolve((_d = value.providerMetadata) != null ? _d : {});
16468
+ break;
16469
+ }
16470
+ default: {
16471
+ const _exhaustiveCheck = value;
16472
+ throw new Error(`Unsupported part type: ${_exhaustiveCheck}`);
16473
+ }
16474
+ }
16475
+ },
16476
+ flush() {
16477
+ if (translationTextPromise.isPending()) {
16478
+ throw new NoTranslationGeneratedError({
16479
+ response: currentResponseMetadata()
16480
+ });
16481
+ }
16482
+ },
16483
+ cancel(reason) {
16484
+ pipeAbortController.abort(
16485
+ reason != null ? reason : new Error("Translation stream was cancelled.")
16486
+ );
16487
+ }
16488
+ };
16489
+ const transform = new TransformStream(transformer);
16490
+ void (async () => {
16491
+ var _a23, _b, _c, _d, _e;
16492
+ const result = await doStream({
16493
+ audio,
16494
+ inputAudioFormat,
16495
+ targetLanguage,
16496
+ sourceLanguage,
16497
+ outputAudioFormat,
16498
+ providerOptions,
16499
+ // merged so cancelling fullStream also aborts a still-pending doStream
16500
+ abortSignal: mergeAbortSignals(abortSignal, pipeAbortController.signal),
16501
+ headers: headersWithUserAgent,
16502
+ includeRawChunks
16503
+ });
16504
+ response = {
16505
+ timestamp: (_b = (_a23 = result.response) == null ? void 0 : _a23.timestamp) != null ? _b : startedAt,
16506
+ modelId: (_d = (_c = result.response) == null ? void 0 : _c.modelId) != null ? _d : resolvedModel.modelId,
16507
+ headers: (_e = result.response) == null ? void 0 : _e.headers
16508
+ };
16509
+ await result.stream.pipeTo(transform.writable, {
16510
+ signal: pipeAbortController.signal
16511
+ });
16512
+ })().catch((error) => {
16513
+ const reason = error != null ? error : new Error("Translation stream was cancelled or errored.");
16514
+ rejectPendingPromises(reason);
16515
+ audio.cancel(reason).catch(() => {
16516
+ });
16517
+ transform.writable.abort(reason).catch(() => {
16518
+ });
16519
+ });
16520
+ let streamOwner = "unclaimed";
16521
+ function consumeStream2() {
16522
+ if (streamOwner === "full-stream" || streamOwner === "result-promises") {
16523
+ return;
16524
+ }
16525
+ streamOwner = "result-promises";
16526
+ const reader = transform.readable.getReader();
16527
+ void (async () => {
16528
+ while (!(await reader.read()).done) {
16529
+ }
16530
+ })().catch(() => {
16531
+ });
16532
+ }
16533
+ function getFullStream() {
16534
+ if (streamOwner !== "unclaimed") {
16535
+ throw new Error(
16536
+ streamOwner === "full-stream" ? "fullStream can only be accessed once." : "fullStream cannot be accessed after a result promise."
16537
+ );
16538
+ }
16539
+ streamOwner = "full-stream";
16540
+ return asAsyncIterableStream(transform.readable);
16541
+ }
16542
+ return {
16543
+ get sourceText() {
16544
+ consumeStream2();
16545
+ return sourceTextPromise.promise;
16546
+ },
16547
+ get translationText() {
16548
+ consumeStream2();
16549
+ return translationTextPromise.promise;
16550
+ },
16551
+ get durationInSeconds() {
16552
+ consumeStream2();
16553
+ return durationInSecondsPromise.promise;
16554
+ },
16555
+ get usage() {
16556
+ consumeStream2();
16557
+ return usagePromise.promise;
16558
+ },
16559
+ get warnings() {
16560
+ consumeStream2();
16561
+ return warningsPromise.promise;
16562
+ },
16563
+ get response() {
16564
+ consumeStream2();
16565
+ return responsePromise.promise;
16566
+ },
16567
+ get providerMetadata() {
16568
+ consumeStream2();
16569
+ return providerMetadataPromise.promise;
16570
+ },
16571
+ get fullStream() {
16572
+ return getFullStream();
16573
+ }
16574
+ };
16575
+ }
16576
+
16318
16577
  // src/ui/call-completion-api.ts
16319
16578
  import {
16320
16579
  parseJsonEventStream,
16321
- withUserAgentSuffix as withUserAgentSuffix12,
16580
+ withUserAgentSuffix as withUserAgentSuffix13,
16322
16581
  getRuntimeEnvironmentUserAgent as getRuntimeEnvironmentUserAgent2
16323
16582
  } from "@ai-sdk/provider-utils";
16324
16583
 
@@ -16354,7 +16613,7 @@ async function callCompletionApi({
16354
16613
  onError,
16355
16614
  fetch: fetch2 = getOriginalFetch()
16356
16615
  }) {
16357
- var _a22;
16616
+ var _a23;
16358
16617
  try {
16359
16618
  setLoading(true);
16360
16619
  setError(void 0);
@@ -16368,7 +16627,7 @@ async function callCompletionApi({
16368
16627
  ...body
16369
16628
  }),
16370
16629
  credentials,
16371
- headers: withUserAgentSuffix12(
16630
+ headers: withUserAgentSuffix13(
16372
16631
  {
16373
16632
  "Content-Type": "application/json",
16374
16633
  ...headers
@@ -16382,7 +16641,7 @@ async function callCompletionApi({
16382
16641
  });
16383
16642
  if (!response.ok) {
16384
16643
  throw new Error(
16385
- (_a22 = await response.text()) != null ? _a22 : "Failed to fetch the chat response."
16644
+ (_a23 = await response.text()) != null ? _a23 : "Failed to fetch the chat response."
16386
16645
  );
16387
16646
  }
16388
16647
  if (!response.body) {
@@ -16468,12 +16727,12 @@ async function convertFileListToFileUIParts(files) {
16468
16727
  }
16469
16728
  return Promise.all(
16470
16729
  Array.from(files).map(async (file) => {
16471
- const { name: name22, type } = file;
16730
+ const { name: name23, type } = file;
16472
16731
  const dataUrl = await new Promise((resolve3, reject) => {
16473
16732
  const reader = new FileReader();
16474
16733
  reader.onload = (readerEvent) => {
16475
- var _a22;
16476
- resolve3((_a22 = readerEvent.target) == null ? void 0 : _a22.result);
16734
+ var _a23;
16735
+ resolve3((_a23 = readerEvent.target) == null ? void 0 : _a23.result);
16477
16736
  };
16478
16737
  reader.onerror = (error) => reject(error);
16479
16738
  reader.readAsDataURL(file);
@@ -16481,7 +16740,7 @@ async function convertFileListToFileUIParts(files) {
16481
16740
  return {
16482
16741
  type: "file",
16483
16742
  mediaType: type,
16484
- filename: name22,
16743
+ filename: name23,
16485
16744
  url: dataUrl
16486
16745
  };
16487
16746
  })
@@ -16518,7 +16777,7 @@ var HttpChatTransport = class {
16518
16777
  abortSignal,
16519
16778
  ...options
16520
16779
  }) {
16521
- var _a22, _b, _c, _d, _e;
16780
+ var _a23, _b, _c, _d, _e;
16522
16781
  const resolvedBody = await resolve2(this.body);
16523
16782
  const resolvedHeaders = await resolve2(this.headers);
16524
16783
  const resolvedCredentials = await resolve2(this.credentials);
@@ -16526,7 +16785,7 @@ var HttpChatTransport = class {
16526
16785
  ...normalizeHeaders(resolvedHeaders),
16527
16786
  ...normalizeHeaders(options.headers)
16528
16787
  };
16529
- const preparedRequest = await ((_a22 = this.prepareSendMessagesRequest) == null ? void 0 : _a22.call(this, {
16788
+ const preparedRequest = await ((_a23 = this.prepareSendMessagesRequest) == null ? void 0 : _a23.call(this, {
16530
16789
  api: this.api,
16531
16790
  id: options.chatId,
16532
16791
  messages: options.messages,
@@ -16570,7 +16829,7 @@ var HttpChatTransport = class {
16570
16829
  return this.processResponseStream(response.body);
16571
16830
  }
16572
16831
  async reconnectToStream(options) {
16573
- var _a22, _b, _c, _d, _e;
16832
+ var _a23, _b, _c, _d, _e;
16574
16833
  const resolvedBody = await resolve2(this.body);
16575
16834
  const resolvedHeaders = await resolve2(this.headers);
16576
16835
  const resolvedCredentials = await resolve2(this.credentials);
@@ -16578,7 +16837,7 @@ var HttpChatTransport = class {
16578
16837
  ...normalizeHeaders(resolvedHeaders),
16579
16838
  ...normalizeHeaders(options.headers)
16580
16839
  };
16581
- const preparedRequest = await ((_a22 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a22.call(this, {
16840
+ const preparedRequest = await ((_a23 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a23.call(this, {
16582
16841
  api: this.api,
16583
16842
  id: options.chatId,
16584
16843
  body: { ...resolvedBody, ...options.body },
@@ -16656,11 +16915,11 @@ var AbstractChat = class {
16656
16915
  * If a messageId is provided, the message will be replaced.
16657
16916
  */
16658
16917
  this.sendMessage = async (message, options) => {
16659
- var _a22, _b, _c, _d;
16918
+ var _a23, _b, _c, _d;
16660
16919
  if (message == null) {
16661
16920
  await this.makeRequest({
16662
16921
  trigger: "submit-message",
16663
- messageId: (_a22 = this.lastMessage) == null ? void 0 : _a22.id,
16922
+ messageId: (_a23 = this.lastMessage) == null ? void 0 : _a23.id,
16664
16923
  ...options
16665
16924
  });
16666
16925
  return;
@@ -16770,11 +17029,11 @@ var AbstractChat = class {
16770
17029
  }
16771
17030
  if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
16772
17031
  this.shouldSendAutomatically().then((shouldSend) => {
16773
- var _a22;
17032
+ var _a23;
16774
17033
  if (shouldSend) {
16775
17034
  this.makeRequest({
16776
17035
  trigger: "submit-message",
16777
- messageId: (_a22 = this.lastMessage) == null ? void 0 : _a22.id,
17036
+ messageId: (_a23 = this.lastMessage) == null ? void 0 : _a23.id,
16778
17037
  ...options
16779
17038
  });
16780
17039
  }
@@ -16800,11 +17059,11 @@ var AbstractChat = class {
16800
17059
  }
16801
17060
  if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
16802
17061
  this.shouldSendAutomatically().then((shouldSend) => {
16803
- var _a22;
17062
+ var _a23;
16804
17063
  if (shouldSend) {
16805
17064
  this.makeRequest({
16806
17065
  trigger: "submit-message",
16807
- messageId: (_a22 = this.lastMessage) == null ? void 0 : _a22.id,
17066
+ messageId: (_a23 = this.lastMessage) == null ? void 0 : _a23.id,
16808
17067
  ...options
16809
17068
  });
16810
17069
  }
@@ -16817,10 +17076,10 @@ var AbstractChat = class {
16817
17076
  * Abort the current request immediately, keep the generated tokens if any.
16818
17077
  */
16819
17078
  this.stop = async () => {
16820
- var _a22;
17079
+ var _a23;
16821
17080
  if (this.status !== "streaming" && this.status !== "submitted")
16822
17081
  return;
16823
- if ((_a22 = this.activeResponse) == null ? void 0 : _a22.abortController) {
17082
+ if ((_a23 = this.activeResponse) == null ? void 0 : _a23.abortController) {
16824
17083
  this.activeResponse.abortController.abort();
16825
17084
  }
16826
17085
  };
@@ -16886,7 +17145,7 @@ var AbstractChat = class {
16886
17145
  body,
16887
17146
  messageId
16888
17147
  }) {
16889
- var _a22, _b;
17148
+ var _a23, _b;
16890
17149
  let resumeStream;
16891
17150
  if (trigger === "resume-stream") {
16892
17151
  try {
@@ -16948,9 +17207,9 @@ var AbstractChat = class {
16948
17207
  () => job({
16949
17208
  state: response.state,
16950
17209
  write: () => {
16951
- var _a23;
17210
+ var _a24;
16952
17211
  this.setStatus({ status: "streaming" });
16953
- const replaceLastMessage = response.state.message.id === ((_a23 = this.lastMessage) == null ? void 0 : _a23.id);
17212
+ const replaceLastMessage = response.state.message.id === ((_a24 = this.lastMessage) == null ? void 0 : _a24.id);
16954
17213
  if (replaceLastMessage) {
16955
17214
  this.state.replaceMessage(
16956
17215
  this.state.messages.length - 1,
@@ -16997,7 +17256,7 @@ var AbstractChat = class {
16997
17256
  } finally {
16998
17257
  try {
16999
17258
  if (activeResponse) {
17000
- (_a22 = this.onFinish) == null ? void 0 : _a22.call(this, {
17259
+ (_a23 = this.onFinish) == null ? void 0 : _a23.call(this, {
17001
17260
  message: activeResponse.state.message,
17002
17261
  messages: this.state.messages,
17003
17262
  isAbort,
@@ -17162,9 +17421,9 @@ async function uploadFile({
17162
17421
  filename,
17163
17422
  providerOptions
17164
17423
  }) {
17165
- var _a22;
17424
+ var _a23;
17166
17425
  const data = dataArg instanceof Uint8Array || typeof dataArg === "string" ? { type: "data", data: dataArg } : dataArg;
17167
- const mediaType = mediaTypeArg != null ? mediaTypeArg : data.type === "text" ? "text/plain" : (_a22 = detectMediaType6({ data: data.data })) != null ? _a22 : isLikelyText(data.data) ? "text/plain" : "application/octet-stream";
17426
+ const mediaType = mediaTypeArg != null ? mediaTypeArg : data.type === "text" ? "text/plain" : (_a23 = detectMediaType6({ data: data.data })) != null ? _a23 : isLikelyText(data.data) ? "text/plain" : "application/octet-stream";
17168
17427
  const filesApi = "uploadFile" in api ? api : typeof api.files === "function" ? api.files() : (() => {
17169
17428
  throw new Error(
17170
17429
  "The provider does not support file uploads. Make sure it exposes a files() method."
@@ -17235,7 +17494,7 @@ async function uploadSkill({
17235
17494
  return result;
17236
17495
  }
17237
17496
  export {
17238
- AISDKError22 as AISDKError,
17497
+ AISDKError23 as AISDKError,
17239
17498
  AI_SDK_TELEMETRY_TRACING_CHANNEL,
17240
17499
  APICallError,
17241
17500
  AbstractChat,
@@ -17272,6 +17531,7 @@ export {
17272
17531
  NoSuchProviderReferenceError,
17273
17532
  NoSuchToolError,
17274
17533
  NoTranscriptGeneratedError,
17534
+ NoTranslationGeneratedError,
17275
17535
  NoVideoGeneratedError,
17276
17536
  output_exports as Output,
17277
17537
  RetryError,
@@ -17321,6 +17581,7 @@ export {
17321
17581
  resampleAudio as experimental_resampleAudio,
17322
17582
  streamLanguageModelCall as experimental_streamLanguageModelCall,
17323
17583
  streamTranscribe as experimental_streamTranscribe,
17584
+ streamTranslate as experimental_streamTranslate,
17324
17585
  experimental_transcribe,
17325
17586
  extractJsonMiddleware,
17326
17587
  extractReasoningMiddleware,