@ai-sdk/provider-utils 4.0.9 → 4.0.11

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.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 2810850: fix(ai): improve type validation error messages with field paths and entity identifiers
8
+ - Updated dependencies [2810850]
9
+ - @ai-sdk/provider@3.0.6
10
+
11
+ ## 4.0.10
12
+
13
+ ### Patch Changes
14
+
15
+ - 462ad00: fix(provider-utils): recognize bun fetch errors as retryable
16
+
3
17
  ## 4.0.9
4
18
 
5
19
  ### 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 } from '@ai-sdk/provider';
1
+ import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions, 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';
@@ -82,11 +82,11 @@ declare class DelayedPromise<T> {
82
82
  }
83
83
 
84
84
  /**
85
- Extracts the headers from a response object and returns them as a key-value object.
86
-
87
- @param response - The response object to extract headers from.
88
- @returns The headers as a key-value object.
89
- */
85
+ * Extracts the headers from a response object and returns them as a key-value object.
86
+ *
87
+ * @param response - The response object to extract headers from.
88
+ * @returns The headers as a key-value object.
89
+ */
90
90
  declare function extractResponseHeaders(response: Response): {
91
91
  [k: string]: string;
92
92
  };
@@ -167,14 +167,14 @@ declare class DownloadError extends AISDKError {
167
167
  type FetchFunction = typeof globalThis.fetch;
168
168
 
169
169
  /**
170
- Creates an ID generator.
171
- The total length of the ID is the sum of the prefix, separator, and random part length.
172
- Not cryptographically secure.
173
-
174
- @param alphabet - The alphabet to use for the ID. Default: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
175
- @param prefix - The prefix of the ID to generate. Optional.
176
- @param separator - The separator between the prefix and the random part of the ID. Default: '-'.
177
- @param size - The size of the random part of the ID to generate. Default: 16.
170
+ * Creates an ID generator.
171
+ * The total length of the ID is the sum of the prefix, separator, and random part length.
172
+ * Not cryptographically secure.
173
+ *
174
+ * @param alphabet - The alphabet to use for the ID. Default: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
175
+ * @param prefix - The prefix of the ID to generate. Optional.
176
+ * @param separator - The separator between the prefix and the random part of the ID. Default: '-'.
177
+ * @param size - The size of the random part of the ID to generate. Default: 16.
178
178
  */
179
179
  declare const createIdGenerator: ({ prefix, size, alphabet, separator, }?: {
180
180
  prefix?: string;
@@ -183,12 +183,12 @@ declare const createIdGenerator: ({ prefix, size, alphabet, separator, }?: {
183
183
  alphabet?: string;
184
184
  }) => IdGenerator;
185
185
  /**
186
- A function that generates an ID.
186
+ * A function that generates an ID.
187
187
  */
188
188
  type IdGenerator = () => string;
189
189
  /**
190
- Generates a 16-character random string to use for IDs.
191
- Not cryptographically secure.
190
+ * Generates a 16-character random string to use for IDs.
191
+ * Not cryptographically secure.
192
192
  */
193
193
  declare const generateId: IdGenerator;
194
194
 
@@ -497,86 +497,86 @@ declare const postToApi: <T>({ url, headers, body, successfulResponseHandler, fa
497
497
  }>;
498
498
 
499
499
  /**
500
- Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
500
+ * Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
501
501
  */
502
502
  type DataContent = string | Uint8Array | ArrayBuffer | Buffer;
503
503
 
504
504
  /**
505
- Additional provider-specific options.
506
-
507
- They are passed through to the provider from the AI SDK and enable
508
- provider-specific functionality that can be fully encapsulated in the provider.
505
+ * Additional provider-specific options.
506
+ *
507
+ * They are passed through to the provider from the AI SDK and enable
508
+ * provider-specific functionality that can be fully encapsulated in the provider.
509
509
  */
510
510
  type ProviderOptions = SharedV3ProviderOptions;
511
511
 
512
512
  /**
513
- Text content part of a prompt. It contains a string of text.
513
+ * Text content part of a prompt. It contains a string of text.
514
514
  */
515
515
  interface TextPart {
516
516
  type: 'text';
517
517
  /**
518
- The text content.
518
+ * The text content.
519
519
  */
520
520
  text: string;
521
521
  /**
522
- Additional provider-specific metadata. They are passed through
523
- to the provider from the AI SDK and enable provider-specific
524
- functionality that can be fully encapsulated in the provider.
525
- */
522
+ * Additional provider-specific metadata. They are passed through
523
+ * to the provider from the AI SDK and enable provider-specific
524
+ * functionality that can be fully encapsulated in the provider.
525
+ */
526
526
  providerOptions?: ProviderOptions;
527
527
  }
528
528
  /**
529
- Image content part of a prompt. It contains an image.
529
+ * Image content part of a prompt. It contains an image.
530
530
  */
531
531
  interface ImagePart {
532
532
  type: 'image';
533
533
  /**
534
- Image data. Can either be:
535
-
536
- - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
537
- - URL: a URL that points to the image
534
+ * Image data. Can either be:
535
+ *
536
+ * - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
537
+ * - URL: a URL that points to the image
538
538
  */
539
539
  image: DataContent | URL;
540
540
  /**
541
- Optional IANA media type of the image.
542
-
543
- @see https://www.iana.org/assignments/media-types/media-types.xhtml
541
+ * Optional IANA media type of the image.
542
+ *
543
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
544
544
  */
545
545
  mediaType?: string;
546
546
  /**
547
- Additional provider-specific metadata. They are passed through
548
- to the provider from the AI SDK and enable provider-specific
549
- functionality that can be fully encapsulated in the provider.
550
- */
547
+ * Additional provider-specific metadata. They are passed through
548
+ * to the provider from the AI SDK and enable provider-specific
549
+ * functionality that can be fully encapsulated in the provider.
550
+ */
551
551
  providerOptions?: ProviderOptions;
552
552
  }
553
553
  /**
554
- File content part of a prompt. It contains a file.
554
+ * File content part of a prompt. It contains a file.
555
555
  */
556
556
  interface FilePart {
557
557
  type: 'file';
558
558
  /**
559
- File data. Can either be:
560
-
561
- - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
562
- - URL: a URL that points to the image
559
+ * File data. Can either be:
560
+ *
561
+ * - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
562
+ * - URL: a URL that points to the image
563
563
  */
564
564
  data: DataContent | URL;
565
565
  /**
566
- Optional filename of the file.
566
+ * Optional filename of the file.
567
567
  */
568
568
  filename?: string;
569
569
  /**
570
- IANA media type of the file.
571
-
572
- @see https://www.iana.org/assignments/media-types/media-types.xhtml
570
+ * IANA media type of the file.
571
+ *
572
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
573
573
  */
574
574
  mediaType: string;
575
575
  /**
576
- Additional provider-specific metadata. They are passed through
577
- to the provider from the AI SDK and enable provider-specific
578
- functionality that can be fully encapsulated in the provider.
579
- */
576
+ * Additional provider-specific metadata. They are passed through
577
+ * to the provider from the AI SDK and enable provider-specific
578
+ * functionality that can be fully encapsulated in the provider.
579
+ */
580
580
  providerOptions?: ProviderOptions;
581
581
  }
582
582
  /**
@@ -585,66 +585,66 @@ interface FilePart {
585
585
  interface ReasoningPart {
586
586
  type: 'reasoning';
587
587
  /**
588
- The reasoning text.
588
+ * The reasoning text.
589
589
  */
590
590
  text: string;
591
591
  /**
592
- Additional provider-specific metadata. They are passed through
593
- to the provider from the AI SDK and enable provider-specific
594
- functionality that can be fully encapsulated in the provider.
595
- */
592
+ * Additional provider-specific metadata. They are passed through
593
+ * to the provider from the AI SDK and enable provider-specific
594
+ * functionality that can be fully encapsulated in the provider.
595
+ */
596
596
  providerOptions?: ProviderOptions;
597
597
  }
598
598
  /**
599
- Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
599
+ * Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
600
600
  */
601
601
  interface ToolCallPart {
602
602
  type: 'tool-call';
603
603
  /**
604
- ID of the tool call. This ID is used to match the tool call with the tool result.
605
- */
604
+ * ID of the tool call. This ID is used to match the tool call with the tool result.
605
+ */
606
606
  toolCallId: string;
607
607
  /**
608
- Name of the tool that is being called.
609
- */
608
+ * Name of the tool that is being called.
609
+ */
610
610
  toolName: string;
611
611
  /**
612
- Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
612
+ * Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
613
613
  */
614
614
  input: unknown;
615
615
  /**
616
- Additional provider-specific metadata. They are passed through
617
- to the provider from the AI SDK and enable provider-specific
618
- functionality that can be fully encapsulated in the provider.
619
- */
616
+ * Additional provider-specific metadata. They are passed through
617
+ * to the provider from the AI SDK and enable provider-specific
618
+ * functionality that can be fully encapsulated in the provider.
619
+ */
620
620
  providerOptions?: ProviderOptions;
621
621
  /**
622
- Whether the tool call was executed by the provider.
623
- */
622
+ * Whether the tool call was executed by the provider.
623
+ */
624
624
  providerExecuted?: boolean;
625
625
  }
626
626
  /**
627
- Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
627
+ * Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
628
628
  */
629
629
  interface ToolResultPart {
630
630
  type: 'tool-result';
631
631
  /**
632
- ID of the tool call that this result is associated with.
633
- */
632
+ * ID of the tool call that this result is associated with.
633
+ */
634
634
  toolCallId: string;
635
635
  /**
636
- Name of the tool that generated this result.
637
- */
636
+ * Name of the tool that generated this result.
637
+ */
638
638
  toolName: string;
639
639
  /**
640
- Result of the tool call. This is a JSON-serializable object.
640
+ * Result of the tool call. This is a JSON-serializable object.
641
641
  */
642
642
  output: ToolResultOutput;
643
643
  /**
644
- Additional provider-specific metadata. They are passed through
645
- to the provider from the AI SDK and enable provider-specific
646
- functionality that can be fully encapsulated in the provider.
647
- */
644
+ * Additional provider-specific metadata. They are passed through
645
+ * to the provider from the AI SDK and enable provider-specific
646
+ * functionality that can be fully encapsulated in the provider.
647
+ */
648
648
  providerOptions?: ProviderOptions;
649
649
  }
650
650
  /**
@@ -699,8 +699,8 @@ type ToolResultOutput = {
699
699
  value: Array<{
700
700
  type: 'text';
701
701
  /**
702
- Text content.
703
- */
702
+ * Text content.
703
+ */
704
704
  text: string;
705
705
  /**
706
706
  * Provider-specific options.
@@ -716,13 +716,13 @@ Text content.
716
716
  } | {
717
717
  type: 'file-data';
718
718
  /**
719
- Base-64 encoded media data.
720
- */
719
+ * Base-64 encoded media data.
720
+ */
721
721
  data: string;
722
722
  /**
723
- IANA media type.
724
- @see https://www.iana.org/assignments/media-types/media-types.xhtml
725
- */
723
+ * IANA media type.
724
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
725
+ */
726
726
  mediaType: string;
727
727
  /**
728
728
  * Optional filename of the file.
@@ -763,13 +763,13 @@ IANA media type.
763
763
  */
764
764
  type: 'image-data';
765
765
  /**
766
- Base-64 encoded image data.
767
- */
766
+ * Base-64 encoded image data.
767
+ */
768
768
  data: string;
769
769
  /**
770
- IANA media type.
771
- @see https://www.iana.org/assignments/media-types/media-types.xhtml
772
- */
770
+ * IANA media type.
771
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
772
+ */
773
773
  mediaType: string;
774
774
  /**
775
775
  * Provider-specific options.
@@ -835,39 +835,39 @@ type ToolApprovalRequest = {
835
835
  };
836
836
 
837
837
  /**
838
- An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
838
+ * An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
839
839
  */
840
840
  type AssistantModelMessage = {
841
841
  role: 'assistant';
842
842
  content: AssistantContent;
843
843
  /**
844
- Additional provider-specific metadata. They are passed through
845
- to the provider from the AI SDK and enable provider-specific
846
- functionality that can be fully encapsulated in the provider.
844
+ * Additional provider-specific metadata. They are passed through
845
+ * to the provider from the AI SDK and enable provider-specific
846
+ * functionality that can be fully encapsulated in the provider.
847
847
  */
848
848
  providerOptions?: ProviderOptions;
849
849
  };
850
850
  /**
851
- Content of an assistant message.
852
- It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
851
+ * Content of an assistant message.
852
+ * It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
853
853
  */
854
854
  type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | ToolCallPart | ToolResultPart | ToolApprovalRequest>;
855
855
 
856
856
  /**
857
- A system message. It can contain system information.
858
-
859
- Note: using the "system" part of the prompt is strongly preferred
860
- to increase the resilience against prompt injection attacks,
861
- and because not all providers support several system messages.
857
+ * A system message. It can contain system information.
858
+ *
859
+ * Note: using the "system" part of the prompt is strongly preferred
860
+ * to increase the resilience against prompt injection attacks,
861
+ * and because not all providers support several system messages.
862
862
  */
863
863
  type SystemModelMessage = {
864
864
  role: 'system';
865
865
  content: string;
866
866
  /**
867
- Additional provider-specific metadata. They are passed through
868
- to the provider from the AI SDK and enable provider-specific
869
- functionality that can be fully encapsulated in the provider.
870
- */
867
+ * Additional provider-specific metadata. They are passed through
868
+ * to the provider from the AI SDK and enable provider-specific
869
+ * functionality that can be fully encapsulated in the provider.
870
+ */
871
871
  providerOptions?: ProviderOptions;
872
872
  };
873
873
 
@@ -896,44 +896,44 @@ type ToolApprovalResponse = {
896
896
  };
897
897
 
898
898
  /**
899
- A tool message. It contains the result of one or more tool calls.
899
+ * A tool message. It contains the result of one or more tool calls.
900
900
  */
901
901
  type ToolModelMessage = {
902
902
  role: 'tool';
903
903
  content: ToolContent;
904
904
  /**
905
- Additional provider-specific metadata. They are passed through
906
- to the provider from the AI SDK and enable provider-specific
907
- functionality that can be fully encapsulated in the provider.
905
+ * Additional provider-specific metadata. They are passed through
906
+ * to the provider from the AI SDK and enable provider-specific
907
+ * functionality that can be fully encapsulated in the provider.
908
908
  */
909
909
  providerOptions?: ProviderOptions;
910
910
  };
911
911
  /**
912
- Content of a tool message. It is an array of tool result parts.
912
+ * Content of a tool message. It is an array of tool result parts.
913
913
  */
914
914
  type ToolContent = Array<ToolResultPart | ToolApprovalResponse>;
915
915
 
916
916
  /**
917
- A user message. It can contain text or a combination of text and images.
917
+ * A user message. It can contain text or a combination of text and images.
918
918
  */
919
919
  type UserModelMessage = {
920
920
  role: 'user';
921
921
  content: UserContent;
922
922
  /**
923
- Additional provider-specific metadata. They are passed through
924
- to the provider from the AI SDK and enable provider-specific
925
- functionality that can be fully encapsulated in the provider.
926
- */
923
+ * Additional provider-specific metadata. They are passed through
924
+ * to the provider from the AI SDK and enable provider-specific
925
+ * functionality that can be fully encapsulated in the provider.
926
+ */
927
927
  providerOptions?: ProviderOptions;
928
928
  };
929
929
  /**
930
- Content of a user message. It can be a string or an array of text and image parts.
931
- */
930
+ * Content of a user message. It can be a string or an array of text and image parts.
931
+ */
932
932
  type UserContent = string | Array<TextPart | ImagePart | FilePart>;
933
933
 
934
934
  /**
935
- A message that can be used in the `messages` field of a prompt.
936
- It can be a user message, an assistant message, or a tool message.
935
+ * A message that can be used in the `messages` field of a prompt.
936
+ * It can be a user message, an assistant message, or a tool message.
937
937
  */
938
938
  type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessage | ToolModelMessage;
939
939
 
@@ -992,12 +992,12 @@ type ToolExecuteFunction<INPUT, OUTPUT> = (input: INPUT, options: ToolExecutionO
992
992
  type NeverOptional<N, T> = 0 extends 1 & N ? Partial<T> : [N] extends [never] ? Partial<Record<keyof T, undefined>> : T;
993
993
  type ToolOutputProperties<INPUT, OUTPUT> = NeverOptional<OUTPUT, {
994
994
  /**
995
- An async function that is called with the arguments from the tool call and produces a result.
996
- If not provided, the tool will not be executed automatically.
997
-
998
- @args is the input of the tool call.
999
- @options.abortSignal is a signal that can be used to abort the tool call.
1000
- */
995
+ * An async function that is called with the arguments from the tool call and produces a result.
996
+ * If not provided, the tool will not be executed automatically.
997
+ *
998
+ * @args is the input of the tool call.
999
+ * @options.abortSignal is a signal that can be used to abort the tool call.
1000
+ */
1001
1001
  execute: ToolExecuteFunction<INPUT, OUTPUT>;
1002
1002
  outputSchema?: FlexibleSchema<OUTPUT>;
1003
1003
  } | {
@@ -1005,16 +1005,16 @@ If not provided, the tool will not be executed automatically.
1005
1005
  execute?: never;
1006
1006
  }>;
1007
1007
  /**
1008
- A tool contains the description and the schema of the input that the tool expects.
1009
- This enables the language model to generate the input.
1010
-
1011
- The tool can also contain an optional execute function for the actual execution function of the tool.
1008
+ * A tool contains the description and the schema of the input that the tool expects.
1009
+ * This enables the language model to generate the input.
1010
+ *
1011
+ * The tool can also contain an optional execute function for the actual execution function of the tool.
1012
1012
  */
1013
1013
  type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONValue | unknown | never = any> = {
1014
1014
  /**
1015
- An optional description of what the tool does.
1016
- Will be used by the language model to decide whether to use the tool.
1017
- Not used for provider-defined tools.
1015
+ * An optional description of what the tool does.
1016
+ * Will be used by the language model to decide whether to use the tool.
1017
+ * Not used for provider-defined tools.
1018
1018
  */
1019
1019
  description?: string;
1020
1020
  /**
@@ -1022,9 +1022,9 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
1022
1022
  */
1023
1023
  title?: string;
1024
1024
  /**
1025
- Additional provider-specific metadata. They are passed through
1026
- to the provider from the AI SDK and enable provider-specific
1027
- functionality that can be fully encapsulated in the provider.
1025
+ * Additional provider-specific metadata. They are passed through
1026
+ * to the provider from the AI SDK and enable provider-specific
1027
+ * functionality that can be fully encapsulated in the provider.
1028
1028
  */
1029
1029
  providerOptions?: ProviderOptions;
1030
1030
  /**
@@ -1095,27 +1095,27 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
1095
1095
  }) => ToolResultOutput | PromiseLike<ToolResultOutput>;
1096
1096
  } & ({
1097
1097
  /**
1098
- Tool with user-defined input and output schemas.
1099
- */
1098
+ * Tool with user-defined input and output schemas.
1099
+ */
1100
1100
  type?: undefined | 'function';
1101
1101
  } | {
1102
1102
  /**
1103
- Tool that is defined at runtime (e.g. an MCP tool).
1104
- The types of input and output are not known at development time.
1105
- */
1103
+ * Tool that is defined at runtime (e.g. an MCP tool).
1104
+ * The types of input and output are not known at development time.
1105
+ */
1106
1106
  type: 'dynamic';
1107
1107
  } | {
1108
1108
  /**
1109
- Tool with provider-defined input and output schemas.
1110
- */
1109
+ * Tool with provider-defined input and output schemas.
1110
+ */
1111
1111
  type: 'provider';
1112
1112
  /**
1113
- The ID of the tool. Must follow the format `<provider-name>.<unique-tool-name>`.
1114
- */
1113
+ * The ID of the tool. Must follow the format `<provider-name>.<unique-tool-name>`.
1114
+ */
1115
1115
  id: `${string}.${string}`;
1116
1116
  /**
1117
- The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
1118
- */
1117
+ * The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
1118
+ */
1119
1119
  args: Record<string, unknown>;
1120
1120
  /**
1121
1121
  * Whether this provider-executed tool supports deferred results.
@@ -1141,7 +1141,7 @@ type InferToolInput<TOOL extends Tool> = TOOL extends Tool<infer INPUT, any> ? I
1141
1141
  */
1142
1142
  type InferToolOutput<TOOL extends Tool> = TOOL extends Tool<any, infer OUTPUT> ? OUTPUT : never;
1143
1143
  /**
1144
- Helper function for inferring the execute args of a tool.
1144
+ * Helper function for inferring the execute args of a tool.
1145
1145
  */
1146
1146
  declare function tool<INPUT, OUTPUT>(tool: Tool<INPUT, OUTPUT>): Tool<INPUT, OUTPUT>;
1147
1147
  declare function tool<INPUT>(tool: Tool<INPUT, never>): Tool<INPUT, never>;
@@ -1245,11 +1245,13 @@ declare function convertToBase64(value: string | Uint8Array): string;
1245
1245
  * @template T - The type of the object to validate.
1246
1246
  * @param {string} options.value - The object to validate.
1247
1247
  * @param {Validator<T>} options.schema - The schema to use for validating the JSON.
1248
+ * @param {TypeValidationContext} options.context - Optional context about what is being validated.
1248
1249
  * @returns {Promise<T>} - The typed object.
1249
1250
  */
1250
- declare function validateTypes<OBJECT>({ value, schema, }: {
1251
+ declare function validateTypes<OBJECT>({ value, schema, context, }: {
1251
1252
  value: unknown;
1252
1253
  schema: FlexibleSchema<OBJECT>;
1254
+ context?: TypeValidationContext;
1253
1255
  }): Promise<OBJECT>;
1254
1256
  /**
1255
1257
  * Safely validates the types of an unknown object using a schema and
@@ -1258,11 +1260,13 @@ declare function validateTypes<OBJECT>({ value, schema, }: {
1258
1260
  * @template T - The type of the object to validate.
1259
1261
  * @param {string} options.value - The JSON object to validate.
1260
1262
  * @param {Validator<T>} options.schema - The schema to use for validating the JSON.
1263
+ * @param {TypeValidationContext} options.context - Optional context about what is being validated.
1261
1264
  * @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
1262
1265
  */
1263
- declare function safeValidateTypes<OBJECT>({ value, schema, }: {
1266
+ declare function safeValidateTypes<OBJECT>({ value, schema, context, }: {
1264
1267
  value: unknown;
1265
1268
  schema: FlexibleSchema<OBJECT>;
1269
+ context?: TypeValidationContext;
1266
1270
  }): Promise<{
1267
1271
  success: true;
1268
1272
  value: OBJECT;
@@ -1302,20 +1306,20 @@ declare function executeTool<INPUT, OUTPUT>({ execute, input, options, }: {
1302
1306
  }>;
1303
1307
 
1304
1308
  /**
1305
- Typed tool call that is returned by generateText and streamText.
1306
- It contains the tool call ID, the tool name, and the tool arguments.
1309
+ * Typed tool call that is returned by generateText and streamText.
1310
+ * It contains the tool call ID, the tool name, and the tool arguments.
1307
1311
  */
1308
1312
  interface ToolCall<NAME extends string, INPUT> {
1309
1313
  /**
1310
- ID of the tool call. This ID is used to match the tool call with the tool result.
1311
- */
1314
+ * ID of the tool call. This ID is used to match the tool call with the tool result.
1315
+ */
1312
1316
  toolCallId: string;
1313
1317
  /**
1314
- Name of the tool that is being called.
1315
- */
1318
+ * Name of the tool that is being called.
1319
+ */
1316
1320
  toolName: NAME;
1317
1321
  /**
1318
- Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
1322
+ * Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
1319
1323
  */
1320
1324
  input: INPUT;
1321
1325
  /**
@@ -1330,25 +1334,25 @@ interface ToolCall<NAME extends string, INPUT> {
1330
1334
  }
1331
1335
 
1332
1336
  /**
1333
- Typed tool result that is returned by `generateText` and `streamText`.
1334
- It contains the tool call ID, the tool name, the tool arguments, and the tool result.
1337
+ * Typed tool result that is returned by `generateText` and `streamText`.
1338
+ * It contains the tool call ID, the tool name, the tool arguments, and the tool result.
1335
1339
  */
1336
1340
  interface ToolResult<NAME extends string, INPUT, OUTPUT> {
1337
1341
  /**
1338
- ID of the tool call. This ID is used to match the tool call with the tool result.
1342
+ * ID of the tool call. This ID is used to match the tool call with the tool result.
1339
1343
  */
1340
1344
  toolCallId: string;
1341
1345
  /**
1342
- Name of the tool that was called.
1346
+ * Name of the tool that was called.
1343
1347
  */
1344
1348
  toolName: NAME;
1345
1349
  /**
1346
- Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
1347
- */
1350
+ * Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
1351
+ */
1348
1352
  input: INPUT;
1349
1353
  /**
1350
- Result of the tool call. This is the result of the tool's execution.
1351
- */
1354
+ * Result of the tool call. This is the result of the tool's execution.
1355
+ */
1352
1356
  output: OUTPUT;
1353
1357
  /**
1354
1358
  * Whether the tool result has been executed by the provider.