@ai-sdk/provider-utils 3.1.0-beta.7 → 3.1.0-beta.9
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 +12 -0
- package/dist/index.d.mts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @ai-sdk/provider-utils
|
2
2
|
|
3
|
+
## 3.1.0-beta.9
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 521c537: feat(ai): Tool.needsApproval can be a function
|
8
|
+
|
9
|
+
## 3.1.0-beta.8
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- e06565c: feat(provider-utils): add needsApproval support to provider-defined tools
|
14
|
+
|
3
15
|
## 3.1.0-beta.7
|
4
16
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -698,7 +698,23 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
|
|
698
698
|
/**
|
699
699
|
Whether the tool needs approval before it can be executed.
|
700
700
|
*/
|
701
|
-
needsApproval?: boolean
|
701
|
+
needsApproval?: boolean | ((input: [INPUT] extends [never] ? unknown : INPUT, options: {
|
702
|
+
/**
|
703
|
+
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
704
|
+
*/
|
705
|
+
toolCallId: string;
|
706
|
+
/**
|
707
|
+
* Messages that were sent to the language model to initiate the response that contained the tool call.
|
708
|
+
* The messages **do not** include the system prompt nor the assistant response that contained the tool call.
|
709
|
+
*/
|
710
|
+
messages: ModelMessage[];
|
711
|
+
/**
|
712
|
+
* Additional context.
|
713
|
+
*
|
714
|
+
* Experimental (can break in patch releases).
|
715
|
+
*/
|
716
|
+
experimental_context?: unknown;
|
717
|
+
}) => boolean | PromiseLike<boolean>);
|
702
718
|
/**
|
703
719
|
* Optional function that is called when the argument streaming starts.
|
704
720
|
* Only called when the tool is used in a streaming context.
|
@@ -716,7 +732,7 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
|
|
716
732
|
* even if the execute function is not provided.
|
717
733
|
*/
|
718
734
|
onInputAvailable?: (options: {
|
719
|
-
input: [INPUT] extends [never] ?
|
735
|
+
input: [INPUT] extends [never] ? unknown : INPUT;
|
720
736
|
} & ToolCallOptions) => void | PromiseLike<void>;
|
721
737
|
} & ToolOutputProperties<INPUT, OUTPUT> & {
|
722
738
|
/**
|
@@ -784,6 +800,7 @@ declare function dynamicTool(tool: {
|
|
784
800
|
|
785
801
|
type ProviderDefinedToolFactory<INPUT, ARGS extends object> = <OUTPUT>(options: ARGS & {
|
786
802
|
execute?: ToolExecuteFunction<INPUT, OUTPUT>;
|
803
|
+
needsApproval?: Tool<INPUT, OUTPUT>['needsApproval'];
|
787
804
|
toModelOutput?: Tool<INPUT, OUTPUT>['toModelOutput'];
|
788
805
|
onInputStart?: Tool<INPUT, OUTPUT>['onInputStart'];
|
789
806
|
onInputDelta?: Tool<INPUT, OUTPUT>['onInputDelta'];
|
@@ -796,6 +813,7 @@ declare function createProviderDefinedToolFactory<INPUT, ARGS extends object>({
|
|
796
813
|
}): ProviderDefinedToolFactory<INPUT, ARGS>;
|
797
814
|
type ProviderDefinedToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object> = (options: ARGS & {
|
798
815
|
execute?: ToolExecuteFunction<INPUT, OUTPUT>;
|
816
|
+
needsApproval?: Tool<INPUT, OUTPUT>['needsApproval'];
|
799
817
|
toModelOutput?: Tool<INPUT, OUTPUT>['toModelOutput'];
|
800
818
|
onInputStart?: Tool<INPUT, OUTPUT>['onInputStart'];
|
801
819
|
onInputDelta?: Tool<INPUT, OUTPUT>['onInputDelta'];
|
package/dist/index.d.ts
CHANGED
@@ -698,7 +698,23 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
|
|
698
698
|
/**
|
699
699
|
Whether the tool needs approval before it can be executed.
|
700
700
|
*/
|
701
|
-
needsApproval?: boolean
|
701
|
+
needsApproval?: boolean | ((input: [INPUT] extends [never] ? unknown : INPUT, options: {
|
702
|
+
/**
|
703
|
+
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
704
|
+
*/
|
705
|
+
toolCallId: string;
|
706
|
+
/**
|
707
|
+
* Messages that were sent to the language model to initiate the response that contained the tool call.
|
708
|
+
* The messages **do not** include the system prompt nor the assistant response that contained the tool call.
|
709
|
+
*/
|
710
|
+
messages: ModelMessage[];
|
711
|
+
/**
|
712
|
+
* Additional context.
|
713
|
+
*
|
714
|
+
* Experimental (can break in patch releases).
|
715
|
+
*/
|
716
|
+
experimental_context?: unknown;
|
717
|
+
}) => boolean | PromiseLike<boolean>);
|
702
718
|
/**
|
703
719
|
* Optional function that is called when the argument streaming starts.
|
704
720
|
* Only called when the tool is used in a streaming context.
|
@@ -716,7 +732,7 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
|
|
716
732
|
* even if the execute function is not provided.
|
717
733
|
*/
|
718
734
|
onInputAvailable?: (options: {
|
719
|
-
input: [INPUT] extends [never] ?
|
735
|
+
input: [INPUT] extends [never] ? unknown : INPUT;
|
720
736
|
} & ToolCallOptions) => void | PromiseLike<void>;
|
721
737
|
} & ToolOutputProperties<INPUT, OUTPUT> & {
|
722
738
|
/**
|
@@ -784,6 +800,7 @@ declare function dynamicTool(tool: {
|
|
784
800
|
|
785
801
|
type ProviderDefinedToolFactory<INPUT, ARGS extends object> = <OUTPUT>(options: ARGS & {
|
786
802
|
execute?: ToolExecuteFunction<INPUT, OUTPUT>;
|
803
|
+
needsApproval?: Tool<INPUT, OUTPUT>['needsApproval'];
|
787
804
|
toModelOutput?: Tool<INPUT, OUTPUT>['toModelOutput'];
|
788
805
|
onInputStart?: Tool<INPUT, OUTPUT>['onInputStart'];
|
789
806
|
onInputDelta?: Tool<INPUT, OUTPUT>['onInputDelta'];
|
@@ -796,6 +813,7 @@ declare function createProviderDefinedToolFactory<INPUT, ARGS extends object>({
|
|
796
813
|
}): ProviderDefinedToolFactory<INPUT, ARGS>;
|
797
814
|
type ProviderDefinedToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object> = (options: ARGS & {
|
798
815
|
execute?: ToolExecuteFunction<INPUT, OUTPUT>;
|
816
|
+
needsApproval?: Tool<INPUT, OUTPUT>['needsApproval'];
|
799
817
|
toModelOutput?: Tool<INPUT, OUTPUT>['toModelOutput'];
|
800
818
|
onInputStart?: Tool<INPUT, OUTPUT>['onInputStart'];
|
801
819
|
onInputDelta?: Tool<INPUT, OUTPUT>['onInputDelta'];
|
package/dist/index.js
CHANGED
@@ -284,7 +284,7 @@ function handleFetchError({
|
|
284
284
|
}
|
285
285
|
|
286
286
|
// src/version.ts
|
287
|
-
var VERSION = true ? "3.1.0-beta.
|
287
|
+
var VERSION = true ? "3.1.0-beta.9" : "0.0.0-test";
|
288
288
|
|
289
289
|
// src/get-from-api.ts
|
290
290
|
var getOriginalFetch = () => globalThis.fetch;
|
@@ -844,6 +844,7 @@ function createProviderDefinedToolFactory({
|
|
844
844
|
return ({
|
845
845
|
execute,
|
846
846
|
outputSchema,
|
847
|
+
needsApproval,
|
847
848
|
toModelOutput,
|
848
849
|
onInputStart,
|
849
850
|
onInputDelta,
|
@@ -857,6 +858,7 @@ function createProviderDefinedToolFactory({
|
|
857
858
|
inputSchema,
|
858
859
|
outputSchema,
|
859
860
|
execute,
|
861
|
+
needsApproval,
|
860
862
|
toModelOutput,
|
861
863
|
onInputStart,
|
862
864
|
onInputDelta,
|
@@ -871,6 +873,7 @@ function createProviderDefinedToolFactoryWithOutputSchema({
|
|
871
873
|
}) {
|
872
874
|
return ({
|
873
875
|
execute,
|
876
|
+
needsApproval,
|
874
877
|
toModelOutput,
|
875
878
|
onInputStart,
|
876
879
|
onInputDelta,
|
@@ -884,6 +887,7 @@ function createProviderDefinedToolFactoryWithOutputSchema({
|
|
884
887
|
inputSchema,
|
885
888
|
outputSchema,
|
886
889
|
execute,
|
890
|
+
needsApproval,
|
887
891
|
toModelOutput,
|
888
892
|
onInputStart,
|
889
893
|
onInputDelta,
|