ai 5.0.0-alpha.7 → 5.0.0-alpha.8
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 +29 -0
- package/dist/index.d.mts +26 -22
- package/dist/index.d.ts +26 -22
- package/dist/index.js +510 -475
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +488 -449
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +3 -2
- package/dist/internal/index.d.ts +3 -2
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 5.0.0-alpha.8
|
4
|
+
|
5
|
+
### Major Changes
|
6
|
+
|
7
|
+
- c25cbce: feat (ai): use console.error as default error handler for streamText and streamObject
|
8
|
+
|
9
|
+
### Patch Changes
|
10
|
+
|
11
|
+
- 4fef487: feat: support for zod v4 for schema validation
|
12
|
+
|
13
|
+
All these methods now accept both a zod v4 and zod v3 schemas for validation:
|
14
|
+
|
15
|
+
- `generateObject()`
|
16
|
+
- `streamObject()`
|
17
|
+
- `generateText()`
|
18
|
+
- `experimental_useObject()` from `@ai-sdk/react`
|
19
|
+
- `streamUI()` from `@ai-sdk/rsc`
|
20
|
+
|
21
|
+
- 6b1c55c: feat (ai): introduce GLOBAL_DEFAULT_PROVIDER
|
22
|
+
- 2e4f9e4: feat (ai): improved error messages when using gateway
|
23
|
+
- Updated dependencies [4fef487]
|
24
|
+
- Updated dependencies [9222aeb]
|
25
|
+
- Updated dependencies [3cbcbb7]
|
26
|
+
- Updated dependencies [989ac75]
|
27
|
+
- Updated dependencies [7742ba3]
|
28
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.8
|
29
|
+
- @ai-sdk/provider@2.0.0-alpha.8
|
30
|
+
- @ai-sdk/gateway@1.0.0-alpha.8
|
31
|
+
|
3
32
|
## 5.0.0-alpha.7
|
4
33
|
|
5
34
|
### Major Changes
|
package/dist/index.d.mts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
import { ToolResultContent, Schema, ToolCall, ToolResult, IdGenerator, Validator, StandardSchemaV1, FetchFunction } from '@ai-sdk/provider-utils';
|
1
|
+
import { ToolResultContent, Schema, ToolCall, ToolResult, IdGenerator, InferSchema, Validator, StandardSchemaV1, FetchFunction } from '@ai-sdk/provider-utils';
|
2
2
|
export { IdGenerator, Schema, ToolCall, ToolResult, asSchema, createIdGenerator, generateId, jsonSchema } from '@ai-sdk/provider-utils';
|
3
3
|
import { AISDKError, SharedV2ProviderMetadata, SharedV2ProviderOptions, EmbeddingModelV2, EmbeddingModelV2Embedding, ImageModelV2, ImageModelV2CallWarning, ImageModelV2ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2CallWarning, LanguageModelV2Source, SpeechModelV1, SpeechModelV1CallWarning, TranscriptionModelV1, TranscriptionModelV1CallWarning, LanguageModelV2Usage, JSONObject, LanguageModelV2ToolCall, JSONSchema7, LanguageModelV2CallOptions, JSONParseError, TypeValidationError, LanguageModelV2Middleware, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
4
4
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
5
|
-
import
|
5
|
+
import * as z3 from 'zod/v3';
|
6
|
+
import * as z4 from 'zod/v4/core';
|
6
7
|
import { z } from 'zod';
|
7
8
|
import { ServerResponse } from 'node:http';
|
8
9
|
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
@@ -383,7 +384,7 @@ type JSONValue = JSONValue$1;
|
|
383
384
|
/**
|
384
385
|
Language model that is used by the AI SDK Core functions.
|
385
386
|
*/
|
386
|
-
type LanguageModel =
|
387
|
+
type LanguageModel = string | LanguageModelV2;
|
387
388
|
/**
|
388
389
|
Reason why a language model finished generating a response.
|
389
390
|
|
@@ -879,7 +880,7 @@ type MCPTransportConfig = {
|
|
879
880
|
headers?: Record<string, string>;
|
880
881
|
};
|
881
882
|
|
882
|
-
type ToolParameters<T = JSONObject> =
|
883
|
+
type ToolParameters<T = JSONObject> = z4.$ZodType<T> | z3.Schema<T> | Schema<T>;
|
883
884
|
interface ToolExecutionOptions {
|
884
885
|
/**
|
885
886
|
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
@@ -961,7 +962,7 @@ type ToolSchemas = Record<string, {
|
|
961
962
|
parameters: ToolParameters<JSONObject | unknown>;
|
962
963
|
}> | 'automatic' | undefined;
|
963
964
|
type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS extends Record<string, {
|
964
|
-
parameters: ToolParameters<
|
965
|
+
parameters: ToolParameters<unknown>;
|
965
966
|
}> ? {
|
966
967
|
[K in keyof TOOL_SCHEMAS]: MappedTool<TOOL_SCHEMAS[K], CallToolResult> & Required<Pick<MappedTool<TOOL_SCHEMAS[K], CallToolResult>, 'execute'>>;
|
967
968
|
} : McpToolSet<Record<string, {
|
@@ -1901,6 +1902,8 @@ type Prompt = {
|
|
1901
1902
|
messages?: Array<ModelMessage>;
|
1902
1903
|
};
|
1903
1904
|
|
1905
|
+
declare const GLOBAL_DEFAULT_PROVIDER: unique symbol;
|
1906
|
+
|
1904
1907
|
/**
|
1905
1908
|
* A function that attempts to repair a tool call that failed to parse.
|
1906
1909
|
*
|
@@ -2666,7 +2669,7 @@ It always recurses into arrays.
|
|
2666
2669
|
|
2667
2670
|
Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
|
2668
2671
|
*/
|
2669
|
-
type DeepPartial<T> = T extends
|
2672
|
+
type DeepPartial<T> = T extends z3.ZodTypeAny ? DeepPartialInternal<z3.infer<T>> : T extends z4.$ZodType ? DeepPartialInternal<z4.infer<T>> : DeepPartialInternal<T>;
|
2670
2673
|
type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
|
2671
2674
|
type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
2672
2675
|
type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
|
@@ -2676,7 +2679,7 @@ type PartialObject<ObjectType extends object> = {
|
|
2676
2679
|
[KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
|
2677
2680
|
};
|
2678
2681
|
|
2679
|
-
interface Output
|
2682
|
+
interface Output<OUTPUT, PARTIAL> {
|
2680
2683
|
readonly type: 'object' | 'text';
|
2681
2684
|
responseFormat: LanguageModelV2CallOptions['responseFormat'];
|
2682
2685
|
parsePartial(options: {
|
@@ -2692,16 +2695,17 @@ interface Output$1<OUTPUT, PARTIAL> {
|
|
2692
2695
|
finishReason: FinishReason;
|
2693
2696
|
}): Promise<OUTPUT>;
|
2694
2697
|
}
|
2695
|
-
declare const text: () => Output
|
2698
|
+
declare const text: () => Output<string, string>;
|
2696
2699
|
declare const object: <OUTPUT>({ schema: inputSchema, }: {
|
2697
|
-
schema:
|
2698
|
-
}) => Output
|
2700
|
+
schema: z4.$ZodType<OUTPUT, any> | z3.Schema<OUTPUT, z3.ZodTypeDef, any> | Schema<OUTPUT>;
|
2701
|
+
}) => Output<OUTPUT, DeepPartial<OUTPUT>>;
|
2699
2702
|
|
2703
|
+
type output_Output<OUTPUT, PARTIAL> = Output<OUTPUT, PARTIAL>;
|
2700
2704
|
declare const output_object: typeof object;
|
2701
2705
|
declare const output_text: typeof text;
|
2702
2706
|
declare namespace output {
|
2703
2707
|
export {
|
2704
|
-
|
2708
|
+
output_Output as Output,
|
2705
2709
|
output_object as object,
|
2706
2710
|
output_text as text,
|
2707
2711
|
};
|
@@ -2830,7 +2834,7 @@ changing the tool call and result types in the result.
|
|
2830
2834
|
/**
|
2831
2835
|
Optional specification for parsing structured outputs from the LLM response.
|
2832
2836
|
*/
|
2833
|
-
experimental_output?: Output
|
2837
|
+
experimental_output?: Output<OUTPUT, OUTPUT_PARTIAL>;
|
2834
2838
|
/**
|
2835
2839
|
* @deprecated Use `prepareStep` instead.
|
2836
2840
|
*/
|
@@ -3318,7 +3322,7 @@ functionality that can be fully encapsulated in the provider.
|
|
3318
3322
|
/**
|
3319
3323
|
Optional specification for parsing structured outputs from the LLM response.
|
3320
3324
|
*/
|
3321
|
-
experimental_output?: Output
|
3325
|
+
experimental_output?: Output<OUTPUT, PARTIAL_OUTPUT>;
|
3322
3326
|
/**
|
3323
3327
|
Optional function that you can use to provide different settings for a step.
|
3324
3328
|
|
@@ -3607,14 +3611,14 @@ functionality that can be fully encapsulated in the provider.
|
|
3607
3611
|
@returns
|
3608
3612
|
A result object that contains the generated object, the finish reason, the token usage, and additional information.
|
3609
3613
|
*/
|
3610
|
-
declare function generateObject<
|
3614
|
+
declare function generateObject<SCHEMA extends z3.Schema | z4.$ZodType | Schema = z4.$ZodType<JSONValue$1>, OUTPUT extends 'object' | 'array' | 'enum' | 'no-schema' = InferSchema<SCHEMA> extends string ? 'enum' : 'object', RESULT = OUTPUT extends 'array' ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(options: Omit<CallSettings, 'stopSequences'> & Prompt & (OUTPUT extends 'enum' ? {
|
3611
3615
|
/**
|
3612
3616
|
The enum values that the model should use.
|
3613
3617
|
*/
|
3614
3618
|
enum: Array<RESULT>;
|
3615
3619
|
mode?: 'json';
|
3616
3620
|
output: 'enum';
|
3617
|
-
} :
|
3621
|
+
} : OUTPUT extends 'no-schema' ? {} : {
|
3618
3622
|
/**
|
3619
3623
|
The schema of the object that the model should generate.
|
3620
3624
|
*/
|
@@ -3646,7 +3650,7 @@ Default and recommended: 'auto' (best mode for the model).
|
|
3646
3650
|
*/
|
3647
3651
|
mode?: 'auto' | 'json' | 'tool';
|
3648
3652
|
}) & {
|
3649
|
-
output?:
|
3653
|
+
output?: OUTPUT;
|
3650
3654
|
/**
|
3651
3655
|
The language model to use.
|
3652
3656
|
*/
|
@@ -3915,14 +3919,14 @@ functionality that can be fully encapsulated in the provider.
|
|
3915
3919
|
@returns
|
3916
3920
|
A result object for accessing the partial object stream and additional information.
|
3917
3921
|
*/
|
3918
|
-
declare function streamObject<
|
3922
|
+
declare function streamObject<SCHEMA extends z3.Schema | z4.$ZodType | Schema = z4.$ZodType<JSONValue$1>, OUTPUT extends 'object' | 'array' | 'enum' | 'no-schema' = InferSchema<SCHEMA> extends string ? 'enum' : 'object', RESULT = OUTPUT extends 'array' ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(options: Omit<CallSettings, 'stopSequences'> & Prompt & (OUTPUT extends 'enum' ? {
|
3919
3923
|
/**
|
3920
3924
|
The enum values that the model should use.
|
3921
3925
|
*/
|
3922
3926
|
enum: Array<RESULT>;
|
3923
3927
|
mode?: 'json';
|
3924
3928
|
output: 'enum';
|
3925
|
-
} :
|
3929
|
+
} : OUTPUT extends 'no-schema' ? {} : {
|
3926
3930
|
/**
|
3927
3931
|
The schema of the object that the model should generate.
|
3928
3932
|
*/
|
@@ -3954,7 +3958,7 @@ Default and recommended: 'auto' (best mode for the model).
|
|
3954
3958
|
*/
|
3955
3959
|
mode?: 'auto' | 'json' | 'tool';
|
3956
3960
|
}) & {
|
3957
|
-
output?:
|
3961
|
+
output?: OUTPUT;
|
3958
3962
|
/**
|
3959
3963
|
The language model to use.
|
3960
3964
|
*/
|
@@ -3987,7 +3991,7 @@ Callback that is called when the LLM response and the final object validation ar
|
|
3987
3991
|
currentDate?: () => Date;
|
3988
3992
|
now?: () => number;
|
3989
3993
|
};
|
3990
|
-
}): StreamObjectResult<
|
3994
|
+
}): StreamObjectResult<OUTPUT extends 'enum' ? string : OUTPUT extends 'array' ? RESULT : DeepPartial<RESULT>, OUTPUT extends 'array' ? RESULT : RESULT, OUTPUT extends 'array' ? RESULT extends Array<infer U> ? AsyncIterableStream<U> : never : never>;
|
3991
3995
|
|
3992
3996
|
/**
|
3993
3997
|
* A generated audio file.
|
@@ -4659,7 +4663,7 @@ declare class ChatStore<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS extends
|
|
4659
4663
|
chatId: string;
|
4660
4664
|
}): Promise<void>;
|
4661
4665
|
private emit;
|
4662
|
-
private
|
4666
|
+
private getChat;
|
4663
4667
|
private triggerRequest;
|
4664
4668
|
}
|
4665
4669
|
|
@@ -4942,4 +4946,4 @@ type UseCompletionOptions = {
|
|
4942
4946
|
fetch?: FetchFunction;
|
4943
4947
|
};
|
4944
4948
|
|
4945
|
-
export { ActiveResponse, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, Chat, ChatRequestOptions, ChatStatus, ChatStore, ChatStoreEvent, ChatStoreFactory, ChatStoreOptions, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, DefaultChatStoreOptions, DefaultChatTransport, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FilePart, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, ImagePart, InferUIDataParts, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolArgumentsError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, ModelMessage, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderOptions, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, SystemModelMessage, TelemetrySettings, TextPart, TextStreamChatTransport, TextStreamPart, TextUIPart, Tool, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolExecutionOptions, ToolInvocation, ToolInvocationUIPart, ToolModelMessage, ToolResultPart, ToolResultUnion, ToolSet, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessagePart, UIMessageStreamOptions, UIMessageStreamPart, UIMessageStreamWriter, UseChatOptions, UseCompletionOptions, UserContent, UserModelMessage, assistantModelMessageSchema, callCompletionApi, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultChatStoreOptions, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolInvocations, hasToolCall, isDeepEqualData, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, tool, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel };
|
4949
|
+
export { ActiveResponse, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, Chat, ChatRequestOptions, ChatStatus, ChatStore, ChatStoreEvent, ChatStoreFactory, ChatStoreOptions, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, DefaultChatStoreOptions, DefaultChatTransport, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FilePart, FileUIPart, FinishReason, GLOBAL_DEFAULT_PROVIDER, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, ImagePart, InferUIDataParts, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolArgumentsError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, ModelMessage, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderOptions, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, SystemModelMessage, TelemetrySettings, TextPart, TextStreamChatTransport, TextStreamPart, TextUIPart, Tool, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolExecutionOptions, ToolInvocation, ToolInvocationUIPart, ToolModelMessage, ToolResultPart, ToolResultUnion, ToolSet, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessagePart, UIMessageStreamOptions, UIMessageStreamPart, UIMessageStreamWriter, UseChatOptions, UseCompletionOptions, UserContent, UserModelMessage, assistantModelMessageSchema, callCompletionApi, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultChatStoreOptions, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolInvocations, hasToolCall, isDeepEqualData, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, tool, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel };
|
package/dist/index.d.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
import { ToolResultContent, Schema, ToolCall, ToolResult, IdGenerator, Validator, StandardSchemaV1, FetchFunction } from '@ai-sdk/provider-utils';
|
1
|
+
import { ToolResultContent, Schema, ToolCall, ToolResult, IdGenerator, InferSchema, Validator, StandardSchemaV1, FetchFunction } from '@ai-sdk/provider-utils';
|
2
2
|
export { IdGenerator, Schema, ToolCall, ToolResult, asSchema, createIdGenerator, generateId, jsonSchema } from '@ai-sdk/provider-utils';
|
3
3
|
import { AISDKError, SharedV2ProviderMetadata, SharedV2ProviderOptions, EmbeddingModelV2, EmbeddingModelV2Embedding, ImageModelV2, ImageModelV2CallWarning, ImageModelV2ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2CallWarning, LanguageModelV2Source, SpeechModelV1, SpeechModelV1CallWarning, TranscriptionModelV1, TranscriptionModelV1CallWarning, LanguageModelV2Usage, JSONObject, LanguageModelV2ToolCall, JSONSchema7, LanguageModelV2CallOptions, JSONParseError, TypeValidationError, LanguageModelV2Middleware, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
4
4
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
5
|
-
import
|
5
|
+
import * as z3 from 'zod/v3';
|
6
|
+
import * as z4 from 'zod/v4/core';
|
6
7
|
import { z } from 'zod';
|
7
8
|
import { ServerResponse } from 'node:http';
|
8
9
|
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
@@ -383,7 +384,7 @@ type JSONValue = JSONValue$1;
|
|
383
384
|
/**
|
384
385
|
Language model that is used by the AI SDK Core functions.
|
385
386
|
*/
|
386
|
-
type LanguageModel =
|
387
|
+
type LanguageModel = string | LanguageModelV2;
|
387
388
|
/**
|
388
389
|
Reason why a language model finished generating a response.
|
389
390
|
|
@@ -879,7 +880,7 @@ type MCPTransportConfig = {
|
|
879
880
|
headers?: Record<string, string>;
|
880
881
|
};
|
881
882
|
|
882
|
-
type ToolParameters<T = JSONObject> =
|
883
|
+
type ToolParameters<T = JSONObject> = z4.$ZodType<T> | z3.Schema<T> | Schema<T>;
|
883
884
|
interface ToolExecutionOptions {
|
884
885
|
/**
|
885
886
|
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
@@ -961,7 +962,7 @@ type ToolSchemas = Record<string, {
|
|
961
962
|
parameters: ToolParameters<JSONObject | unknown>;
|
962
963
|
}> | 'automatic' | undefined;
|
963
964
|
type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS extends Record<string, {
|
964
|
-
parameters: ToolParameters<
|
965
|
+
parameters: ToolParameters<unknown>;
|
965
966
|
}> ? {
|
966
967
|
[K in keyof TOOL_SCHEMAS]: MappedTool<TOOL_SCHEMAS[K], CallToolResult> & Required<Pick<MappedTool<TOOL_SCHEMAS[K], CallToolResult>, 'execute'>>;
|
967
968
|
} : McpToolSet<Record<string, {
|
@@ -1901,6 +1902,8 @@ type Prompt = {
|
|
1901
1902
|
messages?: Array<ModelMessage>;
|
1902
1903
|
};
|
1903
1904
|
|
1905
|
+
declare const GLOBAL_DEFAULT_PROVIDER: unique symbol;
|
1906
|
+
|
1904
1907
|
/**
|
1905
1908
|
* A function that attempts to repair a tool call that failed to parse.
|
1906
1909
|
*
|
@@ -2666,7 +2669,7 @@ It always recurses into arrays.
|
|
2666
2669
|
|
2667
2670
|
Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
|
2668
2671
|
*/
|
2669
|
-
type DeepPartial<T> = T extends
|
2672
|
+
type DeepPartial<T> = T extends z3.ZodTypeAny ? DeepPartialInternal<z3.infer<T>> : T extends z4.$ZodType ? DeepPartialInternal<z4.infer<T>> : DeepPartialInternal<T>;
|
2670
2673
|
type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
|
2671
2674
|
type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
2672
2675
|
type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
|
@@ -2676,7 +2679,7 @@ type PartialObject<ObjectType extends object> = {
|
|
2676
2679
|
[KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
|
2677
2680
|
};
|
2678
2681
|
|
2679
|
-
interface Output
|
2682
|
+
interface Output<OUTPUT, PARTIAL> {
|
2680
2683
|
readonly type: 'object' | 'text';
|
2681
2684
|
responseFormat: LanguageModelV2CallOptions['responseFormat'];
|
2682
2685
|
parsePartial(options: {
|
@@ -2692,16 +2695,17 @@ interface Output$1<OUTPUT, PARTIAL> {
|
|
2692
2695
|
finishReason: FinishReason;
|
2693
2696
|
}): Promise<OUTPUT>;
|
2694
2697
|
}
|
2695
|
-
declare const text: () => Output
|
2698
|
+
declare const text: () => Output<string, string>;
|
2696
2699
|
declare const object: <OUTPUT>({ schema: inputSchema, }: {
|
2697
|
-
schema:
|
2698
|
-
}) => Output
|
2700
|
+
schema: z4.$ZodType<OUTPUT, any> | z3.Schema<OUTPUT, z3.ZodTypeDef, any> | Schema<OUTPUT>;
|
2701
|
+
}) => Output<OUTPUT, DeepPartial<OUTPUT>>;
|
2699
2702
|
|
2703
|
+
type output_Output<OUTPUT, PARTIAL> = Output<OUTPUT, PARTIAL>;
|
2700
2704
|
declare const output_object: typeof object;
|
2701
2705
|
declare const output_text: typeof text;
|
2702
2706
|
declare namespace output {
|
2703
2707
|
export {
|
2704
|
-
|
2708
|
+
output_Output as Output,
|
2705
2709
|
output_object as object,
|
2706
2710
|
output_text as text,
|
2707
2711
|
};
|
@@ -2830,7 +2834,7 @@ changing the tool call and result types in the result.
|
|
2830
2834
|
/**
|
2831
2835
|
Optional specification for parsing structured outputs from the LLM response.
|
2832
2836
|
*/
|
2833
|
-
experimental_output?: Output
|
2837
|
+
experimental_output?: Output<OUTPUT, OUTPUT_PARTIAL>;
|
2834
2838
|
/**
|
2835
2839
|
* @deprecated Use `prepareStep` instead.
|
2836
2840
|
*/
|
@@ -3318,7 +3322,7 @@ functionality that can be fully encapsulated in the provider.
|
|
3318
3322
|
/**
|
3319
3323
|
Optional specification for parsing structured outputs from the LLM response.
|
3320
3324
|
*/
|
3321
|
-
experimental_output?: Output
|
3325
|
+
experimental_output?: Output<OUTPUT, PARTIAL_OUTPUT>;
|
3322
3326
|
/**
|
3323
3327
|
Optional function that you can use to provide different settings for a step.
|
3324
3328
|
|
@@ -3607,14 +3611,14 @@ functionality that can be fully encapsulated in the provider.
|
|
3607
3611
|
@returns
|
3608
3612
|
A result object that contains the generated object, the finish reason, the token usage, and additional information.
|
3609
3613
|
*/
|
3610
|
-
declare function generateObject<
|
3614
|
+
declare function generateObject<SCHEMA extends z3.Schema | z4.$ZodType | Schema = z4.$ZodType<JSONValue$1>, OUTPUT extends 'object' | 'array' | 'enum' | 'no-schema' = InferSchema<SCHEMA> extends string ? 'enum' : 'object', RESULT = OUTPUT extends 'array' ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(options: Omit<CallSettings, 'stopSequences'> & Prompt & (OUTPUT extends 'enum' ? {
|
3611
3615
|
/**
|
3612
3616
|
The enum values that the model should use.
|
3613
3617
|
*/
|
3614
3618
|
enum: Array<RESULT>;
|
3615
3619
|
mode?: 'json';
|
3616
3620
|
output: 'enum';
|
3617
|
-
} :
|
3621
|
+
} : OUTPUT extends 'no-schema' ? {} : {
|
3618
3622
|
/**
|
3619
3623
|
The schema of the object that the model should generate.
|
3620
3624
|
*/
|
@@ -3646,7 +3650,7 @@ Default and recommended: 'auto' (best mode for the model).
|
|
3646
3650
|
*/
|
3647
3651
|
mode?: 'auto' | 'json' | 'tool';
|
3648
3652
|
}) & {
|
3649
|
-
output?:
|
3653
|
+
output?: OUTPUT;
|
3650
3654
|
/**
|
3651
3655
|
The language model to use.
|
3652
3656
|
*/
|
@@ -3915,14 +3919,14 @@ functionality that can be fully encapsulated in the provider.
|
|
3915
3919
|
@returns
|
3916
3920
|
A result object for accessing the partial object stream and additional information.
|
3917
3921
|
*/
|
3918
|
-
declare function streamObject<
|
3922
|
+
declare function streamObject<SCHEMA extends z3.Schema | z4.$ZodType | Schema = z4.$ZodType<JSONValue$1>, OUTPUT extends 'object' | 'array' | 'enum' | 'no-schema' = InferSchema<SCHEMA> extends string ? 'enum' : 'object', RESULT = OUTPUT extends 'array' ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(options: Omit<CallSettings, 'stopSequences'> & Prompt & (OUTPUT extends 'enum' ? {
|
3919
3923
|
/**
|
3920
3924
|
The enum values that the model should use.
|
3921
3925
|
*/
|
3922
3926
|
enum: Array<RESULT>;
|
3923
3927
|
mode?: 'json';
|
3924
3928
|
output: 'enum';
|
3925
|
-
} :
|
3929
|
+
} : OUTPUT extends 'no-schema' ? {} : {
|
3926
3930
|
/**
|
3927
3931
|
The schema of the object that the model should generate.
|
3928
3932
|
*/
|
@@ -3954,7 +3958,7 @@ Default and recommended: 'auto' (best mode for the model).
|
|
3954
3958
|
*/
|
3955
3959
|
mode?: 'auto' | 'json' | 'tool';
|
3956
3960
|
}) & {
|
3957
|
-
output?:
|
3961
|
+
output?: OUTPUT;
|
3958
3962
|
/**
|
3959
3963
|
The language model to use.
|
3960
3964
|
*/
|
@@ -3987,7 +3991,7 @@ Callback that is called when the LLM response and the final object validation ar
|
|
3987
3991
|
currentDate?: () => Date;
|
3988
3992
|
now?: () => number;
|
3989
3993
|
};
|
3990
|
-
}): StreamObjectResult<
|
3994
|
+
}): StreamObjectResult<OUTPUT extends 'enum' ? string : OUTPUT extends 'array' ? RESULT : DeepPartial<RESULT>, OUTPUT extends 'array' ? RESULT : RESULT, OUTPUT extends 'array' ? RESULT extends Array<infer U> ? AsyncIterableStream<U> : never : never>;
|
3991
3995
|
|
3992
3996
|
/**
|
3993
3997
|
* A generated audio file.
|
@@ -4659,7 +4663,7 @@ declare class ChatStore<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS extends
|
|
4659
4663
|
chatId: string;
|
4660
4664
|
}): Promise<void>;
|
4661
4665
|
private emit;
|
4662
|
-
private
|
4666
|
+
private getChat;
|
4663
4667
|
private triggerRequest;
|
4664
4668
|
}
|
4665
4669
|
|
@@ -4942,4 +4946,4 @@ type UseCompletionOptions = {
|
|
4942
4946
|
fetch?: FetchFunction;
|
4943
4947
|
};
|
4944
4948
|
|
4945
|
-
export { ActiveResponse, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, Chat, ChatRequestOptions, ChatStatus, ChatStore, ChatStoreEvent, ChatStoreFactory, ChatStoreOptions, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, DefaultChatStoreOptions, DefaultChatTransport, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FilePart, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, ImagePart, InferUIDataParts, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolArgumentsError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, ModelMessage, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderOptions, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, SystemModelMessage, TelemetrySettings, TextPart, TextStreamChatTransport, TextStreamPart, TextUIPart, Tool, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolExecutionOptions, ToolInvocation, ToolInvocationUIPart, ToolModelMessage, ToolResultPart, ToolResultUnion, ToolSet, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessagePart, UIMessageStreamOptions, UIMessageStreamPart, UIMessageStreamWriter, UseChatOptions, UseCompletionOptions, UserContent, UserModelMessage, assistantModelMessageSchema, callCompletionApi, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultChatStoreOptions, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolInvocations, hasToolCall, isDeepEqualData, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, tool, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel };
|
4949
|
+
export { ActiveResponse, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, Chat, ChatRequestOptions, ChatStatus, ChatStore, ChatStoreEvent, ChatStoreFactory, ChatStoreOptions, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, DefaultChatStoreOptions, DefaultChatTransport, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FilePart, FileUIPart, FinishReason, GLOBAL_DEFAULT_PROVIDER, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, ImagePart, InferUIDataParts, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolArgumentsError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, ModelMessage, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderOptions, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, SystemModelMessage, TelemetrySettings, TextPart, TextStreamChatTransport, TextStreamPart, TextUIPart, Tool, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolExecutionOptions, ToolInvocation, ToolInvocationUIPart, ToolModelMessage, ToolResultPart, ToolResultUnion, ToolSet, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessagePart, UIMessageStreamOptions, UIMessageStreamPart, UIMessageStreamWriter, UseChatOptions, UseCompletionOptions, UserContent, UserModelMessage, assistantModelMessageSchema, callCompletionApi, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultChatStoreOptions, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolInvocations, hasToolCall, isDeepEqualData, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, tool, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel };
|