ai 6.0.0-beta.66 → 6.0.0-beta.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -61,7 +61,7 @@ __export(src_exports, {
61
61
  UI_MESSAGE_STREAM_HEADERS: () => UI_MESSAGE_STREAM_HEADERS,
62
62
  UnsupportedFunctionalityError: () => import_provider18.UnsupportedFunctionalityError,
63
63
  UnsupportedModelVersionError: () => UnsupportedModelVersionError,
64
- asSchema: () => import_provider_utils37.asSchema,
64
+ asSchema: () => import_provider_utils38.asSchema,
65
65
  assistantModelMessageSchema: () => assistantModelMessageSchema,
66
66
  callCompletionApi: () => callCompletionApi,
67
67
  consumeStream: () => consumeStream,
@@ -77,14 +77,14 @@ __export(src_exports, {
77
77
  createAgentUIStream: () => createAgentUIStream,
78
78
  createAgentUIStreamResponse: () => createAgentUIStreamResponse,
79
79
  createGateway: () => import_gateway3.createGateway,
80
- createIdGenerator: () => import_provider_utils37.createIdGenerator,
80
+ createIdGenerator: () => import_provider_utils38.createIdGenerator,
81
81
  createProviderRegistry: () => createProviderRegistry,
82
82
  createTextStreamResponse: () => createTextStreamResponse,
83
83
  createUIMessageStream: () => createUIMessageStream,
84
84
  createUIMessageStreamResponse: () => createUIMessageStreamResponse,
85
85
  customProvider: () => customProvider,
86
86
  defaultSettingsMiddleware: () => defaultSettingsMiddleware,
87
- dynamicTool: () => import_provider_utils37.dynamicTool,
87
+ dynamicTool: () => import_provider_utils38.dynamicTool,
88
88
  embed: () => embed,
89
89
  embedMany: () => embedMany,
90
90
  experimental_createMCPClient: () => createMCPClient,
@@ -95,7 +95,7 @@ __export(src_exports, {
95
95
  experimental_transcribe: () => transcribe,
96
96
  extractReasoningMiddleware: () => extractReasoningMiddleware,
97
97
  gateway: () => import_gateway3.gateway,
98
- generateId: () => import_provider_utils37.generateId,
98
+ generateId: () => import_provider_utils38.generateId,
99
99
  generateObject: () => generateObject,
100
100
  generateText: () => generateText,
101
101
  getTextFromDataUrl: () => getTextFromDataUrl,
@@ -104,13 +104,16 @@ __export(src_exports, {
104
104
  hasToolCall: () => hasToolCall,
105
105
  isDataUIPart: () => isDataUIPart,
106
106
  isDeepEqualData: () => isDeepEqualData,
107
+ isFileUIPart: () => isFileUIPart,
108
+ isReasoningUIPart: () => isReasoningUIPart,
109
+ isTextUIPart: () => isTextUIPart,
107
110
  isToolOrDynamicToolUIPart: () => isToolOrDynamicToolUIPart,
108
111
  isToolUIPart: () => isToolUIPart,
109
- jsonSchema: () => import_provider_utils37.jsonSchema,
112
+ jsonSchema: () => import_provider_utils38.jsonSchema,
110
113
  lastAssistantMessageIsCompleteWithApprovalResponses: () => lastAssistantMessageIsCompleteWithApprovalResponses,
111
114
  lastAssistantMessageIsCompleteWithToolCalls: () => lastAssistantMessageIsCompleteWithToolCalls,
112
115
  modelMessageSchema: () => modelMessageSchema,
113
- parseJsonEventStream: () => import_provider_utils37.parseJsonEventStream,
116
+ parseJsonEventStream: () => import_provider_utils38.parseJsonEventStream,
114
117
  parsePartialJson: () => parsePartialJson,
115
118
  pipeAgentUIStreamToResponse: () => pipeAgentUIStreamToResponse,
116
119
  pipeTextStreamToResponse: () => pipeTextStreamToResponse,
@@ -125,18 +128,18 @@ __export(src_exports, {
125
128
  streamObject: () => streamObject,
126
129
  streamText: () => streamText,
127
130
  systemModelMessageSchema: () => systemModelMessageSchema,
128
- tool: () => import_provider_utils37.tool,
131
+ tool: () => import_provider_utils38.tool,
129
132
  toolModelMessageSchema: () => toolModelMessageSchema,
130
133
  uiMessageChunkSchema: () => uiMessageChunkSchema,
131
134
  userModelMessageSchema: () => userModelMessageSchema,
132
135
  validateUIMessages: () => validateUIMessages,
133
136
  wrapLanguageModel: () => wrapLanguageModel,
134
137
  wrapProvider: () => wrapProvider,
135
- zodSchema: () => import_provider_utils37.zodSchema
138
+ zodSchema: () => import_provider_utils38.zodSchema
136
139
  });
137
140
  module.exports = __toCommonJS(src_exports);
138
141
  var import_gateway3 = require("@ai-sdk/gateway");
139
- var import_provider_utils37 = require("@ai-sdk/provider-utils");
142
+ var import_provider_utils38 = require("@ai-sdk/provider-utils");
140
143
 
141
144
  // src/generate-text/generate-text.ts
142
145
  var import_provider_utils11 = require("@ai-sdk/provider-utils");
@@ -873,7 +876,7 @@ function detectMediaType({
873
876
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
874
877
 
875
878
  // src/version.ts
876
- var VERSION = true ? "6.0.0-beta.66" : "0.0.0-test";
879
+ var VERSION = true ? "6.0.0-beta.68" : "0.0.0-test";
877
880
 
878
881
  // src/util/download/download.ts
879
882
  var download = async ({ url }) => {
@@ -3909,6 +3912,15 @@ async function parsePartialJson(jsonText) {
3909
3912
  function isDataUIPart(part) {
3910
3913
  return part.type.startsWith("data-");
3911
3914
  }
3915
+ function isTextUIPart(part) {
3916
+ return part.type === "text";
3917
+ }
3918
+ function isFileUIPart(part) {
3919
+ return part.type === "file";
3920
+ }
3921
+ function isReasoningUIPart(part) {
3922
+ return part.type === "reasoning";
3923
+ }
3912
3924
  function isToolUIPart(part) {
3913
3925
  return part.type.startsWith("tool-");
3914
3926
  }
@@ -6505,6 +6517,7 @@ function readUIMessageStream({
6505
6517
  }
6506
6518
 
6507
6519
  // src/ui/convert-to-model-messages.ts
6520
+ var import_provider_utils18 = require("@ai-sdk/provider-utils");
6508
6521
  function convertToModelMessages(messages, options) {
6509
6522
  const modelMessages = [];
6510
6523
  if (options == null ? void 0 : options.ignoreIncompleteToolCalls) {
@@ -6518,7 +6531,9 @@ function convertToModelMessages(messages, options) {
6518
6531
  for (const message of messages) {
6519
6532
  switch (message.role) {
6520
6533
  case "system": {
6521
- const textParts = message.parts.filter((part) => part.type === "text");
6534
+ const textParts = message.parts.filter(
6535
+ (part) => part.type === "text"
6536
+ );
6522
6537
  const providerMetadata = textParts.reduce((acc, part) => {
6523
6538
  if (part.providerMetadata != null) {
6524
6539
  return { ...acc, ...part.providerMetadata };
@@ -6535,54 +6550,57 @@ function convertToModelMessages(messages, options) {
6535
6550
  case "user": {
6536
6551
  modelMessages.push({
6537
6552
  role: "user",
6538
- content: message.parts.filter(
6539
- (part) => part.type === "text" || part.type === "file"
6540
- ).map((part) => {
6541
- switch (part.type) {
6542
- case "text":
6543
- return {
6544
- type: "text",
6545
- text: part.text,
6546
- ...part.providerMetadata != null ? { providerOptions: part.providerMetadata } : {}
6547
- };
6548
- case "file":
6549
- return {
6550
- type: "file",
6551
- mediaType: part.mediaType,
6552
- filename: part.filename,
6553
- data: part.url,
6554
- ...part.providerMetadata != null ? { providerOptions: part.providerMetadata } : {}
6555
- };
6556
- default:
6557
- return part;
6553
+ content: message.parts.map((part) => {
6554
+ var _a17;
6555
+ if (isTextUIPart(part)) {
6556
+ return {
6557
+ type: "text",
6558
+ text: part.text,
6559
+ ...part.providerMetadata != null ? { providerOptions: part.providerMetadata } : {}
6560
+ };
6558
6561
  }
6559
- })
6562
+ if (isFileUIPart(part)) {
6563
+ return {
6564
+ type: "file",
6565
+ mediaType: part.mediaType,
6566
+ filename: part.filename,
6567
+ data: part.url,
6568
+ ...part.providerMetadata != null ? { providerOptions: part.providerMetadata } : {}
6569
+ };
6570
+ }
6571
+ if (isDataUIPart(part)) {
6572
+ return (_a17 = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _a17.call(
6573
+ options,
6574
+ part
6575
+ );
6576
+ }
6577
+ }).filter(import_provider_utils18.isNonNullable)
6560
6578
  });
6561
6579
  break;
6562
6580
  }
6563
6581
  case "assistant": {
6564
6582
  if (message.parts != null) {
6565
6583
  let processBlock2 = function() {
6566
- var _a17, _b;
6584
+ var _a17, _b, _c;
6567
6585
  if (block.length === 0) {
6568
6586
  return;
6569
6587
  }
6570
6588
  const content = [];
6571
6589
  for (const part of block) {
6572
- if (part.type === "text") {
6590
+ if (isTextUIPart(part)) {
6573
6591
  content.push({
6574
6592
  type: "text",
6575
6593
  text: part.text,
6576
6594
  ...part.providerMetadata != null ? { providerOptions: part.providerMetadata } : {}
6577
6595
  });
6578
- } else if (part.type === "file") {
6596
+ } else if (isFileUIPart(part)) {
6579
6597
  content.push({
6580
6598
  type: "file",
6581
6599
  mediaType: part.mediaType,
6582
6600
  filename: part.filename,
6583
6601
  data: part.url
6584
6602
  });
6585
- } else if (part.type === "reasoning") {
6603
+ } else if (isReasoningUIPart(part)) {
6586
6604
  content.push({
6587
6605
  type: "reasoning",
6588
6606
  text: part.text,
@@ -6619,6 +6637,14 @@ function convertToModelMessages(messages, options) {
6619
6637
  });
6620
6638
  }
6621
6639
  }
6640
+ } else if (isDataUIPart(part)) {
6641
+ const dataPart = (_c = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _c.call(
6642
+ options,
6643
+ part
6644
+ );
6645
+ if (dataPart != null) {
6646
+ content.push(dataPart);
6647
+ }
6622
6648
  } else {
6623
6649
  const _exhaustiveCheck = part;
6624
6650
  throw new Error(`Unsupported part: ${_exhaustiveCheck}`);
@@ -6636,7 +6662,7 @@ function convertToModelMessages(messages, options) {
6636
6662
  role: "tool",
6637
6663
  content: toolParts.flatMap(
6638
6664
  (toolPart) => {
6639
- var _a18, _b2, _c;
6665
+ var _a18, _b2, _c2;
6640
6666
  const outputs = [];
6641
6667
  if (((_a18 = toolPart.approval) == null ? void 0 : _a18.approved) != null) {
6642
6668
  outputs.push({
@@ -6668,7 +6694,7 @@ function convertToModelMessages(messages, options) {
6668
6694
  toolName,
6669
6695
  output: createToolModelOutput({
6670
6696
  output: toolPart.state === "output-error" ? toolPart.errorText : toolPart.output,
6671
- tool: (_c = options == null ? void 0 : options.tools) == null ? void 0 : _c[toolName],
6697
+ tool: (_c2 = options == null ? void 0 : options.tools) == null ? void 0 : _c2[toolName],
6672
6698
  errorMode: toolPart.state === "output-error" ? "text" : "none"
6673
6699
  })
6674
6700
  });
@@ -6685,7 +6711,7 @@ function convertToModelMessages(messages, options) {
6685
6711
  var processBlock = processBlock2;
6686
6712
  let block = [];
6687
6713
  for (const part of message.parts) {
6688
- if (part.type === "text" || part.type === "reasoning" || part.type === "file" || isToolOrDynamicToolUIPart(part)) {
6714
+ if (isTextUIPart(part) || isReasoningUIPart(part) || isFileUIPart(part) || isToolOrDynamicToolUIPart(part) || isDataUIPart(part)) {
6689
6715
  block.push(part);
6690
6716
  } else if (part.type === "step-start") {
6691
6717
  processBlock2();
@@ -6711,10 +6737,10 @@ var convertToCoreMessages = convertToModelMessages;
6711
6737
 
6712
6738
  // src/ui/validate-ui-messages.ts
6713
6739
  var import_provider25 = require("@ai-sdk/provider");
6714
- var import_provider_utils18 = require("@ai-sdk/provider-utils");
6740
+ var import_provider_utils19 = require("@ai-sdk/provider-utils");
6715
6741
  var import_v48 = require("zod/v4");
6716
- var uiMessagesSchema = (0, import_provider_utils18.lazySchema)(
6717
- () => (0, import_provider_utils18.zodSchema)(
6742
+ var uiMessagesSchema = (0, import_provider_utils19.lazySchema)(
6743
+ () => (0, import_provider_utils19.zodSchema)(
6718
6744
  import_v48.z.array(
6719
6745
  import_v48.z.object({
6720
6746
  id: import_v48.z.string(),
@@ -6988,13 +7014,13 @@ async function safeValidateUIMessages({
6988
7014
  })
6989
7015
  };
6990
7016
  }
6991
- const validatedMessages = await (0, import_provider_utils18.validateTypes)({
7017
+ const validatedMessages = await (0, import_provider_utils19.validateTypes)({
6992
7018
  value: messages,
6993
7019
  schema: uiMessagesSchema
6994
7020
  });
6995
7021
  if (metadataSchema) {
6996
7022
  for (const message of validatedMessages) {
6997
- await (0, import_provider_utils18.validateTypes)({
7023
+ await (0, import_provider_utils19.validateTypes)({
6998
7024
  value: message.metadata,
6999
7025
  schema: metadataSchema
7000
7026
  });
@@ -7017,7 +7043,7 @@ async function safeValidateUIMessages({
7017
7043
  })
7018
7044
  };
7019
7045
  }
7020
- await (0, import_provider_utils18.validateTypes)({
7046
+ await (0, import_provider_utils19.validateTypes)({
7021
7047
  value: dataPart.data,
7022
7048
  schema: dataSchema
7023
7049
  });
@@ -7042,13 +7068,13 @@ async function safeValidateUIMessages({
7042
7068
  };
7043
7069
  }
7044
7070
  if (toolPart.state === "input-available" || toolPart.state === "output-available" || toolPart.state === "output-error") {
7045
- await (0, import_provider_utils18.validateTypes)({
7071
+ await (0, import_provider_utils19.validateTypes)({
7046
7072
  value: toolPart.input,
7047
7073
  schema: tool3.inputSchema
7048
7074
  });
7049
7075
  }
7050
7076
  if (toolPart.state === "output-available" && tool3.outputSchema) {
7051
- await (0, import_provider_utils18.validateTypes)({
7077
+ await (0, import_provider_utils19.validateTypes)({
7052
7078
  value: toolPart.output,
7053
7079
  schema: tool3.outputSchema
7054
7080
  });
@@ -7143,7 +7169,7 @@ async function pipeAgentUIStreamToResponse({
7143
7169
  }
7144
7170
 
7145
7171
  // src/embed/embed.ts
7146
- var import_provider_utils19 = require("@ai-sdk/provider-utils");
7172
+ var import_provider_utils20 = require("@ai-sdk/provider-utils");
7147
7173
  async function embed({
7148
7174
  model: modelArg,
7149
7175
  value,
@@ -7158,7 +7184,7 @@ async function embed({
7158
7184
  maxRetries: maxRetriesArg,
7159
7185
  abortSignal
7160
7186
  });
7161
- const headersWithUserAgent = (0, import_provider_utils19.withUserAgentSuffix)(
7187
+ const headersWithUserAgent = (0, import_provider_utils20.withUserAgentSuffix)(
7162
7188
  headers != null ? headers : {},
7163
7189
  `ai/${VERSION}`
7164
7190
  );
@@ -7262,7 +7288,7 @@ var DefaultEmbedResult = class {
7262
7288
  };
7263
7289
 
7264
7290
  // src/embed/embed-many.ts
7265
- var import_provider_utils20 = require("@ai-sdk/provider-utils");
7291
+ var import_provider_utils21 = require("@ai-sdk/provider-utils");
7266
7292
 
7267
7293
  // src/util/split-array.ts
7268
7294
  function splitArray(array, chunkSize) {
@@ -7292,7 +7318,7 @@ async function embedMany({
7292
7318
  maxRetries: maxRetriesArg,
7293
7319
  abortSignal
7294
7320
  });
7295
- const headersWithUserAgent = (0, import_provider_utils20.withUserAgentSuffix)(
7321
+ const headersWithUserAgent = (0, import_provider_utils21.withUserAgentSuffix)(
7296
7322
  headers != null ? headers : {},
7297
7323
  `ai/${VERSION}`
7298
7324
  );
@@ -7511,7 +7537,7 @@ var DefaultEmbedManyResult = class {
7511
7537
  };
7512
7538
 
7513
7539
  // src/generate-image/generate-image.ts
7514
- var import_provider_utils21 = require("@ai-sdk/provider-utils");
7540
+ var import_provider_utils22 = require("@ai-sdk/provider-utils");
7515
7541
  async function generateImage({
7516
7542
  model,
7517
7543
  prompt,
@@ -7533,7 +7559,7 @@ async function generateImage({
7533
7559
  modelId: model.modelId
7534
7560
  });
7535
7561
  }
7536
- const headersWithUserAgent = (0, import_provider_utils21.withUserAgentSuffix)(
7562
+ const headersWithUserAgent = (0, import_provider_utils22.withUserAgentSuffix)(
7537
7563
  headers != null ? headers : {},
7538
7564
  `ai/${VERSION}`
7539
7565
  );
@@ -7629,7 +7655,7 @@ async function invokeModelMaxImagesPerCall(model) {
7629
7655
  }
7630
7656
 
7631
7657
  // src/generate-object/generate-object.ts
7632
- var import_provider_utils24 = require("@ai-sdk/provider-utils");
7658
+ var import_provider_utils25 = require("@ai-sdk/provider-utils");
7633
7659
 
7634
7660
  // src/generate-text/extract-reasoning-content.ts
7635
7661
  function extractReasoningContent(content) {
@@ -7641,7 +7667,7 @@ function extractReasoningContent(content) {
7641
7667
 
7642
7668
  // src/generate-object/output-strategy.ts
7643
7669
  var import_provider26 = require("@ai-sdk/provider");
7644
- var import_provider_utils22 = require("@ai-sdk/provider-utils");
7670
+ var import_provider_utils23 = require("@ai-sdk/provider-utils");
7645
7671
  var noSchemaOutputStrategy = {
7646
7672
  type: "no-schema",
7647
7673
  jsonSchema: async () => void 0,
@@ -7680,7 +7706,7 @@ var objectOutputStrategy = (schema) => ({
7680
7706
  };
7681
7707
  },
7682
7708
  async validateFinalResult(value) {
7683
- return (0, import_provider_utils22.safeValidateTypes)({ value, schema });
7709
+ return (0, import_provider_utils23.safeValidateTypes)({ value, schema });
7684
7710
  },
7685
7711
  createElementStream() {
7686
7712
  throw new import_provider26.UnsupportedFunctionalityError({
@@ -7726,7 +7752,7 @@ var arrayOutputStrategy = (schema) => {
7726
7752
  const resultArray = [];
7727
7753
  for (let i = 0; i < inputArray.length; i++) {
7728
7754
  const element = inputArray[i];
7729
- const result = await (0, import_provider_utils22.safeValidateTypes)({ value: element, schema });
7755
+ const result = await (0, import_provider_utils23.safeValidateTypes)({ value: element, schema });
7730
7756
  if (i === inputArray.length - 1 && !isFinalDelta) {
7731
7757
  continue;
7732
7758
  }
@@ -7767,7 +7793,7 @@ var arrayOutputStrategy = (schema) => {
7767
7793
  }
7768
7794
  const inputArray = value.elements;
7769
7795
  for (const element of inputArray) {
7770
- const result = await (0, import_provider_utils22.safeValidateTypes)({ value: element, schema });
7796
+ const result = await (0, import_provider_utils23.safeValidateTypes)({ value: element, schema });
7771
7797
  if (!result.success) {
7772
7798
  return result;
7773
7799
  }
@@ -7885,9 +7911,9 @@ function getOutputStrategy({
7885
7911
  }) {
7886
7912
  switch (output) {
7887
7913
  case "object":
7888
- return objectOutputStrategy((0, import_provider_utils22.asSchema)(schema));
7914
+ return objectOutputStrategy((0, import_provider_utils23.asSchema)(schema));
7889
7915
  case "array":
7890
- return arrayOutputStrategy((0, import_provider_utils22.asSchema)(schema));
7916
+ return arrayOutputStrategy((0, import_provider_utils23.asSchema)(schema));
7891
7917
  case "enum":
7892
7918
  return enumOutputStrategy(enumValues);
7893
7919
  case "no-schema":
@@ -7901,9 +7927,9 @@ function getOutputStrategy({
7901
7927
 
7902
7928
  // src/generate-object/parse-and-validate-object-result.ts
7903
7929
  var import_provider27 = require("@ai-sdk/provider");
7904
- var import_provider_utils23 = require("@ai-sdk/provider-utils");
7930
+ var import_provider_utils24 = require("@ai-sdk/provider-utils");
7905
7931
  async function parseAndValidateObjectResult(result, outputStrategy, context) {
7906
- const parseResult = await (0, import_provider_utils23.safeParseJSON)({ text: result });
7932
+ const parseResult = await (0, import_provider_utils24.safeParseJSON)({ text: result });
7907
7933
  if (!parseResult.success) {
7908
7934
  throw new NoObjectGeneratedError({
7909
7935
  message: "No object generated: could not parse the response.",
@@ -8075,7 +8101,7 @@ function validateObjectGenerationInput({
8075
8101
  }
8076
8102
 
8077
8103
  // src/generate-object/generate-object.ts
8078
- var originalGenerateId3 = (0, import_provider_utils24.createIdGenerator)({ prefix: "aiobj", size: 24 });
8104
+ var originalGenerateId3 = (0, import_provider_utils25.createIdGenerator)({ prefix: "aiobj", size: 24 });
8079
8105
  async function generateObject(options) {
8080
8106
  const {
8081
8107
  model: modelArg,
@@ -8120,7 +8146,7 @@ async function generateObject(options) {
8120
8146
  enumValues
8121
8147
  });
8122
8148
  const callSettings = prepareCallSettings(settings);
8123
- const headersWithUserAgent = (0, import_provider_utils24.withUserAgentSuffix)(
8149
+ const headersWithUserAgent = (0, import_provider_utils25.withUserAgentSuffix)(
8124
8150
  headers != null ? headers : {},
8125
8151
  `ai/${VERSION}`
8126
8152
  );
@@ -8340,7 +8366,7 @@ var DefaultGenerateObjectResult = class {
8340
8366
  };
8341
8367
 
8342
8368
  // src/generate-object/stream-object.ts
8343
- var import_provider_utils26 = require("@ai-sdk/provider-utils");
8369
+ var import_provider_utils27 = require("@ai-sdk/provider-utils");
8344
8370
 
8345
8371
  // src/util/cosine-similarity.ts
8346
8372
  function cosineSimilarity(vector1, vector2) {
@@ -8450,7 +8476,7 @@ var SerialJobExecutor = class {
8450
8476
  };
8451
8477
 
8452
8478
  // src/util/simulate-readable-stream.ts
8453
- var import_provider_utils25 = require("@ai-sdk/provider-utils");
8479
+ var import_provider_utils26 = require("@ai-sdk/provider-utils");
8454
8480
  function simulateReadableStream({
8455
8481
  chunks,
8456
8482
  initialDelayInMs = 0,
@@ -8458,7 +8484,7 @@ function simulateReadableStream({
8458
8484
  _internal
8459
8485
  }) {
8460
8486
  var _a17;
8461
- const delay2 = (_a17 = _internal == null ? void 0 : _internal.delay) != null ? _a17 : import_provider_utils25.delay;
8487
+ const delay2 = (_a17 = _internal == null ? void 0 : _internal.delay) != null ? _a17 : import_provider_utils26.delay;
8462
8488
  let index = 0;
8463
8489
  return new ReadableStream({
8464
8490
  async pull(controller) {
@@ -8473,7 +8499,7 @@ function simulateReadableStream({
8473
8499
  }
8474
8500
 
8475
8501
  // src/generate-object/stream-object.ts
8476
- var originalGenerateId4 = (0, import_provider_utils26.createIdGenerator)({ prefix: "aiobj", size: 24 });
8502
+ var originalGenerateId4 = (0, import_provider_utils27.createIdGenerator)({ prefix: "aiobj", size: 24 });
8477
8503
  function streamObject(options) {
8478
8504
  const {
8479
8505
  model,
@@ -8996,7 +9022,7 @@ var DefaultStreamObjectResult = class {
8996
9022
  };
8997
9023
 
8998
9024
  // src/generate-speech/generate-speech.ts
8999
- var import_provider_utils27 = require("@ai-sdk/provider-utils");
9025
+ var import_provider_utils28 = require("@ai-sdk/provider-utils");
9000
9026
 
9001
9027
  // src/generate-speech/generated-audio-file.ts
9002
9028
  var DefaultGeneratedAudioFile = class extends DefaultGeneratedFile {
@@ -9042,7 +9068,7 @@ async function generateSpeech({
9042
9068
  if (!resolvedModel) {
9043
9069
  throw new Error("Model could not be resolved");
9044
9070
  }
9045
- const headersWithUserAgent = (0, import_provider_utils27.withUserAgentSuffix)(
9071
+ const headersWithUserAgent = (0, import_provider_utils28.withUserAgentSuffix)(
9046
9072
  headers != null ? headers : {},
9047
9073
  `ai/${VERSION}`
9048
9074
  );
@@ -9096,7 +9122,7 @@ __export(output_exports, {
9096
9122
  object: () => object,
9097
9123
  text: () => text
9098
9124
  });
9099
- var import_provider_utils28 = require("@ai-sdk/provider-utils");
9125
+ var import_provider_utils29 = require("@ai-sdk/provider-utils");
9100
9126
  var text = () => ({
9101
9127
  type: "text",
9102
9128
  responseFormat: Promise.resolve({ type: "text" }),
@@ -9110,10 +9136,10 @@ var text = () => ({
9110
9136
  var object = ({
9111
9137
  schema: inputSchema
9112
9138
  }) => {
9113
- const schema = (0, import_provider_utils28.asSchema)(inputSchema);
9139
+ const schema = (0, import_provider_utils29.asSchema)(inputSchema);
9114
9140
  return {
9115
9141
  type: "object",
9116
- responseFormat: (0, import_provider_utils28.resolve)(schema.jsonSchema).then((jsonSchema3) => ({
9142
+ responseFormat: (0, import_provider_utils29.resolve)(schema.jsonSchema).then((jsonSchema3) => ({
9117
9143
  type: "json",
9118
9144
  schema: jsonSchema3
9119
9145
  })),
@@ -9136,7 +9162,7 @@ var object = ({
9136
9162
  }
9137
9163
  },
9138
9164
  async parseOutput({ text: text2 }, context) {
9139
- const parseResult = await (0, import_provider_utils28.safeParseJSON)({ text: text2 });
9165
+ const parseResult = await (0, import_provider_utils29.safeParseJSON)({ text: text2 });
9140
9166
  if (!parseResult.success) {
9141
9167
  throw new NoObjectGeneratedError({
9142
9168
  message: "No object generated: could not parse the response.",
@@ -9147,7 +9173,7 @@ var object = ({
9147
9173
  finishReason: context.finishReason
9148
9174
  });
9149
9175
  }
9150
- const validationResult = await (0, import_provider_utils28.safeValidateTypes)({
9176
+ const validationResult = await (0, import_provider_utils29.safeValidateTypes)({
9151
9177
  value: parseResult.value,
9152
9178
  schema
9153
9179
  });
@@ -9246,7 +9272,7 @@ function pruneMessages({
9246
9272
  }
9247
9273
 
9248
9274
  // src/generate-text/smooth-stream.ts
9249
- var import_provider_utils29 = require("@ai-sdk/provider-utils");
9275
+ var import_provider_utils30 = require("@ai-sdk/provider-utils");
9250
9276
  var import_provider28 = require("@ai-sdk/provider");
9251
9277
  var CHUNKING_REGEXPS = {
9252
9278
  word: /\S+\s+/m,
@@ -9255,7 +9281,7 @@ var CHUNKING_REGEXPS = {
9255
9281
  function smoothStream({
9256
9282
  delayInMs = 10,
9257
9283
  chunking = "word",
9258
- _internal: { delay: delay2 = import_provider_utils29.delay } = {}
9284
+ _internal: { delay: delay2 = import_provider_utils30.delay } = {}
9259
9285
  } = {}) {
9260
9286
  let detectChunk;
9261
9287
  if (typeof chunking === "function") {
@@ -9854,10 +9880,10 @@ var DefaultProviderRegistry = class {
9854
9880
  };
9855
9881
 
9856
9882
  // src/tool/mcp/mcp-client.ts
9857
- var import_provider_utils31 = require("@ai-sdk/provider-utils");
9883
+ var import_provider_utils32 = require("@ai-sdk/provider-utils");
9858
9884
 
9859
9885
  // src/tool/mcp/mcp-sse-transport.ts
9860
- var import_provider_utils30 = require("@ai-sdk/provider-utils");
9886
+ var import_provider_utils31 = require("@ai-sdk/provider-utils");
9861
9887
 
9862
9888
  // src/tool/mcp/json-rpc-message.ts
9863
9889
  var import_v410 = require("zod/v4");
@@ -10016,13 +10042,13 @@ var SseMCPTransport = class {
10016
10042
  const establishConnection = async () => {
10017
10043
  var _a17, _b, _c;
10018
10044
  try {
10019
- const headers = (0, import_provider_utils30.withUserAgentSuffix)(
10045
+ const headers = (0, import_provider_utils31.withUserAgentSuffix)(
10020
10046
  {
10021
10047
  ...this.headers,
10022
10048
  Accept: "text/event-stream"
10023
10049
  },
10024
10050
  `ai-sdk/${VERSION}`,
10025
- (0, import_provider_utils30.getRuntimeEnvironmentUserAgent)()
10051
+ (0, import_provider_utils31.getRuntimeEnvironmentUserAgent)()
10026
10052
  );
10027
10053
  const response = await fetch(this.url.href, {
10028
10054
  headers,
@@ -10035,7 +10061,7 @@ var SseMCPTransport = class {
10035
10061
  (_b = this.onerror) == null ? void 0 : _b.call(this, error);
10036
10062
  return reject(error);
10037
10063
  }
10038
- const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new import_provider_utils30.EventSourceParserStream());
10064
+ const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new import_provider_utils31.EventSourceParserStream());
10039
10065
  const reader = stream.getReader();
10040
10066
  const processEvents = async () => {
10041
10067
  var _a18, _b2, _c2;
@@ -10114,13 +10140,13 @@ var SseMCPTransport = class {
10114
10140
  });
10115
10141
  }
10116
10142
  try {
10117
- const headers = (0, import_provider_utils30.withUserAgentSuffix)(
10143
+ const headers = (0, import_provider_utils31.withUserAgentSuffix)(
10118
10144
  {
10119
10145
  ...this.headers,
10120
10146
  "Content-Type": "application/json"
10121
10147
  },
10122
10148
  `ai-sdk/${VERSION}`,
10123
- (0, import_provider_utils30.getRuntimeEnvironmentUserAgent)()
10149
+ (0, import_provider_utils31.getRuntimeEnvironmentUserAgent)()
10124
10150
  );
10125
10151
  const init = {
10126
10152
  method: "POST",
@@ -10371,15 +10397,15 @@ var DefaultMCPClient = class {
10371
10397
  (_a18 = options == null ? void 0 : options.abortSignal) == null ? void 0 : _a18.throwIfAborted();
10372
10398
  return self.callTool({ name: name17, args, options });
10373
10399
  };
10374
- const toolWithExecute = schemas === "automatic" ? (0, import_provider_utils31.dynamicTool)({
10400
+ const toolWithExecute = schemas === "automatic" ? (0, import_provider_utils32.dynamicTool)({
10375
10401
  description,
10376
- inputSchema: (0, import_provider_utils31.jsonSchema)({
10402
+ inputSchema: (0, import_provider_utils32.jsonSchema)({
10377
10403
  ...inputSchema,
10378
10404
  properties: (_a17 = inputSchema.properties) != null ? _a17 : {},
10379
10405
  additionalProperties: false
10380
10406
  }),
10381
10407
  execute
10382
- }) : (0, import_provider_utils31.tool)({
10408
+ }) : (0, import_provider_utils32.tool)({
10383
10409
  description,
10384
10410
  inputSchema: schemas[name17].inputSchema,
10385
10411
  execute
@@ -10431,7 +10457,7 @@ var DefaultMCPClient = class {
10431
10457
  };
10432
10458
 
10433
10459
  // src/transcribe/transcribe.ts
10434
- var import_provider_utils32 = require("@ai-sdk/provider-utils");
10460
+ var import_provider_utils33 = require("@ai-sdk/provider-utils");
10435
10461
 
10436
10462
  // src/error/no-transcript-generated-error.ts
10437
10463
  var import_provider32 = require("@ai-sdk/provider");
@@ -10462,7 +10488,7 @@ async function transcribe({
10462
10488
  maxRetries: maxRetriesArg,
10463
10489
  abortSignal
10464
10490
  });
10465
- const headersWithUserAgent = (0, import_provider_utils32.withUserAgentSuffix)(
10491
+ const headersWithUserAgent = (0, import_provider_utils33.withUserAgentSuffix)(
10466
10492
  headers != null ? headers : {},
10467
10493
  `ai/${VERSION}`
10468
10494
  );
@@ -10510,7 +10536,7 @@ var DefaultTranscriptionResult = class {
10510
10536
  };
10511
10537
 
10512
10538
  // src/ui/call-completion-api.ts
10513
- var import_provider_utils33 = require("@ai-sdk/provider-utils");
10539
+ var import_provider_utils34 = require("@ai-sdk/provider-utils");
10514
10540
 
10515
10541
  // src/ui/process-text-stream.ts
10516
10542
  async function processTextStream({
@@ -10558,13 +10584,13 @@ async function callCompletionApi({
10558
10584
  ...body
10559
10585
  }),
10560
10586
  credentials,
10561
- headers: (0, import_provider_utils33.withUserAgentSuffix)(
10587
+ headers: (0, import_provider_utils34.withUserAgentSuffix)(
10562
10588
  {
10563
10589
  "Content-Type": "application/json",
10564
10590
  ...headers
10565
10591
  },
10566
10592
  `ai-sdk/${VERSION}`,
10567
- (0, import_provider_utils33.getRuntimeEnvironmentUserAgent)()
10593
+ (0, import_provider_utils34.getRuntimeEnvironmentUserAgent)()
10568
10594
  ),
10569
10595
  signal: abortController.signal
10570
10596
  }).catch((err) => {
@@ -10592,7 +10618,7 @@ async function callCompletionApi({
10592
10618
  }
10593
10619
  case "data": {
10594
10620
  await consumeStream({
10595
- stream: (0, import_provider_utils33.parseJsonEventStream)({
10621
+ stream: (0, import_provider_utils34.parseJsonEventStream)({
10596
10622
  stream: response.body,
10597
10623
  schema: uiMessageChunkSchema
10598
10624
  }).pipeThrough(
@@ -10644,7 +10670,7 @@ async function callCompletionApi({
10644
10670
  }
10645
10671
 
10646
10672
  // src/ui/chat.ts
10647
- var import_provider_utils36 = require("@ai-sdk/provider-utils");
10673
+ var import_provider_utils37 = require("@ai-sdk/provider-utils");
10648
10674
 
10649
10675
  // src/ui/convert-file-list-to-file-ui-parts.ts
10650
10676
  async function convertFileListToFileUIParts(files) {
@@ -10677,10 +10703,10 @@ async function convertFileListToFileUIParts(files) {
10677
10703
  }
10678
10704
 
10679
10705
  // src/ui/default-chat-transport.ts
10680
- var import_provider_utils35 = require("@ai-sdk/provider-utils");
10706
+ var import_provider_utils36 = require("@ai-sdk/provider-utils");
10681
10707
 
10682
10708
  // src/ui/http-chat-transport.ts
10683
- var import_provider_utils34 = require("@ai-sdk/provider-utils");
10709
+ var import_provider_utils35 = require("@ai-sdk/provider-utils");
10684
10710
  var HttpChatTransport = class {
10685
10711
  constructor({
10686
10712
  api = "/api/chat",
@@ -10704,9 +10730,9 @@ var HttpChatTransport = class {
10704
10730
  ...options
10705
10731
  }) {
10706
10732
  var _a17, _b, _c, _d, _e;
10707
- const resolvedBody = await (0, import_provider_utils34.resolve)(this.body);
10708
- const resolvedHeaders = await (0, import_provider_utils34.resolve)(this.headers);
10709
- const resolvedCredentials = await (0, import_provider_utils34.resolve)(this.credentials);
10733
+ const resolvedBody = await (0, import_provider_utils35.resolve)(this.body);
10734
+ const resolvedHeaders = await (0, import_provider_utils35.resolve)(this.headers);
10735
+ const resolvedCredentials = await (0, import_provider_utils35.resolve)(this.credentials);
10710
10736
  const preparedRequest = await ((_a17 = this.prepareSendMessagesRequest) == null ? void 0 : _a17.call(this, {
10711
10737
  api: this.api,
10712
10738
  id: options.chatId,
@@ -10732,13 +10758,13 @@ var HttpChatTransport = class {
10732
10758
  const fetch2 = (_d = this.fetch) != null ? _d : globalThis.fetch;
10733
10759
  const response = await fetch2(api, {
10734
10760
  method: "POST",
10735
- headers: (0, import_provider_utils34.withUserAgentSuffix)(
10761
+ headers: (0, import_provider_utils35.withUserAgentSuffix)(
10736
10762
  {
10737
10763
  "Content-Type": "application/json",
10738
10764
  ...headers
10739
10765
  },
10740
10766
  `ai-sdk/${VERSION}`,
10741
- (0, import_provider_utils34.getRuntimeEnvironmentUserAgent)()
10767
+ (0, import_provider_utils35.getRuntimeEnvironmentUserAgent)()
10742
10768
  ),
10743
10769
  body: JSON.stringify(body),
10744
10770
  credentials,
@@ -10756,9 +10782,9 @@ var HttpChatTransport = class {
10756
10782
  }
10757
10783
  async reconnectToStream(options) {
10758
10784
  var _a17, _b, _c, _d, _e;
10759
- const resolvedBody = await (0, import_provider_utils34.resolve)(this.body);
10760
- const resolvedHeaders = await (0, import_provider_utils34.resolve)(this.headers);
10761
- const resolvedCredentials = await (0, import_provider_utils34.resolve)(this.credentials);
10785
+ const resolvedBody = await (0, import_provider_utils35.resolve)(this.body);
10786
+ const resolvedHeaders = await (0, import_provider_utils35.resolve)(this.headers);
10787
+ const resolvedCredentials = await (0, import_provider_utils35.resolve)(this.credentials);
10762
10788
  const preparedRequest = await ((_a17 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a17.call(this, {
10763
10789
  api: this.api,
10764
10790
  id: options.chatId,
@@ -10773,10 +10799,10 @@ var HttpChatTransport = class {
10773
10799
  const fetch2 = (_d = this.fetch) != null ? _d : globalThis.fetch;
10774
10800
  const response = await fetch2(api, {
10775
10801
  method: "GET",
10776
- headers: (0, import_provider_utils34.withUserAgentSuffix)(
10802
+ headers: (0, import_provider_utils35.withUserAgentSuffix)(
10777
10803
  headers,
10778
10804
  `ai-sdk/${VERSION}`,
10779
- (0, import_provider_utils34.getRuntimeEnvironmentUserAgent)()
10805
+ (0, import_provider_utils35.getRuntimeEnvironmentUserAgent)()
10780
10806
  ),
10781
10807
  credentials
10782
10808
  });
@@ -10801,7 +10827,7 @@ var DefaultChatTransport = class extends HttpChatTransport {
10801
10827
  super(options);
10802
10828
  }
10803
10829
  processResponseStream(stream) {
10804
- return (0, import_provider_utils35.parseJsonEventStream)({
10830
+ return (0, import_provider_utils36.parseJsonEventStream)({
10805
10831
  stream,
10806
10832
  schema: uiMessageChunkSchema
10807
10833
  }).pipeThrough(
@@ -10820,7 +10846,7 @@ var DefaultChatTransport = class extends HttpChatTransport {
10820
10846
  // src/ui/chat.ts
10821
10847
  var AbstractChat = class {
10822
10848
  constructor({
10823
- generateId: generateId2 = import_provider_utils36.generateId,
10849
+ generateId: generateId2 = import_provider_utils37.generateId,
10824
10850
  id = generateId2(),
10825
10851
  transport = new DefaultChatTransport(),
10826
10852
  messageMetadataSchema,
@@ -11332,6 +11358,9 @@ var TextStreamChatTransport = class extends HttpChatTransport {
11332
11358
  hasToolCall,
11333
11359
  isDataUIPart,
11334
11360
  isDeepEqualData,
11361
+ isFileUIPart,
11362
+ isReasoningUIPart,
11363
+ isTextUIPart,
11335
11364
  isToolOrDynamicToolUIPart,
11336
11365
  isToolUIPart,
11337
11366
  jsonSchema,