ai 7.0.37 → 7.0.39

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 (37) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/index.d.ts +283 -41
  3. package/dist/index.js +688 -425
  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-agents/07-workflow-agent.mdx +3 -2
  11. package/docs/03-ai-sdk-core/36-transcription.mdx +40 -35
  12. package/docs/03-ai-sdk-core/36-translation.mdx +209 -0
  13. package/docs/03-ai-sdk-core/index.mdx +5 -0
  14. package/docs/03-ai-sdk-harnesses/06-workflow-utilities.mdx +225 -122
  15. package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +1 -1
  16. package/docs/07-reference/01-ai-sdk-core/11-stream-translate.mdx +176 -0
  17. package/docs/07-reference/01-ai-sdk-core/index.mdx +5 -0
  18. package/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +11 -4
  19. package/docs/07-reference/05-ai-sdk-errors/ai-no-translation-generated-error.mdx +26 -0
  20. package/docs/07-reference/05-ai-sdk-errors/index.mdx +1 -0
  21. package/package.json +4 -4
  22. package/src/error/index.ts +1 -0
  23. package/src/error/no-translation-generated-error.ts +28 -0
  24. package/src/generate-object/generate-object.ts +12 -2
  25. package/src/generate-object/stream-object.ts +14 -1
  26. package/src/generate-text/generate-text.ts +4 -1
  27. package/src/generate-text/stream-language-model-call.ts +14 -12
  28. package/src/generate-text/stream-text-result.ts +3 -2
  29. package/src/index.ts +1 -0
  30. package/src/model/resolve-model.ts +35 -0
  31. package/src/test/mock-speech-translation-model-v4.ts +24 -0
  32. package/src/transcribe/stream-transcribe.ts +2 -11
  33. package/src/translate/index.ts +5 -0
  34. package/src/translate/stream-translate-result.ts +146 -0
  35. package/src/translate/stream-translate.ts +374 -0
  36. package/src/types/speech-translation-model-response-metadata.ts +22 -0
  37. 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.39" : "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",
@@ -12416,7 +12461,8 @@ async function generateObject(options) {
12416
12461
  maxRetries: maxRetriesArg,
12417
12462
  abortSignal,
12418
12463
  headers,
12419
- experimental_repairText: repairText,
12464
+ experimental_repairText,
12465
+ repairText = experimental_repairText,
12420
12466
  experimental_telemetry,
12421
12467
  telemetry = experimental_telemetry,
12422
12468
  experimental_download: download2,
@@ -12538,7 +12584,7 @@ async function generateObject(options) {
12538
12584
  })
12539
12585
  );
