@voltagent/core 1.1.25 → 1.1.26
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/dist/index.d.mts +47 -19
- package/dist/index.d.ts +47 -19
- package/dist/index.js +28 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -158,7 +158,7 @@ declare class ToolManager {
|
|
|
158
158
|
* @returns The result of the tool execution
|
|
159
159
|
* @throws Error if the tool doesn't exist or fails to execute
|
|
160
160
|
*/
|
|
161
|
-
executeTool(toolName: string, args:
|
|
161
|
+
executeTool(toolName: string, args: unknown, options?: ToolExecuteOptions): Promise<unknown>;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
/**
|
|
@@ -192,7 +192,7 @@ type ToolOptions<T extends ToolSchema = ToolSchema, O extends ToolSchema | undef
|
|
|
192
192
|
/**
|
|
193
193
|
* Function to execute when the tool is called
|
|
194
194
|
*/
|
|
195
|
-
execute
|
|
195
|
+
execute?: (args: z.infer<T>, context?: OperationContext) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
|
|
196
196
|
};
|
|
197
197
|
/**
|
|
198
198
|
* Tool class for defining tools that agents can use
|
|
@@ -221,7 +221,12 @@ declare class Tool<T extends ToolSchema = ToolSchema, O extends ToolSchema | und
|
|
|
221
221
|
/**
|
|
222
222
|
* Function to execute when the tool is called
|
|
223
223
|
*/
|
|
224
|
-
readonly execute
|
|
224
|
+
readonly execute?: (args: z.infer<T>, context?: OperationContext) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
|
|
225
|
+
/**
|
|
226
|
+
* Whether this tool should be executed on the client side.
|
|
227
|
+
* Returns true when no server-side execute handler is provided.
|
|
228
|
+
*/
|
|
229
|
+
readonly isClientSide: () => boolean;
|
|
225
230
|
/**
|
|
226
231
|
* Create a new tool
|
|
227
232
|
*/
|
|
@@ -3447,6 +3452,20 @@ type ModelToolCall = {
|
|
|
3447
3452
|
toolName: string;
|
|
3448
3453
|
args: Record<string, unknown>;
|
|
3449
3454
|
};
|
|
3455
|
+
/**
|
|
3456
|
+
* Represents the payload used when sending a tool's result back to the chat runtime
|
|
3457
|
+
* via useChat().addToolResult in the Vercel AI SDK.
|
|
3458
|
+
*/
|
|
3459
|
+
type ClientSideToolResult = {
|
|
3460
|
+
tool: string;
|
|
3461
|
+
toolCallId: string;
|
|
3462
|
+
output: unknown;
|
|
3463
|
+
} | {
|
|
3464
|
+
tool: string;
|
|
3465
|
+
toolCallId: string;
|
|
3466
|
+
state: "output-error";
|
|
3467
|
+
errorText: string;
|
|
3468
|
+
};
|
|
3450
3469
|
/**
|
|
3451
3470
|
* Agent response format
|
|
3452
3471
|
*/
|
|
@@ -3869,7 +3888,7 @@ declare class Agent {
|
|
|
3869
3888
|
readonly purpose?: string;
|
|
3870
3889
|
readonly instructions: InstructionsDynamicValue;
|
|
3871
3890
|
readonly model: LanguageModel | DynamicValue<LanguageModel>;
|
|
3872
|
-
readonly
|
|
3891
|
+
readonly dynamicTools?: DynamicValue<(Tool<any, any> | Toolkit)[]>;
|
|
3873
3892
|
readonly hooks: AgentHooks;
|
|
3874
3893
|
readonly temperature?: number;
|
|
3875
3894
|
readonly maxOutputTokens?: number;
|
|
@@ -4610,6 +4629,15 @@ interface WorkflowStreamWriter {
|
|
|
4610
4629
|
filter?: (part: DangerouslyAllowAny) => boolean;
|
|
4611
4630
|
}): Promise<void>;
|
|
4612
4631
|
}
|
|
4632
|
+
/**
|
|
4633
|
+
* The state parameter passed to workflow steps
|
|
4634
|
+
*/
|
|
4635
|
+
type WorkflowStepState<INPUT> = Omit<WorkflowState<INPUT, DangerouslyAllowAny>, "data" | "result"> & {
|
|
4636
|
+
/** Workflow execution context for event tracking */
|
|
4637
|
+
workflowContext?: WorkflowExecutionContext;
|
|
4638
|
+
/** AbortSignal for checking suspension during step execution */
|
|
4639
|
+
signal?: AbortSignal;
|
|
4640
|
+
};
|
|
4613
4641
|
|
|
4614
4642
|
/**
|
|
4615
4643
|
* WorkflowTraceContext - Manages trace hierarchy and common attributes for workflows
|
|
@@ -4938,8 +4966,8 @@ type ExtractExecuteResult<T> = T extends {
|
|
|
4938
4966
|
execute: (...args: any[]) => infer R;
|
|
4939
4967
|
} ? R extends Promise<infer U> ? U : R : never;
|
|
4940
4968
|
|
|
4941
|
-
type AgentConfig$1<SCHEMA extends z.ZodTypeAny> = BaseGenerationOptions & {
|
|
4942
|
-
schema: SCHEMA;
|
|
4969
|
+
type AgentConfig$1<SCHEMA extends z.ZodTypeAny, INPUT, DATA> = BaseGenerationOptions & {
|
|
4970
|
+
schema: SCHEMA | ((context: Omit<WorkflowExecuteContext<INPUT, DATA, any, any>, "suspend" | "writer">) => SCHEMA | Promise<SCHEMA>);
|
|
4943
4971
|
};
|
|
4944
4972
|
/**
|
|
4945
4973
|
* Creates an agent step for a workflow
|
|
@@ -4964,7 +4992,7 @@ type AgentConfig$1<SCHEMA extends z.ZodTypeAny> = BaseGenerationOptions & {
|
|
|
4964
4992
|
* @param config - The config for the agent (schema) `generateObject` call
|
|
4965
4993
|
* @returns A workflow step that executes the agent with the task
|
|
4966
4994
|
*/
|
|
4967
|
-
declare function andAgent<INPUT, DATA, SCHEMA extends z.ZodTypeAny>(task: UIMessage[] | ModelMessage[] | string | InternalWorkflowFunc<INPUT, DATA, UIMessage[] | ModelMessage[] | string, any, any>, agent: Agent, config: AgentConfig$1<SCHEMA>): {
|
|
4995
|
+
declare function andAgent<INPUT, DATA, SCHEMA extends z.ZodTypeAny>(task: UIMessage[] | ModelMessage[] | string | InternalWorkflowFunc<INPUT, DATA, UIMessage[] | ModelMessage[] | string, any, any>, agent: Agent, config: AgentConfig$1<SCHEMA, INPUT, DATA>): {
|
|
4968
4996
|
type: "agent";
|
|
4969
4997
|
id: string;
|
|
4970
4998
|
name: string;
|
|
@@ -5373,8 +5401,8 @@ interface SerializedWorkflowStep {
|
|
|
5373
5401
|
/**
|
|
5374
5402
|
* Agent configuration for the chain
|
|
5375
5403
|
*/
|
|
5376
|
-
type AgentConfig<SCHEMA extends z.ZodTypeAny> = {
|
|
5377
|
-
schema: SCHEMA;
|
|
5404
|
+
type AgentConfig<SCHEMA extends z.ZodTypeAny, INPUT_SCHEMA extends InternalBaseWorkflowInputSchema, CURRENT_DATA> = BaseGenerationOptions & {
|
|
5405
|
+
schema: SCHEMA | ((context: Omit<WorkflowExecuteContext<WorkflowInput<INPUT_SCHEMA>, CURRENT_DATA, any, any>, "suspend" | "writer">) => SCHEMA | Promise<SCHEMA>);
|
|
5378
5406
|
};
|
|
5379
5407
|
/**
|
|
5380
5408
|
* A workflow chain that provides a fluent API for building workflows
|
|
@@ -5451,7 +5479,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5451
5479
|
* @param config - The config for the agent (schema) `generateObject` call
|
|
5452
5480
|
* @returns A workflow step that executes the agent with the task
|
|
5453
5481
|
*/
|
|
5454
|
-
andAgent<SCHEMA extends z.ZodTypeAny>(task: string | UIMessage[] | ModelMessage[] | InternalWorkflowFunc<INPUT_SCHEMA
|
|
5482
|
+
andAgent<SCHEMA extends z.ZodTypeAny>(task: string | UIMessage[] | ModelMessage[] | InternalWorkflowFunc<WorkflowInput<INPUT_SCHEMA>, CURRENT_DATA, string | UIMessage[] | ModelMessage[], any, any>, agent: Agent, config: AgentConfig<SCHEMA, INPUT_SCHEMA, CURRENT_DATA>): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, z.infer<SCHEMA>, SUSPEND_SCHEMA, RESUME_SCHEMA>;
|
|
5455
5483
|
/**
|
|
5456
5484
|
* Add a function step to the workflow with both input and output schemas
|
|
5457
5485
|
* @param config - Step configuration with schemas
|
|
@@ -5464,7 +5492,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5464
5492
|
resumeSchema?: RS;
|
|
5465
5493
|
execute: (context: {
|
|
5466
5494
|
data: z.infer<IS>;
|
|
5467
|
-
state:
|
|
5495
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5468
5496
|
getStepData: (stepId: string) => {
|
|
5469
5497
|
input: any;
|
|
5470
5498
|
output: any;
|
|
@@ -5490,7 +5518,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5490
5518
|
resumeSchema?: RS;
|
|
5491
5519
|
execute: (context: {
|
|
5492
5520
|
data: z.infer<IS>;
|
|
5493
|
-
state:
|
|
5521
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5494
5522
|
getStepData: (stepId: string) => {
|
|
5495
5523
|
input: any;
|
|
5496
5524
|
output: any;
|
|
@@ -5516,7 +5544,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5516
5544
|
resumeSchema?: RS;
|
|
5517
5545
|
execute: (context: {
|
|
5518
5546
|
data: CURRENT_DATA;
|
|
5519
|
-
state:
|
|
5547
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5520
5548
|
getStepData: (stepId: string) => {
|
|
5521
5549
|
input: any;
|
|
5522
5550
|
output: any;
|
|
@@ -5542,7 +5570,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5542
5570
|
resumeSchema: RS;
|
|
5543
5571
|
execute: (context: {
|
|
5544
5572
|
data: CURRENT_DATA;
|
|
5545
|
-
state:
|
|
5573
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5546
5574
|
getStepData: (stepId: string) => {
|
|
5547
5575
|
input: any;
|
|
5548
5576
|
output: any;
|
|
@@ -5584,7 +5612,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5584
5612
|
andThen<NEW_DATA>(config: {
|
|
5585
5613
|
execute: (context: {
|
|
5586
5614
|
data: CURRENT_DATA;
|
|
5587
|
-
state:
|
|
5615
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5588
5616
|
getStepData: (stepId: string) => {
|
|
5589
5617
|
input: any;
|
|
5590
5618
|
output: any;
|
|
@@ -5614,7 +5642,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5614
5642
|
resumeSchema?: RS;
|
|
5615
5643
|
condition: (context: {
|
|
5616
5644
|
data: z.infer<IS>;
|
|
5617
|
-
state:
|
|
5645
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5618
5646
|
getStepData: (stepId: string) => {
|
|
5619
5647
|
input: any;
|
|
5620
5648
|
output: any;
|
|
@@ -5675,7 +5703,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5675
5703
|
resumeSchema?: RS;
|
|
5676
5704
|
execute: (context: {
|
|
5677
5705
|
data: z.infer<IS>;
|
|
5678
|
-
state:
|
|
5706
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5679
5707
|
getStepData: (stepId: string) => {
|
|
5680
5708
|
input: any;
|
|
5681
5709
|
output: any;
|
|
@@ -5716,7 +5744,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5716
5744
|
andTap<_NEW_DATA>(config: {
|
|
5717
5745
|
execute: (context: {
|
|
5718
5746
|
data: CURRENT_DATA;
|
|
5719
|
-
state:
|
|
5747
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5720
5748
|
getStepData: (stepId: string) => {
|
|
5721
5749
|
input: any;
|
|
5722
5750
|
output: any;
|
|
@@ -7637,4 +7665,4 @@ declare class VoltAgent {
|
|
|
7637
7665
|
*/
|
|
7638
7666
|
declare function convertUsage(usage: LanguageModelUsage | undefined): UsageInfo | undefined;
|
|
7639
7667
|
|
|
7640
|
-
export { A2AServerRegistry, AbortError, Agent, type AgentFullState, type AgentHookOnEnd, type AgentHookOnError, type AgentHookOnHandoff, type AgentHookOnPrepareMessages, type AgentHookOnPrepareModelMessages, type AgentHookOnStart, type AgentHookOnStepFinish, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentStatus, type AgentTool, AiSdkEmbeddingAdapter, type AllowedVariableValue, type ApiToolInfo, type BaseEventMetadata, type BaseGenerationOptions, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTool, type BaseToolCall, type CachedPrompt, type ChatMessage, ClientHTTPError, type CloudflareFetchHandler, type Conversation, ConversationAlreadyExistsError, ConversationNotFoundError, type ConversationQueryOptions, type ConversationQueryOptions as ConversationQueryOptionsV2, type Conversation as ConversationV2, type CreateConversationInput, type CreateConversationInput as CreateConversationInputV2, type CreateReasoningToolsOptions, DEFAULT_INSTRUCTIONS, type DataContent, type Document, type DynamicValue, type DynamicValueOptions, type EmbeddingAdapter$1 as EmbeddingAdapter, EmbeddingAdapterNotConfiguredError, EmbeddingError, type ExtractVariableNames, FEW_SHOT_EXAMPLES, type GenerateObjectOptions, type GenerateObjectSubAgentConfig, type GenerateTextOptions, type GenerateTextSubAgentConfig, type GetMessagesOptions, type IServerProvider, type IServerlessProvider, type VoltOpsClient$1 as IVoltOpsClient, InMemoryStorageAdapter$1 as InMemoryObservabilityAdapter, InMemoryStorageAdapter, InMemoryVectorAdapter, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type LLMProvider, LazyRemoteExportProcessor, LocalStorageSpanProcessor, type LogFilter, LoggerProxy, MCPConfiguration, type MCPElicitationAdapter, type MCPLoggingAdapter, type MCPPromptsAdapter, type MCPResourcesAdapter, MCPServerRegistry, type ManagedMemoryAddMessageInput, type ManagedMemoryAddMessagesInput, type ManagedMemoryClearMessagesInput, type ManagedMemoryConnectionInfo, type ManagedMemoryConversationsClient, type ManagedMemoryCredentialCreateResult, type ManagedMemoryCredentialListResult, type ManagedMemoryCredentialSummary, type ManagedMemoryDatabaseSummary, type ManagedMemoryGetMessagesInput, type ManagedMemoryMessagesClient, type ManagedMemorySetWorkingMemoryInput, type ManagedMemoryStatus, type ManagedMemoryUpdateConversationInput, type ManagedMemoryVoltOpsClient, type ManagedMemoryWorkflowStateUpdateInput, type ManagedMemoryWorkflowStatesClient, type ManagedMemoryWorkingMemoryClient, type ManagedMemoryWorkingMemoryInput, Memory, type MemoryConfig, type MemoryOptions, type MemoryStorageMetadata, type MemoryUpdateMode, Memory as MemoryV2, MemoryV2Error, type MessageContent, MessageContentBuilder, type MessageRole, type ModelToolCall, NextAction, NodeType, VoltAgentObservability$1 as NodeVoltAgentObservability, type ObservabilityConfig, type ObservabilityLogRecord, type ObservabilitySpan, type ObservabilityStorageAdapter, type ObservabilityWebSocketEvent, type OnEndHookArgs, type OnErrorHookArgs, type OnHandoffHookArgs, type OnPrepareMessagesHookArgs, type OnPrepareMessagesHookResult, type OnPrepareModelMessagesHookArgs, type OnPrepareModelMessagesHookResult, type OnStartHookArgs, type OnStepFinishHookArgs, type OnToolEndHookArgs, type OnToolStartHookArgs, type OperationContext, type PackageUpdateInfo, type PromptApiClient, type PromptApiResponse, type PromptContent, type PromptCreator, type PromptHelper, type PromptReference, type PromptTemplate, type ProviderObjectResponse, type ProviderObjectStreamResponse, type ProviderParams, type ProviderResponse, type ProviderTextResponse, type ProviderTextStreamResponse, type ReadableStreamType, type ReasoningStep, ReasoningStepSchema, type RegisterOptions, type RegisteredWorkflow, type RemoteLogExportConfig, RemoteLogProcessor, type RetrieveOptions, type Retriever, type RetrieverOptions, type SearchOptions, type SearchResult, type ServerAgentResponse, type ServerApiResponse, type ServerProviderDeps, type ServerProviderFactory, type ServerWorkflowResponse, type ServerlessProviderFactory, type ServerlessRemoteEndpointConfig, type ServerlessRemoteExportConfig, type ServerlessRequestHandler, ServerlessVoltAgentObservability, type SpanAttributes, type SpanEvent, type SpanFilterConfig, SpanFilterProcessor, SpanKind, type SpanLink, type SpanStatus, SpanStatusCode, type SpanTreeNode, type StepChunkCallback, type StepFinishCallback, type StepWithContent, type StopWhen, type StorageAdapter, StorageError, StorageLogProcessor, type StoredUIMessage, type StreamObjectFinishResult, type StreamObjectOnFinishCallback, type StreamObjectOptions, type StreamObjectSubAgentConfig, type StreamPart, type StreamTextFinishResult, type StreamTextOnFinishCallback, type StreamTextOptions, type StreamTextSubAgentConfig, type SubAgentConfig, type SubAgentMethod, type SubAgentStateData, type SupervisorConfig, type TemplateVariables, type TimelineEventCoreLevel, type TimelineEventCoreStatus, type TimelineEventCoreType, Tool, type ToolCall, ToolDeniedError, type ToolErrorInfo, type ToolExecuteOptions, ToolManager, type ToolOptions, type ToolSchema, type ToolStatus, type ToolStatusInfo, type ToolWithNodeId, type Toolkit, type Usage, type UsageInfo, type VectorAdapter, VectorAdapterNotConfiguredError, VectorError, type VectorItem, type VectorSearchOptions, type Voice, type VoiceEventData, type VoiceEventType, type VoiceMetadata, type VoiceOptions, VoltAgent, VoltAgentError, VoltAgentObservability, type VoltAgentOptions, type VoltAgentStreamTextResult, type VoltAgentTextStreamPart, VoltOpsClient, type VoltOpsClientOptions, VoltOpsPromptApiClient, type VoltOpsPromptManager, VoltOpsPromptManagerImpl, WebSocketEventEmitter, WebSocketLogProcessor, WebSocketSpanProcessor, type Workflow, type WorkflowConfig, type WorkflowExecutionContext, WorkflowRegistry, type WorkflowStateEntry, type WorkflowStats, type WorkflowStepContext, type WorkflowStepType, type WorkflowTimelineEvent, type WorkingMemoryConfig, type WorkingMemoryScope, type WorkingMemorySummary, type WorkingMemoryUpdateOptions, addTimestampToMessage, andAgent, andAll, andRace, andTap, andThen, andWhen, andWorkflow, appendToMessage, buildRetrieverLogMessage, buildSpanTree, checkForUpdates, convertUsage, cosineSimilarity, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createSimpleTemplateEngine, createSubagent, createSuspendController, createTool, createToolkit, createVoltAgentObservability, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, extractFileParts, extractImageParts, extractText, extractTextParts, extractWorkflowStepInfo, filterContentParts, getContentLength, getEnvVar, getGlobalLogBuffer, getGlobalLogger, getNodeTypeFromNodeId, getWorkflowStepNodeType, hasContent, hasFilePart, hasImagePart, hasTextPart, isAbortError, isNodeRuntime, isServerlessRuntime, isStructuredContent, isTextContent, isVoltAgentError, mapMessageContent, messageHelpers, normalizeContent, normalizeToArray, prependToMessage, readableLogRecordToObservabilityLog, readableSpanToObservabilitySpan, safeJsonParse, serializeValueForDebug, tool, transformTextContent, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
|
|
7668
|
+
export { A2AServerRegistry, AbortError, Agent, type AgentFullState, type AgentHookOnEnd, type AgentHookOnError, type AgentHookOnHandoff, type AgentHookOnPrepareMessages, type AgentHookOnPrepareModelMessages, type AgentHookOnStart, type AgentHookOnStepFinish, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentStatus, type AgentTool, AiSdkEmbeddingAdapter, type AllowedVariableValue, type ApiToolInfo, type BaseEventMetadata, type BaseGenerationOptions, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTool, type BaseToolCall, type CachedPrompt, type ChatMessage, ClientHTTPError, type ClientSideToolResult, type CloudflareFetchHandler, type Conversation, ConversationAlreadyExistsError, ConversationNotFoundError, type ConversationQueryOptions, type ConversationQueryOptions as ConversationQueryOptionsV2, type Conversation as ConversationV2, type CreateConversationInput, type CreateConversationInput as CreateConversationInputV2, type CreateReasoningToolsOptions, DEFAULT_INSTRUCTIONS, type DataContent, type Document, type DynamicValue, type DynamicValueOptions, type EmbeddingAdapter$1 as EmbeddingAdapter, EmbeddingAdapterNotConfiguredError, EmbeddingError, type ExtractVariableNames, FEW_SHOT_EXAMPLES, type GenerateObjectOptions, type GenerateObjectSubAgentConfig, type GenerateTextOptions, type GenerateTextSubAgentConfig, type GetMessagesOptions, type IServerProvider, type IServerlessProvider, type VoltOpsClient$1 as IVoltOpsClient, InMemoryStorageAdapter$1 as InMemoryObservabilityAdapter, InMemoryStorageAdapter, InMemoryVectorAdapter, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type LLMProvider, LazyRemoteExportProcessor, LocalStorageSpanProcessor, type LogFilter, LoggerProxy, MCPConfiguration, type MCPElicitationAdapter, type MCPLoggingAdapter, type MCPPromptsAdapter, type MCPResourcesAdapter, MCPServerRegistry, type ManagedMemoryAddMessageInput, type ManagedMemoryAddMessagesInput, type ManagedMemoryClearMessagesInput, type ManagedMemoryConnectionInfo, type ManagedMemoryConversationsClient, type ManagedMemoryCredentialCreateResult, type ManagedMemoryCredentialListResult, type ManagedMemoryCredentialSummary, type ManagedMemoryDatabaseSummary, type ManagedMemoryGetMessagesInput, type ManagedMemoryMessagesClient, type ManagedMemorySetWorkingMemoryInput, type ManagedMemoryStatus, type ManagedMemoryUpdateConversationInput, type ManagedMemoryVoltOpsClient, type ManagedMemoryWorkflowStateUpdateInput, type ManagedMemoryWorkflowStatesClient, type ManagedMemoryWorkingMemoryClient, type ManagedMemoryWorkingMemoryInput, Memory, type MemoryConfig, type MemoryOptions, type MemoryStorageMetadata, type MemoryUpdateMode, Memory as MemoryV2, MemoryV2Error, type MessageContent, MessageContentBuilder, type MessageRole, type ModelToolCall, NextAction, NodeType, VoltAgentObservability$1 as NodeVoltAgentObservability, type ObservabilityConfig, type ObservabilityLogRecord, type ObservabilitySpan, type ObservabilityStorageAdapter, type ObservabilityWebSocketEvent, type OnEndHookArgs, type OnErrorHookArgs, type OnHandoffHookArgs, type OnPrepareMessagesHookArgs, type OnPrepareMessagesHookResult, type OnPrepareModelMessagesHookArgs, type OnPrepareModelMessagesHookResult, type OnStartHookArgs, type OnStepFinishHookArgs, type OnToolEndHookArgs, type OnToolStartHookArgs, type OperationContext, type PackageUpdateInfo, type PromptApiClient, type PromptApiResponse, type PromptContent, type PromptCreator, type PromptHelper, type PromptReference, type PromptTemplate, type ProviderObjectResponse, type ProviderObjectStreamResponse, type ProviderParams, type ProviderResponse, type ProviderTextResponse, type ProviderTextStreamResponse, type ReadableStreamType, type ReasoningStep, ReasoningStepSchema, type RegisterOptions, type RegisteredWorkflow, type RemoteLogExportConfig, RemoteLogProcessor, type RetrieveOptions, type Retriever, type RetrieverOptions, type SearchOptions, type SearchResult, type ServerAgentResponse, type ServerApiResponse, type ServerProviderDeps, type ServerProviderFactory, type ServerWorkflowResponse, type ServerlessProviderFactory, type ServerlessRemoteEndpointConfig, type ServerlessRemoteExportConfig, type ServerlessRequestHandler, ServerlessVoltAgentObservability, type SpanAttributes, type SpanEvent, type SpanFilterConfig, SpanFilterProcessor, SpanKind, type SpanLink, type SpanStatus, SpanStatusCode, type SpanTreeNode, type StepChunkCallback, type StepFinishCallback, type StepWithContent, type StopWhen, type StorageAdapter, StorageError, StorageLogProcessor, type StoredUIMessage, type StreamObjectFinishResult, type StreamObjectOnFinishCallback, type StreamObjectOptions, type StreamObjectSubAgentConfig, type StreamPart, type StreamTextFinishResult, type StreamTextOnFinishCallback, type StreamTextOptions, type StreamTextSubAgentConfig, type SubAgentConfig, type SubAgentMethod, type SubAgentStateData, type SupervisorConfig, type TemplateVariables, type TimelineEventCoreLevel, type TimelineEventCoreStatus, type TimelineEventCoreType, Tool, type ToolCall, ToolDeniedError, type ToolErrorInfo, type ToolExecuteOptions, ToolManager, type ToolOptions, type ToolSchema, type ToolStatus, type ToolStatusInfo, type ToolWithNodeId, type Toolkit, type Usage, type UsageInfo, type VectorAdapter, VectorAdapterNotConfiguredError, VectorError, type VectorItem, type VectorSearchOptions, type Voice, type VoiceEventData, type VoiceEventType, type VoiceMetadata, type VoiceOptions, VoltAgent, VoltAgentError, VoltAgentObservability, type VoltAgentOptions, type VoltAgentStreamTextResult, type VoltAgentTextStreamPart, VoltOpsClient, type VoltOpsClientOptions, VoltOpsPromptApiClient, type VoltOpsPromptManager, VoltOpsPromptManagerImpl, WebSocketEventEmitter, WebSocketLogProcessor, WebSocketSpanProcessor, type Workflow, type WorkflowConfig, type WorkflowExecutionContext, WorkflowRegistry, type WorkflowStateEntry, type WorkflowStats, type WorkflowStepContext, type WorkflowStepType, type WorkflowTimelineEvent, type WorkingMemoryConfig, type WorkingMemoryScope, type WorkingMemorySummary, type WorkingMemoryUpdateOptions, addTimestampToMessage, andAgent, andAll, andRace, andTap, andThen, andWhen, andWorkflow, appendToMessage, buildRetrieverLogMessage, buildSpanTree, checkForUpdates, convertUsage, cosineSimilarity, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createSimpleTemplateEngine, createSubagent, createSuspendController, createTool, createToolkit, createVoltAgentObservability, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, extractFileParts, extractImageParts, extractText, extractTextParts, extractWorkflowStepInfo, filterContentParts, getContentLength, getEnvVar, getGlobalLogBuffer, getGlobalLogger, getNodeTypeFromNodeId, getWorkflowStepNodeType, hasContent, hasFilePart, hasImagePart, hasTextPart, isAbortError, isNodeRuntime, isServerlessRuntime, isStructuredContent, isTextContent, isVoltAgentError, mapMessageContent, messageHelpers, normalizeContent, normalizeToArray, prependToMessage, readableLogRecordToObservabilityLog, readableSpanToObservabilitySpan, safeJsonParse, serializeValueForDebug, tool, transformTextContent, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
|
package/dist/index.d.ts
CHANGED
|
@@ -158,7 +158,7 @@ declare class ToolManager {
|
|
|
158
158
|
* @returns The result of the tool execution
|
|
159
159
|
* @throws Error if the tool doesn't exist or fails to execute
|
|
160
160
|
*/
|
|
161
|
-
executeTool(toolName: string, args:
|
|
161
|
+
executeTool(toolName: string, args: unknown, options?: ToolExecuteOptions): Promise<unknown>;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
/**
|
|
@@ -192,7 +192,7 @@ type ToolOptions<T extends ToolSchema = ToolSchema, O extends ToolSchema | undef
|
|
|
192
192
|
/**
|
|
193
193
|
* Function to execute when the tool is called
|
|
194
194
|
*/
|
|
195
|
-
execute
|
|
195
|
+
execute?: (args: z.infer<T>, context?: OperationContext) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
|
|
196
196
|
};
|
|
197
197
|
/**
|
|
198
198
|
* Tool class for defining tools that agents can use
|
|
@@ -221,7 +221,12 @@ declare class Tool<T extends ToolSchema = ToolSchema, O extends ToolSchema | und
|
|
|
221
221
|
/**
|
|
222
222
|
* Function to execute when the tool is called
|
|
223
223
|
*/
|
|
224
|
-
readonly execute
|
|
224
|
+
readonly execute?: (args: z.infer<T>, context?: OperationContext) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
|
|
225
|
+
/**
|
|
226
|
+
* Whether this tool should be executed on the client side.
|
|
227
|
+
* Returns true when no server-side execute handler is provided.
|
|
228
|
+
*/
|
|
229
|
+
readonly isClientSide: () => boolean;
|
|
225
230
|
/**
|
|
226
231
|
* Create a new tool
|
|
227
232
|
*/
|
|
@@ -3447,6 +3452,20 @@ type ModelToolCall = {
|
|
|
3447
3452
|
toolName: string;
|
|
3448
3453
|
args: Record<string, unknown>;
|
|
3449
3454
|
};
|
|
3455
|
+
/**
|
|
3456
|
+
* Represents the payload used when sending a tool's result back to the chat runtime
|
|
3457
|
+
* via useChat().addToolResult in the Vercel AI SDK.
|
|
3458
|
+
*/
|
|
3459
|
+
type ClientSideToolResult = {
|
|
3460
|
+
tool: string;
|
|
3461
|
+
toolCallId: string;
|
|
3462
|
+
output: unknown;
|
|
3463
|
+
} | {
|
|
3464
|
+
tool: string;
|
|
3465
|
+
toolCallId: string;
|
|
3466
|
+
state: "output-error";
|
|
3467
|
+
errorText: string;
|
|
3468
|
+
};
|
|
3450
3469
|
/**
|
|
3451
3470
|
* Agent response format
|
|
3452
3471
|
*/
|
|
@@ -3869,7 +3888,7 @@ declare class Agent {
|
|
|
3869
3888
|
readonly purpose?: string;
|
|
3870
3889
|
readonly instructions: InstructionsDynamicValue;
|
|
3871
3890
|
readonly model: LanguageModel | DynamicValue<LanguageModel>;
|
|
3872
|
-
readonly
|
|
3891
|
+
readonly dynamicTools?: DynamicValue<(Tool<any, any> | Toolkit)[]>;
|
|
3873
3892
|
readonly hooks: AgentHooks;
|
|
3874
3893
|
readonly temperature?: number;
|
|
3875
3894
|
readonly maxOutputTokens?: number;
|
|
@@ -4610,6 +4629,15 @@ interface WorkflowStreamWriter {
|
|
|
4610
4629
|
filter?: (part: DangerouslyAllowAny) => boolean;
|
|
4611
4630
|
}): Promise<void>;
|
|
4612
4631
|
}
|
|
4632
|
+
/**
|
|
4633
|
+
* The state parameter passed to workflow steps
|
|
4634
|
+
*/
|
|
4635
|
+
type WorkflowStepState<INPUT> = Omit<WorkflowState<INPUT, DangerouslyAllowAny>, "data" | "result"> & {
|
|
4636
|
+
/** Workflow execution context for event tracking */
|
|
4637
|
+
workflowContext?: WorkflowExecutionContext;
|
|
4638
|
+
/** AbortSignal for checking suspension during step execution */
|
|
4639
|
+
signal?: AbortSignal;
|
|
4640
|
+
};
|
|
4613
4641
|
|
|
4614
4642
|
/**
|
|
4615
4643
|
* WorkflowTraceContext - Manages trace hierarchy and common attributes for workflows
|
|
@@ -4938,8 +4966,8 @@ type ExtractExecuteResult<T> = T extends {
|
|
|
4938
4966
|
execute: (...args: any[]) => infer R;
|
|
4939
4967
|
} ? R extends Promise<infer U> ? U : R : never;
|
|
4940
4968
|
|
|
4941
|
-
type AgentConfig$1<SCHEMA extends z.ZodTypeAny> = BaseGenerationOptions & {
|
|
4942
|
-
schema: SCHEMA;
|
|
4969
|
+
type AgentConfig$1<SCHEMA extends z.ZodTypeAny, INPUT, DATA> = BaseGenerationOptions & {
|
|
4970
|
+
schema: SCHEMA | ((context: Omit<WorkflowExecuteContext<INPUT, DATA, any, any>, "suspend" | "writer">) => SCHEMA | Promise<SCHEMA>);
|
|
4943
4971
|
};
|
|
4944
4972
|
/**
|
|
4945
4973
|
* Creates an agent step for a workflow
|
|
@@ -4964,7 +4992,7 @@ type AgentConfig$1<SCHEMA extends z.ZodTypeAny> = BaseGenerationOptions & {
|
|
|
4964
4992
|
* @param config - The config for the agent (schema) `generateObject` call
|
|
4965
4993
|
* @returns A workflow step that executes the agent with the task
|
|
4966
4994
|
*/
|
|
4967
|
-
declare function andAgent<INPUT, DATA, SCHEMA extends z.ZodTypeAny>(task: UIMessage[] | ModelMessage[] | string | InternalWorkflowFunc<INPUT, DATA, UIMessage[] | ModelMessage[] | string, any, any>, agent: Agent, config: AgentConfig$1<SCHEMA>): {
|
|
4995
|
+
declare function andAgent<INPUT, DATA, SCHEMA extends z.ZodTypeAny>(task: UIMessage[] | ModelMessage[] | string | InternalWorkflowFunc<INPUT, DATA, UIMessage[] | ModelMessage[] | string, any, any>, agent: Agent, config: AgentConfig$1<SCHEMA, INPUT, DATA>): {
|
|
4968
4996
|
type: "agent";
|
|
4969
4997
|
id: string;
|
|
4970
4998
|
name: string;
|
|
@@ -5373,8 +5401,8 @@ interface SerializedWorkflowStep {
|
|
|
5373
5401
|
/**
|
|
5374
5402
|
* Agent configuration for the chain
|
|
5375
5403
|
*/
|
|
5376
|
-
type AgentConfig<SCHEMA extends z.ZodTypeAny> = {
|
|
5377
|
-
schema: SCHEMA;
|
|
5404
|
+
type AgentConfig<SCHEMA extends z.ZodTypeAny, INPUT_SCHEMA extends InternalBaseWorkflowInputSchema, CURRENT_DATA> = BaseGenerationOptions & {
|
|
5405
|
+
schema: SCHEMA | ((context: Omit<WorkflowExecuteContext<WorkflowInput<INPUT_SCHEMA>, CURRENT_DATA, any, any>, "suspend" | "writer">) => SCHEMA | Promise<SCHEMA>);
|
|
5378
5406
|
};
|
|
5379
5407
|
/**
|
|
5380
5408
|
* A workflow chain that provides a fluent API for building workflows
|
|
@@ -5451,7 +5479,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5451
5479
|
* @param config - The config for the agent (schema) `generateObject` call
|
|
5452
5480
|
* @returns A workflow step that executes the agent with the task
|
|
5453
5481
|
*/
|
|
5454
|
-
andAgent<SCHEMA extends z.ZodTypeAny>(task: string | UIMessage[] | ModelMessage[] | InternalWorkflowFunc<INPUT_SCHEMA
|
|
5482
|
+
andAgent<SCHEMA extends z.ZodTypeAny>(task: string | UIMessage[] | ModelMessage[] | InternalWorkflowFunc<WorkflowInput<INPUT_SCHEMA>, CURRENT_DATA, string | UIMessage[] | ModelMessage[], any, any>, agent: Agent, config: AgentConfig<SCHEMA, INPUT_SCHEMA, CURRENT_DATA>): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, z.infer<SCHEMA>, SUSPEND_SCHEMA, RESUME_SCHEMA>;
|
|
5455
5483
|
/**
|
|
5456
5484
|
* Add a function step to the workflow with both input and output schemas
|
|
5457
5485
|
* @param config - Step configuration with schemas
|
|
@@ -5464,7 +5492,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5464
5492
|
resumeSchema?: RS;
|
|
5465
5493
|
execute: (context: {
|
|
5466
5494
|
data: z.infer<IS>;
|
|
5467
|
-
state:
|
|
5495
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5468
5496
|
getStepData: (stepId: string) => {
|
|
5469
5497
|
input: any;
|
|
5470
5498
|
output: any;
|
|
@@ -5490,7 +5518,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5490
5518
|
resumeSchema?: RS;
|
|
5491
5519
|
execute: (context: {
|
|
5492
5520
|
data: z.infer<IS>;
|
|
5493
|
-
state:
|
|
5521
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5494
5522
|
getStepData: (stepId: string) => {
|
|
5495
5523
|
input: any;
|
|
5496
5524
|
output: any;
|
|
@@ -5516,7 +5544,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5516
5544
|
resumeSchema?: RS;
|
|
5517
5545
|
execute: (context: {
|
|
5518
5546
|
data: CURRENT_DATA;
|
|
5519
|
-
state:
|
|
5547
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5520
5548
|
getStepData: (stepId: string) => {
|
|
5521
5549
|
input: any;
|
|
5522
5550
|
output: any;
|
|
@@ -5542,7 +5570,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5542
5570
|
resumeSchema: RS;
|
|
5543
5571
|
execute: (context: {
|
|
5544
5572
|
data: CURRENT_DATA;
|
|
5545
|
-
state:
|
|
5573
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5546
5574
|
getStepData: (stepId: string) => {
|
|
5547
5575
|
input: any;
|
|
5548
5576
|
output: any;
|
|
@@ -5584,7 +5612,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5584
5612
|
andThen<NEW_DATA>(config: {
|
|
5585
5613
|
execute: (context: {
|
|
5586
5614
|
data: CURRENT_DATA;
|
|
5587
|
-
state:
|
|
5615
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5588
5616
|
getStepData: (stepId: string) => {
|
|
5589
5617
|
input: any;
|
|
5590
5618
|
output: any;
|
|
@@ -5614,7 +5642,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5614
5642
|
resumeSchema?: RS;
|
|
5615
5643
|
condition: (context: {
|
|
5616
5644
|
data: z.infer<IS>;
|
|
5617
|
-
state:
|
|
5645
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5618
5646
|
getStepData: (stepId: string) => {
|
|
5619
5647
|
input: any;
|
|
5620
5648
|
output: any;
|
|
@@ -5675,7 +5703,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5675
5703
|
resumeSchema?: RS;
|
|
5676
5704
|
execute: (context: {
|
|
5677
5705
|
data: z.infer<IS>;
|
|
5678
|
-
state:
|
|
5706
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5679
5707
|
getStepData: (stepId: string) => {
|
|
5680
5708
|
input: any;
|
|
5681
5709
|
output: any;
|
|
@@ -5716,7 +5744,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5716
5744
|
andTap<_NEW_DATA>(config: {
|
|
5717
5745
|
execute: (context: {
|
|
5718
5746
|
data: CURRENT_DATA;
|
|
5719
|
-
state:
|
|
5747
|
+
state: WorkflowStepState<WorkflowInput<INPUT_SCHEMA>>;
|
|
5720
5748
|
getStepData: (stepId: string) => {
|
|
5721
5749
|
input: any;
|
|
5722
5750
|
output: any;
|
|
@@ -7637,4 +7665,4 @@ declare class VoltAgent {
|
|
|
7637
7665
|
*/
|
|
7638
7666
|
declare function convertUsage(usage: LanguageModelUsage | undefined): UsageInfo | undefined;
|
|
7639
7667
|
|
|
7640
|
-
export { A2AServerRegistry, AbortError, Agent, type AgentFullState, type AgentHookOnEnd, type AgentHookOnError, type AgentHookOnHandoff, type AgentHookOnPrepareMessages, type AgentHookOnPrepareModelMessages, type AgentHookOnStart, type AgentHookOnStepFinish, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentStatus, type AgentTool, AiSdkEmbeddingAdapter, type AllowedVariableValue, type ApiToolInfo, type BaseEventMetadata, type BaseGenerationOptions, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTool, type BaseToolCall, type CachedPrompt, type ChatMessage, ClientHTTPError, type CloudflareFetchHandler, type Conversation, ConversationAlreadyExistsError, ConversationNotFoundError, type ConversationQueryOptions, type ConversationQueryOptions as ConversationQueryOptionsV2, type Conversation as ConversationV2, type CreateConversationInput, type CreateConversationInput as CreateConversationInputV2, type CreateReasoningToolsOptions, DEFAULT_INSTRUCTIONS, type DataContent, type Document, type DynamicValue, type DynamicValueOptions, type EmbeddingAdapter$1 as EmbeddingAdapter, EmbeddingAdapterNotConfiguredError, EmbeddingError, type ExtractVariableNames, FEW_SHOT_EXAMPLES, type GenerateObjectOptions, type GenerateObjectSubAgentConfig, type GenerateTextOptions, type GenerateTextSubAgentConfig, type GetMessagesOptions, type IServerProvider, type IServerlessProvider, type VoltOpsClient$1 as IVoltOpsClient, InMemoryStorageAdapter$1 as InMemoryObservabilityAdapter, InMemoryStorageAdapter, InMemoryVectorAdapter, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type LLMProvider, LazyRemoteExportProcessor, LocalStorageSpanProcessor, type LogFilter, LoggerProxy, MCPConfiguration, type MCPElicitationAdapter, type MCPLoggingAdapter, type MCPPromptsAdapter, type MCPResourcesAdapter, MCPServerRegistry, type ManagedMemoryAddMessageInput, type ManagedMemoryAddMessagesInput, type ManagedMemoryClearMessagesInput, type ManagedMemoryConnectionInfo, type ManagedMemoryConversationsClient, type ManagedMemoryCredentialCreateResult, type ManagedMemoryCredentialListResult, type ManagedMemoryCredentialSummary, type ManagedMemoryDatabaseSummary, type ManagedMemoryGetMessagesInput, type ManagedMemoryMessagesClient, type ManagedMemorySetWorkingMemoryInput, type ManagedMemoryStatus, type ManagedMemoryUpdateConversationInput, type ManagedMemoryVoltOpsClient, type ManagedMemoryWorkflowStateUpdateInput, type ManagedMemoryWorkflowStatesClient, type ManagedMemoryWorkingMemoryClient, type ManagedMemoryWorkingMemoryInput, Memory, type MemoryConfig, type MemoryOptions, type MemoryStorageMetadata, type MemoryUpdateMode, Memory as MemoryV2, MemoryV2Error, type MessageContent, MessageContentBuilder, type MessageRole, type ModelToolCall, NextAction, NodeType, VoltAgentObservability$1 as NodeVoltAgentObservability, type ObservabilityConfig, type ObservabilityLogRecord, type ObservabilitySpan, type ObservabilityStorageAdapter, type ObservabilityWebSocketEvent, type OnEndHookArgs, type OnErrorHookArgs, type OnHandoffHookArgs, type OnPrepareMessagesHookArgs, type OnPrepareMessagesHookResult, type OnPrepareModelMessagesHookArgs, type OnPrepareModelMessagesHookResult, type OnStartHookArgs, type OnStepFinishHookArgs, type OnToolEndHookArgs, type OnToolStartHookArgs, type OperationContext, type PackageUpdateInfo, type PromptApiClient, type PromptApiResponse, type PromptContent, type PromptCreator, type PromptHelper, type PromptReference, type PromptTemplate, type ProviderObjectResponse, type ProviderObjectStreamResponse, type ProviderParams, type ProviderResponse, type ProviderTextResponse, type ProviderTextStreamResponse, type ReadableStreamType, type ReasoningStep, ReasoningStepSchema, type RegisterOptions, type RegisteredWorkflow, type RemoteLogExportConfig, RemoteLogProcessor, type RetrieveOptions, type Retriever, type RetrieverOptions, type SearchOptions, type SearchResult, type ServerAgentResponse, type ServerApiResponse, type ServerProviderDeps, type ServerProviderFactory, type ServerWorkflowResponse, type ServerlessProviderFactory, type ServerlessRemoteEndpointConfig, type ServerlessRemoteExportConfig, type ServerlessRequestHandler, ServerlessVoltAgentObservability, type SpanAttributes, type SpanEvent, type SpanFilterConfig, SpanFilterProcessor, SpanKind, type SpanLink, type SpanStatus, SpanStatusCode, type SpanTreeNode, type StepChunkCallback, type StepFinishCallback, type StepWithContent, type StopWhen, type StorageAdapter, StorageError, StorageLogProcessor, type StoredUIMessage, type StreamObjectFinishResult, type StreamObjectOnFinishCallback, type StreamObjectOptions, type StreamObjectSubAgentConfig, type StreamPart, type StreamTextFinishResult, type StreamTextOnFinishCallback, type StreamTextOptions, type StreamTextSubAgentConfig, type SubAgentConfig, type SubAgentMethod, type SubAgentStateData, type SupervisorConfig, type TemplateVariables, type TimelineEventCoreLevel, type TimelineEventCoreStatus, type TimelineEventCoreType, Tool, type ToolCall, ToolDeniedError, type ToolErrorInfo, type ToolExecuteOptions, ToolManager, type ToolOptions, type ToolSchema, type ToolStatus, type ToolStatusInfo, type ToolWithNodeId, type Toolkit, type Usage, type UsageInfo, type VectorAdapter, VectorAdapterNotConfiguredError, VectorError, type VectorItem, type VectorSearchOptions, type Voice, type VoiceEventData, type VoiceEventType, type VoiceMetadata, type VoiceOptions, VoltAgent, VoltAgentError, VoltAgentObservability, type VoltAgentOptions, type VoltAgentStreamTextResult, type VoltAgentTextStreamPart, VoltOpsClient, type VoltOpsClientOptions, VoltOpsPromptApiClient, type VoltOpsPromptManager, VoltOpsPromptManagerImpl, WebSocketEventEmitter, WebSocketLogProcessor, WebSocketSpanProcessor, type Workflow, type WorkflowConfig, type WorkflowExecutionContext, WorkflowRegistry, type WorkflowStateEntry, type WorkflowStats, type WorkflowStepContext, type WorkflowStepType, type WorkflowTimelineEvent, type WorkingMemoryConfig, type WorkingMemoryScope, type WorkingMemorySummary, type WorkingMemoryUpdateOptions, addTimestampToMessage, andAgent, andAll, andRace, andTap, andThen, andWhen, andWorkflow, appendToMessage, buildRetrieverLogMessage, buildSpanTree, checkForUpdates, convertUsage, cosineSimilarity, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createSimpleTemplateEngine, createSubagent, createSuspendController, createTool, createToolkit, createVoltAgentObservability, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, extractFileParts, extractImageParts, extractText, extractTextParts, extractWorkflowStepInfo, filterContentParts, getContentLength, getEnvVar, getGlobalLogBuffer, getGlobalLogger, getNodeTypeFromNodeId, getWorkflowStepNodeType, hasContent, hasFilePart, hasImagePart, hasTextPart, isAbortError, isNodeRuntime, isServerlessRuntime, isStructuredContent, isTextContent, isVoltAgentError, mapMessageContent, messageHelpers, normalizeContent, normalizeToArray, prependToMessage, readableLogRecordToObservabilityLog, readableSpanToObservabilitySpan, safeJsonParse, serializeValueForDebug, tool, transformTextContent, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
|
|
7668
|
+
export { A2AServerRegistry, AbortError, Agent, type AgentFullState, type AgentHookOnEnd, type AgentHookOnError, type AgentHookOnHandoff, type AgentHookOnPrepareMessages, type AgentHookOnPrepareModelMessages, type AgentHookOnStart, type AgentHookOnStepFinish, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentStatus, type AgentTool, AiSdkEmbeddingAdapter, type AllowedVariableValue, type ApiToolInfo, type BaseEventMetadata, type BaseGenerationOptions, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTool, type BaseToolCall, type CachedPrompt, type ChatMessage, ClientHTTPError, type ClientSideToolResult, type CloudflareFetchHandler, type Conversation, ConversationAlreadyExistsError, ConversationNotFoundError, type ConversationQueryOptions, type ConversationQueryOptions as ConversationQueryOptionsV2, type Conversation as ConversationV2, type CreateConversationInput, type CreateConversationInput as CreateConversationInputV2, type CreateReasoningToolsOptions, DEFAULT_INSTRUCTIONS, type DataContent, type Document, type DynamicValue, type DynamicValueOptions, type EmbeddingAdapter$1 as EmbeddingAdapter, EmbeddingAdapterNotConfiguredError, EmbeddingError, type ExtractVariableNames, FEW_SHOT_EXAMPLES, type GenerateObjectOptions, type GenerateObjectSubAgentConfig, type GenerateTextOptions, type GenerateTextSubAgentConfig, type GetMessagesOptions, type IServerProvider, type IServerlessProvider, type VoltOpsClient$1 as IVoltOpsClient, InMemoryStorageAdapter$1 as InMemoryObservabilityAdapter, InMemoryStorageAdapter, InMemoryVectorAdapter, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type LLMProvider, LazyRemoteExportProcessor, LocalStorageSpanProcessor, type LogFilter, LoggerProxy, MCPConfiguration, type MCPElicitationAdapter, type MCPLoggingAdapter, type MCPPromptsAdapter, type MCPResourcesAdapter, MCPServerRegistry, type ManagedMemoryAddMessageInput, type ManagedMemoryAddMessagesInput, type ManagedMemoryClearMessagesInput, type ManagedMemoryConnectionInfo, type ManagedMemoryConversationsClient, type ManagedMemoryCredentialCreateResult, type ManagedMemoryCredentialListResult, type ManagedMemoryCredentialSummary, type ManagedMemoryDatabaseSummary, type ManagedMemoryGetMessagesInput, type ManagedMemoryMessagesClient, type ManagedMemorySetWorkingMemoryInput, type ManagedMemoryStatus, type ManagedMemoryUpdateConversationInput, type ManagedMemoryVoltOpsClient, type ManagedMemoryWorkflowStateUpdateInput, type ManagedMemoryWorkflowStatesClient, type ManagedMemoryWorkingMemoryClient, type ManagedMemoryWorkingMemoryInput, Memory, type MemoryConfig, type MemoryOptions, type MemoryStorageMetadata, type MemoryUpdateMode, Memory as MemoryV2, MemoryV2Error, type MessageContent, MessageContentBuilder, type MessageRole, type ModelToolCall, NextAction, NodeType, VoltAgentObservability$1 as NodeVoltAgentObservability, type ObservabilityConfig, type ObservabilityLogRecord, type ObservabilitySpan, type ObservabilityStorageAdapter, type ObservabilityWebSocketEvent, type OnEndHookArgs, type OnErrorHookArgs, type OnHandoffHookArgs, type OnPrepareMessagesHookArgs, type OnPrepareMessagesHookResult, type OnPrepareModelMessagesHookArgs, type OnPrepareModelMessagesHookResult, type OnStartHookArgs, type OnStepFinishHookArgs, type OnToolEndHookArgs, type OnToolStartHookArgs, type OperationContext, type PackageUpdateInfo, type PromptApiClient, type PromptApiResponse, type PromptContent, type PromptCreator, type PromptHelper, type PromptReference, type PromptTemplate, type ProviderObjectResponse, type ProviderObjectStreamResponse, type ProviderParams, type ProviderResponse, type ProviderTextResponse, type ProviderTextStreamResponse, type ReadableStreamType, type ReasoningStep, ReasoningStepSchema, type RegisterOptions, type RegisteredWorkflow, type RemoteLogExportConfig, RemoteLogProcessor, type RetrieveOptions, type Retriever, type RetrieverOptions, type SearchOptions, type SearchResult, type ServerAgentResponse, type ServerApiResponse, type ServerProviderDeps, type ServerProviderFactory, type ServerWorkflowResponse, type ServerlessProviderFactory, type ServerlessRemoteEndpointConfig, type ServerlessRemoteExportConfig, type ServerlessRequestHandler, ServerlessVoltAgentObservability, type SpanAttributes, type SpanEvent, type SpanFilterConfig, SpanFilterProcessor, SpanKind, type SpanLink, type SpanStatus, SpanStatusCode, type SpanTreeNode, type StepChunkCallback, type StepFinishCallback, type StepWithContent, type StopWhen, type StorageAdapter, StorageError, StorageLogProcessor, type StoredUIMessage, type StreamObjectFinishResult, type StreamObjectOnFinishCallback, type StreamObjectOptions, type StreamObjectSubAgentConfig, type StreamPart, type StreamTextFinishResult, type StreamTextOnFinishCallback, type StreamTextOptions, type StreamTextSubAgentConfig, type SubAgentConfig, type SubAgentMethod, type SubAgentStateData, type SupervisorConfig, type TemplateVariables, type TimelineEventCoreLevel, type TimelineEventCoreStatus, type TimelineEventCoreType, Tool, type ToolCall, ToolDeniedError, type ToolErrorInfo, type ToolExecuteOptions, ToolManager, type ToolOptions, type ToolSchema, type ToolStatus, type ToolStatusInfo, type ToolWithNodeId, type Toolkit, type Usage, type UsageInfo, type VectorAdapter, VectorAdapterNotConfiguredError, VectorError, type VectorItem, type VectorSearchOptions, type Voice, type VoiceEventData, type VoiceEventType, type VoiceMetadata, type VoiceOptions, VoltAgent, VoltAgentError, VoltAgentObservability, type VoltAgentOptions, type VoltAgentStreamTextResult, type VoltAgentTextStreamPart, VoltOpsClient, type VoltOpsClientOptions, VoltOpsPromptApiClient, type VoltOpsPromptManager, VoltOpsPromptManagerImpl, WebSocketEventEmitter, WebSocketLogProcessor, WebSocketSpanProcessor, type Workflow, type WorkflowConfig, type WorkflowExecutionContext, WorkflowRegistry, type WorkflowStateEntry, type WorkflowStats, type WorkflowStepContext, type WorkflowStepType, type WorkflowTimelineEvent, type WorkingMemoryConfig, type WorkingMemoryScope, type WorkingMemorySummary, type WorkingMemoryUpdateOptions, addTimestampToMessage, andAgent, andAll, andRace, andTap, andThen, andWhen, andWorkflow, appendToMessage, buildRetrieverLogMessage, buildSpanTree, checkForUpdates, convertUsage, cosineSimilarity, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createSimpleTemplateEngine, createSubagent, createSuspendController, createTool, createToolkit, createVoltAgentObservability, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, extractFileParts, extractImageParts, extractText, extractTextParts, extractWorkflowStepInfo, filterContentParts, getContentLength, getEnvVar, getGlobalLogBuffer, getGlobalLogger, getNodeTypeFromNodeId, getWorkflowStepNodeType, hasContent, hasFilePart, hasImagePart, hasTextPart, isAbortError, isNodeRuntime, isServerlessRuntime, isStructuredContent, isTextContent, isVoltAgentError, mapMessageContent, messageHelpers, normalizeContent, normalizeToArray, prependToMessage, readableLogRecordToObservabilityLog, readableSpanToObservabilitySpan, safeJsonParse, serializeValueForDebug, tool, transformTextContent, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
|
package/dist/index.js
CHANGED
|
@@ -329,8 +329,9 @@ function andAgent(task, agent, config) {
|
|
|
329
329
|
const { state } = context8;
|
|
330
330
|
const { schema, ...restConfig } = config;
|
|
331
331
|
const finalTask = typeof task === "function" ? await task(context8) : task;
|
|
332
|
+
const finalSchema = typeof schema === "function" ? await schema(context8) : schema;
|
|
332
333
|
if (!state.workflowContext) {
|
|
333
|
-
const result = await agent.generateObject(finalTask,
|
|
334
|
+
const result = await agent.generateObject(finalTask, finalSchema, {
|
|
334
335
|
...restConfig,
|
|
335
336
|
context: restConfig.context ?? state.context,
|
|
336
337
|
conversationId: restConfig.conversationId ?? state.conversationId,
|
|
@@ -352,7 +353,7 @@ function andAgent(task, agent, config) {
|
|
|
352
353
|
return result.object;
|
|
353
354
|
}
|
|
354
355
|
try {
|
|
355
|
-
const result = await agent.generateObject(finalTask,
|
|
356
|
+
const result = await agent.generateObject(finalTask, finalSchema, {
|
|
356
357
|
...restConfig,
|
|
357
358
|
context: restConfig.context ?? state.context,
|
|
358
359
|
conversationId: restConfig.conversationId ?? state.conversationId,
|
|
@@ -400,6 +401,7 @@ function convertWorkflowStateToParam(state, executionContext, signal) {
|
|
|
400
401
|
error: state.error,
|
|
401
402
|
usage: state.usage,
|
|
402
403
|
suspension: state.suspension,
|
|
404
|
+
cancellation: state.cancellation,
|
|
403
405
|
workflowContext: executionContext,
|
|
404
406
|
signal
|
|
405
407
|
};
|
|
@@ -8012,9 +8014,6 @@ var ToolManager = class _ToolManager {
|
|
|
8012
8014
|
if (!tool2 || !tool2.name) {
|
|
8013
8015
|
throw new Error("Cannot add an invalid or unnamed tool.");
|
|
8014
8016
|
}
|
|
8015
|
-
if (!tool2.execute || typeof tool2.execute !== "function") {
|
|
8016
|
-
throw new Error(`Tool ${tool2.name} must have an execute function`);
|
|
8017
|
-
}
|
|
8018
8017
|
const conflictsWithToolkitTool = this.toolkits.some(
|
|
8019
8018
|
(toolkit) => toolkit.tools.some((t) => t.name === tool2.name)
|
|
8020
8019
|
);
|
|
@@ -8097,13 +8096,7 @@ var ToolManager = class _ToolManager {
|
|
|
8097
8096
|
);
|
|
8098
8097
|
}
|
|
8099
8098
|
} else {
|
|
8100
|
-
|
|
8101
|
-
this.addTool(item);
|
|
8102
|
-
} else {
|
|
8103
|
-
this.logger.warn(
|
|
8104
|
-
`[ToolManager] Skipping tool '${item.name}' due to missing or invalid 'execute' function.`
|
|
8105
|
-
);
|
|
8106
|
-
}
|
|
8099
|
+
this.addTool(item);
|
|
8107
8100
|
}
|
|
8108
8101
|
}
|
|
8109
8102
|
}
|
|
@@ -8328,6 +8321,13 @@ var Tool = class {
|
|
|
8328
8321
|
* Function to execute when the tool is called
|
|
8329
8322
|
*/
|
|
8330
8323
|
execute;
|
|
8324
|
+
/**
|
|
8325
|
+
* Whether this tool should be executed on the client side.
|
|
8326
|
+
* Returns true when no server-side execute handler is provided.
|
|
8327
|
+
*/
|
|
8328
|
+
isClientSide = /* @__PURE__ */ __name(() => {
|
|
8329
|
+
return typeof this.execute !== "function";
|
|
8330
|
+
}, "isClientSide");
|
|
8331
8331
|
/**
|
|
8332
8332
|
* Create a new tool
|
|
8333
8333
|
*/
|
|
@@ -8342,9 +8342,6 @@ var Tool = class {
|
|
|
8342
8342
|
if (!options.parameters) {
|
|
8343
8343
|
throw new Error(`Tool '${options.name}' parameters schema is required`);
|
|
8344
8344
|
}
|
|
8345
|
-
if (!options.execute) {
|
|
8346
|
-
throw new Error(`Tool '${options.name}' execute function is required`);
|
|
8347
|
-
}
|
|
8348
8345
|
this.id = options.id || (0, import_uuid2.v4)();
|
|
8349
8346
|
this.name = options.name;
|
|
8350
8347
|
this.description = options.description || "";
|
|
@@ -11213,7 +11210,7 @@ var Agent = class {
|
|
|
11213
11210
|
purpose;
|
|
11214
11211
|
instructions;
|
|
11215
11212
|
model;
|
|
11216
|
-
|
|
11213
|
+
dynamicTools;
|
|
11217
11214
|
hooks;
|
|
11218
11215
|
temperature;
|
|
11219
11216
|
maxOutputTokens;
|
|
@@ -11238,7 +11235,7 @@ var Agent = class {
|
|
|
11238
11235
|
this.purpose = options.purpose;
|
|
11239
11236
|
this.instructions = options.instructions;
|
|
11240
11237
|
this.model = options.model;
|
|
11241
|
-
this.
|
|
11238
|
+
this.dynamicTools = typeof options.tools === "function" ? options.tools : void 0;
|
|
11242
11239
|
this.hooks = options.hooks || {};
|
|
11243
11240
|
this.temperature = options.temperature;
|
|
11244
11241
|
this.maxOutputTokens = options.maxOutputTokens;
|
|
@@ -11268,7 +11265,7 @@ var Agent = class {
|
|
|
11268
11265
|
});
|
|
11269
11266
|
this.memory = options.memory;
|
|
11270
11267
|
this.memoryManager = new MemoryManager(this.id, this.memory, {}, this.logger);
|
|
11271
|
-
const staticTools = typeof
|
|
11268
|
+
const staticTools = typeof options.tools === "function" ? [] : options.tools;
|
|
11272
11269
|
this.toolManager = new ToolManager(staticTools, this.logger);
|
|
11273
11270
|
if (options.toolkits) {
|
|
11274
11271
|
this.toolManager.addItems(options.toolkits);
|
|
@@ -11974,8 +11971,6 @@ var Agent = class {
|
|
|
11974
11971
|
* Common preparation for all execution methods
|
|
11975
11972
|
*/
|
|
11976
11973
|
async prepareExecution(input, oc, options) {
|
|
11977
|
-
const model = await this.resolveValue(this.model, oc);
|
|
11978
|
-
const agentToolList = await this.resolveValue(this.tools, oc);
|
|
11979
11974
|
const buffer = this.getConversationBuffer(oc);
|
|
11980
11975
|
const uiMessages = await this.prepareMessages(input, oc, options, buffer);
|
|
11981
11976
|
const hooks = this.getMergedHooks(options);
|
|
@@ -11992,9 +11987,10 @@ var Agent = class {
|
|
|
11992
11987
|
}
|
|
11993
11988
|
}
|
|
11994
11989
|
const maxSteps = options?.maxSteps ?? this.calculateMaxSteps();
|
|
11995
|
-
const
|
|
11990
|
+
const model = await this.resolveValue(this.model, oc);
|
|
11991
|
+
const dynamicToolList = await this.resolveValue(this.dynamicTools, oc) || [];
|
|
11996
11992
|
const optionToolsArray = options?.tools || [];
|
|
11997
|
-
const mergedTools = [...
|
|
11993
|
+
const mergedTools = [...dynamicToolList, ...optionToolsArray];
|
|
11998
11994
|
const tools = await this.prepareTools(mergedTools, oc, maxSteps, options);
|
|
11999
11995
|
return {
|
|
12000
11996
|
messages,
|
|
@@ -12726,8 +12722,14 @@ ${toolkit.instructions}`;
|
|
|
12726
12722
|
for (const tool2 of tools) {
|
|
12727
12723
|
aiTools[tool2.name] = {
|
|
12728
12724
|
description: tool2.description,
|
|
12729
|
-
inputSchema: tool2.parameters
|
|
12725
|
+
inputSchema: tool2.parameters
|
|
12730
12726
|
// AI SDK will convert this to JSON Schema internally
|
|
12727
|
+
};
|
|
12728
|
+
if (tool2.isClientSide()) {
|
|
12729
|
+
continue;
|
|
12730
|
+
}
|
|
12731
|
+
aiTools[tool2.name] = {
|
|
12732
|
+
...aiTools[tool2.name],
|
|
12731
12733
|
execute: /* @__PURE__ */ __name(async (args) => {
|
|
12732
12734
|
const toolSpan = oc.traceContext.createChildSpan(`tool.execution:${tool2.name}`, "tool", {
|
|
12733
12735
|
label: tool2.name,
|
|
@@ -12744,6 +12746,9 @@ ${toolkit.instructions}`;
|
|
|
12744
12746
|
return await oc.traceContext.withSpan(toolSpan, async () => {
|
|
12745
12747
|
try {
|
|
12746
12748
|
await hooks.onToolStart?.({ agent: this, tool: tool2, context: oc, args });
|
|
12749
|
+
if (!tool2.execute) {
|
|
12750
|
+
throw new Error(`Tool ${tool2.name} does not have "execute" method`);
|
|
12751
|
+
}
|
|
12747
12752
|
const result = await tool2.execute(args, oc);
|
|
12748
12753
|
const validatedResult = await this.validateToolOutput(result, tool2);
|
|
12749
12754
|
toolSpan.setAttribute("output", (0, import_utils12.safeStringify)(result));
|