ai 5.1.0-beta.1 → 5.1.0-beta.10

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
@@ -12,6 +12,7 @@ import {
12
12
  dynamicTool as dynamicTool2,
13
13
  generateId as generateId2,
14
14
  jsonSchema as jsonSchema2,
15
+ parseJsonEventStream as parseJsonEventStream3,
15
16
  tool as tool2,
16
17
  zodSchema
17
18
  } from "@ai-sdk/provider-utils";
@@ -463,7 +464,7 @@ function resolveLanguageModel(model) {
463
464
  }
464
465
  function resolveEmbeddingModel(model) {
465
466
  if (typeof model !== "string") {
466
- if (model.specificationVersion !== "v2") {
467
+ if (model.specificationVersion !== "v3") {
467
468
  throw new UnsupportedModelVersionError({
468
469
  version: model.specificationVersion,
469
470
  provider: model.provider,
@@ -678,7 +679,7 @@ import {
678
679
  } from "@ai-sdk/provider-utils";
679
680
 
680
681
  // src/version.ts
681
- var VERSION = true ? "5.1.0-beta.1" : "0.0.0-test";
682
+ var VERSION = true ? "5.1.0-beta.10" : "0.0.0-test";
682
683
 
683
684
  // src/util/download/download.ts
684
685
  var download = async ({ url }) => {
@@ -971,12 +972,12 @@ async function downloadAssets(messages, download2, supportedUrls) {
971
972
  }));
972
973
  const downloadedFiles = await download2(plannedDownloads);
973
974
  return Object.fromEntries(
974
- downloadedFiles.filter(
975
- (downloadedFile) => (downloadedFile == null ? void 0 : downloadedFile.data) != null
976
- ).map(({ data, mediaType }, index) => [
977
- plannedDownloads[index].url.toString(),
978
- { data, mediaType }
979
- ])
975
+ downloadedFiles.map(
976
+ (file, index) => file == null ? null : [
977
+ plannedDownloads[index].url.toString(),
978
+ { data: file.data, mediaType: file.mediaType }
979
+ ]
980
+ ).filter((file) => file != null)
980
981
  );
981
982
  }
982
983
  function convertPartToLanguageModelPart(part, downloadedAssets) {
@@ -2922,11 +2923,6 @@ var uiMessageChunkSchema = z7.union([
2922
2923
  providerExecuted: z7.boolean().optional(),
2923
2924
  dynamic: z7.boolean().optional()
2924
2925
  }),
2925
- z7.strictObject({
2926
- type: z7.literal("reasoning"),
2927
- text: z7.string(),
2928
- providerMetadata: providerMetadataSchema.optional()
2929
- }),
2930
2926
  z7.strictObject({
2931
2927
  type: z7.literal("reasoning-start"),
2932
2928
  id: z7.string(),
@@ -2943,9 +2939,6 @@ var uiMessageChunkSchema = z7.union([
2943
2939
  id: z7.string(),
2944
2940
  providerMetadata: providerMetadataSchema.optional()
2945
2941
  }),
2946
- z7.strictObject({
2947
- type: z7.literal("reasoning-part-finish")
2948
- }),
2949
2942
  z7.strictObject({
2950
2943
  type: z7.literal("source-url"),
2951
2944
  sourceId: z7.string(),
@@ -2968,7 +2961,10 @@ var uiMessageChunkSchema = z7.union([
2968
2961
  providerMetadata: providerMetadataSchema.optional()
2969
2962
  }),
2970
2963
  z7.strictObject({
2971
- type: z7.string().startsWith("data-"),
2964
+ type: z7.custom(
2965
+ (value) => typeof value === "string" && value.startsWith("data-"),
2966
+ { message: 'Type must start with "data-"' }
2967
+ ),
2972
2968
  id: z7.string().optional(),
2973
2969
  data: z7.unknown(),
2974
2970
  transient: z7.boolean().optional()
@@ -6322,7 +6318,7 @@ async function generateImage({
6322
6318
  headers
6323
6319
  }) {
6324
6320
  var _a17, _b;
6325
- if (model.specificationVersion !== "v2") {
6321
+ if (model.specificationVersion !== "v3") {
6326
6322
  throw new UnsupportedModelVersionError({
6327
6323
  version: model.specificationVersion,
6328
6324
  provider: model.provider,
@@ -9701,9 +9697,11 @@ var AbstractChat = class {
9701
9697
  }
9702
9698
  };
9703
9699
  this.addToolResult = async ({
9700
+ state = "output-available",
9704
9701
  tool: tool3,
9705
9702
  toolCallId,
9706
- output
9703
+ output,
9704
+ errorText
9707
9705
  }) => this.jobExecutor.run(async () => {
9708
9706
  var _a17, _b;
9709
9707
  const messages = this.state.messages;
@@ -9711,16 +9709,16 @@ var AbstractChat = class {
9711
9709
  this.state.replaceMessage(messages.length - 1, {
9712
9710
  ...lastMessage,
9713
9711
  parts: lastMessage.parts.map(
9714
- (part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state: "output-available", output } : part
9712
+ (part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state, output, errorText } : part
9715
9713
  )
9716
9714
  });
9717
9715
  if (this.activeResponse) {
9718
9716
  this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(
9719
9717
  (part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? {
9720
9718
  ...part,
9721
- state: "output-available",
9719
+ state,
9722
9720
  output,
9723
- errorText: void 0
9721
+ errorText
9724
9722
  } : part
9725
9723
  );
9726
9724
  }
@@ -9929,7 +9927,9 @@ function lastAssistantMessageIsCompleteWithToolCalls({
9929
9927
  return part.type === "step-start" ? index : lastIndex;
9930
9928
  }, -1);
9931
9929
  const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolOrDynamicToolUIPart);
9932
- return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every((part) => part.state === "output-available");
9930
+ return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every(
9931
+ (part) => part.state === "output-available" || part.state === "output-error"
9932
+ );
9933
9933
  }
9934
9934
 
9935
9935
  // src/ui/transform-text-to-ui-message-stream.ts
@@ -10451,6 +10451,7 @@ export {
10451
10451
  jsonSchema2 as jsonSchema,
10452
10452
  lastAssistantMessageIsCompleteWithToolCalls,
10453
10453
  modelMessageSchema,
10454
+ parseJsonEventStream3 as parseJsonEventStream,
10454
10455
  parsePartialJson,
10455
10456
  pipeTextStreamToResponse,
10456
10457
  pipeUIMessageStreamToResponse,
@@ -10465,6 +10466,7 @@ export {
10465
10466
  systemModelMessageSchema,
10466
10467
  tool2 as tool,
10467
10468
  toolModelMessageSchema,
10469
+ uiMessageChunkSchema,
10468
10470
  userModelMessageSchema,
10469
10471
  validateUIMessages,
10470
10472
  wrapLanguageModel,