@voltagent/core 2.0.12 → 2.0.14

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 CHANGED
@@ -192,7 +192,7 @@ declare class ToolManager extends BaseToolManager<AgentTool | Tool$1 | Toolkit,
192
192
  * @returns true if the toolkit was successfully added or replaced.
193
193
  */
194
194
  addToolkit(toolkit: Toolkit): boolean;
195
- prepareToolsForExecution(createToolExecuteFunction: (tool: AgentTool) => (args: any, options?: ToolExecutionOptions) => Promise<any>): Record<string, any>;
195
+ prepareToolsForExecution(createToolExecuteFunction: (tool: AgentTool) => (args: any, options?: ToolExecutionOptions) => ToolExecutionResult<any>): Record<string, any>;
196
196
  /**
197
197
  * Get agent's tools (including those in toolkits) for API exposure.
198
198
  */
@@ -223,6 +223,7 @@ type ToolStatusInfo = {
223
223
  type JSONValue = string | number | boolean | null | {
224
224
  [key: string]: JSONValue;
225
225
  } | Array<JSONValue>;
226
+ type ToolExecutionResult<T> = PromiseLike<T> | AsyncIterable<T> | T;
226
227
  /**
227
228
  * Tool result output format for multi-modal content.
228
229
  * Matches AI SDK's LanguageModelV2ToolResultOutput type.
@@ -338,8 +339,9 @@ type ToolOptions<T extends ToolSchema = ToolSchema, O extends ToolSchema | undef
338
339
  * Function to execute when the tool is called.
339
340
  * @param args - The arguments passed to the tool
340
341
  * @param options - Optional execution options including context, abort signals, etc.
342
+ * @returns A result or an AsyncIterable of results (last value is final).
341
343
  */
342
- execute?: (args: z.infer<T>, options?: ToolExecuteOptions) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
344
+ execute?: (args: z.infer<T>, options?: ToolExecuteOptions) => ToolExecutionResult<O extends ToolSchema ? z.infer<O> : unknown>;
343
345
  };
344
346
  /**
345
347
  * Tool class for defining tools that agents can use
@@ -394,8 +396,9 @@ declare class Tool<T extends ToolSchema = ToolSchema, O extends ToolSchema | und
394
396
  * Function to execute when the tool is called.
395
397
  * @param args - The arguments passed to the tool
396
398
  * @param options - Optional execution options including context, abort signals, etc.
399
+ * @returns A result or an AsyncIterable of results (last value is final).
397
400
  */
398
- readonly execute?: (args: z.infer<T>, options?: ToolExecuteOptions) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
401
+ readonly execute?: (args: z.infer<T>, options?: ToolExecuteOptions) => ToolExecutionResult<O extends ToolSchema ? z.infer<O> : unknown>;
399
402
  /**
400
403
  * Whether this tool should be executed on the client side.
401
404
  * Returns true when no server-side execute handler is provided.
@@ -11879,4 +11882,4 @@ declare class VoltAgent {
11879
11882
  */
11880
11883
  declare function convertUsage(usage: LanguageModelUsage | undefined): UsageInfo | undefined;
11881
11884
 
