ai 4.1.1 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __export = (target, all) => {
3
- for (var name14 in all)
4
- __defProp(target, name14, { get: all[name14], enumerable: true });
3
+ for (var name15 in all)
4
+ __defProp(target, name15, { get: all[name15], enumerable: true });
5
5
  };
6
6
 
7
7
  // core/index.ts
@@ -352,7 +352,7 @@ function getBaseTelemetryAttributes({
352
352
  telemetry,
353
353
  headers
354
354
  }) {
355
- var _a14;
355
+ var _a15;
356
356
  return {
357
357
  "ai.model.provider": model.provider,
358
358
  "ai.model.id": model.modelId,
@@ -362,7 +362,7 @@ function getBaseTelemetryAttributes({
362
362
  return attributes;
363
363
  }, {}),
364
364
  // add metadata as attributes:
365
- ...Object.entries((_a14 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a14 : {}).reduce(
365
+ ...Object.entries((_a15 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a15 : {}).reduce(
366
366
  (attributes, [key, value]) => {
367
367
  attributes[`ai.telemetry.metadata.${key}`] = value;
368
368
  return attributes;
@@ -387,7 +387,7 @@ var noopTracer = {
387
387
  startSpan() {
388
388
  return noopSpan;
389
389
  },
390
- startActiveSpan(name14, arg1, arg2, arg3) {
390
+ startActiveSpan(name15, arg1, arg2, arg3) {
391
391
  if (typeof arg1 === "function") {
392
392
  return arg1(noopSpan);
393
393
  }
@@ -457,13 +457,13 @@ function getTracer({
457
457
  // core/telemetry/record-span.ts
458
458
  import { SpanStatusCode } from "@opentelemetry/api";
459
459
  function recordSpan({
460
- name: name14,
460
+ name: name15,
461
461
  tracer,
462
462
  attributes,
463
463
  fn,
464
464
  endWhenDone = true
465
465
  }) {
466
- return tracer.startActiveSpan(name14, { attributes }, async (span) => {
466
+ return tracer.startActiveSpan(name15, { attributes }, async (span) => {
467
467
  try {
468
468
  const result = await fn(span);
469
469
  if (endWhenDone) {
@@ -571,14 +571,14 @@ async function embed({
571
571
  }),
572
572
  tracer,
573
573
  fn: async (doEmbedSpan) => {
574
- var _a14;
574
+ var _a15;
575
575
  const modelResponse = await model.doEmbed({
576
576
  values: [value],
577
577
  abortSignal,
578
578
  headers
579
579
  });
580
580
  const embedding2 = modelResponse.embeddings[0];
581
- const usage2 = (_a14 = modelResponse.usage) != null ? _a14 : { tokens: NaN };
581
+ const usage2 = (_a15 = modelResponse.usage) != null ? _a15 : { tokens: NaN };
582
582
  doEmbedSpan.setAttributes(
583
583
  selectTelemetryAttributes({
584
584
  telemetry,
@@ -688,14 +688,14 @@ async function embedMany({
688
688
  }),
689
689
  tracer,
690
690
  fn: async (doEmbedSpan) => {
691
- var _a14;
691
+ var _a15;
692
692
  const modelResponse = await model.doEmbed({
693
693
  values,
694
694
  abortSignal,
695
695
  headers
696
696
  });
697
697
  const embeddings3 = modelResponse.embeddings;
698
- const usage2 = (_a14 = modelResponse.usage) != null ? _a14 : { tokens: NaN };
698
+ const usage2 = (_a15 = modelResponse.usage) != null ? _a15 : { tokens: NaN };
699
699
  doEmbedSpan.setAttributes(
700
700
  selectTelemetryAttributes({
701
701
  telemetry,
@@ -747,14 +747,14 @@ async function embedMany({
747
747
  }),
748
748
  tracer,
749
749
  fn: async (doEmbedSpan) => {
750
- var _a14;
750
+ var _a15;
751
751
  const modelResponse = await model.doEmbed({
752
752
  values: chunk,
753
753
  abortSignal,
754
754
  headers
755
755
  });
756
756
  const embeddings2 = modelResponse.embeddings;
757
- const usage2 = (_a14 = modelResponse.usage) != null ? _a14 : { tokens: NaN };
757
+ const usage2 = (_a15 = modelResponse.usage) != null ? _a15 : { tokens: NaN };
758
758
  doEmbedSpan.setAttributes(
759
759
  selectTelemetryAttributes({
760
760
  telemetry,
@@ -805,6 +805,30 @@ import {
805
805
  convertBase64ToUint8Array,
806
806
  convertUint8ArrayToBase64
807
807
  } from "@ai-sdk/provider-utils";
808
+
809
+ // errors/no-image-generated-error.ts
810
+ import { AISDKError as AISDKError3 } from "@ai-sdk/provider";
811
+ var name3 = "AI_NoImageGeneratedError";
812
+ var marker3 = `vercel.ai.error.${name3}`;
813
+ var symbol3 = Symbol.for(marker3);
814
+ var _a3;
815
+ var NoImageGeneratedError = class extends AISDKError3 {
816
+ constructor({
817
+ message = "No image generated.",
818
+ cause,
819
+ responses
820
+ }) {
821
+ super({ name: name3, message, cause });
822
+ this[_a3] = true;
823
+ this.responses = responses;
824
+ }
825
+ static isInstance(error) {
826
+ return AISDKError3.hasMarker(error, marker3);
827
+ }
828
+ };
829
+ _a3 = symbol3;
830
+
831
+ // core/generate-image/generate-image.ts
808
832
  async function generateImage({
809
833
  model,
810
834
  prompt,
@@ -815,11 +839,14 @@ async function generateImage({
815
839
  providerOptions,
816
840
  maxRetries: maxRetriesArg,
817
841
  abortSignal,
818
- headers
842
+ headers,
843
+ _internal = {
844
+ currentDate: () => /* @__PURE__ */ new Date()
845
+ }
819
846
  }) {
820
- var _a14;
847
+ var _a15;
821
848
  const { retry } = prepareRetries({ maxRetries: maxRetriesArg });
822
- const maxImagesPerCall = (_a14 = model.maxImagesPerCall) != null ? _a14 : 1;
849
+ const maxImagesPerCall = (_a15 = model.maxImagesPerCall) != null ? _a15 : 1;
823
850
  const callCount = Math.ceil(n / maxImagesPerCall);
824
851
  const callImageCounts = Array.from({ length: callCount }, (_, i) => {
825
852
  if (i < callCount - 1) {
@@ -846,18 +873,24 @@ async function generateImage({
846
873
  );
847
874
  const images = [];
848
875
  const warnings = [];
876
+ const responses = [];
849
877
  for (const result of results) {
850
878
  images.push(
851
879
  ...result.images.map((image) => new DefaultGeneratedImage({ image }))
852
880
  );
853
881
  warnings.push(...result.warnings);
882
+ responses.push(result.response);
883
+ }
884
+ if (!images.length) {
885
+ throw new NoImageGeneratedError({ responses });
854
886
  }
855
- return new DefaultGenerateImageResult({ images, warnings });
887
+ return new DefaultGenerateImageResult({ images, warnings, responses });
856
888
  }
857
889
  var DefaultGenerateImageResult = class {
858
890
  constructor(options) {
859
891
  this.images = options.images;
860
892
  this.warnings = options.warnings;
893
+ this.responses = options.responses;
861
894
  }
862
895
  get image() {
863
896
  return this.images[0];
@@ -889,12 +922,12 @@ var DefaultGeneratedImage = class {
889
922
  import { createIdGenerator, safeParseJSON } from "@ai-sdk/provider-utils";
890
923
 
891
924
  // errors/no-object-generated-error.ts
892
- import { AISDKError as AISDKError3 } from "@ai-sdk/provider";
893
- var name3 = "AI_NoObjectGeneratedError";
894
- var marker3 = `vercel.ai.error.${name3}`;
895
- var symbol3 = Symbol.for(marker3);
896
- var _a3;
897
- var NoObjectGeneratedError = class extends AISDKError3 {
925
+ import { AISDKError as AISDKError4 } from "@ai-sdk/provider";
926
+ var name4 = "AI_NoObjectGeneratedError";
927
+ var marker4 = `vercel.ai.error.${name4}`;
928
+ var symbol4 = Symbol.for(marker4);
929
+ var _a4;
930
+ var NoObjectGeneratedError = class extends AISDKError4 {
898
931
  constructor({
899
932
  message = "No object generated.",
900
933
  cause,
@@ -902,25 +935,25 @@ var NoObjectGeneratedError = class extends AISDKError3 {
902
935
  response,
903
936
  usage
904
937
  }) {
905
- super({ name: name3, message, cause });
906
- this[_a3] = true;
938
+ super({ name: name4, message, cause });
939
+ this[_a4] = true;
907
940
  this.text = text2;
908
941
  this.response = response;
909
942
  this.usage = usage;
910
943
  }
911
944
  static isInstance(error) {
912
- return AISDKError3.hasMarker(error, marker3);
945
+ return AISDKError4.hasMarker(error, marker4);
913
946
  }
914
947
  };
915
- _a3 = symbol3;
948
+ _a4 = symbol4;
916
949
 
917
950
  // util/download-error.ts
918
- import { AISDKError as AISDKError4 } from "@ai-sdk/provider";
919
- var name4 = "AI_DownloadError";
920
- var marker4 = `vercel.ai.error.${name4}`;
921
- var symbol4 = Symbol.for(marker4);
922
- var _a4;
923
- var DownloadError = class extends AISDKError4 {
951
+ import { AISDKError as AISDKError5 } from "@ai-sdk/provider";
952
+ var name5 = "AI_DownloadError";
953
+ var marker5 = `vercel.ai.error.${name5}`;
954
+ var symbol5 = Symbol.for(marker5);
955
+ var _a5;
956
+ var DownloadError = class extends AISDKError5 {
924
957
  constructor({
925
958
  url,
926
959
  statusCode,
@@ -928,24 +961,24 @@ var DownloadError = class extends AISDKError4 {
928
961
  cause,
929
962
  message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}`
930
963
  }) {
931
- super({ name: name4, message, cause });
932
- this[_a4] = true;
964
+ super({ name: name5, message, cause });
965
+ this[_a5] = true;
933
966
  this.url = url;
934
967
  this.statusCode = statusCode;
935
968
  this.statusText = statusText;
936
969
  }
937
970
  static isInstance(error) {
938
- return AISDKError4.hasMarker(error, marker4);
971
+ return AISDKError5.hasMarker(error, marker5);
939
972
  }
940
973
  };
941
- _a4 = symbol4;
974
+ _a5 = symbol5;
942
975
 
943
976
  // util/download.ts
944
977
  async function download({
945
978
  url,
946
979
  fetchImplementation = fetch
947
980
  }) {
948
- var _a14;
981
+ var _a15;
949
982
  const urlText = url.toString();
950
983
  try {
951
984
  const response = await fetchImplementation(urlText);
@@ -958,7 +991,7 @@ async function download({
958
991
  }
959
992
  return {
960
993
  data: new Uint8Array(await response.arrayBuffer()),
961
- mimeType: (_a14 = response.headers.get("content-type")) != null ? _a14 : void 0
994
+ mimeType: (_a15 = response.headers.get("content-type")) != null ? _a15 : void 0
962
995
  };
963
996
  } catch (error) {
964
997
  if (DownloadError.isInstance(error)) {
@@ -991,26 +1024,26 @@ import {
991
1024
  } from "@ai-sdk/provider-utils";
992
1025
 
993
1026
  // core/prompt/invalid-data-content-error.ts
994
- import { AISDKError as AISDKError5 } from "@ai-sdk/provider";
995
- var name5 = "AI_InvalidDataContentError";
996
- var marker5 = `vercel.ai.error.${name5}`;
997
- var symbol5 = Symbol.for(marker5);
998
- var _a5;
999
- var InvalidDataContentError = class extends AISDKError5 {
1027
+ import { AISDKError as AISDKError6 } from "@ai-sdk/provider";
1028
+ var name6 = "AI_InvalidDataContentError";
1029
+ var marker6 = `vercel.ai.error.${name6}`;
1030
+ var symbol6 = Symbol.for(marker6);
1031
+ var _a6;
1032
+ var InvalidDataContentError = class extends AISDKError6 {
1000
1033
  constructor({
1001
1034
  content,
1002
1035
  cause,
1003
1036
  message = `Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof content}.`
1004
1037
  }) {
1005
- super({ name: name5, message, cause });
1006
- this[_a5] = true;
1038
+ super({ name: name6, message, cause });
1039
+ this[_a6] = true;
1007
1040
  this.content = content;
1008
1041
  }
1009
1042
  static isInstance(error) {
1010
- return AISDKError5.hasMarker(error, marker5);
1043
+ return AISDKError6.hasMarker(error, marker6);
1011
1044
  }
1012
1045
  };
1013
- _a5 = symbol5;
1046
+ _a6 = symbol6;
1014
1047
 
1015
1048
  // core/prompt/data-content.ts
1016
1049
  import { z } from "zod";
@@ -1021,8 +1054,8 @@ var dataContentSchema = z.union([
1021
1054
  z.custom(
1022
1055
  // Buffer might not be available in some environments such as CloudFlare:
1023
1056
  (value) => {
1024
- var _a14, _b;
1025
- return (_b = (_a14 = globalThis.Buffer) == null ? void 0 : _a14.isBuffer(value)) != null ? _b : false;
1057
+ var _a15, _b;
1058
+ return (_b = (_a15 = globalThis.Buffer) == null ? void 0 : _a15.isBuffer(value)) != null ? _b : false;
1026
1059
  },
1027
1060
  { message: "Must be a Buffer" }
1028
1061
  )
@@ -1065,25 +1098,25 @@ function convertUint8ArrayToText(uint8Array) {
1065
1098
  }
1066
1099
 
1067
1100
  // core/prompt/invalid-message-role-error.ts
1068
- import { AISDKError as AISDKError6 } from "@ai-sdk/provider";
1069
- var name6 = "AI_InvalidMessageRoleError";
1070
- var marker6 = `vercel.ai.error.${name6}`;
1071
- var symbol6 = Symbol.for(marker6);
1072
- var _a6;
1073
- var InvalidMessageRoleError = class extends AISDKError6 {
1101
+ import { AISDKError as AISDKError7 } from "@ai-sdk/provider";
1102
+ var name7 = "AI_InvalidMessageRoleError";
1103
+ var marker7 = `vercel.ai.error.${name7}`;
1104
+ var symbol7 = Symbol.for(marker7);
1105
+ var _a7;
1106
+ var InvalidMessageRoleError = class extends AISDKError7 {
1074
1107
  constructor({
1075
1108
  role,
1076
1109
  message = `Invalid message role: '${role}'. Must be one of: "system", "user", "assistant", "tool".`
1077
1110
  }) {
1078
- super({ name: name6, message });
1079
- this[_a6] = true;
1111
+ super({ name: name7, message });
1112
+ this[_a7] = true;
1080
1113
  this.role = role;
1081
1114
  }
1082
1115
  static isInstance(error) {
1083
- return AISDKError6.hasMarker(error, marker6);
1116
+ return AISDKError7.hasMarker(error, marker7);
1084
1117
  }
1085
1118
  };
1086
- _a6 = symbol6;
1119
+ _a7 = symbol7;
1087
1120
 
1088
1121
  // core/prompt/split-data-url.ts
1089
1122
  function splitDataUrl(dataUrl) {
@@ -1213,7 +1246,7 @@ async function downloadAssets(messages, downloadImplementation, modelSupportsIma
1213
1246
  );
1214
1247
  }
1215
1248
  function convertPartToLanguageModelPart(part, downloadedAssets) {
1216
- var _a14;
1249
+ var _a15;
1217
1250
  if (part.type === "text") {
1218
1251
  return {
1219
1252
  type: "text",
@@ -1266,7 +1299,7 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
1266
1299
  switch (type) {
1267
1300
  case "image": {
1268
1301
  if (normalizedData instanceof Uint8Array) {
1269
- mimeType = (_a14 = detectImageMimeType(normalizedData)) != null ? _a14 : mimeType;
1302
+ mimeType = (_a15 = detectImageMimeType(normalizedData)) != null ? _a15 : mimeType;
1270
1303
  }
1271
1304
  return {
1272
1305
  type: "image",
@@ -1533,7 +1566,7 @@ function detectSingleMessageCharacteristics(message) {
1533
1566
 
1534
1567
  // core/prompt/attachments-to-parts.ts
1535
1568
  function attachmentsToParts(attachments) {
1536
- var _a14, _b, _c;
1569
+ var _a15, _b, _c;
1537
1570
  const parts = [];
1538
1571
  for (const attachment of attachments) {
1539
1572
  let url;
@@ -1545,7 +1578,7 @@ function attachmentsToParts(attachments) {
1545
1578
  switch (url.protocol) {
1546
1579
  case "http:":
1547
1580
  case "https:": {
1548
- if ((_a14 = attachment.contentType) == null ? void 0 : _a14.startsWith("image/")) {
1581
+ if ((_a15 = attachment.contentType) == null ? void 0 : _a15.startsWith("image/")) {
1549
1582
  parts.push({ type: "image", image: url });
1550
1583
  } else {
1551
1584
  if (!attachment.contentType) {
@@ -1609,30 +1642,30 @@ function attachmentsToParts(attachments) {
1609
1642
  }
1610
1643
 
1611
1644
  // core/prompt/message-conversion-error.ts
1612
- import { AISDKError as AISDKError7 } from "@ai-sdk/provider";
1613
- var name7 = "AI_MessageConversionError";
1614
- var marker7 = `vercel.ai.error.${name7}`;
1615
- var symbol7 = Symbol.for(marker7);
1616
- var _a7;
1617
- var MessageConversionError = class extends AISDKError7 {
1645
+ import { AISDKError as AISDKError8 } from "@ai-sdk/provider";
1646
+ var name8 = "AI_MessageConversionError";
1647
+ var marker8 = `vercel.ai.error.${name8}`;
1648
+ var symbol8 = Symbol.for(marker8);
1649
+ var _a8;
1650
+ var MessageConversionError = class extends AISDKError8 {
1618
1651
  constructor({
1619
1652
  originalMessage,
1620
1653
  message
1621
1654
  }) {
1622
- super({ name: name7, message });
1623
- this[_a7] = true;
1655
+ super({ name: name8, message });
1656
+ this[_a8] = true;
1624
1657
  this.originalMessage = originalMessage;
1625
1658
  }
1626
1659
  static isInstance(error) {
1627
- return AISDKError7.hasMarker(error, marker7);
1660
+ return AISDKError8.hasMarker(error, marker8);
1628
1661
  }
1629
1662
  };
1630
- _a7 = symbol7;
1663
+ _a8 = symbol8;
1631
1664
 
1632
1665
  // core/prompt/convert-to-core-messages.ts
1633
1666
  function convertToCoreMessages(messages, options) {
1634
- var _a14;
1635
- const tools = (_a14 = options == null ? void 0 : options.tools) != null ? _a14 : {};
1667
+ var _a15;
1668
+ const tools = (_a15 = options == null ? void 0 : options.tools) != null ? _a15 : {};
1636
1669
  const coreMessages = [];
1637
1670
  for (const message of messages) {
1638
1671
  const { role, content, toolInvocations, experimental_attachments } = message;
@@ -1914,7 +1947,7 @@ var arrayOutputStrategy = (schema) => {
1914
1947
  additionalProperties: false
1915
1948
  },
1916
1949
  validatePartialResult({ value, latestObject, isFirstDelta, isFinalDelta }) {
1917
- var _a14;
1950
+ var _a15;
1918
1951
  if (!isJSONObject(value) || !isJSONArray(value.elements)) {
1919
1952
  return {
1920
1953
  success: false,
@@ -1937,7 +1970,7 @@ var arrayOutputStrategy = (schema) => {
1937
1970
  }
1938
1971
  resultArray.push(result.value);
1939
1972
  }
1940
- const publishedElementCount = (_a14 = latestObject == null ? void 0 : latestObject.length) != null ? _a14 : 0;
1973
+ const publishedElementCount = (_a15 = latestObject == null ? void 0 : latestObject.length) != null ? _a15 : 0;
1941
1974
  let textDelta = "";
1942
1975
  if (isFirstDelta) {
1943
1976
  textDelta += "[";
@@ -2275,7 +2308,7 @@ async function generateObject({
2275
2308
  }),
2276
2309
  tracer,
2277
2310
  fn: async (span) => {
2278
- var _a14, _b;
2311
+ var _a15, _b;
2279
2312
  if (mode === "auto" || mode == null) {
2280
2313
  mode = model.defaultObjectGenerationMode;
2281
2314
  }
@@ -2337,7 +2370,7 @@ async function generateObject({
2337
2370
  }),
2338
2371
  tracer,
2339
2372
  fn: async (span2) => {
2340
- var _a15, _b2, _c, _d, _e, _f;
2373
+ var _a16, _b2, _c, _d, _e, _f;
2341
2374
  const result2 = await model.doGenerate({
2342
2375
  mode: {
2343
2376
  type: "object-json",
@@ -2353,7 +2386,7 @@ async function generateObject({
2353
2386
  headers
2354
2387
  });
2355
2388
  const responseData = {
2356
- id: (_b2 = (_a15 = result2.response) == null ? void 0 : _a15.id) != null ? _b2 : generateId3(),
2389
+ id: (_b2 = (_a16 = result2.response) == null ? void 0 : _a16.id) != null ? _b2 : generateId3(),
2357
2390
  timestamp: (_d = (_c = result2.response) == null ? void 0 : _c.timestamp) != null ? _d : currentDate(),
2358
2391
  modelId: (_f = (_e = result2.response) == null ? void 0 : _e.modelId) != null ? _f : model.modelId
2359
2392
  };
@@ -2395,7 +2428,7 @@ async function generateObject({
2395
2428
  rawResponse = generateResult.rawResponse;
2396
2429
  logprobs = generateResult.logprobs;
2397
2430
  resultProviderMetadata = generateResult.providerMetadata;
2398
- request = (_a14 = generateResult.request) != null ? _a14 : {};
2431
+ request = (_a15 = generateResult.request) != null ? _a15 : {};
2399
2432
  response = generateResult.responseData;
2400
2433
  break;
2401
2434
  }
@@ -2441,7 +2474,7 @@ async function generateObject({
2441
2474
  }),
2442
2475
  tracer,
2443
2476
  fn: async (span2) => {
2444
- var _a15, _b2, _c, _d, _e, _f, _g, _h;
2477
+ var _a16, _b2, _c, _d, _e, _f, _g, _h;
2445
2478
  const result2 = await model.doGenerate({
2446
2479
  mode: {
2447
2480
  type: "object-tool",
@@ -2459,7 +2492,7 @@ async function generateObject({
2459
2492
  abortSignal,
2460
2493
  headers
2461
2494
  });
2462
- const objectText = (_b2 = (_a15 = result2.toolCalls) == null ? void 0 : _a15[0]) == null ? void 0 : _b2.args;
2495
+ const objectText = (_b2 = (_a16 = result2.toolCalls) == null ? void 0 : _a16[0]) == null ? void 0 : _b2.args;
2463
2496
  const responseData = {
2464
2497
  id: (_d = (_c = result2.response) == null ? void 0 : _c.id) != null ? _d : generateId3(),
2465
2498
  timestamp: (_f = (_e = result2.response) == null ? void 0 : _e.timestamp) != null ? _f : currentDate(),
@@ -2585,9 +2618,9 @@ var DefaultGenerateObjectResult = class {
2585
2618
  this.logprobs = options.logprobs;
2586
2619
  }
2587
2620
  toJsonResponse(init) {
2588
- var _a14;
2621
+ var _a15;
2589
2622
  return new Response(JSON.stringify(this.object), {
2590
- status: (_a14 = init == null ? void 0 : init.status) != null ? _a14 : 200,
2623
+ status: (_a15 = init == null ? void 0 : init.status) != null ? _a15 : 200,
2591
2624
  headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
2592
2625
  contentType: "application/json; charset=utf-8"
2593
2626
  })
@@ -2625,17 +2658,17 @@ var DelayedPromise = class {
2625
2658
  return this.promise;
2626
2659
  }
2627
2660
  resolve(value) {
2628
- var _a14;
2661
+ var _a15;
2629
2662
  this.status = { type: "resolved", value };
2630
2663
  if (this.promise) {
2631
- (_a14 = this._resolve) == null ? void 0 : _a14.call(this, value);
2664
+ (_a15 = this._resolve) == null ? void 0 : _a15.call(this, value);
2632
2665
  }
2633
2666
  }
2634
2667
  reject(error) {
2635
- var _a14;
2668
+ var _a15;
2636
2669
  this.status = { type: "rejected", error };
2637
2670
  if (this.promise) {
2638
- (_a14 = this._reject) == null ? void 0 : _a14.call(this, error);
2671
+ (_a15 = this._reject) == null ? void 0 : _a15.call(this, error);
2639
2672
  }
2640
2673
  }
2641
2674
  };
@@ -2739,8 +2772,8 @@ function createStitchableStream() {
2739
2772
 
2740
2773
  // core/util/now.ts
2741
2774
  function now() {
2742
- var _a14, _b;
2743
- return (_b = (_a14 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a14.now()) != null ? _b : Date.now();
2775
+ var _a15, _b;
2776
+ return (_b = (_a15 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a15.now()) != null ? _b : Date.now();
2744
2777
  }
2745
2778
 
2746
2779
  // core/generate-object/stream-object.ts
@@ -3029,7 +3062,7 @@ var DefaultStreamObjectResult = class {
3029
3062
  const transformedStream = stream.pipeThrough(new TransformStream(transformer)).pipeThrough(
3030
3063
  new TransformStream({
3031
3064
  async transform(chunk, controller) {
3032
- var _a14, _b, _c;
3065
+ var _a15, _b, _c;
3033
3066
  if (isFirstChunk) {
3034
3067
  const msToFirstChunk = now2() - startTimestampMs;
3035
3068
  isFirstChunk = false;
@@ -3075,7 +3108,7 @@ var DefaultStreamObjectResult = class {
3075
3108
  switch (chunk.type) {
3076
3109
  case "response-metadata": {
3077
3110
  response = {
3078
- id: (_a14 = chunk.id) != null ? _a14 : response.id,
3111
+ id: (_a15 = chunk.id) != null ? _a15 : response.id,
3079
3112
  timestamp: (_b = chunk.timestamp) != null ? _b : response.timestamp,
3080
3113
  modelId: (_c = chunk.modelId) != null ? _c : response.modelId
3081
3114
  };
@@ -3289,9 +3322,9 @@ var DefaultStreamObjectResult = class {
3289
3322
  });
3290
3323
  }
3291
3324
  toTextStreamResponse(init) {
3292
- var _a14;
3325
+ var _a15;
3293
3326
  return new Response(this.textStream.pipeThrough(new TextEncoderStream()), {
3294
- status: (_a14 = init == null ? void 0 : init.status) != null ? _a14 : 200,
3327
+ status: (_a15 = init == null ? void 0 : init.status) != null ? _a15 : 200,
3295
3328
  headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
3296
3329
  contentType: "text/plain; charset=utf-8"
3297
3330
  })
@@ -3303,30 +3336,30 @@ var DefaultStreamObjectResult = class {
3303
3336
  import { createIdGenerator as createIdGenerator3 } from "@ai-sdk/provider-utils";
3304
3337
 
3305
3338
  // errors/no-output-specified-error.ts
3306
- import { AISDKError as AISDKError8 } from "@ai-sdk/provider";
3307
- var name8 = "AI_NoOutputSpecifiedError";
3308
- var marker8 = `vercel.ai.error.${name8}`;
3309
- var symbol8 = Symbol.for(marker8);
3310
- var _a8;
3311
- var NoOutputSpecifiedError = class extends AISDKError8 {
3339
+ import { AISDKError as AISDKError9 } from "@ai-sdk/provider";
3340
+ var name9 = "AI_NoOutputSpecifiedError";
3341
+ var marker9 = `vercel.ai.error.${name9}`;
3342
+ var symbol9 = Symbol.for(marker9);
3343
+ var _a9;
3344
+ var NoOutputSpecifiedError = class extends AISDKError9 {
3312
3345
  // used in isInstance
3313
3346
  constructor({ message = "No output specified." } = {}) {
3314
- super({ name: name8, message });
3315
- this[_a8] = true;
3347
+ super({ name: name9, message });
3348
+ this[_a9] = true;
3316
3349
  }
3317
3350
  static isInstance(error) {
3318
- return AISDKError8.hasMarker(error, marker8);
3351
+ return AISDKError9.hasMarker(error, marker9);
3319
3352
  }
3320
3353
  };
3321
- _a8 = symbol8;
3354
+ _a9 = symbol9;
3322
3355
 
3323
3356
  // errors/tool-execution-error.ts
3324
- import { AISDKError as AISDKError9, getErrorMessage as getErrorMessage2 } from "@ai-sdk/provider";
3325
- var name9 = "AI_ToolExecutionError";
3326
- var marker9 = `vercel.ai.error.${name9}`;
3327
- var symbol9 = Symbol.for(marker9);
3328
- var _a9;
3329
- var ToolExecutionError = class extends AISDKError9 {
3357
+ import { AISDKError as AISDKError10, getErrorMessage as getErrorMessage2 } from "@ai-sdk/provider";
3358
+ var name10 = "AI_ToolExecutionError";
3359
+ var marker10 = `vercel.ai.error.${name10}`;
3360
+ var symbol10 = Symbol.for(marker10);
3361
+ var _a10;
3362
+ var ToolExecutionError = class extends AISDKError10 {
3330
3363
  constructor({
3331
3364
  toolArgs,
3332
3365
  toolName,
@@ -3334,17 +3367,17 @@ var ToolExecutionError = class extends AISDKError9 {
3334
3367
  cause,
3335
3368
  message = `Error executing tool ${toolName}: ${getErrorMessage2(cause)}`
3336
3369
  }) {
3337
- super({ name: name9, message, cause });
3338
- this[_a9] = true;
3370
+ super({ name: name10, message, cause });
3371
+ this[_a10] = true;
3339
3372
  this.toolArgs = toolArgs;
3340
3373
  this.toolName = toolName;
3341
3374
  this.toolCallId = toolCallId;
3342
3375
  }
3343
3376
  static isInstance(error) {
3344
- return AISDKError9.hasMarker(error, marker9);
3377
+ return AISDKError10.hasMarker(error, marker10);
3345
3378
  }
3346
3379
  };
3347
- _a9 = symbol9;
3380
+ _a10 = symbol10;
3348
3381
 
3349
3382
  // core/prompt/prepare-tools-and-tool-choice.ts
3350
3383
  import { asSchema as asSchema2 } from "@ai-sdk/ui-utils";
@@ -3367,24 +3400,24 @@ function prepareToolsAndToolChoice({
3367
3400
  };
3368
3401
  }
3369
3402
  const filteredTools = activeTools != null ? Object.entries(tools).filter(
3370
- ([name14]) => activeTools.includes(name14)
3403
+ ([name15]) => activeTools.includes(name15)
3371
3404
  ) : Object.entries(tools);
3372
3405
  return {
3373
- tools: filteredTools.map(([name14, tool2]) => {
3406
+ tools: filteredTools.map(([name15, tool2]) => {
3374
3407
  const toolType = tool2.type;
3375
3408
  switch (toolType) {
3376
3409
  case void 0:
3377
3410
  case "function":
3378
3411
  return {
3379
3412
  type: "function",
3380
- name: name14,
3413
+ name: name15,
3381
3414
  description: tool2.description,
3382
3415
  parameters: asSchema2(tool2.parameters).jsonSchema
3383
3416
  };
3384
3417
  case "provider-defined":
3385
3418
  return {
3386
3419
  type: "provider-defined",
3387
- name: name14,
3420
+ name: name15,
3388
3421
  id: tool2.id,
3389
3422
  args: tool2.args
3390
3423
  };
@@ -3416,12 +3449,12 @@ import { safeParseJSON as safeParseJSON2, safeValidateTypes as safeValidateTypes
3416
3449
  import { asSchema as asSchema3 } from "@ai-sdk/ui-utils";
3417
3450
 
3418
3451
  // errors/invalid-tool-arguments-error.ts
3419
- import { AISDKError as AISDKError10, getErrorMessage as getErrorMessage3 } from "@ai-sdk/provider";
3420
- var name10 = "AI_InvalidToolArgumentsError";
3421
- var marker10 = `vercel.ai.error.${name10}`;
3422
- var symbol10 = Symbol.for(marker10);
3423
- var _a10;
3424
- var InvalidToolArgumentsError = class extends AISDKError10 {
3452
+ import { AISDKError as AISDKError11, getErrorMessage as getErrorMessage3 } from "@ai-sdk/provider";
3453
+ var name11 = "AI_InvalidToolArgumentsError";
3454
+ var marker11 = `vercel.ai.error.${name11}`;
3455
+ var symbol11 = Symbol.for(marker11);
3456
+ var _a11;
3457
+ var InvalidToolArgumentsError = class extends AISDKError11 {
3425
3458
  constructor({
3426
3459
  toolArgs,
3427
3460
  toolName,
@@ -3430,61 +3463,61 @@ var InvalidToolArgumentsError = class extends AISDKError10 {
3430
3463
  cause
3431
3464
  )}`
3432
3465
  }) {
3433
- super({ name: name10, message, cause });
3434
- this[_a10] = true;
3466
+ super({ name: name11, message, cause });
3467
+ this[_a11] = true;
3435
3468
  this.toolArgs = toolArgs;
3436
3469
  this.toolName = toolName;
3437
3470
  }
3438
3471
  static isInstance(error) {
3439
- return AISDKError10.hasMarker(error, marker10);
3472
+ return AISDKError11.hasMarker(error, marker11);
3440
3473
  }
3441
3474
  };
3442
- _a10 = symbol10;
3475
+ _a11 = symbol11;
3443
3476
 
3444
3477
  // errors/no-such-tool-error.ts
3445
- import { AISDKError as AISDKError11 } from "@ai-sdk/provider";
3446
- var name11 = "AI_NoSuchToolError";
3447
- var marker11 = `vercel.ai.error.${name11}`;
3448
- var symbol11 = Symbol.for(marker11);
3449
- var _a11;
3450
- var NoSuchToolError = class extends AISDKError11 {
3478
+ import { AISDKError as AISDKError12 } from "@ai-sdk/provider";
3479
+ var name12 = "AI_NoSuchToolError";
3480
+ var marker12 = `vercel.ai.error.${name12}`;
3481
+ var symbol12 = Symbol.for(marker12);
3482
+ var _a12;
3483
+ var NoSuchToolError = class extends AISDKError12 {
3451
3484
  constructor({
3452
3485
  toolName,
3453
3486
  availableTools = void 0,
3454
3487
  message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === void 0 ? "No tools are available." : `Available tools: ${availableTools.join(", ")}.`}`
3455
3488
  }) {
3456
- super({ name: name11, message });
3457
- this[_a11] = true;
3489
+ super({ name: name12, message });
3490
+ this[_a12] = true;
3458
3491
  this.toolName = toolName;
3459
3492
  this.availableTools = availableTools;
3460
3493
  }
3461
3494
  static isInstance(error) {
3462
- return AISDKError11.hasMarker(error, marker11);
3495
+ return AISDKError12.hasMarker(error, marker12);
3463
3496
  }
3464
3497
  };
3465
- _a11 = symbol11;
3498
+ _a12 = symbol12;
3466
3499
 
3467
3500
  // errors/tool-call-repair-error.ts
3468
- import { AISDKError as AISDKError12, getErrorMessage as getErrorMessage4 } from "@ai-sdk/provider";
3469
- var name12 = "AI_ToolCallRepairError";
3470
- var marker12 = `vercel.ai.error.${name12}`;
3471
- var symbol12 = Symbol.for(marker12);
3472
- var _a12;
3473
- var ToolCallRepairError = class extends AISDKError12 {
3501
+ import { AISDKError as AISDKError13, getErrorMessage as getErrorMessage4 } from "@ai-sdk/provider";
3502
+ var name13 = "AI_ToolCallRepairError";
3503
+ var marker13 = `vercel.ai.error.${name13}`;
3504
+ var symbol13 = Symbol.for(marker13);
3505
+ var _a13;
3506
+ var ToolCallRepairError = class extends AISDKError13 {
3474
3507
  constructor({
3475
3508
  cause,
3476
3509
  originalError,
3477
3510
  message = `Error repairing tool call: ${getErrorMessage4(cause)}`
3478
3511
  }) {
3479
- super({ name: name12, message, cause });
3480
- this[_a12] = true;
3512
+ super({ name: name13, message, cause });
3513
+ this[_a13] = true;
3481
3514
  this.originalError = originalError;
3482
3515
  }
3483
3516
  static isInstance(error) {
3484
- return AISDKError12.hasMarker(error, marker12);
3517
+ return AISDKError13.hasMarker(error, marker13);
3485
3518
  }
3486
3519
  };
3487
- _a12 = symbol12;
3520
+ _a13 = symbol13;
3488
3521
 
3489
3522
  // core/generate-text/parse-tool-call.ts
3490
3523
  async function parseToolCall({
@@ -3629,7 +3662,7 @@ async function generateText({
3629
3662
  onStepFinish,
3630
3663
  ...settings
3631
3664
  }) {
3632
- var _a14;
3665
+ var _a15;
3633
3666
  if (maxSteps < 1) {
3634
3667
  throw new InvalidArgumentError({
3635
3668
  parameter: "maxSteps",
@@ -3646,7 +3679,7 @@ async function generateText({
3646
3679
  });
3647
3680
  const initialPrompt = standardizePrompt({
3648
3681
  prompt: {
3649
- system: (_a14 = output == null ? void 0 : output.injectIntoSystemPrompt({ system, model })) != null ? _a14 : system,
3682
+ system: (_a15 = output == null ? void 0 : output.injectIntoSystemPrompt({ system, model })) != null ? _a15 : system,
3650
3683
  prompt,
3651
3684
  messages
3652
3685
  },
@@ -3672,7 +3705,7 @@ async function generateText({
3672
3705
  }),
3673
3706
  tracer,
3674
3707
  fn: async (span) => {
3675
- var _a15, _b, _c, _d, _e, _f;
3708
+ var _a16, _b, _c, _d, _e, _f;
3676
3709
  const mode = {
3677
3710
  type: "regular",
3678
3711
  ...prepareToolsAndToolChoice({ tools, toolChoice, activeTools })
@@ -3724,8 +3757,8 @@ async function generateText({
3724
3757
  "ai.prompt.tools": {
3725
3758
  // convert the language model level tools:
3726
3759
  input: () => {
3727
- var _a16;
3728
- return (_a16 = mode.tools) == null ? void 0 : _a16.map((tool2) => JSON.stringify(tool2));
3760
+ var _a17;
3761
+ return (_a17 = mode.tools) == null ? void 0 : _a17.map((tool2) => JSON.stringify(tool2));
3729
3762
  }
3730
3763
  },
3731
3764
  "ai.prompt.toolChoice": {
@@ -3745,7 +3778,7 @@ async function generateText({
3745
3778
  }),
3746
3779
  tracer,
3747
3780
  fn: async (span2) => {
3748
- var _a16, _b2, _c2, _d2, _e2, _f2;
3781
+ var _a17, _b2, _c2, _d2, _e2, _f2;
3749
3782
  const result = await model.doGenerate({
3750
3783
  mode,
3751
3784
  ...callSettings,
@@ -3757,7 +3790,7 @@ async function generateText({
3757
3790
  headers
3758
3791
  });
3759
3792
  const responseData = {
3760
- id: (_b2 = (_a16 = result.response) == null ? void 0 : _a16.id) != null ? _b2 : generateId3(),
3793
+ id: (_b2 = (_a17 = result.response) == null ? void 0 : _a17.id) != null ? _b2 : generateId3(),
3761
3794
  timestamp: (_d2 = (_c2 = result.response) == null ? void 0 : _c2.timestamp) != null ? _d2 : currentDate(),
3762
3795
  modelId: (_f2 = (_e2 = result.response) == null ? void 0 : _e2.modelId) != null ? _f2 : model.modelId
3763
3796
  };
@@ -3791,7 +3824,7 @@ async function generateText({
3791
3824
  })
3792
3825
  );
3793
3826
  currentToolCalls = await Promise.all(
3794
- ((_a15 = currentModelResponse.toolCalls) != null ? _a15 : []).map(
3827
+ ((_a16 = currentModelResponse.toolCalls) != null ? _a16 : []).map(
3795
3828
  (toolCall) => parseToolCall({
3796
3829
  toolCall,
3797
3830
  tools,
@@ -4033,7 +4066,7 @@ import {
4033
4066
 
4034
4067
  // errors/index.ts
4035
4068
  import {
4036
- AISDKError as AISDKError13,
4069
+ AISDKError as AISDKError14,
4037
4070
  APICallError as APICallError2,
4038
4071
  EmptyResponseBodyError,
4039
4072
  InvalidPromptError as InvalidPromptError2,
@@ -4483,7 +4516,8 @@ function streamText({
4483
4516
  experimental_continueSteps: continueSteps = false,
4484
4517
  experimental_telemetry: telemetry,
4485
4518
  experimental_providerMetadata: providerMetadata,
4486
- experimental_toolCallStreaming: toolCallStreaming = false,
4519
+ experimental_toolCallStreaming = false,
4520
+ toolCallStreaming = experimental_toolCallStreaming,
4487
4521
  experimental_activeTools: activeTools,
4488
4522
  experimental_repairToolCall: repairToolCall,
4489
4523
  experimental_transform: transform,
@@ -4617,7 +4651,7 @@ var DefaultStreamTextResult = class {
4617
4651
  this.requestPromise = new DelayedPromise();
4618
4652
  this.responsePromise = new DelayedPromise();
4619
4653
  this.stepsPromise = new DelayedPromise();
4620
- var _a14;
4654
+ var _a15;
4621
4655
  if (maxSteps < 1) {
4622
4656
  throw new InvalidArgumentError({
4623
4657
  parameter: "maxSteps",
@@ -4728,7 +4762,7 @@ var DefaultStreamTextResult = class {
4728
4762
  }
4729
4763
  },
4730
4764
  async flush(controller) {
4731
- var _a15;
4765
+ var _a16;
4732
4766
  try {
4733
4767
  if (recordedSteps.length === 0) {
4734
4768
  return;
@@ -4761,7 +4795,7 @@ var DefaultStreamTextResult = class {
4761
4795
  reasoning: recordedReasoningText,
4762
4796
  toolCalls: lastStep.toolCalls,
4763
4797
  toolResults: lastStep.toolResults,
4764
- request: (_a15 = lastStep.request) != null ? _a15 : {},
4798
+ request: (_a16 = lastStep.request) != null ? _a16 : {},
4765
4799
  response: lastStep.response,
4766
4800
  warnings: lastStep.warnings,
4767
4801
  experimental_providerMetadata: lastStep.experimental_providerMetadata,
@@ -4775,8 +4809,8 @@ var DefaultStreamTextResult = class {
4775
4809
  "ai.response.text": { output: () => recordedFullText },
4776
4810
  "ai.response.toolCalls": {
4777
4811
  output: () => {
4778
- var _a16;
4779
- return ((_a16 = lastStep.toolCalls) == null ? void 0 : _a16.length) ? JSON.stringify(lastStep.toolCalls) : void 0;
4812
+ var _a17;
4813
+ return ((_a17 = lastStep.toolCalls) == null ? void 0 : _a17.length) ? JSON.stringify(lastStep.toolCalls) : void 0;
4780
4814
  }
4781
4815
  },
4782
4816
  "ai.usage.promptTokens": usage.promptTokens,
@@ -4818,7 +4852,7 @@ var DefaultStreamTextResult = class {
4818
4852
  });
4819
4853
  const initialPrompt = standardizePrompt({
4820
4854
  prompt: {
4821
- system: (_a14 = output == null ? void 0 : output.injectIntoSystemPrompt({ system, model })) != null ? _a14 : system,
4855
+ system: (_a15 = output == null ? void 0 : output.injectIntoSystemPrompt({ system, model })) != null ? _a15 : system,
4822
4856
  prompt,
4823
4857
  messages
4824
4858
  },
@@ -4894,8 +4928,8 @@ var DefaultStreamTextResult = class {
4894
4928
  "ai.prompt.tools": {
4895
4929
  // convert the language model level tools:
4896
4930
  input: () => {
4897
- var _a15;
4898
- return (_a15 = mode.tools) == null ? void 0 : _a15.map((tool2) => JSON.stringify(tool2));
4931
+ var _a16;
4932
+ return (_a16 = mode.tools) == null ? void 0 : _a16.map((tool2) => JSON.stringify(tool2));
4899
4933
  }
4900
4934
  },
4901
4935
  "ai.prompt.toolChoice": {
@@ -4981,7 +5015,7 @@ var DefaultStreamTextResult = class {
4981
5015
  transformedStream.pipeThrough(
4982
5016
  new TransformStream({
4983
5017
  async transform(chunk, controller) {
4984
- var _a15, _b, _c;
5018
+ var _a16, _b, _c;
4985
5019
  if (stepFirstChunk) {
4986
5020
  const msToFirstChunk = now2() - startTimestampMs;
4987
5021
  stepFirstChunk = false;
@@ -5044,7 +5078,7 @@ var DefaultStreamTextResult = class {
5044
5078
  }
5045
5079
  case "response-metadata": {
5046
5080
  stepResponse = {
5047
- id: (_a15 = chunk.id) != null ? _a15 : stepResponse.id,
5081
+ id: (_a16 = chunk.id) != null ? _a16 : stepResponse.id,
5048
5082
  timestamp: (_b = chunk.timestamp) != null ? _b : stepResponse.timestamp,
5049
5083
  modelId: (_c = chunk.modelId) != null ? _c : stepResponse.modelId
5050
5084
  };
@@ -5497,9 +5531,9 @@ var DefaultStreamTextResult = class {
5497
5531
  );
5498
5532
  }
5499
5533
  toTextStreamResponse(init) {
5500
- var _a14;
5534
+ var _a15;
5501
5535
  return new Response(this.textStream.pipeThrough(new TextEncoderStream()), {
5502
- status: (_a14 = init == null ? void 0 : init.status) != null ? _a14 : 200,
5536
+ status: (_a15 = init == null ? void 0 : init.status) != null ? _a15 : 200,
5503
5537
  headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
5504
5538
  contentType: "text/plain; charset=utf-8"
5505
5539
  })
@@ -5546,7 +5580,7 @@ function appendResponseMessages({
5546
5580
  messages,
5547
5581
  responseMessages
5548
5582
  }) {
5549
- var _a14;
5583
+ var _a15;
5550
5584
  const clonedMessages = structuredClone(messages);
5551
5585
  for (const message of responseMessages) {
5552
5586
  const role = message.role;
@@ -5569,7 +5603,7 @@ function appendResponseMessages({
5569
5603
  }
5570
5604
  case "tool": {
5571
5605
  const previousMessage = clonedMessages[clonedMessages.length - 1];
5572
- (_a14 = previousMessage.toolInvocations) != null ? _a14 : previousMessage.toolInvocations = [];
5606
+ (_a15 = previousMessage.toolInvocations) != null ? _a15 : previousMessage.toolInvocations = [];
5573
5607
  if (previousMessage.role !== "assistant") {
5574
5608
  throw new Error(
5575
5609
  `Tool result must follow an assistant message: ${previousMessage.role}`
@@ -5627,11 +5661,11 @@ function experimental_customProvider({
5627
5661
  }
5628
5662
 
5629
5663
  // core/registry/no-such-provider-error.ts
5630
- import { AISDKError as AISDKError14, NoSuchModelError as NoSuchModelError3 } from "@ai-sdk/provider";
5631
- var name13 = "AI_NoSuchProviderError";
5632
- var marker13 = `vercel.ai.error.${name13}`;
5633
- var symbol13 = Symbol.for(marker13);
5634
- var _a13;
5664
+ import { AISDKError as AISDKError15, NoSuchModelError as NoSuchModelError3 } from "@ai-sdk/provider";
5665
+ var name14 = "AI_NoSuchProviderError";
5666
+ var marker14 = `vercel.ai.error.${name14}`;
5667
+ var symbol14 = Symbol.for(marker14);
5668
+ var _a14;
5635
5669
  var NoSuchProviderError = class extends NoSuchModelError3 {
5636
5670
  constructor({
5637
5671
  modelId,
@@ -5640,16 +5674,16 @@ var NoSuchProviderError = class extends NoSuchModelError3 {
5640
5674
  availableProviders,
5641
5675
  message = `No such provider: ${providerId} (available providers: ${availableProviders.join()})`
5642
5676
  }) {
5643
- super({ errorName: name13, modelId, modelType, message });
5644
- this[_a13] = true;
5677
+ super({ errorName: name14, modelId, modelType, message });
5678
+ this[_a14] = true;
5645
5679
  this.providerId = providerId;
5646
5680
  this.availableProviders = availableProviders;
5647
5681
  }
5648
5682
  static isInstance(error) {
5649
- return AISDKError14.hasMarker(error, marker13);
5683
+ return AISDKError15.hasMarker(error, marker14);
5650
5684
  }
5651
5685
  };
5652
- _a13 = symbol13;
5686
+ _a14 = symbol14;
5653
5687
 
5654
5688
  // core/registry/provider-registry.ts
5655
5689
  import { NoSuchModelError as NoSuchModelError4 } from "@ai-sdk/provider";
@@ -5691,19 +5725,19 @@ var DefaultProviderRegistry = class {
5691
5725
  return [id.slice(0, index), id.slice(index + 1)];
5692
5726
  }
5693
5727
  languageModel(id) {
5694
- var _a14, _b;
5728
+ var _a15, _b;
5695
5729
  const [providerId, modelId] = this.splitId(id, "languageModel");
5696
- const model = (_b = (_a14 = this.getProvider(providerId)).languageModel) == null ? void 0 : _b.call(_a14, modelId);
5730
+ const model = (_b = (_a15 = this.getProvider(providerId)).languageModel) == null ? void 0 : _b.call(_a15, modelId);
5697
5731
  if (model == null) {
5698
5732
  throw new NoSuchModelError4({ modelId: id, modelType: "languageModel" });
5699
5733
  }
5700
5734
  return model;
5701
5735
  }
5702
5736
  textEmbeddingModel(id) {
5703
- var _a14;
5737
+ var _a15;
5704
5738
  const [providerId, modelId] = this.splitId(id, "textEmbeddingModel");
5705
5739
  const provider = this.getProvider(providerId);
5706
- const model = (_a14 = provider.textEmbeddingModel) == null ? void 0 : _a14.call(provider, modelId);
5740
+ const model = (_a15 = provider.textEmbeddingModel) == null ? void 0 : _a15.call(provider, modelId);
5707
5741
  if (model == null) {
5708
5742
  throw new NoSuchModelError4({
5709
5743
  modelId: id,
@@ -5766,8 +5800,8 @@ function simulateReadableStream({
5766
5800
  chunkDelayInMs = 0,
5767
5801
  _internal
5768
5802
  }) {
5769
- var _a14;
5770
- const delay2 = (_a14 = _internal == null ? void 0 : _internal.delay) != null ? _a14 : delay;
5803
+ var _a15;
5804
+ const delay2 = (_a15 = _internal == null ? void 0 : _internal.delay) != null ? _a15 : delay;
5771
5805
  let index = 0;
5772
5806
  return new ReadableStream({
5773
5807
  async pull(controller) {
@@ -5788,7 +5822,7 @@ import {
5788
5822
  function AssistantResponse({ threadId, messageId }, process2) {
5789
5823
  const stream = new ReadableStream({
5790
5824
  async start(controller) {
5791
- var _a14;
5825
+ var _a15;
5792
5826
  const textEncoder = new TextEncoder();
5793
5827
  const sendMessage = (message) => {
5794
5828
  controller.enqueue(
@@ -5810,7 +5844,7 @@ function AssistantResponse({ threadId, messageId }, process2) {
5810
5844
  );
5811
5845
  };
5812
5846
  const forwardStream = async (stream2) => {
5813
- var _a15, _b;
5847
+ var _a16, _b;
5814
5848
  let result = void 0;
5815
5849
  for await (const value of stream2) {
5816
5850
  switch (value.event) {
@@ -5827,7 +5861,7 @@ function AssistantResponse({ threadId, messageId }, process2) {
5827
5861
  break;
5828
5862
  }
5829
5863
  case "thread.message.delta": {
5830
- const content = (_a15 = value.data.delta.content) == null ? void 0 : _a15[0];
5864
+ const content = (_a16 = value.data.delta.content) == null ? void 0 : _a16[0];
5831
5865
  if ((content == null ? void 0 : content.type) === "text" && ((_b = content.text) == null ? void 0 : _b.value) != null) {
5832
5866
  controller.enqueue(
5833
5867
  textEncoder.encode(
@@ -5861,7 +5895,7 @@ function AssistantResponse({ threadId, messageId }, process2) {
5861
5895
  forwardStream
5862
5896
  });
5863
5897
  } catch (error) {
5864
- sendError((_a14 = error.message) != null ? _a14 : `${error}`);
5898
+ sendError((_a15 = error.message) != null ? _a15 : `${error}`);
5865
5899
  } finally {
5866
5900
  controller.close();
5867
5901
  }
@@ -5922,7 +5956,7 @@ function toDataStreamInternal(stream, callbacks) {
5922
5956
  return stream.pipeThrough(
5923
5957
  new TransformStream({
5924
5958
  transform: async (value, controller) => {
5925
- var _a14;
5959
+ var _a15;
5926
5960
  if (typeof value === "string") {
5927
5961
  controller.enqueue(value);
5928
5962
  return;
@@ -5930,7 +5964,7 @@ function toDataStreamInternal(stream, callbacks) {
5930
5964
  if ("event" in value) {
5931
5965
  if (value.event === "on_chat_model_stream") {
5932
5966
  forwardAIMessageChunk(
5933
- (_a14 = value.data) == null ? void 0 : _a14.chunk,
5967
+ (_a15 = value.data) == null ? void 0 : _a15.chunk,
5934
5968
  controller
5935
5969
  );
5936
5970
  }
@@ -5953,7 +5987,7 @@ function toDataStream(stream, callbacks) {
5953
5987
  );
5954
5988
  }
5955
5989
  function toDataStreamResponse(stream, options) {
5956
- var _a14;
5990
+ var _a15;
5957
5991
  const dataStream = toDataStreamInternal(
5958
5992
  stream,
5959
5993
  options == null ? void 0 : options.callbacks
@@ -5962,7 +5996,7 @@ function toDataStreamResponse(stream, options) {
5962
5996
  const init = options == null ? void 0 : options.init;
5963
5997
  const responseStream = data ? mergeStreams(data.stream, dataStream) : dataStream;
5964
5998
  return new Response(responseStream, {
5965
- status: (_a14 = init == null ? void 0 : init.status) != null ? _a14 : 200,
5999
+ status: (_a15 = init == null ? void 0 : init.status) != null ? _a15 : 200,
5966
6000
  statusText: init == null ? void 0 : init.statusText,
5967
6001
  headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
5968
6002
  contentType: "text/plain; charset=utf-8",
@@ -6017,14 +6051,14 @@ function toDataStream2(stream, callbacks) {
6017
6051
  );
6018
6052
  }
6019
6053
  function toDataStreamResponse2(stream, options = {}) {
6020
- var _a14;
6054
+ var _a15;
6021
6055
  const { init, data, callbacks } = options;
6022
6056
  const dataStream = toDataStreamInternal2(stream, callbacks).pipeThrough(
6023
6057
  new TextEncoderStream()
6024
6058
  );
6025
6059
  const responseStream = data ? mergeStreams(data.stream, dataStream) : dataStream;
6026
6060
  return new Response(responseStream, {
6027
- status: (_a14 = init == null ? void 0 : init.status) != null ? _a14 : 200,
6061
+ status: (_a15 = init == null ? void 0 : init.status) != null ? _a15 : 200,
6028
6062
  statusText: init == null ? void 0 : init.statusText,
6029
6063
  headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
6030
6064
  contentType: "text/plain; charset=utf-8",
@@ -6116,7 +6150,7 @@ var StreamData = class {
6116
6150
  }
6117
6151
  };
6118
6152
  export {
6119
- AISDKError13 as AISDKError,
6153
+ AISDKError14 as AISDKError,
6120
6154
  APICallError2 as APICallError,
6121
6155
  AssistantResponse,
6122
6156
  DownloadError,
@@ -6133,6 +6167,7 @@ export {
6133
6167
  LoadAPIKeyError,
6134
6168
  MessageConversionError,
6135
6169
  NoContentGeneratedError,
6170
+ NoImageGeneratedError,
6136
6171
  NoObjectGeneratedError,
6137
6172
  NoOutputSpecifiedError,
6138
6173
  NoSuchModelError,