12540
12586
  const responseData = {
12541
- id: (_b = (_a22 = generateResult.response) == null ? void 0 : _a22.id) != null ? _b : generateId2(),
12587
+ id: (_b = (_a23 = generateResult.response) == null ? void 0 : _a23.id) != null ? _b : generateId2(),
12542
12588
  timestamp: (_d = (_c = generateResult.response) == null ? void 0 : _c.timestamp) != null ? _d : currentDate(),
12543
12589
  modelId: (_f = (_e = generateResult.response) == null ? void 0 : _e.modelId) != null ? _f : model.modelId,
12544
12590
  headers: (_g = generateResult.response) == null ? void 0 : _g.headers,
@@ -12636,9 +12682,9 @@ var DefaultGenerateObjectResult = class {
12636
12682
  this.reasoning = options.reasoning;
12637
12683
  }
12638
12684
  toJsonResponse(init) {
12639
- var _a22;
12685
+ var _a23;
12640
12686
  return new Response(JSON.stringify(this.object), {
12641
- status: (_a22 = init == null ? void 0 : init.status) != null ? _a22 : 200,
12687
+ status: (_a23 = init == null ? void 0 : init.status) != null ? _a23 : 200,
12642
12688
  headers: prepareHeaders(init == null ? void 0 : init.headers, {
12643
12689
  "content-type": "application/json; charset=utf-8"
12644
12690
  })
@@ -12772,8 +12818,8 @@ function simulateReadableStream({
12772
12818
  chunkDelayInMs = 0,
12773
12819
  _internal
12774
12820
  }) {
12775
- var _a22;
12776
- const delay = (_a22 = _internal == null ? void 0 : _internal.delay) != null ? _a22 : delayFunction;
12821
+ var _a23;
12822
+ const delay = (_a23 = _internal == null ? void 0 : _internal.delay) != null ? _a23 : delayFunction;
12777
12823
  let index = 0;
12778
12824
  return new ReadableStream({
12779
12825
  async pull(controller) {
@@ -12801,7 +12847,8 @@ function streamObject(options) {
12801
12847
  maxRetries,
12802
12848
  abortSignal,
12803
12849
  headers,
12804
- experimental_repairText: repairText,
12850
+ experimental_repairText,
12851
+ repairText = experimental_repairText,
12805
12852
  experimental_telemetry,
12806
12853
  telemetry = experimental_telemetry,
12807
12854
  experimental_download: download2,
@@ -13032,7 +13079,7 @@ var DefaultStreamObjectResult = class {
13032
13079
  const transformedStream = stream.pipeThrough(new TransformStream(transformer)).pipeThrough(
13033
13080
  new TransformStream({
13034
13081
  async transform(chunk, controller) {
13035
- var _a22, _b, _c;
13082
+ var _a23, _b, _c;
13036
13083
  if (typeof chunk === "object" && chunk.type === "stream-start") {
13037
13084
  warnings = chunk.warnings;
13038
13085
  return;
@@ -13076,7 +13123,7 @@ var DefaultStreamObjectResult = class {
13076
13123
  switch (chunk.type) {
13077
13124
  case "response-metadata": {
13078
13125
  fullResponse = {
13079
- id: (_a22 = chunk.id) != null ? _a22 : fullResponse.id,
13126
+ id: (_a23 = chunk.id) != null ? _a23 : fullResponse.id,
13080
13127
  timestamp: (_b = chunk.timestamp) != null ? _b : fullResponse.timestamp,
13081
13128
  modelId: (_c = chunk.modelId) != null ? _c : fullResponse.modelId
13082
13129
  };
@@ -13189,8 +13236,8 @@ var DefaultStreamObjectResult = class {
13189
13236
  );
13190
13237
  stitchableStream.addStream(transformedStream);
13191
13238
  })().catch(async (error) => {
13192
- var _a22;
13193
- await ((_a22 = telemetryDispatcher.onError) == null ? void 0 : _a22.call(telemetryDispatcher, { callId, error }));
13239
+ var _a23;
13240
+ await ((_a23 = telemetryDispatcher.onError) == null ? void 0 : _a23.call(telemetryDispatcher, { callId, error }));
13194
13241
  stitchableStream.addStream(
13195
13242
  new ReadableStream({
13196
13243
  start(controller) {
@@ -13337,7 +13384,7 @@ async function generateSpeech({
13337
13384
  abortSignal,
13338
13385
  headers
13339
13386
  }) {
13340
- var _a22;
13387
+ var _a23;
13341
13388
  const resolvedModel = resolveSpeechModel(model);
13342
13389
  if (!resolvedModel) {
13343
13390
  throw new Error("Model could not be resolved");
@@ -13374,10 +13421,10 @@ async function generateSpeech({
13374
13421
  return new DefaultSpeechResult({
13375
13422
  audio: new DefaultGeneratedAudioFile({
13376
13423
  data: result.audio,
13377
- mediaType: (_a22 = detectMediaType3({
13424
+ mediaType: (_a23 = detectMediaType3({
13378
13425
  data: result.audio,
13379
13426
  topLevelType: "audio"
13380
- })) != null ? _a22 : "audio/mp3"
13427
+ })) != null ? _a23 : "audio/mp3"
13381
13428
  }),
13382
13429
  warnings: result.warnings,
13383
13430
  responses: [result.response],
@@ -13386,11 +13433,11 @@ async function generateSpeech({
13386
13433
  }
13387
13434
  var DefaultSpeechResult = class {
13388
13435
  constructor(options) {
13389
- var _a22;
13436
+ var _a23;
13390
13437
  this.audio = options.audio;
13391
13438
  this.warnings = options.warnings;
13392
13439
  this.responses = options.responses;
13393
- this.providerMetadata = (_a22 = options.providerMetadata) != null ? _a22 : {};
13440
+ this.providerMetadata = (_a23 = options.providerMetadata) != null ? _a23 : {};
13394
13441
  }
13395
13442
  };
13396
13443
 
@@ -13604,14 +13651,14 @@ function tagDescription(description) {
13604
13651
  }
13605
13652
  async function fingerprintTools(tools) {
13606
13653
  const entries = await Promise.all(
13607
- Object.keys(tools).map(async (name22) => {
13608
- const tool2 = tools[name22];
13654
+ Object.keys(tools).map(async (name23) => {
13655
+ const tool2 = tools[name23];
13609
13656
  const digest = await hashCanonical({
13610
13657
  description: tagDescription(tool2.description),
13611
13658
  inputSchema: await asSchema6(tool2.inputSchema).jsonSchema,
13612
13659
  title: tool2.title
13613
13660
  });
13614
- return [name22, digest];
13661
+ return [name23, digest];
13615
13662
  })
13616
13663
  );
13617
13664
  return Object.fromEntries(entries);
@@ -13620,16 +13667,16 @@ function detectToolDrift(current, baseline) {
13620
13667
  const added = [];
13621
13668
  const removed = [];
13622
13669
  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);
13670
+ for (const name23 of Object.keys(current)) {
13671
+ if (!Object.hasOwn(baseline, name23)) {
13672
+ added.push(name23);
13673
+ } else if (current[name23] !== baseline[name23]) {
13674
+ changed.push(name23);
13628
13675
  }
13629
13676
  }
13630
- for (const name22 of Object.keys(baseline)) {
13631
- if (!Object.hasOwn(current, name22)) {
13632
- removed.push(name22);
13677
+ for (const name23 of Object.keys(baseline)) {
13678
+ if (!Object.hasOwn(current, name23)) {
13679
+ removed.push(name23);
13633
13680
  }
13634
13681
  }
13635
13682
  return { added, removed, changed };
@@ -13661,7 +13708,7 @@ async function experimental_generateVideo({
13661
13708
  headers,
13662
13709
  download: downloadFn = defaultDownload
13663
13710
  }) {
13664
- var _a22, _b;
13711
+ var _a23, _b;
13665
13712
  const model = resolveVideoModel(modelArg);
13666
13713
  const headersWithUserAgent = withUserAgentSuffix9(
13667
13714
  headers != null ? headers : {},
@@ -13688,9 +13735,9 @@ async function experimental_generateVideo({
13688
13735
  message: "inputReferences were ignored because frameImages were provided; frameImages and inputReferences cannot be combined."
13689
13736
  });
13690
13737
  }
13691
- const firstFrameImage = (_a22 = normalizedFrameImages == null ? void 0 : normalizedFrameImages.find(
13738
+ const firstFrameImage = (_a23 = normalizedFrameImages == null ? void 0 : normalizedFrameImages.find(
13692
13739
  (frame) => frame.frameType === "first_frame"
13693
- )) == null ? void 0 : _a22.image;
13740
+ )) == null ? void 0 : _a23.image;
13694
13741
  if (image != null && firstFrameImage != null) {
13695
13742
  warnings.push({
13696
13743
  type: "other",
@@ -13928,8 +13975,8 @@ function stripMarkdownCodeFenceSuffix(text2) {
13928
13975
  return text2.replace(/\n?```\s*$/, "").trimEnd();
13929
13976
  }
13930
13977
  function extractJsonMiddleware(options) {
13931
- var _a22;
13932
- const transform = (_a22 = options == null ? void 0 : options.transform) != null ? _a22 : defaultTransform;
13978
+ var _a23;
13979
+ const transform = (_a23 = options == null ? void 0 : options.transform) != null ? _a23 : defaultTransform;
13933
13980
  const hasCustomTransform = (options == null ? void 0 : options.transform) !== void 0;
13934
13981
  return {
13935
13982
  specificationVersion: "v4",
@@ -14305,13 +14352,13 @@ function addToolInputExamplesMiddleware({
14305
14352
  return {
14306
14353
  specificationVersion: "v4",
14307
14354
  transformParams: async ({ params }) => {
14308
- var _a22;
14309
- if (!((_a22 = params.tools) == null ? void 0 : _a22.length)) {
14355
+ var _a23;
14356
+ if (!((_a23 = params.tools) == null ? void 0 : _a23.length)) {
14310
14357
  return params;
14311
14358
  }
14312
14359
  const transformedTools = params.tools.map((tool2) => {
14313
- var _a23;
14314
- if (tool2.type !== "function" || !((_a23 = tool2.inputExamples) == null ? void 0 : _a23.length)) {
14360
+ var _a24;
14361
+ if (tool2.type !== "function" || !((_a24 = tool2.inputExamples) == null ? void 0 : _a24.length)) {
14315
14362
  return tool2;
14316
14363
  }
14317
14364
  const formattedExamples = tool2.inputExamples.map((example, index) => format(example, index)).join("\n");
@@ -14360,7 +14407,7 @@ var doWrap = ({
14360
14407
  modelId,
14361
14408
  providerId
14362
14409
  }) => {
14363
- var _a22, _b, _c;
14410
+ var _a23, _b, _c;
14364
14411
  async function doTransform({
14365
14412
  params,
14366
14413
  type
@@ -14369,7 +14416,7 @@ var doWrap = ({
14369
14416
  }
14370
14417
  return {
14371
14418
  specificationVersion: "v4",
14372
- provider: (_a22 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a22 : model.provider,
14419
+ provider: (_a23 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a23 : model.provider,
14373
14420
  modelId: (_b = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b : model.modelId,
14374
14421
  supportedUrls: (_c = overrideSupportedUrls == null ? void 0 : overrideSupportedUrls({ model })) != null ? _c : model.supportedUrls,
14375
14422
  async doGenerate(params) {
@@ -14423,7 +14470,7 @@ var doWrap2 = ({
14423
14470
  modelId,
14424
14471
  providerId
14425
14472
  }) => {
14426
- var _a22, _b, _c, _d;
14473
+ var _a23, _b, _c, _d;
14427
14474
  async function doTransform({
14428
14475
  params
14429
14476
  }) {
@@ -14431,7 +14478,7 @@ var doWrap2 = ({
14431
14478
  }
14432
14479
  return {
14433
14480
  specificationVersion: "v4",
14434
- provider: (_a22 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a22 : model.provider,
14481
+ provider: (_a23 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a23 : model.provider,
14435
14482
  modelId: (_b = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b : model.modelId,
14436
14483
  maxEmbeddingsPerCall: (_c = overrideMaxEmbeddingsPerCall == null ? void 0 : overrideMaxEmbeddingsPerCall({ model })) != null ? _c : model.maxEmbeddingsPerCall,
14437
14484
  supportsParallelCalls: (_d = overrideSupportsParallelCalls == null ? void 0 : overrideSupportsParallelCalls({ model })) != null ? _d : model.supportsParallelCalls,
@@ -14472,11 +14519,11 @@ var doWrap3 = ({
14472
14519
  modelId,
14473
14520
  providerId
14474
14521
  }) => {
14475
- var _a22, _b, _c;
14522
+ var _a23, _b, _c;
14476
14523
  async function doTransform({ params }) {
14477
14524
  return transformParams ? await transformParams({ params, model }) : params;
14478
14525
  }
14479
- const maxImagesPerCallRaw = (_a22 = overrideMaxImagesPerCall == null ? void 0 : overrideMaxImagesPerCall({ model })) != null ? _a22 : model.maxImagesPerCall;
14526
+ const maxImagesPerCallRaw = (_a23 = overrideMaxImagesPerCall == null ? void 0 : overrideMaxImagesPerCall({ model })) != null ? _a23 : model.maxImagesPerCall;
14480
14527
  const maxImagesPerCall = maxImagesPerCallRaw instanceof Function ? maxImagesPerCallRaw.bind(model) : maxImagesPerCallRaw;
14481
14528
  return {
14482
14529
  specificationVersion: "v4",
@@ -14578,7 +14625,7 @@ async function getRealtimeToolDefinitions({
14578
14625
  toolsContext = {}
14579
14626
  }) {
14580
14627
  const definitions = [];
14581
- for (const [name22, tool2] of Object.entries(tools)) {
14628
+ for (const [name23, tool2] of Object.entries(tools)) {
14582
14629
  const toolType = tool2.type;
14583
14630
  switch (toolType) {
14584
14631
  case void 0:
@@ -14586,12 +14633,12 @@ async function getRealtimeToolDefinitions({
14586
14633
  case "dynamic": {
14587
14634
  const description = resolveRealtimeToolDescription({
14588
14635
  tool: tool2,
14589
- toolName: name22,
14636
+ toolName: name23,
14590
14637
  toolsContext
14591
14638
  });
14592
14639
  definitions.push({
14593
14640
  type: "function",
14594
- name: name22,
14641
+ name: name23,
14595
14642
  description,
14596
14643
  parameters: await asSchema7(tool2.inputSchema).jsonSchema
14597
14644
  });
@@ -14665,8 +14712,8 @@ var BrowserRealtimeAudio = class {
14665
14712
  this.onCapturingChange(true);
14666
14713
  }
14667
14714
  stopCapture() {
14668
- var _a22, _b, _c, _d;
14669
- (_a22 = this.captureProcessor) == null ? void 0 : _a22.disconnect();
14715
+ var _a23, _b, _c, _d;
14716
+ (_a23 = this.captureProcessor) == null ? void 0 : _a23.disconnect();
14670
14717
  (_b = this.captureSource) == null ? void 0 : _b.disconnect();
14671
14718
  void ((_c = this.captureContext) == null ? void 0 : _c.close());
14672
14719
  (_d = this.captureStream) == null ? void 0 : _d.getTracks().forEach((track) => track.stop());
@@ -14702,16 +14749,16 @@ var BrowserRealtimeAudio = class {
14702
14749
  return (ctx.currentTime - this.playbackStartTime) * 1e3;
14703
14750
  }
14704
14751
  dispose() {
14705
- var _a22;
14752
+ var _a23;
14706
14753
  this.stopCapture();
14707
14754
  this.stopPlayback();
14708
- void ((_a22 = this.playbackContext) == null ? void 0 : _a22.close());
14755
+ void ((_a23 = this.playbackContext) == null ? void 0 : _a23.close());
14709
14756
  this.playbackContext = null;
14710
14757
  }
14711
14758
  setPlaying(isPlaying) {
14712
- var _a22, _b;
14759
+ var _a23, _b;
14713
14760
  if (isPlaying && !this.isPlaying) {
14714
- this.playbackStartTime = (_b = (_a22 = this.playbackContext) == null ? void 0 : _a22.currentTime) != null ? _b : 0;
14761
+ this.playbackStartTime = (_b = (_a23 = this.playbackContext) == null ? void 0 : _a23.currentTime) != null ? _b : 0;
14715
14762
  }
14716
14763
  if (this.isPlaying !== isPlaying) {
14717
14764
  this.isPlaying = isPlaying;
@@ -14764,8 +14811,8 @@ var BrowserRealtimeTransport = class {
14764
14811
  url,
14765
14812
  onOpen
14766
14813
  }) {
14767
- var _a22;
14768
- (_a22 = this.ws) == null ? void 0 : _a22.close();
14814
+ var _a23;
14815
+ (_a23 = this.ws) == null ? void 0 : _a23.close();
14769
14816
  this.ws = null;
14770
14817
  const wsConfig = this.model.getWebSocketConfig({ token, url });
14771
14818
  const ws = new WebSocket(wsConfig.url, wsConfig.protocols);
@@ -14789,8 +14836,8 @@ var BrowserRealtimeTransport = class {
14789
14836
  };
14790
14837
  }
14791
14838
  disconnect() {
14792
- var _a22;
14793
- (_a22 = this.ws) == null ? void 0 : _a22.close();
14839
+ var _a23;
14840
+ (_a23 = this.ws) == null ? void 0 : _a23.close();
14794
14841
  this.ws = null;
14795
14842
  }
14796
14843
  sendEvent(event) {
@@ -14806,8 +14853,8 @@ var BrowserRealtimeTransport = class {
14806
14853
  });
14807
14854
  }
14808
14855
  sendRaw(data) {
14809
- var _a22;
14810
- if (((_a22 = this.ws) == null ? void 0 : _a22.readyState) === WebSocket.OPEN) {
14856
+ var _a23;
14857
+ if (((_a23 = this.ws) == null ? void 0 : _a23.readyState) === WebSocket.OPEN) {
14811
14858
  if (typeof data === "string" || data instanceof ArrayBuffer || ArrayBuffer.isView(data) || data instanceof Blob) {
14812
14859
  this.ws.send(data);
14813
14860
  } else {
@@ -14900,7 +14947,7 @@ var RealtimeEventReducer = class {
14900
14947
  };
14901
14948
  }
14902
14949
  async reduceServerEvent(state, event) {
14903
- var _a22;
14950
+ var _a23;
14904
14951
  let nextState = this.pushEvent(state, event);
14905
14952
  const effects = [];
14906
14953
  switch (event.type) {
@@ -14967,7 +15014,7 @@ var RealtimeEventReducer = class {
14967
15014
  const { state: updatedState, messageId } = this.getOrCreateAssistantMessage(nextState);
14968
15015
  nextState = updatedState;
14969
15016
  this.toolCallIdToMessageId.set(event.callId, messageId);
14970
- const acc = (_a22 = this.toolArgAccumulators.get(event.callId)) != null ? _a22 : "";
15017
+ const acc = (_a23 = this.toolArgAccumulators.get(event.callId)) != null ? _a23 : "";
14971
15018
  this.toolArgAccumulators.set(event.callId, acc + event.delta);
14972
15019
  nextState = this.ensureToolPart(nextState, messageId, event.callId);
14973
15020
  break;
@@ -15041,7 +15088,7 @@ var RealtimeEventReducer = class {
15041
15088
  };
15042
15089
  }
15043
15090
  addInputTranscriptionMessage(state, itemId, transcript) {
15044
- var _a22;
15091
+ var _a23;
15045
15092
  const messageId = `user-${itemId}`;
15046
15093
  const existingMessage = state.messages.find(
15047
15094
  (message) => message.id === messageId
@@ -15064,7 +15111,7 @@ var RealtimeEventReducer = class {
15064
15111
  };
15065
15112
  }
15066
15113
  const insertIndex = Math.min(
15067
- (_a22 = this.inputAudioMessageInsertIndex.get(itemId)) != null ? _a22 : state.messages.length,
15114
+ (_a23 = this.inputAudioMessageInsertIndex.get(itemId)) != null ? _a23 : state.messages.length,
15068
15115
  state.messages.length
15069
15116
  );
15070
15117
  const messages = [...state.messages];
@@ -15085,9 +15132,9 @@ var RealtimeEventReducer = class {
15085
15132
  };
15086
15133
  }
15087
15134
  appendTextDelta(state, itemId, delta) {
15088
- var _a22;
15135
+ var _a23;
15089
15136
  const { state: stateWithMessage, messageId } = this.getOrCreateAssistantMessage(state);
15090
- const acc = (_a22 = this.textAccumulators.get(itemId)) != null ? _a22 : "";
15137
+ const acc = (_a23 = this.textAccumulators.get(itemId)) != null ? _a23 : "";
15091
15138
  const text2 = acc + delta;
15092
15139
  this.textAccumulators.set(itemId, text2);
15093
15140
  const location = this.itemIdToPartLocation.get(itemId);
@@ -15117,8 +15164,8 @@ var RealtimeEventReducer = class {
15117
15164
  };
15118
15165
  }
15119
15166
  finalizeText(state, itemId, finalText) {
15120
- var _a22;
15121
- const text2 = (_a22 = finalText != null ? finalText : this.textAccumulators.get(itemId)) != null ? _a22 : "";
15167
+ var _a23;
15168
+ const text2 = (_a23 = finalText != null ? finalText : this.textAccumulators.get(itemId)) != null ? _a23 : "";
15122
15169
  this.textAccumulators.delete(itemId);
15123
15170
  const location = this.itemIdToPartLocation.get(itemId);
15124
15171
  if (location == null)
@@ -15158,7 +15205,7 @@ var RealtimeEventReducer = class {
15158
15205
  })
15159
15206
  };
15160
15207
  }
15161
- markToolInputAvailable(state, messageId, callId, name22, input) {
15208
+ markToolInputAvailable(state, messageId, callId, name23, input) {
15162
15209
  return {
15163
15210
  ...state,
15164
15211
  messages: state.messages.map((message) => {
@@ -15174,7 +15221,7 @@ var RealtimeEventReducer = class {
15174
15221
  return part;
15175
15222
  return {
15176
15223
  ...toolPart,
15177
- toolName: name22,
15224
+ toolName: name23,
15178
15225
  state: "input-available",
15179
15226
  input
15180
15227
  };
@@ -15236,11 +15283,11 @@ var AbstractRealtimeSession = class {
15236
15283
  this.toolCallsInResponse = /* @__PURE__ */ new Set();
15237
15284
  this.submittedToolOutputs = /* @__PURE__ */ new Set();
15238
15285
  this.responseToolCallsClosed = false;
15239
- var _a22, _b, _c, _d, _e, _f, _g, _h;
15286
+ var _a23, _b, _c, _d, _e, _f, _g, _h;
15240
15287
  this.model = options.model;
15241
15288
  this.api = options.api;
15242
15289
  this.sessionConfig = options.sessionConfig;
15243
- this.maxEvents = (_a22 = options.maxEvents) != null ? _a22 : 500;
15290
+ this.maxEvents = (_a23 = options.maxEvents) != null ? _a23 : 500;
15244
15291
  this.reducer = new RealtimeEventReducer(this.maxEvents);
15245
15292
  this.onToolCall = options.onToolCall;
15246
15293
  this.onEvent = options.onEvent;
@@ -15252,9 +15299,9 @@ var AbstractRealtimeSession = class {
15252
15299
  model: this.model,
15253
15300
  onServerEvent: (event) => this.handleServerEvent(event),
15254
15301
  onError: (error) => {
15255
- var _a23;
15302
+ var _a24;
15256
15303
  this.applyState(this.reducer.setStatus(this.state, "error"));
15257
- (_a23 = this.onError) == null ? void 0 : _a23.call(this, error);
15304
+ (_a24 = this.onError) == null ? void 0 : _a24.call(this, error);
15258
15305
  },
15259
15306
  onClose: () => {
15260
15307
  this.applyState(this.reducer.setStatus(this.state, "disconnected"));
@@ -15274,7 +15321,7 @@ var AbstractRealtimeSession = class {
15274
15321
  }
15275
15322
  // ── Connection ─────────────────────────────────────────────────────
15276
15323
  async connect() {
15277
- var _a22;
15324
+ var _a23;
15278
15325
  this.applyState(this.reducer.setStatus(this.state, "connecting"));
15279
15326
  try {
15280
15327
  const response = await fetch(this.api.token, {
@@ -15304,7 +15351,7 @@ var AbstractRealtimeSession = class {
15304
15351
  });
15305
15352
  } catch (error) {
15306
15353
  this.applyState(this.reducer.setStatus(this.state, "error"));
15307
- (_a22 = this.onError) == null ? void 0 : _a22.call(
15354
+ (_a23 = this.onError) == null ? void 0 : _a23.call(
15308
15355
  this,
15309
15356
  error instanceof Error ? error : new Error(`Connection failed: ${String(error)}`)
15310
15357
  );
@@ -15430,18 +15477,18 @@ var AbstractRealtimeSession = class {
15430
15477
  }
15431
15478
  }
15432
15479
  async executeToolCall({
15433
- name: name22,
15480
+ name: name23,
15434
15481
  args,
15435
15482
  callId
15436
15483
  }) {
15437
- var _a22, _b;
15484
+ var _a23, _b;
15438
15485
  if (this.onToolCall == null) {
15439
- (_a22 = this.onError) == null ? void 0 : _a22.call(this, new Error(`No handler provided for tool "${name22}"`));
15486
+ (_a23 = this.onError) == null ? void 0 : _a23.call(this, new Error(`No handler provided for tool "${name23}"`));
15440
15487
  return;
15441
15488
  }
15442
15489
  try {
15443
15490
  const result = await this.onToolCall({
15444
- toolCall: { toolCallId: callId, toolName: name22, args }
15491
+ toolCall: { toolCallId: callId, toolName: name23, args }
15445
15492
  });
15446
15493
  if (result !== void 0) {
15447
15494
  this.addToolOutput(callId, result);
@@ -15454,10 +15501,10 @@ var AbstractRealtimeSession = class {
15454
15501
  }
15455
15502
  }
15456
15503
  async handleServerEvent(event) {
15457
- var _a22;
15504
+ var _a23;
15458
15505
  const result = await this.reducer.reduceServerEvent(this.state, event);
15459
15506
  this.applyState(result.state);
15460
- (_a22 = this.onEvent) == null ? void 0 : _a22.call(this, event);
15507
+ (_a23 = this.onEvent) == null ? void 0 : _a23.call(this, event);
15461
15508
  for (const effect of result.effects) {
15462
15509
  this.handleReducerEffect(effect);
15463
15510
  }
@@ -15467,7 +15514,7 @@ var AbstractRealtimeSession = class {
15467
15514
  }
15468
15515
  }
15469
15516
  handleReducerEffect(effect) {
15470
- var _a22;
15517
+ var _a23;
15471
15518
  switch (effect.type) {
15472
15519
  case "play-audio": {
15473
15520
  this.currentResponseItemId = effect.itemId;
@@ -15499,7 +15546,7 @@ var AbstractRealtimeSession = class {
15499
15546
  break;
15500
15547
  }
15501
15548
  case "error": {
15502
- (_a22 = this.onError) == null ? void 0 : _a22.call(this, effect.error);
15549
+ (_a23 = this.onError) == null ? void 0 : _a23.call(this, effect.error);
15503
15550
  break;
15504
15551
  }
15505
15552
  }
@@ -15612,11 +15659,11 @@ function customProvider({
15612
15659
  }
15613
15660
 
15614
15661
  // 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;
15662
+ import { AISDKError as AISDKError25, NoSuchModelError as NoSuchModelError3 } from "@ai-sdk/provider";
15663
+ var name22 = "AI_NoSuchProviderError";
15664
+ var marker22 = `vercel.ai.error.${name22}`;
15665
+ var symbol22 = Symbol.for(marker22);
15666
+ var _a22;
15620
15667
  var NoSuchProviderError = class extends NoSuchModelError3 {
15621
15668
  constructor({
15622
15669
  modelId,
@@ -15625,16 +15672,16 @@ var NoSuchProviderError = class extends NoSuchModelError3 {
15625
15672
  availableProviders,
15626
15673
  message = `No such provider: ${providerId} (available providers: ${availableProviders.join()})`
15627
15674
  }) {
15628
- super({ errorName: name21, modelId, modelType, message });
15629
- this[_a21] = true;
15675
+ super({ errorName: name22, modelId, modelType, message });
15676
+ this[_a22] = true;
15630
15677
  this.providerId = providerId;
15631
15678
  this.availableProviders = availableProviders;
15632
15679
  }
15633
15680
  static isInstance(error) {
15634
- return AISDKError24.hasMarker(error, marker21);
15681
+ return AISDKError25.hasMarker(error, marker22);
15635
15682
  }
15636
15683
  };
15637
- _a21 = symbol21;
15684
+ _a22 = symbol22;
15638
15685
 
15639
15686
  // src/registry/provider-registry.ts
15640
15687
  import {
@@ -15671,9 +15718,9 @@ var DefaultProviderRegistry = class {
15671
15718
  id,
15672
15719
  provider
15673
15720
  }) {
15674
- var _a22;
15721
+ var _a23;
15675
15722
  const providerV4 = asProviderV4(provider);
15676
- const videoModel = (_a22 = provider.videoModel) == null ? void 0 : _a22.bind(provider);
15723
+ const videoModel = (_a23 = provider.videoModel) == null ? void 0 : _a23.bind(provider);
15677
15724
  this.providers[id] = videoModel == null ? providerV4 : Object.assign(Object.create(Object.getPrototypeOf(providerV4)), {
15678
15725
  ...providerV4,
15679
15726
  videoModel: (modelId) => asVideoModelV4(videoModel(modelId))
@@ -15703,10 +15750,10 @@ var DefaultProviderRegistry = class {
15703
15750
  return [id.slice(0, index), id.slice(index + this.separator.length)];
15704
15751
  }
15705
15752
  languageModel(id) {
15706
- var _a22, _b;
15753
+ var _a23, _b;
15707
15754
  const [providerId, modelId] = this.splitId(id, "languageModel");
15708
- let model = (_b = (_a22 = this.getProvider(providerId, "languageModel")).languageModel) == null ? void 0 : _b.call(
15709
- _a22,
15755
+ let model = (_b = (_a23 = this.getProvider(providerId, "languageModel")).languageModel) == null ? void 0 : _b.call(
15756
+ _a23,
15710
15757
  modelId
15711
15758
  );
15712
15759
  if (model == null) {
@@ -15721,10 +15768,10 @@ var DefaultProviderRegistry = class {
15721
15768
  return model;
15722
15769
  }
15723
15770
  embeddingModel(id) {
15724
- var _a22;
15771
+ var _a23;
15725
15772
  const [providerId, modelId] = this.splitId(id, "embeddingModel");
15726
15773
  const provider = this.getProvider(providerId, "embeddingModel");
15727
- const model = (_a22 = provider.embeddingModel) == null ? void 0 : _a22.call(provider, modelId);
15774
+ const model = (_a23 = provider.embeddingModel) == null ? void 0 : _a23.call(provider, modelId);
15728
15775
  if (model == null) {
15729
15776
  throw new NoSuchModelError4({
15730
15777
  modelId: id,
@@ -15734,10 +15781,10 @@ var DefaultProviderRegistry = class {
15734
15781
  return model;
15735
15782
  }
15736
15783
  imageModel(id) {
15737
- var _a22;
15784
+ var _a23;
15738
15785
  const [providerId, modelId] = this.splitId(id, "imageModel");
15739
15786
  const provider = this.getProvider(providerId, "imageModel");
15740
- let model = (_a22 = provider.imageModel) == null ? void 0 : _a22.call(provider, modelId);
15787
+ let model = (_a23 = provider.imageModel) == null ? void 0 : _a23.call(provider, modelId);
15741
15788
  if (model == null) {
15742
15789
  throw new NoSuchModelError4({ modelId: id, modelType: "imageModel" });
15743
15790
  }
@@ -15750,10 +15797,10 @@ var DefaultProviderRegistry = class {
15750
15797
  return model;
15751
15798
  }
15752
15799
  transcriptionModel(id) {
15753
- var _a22;
15800
+ var _a23;
15754
15801
  const [providerId, modelId] = this.splitId(id, "transcriptionModel");
15755
15802
  const provider = this.getProvider(providerId, "transcriptionModel");
15756
- const model = (_a22 = provider.transcriptionModel) == null ? void 0 : _a22.call(provider, modelId);
15803
+ const model = (_a23 = provider.transcriptionModel) == null ? void 0 : _a23.call(provider, modelId);
15757
15804
  if (model == null) {
15758
15805
  throw new NoSuchModelError4({
15759
15806
  modelId: id,
@@ -15763,39 +15810,39 @@ var DefaultProviderRegistry = class {
15763
15810
  return model;
15764
15811
  }
15765
15812
  speechModel(id) {
15766
- var _a22;
15813
+ var _a23;
15767
15814
  const [providerId, modelId] = this.splitId(id, "speechModel");
15768
15815
  const provider = this.getProvider(providerId, "speechModel");
15769
- const model = (_a22 = provider.speechModel) == null ? void 0 : _a22.call(provider, modelId);
15816
+ const model = (_a23 = provider.speechModel) == null ? void 0 : _a23.call(provider, modelId);
15770
15817
  if (model == null) {
15771
15818
  throw new NoSuchModelError4({ modelId: id, modelType: "speechModel" });
15772
15819
  }
15773
15820
  return model;
15774
15821
  }
15775
15822
  rerankingModel(id) {
15776
- var _a22;
15823
+ var _a23;
15777
15824
  const [providerId, modelId] = this.splitId(id, "rerankingModel");
15778
15825
  const provider = this.getProvider(providerId, "rerankingModel");
15779
- const model = (_a22 = provider.rerankingModel) == null ? void 0 : _a22.call(provider, modelId);
15826
+ const model = (_a23 = provider.rerankingModel) == null ? void 0 : _a23.call(provider, modelId);
15780
15827
  if (model == null) {
15781
15828
  throw new NoSuchModelError4({ modelId: id, modelType: "rerankingModel" });
15782
15829
  }
15783
15830
  return model;
15784
15831
  }
15785
15832
  videoModel(id) {
15786
- var _a22;
15833
+ var _a23;
15787
15834
  const [providerId, modelId] = this.splitId(id, "videoModel");
15788
15835
  const provider = this.getProvider(providerId, "videoModel");
15789
- const model = (_a22 = provider.videoModel) == null ? void 0 : _a22.call(provider, modelId);
15836
+ const model = (_a23 = provider.videoModel) == null ? void 0 : _a23.call(provider, modelId);
15790
15837
  if (model == null) {
15791
15838
  throw new NoSuchModelError4({ modelId: id, modelType: "videoModel" });
15792
15839
  }
15793
15840
  return asVideoModelV4(model);
15794
15841
  }
15795
15842
  files(id) {
15796
- var _a22;
15843
+ var _a23;
15797
15844
  const provider = this.getProvider(id, "languageModel");
15798
- const files = (_a22 = provider.files) == null ? void 0 : _a22.call(provider);
15845
+ const files = (_a23 = provider.files) == null ? void 0 : _a23.call(provider);
15799
15846
  if (files == null) {
15800
15847
  throw new Error(
15801
15848
  `The provider "${id}" does not support file uploads. Make sure it exposes a files() method.`
@@ -15804,9 +15851,9 @@ var DefaultProviderRegistry = class {
15804
15851
  return files;
15805
15852
  }
15806
15853
  skills(id) {
15807
- var _a22;
15854
+ var _a23;
15808
15855
  const provider = this.getProvider(id, "languageModel");
15809
- const skills = (_a22 = provider.skills) == null ? void 0 : _a22.call(provider);
15856
+ const skills = (_a23 = provider.skills) == null ? void 0 : _a23.call(provider);
15810
15857
  if (skills == null) {
15811
15858
  throw new Error(
15812
15859
  `The provider "${id}" does not support skills. Make sure it exposes a skills() method.`
@@ -15841,7 +15888,7 @@ async function rerank({
15841
15888
  experimental_onEnd,
15842
15889
  _internal: { generateCallId = originalGenerateCallId6 } = {}
15843
15890
  }) {
15844
- var _a22;
15891
+ var _a23;
15845
15892
  const model = resolveRerankingModel(modelArg);
15846
15893
  const callId = generateCallId();
15847
15894
  const resolvedOnStart = onStart != null ? onStart : experimental_onStart;
@@ -15849,7 +15896,7 @@ async function rerank({
15849
15896
  const telemetryDispatcher = createTelemetryDispatcher({
15850
15897
  telemetry
15851
15898
  });
15852
- const runInTracingChannelSpan = (_a22 = telemetryDispatcher.runInTracingChannelSpan) != null ? _a22 : async ({ execute }) => await execute();
15899
+ const runInTracingChannelSpan = (_a23 = telemetryDispatcher.runInTracingChannelSpan) != null ? _a23 : async ({ execute }) => await execute();
15853
15900
  if (documents.length === 0) {
15854
15901
  await notify({
15855
15902
  event: {
@@ -15915,7 +15962,7 @@ async function rerank({
15915
15962
  type: "rerank",
15916
15963
  event: startEvent,
15917
15964
  execute: async () => {
15918
- var _a23, _b, _c, _d, _e;
15965
+ var _a24, _b, _c, _d, _e;
15919
15966
  await notify({
15920
15967
  event: startEvent,
15921
15968
  callbacks: [resolvedOnStart, telemetryDispatcher.onStart]
@@ -15986,7 +16033,7 @@ async function rerank({
15986
16033
  providerMetadata,
15987
16034
  response: {
15988
16035
  id: response == null ? void 0 : response.id,
15989
- timestamp: (_a23 = response == null ? void 0 : response.timestamp) != null ? _a23 : /* @__PURE__ */ new Date(),
16036
+ timestamp: (_a24 = response == null ? void 0 : response.timestamp) != null ? _a24 : /* @__PURE__ */ new Date(),
15990
16037
  modelId: (_b = response == null ? void 0 : response.modelId) != null ? _b : model.modelId,
15991
16038
  headers: response == null ? void 0 : response.headers,
15992
16039
  body: response == null ? void 0 : response.body
@@ -16059,16 +16106,16 @@ async function transcribe({
16059
16106
  const audioData = audio instanceof URL ? (await downloadFn({ url: audio, abortSignal })).data : convertDataContentToUint8Array(audio);
16060
16107
  const result = await retry(
16061
16108
  () => {
16062
- var _a22;
16109
+ var _a23;
16063
16110
  return resolvedModel.doGenerate({
16064
16111
  audio: audioData,
16065
16112
  abortSignal,
16066
16113
  headers: headersWithUserAgent,
16067
16114
  providerOptions,
16068
- mediaType: (_a22 = detectMediaType5({
16115
+ mediaType: (_a23 = detectMediaType5({
16069
16116
  data: audioData,
16070
16117
  topLevelType: "audio"
16071
- })) != null ? _a22 : "audio/wav"
16118
+ })) != null ? _a23 : "audio/wav"
16072
16119
  });
16073
16120
  }
16074
16121
  );
@@ -16092,14 +16139,14 @@ async function transcribe({
16092
16139
  }
16093
16140
  var DefaultTranscriptionResult = class {
16094
16141
  constructor(options) {
16095
- var _a22;
16142
+ var _a23;
16096
16143
  this.text = options.text;
16097
16144
  this.segments = options.segments;
16098
16145
  this.language = options.language;
16099
16146
  this.durationInSeconds = options.durationInSeconds;
16100
16147
  this.warnings = options.warnings;
16101
16148
  this.responses = options.responses;
16102
- this.providerMetadata = (_a22 = options.providerMetadata) != null ? _a22 : {};
16149
+ this.providerMetadata = (_a23 = options.providerMetadata) != null ? _a23 : {};
16103
16150
  }
16104
16151
  };
16105
16152
 
@@ -16121,12 +16168,12 @@ function streamTranscribe({
16121
16168
  includeRawChunks,
16122
16169
  _internal: { currentDate = () => /* @__PURE__ */ new Date() } = {}
16123
16170
  }) {
16124
- var _a22;
16171
+ var _a23;
16125
16172
  const resolvedModel = resolveTranscriptionModel(model);
16126
16173
  if (!resolvedModel) {
16127
16174
  throw new Error("Model could not be resolved");
16128
16175
  }
16129
- const doStream = (_a22 = resolvedModel.doStream) == null ? void 0 : _a22.bind(resolvedModel);
16176
+ const doStream = (_a23 = resolvedModel.doStream) == null ? void 0 : _a23.bind(resolvedModel);
16130
16177
  if (doStream == null) {
16131
16178
  throw new UnsupportedFunctionalityError4({
16132
16179
  functionality: "streaming transcription",
@@ -16173,7 +16220,7 @@ function streamTranscribe({
16173
16220
  const pipeAbortController = new AbortController();
16174
16221
  const transformer = {
16175
16222
  transform(value, controller) {
16176
- var _a23, _b, _c, _d;
16223
+ var _a24, _b, _c, _d;
16177
16224
  switch (value.type) {
16178
16225
  case "stream-start": {
16179
16226
  resolveWarnings(value.warnings);
@@ -16181,7 +16228,7 @@ function streamTranscribe({
16181
16228
  }
16182
16229
  case "response-metadata": {
16183
16230
  response = {
16184
- timestamp: (_a23 = value.timestamp) != null ? _a23 : currentResponseMetadata().timestamp,
16231
+ timestamp: (_a24 = value.timestamp) != null ? _a24 : currentResponseMetadata().timestamp,
16185
16232
  modelId: (_b = value.modelId) != null ? _b : currentResponseMetadata().modelId,
16186
16233
  headers: (_c = value.headers) != null ? _c : response == null ? void 0 : response.headers
16187
16234
  };
@@ -16229,7 +16276,7 @@ function streamTranscribe({
16229
16276
  };
16230
16277
  const transform = new TransformStream(transformer);
16231
16278
  void (async () => {
16232
- var _a23, _b, _c, _d, _e;
16279
+ var _a24, _b, _c, _d, _e;
16233
16280
  const result = await doStream({
16234
16281
  audio,
16235
16282
  inputAudioFormat,
@@ -16240,7 +16287,7 @@ function streamTranscribe({
16240
16287
  includeRawChunks
16241
16288
  });
16242
16289
  response = {
16243
- timestamp: (_b = (_a23 = result.response) == null ? void 0 : _a23.timestamp) != null ? _b : startedAt,
16290
+ timestamp: (_b = (_a24 = result.response) == null ? void 0 : _a24.timestamp) != null ? _b : startedAt,
16244
16291
  modelId: (_d = (_c = result.response) == null ? void 0 : _c.modelId) != null ? _d : resolvedModel.modelId,
16245
16292
  headers: (_e = result.response) == null ? void 0 : _e.headers
16246
16293
  };
@@ -16315,10 +16362,224 @@ function streamTranscribe({
16315
16362
  // src/transcribe/index.ts
16316
16363
  var experimental_transcribe = transcribe;
16317
16364
 
16365
+ // src/translate/stream-translate.ts
16366
+ import {
16367
+ DelayedPromise as DelayedPromise4,
16368
+ withUserAgentSuffix as withUserAgentSuffix12
16369
+ } from "@ai-sdk/provider-utils";
16370
+ function streamTranslate({
16371
+ model,
16372
+ audio,
16373
+ inputAudioFormat,
16374
+ targetLanguage,
16375
+ sourceLanguage,
16376
+ outputAudioFormat,
16377
+ providerOptions = {},
16378
+ abortSignal,
16379
+ headers,
16380
+ includeRawChunks,
16381
+ _internal: { currentDate = () => /* @__PURE__ */ new Date() } = {}
16382
+ }) {
16383
+ const resolvedModel = resolveSpeechTranslationModel(model);
16384
+ const doStream = resolvedModel.doStream.bind(resolvedModel);
16385
+ const headersWithUserAgent = withUserAgentSuffix12(
16386
+ headers != null ? headers : {},
16387
+ `ai/${VERSION}`
16388
+ );
16389
+ const sourceTextPromise = new DelayedPromise4();
16390
+ const translationTextPromise = new DelayedPromise4();
16391
+ const durationInSecondsPromise = new DelayedPromise4();
16392
+ const usagePromise = new DelayedPromise4();
16393
+ const warningsPromise = new DelayedPromise4();
16394
+ const responsePromise = new DelayedPromise4();
16395
+ const providerMetadataPromise = new DelayedPromise4();
16396
+ const rejectPendingPromises = (error) => {
16397
+ for (const promise of [
16398
+ sourceTextPromise,
16399
+ translationTextPromise,
16400
+ durationInSecondsPromise,
16401
+ usagePromise,
16402
+ warningsPromise,
16403
+ responsePromise,
16404
+ providerMetadataPromise
16405
+ ]) {
16406
+ if (promise.isPending()) {
16407
+ promise.reject(error);
16408
+ }
16409
+ }
16410
+ };
16411
+ const startedAt = currentDate();
16412
+ let response;
16413
+ const currentResponseMetadata = () => response != null ? response : { timestamp: startedAt, modelId: resolvedModel.modelId };
16414
+ const resolveWarnings = (warnings) => {
16415
+ warningsPromise.resolve(warnings);
16416
+ logWarnings({
16417
+ warnings,
16418
+ provider: resolvedModel.provider,
16419
+ model: resolvedModel.modelId
16420
+ });
16421
+ };
16422
+ const pipeAbortController = new AbortController();
16423
+ let hasAudioOutput = false;
16424
+ const transformer = {
16425
+ transform(value, controller) {
16426
+ var _a23, _b, _c, _d;
16427
+ switch (value.type) {
16428
+ case "stream-start": {
16429
+ resolveWarnings(value.warnings);
16430
+ break;
16431
+ }
16432
+ case "response-metadata": {
16433
+ response = {
16434
+ timestamp: (_a23 = value.timestamp) != null ? _a23 : currentResponseMetadata().timestamp,
16435
+ modelId: (_b = value.modelId) != null ? _b : currentResponseMetadata().modelId,
16436
+ headers: (_c = value.headers) != null ? _c : response == null ? void 0 : response.headers
16437
+ };
16438
+ break;
16439
+ }
16440
+ case "audio": {
16441
+ hasAudioOutput = true;
16442
+ controller.enqueue(value);
16443
+ break;
16444
+ }
16445
+ case "output-text-delta":
16446
+ case "output-text-final":
16447
+ case "source-transcript-delta":
16448
+ case "source-transcript-partial":
16449
+ case "source-transcript-final":
16450
+ case "raw":
16451
+ case "error": {
16452
+ controller.enqueue(value);
16453
+ break;
16454
+ }
16455
+ case "finish": {
16456
+ if (!warningsPromise.isResolved()) {
16457
+ resolveWarnings([]);
16458
+ }
16459
+ if (!hasAudioOutput && !value.outputText) {
16460
+ throw new NoTranslationGeneratedError({
16461
+ response: currentResponseMetadata()
16462
+ });
16463
+ }
16464
+ sourceTextPromise.resolve(value.sourceText);
16465
+ translationTextPromise.resolve(value.outputText);
16466
+ durationInSecondsPromise.resolve(value.durationInSeconds);
16467
+ usagePromise.resolve(value.usage);
16468
+ responsePromise.resolve(currentResponseMetadata());
16469
+ providerMetadataPromise.resolve((_d = value.providerMetadata) != null ? _d : {});
16470
+ break;
16471
+ }
16472
+ default: {
16473
+ const _exhaustiveCheck = value;
16474
+ throw new Error(`Unsupported part type: ${_exhaustiveCheck}`);
16475
+ }
16476
+ }
16477
+ },
16478
+ flush() {
16479
+ if (translationTextPromise.isPending()) {
16480
+ throw new NoTranslationGeneratedError({
16481
+ response: currentResponseMetadata()
16482
+ });
16483
+ }
16484
+ },
16485
+ cancel(reason) {
16486
+ pipeAbortController.abort(
16487
+ reason != null ? reason : new Error("Translation stream was cancelled.")
16488
+ );
16489
+ }
16490
+ };
16491
+ const transform = new TransformStream(transformer);
16492
+ void (async () => {
16493
+ var _a23, _b, _c, _d, _e;
16494
+ const result = await doStream({
16495
+ audio,
16496
+ inputAudioFormat,
16497
+ targetLanguage,
16498
+ sourceLanguage,
16499
+ outputAudioFormat,
16500
+ providerOptions,
16501
+ // merged so cancelling fullStream also aborts a still-pending doStream
16502
+ abortSignal: mergeAbortSignals(abortSignal, pipeAbortController.signal),
16503
+ headers: headersWithUserAgent,
16504
+ includeRawChunks
16505
+ });
16506
+ response = {
16507
+ timestamp: (_b = (_a23 = result.response) == null ? void 0 : _a23.timestamp) != null ? _b : startedAt,
16508
+ modelId: (_d = (_c = result.response) == null ? void 0 : _c.modelId) != null ? _d : resolvedModel.modelId,
16509
+ headers: (_e = result.response) == null ? void 0 : _e.headers
16510
+ };
16511
+ await result.stream.pipeTo(transform.writable, {
16512
+ signal: pipeAbortController.signal
16513
+ });
16514
+ })().catch((error) => {
16515
+ const reason = error != null ? error : new Error("Translation stream was cancelled or errored.");
16516
+ rejectPendingPromises(reason);
16517
+ audio.cancel(reason).catch(() => {
16518
+ });
16519
+ transform.writable.abort(reason).catch(() => {
16520
+ });
16521
+ });
16522
+ let streamOwner = "unclaimed";
16523
+ function consumeStream2() {
16524
+ if (streamOwner === "full-stream" || streamOwner === "result-promises") {
16525
+ return;
16526
+ }
16527
+ streamOwner = "result-promises";
16528
+ const reader = transform.readable.getReader();
16529
+ void (async () => {
16530
+ while (!(await reader.read()).done) {
16531
+ }
16532
+ })().catch(() => {
16533
+ });
16534
+ }
16535
+ function getFullStream() {
16536
+ if (streamOwner !== "unclaimed") {
16537
+ throw new Error(
16538
+ streamOwner === "full-stream" ? "fullStream can only be accessed once." : "fullStream cannot be accessed after a result promise."
16539
+ );
16540
+ }
16541
+ streamOwner = "full-stream";
16542
+ return asAsyncIterableStream(transform.readable);
16543
+ }
16544
+ return {
16545
+ get sourceText() {
16546
+ consumeStream2();
16547
+ return sourceTextPromise.promise;
16548
+ },
16549
+ get translationText() {
16550
+ consumeStream2();
16551
+ return translationTextPromise.promise;
16552
+ },
16553
+ get durationInSeconds() {
16554
+ consumeStream2();
16555
+ return durationInSecondsPromise.promise;
16556
+ },
16557
+ get usage() {
16558
+ consumeStream2();
16559
+ return usagePromise.promise;
16560
+ },
16561
+ get warnings() {
16562
+ consumeStream2();
16563
+ return warningsPromise.promise;
16564
+ },
16565
+ get response() {
16566
+ consumeStream2();
16567
+ return responsePromise.promise;
16568
+ },
16569
+ get providerMetadata() {
16570
+ consumeStream2();
16571
+ return providerMetadataPromise.promise;
16572
+ },
16573
+ get fullStream() {
16574
+ return getFullStream();
16575
+ }
16576
+ };
16577
+ }
16578
+
16318
16579
  // src/ui/call-completion-api.ts
16319
16580
  import {
16320
16581
  parseJsonEventStream,
16321
- withUserAgentSuffix as withUserAgentSuffix12,
16582
+ withUserAgentSuffix as withUserAgentSuffix13,
16322
16583
  getRuntimeEnvironmentUserAgent as getRuntimeEnvironmentUserAgent2
16323
16584
  } from "@ai-sdk/provider-utils";
16324
16585
 
@@ -16354,7 +16615,7 @@ async function callCompletionApi({
16354
16615
  onError,
16355
16616
  fetch: fetch2 = getOriginalFetch()
16356
16617
  }) {
16357
- var _a22;
16618
+ var _a23;
16358
16619
  try {
16359
16620
  setLoading(true);
16360
16621
  setError(void 0);
@@ -16368,7 +16629,7 @@ async function callCompletionApi({
16368
16629
  ...body
16369
16630
  }),
16370
16631
  credentials,
16371
- headers: withUserAgentSuffix12(
16632
+ headers: withUserAgentSuffix13(
16372
16633
  {
16373
16634
  "Content-Type": "application/json",
16374
16635
  ...headers
@@ -16382,7 +16643,7 @@ async function callCompletionApi({
16382
16643
  });
16383
16644
  if (!response.ok) {
16384
16645
  throw new Error(
16385
- (_a22 = await response.text()) != null ? _a22 : "Failed to fetch the chat response."
16646
+ (_a23 = await response.text()) != null ? _a23 : "Failed to fetch the chat response."
16386
16647
  );
16387
16648
  }
16388
16649
  if (!response.body) {
@@ -16468,12 +16729,12 @@ async function convertFileListToFileUIParts(files) {
16468
16729
  }
16469
16730
  return Promise.all(
16470
16731
  Array.from(files).map(async (file) => {
16471
- const { name: name22, type } = file;
16732
+ const { name: name23, type } = file;
16472
16733
  const dataUrl = await new Promise((resolve3, reject) => {
16473
16734
  const reader = new FileReader();
16474
16735
  reader.onload = (readerEvent) => {
16475
- var _a22;
16476
- resolve3((_a22 = readerEvent.target) == null ? void 0 : _a22.result);
16736
+ var _a23;
16737
+ resolve3((_a23 = readerEvent.target) == null ? void 0 : _a23.result);
16477
16738
  };
16478
16739
  reader.onerror = (error) => reject(error);
16479
16740
  reader.readAsDataURL(file);
@@ -16481,7 +16742,7 @@ async function convertFileListToFileUIParts(files) {
16481
16742
  return {
16482
16743
  type: "file",
16483
16744
  mediaType: type,
16484
- filename: name22,
16745
+ filename: name23,
16485
16746
  url: dataUrl
16486
16747
  };
16487
16748
  })
@@ -16518,7 +16779,7 @@ var HttpChatTransport = class {
16518
16779
  abortSignal,
16519
16780
  ...options
16520
16781
  }) {
16521
- var _a22, _b, _c, _d, _e;
16782
+ var _a23, _b, _c, _d, _e;
16522
16783
  const resolvedBody = await resolve2(this.body);
16523
16784
  const resolvedHeaders = await resolve2(this.headers);
16524
16785
  const resolvedCredentials = await resolve2(this.credentials);
@@ -16526,7 +16787,7 @@ var HttpChatTransport = class {
16526
16787
  ...normalizeHeaders(resolvedHeaders),
16527
16788
  ...normalizeHeaders(options.headers)
16528
16789
  };
16529
- const preparedRequest = await ((_a22 = this.prepareSendMessagesRequest) == null ? void 0 : _a22.call(this, {
16790
+ const preparedRequest = await ((_a23 = this.prepareSendMessagesRequest) == null ? void 0 : _a23.call(this, {
16530
16791
  api: this.api,
16531
16792
  id: options.chatId,
16532
16793
  messages: options.messages,
@@ -16570,7 +16831,7 @@ var HttpChatTransport = class {
16570
16831
  return this.processResponseStream(response.body);
16571
16832
  }
16572
16833
  async reconnectToStream(options) {
16573
- var _a22, _b, _c, _d, _e;
16834
+ var _a23, _b, _c, _d, _e;
16574
16835
  const resolvedBody = await resolve2(this.body);
16575
16836
  const resolvedHeaders = await resolve2(this.headers);
16576
16837
  const resolvedCredentials = await resolve2(this.credentials);
@@ -16578,7 +16839,7 @@ var HttpChatTransport = class {
16578
16839
  ...normalizeHeaders(resolvedHeaders),
16579
16840
  ...normalizeHeaders(options.headers)
16580
16841
  };
16581
- const preparedRequest = await ((_a22 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a22.call(this, {
16842
+ const preparedRequest = await ((_a23 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a23.call(this, {
16582
16843
  api: this.api,
16583
16844
  id: options.chatId,
16584
16845
  body: { ...resolvedBody, ...options.body },
@@ -16656,11 +16917,11 @@ var AbstractChat = class {
16656
16917
  * If a messageId is provided, the message will be replaced.
16657
16918
  */
16658
16919
  this.sendMessage = async (message, options) => {
16659
- var _a22, _b, _c, _d;
16920
+ var _a23, _b, _c, _d;
16660
16921
  if (message == null) {
16661
16922
  await this.makeRequest({
16662
16923
  trigger: "submit-message",
16663
- messageId: (_a22 = this.lastMessage) == null ? void 0 : _a22.id,
16924
+ messageId: (_a23 = this.lastMessage) == null ? void 0 : _a23.id,
16664
16925
  ...options
16665
16926
  });
16666
16927
  return;
@@ -16770,11 +17031,11 @@ var AbstractChat = class {
16770
17031
  }
16771
17032
  if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
16772
17033
  this.shouldSendAutomatically().then((shouldSend) => {
16773
- var _a22;
17034
+ var _a23;
16774
17035
  if (shouldSend) {
16775
17036
  this.makeRequest({
16776
17037
  trigger: "submit-message",
16777
- messageId: (_a22 = this.lastMessage) == null ? void 0 : _a22.id,
17038
+ messageId: (_a23 = this.lastMessage) == null ? void 0 : _a23.id,
16778
17039
  ...options
16779
17040
  });
16780
17041
  }
@@ -16800,11 +17061,11 @@ var AbstractChat = class {
16800
17061
  }
16801
17062
  if (this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
16802
17063
  this.shouldSendAutomatically().then((shouldSend) => {
16803
- var _a22;
17064
+ var _a23;
16804
17065
  if (shouldSend) {
16805
17066
  this.makeRequest({
16806
17067
  trigger: "submit-message",
16807
- messageId: (_a22 = this.lastMessage) == null ? void 0 : _a22.id,
17068
+ messageId: (_a23 = this.lastMessage) == null ? void 0 : _a23.id,
16808
17069
  ...options
16809
17070
  });
16810
17071
  }
@@ -16817,10 +17078,10 @@ var AbstractChat = class {
16817
17078
  * Abort the current request immediately, keep the generated tokens if any.
16818
17079
  */
16819
17080
  this.stop = async () => {
16820
- var _a22;
17081
+ var _a23;
16821
17082
  if (this.status !== "streaming" && this.status !== "submitted")
16822
17083
  return;
16823
- if ((_a22 = this.activeResponse) == null ? void 0 : _a22.abortController) {
17084
+ if ((_a23 = this.activeResponse) == null ? void 0 : _a23.abortController) {
16824
17085
  this.activeResponse.abortController.abort();
16825
17086
  }
16826
17087
  };
@@ -16886,7 +17147,7 @@ var AbstractChat = class {
16886
17147
  body,
16887
17148
  messageId
16888
17149
  }) {
16889
- var _a22, _b;
17150
+ var _a23, _b;
16890
17151
  let resumeStream;
16891
17152
  if (trigger === "resume-stream") {
16892
17153
  try {
@@ -16948,9 +17209,9 @@ var AbstractChat = class {
16948
17209
  () => job({
16949
17210
  state: response.state,
16950
17211
  write: () => {
16951
- var _a23;
17212
+ var _a24;
16952
17213
  this.setStatus({ status: "streaming" });
16953
- const replaceLastMessage = response.state.message.id === ((_a23 = this.lastMessage) == null ? void 0 : _a23.id);
17214
+ const replaceLastMessage = response.state.message.id === ((_a24 = this.lastMessage) == null ? void 0 : _a24.id);
16954
17215
  if (replaceLastMessage) {
16955
17216
  this.state.replaceMessage(
16956
17217
  this.state.messages.length - 1,
@@ -16997,7 +17258,7 @@ var AbstractChat = class {
16997
17258
  } finally {
16998
17259
  try {
16999
17260
  if (activeResponse) {
17000
- (_a22 = this.onFinish) == null ? void 0 : _a22.call(this, {
17261
+ (_a23 = this.onFinish) == null ? void 0 : _a23.call(this, {
17001
17262
  message: activeResponse.state.message,
17002
17263
  messages: this.state.messages,
17003
17264
  isAbort,
@@ -17162,9 +17423,9 @@ async function uploadFile({
17162
17423
  filename,
17163
17424
  providerOptions
17164
17425
  }) {
17165
- var _a22;
17426
+ var _a23;
17166
17427
  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";
17428
+ 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
17429
  const filesApi = "uploadFile" in api ? api : typeof api.files === "function" ? api.files() : (() => {
17169
17430
  throw new Error(
17170
17431
  "The provider does not support file uploads. Make sure it exposes a files() method."
@@ -17235,7 +17496,7 @@ async function uploadSkill({
17235
17496
  return result;
17236
17497
  }
17237
17498
  export {
17238
- AISDKError22 as AISDKError,
17499
+ AISDKError23 as AISDKError,
17239
17500
  AI_SDK_TELEMETRY_TRACING_CHANNEL,
17240
17501
  APICallError,
17241
17502
  AbstractChat,
@@ -17272,6 +17533,7 @@ export {
17272
17533
  NoSuchProviderReferenceError,
17273
17534
  NoSuchToolError,
17274
17535
  NoTranscriptGeneratedError,
17536
+ NoTranslationGeneratedError,
17275
17537
  NoVideoGeneratedError,
17276
17538
  output_exports as Output,
17277
17539
  RetryError,
@@ -17321,6 +17583,7 @@ export {
17321
17583
  resampleAudio as experimental_resampleAudio,
17322
17584
  streamLanguageModelCall as experimental_streamLanguageModelCall,
17323
17585
  streamTranscribe as experimental_streamTranscribe,
17586
+ streamTranslate as experimental_streamTranslate,
17324
17587
  experimental_transcribe,
17325
17588
  extractJsonMiddleware,
17326
17589
  extractReasoningMiddleware,