ai 5.0.0-alpha.10 → 5.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/index.d.mts +44 -7
- package/dist/index.d.ts +44 -7
- package/dist/index.js +69 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -2
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +22 -3
- package/dist/internal/index.d.ts +22 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 5.0.0-alpha.11
|
4
|
+
|
5
|
+
### Major Changes
|
6
|
+
|
7
|
+
- e8324c5: feat (ai): add args callbacks to tools
|
8
|
+
|
9
|
+
### Patch Changes
|
10
|
+
|
11
|
+
- Updated dependencies [c1e6647]
|
12
|
+
- @ai-sdk/provider@2.0.0-alpha.11
|
13
|
+
- @ai-sdk/gateway@1.0.0-alpha.11
|
14
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.11
|
15
|
+
|
3
16
|
## 5.0.0-alpha.10
|
4
17
|
|
5
18
|
### Major Changes
|
package/dist/index.d.mts
CHANGED
@@ -881,7 +881,7 @@ type MCPTransportConfig = {
|
|
881
881
|
};
|
882
882
|
|
883
883
|
type ToolParameters<T = JSONObject> = z4.$ZodType<T> | z3.Schema<T> | Schema<T>;
|
884
|
-
interface
|
884
|
+
interface ToolCallOptions {
|
885
885
|
/**
|
886
886
|
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
887
887
|
*/
|
@@ -925,11 +925,30 @@ If not provided, the tool will not be executed automatically.
|
|
925
925
|
@args is the input of the tool call.
|
926
926
|
@options.abortSignal is a signal that can be used to abort the tool call.
|
927
927
|
*/
|
928
|
-
execute: (args: [PARAMETERS] extends [never] ? undefined : PARAMETERS, options:
|
928
|
+
execute: (args: [PARAMETERS] extends [never] ? undefined : PARAMETERS, options: ToolCallOptions) => PromiseLike<RESULT>;
|
929
929
|
/**
|
930
930
|
Optional conversion function that maps the tool result to multi-part tool content for LLMs.
|
931
931
|
*/
|
932
932
|
experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
|
933
|
+
/**
|
934
|
+
* Optional function that is called when the argument streaming starts.
|
935
|
+
* Only called when the tool is used in a streaming context.
|
936
|
+
*/
|
937
|
+
onArgsStreamingStart?: (options: ToolCallOptions) => void | PromiseLike<void>;
|
938
|
+
/**
|
939
|
+
* Optional function that is called when an argument streaming delta is available.
|
940
|
+
* Only called when the tool is used in a streaming context.
|
941
|
+
*/
|
942
|
+
onArgsStreamingDelta?: (options: {
|
943
|
+
argsTextDelta: string;
|
944
|
+
} & ToolCallOptions) => void | PromiseLike<void>;
|
945
|
+
/**
|
946
|
+
* Optional function that is called when a tool call can be started,
|
947
|
+
* even if the execute function is not provided.
|
948
|
+
*/
|
949
|
+
onArgsAvailable?: (options: {
|
950
|
+
args: [PARAMETERS] extends [never] ? undefined : PARAMETERS;
|
951
|
+
} & ToolCallOptions) => void | PromiseLike<void>;
|
933
952
|
}> & ({
|
934
953
|
/**
|
935
954
|
Function tool.
|
@@ -952,10 +971,10 @@ The arguments for configuring the tool. Must match the expected arguments define
|
|
952
971
|
/**
|
953
972
|
Helper function for inferring the execute args of a tool.
|
954
973
|
*/
|
955
|
-
declare function tool(tool: Tool<
|
974
|
+
declare function tool<PARAMETERS, RESULT>(tool: Tool<PARAMETERS, RESULT>): Tool<PARAMETERS, RESULT>;
|
956
975
|
declare function tool<PARAMETERS>(tool: Tool<PARAMETERS, never>): Tool<PARAMETERS, never>;
|
957
976
|
declare function tool<RESULT>(tool: Tool<never, RESULT>): Tool<never, RESULT>;
|
958
|
-
declare function tool
|
977
|
+
declare function tool(tool: Tool<never, never>): Tool<never, never>;
|
959
978
|
type MappedTool<T extends Tool | JSONObject, RESULT extends any> = T extends Tool<infer P> ? Tool<P, RESULT> : T extends JSONObject ? Tool<T, RESULT> : never;
|
960
979
|
|
961
980
|
type ToolSchemas = Record<string, {
|
@@ -1736,7 +1755,7 @@ declare class MCPClient {
|
|
1736
1755
|
private onResponse;
|
1737
1756
|
}
|
1738
1757
|
|
1739
|
-
type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute'>>;
|
1758
|
+
type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onArgsAvailable' | 'onArgsStreamingStart' | 'onArgsStreamingDelta'>>;
|
1740
1759
|
|
1741
1760
|
type ToolCallUnion<TOOLS extends ToolSet> = ValueOf<{
|
1742
1761
|
[NAME in keyof TOOLS]: {
|
@@ -2155,7 +2174,7 @@ interface UIMessage<METADATA = unknown, DATA_PARTS extends UIDataTypes = UIDataT
|
|
2155
2174
|
*/
|
2156
2175
|
parts: Array<UIMessagePart<DATA_PARTS>>;
|
2157
2176
|
}
|
2158
|
-
type UIMessagePart<DATA_TYPES extends UIDataTypes> = TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUrlUIPart | FileUIPart | DataUIPart<DATA_TYPES> | StepStartUIPart;
|
2177
|
+
type UIMessagePart<DATA_TYPES extends UIDataTypes> = TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUrlUIPart | SourceDocumentUIPart | FileUIPart | DataUIPart<DATA_TYPES> | StepStartUIPart;
|
2159
2178
|
type DataUIPart<DATA_TYPES extends UIDataTypes> = ValueOf<{
|
2160
2179
|
[NAME in keyof DATA_TYPES & string]: {
|
2161
2180
|
type: `data-${NAME}`;
|
@@ -2211,6 +2230,17 @@ type SourceUrlUIPart = {
|
|
2211
2230
|
title?: string;
|
2212
2231
|
providerMetadata?: Record<string, any>;
|
2213
2232
|
};
|
2233
|
+
/**
|
2234
|
+
* A document source part of a message.
|
2235
|
+
*/
|
2236
|
+
type SourceDocumentUIPart = {
|
2237
|
+
type: 'source-document';
|
2238
|
+
sourceId: string;
|
2239
|
+
mediaType: string;
|
2240
|
+
title: string;
|
2241
|
+
filename?: string;
|
2242
|
+
providerMetadata?: Record<string, any>;
|
2243
|
+
};
|
2214
2244
|
/**
|
2215
2245
|
* A file part of a message.
|
2216
2246
|
*/
|
@@ -4369,6 +4399,13 @@ type UIMessageStreamPart = {
|
|
4369
4399
|
url: string;
|
4370
4400
|
title?: string;
|
4371
4401
|
providerMetadata?: ProviderMetadata;
|
4402
|
+
} | {
|
4403
|
+
type: 'source-document';
|
4404
|
+
sourceId: string;
|
4405
|
+
mediaType: string;
|
4406
|
+
title: string;
|
4407
|
+
filename?: string;
|
4408
|
+
providerMetadata?: ProviderMetadata;
|
4372
4409
|
} | {
|
4373
4410
|
type: 'file';
|
4374
4411
|
url: string;
|
@@ -4802,4 +4839,4 @@ type UseCompletionOptions = {
|
|
4802
4839
|
fetch?: FetchFunction;
|
4803
4840
|
};
|
4804
4841
|
|
4805
|
-
export { AbstractChat, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, ChatEvent, ChatInit, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, 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,
|
4842
|
+
export { AbstractChat, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, ChatEvent, ChatInit, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, 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, ToolCallOptions, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolInvocation, ToolInvocationUIPart, ToolModelMessage, ToolResultPart, ToolResultUnion, ToolSet, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessagePart, UIMessageStreamOptions, UIMessageStreamPart, UIMessageStreamWriter, UseCompletionOptions, UserContent, UserModelMessage, assistantModelMessageSchema, callCompletionApi, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, 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
@@ -881,7 +881,7 @@ type MCPTransportConfig = {
|
|
881
881
|
};
|
882
882
|
|
883
883
|
type ToolParameters<T = JSONObject> = z4.$ZodType<T> | z3.Schema<T> | Schema<T>;
|
884
|
-
interface
|
884
|
+
interface ToolCallOptions {
|
885
885
|
/**
|
886
886
|
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
887
887
|
*/
|
@@ -925,11 +925,30 @@ If not provided, the tool will not be executed automatically.
|
|
925
925
|
@args is the input of the tool call.
|
926
926
|
@options.abortSignal is a signal that can be used to abort the tool call.
|
927
927
|
*/
|
928
|
-
execute: (args: [PARAMETERS] extends [never] ? undefined : PARAMETERS, options:
|
928
|
+
execute: (args: [PARAMETERS] extends [never] ? undefined : PARAMETERS, options: ToolCallOptions) => PromiseLike<RESULT>;
|
929
929
|
/**
|
930
930
|
Optional conversion function that maps the tool result to multi-part tool content for LLMs.
|
931
931
|
*/
|
932
932
|
experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
|
933
|
+
/**
|
934
|
+
* Optional function that is called when the argument streaming starts.
|
935
|
+
* Only called when the tool is used in a streaming context.
|
936
|
+
*/
|
937
|
+
onArgsStreamingStart?: (options: ToolCallOptions) => void | PromiseLike<void>;
|
938
|
+
/**
|
939
|
+
* Optional function that is called when an argument streaming delta is available.
|
940
|
+
* Only called when the tool is used in a streaming context.
|
941
|
+
*/
|
942
|
+
onArgsStreamingDelta?: (options: {
|
943
|
+
argsTextDelta: string;
|
944
|
+
} & ToolCallOptions) => void | PromiseLike<void>;
|
945
|
+
/**
|
946
|
+
* Optional function that is called when a tool call can be started,
|
947
|
+
* even if the execute function is not provided.
|
948
|
+
*/
|
949
|
+
onArgsAvailable?: (options: {
|
950
|
+
args: [PARAMETERS] extends [never] ? undefined : PARAMETERS;
|
951
|
+
} & ToolCallOptions) => void | PromiseLike<void>;
|
933
952
|
}> & ({
|
934
953
|
/**
|
935
954
|
Function tool.
|
@@ -952,10 +971,10 @@ The arguments for configuring the tool. Must match the expected arguments define
|
|
952
971
|
/**
|
953
972
|
Helper function for inferring the execute args of a tool.
|
954
973
|
*/
|
955
|
-
declare function tool(tool: Tool<
|
974
|
+
declare function tool<PARAMETERS, RESULT>(tool: Tool<PARAMETERS, RESULT>): Tool<PARAMETERS, RESULT>;
|
956
975
|
declare function tool<PARAMETERS>(tool: Tool<PARAMETERS, never>): Tool<PARAMETERS, never>;
|
957
976
|
declare function tool<RESULT>(tool: Tool<never, RESULT>): Tool<never, RESULT>;
|
958
|
-
declare function tool
|
977
|
+
declare function tool(tool: Tool<never, never>): Tool<never, never>;
|
959
978
|
type MappedTool<T extends Tool | JSONObject, RESULT extends any> = T extends Tool<infer P> ? Tool<P, RESULT> : T extends JSONObject ? Tool<T, RESULT> : never;
|
960
979
|
|
961
980
|
type ToolSchemas = Record<string, {
|
@@ -1736,7 +1755,7 @@ declare class MCPClient {
|
|
1736
1755
|
private onResponse;
|
1737
1756
|
}
|
1738
1757
|
|
1739
|
-
type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute'>>;
|
1758
|
+
type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onArgsAvailable' | 'onArgsStreamingStart' | 'onArgsStreamingDelta'>>;
|
1740
1759
|
|
1741
1760
|
type ToolCallUnion<TOOLS extends ToolSet> = ValueOf<{
|
1742
1761
|
[NAME in keyof TOOLS]: {
|
@@ -2155,7 +2174,7 @@ interface UIMessage<METADATA = unknown, DATA_PARTS extends UIDataTypes = UIDataT
|
|
2155
2174
|
*/
|
2156
2175
|
parts: Array<UIMessagePart<DATA_PARTS>>;
|
2157
2176
|
}
|
2158
|
-
type UIMessagePart<DATA_TYPES extends UIDataTypes> = TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUrlUIPart | FileUIPart | DataUIPart<DATA_TYPES> | StepStartUIPart;
|
2177
|
+
type UIMessagePart<DATA_TYPES extends UIDataTypes> = TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUrlUIPart | SourceDocumentUIPart | FileUIPart | DataUIPart<DATA_TYPES> | StepStartUIPart;
|
2159
2178
|
type DataUIPart<DATA_TYPES extends UIDataTypes> = ValueOf<{
|
2160
2179
|
[NAME in keyof DATA_TYPES & string]: {
|
2161
2180
|
type: `data-${NAME}`;
|
@@ -2211,6 +2230,17 @@ type SourceUrlUIPart = {
|
|
2211
2230
|
title?: string;
|
2212
2231
|
providerMetadata?: Record<string, any>;
|
2213
2232
|
};
|
2233
|
+
/**
|
2234
|
+
* A document source part of a message.
|
2235
|
+
*/
|
2236
|
+
type SourceDocumentUIPart = {
|
2237
|
+
type: 'source-document';
|
2238
|
+
sourceId: string;
|
2239
|
+
mediaType: string;
|
2240
|
+
title: string;
|
2241
|
+
filename?: string;
|
2242
|
+
providerMetadata?: Record<string, any>;
|
2243
|
+
};
|
2214
2244
|
/**
|
2215
2245
|
* A file part of a message.
|
2216
2246
|
*/
|
@@ -4369,6 +4399,13 @@ type UIMessageStreamPart = {
|
|
4369
4399
|
url: string;
|
4370
4400
|
title?: string;
|
4371
4401
|
providerMetadata?: ProviderMetadata;
|
4402
|
+
} | {
|
4403
|
+
type: 'source-document';
|
4404
|
+
sourceId: string;
|
4405
|
+
mediaType: string;
|
4406
|
+
title: string;
|
4407
|
+
filename?: string;
|
4408
|
+
providerMetadata?: ProviderMetadata;
|
4372
4409
|
} | {
|
4373
4410
|
type: 'file';
|
4374
4411
|
url: string;
|
@@ -4802,4 +4839,4 @@ type UseCompletionOptions = {
|
|
4802
4839
|
fetch?: FetchFunction;
|
4803
4840
|
};
|
4804
4841
|
|
4805
|
-
export { AbstractChat, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, ChatEvent, ChatInit, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, 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,
|
4842
|
+
export { AbstractChat, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, ChatEvent, ChatInit, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, 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, ToolCallOptions, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolInvocation, ToolInvocationUIPart, ToolModelMessage, ToolResultPart, ToolResultUnion, ToolSet, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessagePart, UIMessageStreamOptions, UIMessageStreamPart, UIMessageStreamWriter, UseCompletionOptions, UserContent, UserModelMessage, assistantModelMessageSchema, callCompletionApi, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, 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.js
CHANGED
@@ -583,6 +583,15 @@ var uiMessageStreamPartSchema = import_zod.z.union([
|
|
583
583
|
providerMetadata: import_zod.z.any().optional()
|
584
584
|
// Use z.any() for generic metadata
|
585
585
|
}),
|
586
|
+
import_zod.z.object({
|
587
|
+
type: import_zod.z.literal("source-document"),
|
588
|
+
sourceId: import_zod.z.string(),
|
589
|
+
mediaType: import_zod.z.string(),
|
590
|
+
title: import_zod.z.string(),
|
591
|
+
filename: import_zod.z.string().optional(),
|
592
|
+
providerMetadata: import_zod.z.any().optional()
|
593
|
+
// Use z.any() for generic metadata
|
594
|
+
}),
|
586
595
|
import_zod.z.object({
|
587
596
|
type: import_zod.z.literal("file"),
|
588
597
|
url: import_zod.z.string(),
|
@@ -1293,6 +1302,18 @@ function processUIMessageStream({
|
|
1293
1302
|
write();
|
1294
1303
|
break;
|
1295
1304
|
}
|
1305
|
+
case "source-document": {
|
1306
|
+
state.message.parts.push({
|
1307
|
+
type: "source-document",
|
1308
|
+
sourceId: part.sourceId,
|
1309
|
+
mediaType: part.mediaType,
|
1310
|
+
title: part.title,
|
1311
|
+
filename: part.filename,
|
1312
|
+
providerMetadata: part.providerMetadata
|
1313
|
+
});
|
1314
|
+
write();
|
1315
|
+
break;
|
1316
|
+
}
|
1296
1317
|
case "tool-call-streaming-start": {
|
1297
1318
|
const toolInvocations = getToolInvocations(state.message);
|
1298
1319
|
state.partialToolCalls[part.toolCallId] = {
|
@@ -5957,6 +5978,14 @@ async function executeTools({
|
|
5957
5978
|
const toolResults = await Promise.all(
|
5958
5979
|
toolCalls.map(async ({ toolCallId, toolName, args }) => {
|
5959
5980
|
const tool2 = tools[toolName];
|
5981
|
+
if ((tool2 == null ? void 0 : tool2.onArgsAvailable) != null) {
|
5982
|
+
await tool2.onArgsAvailable({
|
5983
|
+
args,
|
5984
|
+
toolCallId,
|
5985
|
+
messages,
|
5986
|
+
abortSignal
|
5987
|
+
});
|
5988
|
+
}
|
5960
5989
|
if ((tool2 == null ? void 0 : tool2.execute) == null) {
|
5961
5990
|
return void 0;
|
5962
5991
|
}
|
@@ -6341,6 +6370,14 @@ function runToolsTransformation({
|
|
6341
6370
|
});
|
6342
6371
|
controller.enqueue(toolCall);
|
6343
6372
|
const tool2 = tools[toolCall.toolName];
|
6373
|
+
if (tool2.onArgsAvailable != null) {
|
6374
|
+
await tool2.onArgsAvailable({
|
6375
|
+
args: toolCall.args,
|
6376
|
+
toolCallId: toolCall.toolCallId,
|
6377
|
+
messages,
|
6378
|
+
abortSignal
|
6379
|
+
});
|
6380
|
+
}
|
6344
6381
|
if (tool2.execute != null) {
|
6345
6382
|
const toolExecutionId = (0, import_provider_utils21.generateId)();
|
6346
6383
|
outstandingToolResults.add(toolExecutionId);
|
@@ -7031,8 +7068,28 @@ var DefaultStreamTextResult = class {
|
|
7031
7068
|
controller.enqueue(chunk);
|
7032
7069
|
break;
|
7033
7070
|
}
|
7034
|
-
case "tool-call-streaming-start":
|
7071
|
+
case "tool-call-streaming-start": {
|
7072
|
+
const tool2 = tools == null ? void 0 : tools[chunk.toolName];
|
7073
|
+
if ((tool2 == null ? void 0 : tool2.onArgsStreamingStart) != null) {
|
7074
|
+
await tool2.onArgsStreamingStart({
|
7075
|
+
toolCallId: chunk.toolCallId,
|
7076
|
+
messages: stepInputMessages,
|
7077
|
+
abortSignal
|
7078
|
+
});
|
7079
|
+
}
|
7080
|
+
controller.enqueue(chunk);
|
7081
|
+
break;
|
7082
|
+
}
|
7035
7083
|
case "tool-call-delta": {
|
7084
|
+
const tool2 = tools == null ? void 0 : tools[chunk.toolName];
|
7085
|
+
if ((tool2 == null ? void 0 : tool2.onArgsStreamingDelta) != null) {
|
7086
|
+
await tool2.onArgsStreamingDelta({
|
7087
|
+
argsTextDelta: chunk.argsTextDelta,
|
7088
|
+
toolCallId: chunk.toolCallId,
|
7089
|
+
messages: stepInputMessages,
|
7090
|
+
abortSignal
|
7091
|
+
});
|
7092
|
+
}
|
7036
7093
|
controller.enqueue(chunk);
|
7037
7094
|
break;
|
7038
7095
|
}
|
@@ -7312,7 +7369,7 @@ var DefaultStreamTextResult = class {
|
|
7312
7369
|
break;
|
7313
7370
|
}
|
7314
7371
|
case "source": {
|
7315
|
-
if (sendSources) {
|
7372
|
+
if (sendSources && part.sourceType === "url") {
|
7316
7373
|
controller.enqueue({
|
7317
7374
|
type: "source-url",
|
7318
7375
|
sourceId: part.id,
|
@@ -7321,6 +7378,16 @@ var DefaultStreamTextResult = class {
|
|
7321
7378
|
providerMetadata: part.providerMetadata
|
7322
7379
|
});
|
7323
7380
|
}
|
7381
|
+
if (sendSources && part.sourceType === "document") {
|
7382
|
+
controller.enqueue({
|
7383
|
+
type: "source-document",
|
7384
|
+
sourceId: part.id,
|
7385
|
+
mediaType: part.mediaType,
|
7386
|
+
title: part.title,
|
7387
|
+
filename: part.filename,
|
7388
|
+
providerMetadata: part.providerMetadata
|
7389
|
+
});
|
7390
|
+
}
|
7324
7391
|
break;
|
7325
7392
|
}
|
7326
7393
|
case "tool-call-streaming-start": {
|