@ai-sdk/provider-utils 4.0.0-beta.41 → 4.0.0-beta.43

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,19 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 4.0.0-beta.43
4
+
5
+ ### Patch Changes
6
+
7
+ - dce03c4: feat: tool input examples
8
+ - Updated dependencies [dce03c4]
9
+ - @ai-sdk/provider@3.0.0-beta.24
10
+
11
+ ## 4.0.0-beta.42
12
+
13
+ ### Patch Changes
14
+
15
+ - 3ed5519: chore: rename ToolCallOptions to ToolExecutionOptions
16
+
3
17
  ## 4.0.0-beta.41
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -863,7 +863,7 @@ type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessag
863
863
  /**
864
864
  * Additional options that are sent into each tool call.
865
865
  */
866
- interface ToolCallOptions {
866
+ interface ToolExecutionOptions {
867
867
  /**
868
868
  * The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
869
869
  */
@@ -904,7 +904,7 @@ type ToolNeedsApprovalFunction<INPUT> = (input: INPUT, options: {
904
904
  */
905
905
  experimental_context?: unknown;
906
906
  }) => boolean | PromiseLike<boolean>;
907
- type ToolExecuteFunction<INPUT, OUTPUT> = (input: INPUT, options: ToolCallOptions) => AsyncIterable<OUTPUT> | PromiseLike<OUTPUT> | OUTPUT;
907
+ type ToolExecuteFunction<INPUT, OUTPUT> = (input: INPUT, options: ToolExecutionOptions) => AsyncIterable<OUTPUT> | PromiseLike<OUTPUT> | OUTPUT;
908
908
  type NeverOptional<N, T> = 0 extends 1 & N ? Partial<T> : [N] extends [never] ? Partial<Record<keyof T, undefined>> : T;
909
909
  type ToolOutputProperties<INPUT, OUTPUT> = NeverOptional<OUTPUT, {
910
910
  /**
@@ -944,13 +944,22 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
944
944
  */
945
945
  providerOptions?: ProviderOptions;
946
946
  /**
947
- The schema of the input that the tool expects. The language model will use this to generate the input.
948
- It is also used to validate the output of the language model.
949
- Use descriptions to make the input understandable for the language model.
947
+ * The schema of the input that the tool expects.
948
+ * The language model will use this to generate the input.
949
+ * It is also used to validate the output of the language model.
950
+ *
951
+ * You can use descriptions on the schema properties to make the input understandable for the language model.
950
952
  */
951
953
  inputSchema: FlexibleSchema<INPUT>;
952
954
  /**
953
- Whether the tool needs approval before it can be executed.
955
+ * An optional list of input examples that show the language
956
+ * model what the input should look like.
957
+ */
958
+ inputExamples?: Array<{
959
+ input: INPUT;
960
+ }>;
961
+ /**
962
+ * Whether the tool needs approval before it can be executed.
954
963
  */
955
964
  needsApproval?: boolean | ToolNeedsApprovalFunction<[INPUT] extends [never] ? unknown : INPUT>;
956
965
  /**
@@ -965,21 +974,21 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
965
974
  * Optional function that is called when the argument streaming starts.
966
975
  * Only called when the tool is used in a streaming context.
967
976
  */
968
- onInputStart?: (options: ToolCallOptions) => void | PromiseLike<void>;
977
+ onInputStart?: (options: ToolExecutionOptions) => void | PromiseLike<void>;
969
978
  /**
970
979
  * Optional function that is called when an argument streaming delta is available.
971
980
  * Only called when the tool is used in a streaming context.
972
981
  */
973
982
  onInputDelta?: (options: {
974
983
  inputTextDelta: string;
975
- } & ToolCallOptions) => void | PromiseLike<void>;
984
+ } & ToolExecutionOptions) => void | PromiseLike<void>;
976
985
  /**
977
986
  * Optional function that is called when a tool call can be started,
978
987
  * even if the execute function is not provided.
979
988
  */
980
989
  onInputAvailable?: (options: {
981
990
  input: [INPUT] extends [never] ? unknown : INPUT;
982
- } & ToolCallOptions) => void | PromiseLike<void>;
991
+ } & ToolExecutionOptions) => void | PromiseLike<void>;
983
992
  } & ToolOutputProperties<INPUT, OUTPUT> & {
984
993
  /**
985
994
  Optional conversion function that maps the tool result to an output that can be used by the language model.
@@ -1143,7 +1152,7 @@ declare function withoutTrailingSlash(url: string | undefined): string | undefin
1143
1152
  declare function executeTool<INPUT, OUTPUT>({ execute, input, options, }: {
1144
1153
  execute: ToolExecuteFunction<INPUT, OUTPUT>;
1145
1154
  input: INPUT;
1146
- options: ToolCallOptions;
1155
+ options: ToolExecutionOptions;
1147
1156
  }): AsyncGenerator<{
1148
1157
  type: 'preliminary';
1149
1158
  output: OUTPUT;
@@ -1211,4 +1220,9 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
1211
1220
  dynamic?: boolean;
1212
1221
  }
1213
1222
 
1214
- export { type AssistantContent, type AssistantModelMessage, type DataContent, DelayedPromise, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
1223
+ /**
1224
+ * @deprecated Use ToolExecutionOptions instead.
1225
+ */
1226
+ type ToolCallOptions = ToolExecutionOptions;
1227
+
1228
+ export { type AssistantContent, type AssistantModelMessage, type DataContent, DelayedPromise, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
package/dist/index.d.ts CHANGED
@@ -863,7 +863,7 @@ type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessag
863
863
  /**
864
864
  * Additional options that are sent into each tool call.
865
865
  */
866
- interface ToolCallOptions {
866
+ interface ToolExecutionOptions {
867
867
  /**
868
868
  * The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
869
869
  */
@@ -904,7 +904,7 @@ type ToolNeedsApprovalFunction<INPUT> = (input: INPUT, options: {
904
904
  */
905
905
  experimental_context?: unknown;
906
906
  }) => boolean | PromiseLike<boolean>;
907
- type ToolExecuteFunction<INPUT, OUTPUT> = (input: INPUT, options: ToolCallOptions) => AsyncIterable<OUTPUT> | PromiseLike<OUTPUT> | OUTPUT;
907
+ type ToolExecuteFunction<INPUT, OUTPUT> = (input: INPUT, options: ToolExecutionOptions) => AsyncIterable<OUTPUT> | PromiseLike<OUTPUT> | OUTPUT;
908
908
  type NeverOptional<N, T> = 0 extends 1 & N ? Partial<T> : [N] extends [never] ? Partial<Record<keyof T, undefined>> : T;
909
909
  type ToolOutputProperties<INPUT, OUTPUT> = NeverOptional<OUTPUT, {
910
910
  /**
@@ -944,13 +944,22 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
944
944
  */
945
945
  providerOptions?: ProviderOptions;
946
946
  /**
947
- The schema of the input that the tool expects. The language model will use this to generate the input.
948
- It is also used to validate the output of the language model.
949
- Use descriptions to make the input understandable for the language model.
947
+ * The schema of the input that the tool expects.
948
+ * The language model will use this to generate the input.
949
+ * It is also used to validate the output of the language model.
950
+ *
951
+ * You can use descriptions on the schema properties to make the input understandable for the language model.
950
952
  */
951
953
  inputSchema: FlexibleSchema<INPUT>;
952
954
  /**
953
- Whether the tool needs approval before it can be executed.
955
+ * An optional list of input examples that show the language
956
+ * model what the input should look like.
957
+ */
958
+ inputExamples?: Array<{
959
+ input: INPUT;
960
+ }>;
961
+ /**
962
+ * Whether the tool needs approval before it can be executed.
954
963
  */
955
964
  needsApproval?: boolean | ToolNeedsApprovalFunction<[INPUT] extends [never] ? unknown : INPUT>;
956
965
  /**
@@ -965,21 +974,21 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
965
974
  * Optional function that is called when the argument streaming starts.
966
975
  * Only called when the tool is used in a streaming context.
967
976
  */
968
- onInputStart?: (options: ToolCallOptions) => void | PromiseLike<void>;
977
+ onInputStart?: (options: ToolExecutionOptions) => void | PromiseLike<void>;
969
978
  /**
970
979
  * Optional function that is called when an argument streaming delta is available.
971
980
  * Only called when the tool is used in a streaming context.
972
981
  */
973
982
  onInputDelta?: (options: {
974
983
  inputTextDelta: string;
975
- } & ToolCallOptions) => void | PromiseLike<void>;
984
+ } & ToolExecutionOptions) => void | PromiseLike<void>;
976
985
  /**
977
986
  * Optional function that is called when a tool call can be started,
978
987
  * even if the execute function is not provided.
979
988
  */
980
989
  onInputAvailable?: (options: {
981
990
  input: [INPUT] extends [never] ? unknown : INPUT;
982
- } & ToolCallOptions) => void | PromiseLike<void>;
991
+ } & ToolExecutionOptions) => void | PromiseLike<void>;
983
992
  } & ToolOutputProperties<INPUT, OUTPUT> & {
984
993
  /**
985
994
  Optional conversion function that maps the tool result to an output that can be used by the language model.
@@ -1143,7 +1152,7 @@ declare function withoutTrailingSlash(url: string | undefined): string | undefin
1143
1152
  declare function executeTool<INPUT, OUTPUT>({ execute, input, options, }: {
1144
1153
  execute: ToolExecuteFunction<INPUT, OUTPUT>;
1145
1154
  input: INPUT;
1146
- options: ToolCallOptions;
1155
+ options: ToolExecutionOptions;
1147
1156
  }): AsyncGenerator<{
1148
1157
  type: 'preliminary';
1149
1158
  output: OUTPUT;
@@ -1211,4 +1220,9 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
1211
1220
  dynamic?: boolean;
1212
1221
  }
1213
1222
 
1214
- export { type AssistantContent, type AssistantModelMessage, type DataContent, DelayedPromise, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
1223
+ /**
1224
+ * @deprecated Use ToolExecutionOptions instead.
1225
+ */
1226
+ type ToolCallOptions = ToolExecutionOptions;
1227
+
1228
+ export { type AssistantContent, type AssistantModelMessage, type DataContent, DelayedPromise, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
package/dist/index.js CHANGED
@@ -378,7 +378,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
378
378
  }
379
379
 
380
380
  // src/version.ts
381
- var VERSION = true ? "4.0.0-beta.41" : "0.0.0-test";
381
+ var VERSION = true ? "4.0.0-beta.43" : "0.0.0-test";
382
382
 
383
383
  // src/get-from-api.ts
384
384
  var getOriginalFetch = () => globalThis.fetch;