11882
- export { A2AServerRegistry, AbortError, Agent, type AgentEvalConfig, type AgentEvalContext, type AgentEvalOperationType, type AgentEvalPayload, type AgentEvalResult, type AgentEvalSamplingPolicy, type AgentEvalScorerConfig, type AgentEvalScorerFactory, type AgentEvalScorerReference, type AgentFeedbackMetadata, type AgentFeedbackOptions, type AgentFullState, type AgentHookOnEnd, type AgentHookOnError, type AgentHookOnHandoff, type AgentHookOnHandoffComplete, type AgentHookOnPrepareMessages, type AgentHookOnPrepareModelMessages, type AgentHookOnStart, type AgentHookOnStepFinish, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentScorerState, type AgentStatus, type AgentSummarizationOptions, type AgentTool, AiSdkEmbeddingAdapter, type AllowedVariableValue, type ApiToolInfo, type BaseEventMetadata, type BaseGenerationOptions, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTool, type BaseToolCall, type BuildScorerOptions, type BuildScorerRunArgs, type BuildScorerRunResult, type BuilderAnalyzeContext, type BuilderPrepareContext, type BuilderReasonContext, type BuilderScoreContext, type CachedPrompt, type ChatMessage, ClientHTTPError, type ClientSideToolResult, type CloudflareFetchHandler, CompositeFilesystemBackend, type Conversation, ConversationAlreadyExistsError, ConversationNotFoundError, type ConversationQueryOptions, type ConversationQueryOptions as ConversationQueryOptionsV2, type ConversationStepRecord, type ConversationStepType, ConversationTodoBackend, type Conversation as ConversationV2, type CreateConversationInput, type CreateConversationInput as CreateConversationInputV2, type CreateInputGuardrailOptions, type CreateOutputGuardrailOptions, type CreateReasoningToolsOptions, type CreateScorerOptions, DEFAULT_INSTRUCTIONS, type DataContent, type Document, type DynamicValue, type DynamicValueOptions, EDIT_FILE_TOOL_DESCRIPTION, type EditResult, type EmbeddingAdapter$1 as EmbeddingAdapter, EmbeddingAdapterNotConfiguredError, EmbeddingError, type ExtractVariableNames, FEW_SHOT_EXAMPLES, FILESYSTEM_SYSTEM_PROMPT, type FileData, type FileInfo, type FilesystemBackend, type FilesystemBackendContext, type FilesystemBackendFactory, type FilesystemToolkitOptions, GLOB_TOOL_DESCRIPTION, GREP_TOOL_DESCRIPTION, type GenerateObjectOptions, type GenerateObjectResultWithContext, type GenerateObjectSubAgentConfig, type GenerateReasonResult, type GenerateScoreResult, type GenerateScoreStep, type GenerateTextOptions, type GenerateTextResultWithContext, type GenerateTextSubAgentConfig, type GetConversationStepsOptions, type GetMessagesOptions, type GrepMatch, type GuardrailAction, type GuardrailContext, type GuardrailDefinition, type GuardrailFunction, type GuardrailSeverity, type IServerProvider, type IServerlessProvider, type VoltOpsClient$1 as IVoltOpsClient, InMemoryFilesystemBackend, InMemoryStorageAdapter$1 as InMemoryObservabilityAdapter, InMemoryStorageAdapter, InMemoryVectorAdapter, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type InputGuardrail, type InputGuardrailArgs, type InputGuardrailResult, type KnowledgeBaseTagFilter, type LLMProvider, LS_TOOL_DESCRIPTION, LazyRemoteExportProcessor, type LocalScorerDefinition, type LocalScorerExecutionResult, LocalStorageSpanProcessor, type LogFilter, LoggerProxy, type MCPAuthorizationAction, type MCPAuthorizationConfig, type MCPAuthorizationContext, MCPAuthorizationError, type MCPCanFunction, type MCPCanParams, type MCPCanResult, MCPClient, type MCPClientCallOptions, type MCPClientConfig, MCPConfiguration, type MCPConfigurationOptions, type MCPElicitationAdapter, type MCPElicitationHandler, 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 ManagedMemoryQueryWorkflowRunsInput, 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, NodeFilesystemBackend, NodeType, VoltAgentObservability$1 as NodeVoltAgentObservability, type ObservabilityConfig, type ObservabilityLogRecord, type ObservabilitySpan, type ObservabilityStorageAdapter, type ObservabilityWebSocketEvent, type OnEndHookArgs, type OnErrorHookArgs, type OnHandoffCompleteHookArgs, type OnHandoffHookArgs, type OnPrepareMessagesHookArgs, type OnPrepareMessagesHookResult, type OnPrepareModelMessagesHookArgs, type OnPrepareModelMessagesHookResult, type OnStartHookArgs, type OnStepFinishHookArgs, type OnToolEndHookArgs, type OnToolStartHookArgs, type OperationContext, type OutputGuardrail, type OutputGuardrailArgs, type OutputGuardrailResult, type OutputSpec, type PackageUpdateInfo, PlanAgent, type PlanAgentExtension, type PlanAgentExtensionContext, type PlanAgentExtensionResult, type PlanAgentFileData, type PlanAgentOptions, type PlanAgentState, type PlanAgentSubagentDefinition, type PlanAgentTodoItem, type PlanAgentTodoStatus, type PlanningToolkitOptions, 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 ProviderTool, READ_FILE_TOOL_DESCRIPTION, type RagKnowledgeBaseSummary, type RagSearchKnowledgeBaseChildChunk, type RagSearchKnowledgeBaseRequest, type RagSearchKnowledgeBaseResponse, type RagSearchKnowledgeBaseResult, type ReadableStreamType, type ReasoningStep, ReasoningStepSchema, type RegisterOptions, type RegisteredTrigger, type RegisteredWorkflow, type RemoteLogExportConfig, RemoteLogProcessor, type ResumableStreamAdapter, type ResumableStreamContext, type RetrieveOptions, type Retriever, type RetrieverOptions, type RunLocalScorersArgs, type RunLocalScorersResult, SERVERLESS_ENV_CONTEXT_KEY, type SamplingMetadata, type SamplingPolicy, type ScorerBuilder, type ScorerContext, type ScorerLifecycleScope, type ScorerPipelineContext, type ScorerReasonContext, type ScorerResult, 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 StreamObjectResultWithContext, type StreamObjectSubAgentConfig, type StreamPart, type StreamTextFinishResult, type StreamTextOnFinishCallback, type StreamTextOptions, type StreamTextResultWithContext, type StreamTextSubAgentConfig, type SubAgentConfig, type SubAgentMethod, type SubAgentStateData, type SupervisorConfig, TRIGGER_CONTEXT_KEY, type TaskToolOptions, type TemplateVariables, type TimelineEventCoreLevel, type TimelineEventCoreStatus, type TimelineEventCoreType, type TodoBackend, type TodoBackendFactory, Tool, type ToolCall, type ToolContext, ToolDeniedError, type ToolErrorInfo, type ToolExecuteOptions, ToolManager, type ToolOptions, type ToolResultOutput, type ToolSchema, type ToolStatus, type ToolStatusInfo, type ToolWithNodeId, type Toolkit, type TriggerHandler, type TriggerHandlerBody, type TriggerHandlerContext, type TriggerHandlerResponse, type TriggerHandlerResult, type TriggerHandlerReturn, type TriggerHttpMethod, TriggerRegistry, type Usage, type UsageInfo, UserInputBridge, type UserInputHandler, type VectorAdapter, VectorAdapterNotConfiguredError, VectorError, type VectorItem, type VectorSearchOptions, type Voice, type VoiceEventData, type VoiceEventType, type VoiceMetadata, type VoiceOptions, VoltAgent, VoltAgentError, VoltAgentObservability, type VoltAgentOptions, VoltAgentRagRetriever, type VoltAgentRagRetrieverOptions, type VoltAgentStreamTextResult, type VoltAgentTextStreamPart, type VoltAgentTriggerConfig, type VoltAgentTriggersConfig, type VoltOpsActionExecutionResult, type VoltOpsActionsApi, VoltOpsActionsClient, type VoltOpsActionsTransport, type VoltOpsAirtableCreateRecordParams, type VoltOpsAirtableCredential, type VoltOpsAirtableDeleteRecordParams, type VoltOpsAirtableGetRecordParams, type VoltOpsAirtableListRecordsParams, type VoltOpsAirtableUpdateRecordParams, type VoltOpsAppendEvalRunResultPayload, type VoltOpsAppendEvalRunResultsRequest, VoltOpsClient, type VoltOpsClientOptions, type VoltOpsCompleteEvalRunRequest, type VoltOpsCreateEvalRunRequest, type VoltOpsCreateScorerRequest, type VoltOpsDiscordChannelMessageParams, type VoltOpsDiscordChannelType, type VoltOpsDiscordConfig, type VoltOpsDiscordCreateChannelParams, type VoltOpsDiscordCredential, type VoltOpsDiscordDeleteChannelParams, type VoltOpsDiscordGetChannelParams, type VoltOpsDiscordListChannelsParams, type VoltOpsDiscordListMembersParams, type VoltOpsDiscordListMessagesParams, type VoltOpsDiscordMemberRoleParams, type VoltOpsDiscordReactionParams, type VoltOpsDiscordSendMessageParams, type VoltOpsDiscordSendWebhookMessageParams, type VoltOpsDiscordUpdateChannelParams, type VoltOpsEvalResultStatus, type VoltOpsEvalRunCompletionSummaryPayload, type VoltOpsEvalRunErrorPayload, type VoltOpsEvalRunResultLiveMetadata, type VoltOpsEvalRunResultScorePayload, type VoltOpsEvalRunStatus, type VoltOpsEvalRunSummary, type VoltOpsFeedbackConfig, type VoltOpsFeedbackExpiresIn, type VoltOpsFeedbackToken, type VoltOpsFeedbackTokenCreateInput, VoltOpsPromptApiClient, type VoltOpsPromptManager, VoltOpsPromptManagerImpl, type VoltOpsScorerSummary, type VoltOpsSlackCredential, type VoltOpsSlackDeleteMessageParams, type VoltOpsSlackPostMessageParams, type VoltOpsSlackSearchMessagesParams, type VoltOpsTerminalEvalRunStatus, type VoltOpsTriggerDefinition, VoltOpsTriggerDefinitions, type VoltOpsTriggerEnvelope, type VoltOpsTriggerGroupMap, type VoltOpsTriggerName, VoltOpsTriggerNames, WRITE_FILE_TOOL_DESCRIPTION, WRITE_TODOS_TOOL_DESCRIPTION, WRITE_TODOS_TOOL_NAME, WebSocketEventEmitter, WebSocketLogProcessor, WebSocketSpanProcessor, type WeightedBlendComponent, type WeightedBlendOptions, type Workflow, type WorkflowConfig, type WorkflowExecutionContext, WorkflowRegistry, type WorkflowRunQuery, type WorkflowStateEntry, type WorkflowStats, type WorkflowStepContext, type WorkflowStepType, type WorkflowTimelineEvent, type WorkingMemoryConfig, type WorkingMemoryScope, type WorkingMemorySummary, type WorkingMemoryUpdateOptions, type WriteResult, addTimestampToMessage, andAgent, andAll, andBranch, andDoUntil, andDoWhile, andForEach, andGuardrail, andMap, andRace, andSleep, andSleepUntil, andTap, andThen, andWhen, andWorkflow, appendToMessage, buildRetrieverLogMessage, buildSamplingMetadata, buildScorer, buildSpanTree, checkForUpdates, convertUsage, cosineSimilarity, createDefaultInputSafetyGuardrails, createDefaultPIIGuardrails, createDefaultSafetyGuardrails, createEmailRedactorGuardrail, createFilesystemToolkit, createHTMLSanitizerInputGuardrail, createHooks, createInputGuardrail, createInputLengthGuardrail, createMaxLengthGuardrail, createNodeId, createOutputGuardrail, createPIIInputGuardrail, createPhoneNumberGuardrail, createPlanningToolkit, createProfanityGuardrail, createProfanityInputGuardrail, createPrompt, createPromptInjectionGuardrail, createReasoningTools, createRetrieverTool, createScorer, createSensitiveNumberGuardrail, createSimpleTemplateEngine, createSubagent, createSuspendController, createTool, createToolResultEvictor, createToolkit, createTriggers, createVoltAgentObservability, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, defineVoltOpsTrigger, extractFileParts, extractImageParts, extractText, extractTextParts, extractWorkflowStepInfo, filterContentParts, getContentLength, getEnvVar, getGlobalLogBuffer, getGlobalLogger, getGlobalVoltOpsClient, getNodeTypeFromNodeId, getVoltOpsTriggerDefinition, getWorkflowStepNodeType, hasContent, hasFilePart, hasImagePart, hasTextPart, isAbortError, isNodeRuntime, isServerlessRuntime, isStructuredContent, isTextContent, isVoltAgentError, mapMessageContent, messageHelpers, normalizeContent, normalizeScorerResult, normalizeToArray, prependToMessage, readableLogRecordToObservabilityLog, readableSpanToObservabilitySpan, runLocalScorers, safeJsonParse, serializeValueForDebug, setWaitUntil, shouldSample, tool, transformTextContent, updateAllPackages, updateSinglePackage, weightedBlend, zodSchemaToJsonUI };
11885
+ export { A2AServerRegistry, AbortError, Agent, type AgentEvalConfig, type AgentEvalContext, type AgentEvalOperationType, type AgentEvalPayload, type AgentEvalResult, type AgentEvalSamplingPolicy, type AgentEvalScorerConfig, type AgentEvalScorerFactory, type AgentEvalScorerReference, type AgentFeedbackMetadata, type AgentFeedbackOptions, type AgentFullState, type AgentHookOnEnd, type AgentHookOnError, type AgentHookOnHandoff, type AgentHookOnHandoffComplete, type AgentHookOnPrepareMessages, type AgentHookOnPrepareModelMessages, type AgentHookOnStart, type AgentHookOnStepFinish, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentScorerState, type AgentStatus, type AgentSummarizationOptions, type AgentTool, AiSdkEmbeddingAdapter, type AllowedVariableValue, type ApiToolInfo, type BaseEventMetadata, type BaseGenerationOptions, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTool, type BaseToolCall, type BuildScorerOptions, type BuildScorerRunArgs, type BuildScorerRunResult, type BuilderAnalyzeContext, type BuilderPrepareContext, type BuilderReasonContext, type BuilderScoreContext, type CachedPrompt, type ChatMessage, ClientHTTPError, type ClientSideToolResult, type CloudflareFetchHandler, CompositeFilesystemBackend, type Conversation, ConversationAlreadyExistsError, ConversationNotFoundError, type ConversationQueryOptions, type ConversationQueryOptions as ConversationQueryOptionsV2, type ConversationStepRecord, type ConversationStepType, ConversationTodoBackend, type Conversation as ConversationV2, type CreateConversationInput, type CreateConversationInput as CreateConversationInputV2, type CreateInputGuardrailOptions, type CreateOutputGuardrailOptions, type CreateReasoningToolsOptions, type CreateScorerOptions, DEFAULT_INSTRUCTIONS, type DataContent, type Document, type DynamicValue, type DynamicValueOptions, EDIT_FILE_TOOL_DESCRIPTION, type EditResult, type EmbeddingAdapter$1 as EmbeddingAdapter, EmbeddingAdapterNotConfiguredError, EmbeddingError, type ExtractVariableNames, FEW_SHOT_EXAMPLES, FILESYSTEM_SYSTEM_PROMPT, type FileData, type FileInfo, type FilesystemBackend, type FilesystemBackendContext, type FilesystemBackendFactory, type FilesystemToolkitOptions, GLOB_TOOL_DESCRIPTION, GREP_TOOL_DESCRIPTION, type GenerateObjectOptions, type GenerateObjectResultWithContext, type GenerateObjectSubAgentConfig, type GenerateReasonResult, type GenerateScoreResult, type GenerateScoreStep, type GenerateTextOptions, type GenerateTextResultWithContext, type GenerateTextSubAgentConfig, type GetConversationStepsOptions, type GetMessagesOptions, type GrepMatch, type GuardrailAction, type GuardrailContext, type GuardrailDefinition, type GuardrailFunction, type GuardrailSeverity, type IServerProvider, type IServerlessProvider, type VoltOpsClient$1 as IVoltOpsClient, InMemoryFilesystemBackend, InMemoryStorageAdapter$1 as InMemoryObservabilityAdapter, InMemoryStorageAdapter, InMemoryVectorAdapter, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type InputGuardrail, type InputGuardrailArgs, type InputGuardrailResult, type KnowledgeBaseTagFilter, type LLMProvider, LS_TOOL_DESCRIPTION, LazyRemoteExportProcessor, type LocalScorerDefinition, type LocalScorerExecutionResult, LocalStorageSpanProcessor, type LogFilter, LoggerProxy, type MCPAuthorizationAction, type MCPAuthorizationConfig, type MCPAuthorizationContext, MCPAuthorizationError, type MCPCanFunction, type MCPCanParams, type MCPCanResult, MCPClient, type MCPClientCallOptions, type MCPClientConfig, MCPConfiguration, type MCPConfigurationOptions, type MCPElicitationAdapter, type MCPElicitationHandler, 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 ManagedMemoryQueryWorkflowRunsInput, 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, NodeFilesystemBackend, NodeType, VoltAgentObservability$1 as NodeVoltAgentObservability, type ObservabilityConfig, type ObservabilityLogRecord, type ObservabilitySpan, type ObservabilityStorageAdapter, type ObservabilityWebSocketEvent, type OnEndHookArgs, type OnErrorHookArgs, type OnHandoffCompleteHookArgs, type OnHandoffHookArgs, type OnPrepareMessagesHookArgs, type OnPrepareMessagesHookResult, type OnPrepareModelMessagesHookArgs, type OnPrepareModelMessagesHookResult, type OnStartHookArgs, type OnStepFinishHookArgs, type OnToolEndHookArgs, type OnToolStartHookArgs, type OperationContext, type OutputGuardrail, type OutputGuardrailArgs, type OutputGuardrailResult, type OutputSpec, type PackageUpdateInfo, PlanAgent, type PlanAgentExtension, type PlanAgentExtensionContext, type PlanAgentExtensionResult, type PlanAgentFileData, type PlanAgentOptions, type PlanAgentState, type PlanAgentSubagentDefinition, type PlanAgentTodoItem, type PlanAgentTodoStatus, type PlanningToolkitOptions, 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 ProviderTool, READ_FILE_TOOL_DESCRIPTION, type RagKnowledgeBaseSummary, type RagSearchKnowledgeBaseChildChunk, type RagSearchKnowledgeBaseRequest, type RagSearchKnowledgeBaseResponse, type RagSearchKnowledgeBaseResult, type ReadableStreamType, type ReasoningStep, ReasoningStepSchema, type RegisterOptions, type RegisteredTrigger, type RegisteredWorkflow, type RemoteLogExportConfig, RemoteLogProcessor, type ResumableStreamAdapter, type ResumableStreamContext, type RetrieveOptions, type Retriever, type RetrieverOptions, type RunLocalScorersArgs, type RunLocalScorersResult, SERVERLESS_ENV_CONTEXT_KEY, type SamplingMetadata, type SamplingPolicy, type ScorerBuilder, type ScorerContext, type ScorerLifecycleScope, type ScorerPipelineContext, type ScorerReasonContext, type ScorerResult, 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 StreamObjectResultWithContext, type StreamObjectSubAgentConfig, type StreamPart, type StreamTextFinishResult, type StreamTextOnFinishCallback, type StreamTextOptions, type StreamTextResultWithContext, type StreamTextSubAgentConfig, type SubAgentConfig, type SubAgentMethod, type SubAgentStateData, type SupervisorConfig, TRIGGER_CONTEXT_KEY, type TaskToolOptions, type TemplateVariables, type TimelineEventCoreLevel, type TimelineEventCoreStatus, type TimelineEventCoreType, type TodoBackend, type TodoBackendFactory, Tool, type ToolCall, type ToolContext, ToolDeniedError, type ToolErrorInfo, type ToolExecuteOptions, type ToolExecutionResult, ToolManager, type ToolOptions, type ToolResultOutput, type ToolSchema, type ToolStatus, type ToolStatusInfo, type ToolWithNodeId, type Toolkit, type TriggerHandler, type TriggerHandlerBody, type TriggerHandlerContext, type TriggerHandlerResponse, type TriggerHandlerResult, type TriggerHandlerReturn, type TriggerHttpMethod, TriggerRegistry, type Usage, type UsageInfo, UserInputBridge, type UserInputHandler, type VectorAdapter, VectorAdapterNotConfiguredError, VectorError, type VectorItem, type VectorSearchOptions, type Voice, type VoiceEventData, type VoiceEventType, type VoiceMetadata, type VoiceOptions, VoltAgent, VoltAgentError, VoltAgentObservability, type VoltAgentOptions, VoltAgentRagRetriever, type VoltAgentRagRetrieverOptions, type VoltAgentStreamTextResult, type VoltAgentTextStreamPart, type VoltAgentTriggerConfig, type VoltAgentTriggersConfig, type VoltOpsActionExecutionResult, type VoltOpsActionsApi, VoltOpsActionsClient, type VoltOpsActionsTransport, type VoltOpsAirtableCreateRecordParams, type VoltOpsAirtableCredential, type VoltOpsAirtableDeleteRecordParams, type VoltOpsAirtableGetRecordParams, type VoltOpsAirtableListRecordsParams, type VoltOpsAirtableUpdateRecordParams, type VoltOpsAppendEvalRunResultPayload, type VoltOpsAppendEvalRunResultsRequest, VoltOpsClient, type VoltOpsClientOptions, type VoltOpsCompleteEvalRunRequest, type VoltOpsCreateEvalRunRequest, type VoltOpsCreateScorerRequest, type VoltOpsDiscordChannelMessageParams, type VoltOpsDiscordChannelType, type VoltOpsDiscordConfig, type VoltOpsDiscordCreateChannelParams, type VoltOpsDiscordCredential, type VoltOpsDiscordDeleteChannelParams, type VoltOpsDiscordGetChannelParams, type VoltOpsDiscordListChannelsParams, type VoltOpsDiscordListMembersParams, type VoltOpsDiscordListMessagesParams, type VoltOpsDiscordMemberRoleParams, type VoltOpsDiscordReactionParams, type VoltOpsDiscordSendMessageParams, type VoltOpsDiscordSendWebhookMessageParams, type VoltOpsDiscordUpdateChannelParams, type VoltOpsEvalResultStatus, type VoltOpsEvalRunCompletionSummaryPayload, type VoltOpsEvalRunErrorPayload, type VoltOpsEvalRunResultLiveMetadata, type VoltOpsEvalRunResultScorePayload, type VoltOpsEvalRunStatus, type VoltOpsEvalRunSummary, type VoltOpsFeedbackConfig, type VoltOpsFeedbackExpiresIn, type VoltOpsFeedbackToken, type VoltOpsFeedbackTokenCreateInput, VoltOpsPromptApiClient, type VoltOpsPromptManager, VoltOpsPromptManagerImpl, type VoltOpsScorerSummary, type VoltOpsSlackCredential, type VoltOpsSlackDeleteMessageParams, type VoltOpsSlackPostMessageParams, type VoltOpsSlackSearchMessagesParams, type VoltOpsTerminalEvalRunStatus, type VoltOpsTriggerDefinition, VoltOpsTriggerDefinitions, type VoltOpsTriggerEnvelope, type VoltOpsTriggerGroupMap, type VoltOpsTriggerName, VoltOpsTriggerNames, WRITE_FILE_TOOL_DESCRIPTION, WRITE_TODOS_TOOL_DESCRIPTION, WRITE_TODOS_TOOL_NAME, WebSocketEventEmitter, WebSocketLogProcessor, WebSocketSpanProcessor, type WeightedBlendComponent, type WeightedBlendOptions, type Workflow, type WorkflowConfig, type WorkflowExecutionContext, type WorkflowHookContext, type WorkflowHookStatus, type WorkflowHooks, WorkflowRegistry, type WorkflowRunQuery, type WorkflowStateEntry, type WorkflowStats, type WorkflowStepContext, type WorkflowStepData, type WorkflowStepStatus, type WorkflowStepType, type WorkflowTimelineEvent, type WorkingMemoryConfig, type WorkingMemoryScope, type WorkingMemorySummary, type WorkingMemoryUpdateOptions, type WriteResult, addTimestampToMessage, andAgent, andAll, andBranch, andDoUntil, andDoWhile, andForEach, andGuardrail, andMap, andRace, andSleep, andSleepUntil, andTap, andThen, andWhen, andWorkflow, appendToMessage, buildRetrieverLogMessage, buildSamplingMetadata, buildScorer, buildSpanTree, checkForUpdates, convertUsage, cosineSimilarity, createDefaultInputSafetyGuardrails, createDefaultPIIGuardrails, createDefaultSafetyGuardrails, createEmailRedactorGuardrail, createFilesystemToolkit, createHTMLSanitizerInputGuardrail, createHooks, createInputGuardrail, createInputLengthGuardrail, createMaxLengthGuardrail, createNodeId, createOutputGuardrail, createPIIInputGuardrail, createPhoneNumberGuardrail, createPlanningToolkit, createProfanityGuardrail, createProfanityInputGuardrail, createPrompt, createPromptInjectionGuardrail, createReasoningTools, createRetrieverTool, createScorer, createSensitiveNumberGuardrail, createSimpleTemplateEngine, createSubagent, createSuspendController, createTool, createToolResultEvictor, createToolkit, createTriggers, createVoltAgentObservability, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, defineVoltOpsTrigger, extractFileParts, extractImageParts, extractText, extractTextParts, extractWorkflowStepInfo, filterContentParts, getContentLength, getEnvVar, getGlobalLogBuffer, getGlobalLogger, getGlobalVoltOpsClient, getNodeTypeFromNodeId, getVoltOpsTriggerDefinition, getWorkflowStepNodeType, hasContent, hasFilePart, hasImagePart, hasTextPart, isAbortError, isNodeRuntime, isServerlessRuntime, isStructuredContent, isTextContent, isVoltAgentError, mapMessageContent, messageHelpers, normalizeContent, normalizeScorerResult, normalizeToArray, prependToMessage, readableLogRecordToObservabilityLog, readableSpanToObservabilitySpan, runLocalScorers, safeJsonParse, serializeValueForDebug, setWaitUntil, shouldSample, tool, transformTextContent, updateAllPackages, updateSinglePackage, weightedBlend, zodSchemaToJsonUI };
package/dist/index.d.ts CHANGED
@@ -192,7 +192,7 @@ declare class ToolManager extends BaseToolManager<AgentTool | Tool$1 | Toolkit,
192
192
  * @returns true if the toolkit was successfully added or replaced.
