ai 5.0.0-beta.31 → 5.0.0-beta.32
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 +8 -0
- package/dist/index.d.mts +16 -52
- package/dist/index.d.ts +16 -52
- package/dist/index.js +31 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -26
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.js +24 -24
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs +24 -24
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 5.0.0-beta.32
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- bc24722: feat (ai): Add finishReason as a promise on StreamObjectResult to match StreamTextResult
|
8
|
+
- 13b4f46: feat (ai): export experimental MCPClient and MCPClientConfig interfaces
|
9
|
+
- 56c232b: fix (ai): remove outdated sendStart jsdoc
|
10
|
+
|
3
11
|
## 5.0.0-beta.31
|
4
12
|
|
5
13
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -1662,11 +1662,6 @@ type UIMessageStreamOptions<UI_MESSAGE extends UIMessage> = {
|
|
1662
1662
|
* Set to false if you are using additional streamText calls
|
1663
1663
|
* and the message start event has already been sent.
|
1664
1664
|
* Default to true.
|
1665
|
-
*
|
1666
|
-
* Note: this setting is currently not used, but you should
|
1667
|
-
* already set it to false if you are using additional
|
1668
|
-
* streamText calls that send additional data to prevent
|
1669
|
-
* the message start event from being sent multiple times.
|
1670
1665
|
*/
|
1671
1666
|
sendStart?: boolean;
|
1672
1667
|
/**
|
@@ -2891,6 +2886,12 @@ interface StreamObjectResult<PARTIAL, RESULT, ELEMENT_STREAM> {
|
|
2891
2886
|
*/
|
2892
2887
|
readonly response: Promise<LanguageModelResponseMetadata>;
|
2893
2888
|
/**
|
2889
|
+
The reason why the generation finished. Taken from the last step.
|
2890
|
+
|
2891
|
+
Resolved when the response is finished.
|
2892
|
+
*/
|
2893
|
+
readonly finishReason: Promise<FinishReason>;
|
2894
|
+
/**
|
2894
2895
|
The generated object (typed according to the schema). Resolved when the response is finished.
|
2895
2896
|
*/
|
2896
2897
|
readonly object: Promise<RESULT>;
|
@@ -3515,11 +3516,12 @@ type MCPTransportConfig = {
|
|
3515
3516
|
type ToolSchemas = Record<string, {
|
3516
3517
|
inputSchema: FlexibleSchema<JSONObject | unknown>;
|
3517
3518
|
}> | 'automatic' | undefined;
|
3518
|
-
type MappedTool<T extends Tool | JSONObject, OUTPUT extends any> = T extends Tool<infer INPUT> ? Tool<INPUT, OUTPUT> : T extends JSONObject ? Tool<T, OUTPUT> : never;
|
3519
3519
|
type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS extends Record<string, {
|
3520
|
-
inputSchema: FlexibleSchema<
|
3520
|
+
inputSchema: FlexibleSchema<any>;
|
3521
3521
|
}> ? {
|
3522
|
-
[K in keyof TOOL_SCHEMAS]:
|
3522
|
+
[K in keyof TOOL_SCHEMAS]: TOOL_SCHEMAS[K] extends {
|
3523
|
+
inputSchema: FlexibleSchema<infer INPUT>;
|
3524
|
+
} ? Tool<INPUT, CallToolResult> & Required<Pick<Tool<INPUT, CallToolResult>, 'execute'>> : never;
|
3523
3525
|
} : McpToolSet<Record<string, {
|
3524
3526
|
inputSchema: FlexibleSchema<unknown>;
|
3525
3527
|
}>>;
|
@@ -3530,7 +3532,7 @@ declare const CallToolResultSchema: z.ZodUnion<[z.ZodObject<{
|
|
3530
3532
|
text: z.ZodString;
|
3531
3533
|
}, z.core.$loose>, z.ZodObject<{
|
3532
3534
|
type: z.ZodLiteral<"image">;
|
3533
|
-
data: z.
|
3535
|
+
data: z.ZodBase64;
|
3534
3536
|
mimeType: z.ZodString;
|
3535
3537
|
}, z.core.$loose>, z.ZodObject<{
|
3536
3538
|
type: z.ZodLiteral<"resource">;
|
@@ -3541,7 +3543,7 @@ declare const CallToolResultSchema: z.ZodUnion<[z.ZodObject<{
|
|
3541
3543
|
}, z.core.$loose>, z.ZodObject<{
|
3542
3544
|
uri: z.ZodString;
|
3543
3545
|
mimeType: z.ZodOptional<z.ZodString>;
|
3544
|
-
blob: z.
|
3546
|
+
blob: z.ZodBase64;
|
3545
3547
|
}, z.core.$loose>]>;
|
3546
3548
|
}, z.core.$loose>]>>;
|
3547
3549
|
isError: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
@@ -3560,49 +3562,11 @@ interface MCPClientConfig {
|
|
3560
3562
|
name?: string;
|
3561
3563
|
}
|
3562
3564
|
declare function createMCPClient(config: MCPClientConfig): Promise<MCPClient>;
|
3563
|
-
|
3564
|
-
|
3565
|
-
*
|
3566
|
-
* The primary purpose of this client is tool conversion between MCP<>AI SDK
|
3567
|
-
* but can later be extended to support other MCP features
|
3568
|
-
*
|
3569
|
-
* Tool parameters are automatically inferred from the server's JSON schema
|
3570
|
-
* if not explicitly provided in the tools configuration
|
3571
|
-
*
|
3572
|
-
* This client is meant to be used to communicate with a single server. To communicate and fetch tools across multiple servers, it's recommended to create a new client instance per server.
|
3573
|
-
*
|
3574
|
-
* Not supported:
|
3575
|
-
* - Client options (e.g. sampling, roots) as they are not needed for tool conversion
|
3576
|
-
* - Accepting notifications
|
3577
|
-
* - Session management (when passing a sessionId to an instance of the Streamable HTTP transport)
|
3578
|
-
* - Resumable SSE streams
|
3579
|
-
*/
|
3580
|
-
declare class MCPClient {
|
3581
|
-
private transport;
|
3582
|
-
private onUncaughtError?;
|
3583
|
-
private clientInfo;
|
3584
|
-
private requestMessageId;
|
3585
|
-
private responseHandlers;
|
3586
|
-
private serverCapabilities;
|
3587
|
-
private isClosed;
|
3588
|
-
constructor({ transport: transportConfig, name, onUncaughtError, }: MCPClientConfig);
|
3589
|
-
init(): Promise<this>;
|
3590
|
-
close(): Promise<void>;
|
3591
|
-
private assertCapability;
|
3592
|
-
private request;
|
3593
|
-
private listTools;
|
3594
|
-
private callTool;
|
3595
|
-
private notification;
|
3596
|
-
/**
|
3597
|
-
* Returns a set of AI SDK tools from the MCP server
|
3598
|
-
* @returns A record of tool names to their implementations
|
3599
|
-
*/
|
3600
|
-
tools<TOOL_SCHEMAS extends ToolSchemas = 'automatic'>({ schemas, }?: {
|
3565
|
+
interface MCPClient {
|
3566
|
+
tools<TOOL_SCHEMAS extends ToolSchemas = 'automatic'>(options?: {
|
3601
3567
|
schemas?: TOOL_SCHEMAS;
|
3602
3568
|
}): Promise<McpToolSet<TOOL_SCHEMAS>>;
|
3603
|
-
|
3604
|
-
private onError;
|
3605
|
-
private onResponse;
|
3569
|
+
close: () => Promise<void>;
|
3606
3570
|
}
|
3607
3571
|
|
3608
3572
|
/**
|
@@ -4203,4 +4167,4 @@ declare global {
|
|
4203
4167
|
var AI_SDK_DEFAULT_PROVIDER: ProviderV2 | undefined;
|
4204
4168
|
}
|
4205
4169
|
|
4206
|
-
export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, 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, getToolName, hasToolCall, isDeepEqualData, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel, wrapProvider };
|
4170
|
+
export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, MCPClient as experimental_MCPClient, MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, hasToolCall, isDeepEqualData, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel, wrapProvider };
|
package/dist/index.d.ts
CHANGED
@@ -1662,11 +1662,6 @@ type UIMessageStreamOptions<UI_MESSAGE extends UIMessage> = {
|
|
1662
1662
|
* Set to false if you are using additional streamText calls
|
1663
1663
|
* and the message start event has already been sent.
|
1664
1664
|
* Default to true.
|
1665
|
-
*
|
1666
|
-
* Note: this setting is currently not used, but you should
|
1667
|
-
* already set it to false if you are using additional
|
1668
|
-
* streamText calls that send additional data to prevent
|
1669
|
-
* the message start event from being sent multiple times.
|
1670
1665
|
*/
|
1671
1666
|
sendStart?: boolean;
|
1672
1667
|
/**
|
@@ -2891,6 +2886,12 @@ interface StreamObjectResult<PARTIAL, RESULT, ELEMENT_STREAM> {
|
|
2891
2886
|
*/
|
2892
2887
|
readonly response: Promise<LanguageModelResponseMetadata>;
|
2893
2888
|
/**
|
2889
|
+
The reason why the generation finished. Taken from the last step.
|
2890
|
+
|
2891
|
+
Resolved when the response is finished.
|
2892
|
+
*/
|
2893
|
+
readonly finishReason: Promise<FinishReason>;
|
2894
|
+
/**
|
2894
2895
|
The generated object (typed according to the schema). Resolved when the response is finished.
|
2895
2896
|
*/
|
2896
2897
|
readonly object: Promise<RESULT>;
|
@@ -3515,11 +3516,12 @@ type MCPTransportConfig = {
|
|
3515
3516
|
type ToolSchemas = Record<string, {
|
3516
3517
|
inputSchema: FlexibleSchema<JSONObject | unknown>;
|
3517
3518
|
}> | 'automatic' | undefined;
|
3518
|
-
type MappedTool<T extends Tool | JSONObject, OUTPUT extends any> = T extends Tool<infer INPUT> ? Tool<INPUT, OUTPUT> : T extends JSONObject ? Tool<T, OUTPUT> : never;
|
3519
3519
|
type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS extends Record<string, {
|
3520
|
-
inputSchema: FlexibleSchema<
|
3520
|
+
inputSchema: FlexibleSchema<any>;
|
3521
3521
|
}> ? {
|
3522
|
-
[K in keyof TOOL_SCHEMAS]:
|
3522
|
+
[K in keyof TOOL_SCHEMAS]: TOOL_SCHEMAS[K] extends {
|
3523
|
+
inputSchema: FlexibleSchema<infer INPUT>;
|
3524
|
+
} ? Tool<INPUT, CallToolResult> & Required<Pick<Tool<INPUT, CallToolResult>, 'execute'>> : never;
|
3523
3525
|
} : McpToolSet<Record<string, {
|
3524
3526
|
inputSchema: FlexibleSchema<unknown>;
|
3525
3527
|
}>>;
|
@@ -3530,7 +3532,7 @@ declare const CallToolResultSchema: z.ZodUnion<[z.ZodObject<{
|
|
3530
3532
|
text: z.ZodString;
|
3531
3533
|
}, z.core.$loose>, z.ZodObject<{
|
3532
3534
|
type: z.ZodLiteral<"image">;
|
3533
|
-
data: z.
|
3535
|
+
data: z.ZodBase64;
|
3534
3536
|
mimeType: z.ZodString;
|
3535
3537
|
}, z.core.$loose>, z.ZodObject<{
|
3536
3538
|
type: z.ZodLiteral<"resource">;
|
@@ -3541,7 +3543,7 @@ declare const CallToolResultSchema: z.ZodUnion<[z.ZodObject<{
|
|
3541
3543
|
}, z.core.$loose>, z.ZodObject<{
|
3542
3544
|
uri: z.ZodString;
|
3543
3545
|
mimeType: z.ZodOptional<z.ZodString>;
|
3544
|
-
blob: z.
|
3546
|
+
blob: z.ZodBase64;
|
3545
3547
|
}, z.core.$loose>]>;
|
3546
3548
|
}, z.core.$loose>]>>;
|
3547
3549
|
isError: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
@@ -3560,49 +3562,11 @@ interface MCPClientConfig {
|
|
3560
3562
|
name?: string;
|
3561
3563
|
}
|
3562
3564
|
declare function createMCPClient(config: MCPClientConfig): Promise<MCPClient>;
|
3563
|
-
|
3564
|
-
|
3565
|
-
*
|
3566
|
-
* The primary purpose of this client is tool conversion between MCP<>AI SDK
|
3567
|
-
* but can later be extended to support other MCP features
|
3568
|
-
*
|
3569
|
-
* Tool parameters are automatically inferred from the server's JSON schema
|
3570
|
-
* if not explicitly provided in the tools configuration
|
3571
|
-
*
|
3572
|
-
* This client is meant to be used to communicate with a single server. To communicate and fetch tools across multiple servers, it's recommended to create a new client instance per server.
|
3573
|
-
*
|
3574
|
-
* Not supported:
|
3575
|
-
* - Client options (e.g. sampling, roots) as they are not needed for tool conversion
|
3576
|
-
* - Accepting notifications
|
3577
|
-
* - Session management (when passing a sessionId to an instance of the Streamable HTTP transport)
|
3578
|
-
* - Resumable SSE streams
|
3579
|
-
*/
|
3580
|
-
declare class MCPClient {
|
3581
|
-
private transport;
|
3582
|
-
private onUncaughtError?;
|
3583
|
-
private clientInfo;
|
3584
|
-
private requestMessageId;
|
3585
|
-
private responseHandlers;
|
3586
|
-
private serverCapabilities;
|
3587
|
-
private isClosed;
|
3588
|
-
constructor({ transport: transportConfig, name, onUncaughtError, }: MCPClientConfig);
|
3589
|
-
init(): Promise<this>;
|
3590
|
-
close(): Promise<void>;
|
3591
|
-
private assertCapability;
|
3592
|
-
private request;
|
3593
|
-
private listTools;
|
3594
|
-
private callTool;
|
3595
|
-
private notification;
|
3596
|
-
/**
|
3597
|
-
* Returns a set of AI SDK tools from the MCP server
|
3598
|
-
* @returns A record of tool names to their implementations
|
3599
|
-
*/
|
3600
|
-
tools<TOOL_SCHEMAS extends ToolSchemas = 'automatic'>({ schemas, }?: {
|
3565
|
+
interface MCPClient {
|
3566
|
+
tools<TOOL_SCHEMAS extends ToolSchemas = 'automatic'>(options?: {
|
3601
3567
|
schemas?: TOOL_SCHEMAS;
|
3602
3568
|
}): Promise<McpToolSet<TOOL_SCHEMAS>>;
|
3603
|
-
|
3604
|
-
private onError;
|
3605
|
-
private onResponse;
|
3569
|
+
close: () => Promise<void>;
|
3606
3570
|
}
|
3607
3571
|
|
3608
3572
|
/**
|
@@ -4203,4 +4167,4 @@ declare global {
|
|
4203
4167
|
var AI_SDK_DEFAULT_PROVIDER: ProviderV2 | undefined;
|
4204
4168
|
}
|
4205
4169
|
|
4206
|
-
export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, 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, getToolName, hasToolCall, isDeepEqualData, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel, wrapProvider };
|
4170
|
+
export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, MCPClient as experimental_MCPClient, MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, hasToolCall, isDeepEqualData, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel, wrapProvider };
|
package/dist/index.js
CHANGED
@@ -6699,6 +6699,7 @@ var DefaultStreamObjectResult = class {
|
|
6699
6699
|
this._warnings = new DelayedPromise();
|
6700
6700
|
this._request = new DelayedPromise();
|
6701
6701
|
this._response = new DelayedPromise();
|
6702
|
+
this._finishReason = new DelayedPromise();
|
6702
6703
|
const model = resolveLanguageModel(modelArg);
|
6703
6704
|
const { maxRetries, retry } = prepareRetries({
|
6704
6705
|
maxRetries: maxRetriesArg
|
@@ -6918,6 +6919,7 @@ var DefaultStreamObjectResult = class {
|
|
6918
6919
|
...fullResponse,
|
6919
6920
|
headers: response == null ? void 0 : response.headers
|
6920
6921
|
});
|
6922
|
+
self._finishReason.resolve(finishReason != null ? finishReason : "unknown");
|
6921
6923
|
const validationResult = await outputStrategy.validateFinalResult(
|
6922
6924
|
latestObjectJson,
|
6923
6925
|
{
|
@@ -7052,6 +7054,9 @@ var DefaultStreamObjectResult = class {
|
|
7052
7054
|
get response() {
|
7053
7055
|
return this._response.promise;
|
7054
7056
|
}
|
7057
|
+
get finishReason() {
|
7058
|
+
return this._finishReason.promise;
|
7059
|
+
}
|
7055
7060
|
get partialObjectStream() {
|
7056
7061
|
return createAsyncIterableStream(
|
7057
7062
|
this.baseStream.pipeThrough(
|
@@ -7904,38 +7909,38 @@ var SUPPORTED_PROTOCOL_VERSIONS = [
|
|
7904
7909
|
"2025-03-26",
|
7905
7910
|
"2024-11-05"
|
7906
7911
|
];
|
7907
|
-
var ClientOrServerImplementationSchema = import_v48.z.
|
7912
|
+
var ClientOrServerImplementationSchema = import_v48.z.looseObject({
|
7908
7913
|
name: import_v48.z.string(),
|
7909
7914
|
version: import_v48.z.string()
|
7910
|
-
})
|
7911
|
-
var BaseParamsSchema = import_v48.z.
|
7912
|
-
_meta: import_v48.z.optional(import_v48.z.object({}).
|
7913
|
-
})
|
7915
|
+
});
|
7916
|
+
var BaseParamsSchema = import_v48.z.looseObject({
|
7917
|
+
_meta: import_v48.z.optional(import_v48.z.object({}).loose())
|
7918
|
+
});
|
7914
7919
|
var ResultSchema = BaseParamsSchema;
|
7915
7920
|
var RequestSchema = import_v48.z.object({
|
7916
7921
|
method: import_v48.z.string(),
|
7917
7922
|
params: import_v48.z.optional(BaseParamsSchema)
|
7918
7923
|
});
|
7919
|
-
var ServerCapabilitiesSchema = import_v48.z.
|
7920
|
-
experimental: import_v48.z.optional(import_v48.z.object({}).
|
7921
|
-
logging: import_v48.z.optional(import_v48.z.object({}).
|
7924
|
+
var ServerCapabilitiesSchema = import_v48.z.looseObject({
|
7925
|
+
experimental: import_v48.z.optional(import_v48.z.object({}).loose()),
|
7926
|
+
logging: import_v48.z.optional(import_v48.z.object({}).loose()),
|
7922
7927
|
prompts: import_v48.z.optional(
|
7923
|
-
import_v48.z.
|
7928
|
+
import_v48.z.looseObject({
|
7924
7929
|
listChanged: import_v48.z.optional(import_v48.z.boolean())
|
7925
|
-
})
|
7930
|
+
})
|
7926
7931
|
),
|
7927
7932
|
resources: import_v48.z.optional(
|
7928
|
-
import_v48.z.
|
7933
|
+
import_v48.z.looseObject({
|
7929
7934
|
subscribe: import_v48.z.optional(import_v48.z.boolean()),
|
7930
7935
|
listChanged: import_v48.z.optional(import_v48.z.boolean())
|
7931
|
-
})
|
7936
|
+
})
|
7932
7937
|
),
|
7933
7938
|
tools: import_v48.z.optional(
|
7934
|
-
import_v48.z.
|
7939
|
+
import_v48.z.looseObject({
|
7935
7940
|
listChanged: import_v48.z.optional(import_v48.z.boolean())
|
7936
|
-
})
|
7941
|
+
})
|
7937
7942
|
)
|
7938
|
-
})
|
7943
|
+
});
|
7939
7944
|
var InitializeResultSchema = ResultSchema.extend({
|
7940
7945
|
protocolVersion: import_v48.z.string(),
|
7941
7946
|
capabilities: ServerCapabilitiesSchema,
|
@@ -7950,21 +7955,21 @@ var ToolSchema = import_v48.z.object({
|
|
7950
7955
|
description: import_v48.z.optional(import_v48.z.string()),
|
7951
7956
|
inputSchema: import_v48.z.object({
|
7952
7957
|
type: import_v48.z.literal("object"),
|
7953
|
-
properties: import_v48.z.optional(import_v48.z.object({}).
|
7954
|
-
}).
|
7955
|
-
}).
|
7958
|
+
properties: import_v48.z.optional(import_v48.z.object({}).loose())
|
7959
|
+
}).loose()
|
7960
|
+
}).loose();
|
7956
7961
|
var ListToolsResultSchema = PaginatedResultSchema.extend({
|
7957
7962
|
tools: import_v48.z.array(ToolSchema)
|
7958
7963
|
});
|
7959
7964
|
var TextContentSchema = import_v48.z.object({
|
7960
7965
|
type: import_v48.z.literal("text"),
|
7961
7966
|
text: import_v48.z.string()
|
7962
|
-
}).
|
7967
|
+
}).loose();
|
7963
7968
|
var ImageContentSchema = import_v48.z.object({
|
7964
7969
|
type: import_v48.z.literal("image"),
|
7965
|
-
data: import_v48.z.
|
7970
|
+
data: import_v48.z.base64(),
|
7966
7971
|
mimeType: import_v48.z.string()
|
7967
|
-
}).
|
7972
|
+
}).loose();
|
7968
7973
|
var ResourceContentsSchema = import_v48.z.object({
|
7969
7974
|
/**
|
7970
7975
|
* The URI of this resource.
|
@@ -7974,17 +7979,17 @@ var ResourceContentsSchema = import_v48.z.object({
|
|
7974
7979
|
* The MIME type of this resource, if known.
|
7975
7980
|
*/
|
7976
7981
|
mimeType: import_v48.z.optional(import_v48.z.string())
|
7977
|
-
}).
|
7982
|
+
}).loose();
|
7978
7983
|
var TextResourceContentsSchema = ResourceContentsSchema.extend({
|
7979
7984
|
text: import_v48.z.string()
|
7980
7985
|
});
|
7981
7986
|
var BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
7982
|
-
blob: import_v48.z.
|
7987
|
+
blob: import_v48.z.base64()
|
7983
7988
|
});
|
7984
7989
|
var EmbeddedResourceSchema = import_v48.z.object({
|
7985
7990
|
type: import_v48.z.literal("resource"),
|
7986
7991
|
resource: import_v48.z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
|
7987
|
-
}).
|
7992
|
+
}).loose();
|
7988
7993
|
var CallToolResultSchema = ResultSchema.extend({
|
7989
7994
|
content: import_v48.z.array(
|
7990
7995
|
import_v48.z.union([TextContentSchema, ImageContentSchema, EmbeddedResourceSchema])
|
@@ -8182,11 +8187,11 @@ function isCustomMcpTransport(transport) {
|
|
8182
8187
|
// src/tool/mcp/mcp-client.ts
|
8183
8188
|
var CLIENT_VERSION = "1.0.0";
|
8184
8189
|
async function createMCPClient(config) {
|
8185
|
-
const client = new
|
8190
|
+
const client = new DefaultMCPClient(config);
|
8186
8191
|
await client.init();
|
8187
8192
|
return client;
|
8188
8193
|
}
|
8189
|
-
var
|
8194
|
+
var DefaultMCPClient = class {
|
8190
8195
|
constructor({
|
8191
8196
|
transport: transportConfig,
|
8192
8197
|
name: name16 = "ai-sdk-mcp-client",
|