ai 5.0.265 → 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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # ai
2
2
 
3
+ ## 5.0.266
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [cd9b333]
8
+ - @ai-sdk/gateway@2.0.158
9
+
3
10
  ## 5.0.265
4
11
 
5
12
  ### Patch Changes
package/dist/index.js CHANGED
@@ -816,7 +816,7 @@ function detectMediaType({
816
816
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
817
817
 
818
818
  // src/version.ts
819
- var VERSION = true ? "5.0.265" : "0.0.0-test";
819
+ var VERSION = true ? "5.0.266" : "0.0.0-test";
820
820
 
821
821
  // src/util/download/download.ts
822
822
  var download = async ({
@@ -2047,6 +2047,9 @@ async function parseToolCall({
2047
2047
  }) {
2048
2048
  try {
2049
2049
  if (tools == null) {
2050
+ if (toolCall.providerExecuted) {
2051
+ return await parseProviderExecutedDynamicToolCall(toolCall);
2052
+ }
2050
2053
  throw new NoSuchToolError({ toolName: toolCall.toolName });
2051
2054
  }
2052
2055
  try {
@@ -2094,6 +2097,25 @@ async function parseToolCall({
2094
2097
  };
2095
2098
  }
2096
2099
  }
2100
+ async function parseProviderExecutedDynamicToolCall(toolCall) {
2101
+ const parseResult = toolCall.input.trim() === "" ? { success: true, value: {} } : await (0, import_provider_utils9.safeParseJSON)({ text: toolCall.input });
2102
+ if (parseResult.success === false) {
2103
+ throw new InvalidToolInputError({
2104
+ toolName: toolCall.toolName,
2105
+ toolInput: toolCall.input,
2106
+ cause: parseResult.error
2107
+ });
2108
+ }
2109
+ return {
2110
+ type: "tool-call",
2111
+ toolCallId: toolCall.toolCallId,
2112
+ toolName: toolCall.toolName,
2113
+ input: parseResult.value,
2114
+ providerExecuted: true,
2115
+ dynamic: true,
2116
+ providerMetadata: toolCall.providerMetadata
2117
+ };
2118
+ }
2097
2119
  async function doParseToolCall({
2098
2120
  toolCall,
2099
2121
  tools
@@ -2101,6 +2123,9 @@ async function doParseToolCall({
2101
2123
  const toolName = toolCall.toolName;
2102
2124
  const tool2 = tools[toolName];
2103
2125
  if (tool2 == null) {
2126
+ if (toolCall.providerExecuted) {
2127
+ return await parseProviderExecutedDynamicToolCall(toolCall);
2128
+ }
2104
2129
  throw new NoSuchToolError({
2105
2130
  toolName: toolCall.toolName,
2106
2131
  availableTools: Object.keys(tools)