ai 6.0.0-beta.41 → 6.0.0-beta.43
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 +14 -0
- package/dist/index.d.mts +51 -22
- package/dist/index.d.ts +51 -22
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -12
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.0-beta.43
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 27e8c3a: chore(ai): rename Agent to BasicAgent, introduce Agent interface
|
|
8
|
+
|
|
9
|
+
## 6.0.0-beta.42
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [6306603]
|
|
14
|
+
- @ai-sdk/provider-utils@4.0.0-beta.16
|
|
15
|
+
- @ai-sdk/gateway@2.0.0-beta.29
|
|
16
|
+
|
|
3
17
|
## 6.0.0-beta.41
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createGateway, gateway } from '@ai-sdk/gateway';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
|
-
import { Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, ModelMessage, FlexibleSchema, InferSchema, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, ToolCall, DataContent,
|
|
3
|
+
import { Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, ModelMessage, FlexibleSchema, InferSchema, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, ToolCall, DataContent, Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
export { AssistantContent, AssistantModelMessage, DataContent, FilePart, FlexibleSchema, IdGenerator, ImagePart, InferSchema, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolApprovalRequest, ToolApprovalResponse, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, parseJsonEventStream, tool, zodSchema } from '@ai-sdk/provider-utils';
|
|
5
5
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
6
6
|
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, ImageModelV3, ImageModelV3CallWarning, ImageModelV3ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, LanguageModelV3FinishReason, LanguageModelV3CallWarning, LanguageModelV3Source, LanguageModelV3Middleware, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV3CallWarning, TranscriptionModelV3, TranscriptionModelV3CallWarning, LanguageModelV3Usage, LanguageModelV3CallOptions, AISDKError, LanguageModelV3ToolCall, JSONSchema7, JSONParseError, TypeValidationError, ProviderV3, ProviderV2, NoSuchModelError, JSONObject } from '@ai-sdk/provider';
|
|
@@ -1690,7 +1690,7 @@ type InferUIMessageToolCall<UI_MESSAGE extends UIMessage> = ValueOf<{
|
|
|
1690
1690
|
dynamic: true;
|
|
1691
1691
|
});
|
|
1692
1692
|
|
|
1693
|
-
declare const uiMessageChunkSchema: _ai_sdk_provider_utils.
|
|
1693
|
+
declare const uiMessageChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
1694
1694
|
type: "text-start";
|
|
1695
1695
|
id: string;
|
|
1696
1696
|
providerMetadata?: _ai_sdk_provider.SharedV3ProviderMetadata | undefined;
|
|
@@ -2295,12 +2295,41 @@ type TextStreamPart<TOOLS extends ToolSet> = {
|
|
|
2295
2295
|
rawValue: unknown;
|
|
2296
2296
|
};
|
|
2297
2297
|
|
|
2298
|
+
/**
|
|
2299
|
+
* An agent is a reusable component that that has tools and that
|
|
2300
|
+
* can generate or stream content.
|
|
2301
|
+
*/
|
|
2302
|
+
interface Agent<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> {
|
|
2303
|
+
/**
|
|
2304
|
+
* The id of the agent.
|
|
2305
|
+
*/
|
|
2306
|
+
id: string | undefined;
|
|
2307
|
+
/**
|
|
2308
|
+
* The tools that the agent can use.
|
|
2309
|
+
*/
|
|
2310
|
+
tools: TOOLS;
|
|
2311
|
+
/**
|
|
2312
|
+
* Generates an output from the agent (non-streaming).
|
|
2313
|
+
*/
|
|
2314
|
+
generate(options: Prompt): PromiseLike<GenerateTextResult<TOOLS, OUTPUT>>;
|
|
2315
|
+
/**
|
|
2316
|
+
* Streams an output from the agent (streaming).
|
|
2317
|
+
*/
|
|
2318
|
+
stream(options: Prompt): StreamTextResult<TOOLS, OUTPUT_PARTIAL>;
|
|
2319
|
+
/**
|
|
2320
|
+
* Creates a response object that streams UI messages to the client.
|
|
2321
|
+
*/
|
|
2322
|
+
respond(options: {
|
|
2323
|
+
messages: UIMessage<never, never, InferUITools<TOOLS>>[];
|
|
2324
|
+
}): Response;
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2298
2327
|
/**
|
|
2299
2328
|
Callback that is set using the `onFinish` option.
|
|
2300
2329
|
|
|
2301
2330
|
@param event - The event that is passed to the callback.
|
|
2302
2331
|
*/
|
|
2303
|
-
type
|
|
2332
|
+
type BasicAgentOnFinishCallback<TOOLS extends ToolSet> = (event: StepResult<TOOLS> & {
|
|
2304
2333
|
/**
|
|
2305
2334
|
Details for all steps.
|
|
2306
2335
|
*/
|
|
@@ -2316,16 +2345,16 @@ Callback that is set using the `onStepFinish` option.
|
|
|
2316
2345
|
|
|
2317
2346
|
@param stepResult - The result of the step.
|
|
2318
2347
|
*/
|
|
2319
|
-
type
|
|
2348
|
+
type BasicAgentOnStepFinishCallback<TOOLS extends ToolSet> = (stepResult: StepResult<TOOLS>) => Promise<void> | void;
|
|
2320
2349
|
|
|
2321
2350
|
/**
|
|
2322
2351
|
* Configuration options for an agent.
|
|
2323
2352
|
*/
|
|
2324
|
-
type
|
|
2353
|
+
type BasicAgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> = CallSettings & {
|
|
2325
2354
|
/**
|
|
2326
|
-
* The
|
|
2355
|
+
* The id of the agent.
|
|
2327
2356
|
*/
|
|
2328
|
-
|
|
2357
|
+
id?: string;
|
|
2329
2358
|
/**
|
|
2330
2359
|
* The system prompt to use.
|
|
2331
2360
|
*/
|
|
@@ -2377,11 +2406,11 @@ type AgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never
|
|
|
2377
2406
|
/**
|
|
2378
2407
|
* Callback that is called when each step (LLM call) is finished, including intermediate steps.
|
|
2379
2408
|
*/
|
|
2380
|
-
onStepFinish?:
|
|
2409
|
+
onStepFinish?: BasicAgentOnStepFinishCallback<NoInfer<TOOLS>>;
|
|
2381
2410
|
/**
|
|
2382
2411
|
* Callback that is called when all steps are finished and the response is complete.
|
|
2383
2412
|
*/
|
|
2384
|
-
onFinish?:
|
|
2413
|
+
onFinish?: BasicAgentOnFinishCallback<NoInfer<TOOLS>>;
|
|
2385
2414
|
/**
|
|
2386
2415
|
Additional provider-specific options. They are passed through
|
|
2387
2416
|
to the provider from the AI SDK and enable provider-specific
|
|
@@ -2407,13 +2436,13 @@ type AgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never
|
|
|
2407
2436
|
*
|
|
2408
2437
|
* Define agents once and use them across your application.
|
|
2409
2438
|
*/
|
|
2410
|
-
declare class
|
|
2439
|
+
declare class BasicAgent<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> implements Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL> {
|
|
2411
2440
|
private readonly settings;
|
|
2412
|
-
constructor(settings:
|
|
2441
|
+
constructor(settings: BasicAgentSettings<TOOLS, OUTPUT, OUTPUT_PARTIAL>);
|
|
2413
2442
|
/**
|
|
2414
|
-
* The
|
|
2443
|
+
* The id of the agent.
|
|
2415
2444
|
*/
|
|
2416
|
-
get
|
|
2445
|
+
get id(): string | undefined;
|
|
2417
2446
|
/**
|
|
2418
2447
|
* The tools that the agent can use.
|
|
2419
2448
|
*/
|
|
@@ -4303,12 +4332,12 @@ type CreateUIMessage<UI_MESSAGE extends UIMessage> = Omit<UI_MESSAGE, 'id' | 'ro
|
|
|
4303
4332
|
id?: UI_MESSAGE['id'];
|
|
4304
4333
|
role?: UI_MESSAGE['role'];
|
|
4305
4334
|
};
|
|
4306
|
-
type UIDataPartSchemas = Record<string,
|
|
4335
|
+
type UIDataPartSchemas = Record<string, FlexibleSchema>;
|
|
4307
4336
|
type UIDataTypesToSchemas<T extends UIDataTypes> = {
|
|
4308
|
-
[K in keyof T]:
|
|
4337
|
+
[K in keyof T]: FlexibleSchema<T[K]>;
|
|
4309
4338
|
};
|
|
4310
4339
|
type InferUIDataParts<T extends UIDataPartSchemas> = {
|
|
4311
|
-
[K in keyof T]:
|
|
4340
|
+
[K in keyof T]: InferSchema<T[K]>;
|
|
4312
4341
|
};
|
|
4313
4342
|
type ChatRequestOptions = {
|
|
4314
4343
|
/**
|
|
@@ -4373,7 +4402,7 @@ interface ChatInit<UI_MESSAGE extends UIMessage> {
|
|
|
4373
4402
|
* generated.
|
|
4374
4403
|
*/
|
|
4375
4404
|
id?: string;
|
|
4376
|
-
messageMetadataSchema?:
|
|
4405
|
+
messageMetadataSchema?: FlexibleSchema<InferUIMessageMetadata<UI_MESSAGE>>;
|
|
4377
4406
|
dataPartSchemas?: UIDataTypesToSchemas<InferUIMessageData<UI_MESSAGE>>;
|
|
4378
4407
|
messages?: UI_MESSAGE[];
|
|
4379
4408
|
/**
|
|
@@ -4749,9 +4778,9 @@ type SafeValidateUIMessagesResult<UI_MESSAGE extends UIMessage> = {
|
|
|
4749
4778
|
*/
|
|
4750
4779
|
declare function safeValidateUIMessages<UI_MESSAGE extends UIMessage>({ messages, metadataSchema, dataSchemas, tools, }: {
|
|
4751
4780
|
messages: unknown;
|
|
4752
|
-
metadataSchema?:
|
|
4781
|
+
metadataSchema?: FlexibleSchema<UIMessage['metadata']>;
|
|
4753
4782
|
dataSchemas?: {
|
|
4754
|
-
[NAME in keyof InferUIMessageData<UI_MESSAGE> & string]?:
|
|
4783
|
+
[NAME in keyof InferUIMessageData<UI_MESSAGE> & string]?: FlexibleSchema<InferUIMessageData<UI_MESSAGE>[NAME]>;
|
|
4755
4784
|
};
|
|
4756
4785
|
tools?: {
|
|
4757
4786
|
[NAME in keyof InferUIMessageTools<UI_MESSAGE> & string]?: Tool<InferUIMessageTools<UI_MESSAGE>[NAME]['input'], InferUIMessageTools<UI_MESSAGE>[NAME]['output']>;
|
|
@@ -4766,9 +4795,9 @@ declare function safeValidateUIMessages<UI_MESSAGE extends UIMessage>({ messages
|
|
|
4766
4795
|
*/
|
|
4767
4796
|
declare function validateUIMessages<UI_MESSAGE extends UIMessage>({ messages, metadataSchema, dataSchemas, tools, }: {
|
|
4768
4797
|
messages: unknown;
|
|
4769
|
-
metadataSchema?:
|
|
4798
|
+
metadataSchema?: FlexibleSchema<UIMessage['metadata']>;
|
|
4770
4799
|
dataSchemas?: {
|
|
4771
|
-
[NAME in keyof InferUIMessageData<UI_MESSAGE> & string]?:
|
|
4800
|
+
[NAME in keyof InferUIMessageData<UI_MESSAGE> & string]?: FlexibleSchema<InferUIMessageData<UI_MESSAGE>[NAME]>;
|
|
4772
4801
|
};
|
|
4773
4802
|
tools?: {
|
|
4774
4803
|
[NAME in keyof InferUIMessageTools<UI_MESSAGE> & string]?: Tool<InferUIMessageTools<UI_MESSAGE>[NAME]['input'], InferUIMessageTools<UI_MESSAGE>[NAME]['output']>;
|
|
@@ -4795,4 +4824,4 @@ declare global {
|
|
|
4795
4824
|
var AI_SDK_LOG_WARNINGS: LogWarningsFunction | undefined | false;
|
|
4796
4825
|
}
|
|
4797
4826
|
|
|
4798
|
-
export { AbstractChat, Agent,
|
|
4827
|
+
export { AbstractChat, Agent, AsyncIterableStream, BasicAgent, BasicAgentOnFinishCallback, BasicAgentOnStepFinishCallback, BasicAgentSettings, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, 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, BasicAgent as Experimental_Agent, BasicAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferAgentUIMessage, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolApprovalRequestOutput, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, 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, getToolOrDynamicToolName, hasToolCall, isDeepEqualData, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapLanguageModel, wrapProvider };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createGateway, gateway } from '@ai-sdk/gateway';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
|
-
import { Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, ModelMessage, FlexibleSchema, InferSchema, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, ToolCall, DataContent,
|
|
3
|
+
import { Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, ModelMessage, FlexibleSchema, InferSchema, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, ToolCall, DataContent, Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
export { AssistantContent, AssistantModelMessage, DataContent, FilePart, FlexibleSchema, IdGenerator, ImagePart, InferSchema, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolApprovalRequest, ToolApprovalResponse, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, parseJsonEventStream, tool, zodSchema } from '@ai-sdk/provider-utils';
|
|
5
5
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
6
6
|
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, ImageModelV3, ImageModelV3CallWarning, ImageModelV3ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, LanguageModelV3FinishReason, LanguageModelV3CallWarning, LanguageModelV3Source, LanguageModelV3Middleware, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV3CallWarning, TranscriptionModelV3, TranscriptionModelV3CallWarning, LanguageModelV3Usage, LanguageModelV3CallOptions, AISDKError, LanguageModelV3ToolCall, JSONSchema7, JSONParseError, TypeValidationError, ProviderV3, ProviderV2, NoSuchModelError, JSONObject } from '@ai-sdk/provider';
|
|
@@ -1690,7 +1690,7 @@ type InferUIMessageToolCall<UI_MESSAGE extends UIMessage> = ValueOf<{
|
|
|
1690
1690
|
dynamic: true;
|
|
1691
1691
|
});
|
|
1692
1692
|
|
|
1693
|
-
declare const uiMessageChunkSchema: _ai_sdk_provider_utils.
|
|
1693
|
+
declare const uiMessageChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
1694
1694
|
type: "text-start";
|
|
1695
1695
|
id: string;
|
|
1696
1696
|
providerMetadata?: _ai_sdk_provider.SharedV3ProviderMetadata | undefined;
|
|
@@ -2295,12 +2295,41 @@ type TextStreamPart<TOOLS extends ToolSet> = {
|
|
|
2295
2295
|
rawValue: unknown;
|
|
2296
2296
|
};
|
|
2297
2297
|
|
|
2298
|
+
/**
|
|
2299
|
+
* An agent is a reusable component that that has tools and that
|
|
2300
|
+
* can generate or stream content.
|
|
2301
|
+
*/
|
|
2302
|
+
interface Agent<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> {
|
|
2303
|
+
/**
|
|
2304
|
+
* The id of the agent.
|
|
2305
|
+
*/
|
|
2306
|
+
id: string | undefined;
|
|
2307
|
+
/**
|
|
2308
|
+
* The tools that the agent can use.
|
|
2309
|
+
*/
|
|
2310
|
+
tools: TOOLS;
|
|
2311
|
+
/**
|
|
2312
|
+
* Generates an output from the agent (non-streaming).
|
|
2313
|
+
*/
|
|
2314
|
+
generate(options: Prompt): PromiseLike<GenerateTextResult<TOOLS, OUTPUT>>;
|
|
2315
|
+
/**
|
|
2316
|
+
* Streams an output from the agent (streaming).
|
|
2317
|
+
*/
|
|
2318
|
+
stream(options: Prompt): StreamTextResult<TOOLS, OUTPUT_PARTIAL>;
|
|
2319
|
+
/**
|
|
2320
|
+
* Creates a response object that streams UI messages to the client.
|
|
2321
|
+
*/
|
|
2322
|
+
respond(options: {
|
|
2323
|
+
messages: UIMessage<never, never, InferUITools<TOOLS>>[];
|
|
2324
|
+
}): Response;
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2298
2327
|
/**
|
|
2299
2328
|
Callback that is set using the `onFinish` option.
|
|
2300
2329
|
|
|
2301
2330
|
@param event - The event that is passed to the callback.
|
|
2302
2331
|
*/
|
|
2303
|
-
type
|
|
2332
|
+
type BasicAgentOnFinishCallback<TOOLS extends ToolSet> = (event: StepResult<TOOLS> & {
|
|
2304
2333
|
/**
|
|
2305
2334
|
Details for all steps.
|
|
2306
2335
|
*/
|
|
@@ -2316,16 +2345,16 @@ Callback that is set using the `onStepFinish` option.
|
|
|
2316
2345
|
|
|
2317
2346
|
@param stepResult - The result of the step.
|
|
2318
2347
|
*/
|
|
2319
|
-
type
|
|
2348
|
+
type BasicAgentOnStepFinishCallback<TOOLS extends ToolSet> = (stepResult: StepResult<TOOLS>) => Promise<void> | void;
|
|
2320
2349
|
|
|
2321
2350
|
/**
|
|
2322
2351
|
* Configuration options for an agent.
|
|
2323
2352
|
*/
|
|
2324
|
-
type
|
|
2353
|
+
type BasicAgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> = CallSettings & {
|
|
2325
2354
|
/**
|
|
2326
|
-
* The
|
|
2355
|
+
* The id of the agent.
|
|
2327
2356
|
*/
|
|
2328
|
-
|
|
2357
|
+
id?: string;
|
|
2329
2358
|
/**
|
|
2330
2359
|
* The system prompt to use.
|
|
2331
2360
|
*/
|
|
@@ -2377,11 +2406,11 @@ type AgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never
|
|
|
2377
2406
|
/**
|
|
2378
2407
|
* Callback that is called when each step (LLM call) is finished, including intermediate steps.
|
|
2379
2408
|
*/
|
|
2380
|
-
onStepFinish?:
|
|
2409
|
+
onStepFinish?: BasicAgentOnStepFinishCallback<NoInfer<TOOLS>>;
|
|
2381
2410
|
/**
|
|
2382
2411
|
* Callback that is called when all steps are finished and the response is complete.
|
|
2383
2412
|
*/
|
|
2384
|
-
onFinish?:
|
|
2413
|
+
onFinish?: BasicAgentOnFinishCallback<NoInfer<TOOLS>>;
|
|
2385
2414
|
/**
|
|
2386
2415
|
Additional provider-specific options. They are passed through
|
|
2387
2416
|
to the provider from the AI SDK and enable provider-specific
|
|
@@ -2407,13 +2436,13 @@ type AgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never
|
|
|
2407
2436
|
*
|
|
2408
2437
|
* Define agents once and use them across your application.
|
|
2409
2438
|
*/
|
|
2410
|
-
declare class
|
|
2439
|
+
declare class BasicAgent<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> implements Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL> {
|
|
2411
2440
|
private readonly settings;
|
|
2412
|
-
constructor(settings:
|
|
2441
|
+
constructor(settings: BasicAgentSettings<TOOLS, OUTPUT, OUTPUT_PARTIAL>);
|
|
2413
2442
|
/**
|
|
2414
|
-
* The
|
|
2443
|
+
* The id of the agent.
|
|
2415
2444
|
*/
|
|
2416
|
-
get
|
|
2445
|
+
get id(): string | undefined;
|
|
2417
2446
|
/**
|
|
2418
2447
|
* The tools that the agent can use.
|
|
2419
2448
|
*/
|
|
@@ -4303,12 +4332,12 @@ type CreateUIMessage<UI_MESSAGE extends UIMessage> = Omit<UI_MESSAGE, 'id' | 'ro
|
|
|
4303
4332
|
id?: UI_MESSAGE['id'];
|
|
4304
4333
|
role?: UI_MESSAGE['role'];
|
|
4305
4334
|
};
|
|
4306
|
-
type UIDataPartSchemas = Record<string,
|
|
4335
|
+
type UIDataPartSchemas = Record<string, FlexibleSchema>;
|
|
4307
4336
|
type UIDataTypesToSchemas<T extends UIDataTypes> = {
|
|
4308
|
-
[K in keyof T]:
|
|
4337
|
+
[K in keyof T]: FlexibleSchema<T[K]>;
|
|
4309
4338
|
};
|
|
4310
4339
|
type InferUIDataParts<T extends UIDataPartSchemas> = {
|
|
4311
|
-
[K in keyof T]:
|
|
4340
|
+
[K in keyof T]: InferSchema<T[K]>;
|
|
4312
4341
|
};
|
|
4313
4342
|
type ChatRequestOptions = {
|
|
4314
4343
|
/**
|
|
@@ -4373,7 +4402,7 @@ interface ChatInit<UI_MESSAGE extends UIMessage> {
|
|
|
4373
4402
|
* generated.
|
|
4374
4403
|
*/
|
|
4375
4404
|
id?: string;
|
|
4376
|
-
messageMetadataSchema?:
|
|
4405
|
+
messageMetadataSchema?: FlexibleSchema<InferUIMessageMetadata<UI_MESSAGE>>;
|
|
4377
4406
|
dataPartSchemas?: UIDataTypesToSchemas<InferUIMessageData<UI_MESSAGE>>;
|
|
4378
4407
|
messages?: UI_MESSAGE[];
|
|
4379
4408
|
/**
|
|
@@ -4749,9 +4778,9 @@ type SafeValidateUIMessagesResult<UI_MESSAGE extends UIMessage> = {
|
|
|
4749
4778
|
*/
|
|
4750
4779
|
declare function safeValidateUIMessages<UI_MESSAGE extends UIMessage>({ messages, metadataSchema, dataSchemas, tools, }: {
|
|
4751
4780
|
messages: unknown;
|
|
4752
|
-
metadataSchema?:
|
|
4781
|
+
metadataSchema?: FlexibleSchema<UIMessage['metadata']>;
|
|
4753
4782
|
dataSchemas?: {
|
|
4754
|
-
[NAME in keyof InferUIMessageData<UI_MESSAGE> & string]?:
|
|
4783
|
+
[NAME in keyof InferUIMessageData<UI_MESSAGE> & string]?: FlexibleSchema<InferUIMessageData<UI_MESSAGE>[NAME]>;
|
|
4755
4784
|
};
|
|
4756
4785
|
tools?: {
|
|
4757
4786
|
[NAME in keyof InferUIMessageTools<UI_MESSAGE> & string]?: Tool<InferUIMessageTools<UI_MESSAGE>[NAME]['input'], InferUIMessageTools<UI_MESSAGE>[NAME]['output']>;
|
|
@@ -4766,9 +4795,9 @@ declare function safeValidateUIMessages<UI_MESSAGE extends UIMessage>({ messages
|
|
|
4766
4795
|
*/
|
|
4767
4796
|
declare function validateUIMessages<UI_MESSAGE extends UIMessage>({ messages, metadataSchema, dataSchemas, tools, }: {
|
|
4768
4797
|
messages: unknown;
|
|
4769
|
-
metadataSchema?:
|
|
4798
|
+
metadataSchema?: FlexibleSchema<UIMessage['metadata']>;
|
|
4770
4799
|
dataSchemas?: {
|
|
4771
|
-
[NAME in keyof InferUIMessageData<UI_MESSAGE> & string]?:
|
|
4800
|
+
[NAME in keyof InferUIMessageData<UI_MESSAGE> & string]?: FlexibleSchema<InferUIMessageData<UI_MESSAGE>[NAME]>;
|
|
4772
4801
|
};
|
|
4773
4802
|
tools?: {
|
|
4774
4803
|
[NAME in keyof InferUIMessageTools<UI_MESSAGE> & string]?: Tool<InferUIMessageTools<UI_MESSAGE>[NAME]['input'], InferUIMessageTools<UI_MESSAGE>[NAME]['output']>;
|
|
@@ -4795,4 +4824,4 @@ declare global {
|
|
|
4795
4824
|
var AI_SDK_LOG_WARNINGS: LogWarningsFunction | undefined | false;
|
|
4796
4825
|
}
|
|
4797
4826
|
|
|
4798
|
-
export { AbstractChat, Agent,
|
|
4827
|
+
export { AbstractChat, Agent, AsyncIterableStream, BasicAgent, BasicAgentOnFinishCallback, BasicAgentOnStepFinishCallback, BasicAgentSettings, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, 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, BasicAgent as Experimental_Agent, BasicAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferAgentUIMessage, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolApprovalRequestOutput, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, 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, getToolOrDynamicToolName, hasToolCall, isDeepEqualData, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapLanguageModel, wrapProvider };
|
package/dist/index.js
CHANGED
|
@@ -23,11 +23,11 @@ __export(src_exports, {
|
|
|
23
23
|
AISDKError: () => import_provider18.AISDKError,
|
|
24
24
|
APICallError: () => import_provider18.APICallError,
|
|
25
25
|
AbstractChat: () => AbstractChat,
|
|
26
|
-
|
|
26
|
+
BasicAgent: () => BasicAgent,
|
|
27
27
|
DefaultChatTransport: () => DefaultChatTransport,
|
|
28
28
|
DownloadError: () => DownloadError,
|
|
29
29
|
EmptyResponseBodyError: () => import_provider18.EmptyResponseBodyError,
|
|
30
|
-
Experimental_Agent: () =>
|
|
30
|
+
Experimental_Agent: () => BasicAgent,
|
|
31
31
|
HttpChatTransport: () => HttpChatTransport,
|
|
32
32
|
InvalidArgumentError: () => InvalidArgumentError,
|
|
33
33
|
InvalidDataContentError: () => InvalidDataContentError,
|
|
@@ -813,7 +813,7 @@ function detectMediaType({
|
|
|
813
813
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
814
814
|
|
|
815
815
|
// src/version.ts
|
|
816
|
-
var VERSION = true ? "6.0.0-beta.
|
|
816
|
+
var VERSION = true ? "6.0.0-beta.43" : "0.0.0-test";
|
|
817
817
|
|
|
818
818
|
// src/util/download/download.ts
|
|
819
819
|
var download = async ({ url }) => {
|
|
@@ -3214,7 +3214,7 @@ var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
|
3214
3214
|
// src/ui-message-stream/ui-message-chunks.ts
|
|
3215
3215
|
var import_v47 = require("zod/v4");
|
|
3216
3216
|
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
3217
|
-
var uiMessageChunkSchema = (0, import_provider_utils12.
|
|
3217
|
+
var uiMessageChunkSchema = (0, import_provider_utils12.lazySchema)(
|
|
3218
3218
|
() => (0, import_provider_utils12.zodSchema)(
|
|
3219
3219
|
import_v47.z.union([
|
|
3220
3220
|
import_v47.z.strictObject({
|
|
@@ -6376,16 +6376,16 @@ function convertToModelMessages(messages, options) {
|
|
|
6376
6376
|
}
|
|
6377
6377
|
var convertToCoreMessages = convertToModelMessages;
|
|
6378
6378
|
|
|
6379
|
-
// src/agent/agent.ts
|
|
6380
|
-
var
|
|
6379
|
+
// src/agent/basic-agent.ts
|
|
6380
|
+
var BasicAgent = class {
|
|
6381
6381
|
constructor(settings) {
|
|
6382
6382
|
this.settings = settings;
|
|
6383
6383
|
}
|
|
6384
6384
|
/**
|
|
6385
|
-
* The
|
|
6385
|
+
* The id of the agent.
|
|
6386
6386
|
*/
|
|
6387
|
-
get
|
|
6388
|
-
return this.settings.
|
|
6387
|
+
get id() {
|
|
6388
|
+
return this.settings.id;
|
|
6389
6389
|
}
|
|
6390
6390
|
/**
|
|
6391
6391
|
* The tools that the agent can use.
|
|
@@ -10461,7 +10461,7 @@ var TextStreamChatTransport = class extends HttpChatTransport {
|
|
|
10461
10461
|
var import_provider32 = require("@ai-sdk/provider");
|
|
10462
10462
|
var import_provider_utils35 = require("@ai-sdk/provider-utils");
|
|
10463
10463
|
var import_v410 = require("zod/v4");
|
|
10464
|
-
var uiMessagesSchema = (0, import_provider_utils35.
|
|
10464
|
+
var uiMessagesSchema = (0, import_provider_utils35.lazySchema)(
|
|
10465
10465
|
() => (0, import_provider_utils35.zodSchema)(
|
|
10466
10466
|
import_v410.z.array(
|
|
10467
10467
|
import_v410.z.object({
|
|
@@ -10907,7 +10907,7 @@ function readUIMessageStream({
|
|
|
10907
10907
|
AISDKError,
|
|
10908
10908
|
APICallError,
|
|
10909
10909
|
AbstractChat,
|
|
10910
|
-
|
|
10910
|
+
BasicAgent,
|
|
10911
10911
|
DefaultChatTransport,
|
|
10912
10912
|
DownloadError,
|
|
10913
10913
|
EmptyResponseBodyError,
|