193
193
  */
194
194
  addToolkit(toolkit: Toolkit): boolean;
195
- prepareToolsForExecution(createToolExecuteFunction: (tool: AgentTool) => (args: any, options?: ToolExecutionOptions) => Promise<any>): Record<string, any>;
195
+ prepareToolsForExecution(createToolExecuteFunction: (tool: AgentTool) => (args: any, options?: ToolExecutionOptions) => ToolExecutionResult<any>): Record<string, any>;
196
196
  /**
197
197
  * Get agent's tools (including those in toolkits) for API exposure.
198
198
  */
@@ -223,6 +223,7 @@ type ToolStatusInfo = {
223
223
  type JSONValue = string | number | boolean | null | {
224
224
  [key: string]: JSONValue;
225
225
  } | Array<JSONValue>;
226
+ type ToolExecutionResult<T> = PromiseLike<T> | AsyncIterable<T> | T;
226
227
  /**
227
228
  * Tool result output format for multi-modal content.
228
229
  * Matches AI SDK's LanguageModelV2ToolResultOutput type.
@@ -338,8 +339,9 @@ type ToolOptions<T extends ToolSchema = ToolSchema, O extends ToolSchema | undef
338
339
  * Function to execute when the tool is called.
339
340
  * @param args - The arguments passed to the tool
340
341
  * @param options - Optional execution options including context, abort signals, etc.
342
+ * @returns A result or an AsyncIterable of results (last value is final).
341
343
  */
342
- execute?: (args: z.infer<T>, options?: ToolExecuteOptions) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
344
+ execute?: (args: z.infer<T>, options?: ToolExecuteOptions) => ToolExecutionResult<O extends ToolSchema ? z.infer<O> : unknown>;
343
345
  };
