@ai-sdk/provider-utils 4.0.26 → 4.0.28

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,21 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 4.0.28
4
+
5
+ ### Patch Changes
6
+
7
+ - 942f2f8: fix(security): re-validate tool approvals from client message history before execution
8
+
9
+ The approval-replay path in `generateText`/`streamText` reconstructed approved tool calls from the client-supplied messages array and executed them without re-validating input against the tool's schema or re-checking that the tool actually requires approval. A client could forge an assistant message with a pre-approved tool-call part and have the server execute a tool with attacker-chosen arguments.
10
+
11
+ The replay path now verifies the HMAC signature (when `experimental_toolApprovalSecret` is configured), re-validates tool-call input against the tool's input schema, and re-resolves whether the tool requires approval before execution.
12
+
13
+ ## 4.0.27
14
+
15
+ ### Patch Changes
16
+
17
+ - f591416: feat(ai): add toolMetadata for tool specific metdata
18
+
3
19
  ## 4.0.26
4
20
 
5
21
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions, SharedV3ProviderMetadata, TypeValidationContext } from '@ai-sdk/provider';
1
+ import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions, JSONObject, TypeValidationContext } from '@ai-sdk/provider';
2
2
  import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
3
3
  export * from '@standard-schema/spec';
4
4
  import * as z3 from 'zod/v3';
@@ -874,6 +874,11 @@ type ToolApprovalRequest = {
874
874
  * ID of the tool call that the approval request is for.
875
875
  */
876
876
  toolCallId: string;
877
+ /**
878
+ * HMAC-SHA256 signature binding this approval to its tool call.
879
+ * Present only when `experimental_toolApprovalSecret` is configured.
880
+ */
881
+ signature?: string;
877
882
  };
878
883
 
879
884
  /**
@@ -1074,11 +1079,11 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
1074
1079
  *
1075
1080
  * Unlike `providerOptions`, this metadata is not sent to the language
1076
1081
  * model. Instead, it is propagated onto the resulting tool call's
1077
- * `providerMetadata` so consumers can read it from tool call / result
1078
- * parts and UI message parts. This is useful for sources of dynamic
1079
- * tools (e.g. an MCP server) to identify themselves.
1082
+ * `toolMetadata` so consumers can read it from tool call / result parts
1083
+ * and UI message parts. This is useful for sources of dynamic tools (e.g.
1084
+ * an MCP server) to identify themselves.
1080
1085
  */
1081
- providerMetadata?: SharedV3ProviderMetadata;
1086
+ metadata?: JSONObject;
1082
1087
  /**
1083
1088
  * The schema of the input that the tool expects.
1084
1089
  * The language model will use this to generate the input.
@@ -1206,7 +1211,7 @@ declare function dynamicTool(tool: {
1206
1211
  description?: string;
1207
1212
  title?: string;
1208
1213
  providerOptions?: ProviderOptions;
1209
- providerMetadata?: SharedV3ProviderMetadata;
1214
+ metadata?: JSONObject;
1210
1215
  inputSchema: FlexibleSchema<unknown>;
1211
1216
  execute: ToolExecuteFunction<unknown, unknown>;
1212
1217
  /**
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions, SharedV3ProviderMetadata, TypeValidationContext } from '@ai-sdk/provider';
1
+ import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions, JSONObject, TypeValidationContext } from '@ai-sdk/provider';
2
2
  import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
3
3
  export * from '@standard-schema/spec';
4
4
  import * as z3 from 'zod/v3';
@@ -874,6 +874,11 @@ type ToolApprovalRequest = {
874
874
  * ID of the tool call that the approval request is for.
875
875
  */
876
876
  toolCallId: string;
877
+ /**
878
+ * HMAC-SHA256 signature binding this approval to its tool call.
879
+ * Present only when `experimental_toolApprovalSecret` is configured.
880
+ */
881
+ signature?: string;
877
882
  };
878
883
 
879
884
  /**
@@ -1074,11 +1079,11 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
1074
1079
  *
1075
1080
  * Unlike `providerOptions`, this metadata is not sent to the language
1076
1081
  * model. Instead, it is propagated onto the resulting tool call's
1077
- * `providerMetadata` so consumers can read it from tool call / result
1078
- * parts and UI message parts. This is useful for sources of dynamic
1079
- * tools (e.g. an MCP server) to identify themselves.
1082
+ * `toolMetadata` so consumers can read it from tool call / result parts
1083
+ * and UI message parts. This is useful for sources of dynamic tools (e.g.
1084
+ * an MCP server) to identify themselves.
1080
1085
  */
1081
- providerMetadata?: SharedV3ProviderMetadata;
1086
+ metadata?: JSONObject;
1082
1087
  /**
1083
1088
  * The schema of the input that the tool expects.
1084
1089
  * The language model will use this to generate the input.
@@ -1206,7 +1211,7 @@ declare function dynamicTool(tool: {
1206
1211
  description?: string;
1207
1212
  title?: string;
1208
1213
  providerOptions?: ProviderOptions;
1209
- providerMetadata?: SharedV3ProviderMetadata;
1214
+ metadata?: JSONObject;
1210
1215
  inputSchema: FlexibleSchema<unknown>;
1211
1216
  execute: ToolExecuteFunction<unknown, unknown>;
1212
1217
  /**
package/dist/index.js CHANGED
@@ -678,7 +678,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
678
678
  }
679
679
 
680
680
  // src/version.ts
681
- var VERSION = true ? "4.0.26" : "0.0.0-test";
681
+ var VERSION = true ? "4.0.28" : "0.0.0-test";
682
682
 
683
683
  // src/get-from-api.ts
684
684
  var getOriginalFetch = () => globalThis.fetch;