Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@ai-sdk/provider-utils

Package Overview
Dependencies
Maintainers
3
Versions
227
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/provider-utils - npm Package Compare versions

Comparing version
4.0.10
to
4.0.11
+8
-0
CHANGELOG.md
# @ai-sdk/provider-utils
## 4.0.11
### Patch Changes
- 2810850: fix(ai): improve type validation error messages with field paths and entity identifiers
- Updated dependencies [2810850]
- @ai-sdk/provider@3.0.6
## 4.0.10

@@ -4,0 +12,0 @@

+170
-166

@@ -1,2 +0,2 @@

import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions } from '@ai-sdk/provider';
import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions, TypeValidationContext } from '@ai-sdk/provider';
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';

@@ -85,7 +85,7 @@ export * from '@standard-schema/spec';

/**
Extracts the headers from a response object and returns them as a key-value object.
@param response - The response object to extract headers from.
@returns The headers as a key-value object.
*/
* Extracts the headers from a response object and returns them as a key-value object.
*
* @param response - The response object to extract headers from.
* @returns The headers as a key-value object.
*/
declare function extractResponseHeaders(response: Response): {

@@ -171,10 +171,10 @@ [k: string]: string;

/**
Creates an ID generator.
The total length of the ID is the sum of the prefix, separator, and random part length.
Not cryptographically secure.
@param alphabet - The alphabet to use for the ID. Default: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
@param prefix - The prefix of the ID to generate. Optional.
@param separator - The separator between the prefix and the random part of the ID. Default: '-'.
@param size - The size of the random part of the ID to generate. Default: 16.
* Creates an ID generator.
* The total length of the ID is the sum of the prefix, separator, and random part length.
* Not cryptographically secure.
*
* @param alphabet - The alphabet to use for the ID. Default: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
* @param prefix - The prefix of the ID to generate. Optional.
* @param separator - The separator between the prefix and the random part of the ID. Default: '-'.
* @param size - The size of the random part of the ID to generate. Default: 16.
*/

@@ -188,8 +188,8 @@ declare const createIdGenerator: ({ prefix, size, alphabet, separator, }?: {

/**
A function that generates an ID.
* A function that generates an ID.
*/
type IdGenerator = () => string;
/**
Generates a 16-character random string to use for IDs.
Not cryptographically secure.
* Generates a 16-character random string to use for IDs.
* Not cryptographically secure.
*/

@@ -503,3 +503,3 @@ declare const generateId: IdGenerator;

/**
Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
* Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
*/

@@ -509,6 +509,6 @@ type DataContent = string | Uint8Array | ArrayBuffer | Buffer;

/**
Additional provider-specific options.
They are passed through to the provider from the AI SDK and enable
provider-specific functionality that can be fully encapsulated in the provider.
* Additional provider-specific options.
*
* They are passed through to the provider from the AI SDK and enable
* provider-specific functionality that can be fully encapsulated in the provider.
*/

@@ -518,3 +518,3 @@ type ProviderOptions = SharedV3ProviderOptions;

/**
Text content part of a prompt. It contains a string of text.
* Text content part of a prompt. It contains a string of text.
*/

@@ -524,14 +524,14 @@ interface TextPart {

/**
The text content.
* The text content.
*/
text: string;
/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;
}
/**
Image content part of a prompt. It contains an image.
* Image content part of a prompt. It contains an image.
*/

@@ -541,23 +541,23 @@ interface ImagePart {

/**
Image data. Can either be:
- data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
- URL: a URL that points to the image
* Image data. Can either be:
*
* - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
* - URL: a URL that points to the image
*/
image: DataContent | URL;
/**
Optional IANA media type of the image.
@see https://www.iana.org/assignments/media-types/media-types.xhtml
* Optional IANA media type of the image.
*
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
mediaType?: string;
/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;
}
/**
File content part of a prompt. It contains a file.
* File content part of a prompt. It contains a file.
*/

@@ -567,23 +567,23 @@ interface FilePart {

/**
File data. Can either be:
- data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
- URL: a URL that points to the image
* File data. Can either be:
*
* - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
* - URL: a URL that points to the image
*/
data: DataContent | URL;
/**
Optional filename of the file.
* Optional filename of the file.
*/
filename?: string;
/**
IANA media type of the file.
@see https://www.iana.org/assignments/media-types/media-types.xhtml
* IANA media type of the file.
*
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
mediaType: string;
/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;

@@ -597,14 +597,14 @@ }

/**
The reasoning text.
* The reasoning text.
*/
text: string;
/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;
}
/**
Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
* Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
*/

@@ -614,26 +614,26 @@ interface ToolCallPart {

/**
ID of the tool call. This ID is used to match the tool call with the tool result.
*/
* ID of the tool call. This ID is used to match the tool call with the tool result.
*/
toolCallId: string;
/**
Name of the tool that is being called.
*/
* Name of the tool that is being called.
*/
toolName: string;
/**
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
*/
input: unknown;
/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;
/**
Whether the tool call was executed by the provider.
*/
* Whether the tool call was executed by the provider.
*/
providerExecuted?: boolean;
}
/**
Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
* Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
*/

@@ -643,18 +643,18 @@ interface ToolResultPart {

/**
ID of the tool call that this result is associated with.
*/
* ID of the tool call that this result is associated with.
*/
toolCallId: string;
/**
Name of the tool that generated this result.
*/
* Name of the tool that generated this result.
*/
toolName: string;
/**
Result of the tool call. This is a JSON-serializable object.
* Result of the tool call. This is a JSON-serializable object.
*/
output: ToolResultOutput;
/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;

@@ -714,4 +714,4 @@ }

/**
Text content.
*/
* Text content.
*/
text: string;

@@ -732,9 +732,9 @@ /**

/**
Base-64 encoded media data.
*/
* Base-64 encoded media data.
*/
data: string;
/**
IANA media type.
@see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
* IANA media type.
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
mediaType: string;

@@ -780,9 +780,9 @@ /**

/**
Base-64 encoded image data.
*/
* Base-64 encoded image data.
*/
data: string;
/**
IANA media type.
@see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
* IANA media type.
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
mediaType: string;

@@ -853,3 +853,3 @@ /**

/**
An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
* An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
*/

@@ -860,5 +860,5 @@ type AssistantModelMessage = {

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/

@@ -868,4 +868,4 @@ providerOptions?: ProviderOptions;

/**
Content of an assistant message.
It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
* Content of an assistant message.
* It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
*/

@@ -875,7 +875,7 @@ type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | ToolCallPart | ToolResultPart | ToolApprovalRequest>;

/**
A system message. It can contain system information.
Note: using the "system" part of the prompt is strongly preferred
to increase the resilience against prompt injection attacks,
and because not all providers support several system messages.
* A system message. It can contain system information.
*
* Note: using the "system" part of the prompt is strongly preferred
* to increase the resilience against prompt injection attacks,
* and because not all providers support several system messages.
*/

@@ -886,6 +886,6 @@ type SystemModelMessage = {

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;

@@ -919,3 +919,3 @@ };

/**
A tool message. It contains the result of one or more tool calls.
* A tool message. It contains the result of one or more tool calls.
*/

@@ -926,5 +926,5 @@ type ToolModelMessage = {

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/

@@ -934,3 +934,3 @@ providerOptions?: ProviderOptions;

/**
Content of a tool message. It is an array of tool result parts.
* Content of a tool message. It is an array of tool result parts.
*/

@@ -940,3 +940,3 @@ type ToolContent = Array<ToolResultPart | ToolApprovalResponse>;

/**
A user message. It can contain text or a combination of text and images.
* A user message. It can contain text or a combination of text and images.
*/

@@ -947,16 +947,16 @@ type UserModelMessage = {

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;
};
/**
Content of a user message. It can be a string or an array of text and image parts.
*/
* Content of a user message. It can be a string or an array of text and image parts.
*/
type UserContent = string | Array<TextPart | ImagePart | FilePart>;
/**
A message that can be used in the `messages` field of a prompt.
It can be a user message, an assistant message, or a tool message.
* A message that can be used in the `messages` field of a prompt.
* It can be a user message, an assistant message, or a tool message.
*/

@@ -1020,8 +1020,8 @@ type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessage | ToolModelMessage;

/**
An async function that is called with the arguments from the tool call and produces a result.
If not provided, the tool will not be executed automatically.
@args is the input of the tool call.
@options.abortSignal is a signal that can be used to abort the tool call.
*/
* An async function that is called with the arguments from the tool call and produces a result.
* If not provided, the tool will not be executed automatically.
*
* @args is the input of the tool call.
* @options.abortSignal is a signal that can be used to abort the tool call.
*/
execute: ToolExecuteFunction<INPUT, OUTPUT>;

@@ -1034,12 +1034,12 @@ outputSchema?: FlexibleSchema<OUTPUT>;

/**
A tool contains the description and the schema of the input that the tool expects.
This enables the language model to generate the input.
The tool can also contain an optional execute function for the actual execution function of the tool.
* A tool contains the description and the schema of the input that the tool expects.
* This enables the language model to generate the input.
*
* The tool can also contain an optional execute function for the actual execution function of the tool.
*/
type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONValue | unknown | never = any> = {
/**
An optional description of what the tool does.
Will be used by the language model to decide whether to use the tool.
Not used for provider-defined tools.
* An optional description of what the tool does.
* Will be used by the language model to decide whether to use the tool.
* Not used for provider-defined tools.
*/

@@ -1052,5 +1052,5 @@ description?: string;

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/

@@ -1126,23 +1126,23 @@ providerOptions?: ProviderOptions;

/**
Tool with user-defined input and output schemas.
*/
* Tool with user-defined input and output schemas.
*/
type?: undefined | 'function';
} | {
/**
Tool that is defined at runtime (e.g. an MCP tool).
The types of input and output are not known at development time.
*/
* Tool that is defined at runtime (e.g. an MCP tool).
* The types of input and output are not known at development time.
*/
type: 'dynamic';
} | {
/**
Tool with provider-defined input and output schemas.
*/
* Tool with provider-defined input and output schemas.
*/
type: 'provider';
/**
The ID of the tool. Must follow the format `<provider-name>.<unique-tool-name>`.
*/
* The ID of the tool. Must follow the format `<provider-name>.<unique-tool-name>`.
*/
id: `${string}.${string}`;
/**
The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
*/
* The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
*/
args: Record<string, unknown>;

@@ -1173,3 +1173,3 @@ /**

/**
Helper function for inferring the execute args of a tool.
* Helper function for inferring the execute args of a tool.
*/

@@ -1278,7 +1278,9 @@ declare function tool<INPUT, OUTPUT>(tool: Tool<INPUT, OUTPUT>): Tool<INPUT, OUTPUT>;

* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
* @param {TypeValidationContext} options.context - Optional context about what is being validated.
* @returns {Promise<T>} - The typed object.
*/
declare function validateTypes<OBJECT>({ value, schema, }: {
declare function validateTypes<OBJECT>({ value, schema, context, }: {
value: unknown;
schema: FlexibleSchema<OBJECT>;
context?: TypeValidationContext;
}): Promise<OBJECT>;

@@ -1292,7 +1294,9 @@ /**

* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
* @param {TypeValidationContext} options.context - Optional context about what is being validated.
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
*/
declare function safeValidateTypes<OBJECT>({ value, schema, }: {
declare function safeValidateTypes<OBJECT>({ value, schema, context, }: {
value: unknown;
schema: FlexibleSchema<OBJECT>;
context?: TypeValidationContext;
}): Promise<{

@@ -1337,16 +1341,16 @@ success: true;

/**
Typed tool call that is returned by generateText and streamText.
It contains the tool call ID, the tool name, and the tool arguments.
* Typed tool call that is returned by generateText and streamText.
* It contains the tool call ID, the tool name, and the tool arguments.
*/
interface ToolCall<NAME extends string, INPUT> {
/**
ID of the tool call. This ID is used to match the tool call with the tool result.
*/
* ID of the tool call. This ID is used to match the tool call with the tool result.
*/
toolCallId: string;
/**
Name of the tool that is being called.
*/
* Name of the tool that is being called.
*/
toolName: NAME;
/**
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
*/

@@ -1366,21 +1370,21 @@ input: INPUT;

/**
Typed tool result that is returned by `generateText` and `streamText`.
It contains the tool call ID, the tool name, the tool arguments, and the tool result.
* Typed tool result that is returned by `generateText` and `streamText`.
* It contains the tool call ID, the tool name, the tool arguments, and the tool result.
*/
interface ToolResult<NAME extends string, INPUT, OUTPUT> {
/**
ID of the tool call. This ID is used to match the tool call with the tool result.
* ID of the tool call. This ID is used to match the tool call with the tool result.
*/
toolCallId: string;
/**
Name of the tool that was called.
* Name of the tool that was called.
*/
toolName: NAME;
/**
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
*/
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
*/
input: INPUT;
/**
Result of the tool call. This is the result of the tool's execution.
*/
* Result of the tool call. This is the result of the tool's execution.
*/
output: OUTPUT;

@@ -1387,0 +1391,0 @@ /**

@@ -1,2 +0,2 @@

import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions } from '@ai-sdk/provider';
import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions, TypeValidationContext } from '@ai-sdk/provider';
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';

@@ -85,7 +85,7 @@ export * from '@standard-schema/spec';

/**
Extracts the headers from a response object and returns them as a key-value object.
@param response - The response object to extract headers from.
@returns The headers as a key-value object.
*/
* Extracts the headers from a response object and returns them as a key-value object.
*
* @param response - The response object to extract headers from.
* @returns The headers as a key-value object.
*/
declare function extractResponseHeaders(response: Response): {

@@ -171,10 +171,10 @@ [k: string]: string;

/**
Creates an ID generator.
The total length of the ID is the sum of the prefix, separator, and random part length.
Not cryptographically secure.
@param alphabet - The alphabet to use for the ID. Default: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
@param prefix - The prefix of the ID to generate. Optional.
@param separator - The separator between the prefix and the random part of the ID. Default: '-'.
@param size - The size of the random part of the ID to generate. Default: 16.
* Creates an ID generator.
* The total length of the ID is the sum of the prefix, separator, and random part length.
* Not cryptographically secure.
*
* @param alphabet - The alphabet to use for the ID. Default: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
* @param prefix - The prefix of the ID to generate. Optional.
* @param separator - The separator between the prefix and the random part of the ID. Default: '-'.
* @param size - The size of the random part of the ID to generate. Default: 16.
*/

@@ -188,8 +188,8 @@ declare const createIdGenerator: ({ prefix, size, alphabet, separator, }?: {

/**
A function that generates an ID.
* A function that generates an ID.
*/
type IdGenerator = () => string;
/**
Generates a 16-character random string to use for IDs.
Not cryptographically secure.
* Generates a 16-character random string to use for IDs.
* Not cryptographically secure.
*/

@@ -503,3 +503,3 @@ declare const generateId: IdGenerator;

/**
Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
* Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
*/

@@ -509,6 +509,6 @@ type DataContent = string | Uint8Array | ArrayBuffer | Buffer;

/**
Additional provider-specific options.
They are passed through to the provider from the AI SDK and enable
provider-specific functionality that can be fully encapsulated in the provider.
* Additional provider-specific options.
*
* They are passed through to the provider from the AI SDK and enable
* provider-specific functionality that can be fully encapsulated in the provider.
*/

@@ -518,3 +518,3 @@ type ProviderOptions = SharedV3ProviderOptions;

/**
Text content part of a prompt. It contains a string of text.
* Text content part of a prompt. It contains a string of text.
*/

@@ -524,14 +524,14 @@ interface TextPart {

/**
The text content.
* The text content.
*/
text: string;
/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;
}
/**
Image content part of a prompt. It contains an image.
* Image content part of a prompt. It contains an image.
*/

@@ -541,23 +541,23 @@ interface ImagePart {

/**
Image data. Can either be:
- data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
- URL: a URL that points to the image
* Image data. Can either be:
*
* - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
* - URL: a URL that points to the image
*/
image: DataContent | URL;
/**
Optional IANA media type of the image.
@see https://www.iana.org/assignments/media-types/media-types.xhtml
* Optional IANA media type of the image.
*
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
mediaType?: string;
/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;
}
/**
File content part of a prompt. It contains a file.
* File content part of a prompt. It contains a file.
*/

@@ -567,23 +567,23 @@ interface FilePart {

/**
File data. Can either be:
- data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
- URL: a URL that points to the image
* File data. Can either be:
*
* - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
* - URL: a URL that points to the image
*/
data: DataContent | URL;
/**
Optional filename of the file.
* Optional filename of the file.
*/
filename?: string;
/**
IANA media type of the file.
@see https://www.iana.org/assignments/media-types/media-types.xhtml
* IANA media type of the file.
*
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
mediaType: string;
/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;

@@ -597,14 +597,14 @@ }

/**
The reasoning text.
* The reasoning text.
*/
text: string;
/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;
}
/**
Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
* Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
*/

@@ -614,26 +614,26 @@ interface ToolCallPart {

/**
ID of the tool call. This ID is used to match the tool call with the tool result.
*/
* ID of the tool call. This ID is used to match the tool call with the tool result.
*/
toolCallId: string;
/**
Name of the tool that is being called.
*/
* Name of the tool that is being called.
*/
toolName: string;
/**
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
*/
input: unknown;
/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;
/**
Whether the tool call was executed by the provider.
*/
* Whether the tool call was executed by the provider.
*/
providerExecuted?: boolean;
}
/**
Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
* Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
*/

@@ -643,18 +643,18 @@ interface ToolResultPart {

/**
ID of the tool call that this result is associated with.
*/
* ID of the tool call that this result is associated with.
*/
toolCallId: string;
/**
Name of the tool that generated this result.
*/
* Name of the tool that generated this result.
*/
toolName: string;
/**
Result of the tool call. This is a JSON-serializable object.
* Result of the tool call. This is a JSON-serializable object.
*/
output: ToolResultOutput;
/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;

@@ -714,4 +714,4 @@ }

/**
Text content.
*/
* Text content.
*/
text: string;

@@ -732,9 +732,9 @@ /**

/**
Base-64 encoded media data.
*/
* Base-64 encoded media data.
*/
data: string;
/**
IANA media type.
@see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
* IANA media type.
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
mediaType: string;

@@ -780,9 +780,9 @@ /**

/**
Base-64 encoded image data.
*/
* Base-64 encoded image data.
*/
data: string;
/**
IANA media type.
@see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
* IANA media type.
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
mediaType: string;

@@ -853,3 +853,3 @@ /**

/**
An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
* An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
*/

@@ -860,5 +860,5 @@ type AssistantModelMessage = {

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/

@@ -868,4 +868,4 @@ providerOptions?: ProviderOptions;

/**
Content of an assistant message.
It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
* Content of an assistant message.
* It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
*/

@@ -875,7 +875,7 @@ type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | ToolCallPart | ToolResultPart | ToolApprovalRequest>;

/**
A system message. It can contain system information.
Note: using the "system" part of the prompt is strongly preferred
to increase the resilience against prompt injection attacks,
and because not all providers support several system messages.
* A system message. It can contain system information.
*
* Note: using the "system" part of the prompt is strongly preferred
* to increase the resilience against prompt injection attacks,
* and because not all providers support several system messages.
*/

@@ -886,6 +886,6 @@ type SystemModelMessage = {

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;

@@ -919,3 +919,3 @@ };

/**
A tool message. It contains the result of one or more tool calls.
* A tool message. It contains the result of one or more tool calls.
*/

@@ -926,5 +926,5 @@ type ToolModelMessage = {

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/

@@ -934,3 +934,3 @@ providerOptions?: ProviderOptions;

/**
Content of a tool message. It is an array of tool result parts.
* Content of a tool message. It is an array of tool result parts.
*/

@@ -940,3 +940,3 @@ type ToolContent = Array<ToolResultPart | ToolApprovalResponse>;

/**
A user message. It can contain text or a combination of text and images.
* A user message. It can contain text or a combination of text and images.
*/

@@ -947,16 +947,16 @@ type UserModelMessage = {

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;
};
/**
Content of a user message. It can be a string or an array of text and image parts.
*/
* Content of a user message. It can be a string or an array of text and image parts.
*/
type UserContent = string | Array<TextPart | ImagePart | FilePart>;
/**
A message that can be used in the `messages` field of a prompt.
It can be a user message, an assistant message, or a tool message.
* A message that can be used in the `messages` field of a prompt.
* It can be a user message, an assistant message, or a tool message.
*/

@@ -1020,8 +1020,8 @@ type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessage | ToolModelMessage;

/**
An async function that is called with the arguments from the tool call and produces a result.
If not provided, the tool will not be executed automatically.
@args is the input of the tool call.
@options.abortSignal is a signal that can be used to abort the tool call.
*/
* An async function that is called with the arguments from the tool call and produces a result.
* If not provided, the tool will not be executed automatically.
*
* @args is the input of the tool call.
* @options.abortSignal is a signal that can be used to abort the tool call.
*/
execute: ToolExecuteFunction<INPUT, OUTPUT>;

@@ -1034,12 +1034,12 @@ outputSchema?: FlexibleSchema<OUTPUT>;

/**
A tool contains the description and the schema of the input that the tool expects.
This enables the language model to generate the input.
The tool can also contain an optional execute function for the actual execution function of the tool.
* A tool contains the description and the schema of the input that the tool expects.
* This enables the language model to generate the input.
*
* The tool can also contain an optional execute function for the actual execution function of the tool.
*/
type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONValue | unknown | never = any> = {
/**
An optional description of what the tool does.
Will be used by the language model to decide whether to use the tool.
Not used for provider-defined tools.
* An optional description of what the tool does.
* Will be used by the language model to decide whether to use the tool.
* Not used for provider-defined tools.
*/

@@ -1052,5 +1052,5 @@ description?: string;

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/

@@ -1126,23 +1126,23 @@ providerOptions?: ProviderOptions;

/**
Tool with user-defined input and output schemas.
*/
* Tool with user-defined input and output schemas.
*/
type?: undefined | 'function';
} | {
/**
Tool that is defined at runtime (e.g. an MCP tool).
The types of input and output are not known at development time.
*/
* Tool that is defined at runtime (e.g. an MCP tool).
* The types of input and output are not known at development time.
*/
type: 'dynamic';
} | {
/**
Tool with provider-defined input and output schemas.
*/
* Tool with provider-defined input and output schemas.
*/
type: 'provider';
/**
The ID of the tool. Must follow the format `<provider-name>.<unique-tool-name>`.
*/
* The ID of the tool. Must follow the format `<provider-name>.<unique-tool-name>`.
*/
id: `${string}.${string}`;
/**
The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
*/
* The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
*/
args: Record<string, unknown>;

@@ -1173,3 +1173,3 @@ /**

/**
Helper function for inferring the execute args of a tool.
* Helper function for inferring the execute args of a tool.
*/

@@ -1278,7 +1278,9 @@ declare function tool<INPUT, OUTPUT>(tool: Tool<INPUT, OUTPUT>): Tool<INPUT, OUTPUT>;

* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
* @param {TypeValidationContext} options.context - Optional context about what is being validated.
* @returns {Promise<T>} - The typed object.
*/
declare function validateTypes<OBJECT>({ value, schema, }: {
declare function validateTypes<OBJECT>({ value, schema, context, }: {
value: unknown;
schema: FlexibleSchema<OBJECT>;
context?: TypeValidationContext;
}): Promise<OBJECT>;

@@ -1292,7 +1294,9 @@ /**

* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
* @param {TypeValidationContext} options.context - Optional context about what is being validated.
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
*/
declare function safeValidateTypes<OBJECT>({ value, schema, }: {
declare function safeValidateTypes<OBJECT>({ value, schema, context, }: {
value: unknown;
schema: FlexibleSchema<OBJECT>;
context?: TypeValidationContext;
}): Promise<{

@@ -1337,16 +1341,16 @@ success: true;

/**
Typed tool call that is returned by generateText and streamText.
It contains the tool call ID, the tool name, and the tool arguments.
* Typed tool call that is returned by generateText and streamText.
* It contains the tool call ID, the tool name, and the tool arguments.
*/
interface ToolCall<NAME extends string, INPUT> {
/**
ID of the tool call. This ID is used to match the tool call with the tool result.
*/
* ID of the tool call. This ID is used to match the tool call with the tool result.
*/
toolCallId: string;
/**
Name of the tool that is being called.
*/
* Name of the tool that is being called.
*/
toolName: NAME;
/**
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
*/

@@ -1366,21 +1370,21 @@ input: INPUT;

/**
Typed tool result that is returned by `generateText` and `streamText`.
It contains the tool call ID, the tool name, the tool arguments, and the tool result.
* Typed tool result that is returned by `generateText` and `streamText`.
* It contains the tool call ID, the tool name, the tool arguments, and the tool result.
*/
interface ToolResult<NAME extends string, INPUT, OUTPUT> {
/**
ID of the tool call. This ID is used to match the tool call with the tool result.
* ID of the tool call. This ID is used to match the tool call with the tool result.
*/
toolCallId: string;
/**
Name of the tool that was called.
* Name of the tool that was called.
*/
toolName: NAME;
/**
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
*/
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
*/
input: INPUT;
/**
Result of the tool call. This is the result of the tool's execution.
*/
* Result of the tool call. This is the result of the tool's execution.
*/
output: OUTPUT;

@@ -1387,0 +1391,0 @@ /**

{
"name": "@ai-sdk/provider-utils",
"version": "4.0.10",
"version": "4.0.11",
"license": "Apache-2.0",

@@ -38,3 +38,3 @@ "sideEffects": false,

"eventsource-parser": "^3.0.6",
"@ai-sdk/provider": "3.0.5"
"@ai-sdk/provider": "3.0.6"
},

@@ -41,0 +41,0 @@ "devDependencies": {

/**
Extracts the headers from a response object and returns them as a key-value object.
@param response - The response object to extract headers from.
@returns The headers as a key-value object.
*/
* Extracts the headers from a response object and returns them as a key-value object.
*
* @param response - The response object to extract headers from.
* @returns The headers as a key-value object.
*/
export function extractResponseHeaders(response: Response) {
return Object.fromEntries<string>([...response.headers]);
}
import { InvalidArgumentError } from '@ai-sdk/provider';
/**
Creates an ID generator.
The total length of the ID is the sum of the prefix, separator, and random part length.
Not cryptographically secure.
@param alphabet - The alphabet to use for the ID. Default: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
@param prefix - The prefix of the ID to generate. Optional.
@param separator - The separator between the prefix and the random part of the ID. Default: '-'.
@param size - The size of the random part of the ID to generate. Default: 16.
* Creates an ID generator.
* The total length of the ID is the sum of the prefix, separator, and random part length.
* Not cryptographically secure.
*
* @param alphabet - The alphabet to use for the ID. Default: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
* @param prefix - The prefix of the ID to generate. Optional.
* @param separator - The separator between the prefix and the random part of the ID. Default: '-'.
* @param size - The size of the random part of the ID to generate. Default: 16.
*/

@@ -49,3 +49,3 @@ export const createIdGenerator = ({

/**
A function that generates an ID.
* A function that generates an ID.
*/

@@ -55,5 +55,5 @@ export type IdGenerator = () => string;

/**
Generates a 16-character random string to use for IDs.
Not cryptographically secure.
* Generates a 16-character random string to use for IDs.
* Not cryptographically secure.
*/
export const generateId = createIdGenerator();

@@ -12,3 +12,3 @@ import {

/**
An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
* An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
*/

@@ -20,5 +20,5 @@ export type AssistantModelMessage = {

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/

@@ -29,4 +29,4 @@ providerOptions?: ProviderOptions;

/**
Content of an assistant message.
It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
* Content of an assistant message.
* It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
*/

@@ -33,0 +33,0 @@ export type AssistantContent =

@@ -6,3 +6,3 @@ import { JSONValue } from '@ai-sdk/provider';

/**
Text content part of a prompt. It contains a string of text.
* Text content part of a prompt. It contains a string of text.
*/

@@ -13,3 +13,3 @@ export interface TextPart {

/**
The text content.
* The text content.
*/

@@ -19,6 +19,6 @@ text: string;

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;

@@ -28,3 +28,3 @@ }

/**
Image content part of a prompt. It contains an image.
* Image content part of a prompt. It contains an image.
*/

@@ -35,6 +35,6 @@ export interface ImagePart {

/**
Image data. Can either be:
- data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
- URL: a URL that points to the image
* Image data. Can either be:
*
* - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
* - URL: a URL that points to the image
*/

@@ -44,5 +44,5 @@ image: DataContent | URL;

/**
Optional IANA media type of the image.
@see https://www.iana.org/assignments/media-types/media-types.xhtml
* Optional IANA media type of the image.
*
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
*/

@@ -52,6 +52,6 @@ mediaType?: string;

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;

@@ -61,3 +61,3 @@ }

/**
File content part of a prompt. It contains a file.
* File content part of a prompt. It contains a file.
*/

@@ -68,6 +68,6 @@ export interface FilePart {

/**
File data. Can either be:
- data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
- URL: a URL that points to the image
* File data. Can either be:
*
* - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
* - URL: a URL that points to the image
*/

@@ -77,3 +77,3 @@ data: DataContent | URL;

/**
Optional filename of the file.
* Optional filename of the file.
*/

@@ -83,5 +83,5 @@ filename?: string;

/**
IANA media type of the file.
@see https://www.iana.org/assignments/media-types/media-types.xhtml
* IANA media type of the file.
*
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
*/

@@ -91,6 +91,6 @@ mediaType: string;

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;

@@ -106,3 +106,3 @@ }

/**
The reasoning text.
* The reasoning text.
*/

@@ -112,6 +112,6 @@ text: string;

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;

@@ -121,3 +121,3 @@ }

/**
Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
* Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
*/

@@ -128,13 +128,13 @@ export interface ToolCallPart {

/**
ID of the tool call. This ID is used to match the tool call with the tool result.
*/
* ID of the tool call. This ID is used to match the tool call with the tool result.
*/
toolCallId: string;
/**
Name of the tool that is being called.
*/
* Name of the tool that is being called.
*/
toolName: string;
/**
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
*/

@@ -144,11 +144,11 @@ input: unknown;

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;
/**
Whether the tool call was executed by the provider.
*/
* Whether the tool call was executed by the provider.
*/
providerExecuted?: boolean;

@@ -158,3 +158,3 @@ }

/**
Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
* Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
*/

@@ -165,13 +165,13 @@ export interface ToolResultPart {

/**
ID of the tool call that this result is associated with.
*/
* ID of the tool call that this result is associated with.
*/
toolCallId: string;
/**
Name of the tool that generated this result.
*/
* Name of the tool that generated this result.
*/
toolName: string;
/**
Result of the tool call. This is a JSON-serializable object.
* Result of the tool call. This is a JSON-serializable object.
*/

@@ -181,6 +181,6 @@ output: ToolResultOutput;

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;

@@ -255,4 +255,4 @@ }

/**
Text content.
*/
* Text content.
*/
text: string;

@@ -277,10 +277,10 @@

/**
Base-64 encoded media data.
*/
* Base-64 encoded media data.
*/
data: string;
/**
IANA media type.
@see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
* IANA media type.
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
mediaType: string;

@@ -336,10 +336,10 @@

/**
Base-64 encoded image data.
*/
* Base-64 encoded image data.
*/
data: string;
/**
IANA media type.
@see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
* IANA media type.
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
*/
mediaType: string;

@@ -346,0 +346,0 @@

/**
Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
* Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
*/
export type DataContent = string | Uint8Array | ArrayBuffer | Buffer;

@@ -7,4 +7,4 @@ import { AssistantModelMessage } from './assistant-model-message';

/**
A message that can be used in the `messages` field of a prompt.
It can be a user message, an assistant message, or a tool message.
* A message that can be used in the `messages` field of a prompt.
* It can be a user message, an assistant message, or a tool message.
*/

@@ -11,0 +11,0 @@ export type ModelMessage =

import { SharedV3ProviderOptions } from '@ai-sdk/provider';
/**
Additional provider-specific options.
They are passed through to the provider from the AI SDK and enable
provider-specific functionality that can be fully encapsulated in the provider.
* Additional provider-specific options.
*
* They are passed through to the provider from the AI SDK and enable
* provider-specific functionality that can be fully encapsulated in the provider.
*/
export type ProviderOptions = SharedV3ProviderOptions;
import { ProviderOptions } from './provider-options';
/**
A system message. It can contain system information.
Note: using the "system" part of the prompt is strongly preferred
to increase the resilience against prompt injection attacks,
and because not all providers support several system messages.
* A system message. It can contain system information.
*
* Note: using the "system" part of the prompt is strongly preferred
* to increase the resilience against prompt injection attacks,
* and because not all providers support several system messages.
*/

@@ -15,7 +15,7 @@ export type SystemModelMessage = {

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;
};
/**
Typed tool call that is returned by generateText and streamText.
It contains the tool call ID, the tool name, and the tool arguments.
* Typed tool call that is returned by generateText and streamText.
* It contains the tool call ID, the tool name, and the tool arguments.
*/
export interface ToolCall<NAME extends string, INPUT> {
/**
ID of the tool call. This ID is used to match the tool call with the tool result.
*/
* ID of the tool call. This ID is used to match the tool call with the tool result.
*/
toolCallId: string;
/**
Name of the tool that is being called.
*/
* Name of the tool that is being called.
*/
toolName: NAME;
/**
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
*/

@@ -19,0 +19,0 @@ input: INPUT;

@@ -6,3 +6,3 @@ import { ToolResultPart } from './content-part';

/**
A tool message. It contains the result of one or more tool calls.
* A tool message. It contains the result of one or more tool calls.
*/

@@ -14,5 +14,5 @@ export type ToolModelMessage = {

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/

@@ -23,4 +23,4 @@ providerOptions?: ProviderOptions;

/**
Content of a tool message. It is an array of tool result parts.
* Content of a tool message. It is an array of tool result parts.
*/
export type ToolContent = Array<ToolResultPart | ToolApprovalResponse>;
/**
Typed tool result that is returned by `generateText` and `streamText`.
It contains the tool call ID, the tool name, the tool arguments, and the tool result.
* Typed tool result that is returned by `generateText` and `streamText`.
* It contains the tool call ID, the tool name, the tool arguments, and the tool result.
*/
export interface ToolResult<NAME extends string, INPUT, OUTPUT> {
/**
ID of the tool call. This ID is used to match the tool call with the tool result.
* ID of the tool call. This ID is used to match the tool call with the tool result.
*/

@@ -12,3 +12,3 @@ toolCallId: string;

/**
Name of the tool that was called.
* Name of the tool that was called.
*/

@@ -18,9 +18,9 @@ toolName: NAME;

/**
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
*/
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
*/
input: INPUT;
/**
Result of the tool call. This is the result of the tool's execution.
*/
* Result of the tool call. This is the result of the tool's execution.
*/
output: OUTPUT;

@@ -27,0 +27,0 @@

@@ -85,8 +85,8 @@ import { JSONValue } from '@ai-sdk/provider';

/**
An async function that is called with the arguments from the tool call and produces a result.
If not provided, the tool will not be executed automatically.
@args is the input of the tool call.
@options.abortSignal is a signal that can be used to abort the tool call.
*/
* An async function that is called with the arguments from the tool call and produces a result.
* If not provided, the tool will not be executed automatically.
*
* @args is the input of the tool call.
* @options.abortSignal is a signal that can be used to abort the tool call.
*/
execute: ToolExecuteFunction<INPUT, OUTPUT>;

@@ -104,6 +104,6 @@

/**
A tool contains the description and the schema of the input that the tool expects.
This enables the language model to generate the input.
The tool can also contain an optional execute function for the actual execution function of the tool.
* A tool contains the description and the schema of the input that the tool expects.
* This enables the language model to generate the input.
*
* The tool can also contain an optional execute function for the actual execution function of the tool.
*/

@@ -115,5 +115,5 @@ export type Tool<

/**
An optional description of what the tool does.
Will be used by the language model to decide whether to use the tool.
Not used for provider-defined tools.
* An optional description of what the tool does.
* Will be used by the language model to decide whether to use the tool.
* Not used for provider-defined tools.
*/

@@ -128,5 +128,5 @@ description?: string;

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/

@@ -218,4 +218,4 @@ providerOptions?: ProviderOptions;

/**
Tool with user-defined input and output schemas.
*/
* Tool with user-defined input and output schemas.
*/
type?: undefined | 'function';

@@ -225,5 +225,5 @@ }

/**
Tool that is defined at runtime (e.g. an MCP tool).
The types of input and output are not known at development time.
*/
* Tool that is defined at runtime (e.g. an MCP tool).
* The types of input and output are not known at development time.
*/
type: 'dynamic';

@@ -233,14 +233,14 @@ }

/**
Tool with provider-defined input and output schemas.
*/
* Tool with provider-defined input and output schemas.
*/
type: 'provider';
/**
The ID of the tool. Must follow the format `<provider-name>.<unique-tool-name>`.
*/
* The ID of the tool. Must follow the format `<provider-name>.<unique-tool-name>`.
*/
id: `${string}.${string}`;
/**
The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
*/
* The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
*/
args: Record<string, unknown>;

@@ -278,3 +278,3 @@

/**
Helper function for inferring the execute args of a tool.
* Helper function for inferring the execute args of a tool.
*/

@@ -281,0 +281,0 @@ // Note: overload order is important for auto-completion

@@ -5,3 +5,3 @@ import { FilePart, ImagePart, TextPart } from './content-part';

/**
A user message. It can contain text or a combination of text and images.
* A user message. It can contain text or a combination of text and images.
*/

@@ -13,6 +13,6 @@ export type UserModelMessage = {

/**
Additional provider-specific metadata. They are passed through
to the provider from the AI SDK and enable provider-specific
functionality that can be fully encapsulated in the provider.
*/
* Additional provider-specific metadata. They are passed through
* to the provider from the AI SDK and enable provider-specific
* functionality that can be fully encapsulated in the provider.
*/
providerOptions?: ProviderOptions;

@@ -22,4 +22,4 @@ };

/**
Content of a user message. It can be a string or an array of text and image parts.
*/
* Content of a user message. It can be a string or an array of text and image parts.
*/
export type UserContent = string | Array<TextPart | ImagePart | FilePart>;

@@ -1,2 +0,2 @@

import { TypeValidationError } from '@ai-sdk/provider';
import { TypeValidationContext, TypeValidationError } from '@ai-sdk/provider';
import { FlexibleSchema, asSchema } from './schema';

@@ -11,2 +11,3 @@

* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
* @param {TypeValidationContext} options.context - Optional context about what is being validated.
* @returns {Promise<T>} - The typed object.

@@ -17,10 +18,12 @@ */

schema,
context,
}: {
value: unknown;
schema: FlexibleSchema<OBJECT>;
context?: TypeValidationContext;
}): Promise<OBJECT> {
const result = await safeValidateTypes({ value, schema });
const result = await safeValidateTypes({ value, schema, context });
if (!result.success) {
throw TypeValidationError.wrap({ value, cause: result.error });
throw TypeValidationError.wrap({ value, cause: result.error, context });
}

@@ -38,2 +41,3 @@

* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
* @param {TypeValidationContext} options.context - Optional context about what is being validated.
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.

@@ -44,5 +48,7 @@ */

schema,
context,
}: {
value: unknown;
schema: FlexibleSchema<OBJECT>;
context?: TypeValidationContext;
}): Promise<

@@ -75,3 +81,3 @@ | {

success: false,
error: TypeValidationError.wrap({ value, cause: result.error }),
error: TypeValidationError.wrap({ value, cause: result.error, context }),
rawValue: value,

@@ -82,3 +88,3 @@ };

success: false,
error: TypeValidationError.wrap({ value, cause: error }),
error: TypeValidationError.wrap({ value, cause: error, context }),
rawValue: value,

@@ -85,0 +91,0 @@ };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display