344
346
  /**
345
347
  * Tool class for defining tools that agents can use
@@ -394,8 +396,9 @@ declare class Tool<T extends ToolSchema = ToolSchema, O extends ToolSchema | und
394
396
  * Function to execute when the tool is called.
395
397
  * @param args - The arguments passed to the tool
396
398
  * @param options - Optional execution options including context, abort signals, etc.
399
+ * @returns A result or an AsyncIterable of results (last value is final).
397
400
  */
398
- readonly execute?: (args: z.infer<T>, options?: ToolExecuteOptions) => Promise<O extends ToolSchema ? z.infer<O> : unknown>;
401
+ readonly execute?: (args: z.infer<T>, options?: ToolExecuteOptions) => ToolExecutionResult<O extends ToolSchema ? z.infer<O> : unknown>;
399
402
  /**
400
403
  * Whether this tool should be executed on the client side.
401
404
  * Returns true when no server-side execute handler is provided.
@@ -11879,4 +11882,4 @@ declare class VoltAgent {
11879
11882
  */
11880
11883
  declare function convertUsage(usage: LanguageModelUsage | undefined): UsageInfo | undefined;
11881
11884
 
11882
- export { A2AServerRegistry, AbortError, Agent, type AgentEvalConfig, type AgentEvalContext, type AgentEvalOperationType, type AgentEvalPayload, type AgentEvalResult, type AgentEvalSamplingPolicy, type AgentEvalScorerConfig, type AgentEvalScorerFactory, type AgentEvalScorerReference, type AgentFeedbackMetadata, type AgentFeedbackOptions, type AgentFullState, type AgentHookOnEnd, type AgentHookOnError, type AgentHookOnHandoff, type AgentHookOnHandoffComplete, type AgentHookOnPrepareMessages, type AgentHookOnPrepareModelMessages, type AgentHookOnStart, type AgentHookOnStepFinish, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentScorerState, type AgentStatus, type AgentSummarizationOptions, type AgentTool, AiSdkEmbeddingAdapter, type AllowedVariableValue, type ApiToolInfo, type BaseEventMetadata, type BaseGenerationOptions, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTool, type BaseToolCall, type BuildScorerOptions, type BuildScorerRunArgs, type BuildScorerRunResult, type BuilderAnalyzeContext, type BuilderPrepareContext, type BuilderReasonContext, type BuilderScoreContext, type CachedPrompt, type ChatMessage, ClientHTTPError, type ClientSideToolResult, type CloudflareFetchHandler, CompositeFilesystemBackend, type Conversation, ConversationAlreadyExistsError, ConversationNotFoundError, type ConversationQueryOptions, type ConversationQueryOptions as ConversationQueryOptionsV2, type ConversationStepRecord, type ConversationStepType, ConversationTodoBackend, type Conversation as ConversationV2, type CreateConversationInput, type CreateConversationInput as CreateConversationInputV2, type CreateInputGuardrailOptions, type CreateOutputGuardrailOptions, type CreateReasoningToolsOptions, type CreateScorerOptions, DEFAULT_INSTRUCTIONS, type DataContent, type Document, type DynamicValue, type DynamicValueOptions, EDIT_FILE_TOOL_DESCRIPTION, type EditResult, type EmbeddingAdapter$1 as EmbeddingAdapter, EmbeddingAdapterNotConfiguredError, EmbeddingError, type ExtractVariableNames, FEW_SHOT_EXAMPLES, FILESYSTEM_SYSTEM_PROMPT, type FileData, type FileInfo, type FilesystemBackend, type FilesystemBackendContext, type FilesystemBackendFactory, type FilesystemToolkitOptions, GLOB_TOOL_DESCRIPTION, GREP_TOOL_DESCRIPTION, type GenerateObjectOptions, type GenerateObjectResultWithContext, type GenerateObjectSubAgentConfig, type GenerateReasonResult, type GenerateScoreResult, type GenerateScoreStep, type GenerateTextOptions, type GenerateTextResultWithContext, type GenerateTextSubAgentConfig, type GetConversationStepsOptions, type GetMessagesOptions, type GrepMatch, type GuardrailAction, type GuardrailContext, type GuardrailDefinition, type GuardrailFunction, type GuardrailSeverity, type IServerProvider, type IServerlessProvider, type VoltOpsClient$1 as IVoltOpsClient, InMemoryFilesystemBackend, InMemoryStorageAdapter$1 as InMemoryObservabilityAdapter, InMemoryStorageAdapter, InMemoryVectorAdapter, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type InputGuardrail, type InputGuardrailArgs, type InputGuardrailResult, type KnowledgeBaseTagFilter, type LLMProvider, LS_TOOL_DESCRIPTION, LazyRemoteExportProcessor, type LocalScorerDefinition, type LocalScorerExecutionResult, LocalStorageSpanProcessor, type LogFilter, LoggerProxy, type MCPAuthorizationAction, type MCPAuthorizationConfig, type MCPAuthorizationContext, MCPAuthorizationError, type MCPCanFunction, type MCPCanParams, type MCPCanResult, MCPClient, type MCPClientCallOptions, type MCPClientConfig, MCPConfiguration, type MCPConfigurationOptions, type MCPElicitationAdapter, type MCPElicitationHandler, 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 ManagedMemoryQueryWorkflowRunsInput, 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, NodeFilesystemBackend, NodeType, VoltAgentObservability$1 as NodeVoltAgentObservability, type ObservabilityConfig, type ObservabilityLogRecord, type ObservabilitySpan, type ObservabilityStorageAdapter, type ObservabilityWebSocketEvent, type OnEndHookArgs, type OnErrorHookArgs, type OnHandoffCompleteHookArgs, type OnHandoffHookArgs, type OnPrepareMessagesHookArgs, type OnPrepareMessagesHookResult, type OnPrepareModelMessagesHookArgs, type OnPrepareModelMessagesHookResult, type OnStartHookArgs, type OnStepFinishHookArgs, type OnToolEndHookArgs, type OnToolStartHookArgs, type OperationContext, type OutputGuardrail, type OutputGuardrailArgs, type OutputGuardrailResult, type OutputSpec, type PackageUpdateInfo, PlanAgent, type PlanAgentExtension, type PlanAgentExtensionContext, type PlanAgentExtensionResult, type PlanAgentFileData, type PlanAgentOptions, type PlanAgentState, type PlanAgentSubagentDefinition, type PlanAgentTodoItem, type PlanAgentTodoStatus, type PlanningToolkitOptions, 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 ProviderTool, READ_FILE_TOOL_DESCRIPTION, type RagKnowledgeBaseSummary, type RagSearchKnowledgeBaseChildChunk, type RagSearchKnowledgeBaseRequest, type RagSearchKnowledgeBaseResponse, type RagSearchKnowledgeBaseResult, type ReadableStreamType, type ReasoningStep, ReasoningStepSchema, type RegisterOptions, type RegisteredTrigger, type RegisteredWorkflow, type RemoteLogExportConfig, RemoteLogProcessor, type ResumableStreamAdapter, type ResumableStreamContext, type RetrieveOptions, type Retriever, type RetrieverOptions, type RunLocalScorersArgs, type RunLocalScorersResult, SERVERLESS_ENV_CONTEXT_KEY, type SamplingMetadata, type SamplingPolicy, type ScorerBuilder, type ScorerContext, type ScorerLifecycleScope, type ScorerPipelineContext, type ScorerReasonContext, type ScorerResult, 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 StreamObjectResultWithContext, type StreamObjectSubAgentConfig, type StreamPart, type StreamTextFinishResult, type StreamTextOnFinishCallback, type StreamTextOptions, type StreamTextResultWithContext, type StreamTextSubAgentConfig, type SubAgentConfig, type SubAgentMethod, type SubAgentStateData, type SupervisorConfig, TRIGGER_CONTEXT_KEY, type TaskToolOptions, type TemplateVariables, type TimelineEventCoreLevel, type TimelineEventCoreStatus, type TimelineEventCoreType, type TodoBackend, type TodoBackendFactory, Tool, type ToolCall, type ToolContext, ToolDeniedError, type ToolErrorInfo, type ToolExecuteOptions, ToolManager, type ToolOptions, type ToolResultOutput, type ToolSchema, type ToolStatus, type ToolStatusInfo, type ToolWithNodeId, type Toolkit, type TriggerHandler, type TriggerHandlerBody, type TriggerHandlerContext, type TriggerHandlerResponse, type TriggerHandlerResult, type TriggerHandlerReturn, type TriggerHttpMethod, TriggerRegistry, type Usage, type UsageInfo, UserInputBridge, type UserInputHandler, type VectorAdapter, VectorAdapterNotConfiguredError, VectorError, type VectorItem, type VectorSearchOptions, type Voice, type VoiceEventData, type VoiceEventType, type VoiceMetadata, type VoiceOptions, VoltAgent, VoltAgentError, VoltAgentObservability, type VoltAgentOptions, VoltAgentRagRetriever, type VoltAgentRagRetrieverOptions, type VoltAgentStreamTextResult, type VoltAgentTextStreamPart, type VoltAgentTriggerConfig, type VoltAgentTriggersConfig, type VoltOpsActionExecutionResult, type VoltOpsActionsApi, VoltOpsActionsClient, type VoltOpsActionsTransport, type VoltOpsAirtableCreateRecordParams, type VoltOpsAirtableCredential, type VoltOpsAirtableDeleteRecordParams, type VoltOpsAirtableGetRecordParams, type VoltOpsAirtableListRecordsParams, type VoltOpsAirtableUpdateRecordParams, type VoltOpsAppendEvalRunResultPayload, type VoltOpsAppendEvalRunResultsRequest, VoltOpsClient, type VoltOpsClientOptions, type VoltOpsCompleteEvalRunRequest, type VoltOpsCreateEvalRunRequest, type VoltOpsCreateScorerRequest, type VoltOpsDiscordChannelMessageParams, type VoltOpsDiscordChannelType, type VoltOpsDiscordConfig, type VoltOpsDiscordCreateChannelParams, type VoltOpsDiscordCredential, type VoltOpsDiscordDeleteChannelParams, type VoltOpsDiscordGetChannelParams, type VoltOpsDiscordListChannelsParams, type VoltOpsDiscordListMembersParams, type VoltOpsDiscordListMessagesParams, type VoltOpsDiscordMemberRoleParams, type VoltOpsDiscordReactionParams, type VoltOpsDiscordSendMessageParams, type VoltOpsDiscordSendWebhookMessageParams, type VoltOpsDiscordUpdateChannelParams, type VoltOpsEvalResultStatus, type VoltOpsEvalRunCompletionSummaryPayload, type VoltOpsEvalRunErrorPayload, type VoltOpsEvalRunResultLiveMetadata, type VoltOpsEvalRunResultScorePayload, type VoltOpsEvalRunStatus, type VoltOpsEvalRunSummary, type VoltOpsFeedbackConfig, type VoltOpsFeedbackExpiresIn, type VoltOpsFeedbackToken, type VoltOpsFeedbackTokenCreateInput, VoltOpsPromptApiClient, type VoltOpsPromptManager, VoltOpsPromptManagerImpl, type VoltOpsScorerSummary, type VoltOpsSlackCredential, type VoltOpsSlackDeleteMessageParams, type VoltOpsSlackPostMessageParams, type VoltOpsSlackSearchMessagesParams, type VoltOpsTerminalEvalRunStatus, type VoltOpsTriggerDefinition, VoltOpsTriggerDefinitions, type VoltOpsTriggerEnvelope, type VoltOpsTriggerGroupMap, type VoltOpsTriggerName, VoltOpsTriggerNames, WRITE_FILE_TOOL_DESCRIPTION, WRITE_TODOS_TOOL_DESCRIPTION, WRITE_TODOS_TOOL_NAME, WebSocketEventEmitter, WebSocketLogProcessor, WebSocketSpanProcessor, type WeightedBlendComponent, type WeightedBlendOptions, type Workflow, type WorkflowConfig, type WorkflowExecutionContext, WorkflowRegistry, type WorkflowRunQuery, type WorkflowStateEntry, type WorkflowStats, type WorkflowStepContext, type WorkflowStepType, type WorkflowTimelineEvent, type WorkingMemoryConfig, type WorkingMemoryScope, type WorkingMemorySummary, type WorkingMemoryUpdateOptions, type WriteResult, addTimestampToMessage, andAgent, andAll, andBranch, andDoUntil, andDoWhile, andForEach, andGuardrail, andMap, andRace, andSleep, andSleepUntil, andTap, andThen, andWhen, andWorkflow, appendToMessage, buildRetrieverLogMessage, buildSamplingMetadata, buildScorer, buildSpanTree, checkForUpdates, convertUsage, cosineSimilarity, createDefaultInputSafetyGuardrails, createDefaultPIIGuardrails, createDefaultSafetyGuardrails, createEmailRedactorGuardrail, createFilesystemToolkit, createHTMLSanitizerInputGuardrail, createHooks, createInputGuardrail, createInputLengthGuardrail, createMaxLengthGuardrail, createNodeId, createOutputGuardrail, createPIIInputGuardrail, createPhoneNumberGuardrail, createPlanningToolkit, createProfanityGuardrail, createProfanityInputGuardrail, createPrompt, createPromptInjectionGuardrail, createReasoningTools, createRetrieverTool, createScorer, createSensitiveNumberGuardrail, createSimpleTemplateEngine, createSubagent, createSuspendController, createTool, createToolResultEvictor, createToolkit, createTriggers, createVoltAgentObservability, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, defineVoltOpsTrigger, extractFileParts, extractImageParts, extractText, extractTextParts, extractWorkflowStepInfo, filterContentParts, getContentLength, getEnvVar, getGlobalLogBuffer, getGlobalLogger, getGlobalVoltOpsClient, getNodeTypeFromNodeId, getVoltOpsTriggerDefinition, getWorkflowStepNodeType, hasContent, hasFilePart, hasImagePart, hasTextPart, isAbortError, isNodeRuntime, isServerlessRuntime, isStructuredContent, isTextContent, isVoltAgentError, mapMessageContent, messageHelpers, normalizeContent, normalizeScorerResult, normalizeToArray, prependToMessage, readableLogRecordToObservabilityLog, readableSpanToObservabilitySpan, runLocalScorers, safeJsonParse, serializeValueForDebug, setWaitUntil, shouldSample, tool, transformTextContent, updateAllPackages, updateSinglePackage, weightedBlend, zodSchemaToJsonUI };
11885
+ export { A2AServerRegistry, AbortError, Agent, type AgentEvalConfig, type AgentEvalContext, type AgentEvalOperationType, type AgentEvalPayload, type AgentEvalResult, type AgentEvalSamplingPolicy, type AgentEvalScorerConfig, type AgentEvalScorerFactory, type AgentEvalScorerReference, type AgentFeedbackMetadata, type AgentFeedbackOptions, type AgentFullState, type AgentHookOnEnd, type AgentHookOnError, type AgentHookOnHandoff, type AgentHookOnHandoffComplete, type AgentHookOnPrepareMessages, type AgentHookOnPrepareModelMessages, type AgentHookOnStart, type AgentHookOnStepFinish, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentScorerState, type AgentStatus, type AgentSummarizationOptions, type AgentTool, AiSdkEmbeddingAdapter, type AllowedVariableValue, type ApiToolInfo, type BaseEventMetadata, type BaseGenerationOptions, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTool, type BaseToolCall, type BuildScorerOptions, type BuildScorerRunArgs, type BuildScorerRunResult, type BuilderAnalyzeContext, type BuilderPrepareContext, type BuilderReasonContext, type BuilderScoreContext, type CachedPrompt, type ChatMessage, ClientHTTPError, type ClientSideToolResult, type CloudflareFetchHandler, CompositeFilesystemBackend, type Conversation, ConversationAlreadyExistsError, ConversationNotFoundError, type ConversationQueryOptions, type ConversationQueryOptions as ConversationQueryOptionsV2, type ConversationStepRecord, type ConversationStepType, ConversationTodoBackend, type Conversation as ConversationV2, type CreateConversationInput, type CreateConversationInput as CreateConversationInputV2, type CreateInputGuardrailOptions, type CreateOutputGuardrailOptions, type CreateReasoningToolsOptions, type CreateScorerOptions, DEFAULT_INSTRUCTIONS, type DataContent, type Document, type DynamicValue, type DynamicValueOptions, EDIT_FILE_TOOL_DESCRIPTION, type EditResult, type EmbeddingAdapter$1 as EmbeddingAdapter, EmbeddingAdapterNotConfiguredError, EmbeddingError, type ExtractVariableNames, FEW_SHOT_EXAMPLES, FILESYSTEM_SYSTEM_PROMPT, type FileData, type FileInfo, type FilesystemBackend, type FilesystemBackendContext, type FilesystemBackendFactory, type FilesystemToolkitOptions, GLOB_TOOL_DESCRIPTION, GREP_TOOL_DESCRIPTION, type GenerateObjectOptions, type GenerateObjectResultWithContext, type GenerateObjectSubAgentConfig, type GenerateReasonResult, type GenerateScoreResult, type GenerateScoreStep, type GenerateTextOptions, type GenerateTextResultWithContext, type GenerateTextSubAgentConfig, type GetConversationStepsOptions, type GetMessagesOptions, type GrepMatch, type GuardrailAction, type GuardrailContext, type GuardrailDefinition, type GuardrailFunction, type GuardrailSeverity, type IServerProvider, type IServerlessProvider, type VoltOpsClient$1 as IVoltOpsClient, InMemoryFilesystemBackend, InMemoryStorageAdapter$1 as InMemoryObservabilityAdapter, InMemoryStorageAdapter, InMemoryVectorAdapter, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type InputGuardrail, type InputGuardrailArgs, type InputGuardrailResult, type KnowledgeBaseTagFilter, type LLMProvider, LS_TOOL_DESCRIPTION, LazyRemoteExportProcessor, type LocalScorerDefinition, type LocalScorerExecutionResult, LocalStorageSpanProcessor, type LogFilter, LoggerProxy, type MCPAuthorizationAction, type MCPAuthorizationConfig, type MCPAuthorizationContext, MCPAuthorizationError, type MCPCanFunction, type MCPCanParams, type MCPCanResult, MCPClient, type MCPClientCallOptions, type MCPClientConfig, MCPConfiguration, type MCPConfigurationOptions, type MCPElicitationAdapter, type MCPElicitationHandler, 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 ManagedMemoryQueryWorkflowRunsInput, 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, NodeFilesystemBackend, NodeType, VoltAgentObservability$1 as NodeVoltAgentObservability, type ObservabilityConfig, type ObservabilityLogRecord, type ObservabilitySpan, type ObservabilityStorageAdapter, type ObservabilityWebSocketEvent, type OnEndHookArgs, type OnErrorHookArgs, type OnHandoffCompleteHookArgs, type OnHandoffHookArgs, type OnPrepareMessagesHookArgs, type OnPrepareMessagesHookResult, type OnPrepareModelMessagesHookArgs, type OnPrepareModelMessagesHookResult, type OnStartHookArgs, type OnStepFinishHookArgs, type OnToolEndHookArgs, type OnToolStartHookArgs, type OperationContext, type OutputGuardrail, type OutputGuardrailArgs, type OutputGuardrailResult, type OutputSpec, type PackageUpdateInfo, PlanAgent, type PlanAgentExtension, type PlanAgentExtensionContext, type PlanAgentExtensionResult, type PlanAgentFileData, type PlanAgentOptions, type PlanAgentState, type PlanAgentSubagentDefinition, type PlanAgentTodoItem, type PlanAgentTodoStatus, type PlanningToolkitOptions, 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 ProviderTool, READ_FILE_TOOL_DESCRIPTION, type RagKnowledgeBaseSummary, type RagSearchKnowledgeBaseChildChunk, type RagSearchKnowledgeBaseRequest, type RagSearchKnowledgeBaseResponse, type RagSearchKnowledgeBaseResult, type ReadableStreamType, type ReasoningStep, ReasoningStepSchema, type RegisterOptions, type RegisteredTrigger, type RegisteredWorkflow, type RemoteLogExportConfig, RemoteLogProcessor, type ResumableStreamAdapter, type ResumableStreamContext, type RetrieveOptions, type Retriever, type RetrieverOptions, type RunLocalScorersArgs, type RunLocalScorersResult, SERVERLESS_ENV_CONTEXT_KEY, type SamplingMetadata, type SamplingPolicy, type ScorerBuilder, type ScorerContext, type ScorerLifecycleScope, type ScorerPipelineContext, type ScorerReasonContext, type ScorerResult, 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 StreamObjectResultWithContext, type StreamObjectSubAgentConfig, type StreamPart, type StreamTextFinishResult, type StreamTextOnFinishCallback, type StreamTextOptions, type StreamTextResultWithContext, type StreamTextSubAgentConfig, type SubAgentConfig, type SubAgentMethod, type SubAgentStateData, type SupervisorConfig, TRIGGER_CONTEXT_KEY, type TaskToolOptions, type TemplateVariables, type TimelineEventCoreLevel, type TimelineEventCoreStatus, type TimelineEventCoreType, type TodoBackend, type TodoBackendFactory, Tool, type ToolCall, type ToolContext, ToolDeniedError, type ToolErrorInfo, type ToolExecuteOptions, type ToolExecutionResult, ToolManager, type ToolOptions, type ToolResultOutput, type ToolSchema, type ToolStatus, type ToolStatusInfo, type ToolWithNodeId, type Toolkit, type TriggerHandler, type TriggerHandlerBody, type TriggerHandlerContext, type TriggerHandlerResponse, type TriggerHandlerResult, type TriggerHandlerReturn, type TriggerHttpMethod, TriggerRegistry, type Usage, type UsageInfo, UserInputBridge, type UserInputHandler, type VectorAdapter, VectorAdapterNotConfiguredError, VectorError, type VectorItem, type VectorSearchOptions, type Voice, type VoiceEventData, type VoiceEventType, type VoiceMetadata, type VoiceOptions, VoltAgent, VoltAgentError, VoltAgentObservability, type VoltAgentOptions, VoltAgentRagRetriever, type VoltAgentRagRetrieverOptions, type VoltAgentStreamTextResult, type VoltAgentTextStreamPart, type VoltAgentTriggerConfig, type VoltAgentTriggersConfig, type VoltOpsActionExecutionResult, type VoltOpsActionsApi, VoltOpsActionsClient, type VoltOpsActionsTransport, type VoltOpsAirtableCreateRecordParams, type VoltOpsAirtableCredential, type VoltOpsAirtableDeleteRecordParams, type VoltOpsAirtableGetRecordParams, type VoltOpsAirtableListRecordsParams, type VoltOpsAirtableUpdateRecordParams, type VoltOpsAppendEvalRunResultPayload, type VoltOpsAppendEvalRunResultsRequest, VoltOpsClient, type VoltOpsClientOptions, type VoltOpsCompleteEvalRunRequest, type VoltOpsCreateEvalRunRequest, type VoltOpsCreateScorerRequest, type VoltOpsDiscordChannelMessageParams, type VoltOpsDiscordChannelType, type VoltOpsDiscordConfig, type VoltOpsDiscordCreateChannelParams, type VoltOpsDiscordCredential, type VoltOpsDiscordDeleteChannelParams, type VoltOpsDiscordGetChannelParams, type VoltOpsDiscordListChannelsParams, type VoltOpsDiscordListMembersParams, type VoltOpsDiscordListMessagesParams, type VoltOpsDiscordMemberRoleParams, type VoltOpsDiscordReactionParams, type VoltOpsDiscordSendMessageParams, type VoltOpsDiscordSendWebhookMessageParams, type VoltOpsDiscordUpdateChannelParams, type VoltOpsEvalResultStatus, type VoltOpsEvalRunCompletionSummaryPayload, type VoltOpsEvalRunErrorPayload, type VoltOpsEvalRunResultLiveMetadata, type VoltOpsEvalRunResultScorePayload, type VoltOpsEvalRunStatus, type VoltOpsEvalRunSummary, type VoltOpsFeedbackConfig, type VoltOpsFeedbackExpiresIn, type VoltOpsFeedbackToken, type VoltOpsFeedbackTokenCreateInput, VoltOpsPromptApiClient, type VoltOpsPromptManager, VoltOpsPromptManagerImpl, type VoltOpsScorerSummary, type VoltOpsSlackCredential, type VoltOpsSlackDeleteMessageParams, type VoltOpsSlackPostMessageParams, type VoltOpsSlackSearchMessagesParams, type VoltOpsTerminalEvalRunStatus, type VoltOpsTriggerDefinition, VoltOpsTriggerDefinitions, type VoltOpsTriggerEnvelope, type VoltOpsTriggerGroupMap, type VoltOpsTriggerName, VoltOpsTriggerNames, WRITE_FILE_TOOL_DESCRIPTION, WRITE_TODOS_TOOL_DESCRIPTION, WRITE_TODOS_TOOL_NAME, WebSocketEventEmitter, WebSocketLogProcessor, WebSocketSpanProcessor, type WeightedBlendComponent, type WeightedBlendOptions, type Workflow, type WorkflowConfig, type WorkflowExecutionContext, type WorkflowHookContext, type WorkflowHookStatus, type WorkflowHooks, WorkflowRegistry, type WorkflowRunQuery, type WorkflowStateEntry, type WorkflowStats, type WorkflowStepContext, type WorkflowStepData, type WorkflowStepStatus, type WorkflowStepType, type WorkflowTimelineEvent, type WorkingMemoryConfig, type WorkingMemoryScope, type WorkingMemorySummary, type WorkingMemoryUpdateOptions, type WriteResult, addTimestampToMessage, andAgent, andAll, andBranch, andDoUntil, andDoWhile, andForEach, andGuardrail, andMap, andRace, andSleep, andSleepUntil, andTap, andThen, andWhen, andWorkflow, appendToMessage, buildRetrieverLogMessage, buildSamplingMetadata, buildScorer, buildSpanTree, checkForUpdates, convertUsage, cosineSimilarity, createDefaultInputSafetyGuardrails, createDefaultPIIGuardrails, createDefaultSafetyGuardrails, createEmailRedactorGuardrail, createFilesystemToolkit, createHTMLSanitizerInputGuardrail, createHooks, createInputGuardrail, createInputLengthGuardrail, createMaxLengthGuardrail, createNodeId, createOutputGuardrail, createPIIInputGuardrail, createPhoneNumberGuardrail, createPlanningToolkit, createProfanityGuardrail, createProfanityInputGuardrail, createPrompt, createPromptInjectionGuardrail, createReasoningTools, createRetrieverTool, createScorer, createSensitiveNumberGuardrail, createSimpleTemplateEngine, createSubagent, createSuspendController, createTool, createToolResultEvictor, createToolkit, createTriggers, createVoltAgentObservability, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, defineVoltOpsTrigger, extractFileParts, extractImageParts, extractText, extractTextParts, extractWorkflowStepInfo, filterContentParts, getContentLength, getEnvVar, getGlobalLogBuffer, getGlobalLogger, getGlobalVoltOpsClient, getNodeTypeFromNodeId, getVoltOpsTriggerDefinition, getWorkflowStepNodeType, hasContent, hasFilePart, hasImagePart, hasTextPart, isAbortError, isNodeRuntime, isServerlessRuntime, isStructuredContent, isTextContent, isVoltAgentError, mapMessageContent, messageHelpers, normalizeContent, normalizeScorerResult, normalizeToArray, prependToMessage, readableLogRecordToObservabilityLog, readableSpanToObservabilitySpan, runLocalScorers, safeJsonParse, serializeValueForDebug, setWaitUntil, shouldSample, tool, transformTextContent, updateAllPackages, updateSinglePackage, weightedBlend, zodSchemaToJsonUI };
package/dist/index.js CHANGED
@@ -10619,6 +10619,7 @@ var Tool = class {
10619
10619
  * Function to execute when the tool is called.
10620
10620
  * @param args - The arguments passed to the tool
10621
10621
  * @param options - Optional execution options including context, abort signals, etc.
10622
+ * @returns A result or an AsyncIterable of results (last value is final).
10622
10623
  */
10623
10624
  execute;
10624
10625
  /**
@@ -19372,6 +19373,19 @@ function createDeferred() {
19372
19373
  return { promise, resolve: resolve2 };
19373
19374
  }
19374
19375
  __name(createDeferred, "createDeferred");
19376
+ var asyncGeneratorFunction = Object.getPrototypeOf(async function* () {
19377
+ }).constructor;
19378
+ function isAsyncGeneratorFunction(value) {
19379
+ return typeof value === "function" && value.constructor === asyncGeneratorFunction;
19380
+ }
19381
+ __name(isAsyncGeneratorFunction, "isAsyncGeneratorFunction");
19382
+ function isAsyncIterable(value) {
19383
+ if (typeof value !== "object" || value === null) {
19384
+ return false;
19385
+ }
19386
+ return typeof value[Symbol.asyncIterator] === "function";
19387
+ }
19388
+ __name(isAsyncIterable, "isAsyncIterable");
19375
19389
  var Agent = class {
19376
19390
  static {
19377
19391
  __name(this, "Agent");
@@ -21764,7 +21778,7 @@ ${retrieverContext}`;
21764
21778
  return parseResult.data;
21765
21779
  }
21766
21780
  createToolExecutionFactory(oc, hooks) {
21767
- return (tool2) => async (args, options) => {
21781
+ return (tool2) => (args, options) => {
21768
21782
  const toolCallId = options?.toolCallId ?? randomUUID();
21769
21783
  const messages = options?.messages ?? [];
21770
21784
  const abortSignal = options?.abortSignal;
@@ -21793,7 +21807,99 @@ ${retrieverContext}`;
21793
21807
  oc.systemContext.set("agentId", this.id);
21794
21808
  oc.systemContext.set("historyEntryId", oc.operationId);
21795
21809
  oc.systemContext.set("parentToolSpan", toolSpan);
21796
- return await oc.traceContext.withSpan(toolSpan, async () => {
21810
+ const handleToolSuccess = /* @__PURE__ */ __name(async (result, validatedResult) => {
21811
+ toolSpan.setAttribute("output", (0, import_utils26.safeStringify)(result));
21812
+ toolSpan.setStatus({ code: import_api15.SpanStatusCode.OK });
21813
+ toolSpan.end();
21814
+ await hooks.onToolEnd?.({
21815
+ agent: this,
21816
+ tool: tool2,
21817
+ output: validatedResult,
21818
+ error: void 0,
21819
+ context: oc,
21820
+ options: executionOptions
21821
+ });
21822
+ }, "handleToolSuccess");
21823
+ const handleToolError = /* @__PURE__ */ __name(async (errorValue) => {
21824
+ const error = errorValue instanceof Error ? errorValue : new Error(String(errorValue));
21825
+ const voltAgentError = createVoltAgentError(error, {
21826
+ stage: "tool_execution",
21827
+ toolError: {
21828
+ toolCallId,
21829
+ toolName: tool2.name,
21830
+ toolExecutionError: error,
21831
+ toolArguments: args
21832
+ }
21833
+ });
21834
+ const errorResult = buildToolErrorResult(error, toolCallId, tool2.name);
21835
+ toolSpan.setStatus({ code: import_api15.SpanStatusCode.ERROR, message: error.message });
21836
+ toolSpan.recordException(error);
21837
+ toolSpan.end();
21838
+ await hooks.onToolEnd?.({
21839
+ agent: this,
21840
+ tool: tool2,
21841
+ output: void 0,
21842
+ error: voltAgentError,
21843
+ context: oc,
21844
+ options: executionOptions
21845
+ });
21846
+ if (isToolDeniedError(errorValue)) {
21847
+ oc.abortController.abort(errorValue);
21848
+ }
21849
+ return errorResult;
21850
+ }, "handleToolError");
21851
+ const execute = tool2.execute;
21852
+ if (execute && isAsyncGeneratorFunction(execute)) {
21853
+ return async function* () {
21854
+ try {
21855
+ await oc.traceContext.withSpan(toolSpan, async () => {
21856
+ await hooks.onToolStart?.({
21857
+ agent: this,
21858
+ tool: tool2,
21859
+ context: oc,
21860
+ args,
21861
+ options: executionOptions
21862
+ });
21863
+ });
21864
+ const result = execute(args, executionOptions);
21865
+ if (!isAsyncIterable(result)) {
21866
+ const resolved = await result;
21867
+ const validatedResult2 = await this.validateToolOutput(resolved, tool2);
21868
+ await oc.traceContext.withSpan(toolSpan, async () => {
21869
+ await handleToolSuccess(resolved, validatedResult2);
21870
+ });
21871
+ yield resolved;
21872
+ return;
21873
+ }
21874
+ const iterator = result[Symbol.asyncIterator]();
21875
+ let finalOutput = void 0;
21876
+ let validatedResult = void 0;
21877
+ let hasOutput = false;
21878
+ while (true) {
21879
+ const next = await oc.traceContext.withSpan(toolSpan, () => iterator.next());
21880
+ if (next.done) {
21881
+ break;
21882
+ }
21883
+ finalOutput = next.value;
21884
+ hasOutput = true;
21885
+ validatedResult = await this.validateToolOutput(finalOutput, tool2);
21886
+ yield finalOutput;
21887
+ }
21888
+ if (!hasOutput) {
21889
+ validatedResult = await this.validateToolOutput(finalOutput, tool2);
21890
+ }
21891
+ await oc.traceContext.withSpan(toolSpan, async () => {
21892
+ await handleToolSuccess(finalOutput, validatedResult);
21893
+ });
21894
+ } catch (e) {
21895
+ const errorResult = await oc.traceContext.withSpan(toolSpan, async () => {
21896
+ return await handleToolError(e);
21897
+ });
21898
+ yield errorResult;
21899
+ }
21900
+ }.call(this);
21901
+ }
21902
+ return oc.traceContext.withSpan(toolSpan, async () => {
21797
21903
  try {
21798
21904
  await hooks.onToolStart?.({
21799
21905
  agent: this,
@@ -21805,47 +21911,19 @@ ${retrieverContext}`;
21805
21911
  if (!tool2.execute) {
21806
21912
  throw new Error(`Tool ${tool2.name} does not have "execute" method`);
21807
21913
  }
21808
- const result = await tool2.execute(args, executionOptions);
21914
+ let result = await tool2.execute(args, executionOptions);
21915
+ if (isAsyncIterable(result)) {
21916
+ let lastOutput = void 0;
21917
+ for await (const output of result) {
21918
+ lastOutput = output;
21919
+ }
21920
+ result = lastOutput;
21921
+ }
21809
21922
  const validatedResult = await this.validateToolOutput(result, tool2);
21810
- toolSpan.setAttribute("output", (0, import_utils26.safeStringify)(result));
21811
- toolSpan.setStatus({ code: import_api15.SpanStatusCode.OK });
21812
- toolSpan.end();
21813
- await hooks.onToolEnd?.({
21814
- agent: this,
21815
- tool: tool2,
21816
- output: validatedResult,
21817
- error: void 0,
21818
- context: oc,
21819
- options: executionOptions
21820
- });
21923
+ await handleToolSuccess(result, validatedResult);
21821
21924
  return result;
21822
21925
  } catch (e) {
21823
- const error = e instanceof Error ? e : new Error(String(e));
21824
- const voltAgentError = createVoltAgentError(error, {
21825
- stage: "tool_execution",
21826
- toolError: {
21827
- toolCallId,
21828
- toolName: tool2.name,
21829
- toolExecutionError: error,
21830
- toolArguments: args
21831
- }
21832
- });
21833
- const errorResult = buildToolErrorResult(error, toolCallId, tool2.name);
21834
- toolSpan.setStatus({ code: import_api15.SpanStatusCode.ERROR, message: error.message });
21835
- toolSpan.recordException(error);
21836
- toolSpan.end();
21837
- await hooks.onToolEnd?.({
21838
- agent: this,
21839
- tool: tool2,
21840
- output: void 0,
21841
- error: voltAgentError,
21842
- context: oc,
21843
- options: executionOptions
21844
- });
21845
- if (isToolDeniedError(e)) {
21846
- oc.abortController.abort(e);
21847
- }
21848
- return errorResult;
21926
+ return await handleToolError(e);
21849
21927
  } finally {
21850
21928
  oc.traceContext.endChildSpan(toolSpan, "completed", {});
21851
21929
  }