ai 5.0.264 → 5.0.266

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
@@ -727,7 +727,7 @@ import {
727
727
  } from "@ai-sdk/provider-utils";
728
728
 
729
729
  // src/version.ts
730
- var VERSION = true ? "5.0.264" : "0.0.0-test";
730
+ var VERSION = true ? "5.0.266" : "0.0.0-test";
731
731
 
732
732
  // src/util/download/download.ts
733
733
  var download = async ({
@@ -1944,8 +1944,8 @@ var DefaultGeneratedFile = class {
1944
1944
  }
1945
1945
  };
1946
1946
  var DefaultGeneratedFileWithType = class extends DefaultGeneratedFile {
1947
- constructor(options) {
1948
- super(options);
1947
+ constructor() {
1948
+ super(...arguments);
1949
1949
  this.type = "file";
1950
1950
  }
1951
1951
  };
@@ -1970,6 +1970,9 @@ async function parseToolCall({
1970
1970
  }) {
1971
1971
  try {
1972
1972
  if (tools == null) {
1973
+ if (toolCall.providerExecuted) {
1974
+ return await parseProviderExecutedDynamicToolCall(toolCall);
1975
+ }
1973
1976
  throw new NoSuchToolError({ toolName: toolCall.toolName });
1974
1977
  }
1975
1978
  try {
@@ -2017,6 +2020,25 @@ async function parseToolCall({
2017
2020
  };
2018
2021
  }
2019
2022
  }
2023
+ async function parseProviderExecutedDynamicToolCall(toolCall) {
2024
+ const parseResult = toolCall.input.trim() === "" ? { success: true, value: {} } : await safeParseJSON({ text: toolCall.input });
2025
+ if (parseResult.success === false) {
2026
+ throw new InvalidToolInputError({
2027
+ toolName: toolCall.toolName,
2028
+ toolInput: toolCall.input,
2029
+ cause: parseResult.error
2030
+ });
2031
+ }
2032
+ return {
2033
+ type: "tool-call",
2034
+ toolCallId: toolCall.toolCallId,
2035
+ toolName: toolCall.toolName,
2036
+ input: parseResult.value,
2037
+ providerExecuted: true,
2038
+ dynamic: true,
2039
+ providerMetadata: toolCall.providerMetadata
2040
+ };
2041
+ }
2020
2042
  async function doParseToolCall({
2021
2043
  toolCall,
2022
2044
  tools
@@ -2024,6 +2046,9 @@ async function doParseToolCall({
2024
2046
  const toolName = toolCall.toolName;
2025
2047
  const tool2 = tools[toolName];
2026
2048
  if (tool2 == null) {
2049
+ if (toolCall.providerExecuted) {
2050
+ return await parseProviderExecutedDynamicToolCall(toolCall);
2051
+ }
2027
2052
  throw new NoSuchToolError({
2028
2053
  toolName: toolCall.toolName,
2029
2054
  availableTools: Object.keys(tools)
@@ -2923,8 +2948,6 @@ function writeToServerResponse({
2923
2948
  });
2924
2949
  }
2925
2950
  }
2926
- } catch (error) {
2927
- throw error;
2928
2951
  } finally {
2929
2952
  response.end();
2930
2953
  }
@@ -6592,7 +6615,6 @@ async function embedMany({
6592
6615
  }),
6593
6616
  tracer,
6594
6617
  fn: async (span) => {
6595
- var _a16;
6596
6618
  const [
6597
6619
  maxEmbeddingsPerCall,
6598
6620
  maxInputBytesPerCall,
@@ -6625,7 +6647,7 @@ async function embedMany({
6625
6647
  }),
6626
6648
  tracer,
6627
6649
  fn: async (doEmbedSpan) => {
6628
- var _a17;
6650
+ var _a16;
6629
6651
  const modelResponse = await model.doEmbed({
6630
6652
  values,
6631
6653
  abortSignal,
@@ -6633,7 +6655,7 @@ async function embedMany({
6633
6655
  providerOptions
6634
6656
  });
6635
6657
  const embeddings3 = modelResponse.embeddings;
6636
- const usage2 = (_a17 = modelResponse.usage) != null ? _a17 : { tokens: NaN };
6658
+ const usage2 = (_a16 = modelResponse.usage) != null ? _a16 : { tokens: NaN };
6637
6659
  doEmbedSpan.setAttributes(
6638
6660
  selectTelemetryAttributes({
6639
6661
  telemetry,
@@ -6711,7 +6733,7 @@ async function embedMany({
6711
6733
  }),
6712
6734
  tracer,
6713
6735
  fn: async (doEmbedSpan) => {
6714
- var _a17;
6736
+ var _a16;
6715
6737
  const modelResponse = await model.doEmbed({
6716
6738
  values: chunk,
6717
6739
  abortSignal,
@@ -6719,7 +6741,7 @@ async function embedMany({
6719
6741
  providerOptions
6720
6742
  });
6721
6743
  const embeddings2 = modelResponse.embeddings;
6722
- const usage = (_a17 = modelResponse.usage) != null ? _a17 : { tokens: NaN };
6744
+ const usage = (_a16 = modelResponse.usage) != null ? _a16 : { tokens: NaN };
6723
6745
  doEmbedSpan.setAttributes(
6724
6746
  selectTelemetryAttributes({
6725
6747
  telemetry,
@@ -6756,7 +6778,7 @@ async function embedMany({
6756
6778
  result.providerMetadata
6757
6779
  )) {
6758
6780
  providerMetadata[providerName] = {
6759
- ...(_a16 = providerMetadata[providerName]) != null ? _a16 : {},
6781
+ ...providerMetadata[providerName],
6760
6782
  ...metadata
6761
6783
  };
6762
6784
  }
@@ -10420,7 +10442,7 @@ async function safeValidateUIMessages({
10420
10442
  }
10421
10443
  if (metadataSchema) {
10422
10444
  for (const message of validatedMessages) {
10423
- await validateTypes2({
10445
+ message.metadata = await validateTypes2({
10424
10446
  value: message.metadata,
10425
10447
  schema: metadataSchema
10426
10448
  });
@@ -10443,7 +10465,7 @@ async function safeValidateUIMessages({
10443
10465
  })
10444
10466
  };
10445
10467
  }
10446
- await validateTypes2({
10468
+ dataPart.data = await validateTypes2({
10447
10469
  value: dataPart.data,
10448
10470
  schema: dataSchema
10449
10471
  });