@voltagent/core 1.1.20 → 1.1.21

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
@@ -2815,6 +2815,8 @@ interface OnToolEndHookArgs {
2815
2815
  interface OnPrepareMessagesHookArgs {
2816
2816
  /** The messages that will be sent to the LLM (AI SDK UIMessage). */
2817
2817
  messages: UIMessage[];
2818
+ /** The raw messages before sanitization (for advanced transformations). */
2819
+ rawMessages?: UIMessage[];
2818
2820
  /** The agent instance making the LLM call. */
2819
2821
  agent: Agent;
2820
2822
  /** The operation context containing metadata about the current operation. */
@@ -2824,6 +2826,20 @@ interface OnPrepareMessagesHookResult {
2824
2826
  /** The transformed messages to send to the LLM. */
2825
2827
  messages?: UIMessage[];
2826
2828
  }
2829
+ interface OnPrepareModelMessagesHookArgs {
2830
+ /** The finalized model messages that will be sent to the provider. */
2831
+ modelMessages: ModelMessage[];
2832
+ /** The sanitized UI messages that produced the model messages. */
2833
+ uiMessages: UIMessage[];
2834
+ /** The agent instance making the LLM call. */
2835
+ agent: Agent;
2836
+ /** The operation context containing metadata about the current operation. */
2837
+ context: OperationContext;
2838
+ }
2839
+ interface OnPrepareModelMessagesHookResult {
2840
+ /** The transformed model messages to send to the provider. */
2841
+ modelMessages?: ModelMessage[];
2842
+ }
2827
2843
  interface OnErrorHookArgs {
2828
2844
  agent: Agent;
2829
2845
  error: VoltAgentError | AbortError | Error;
@@ -2840,6 +2856,7 @@ type AgentHookOnHandoff = (args: OnHandoffHookArgs) => Promise<void> | void;
2840
2856
  type AgentHookOnToolStart = (args: OnToolStartHookArgs) => Promise<void> | void;
2841
2857
  type AgentHookOnToolEnd = (args: OnToolEndHookArgs) => Promise<void> | void;
2842
2858
  type AgentHookOnPrepareMessages = (args: OnPrepareMessagesHookArgs) => Promise<OnPrepareMessagesHookResult> | OnPrepareMessagesHookResult;
2859
+ type AgentHookOnPrepareModelMessages = (args: OnPrepareModelMessagesHookArgs) => Promise<OnPrepareModelMessagesHookResult> | OnPrepareModelMessagesHookResult;
2843
2860
  type AgentHookOnError = (args: OnErrorHookArgs) => Promise<void> | void;
2844
2861
  type AgentHookOnStepFinish = (args: OnStepFinishHookArgs) => Promise<void> | void;
2845
2862
  /**
@@ -2852,6 +2869,7 @@ type AgentHooks = {
2852
2869
  onToolStart?: AgentHookOnToolStart;
2853
2870
  onToolEnd?: AgentHookOnToolEnd;
2854
2871
  onPrepareMessages?: AgentHookOnPrepareMessages;
2872
+ onPrepareModelMessages?: AgentHookOnPrepareModelMessages;
2855
2873
  onError?: AgentHookOnError;
2856
2874
  onStepFinish?: AgentHookOnStepFinish;
2857
2875
  };
@@ -6605,7 +6623,10 @@ interface ServerApiResponse<T> {
6605
6623
  * VoltAgent constructor options
6606
6624
  */
6607
6625
  type VoltAgentOptions = {
6608
- agents: Record<string, Agent>;
6626
+ /**
6627
+ * Optional agents to register when bootstrapping VoltAgent
6628
+ */
6629
+ agents?: Record<string, Agent>;
6609
6630
  /**
6610
6631
  * Optional workflows to register with VoltAgent
6611
6632
  * Can be either Workflow instances or WorkflowChain instances
@@ -7258,7 +7279,7 @@ declare class VoltAgent {
7258
7279
  /**
7259
7280
  * Register multiple agents
7260
7281
  */
7261
- registerAgents(agents: Record<string, Agent>): void;
7282
+ registerAgents(agents?: Record<string, Agent>): void;
7262
7283
  /**
7263
7284
  * Start the server
7264
7285
  */
@@ -7334,4 +7355,4 @@ declare class VoltAgent {
7334
7355
  */
7335
7356
  declare function convertUsage(usage: LanguageModelUsage | undefined): UsageInfo | undefined;
7336
7357
 
7337
- export { A2AServerRegistry, AbortError, Agent, type AgentFullState, type AgentHookOnEnd, type AgentHookOnError, type AgentHookOnHandoff, type AgentHookOnPrepareMessages, 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, 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, Memory, type MemoryConfig, type MemoryOptions, 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 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, 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 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 };
7358
+ 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, 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, Memory, type MemoryConfig, type MemoryOptions, 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, 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 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
@@ -2815,6 +2815,8 @@ interface OnToolEndHookArgs {
2815
2815
  interface OnPrepareMessagesHookArgs {
2816
2816
  /** The messages that will be sent to the LLM (AI SDK UIMessage). */
2817
2817
  messages: UIMessage[];
2818
+ /** The raw messages before sanitization (for advanced transformations). */
2819
+ rawMessages?: UIMessage[];
2818
2820
  /** The agent instance making the LLM call. */
2819
2821
  agent: Agent;
2820
2822
  /** The operation context containing metadata about the current operation. */
@@ -2824,6 +2826,20 @@ interface OnPrepareMessagesHookResult {
2824
2826
  /** The transformed messages to send to the LLM. */
2825
2827
  messages?: UIMessage[];
2826
2828
  }
2829
+ interface OnPrepareModelMessagesHookArgs {
2830
+ /** The finalized model messages that will be sent to the provider. */
2831
+ modelMessages: ModelMessage[];
2832
+ /** The sanitized UI messages that produced the model messages. */
2833
+ uiMessages: UIMessage[];
2834
+ /** The agent instance making the LLM call. */
2835
+ agent: Agent;
2836
+ /** The operation context containing metadata about the current operation. */
2837
+ context: OperationContext;
2838
+ }
2839
+ interface OnPrepareModelMessagesHookResult {
2840
+ /** The transformed model messages to send to the provider. */
2841
+ modelMessages?: ModelMessage[];
2842
+ }
2827
2843
  interface OnErrorHookArgs {
2828
2844
  agent: Agent;
2829
2845
  error: VoltAgentError | AbortError | Error;
@@ -2840,6 +2856,7 @@ type AgentHookOnHandoff = (args: OnHandoffHookArgs) => Promise<void> | void;
2840
2856
  type AgentHookOnToolStart = (args: OnToolStartHookArgs) => Promise<void> | void;
2841
2857
  type AgentHookOnToolEnd = (args: OnToolEndHookArgs) => Promise<void> | void;
2842
2858
  type AgentHookOnPrepareMessages = (args: OnPrepareMessagesHookArgs) => Promise<OnPrepareMessagesHookResult> | OnPrepareMessagesHookResult;
2859
+ type AgentHookOnPrepareModelMessages = (args: OnPrepareModelMessagesHookArgs) => Promise<OnPrepareModelMessagesHookResult> | OnPrepareModelMessagesHookResult;
2843
2860
  type AgentHookOnError = (args: OnErrorHookArgs) => Promise<void> | void;
2844
2861
  type AgentHookOnStepFinish = (args: OnStepFinishHookArgs) => Promise<void> | void;
2845
2862
  /**
@@ -2852,6 +2869,7 @@ type AgentHooks = {
2852
2869
  onToolStart?: AgentHookOnToolStart;
2853
2870
  onToolEnd?: AgentHookOnToolEnd;
2854
2871
  onPrepareMessages?: AgentHookOnPrepareMessages;
2872
+ onPrepareModelMessages?: AgentHookOnPrepareModelMessages;
2855
2873
  onError?: AgentHookOnError;
2856
2874
  onStepFinish?: AgentHookOnStepFinish;
2857
2875
  };
@@ -6605,7 +6623,10 @@ interface ServerApiResponse<T> {
6605
6623
  * VoltAgent constructor options
6606
6624
  */
6607
6625
  type VoltAgentOptions = {
6608
- agents: Record<string, Agent>;
6626
+ /**
6627
+ * Optional agents to register when bootstrapping VoltAgent
6628
+ */
6629
+ agents?: Record<string, Agent>;
6609
6630
  /**
6610
6631
  * Optional workflows to register with VoltAgent
6611
6632
  * Can be either Workflow instances or WorkflowChain instances
@@ -7258,7 +7279,7 @@ declare class VoltAgent {
7258
7279
  /**
7259
7280
  * Register multiple agents
7260
7281
  */
7261
- registerAgents(agents: Record<string, Agent>): void;
7282
+ registerAgents(agents?: Record<string, Agent>): void;
7262
7283
  /**
7263
7284
  * Start the server
7264
7285
  */
@@ -7334,4 +7355,4 @@ declare class VoltAgent {
7334
7355
  */
7335
7356
  declare function convertUsage(usage: LanguageModelUsage | undefined): UsageInfo | undefined;
7336
7357
 
7337
- export { A2AServerRegistry, AbortError, Agent, type AgentFullState, type AgentHookOnEnd, type AgentHookOnError, type AgentHookOnHandoff, type AgentHookOnPrepareMessages, 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, 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, Memory, type MemoryConfig, type MemoryOptions, 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 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, 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 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 };
7358
+ 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, 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, Memory, type MemoryConfig, type MemoryOptions, 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, 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 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
@@ -8365,7 +8365,11 @@ function convertModelMessagesToUIMessages(messages) {
8365
8365
  };
8366
8366
  if (typeof message.content === "string") {
8367
8367
  if (message.content.trim().length > 0) {
8368
- ui.parts.push({ type: "text", text: message.content });
8368
+ ui.parts.push({
8369
+ type: "text",
8370
+ text: message.content,
8371
+ ...message.providerOptions ? { providerMetadata: message.providerOptions } : {}
8372
+ });
8369
8373
  }
8370
8374
  uiMessages.push(ui);
8371
8375
  continue;
@@ -9950,10 +9954,17 @@ var normalizeText = /* @__PURE__ */ __name((part) => {
9950
9954
  if (!text.trim()) {
9951
9955
  return null;
9952
9956
  }
9953
- return {
9957
+ const normalized = {
9954
9958
  type: "text",
9955
9959
  text
9956
9960
  };
9961
+ if (part.providerMetadata) {
9962
+ normalized.providerMetadata = safeClone(part.providerMetadata);
9963
+ }
9964
+ if (part.state) {
9965
+ normalized.state = part.state;
9966
+ }
9967
+ return normalized;
9957
9968
  }, "normalizeText");
9958
9969
  var normalizeReasoning = /* @__PURE__ */ __name((part) => {
9959
9970
  const text = typeof part.text === "string" ? part.text : "";
@@ -11517,8 +11528,19 @@ var Agent = class {
11517
11528
  const agentToolList = await this.resolveValue(this.tools, oc);
11518
11529
  const buffer = this.getConversationBuffer(oc);
11519
11530
  const uiMessages = await this.prepareMessages(input, oc, options, buffer);
11520
- const sanitizedUIMessages = sanitizeMessagesForModel(uiMessages);
11521
- const messages = (0, import_ai2.convertToModelMessages)(sanitizedUIMessages);
11531
+ const hooks = this.getMergedHooks(options);
11532
+ let messages = (0, import_ai2.convertToModelMessages)(uiMessages);
11533
+ if (hooks.onPrepareModelMessages) {
11534
+ const result = await hooks.onPrepareModelMessages({
11535
+ modelMessages: messages,
11536
+ uiMessages,
11537
+ agent: this,
11538
+ context: oc
11539
+ });
11540
+ if (result?.modelMessages) {
11541
+ messages = result.modelMessages;
11542
+ }
11543
+ }
11522
11544
  const maxSteps = options?.maxSteps ?? this.calculateMaxSteps();
11523
11545
  const agentToolsArray = Array.isArray(agentToolList) ? agentToolList : [];
11524
11546
  const optionToolsArray = options?.tools || [];
@@ -11526,7 +11548,7 @@ var Agent = class {
11526
11548
  const tools = await this.prepareTools(mergedTools, oc, maxSteps, options);
11527
11549
  return {
11528
11550
  messages,
11529
- uiMessages: sanitizedUIMessages,
11551
+ uiMessages,
11530
11552
  model,
11531
11553
  tools,
11532
11554
  maxSteps
@@ -11754,19 +11776,36 @@ var Agent = class {
11754
11776
  const messages = [];
11755
11777
  const systemMessage = await this.getSystemMessage(input, oc, options);
11756
11778
  if (systemMessage) {
11757
- const systemUIMessage = {
11758
- id: randomUUID(),
11759
- role: "system",
11760
- parts: [
11761
- {
11762
- type: "text",
11763
- text: typeof systemMessage === "string" ? systemMessage : Array.isArray(systemMessage) ? systemMessage.map((m) => typeof m.content === "string" ? m.content : "").join("\n") : typeof systemMessage.content === "string" ? systemMessage.content : ""
11764
- }
11765
- ]
11766
- };
11767
- messages.push(systemUIMessage);
11768
- if (systemUIMessage.parts[0]?.type === "text") {
11769
- oc.traceContext.setInstructions(systemUIMessage.parts[0].text);
11779
+ const systemMessagesAsUI = (() => {
11780
+ if (typeof systemMessage === "string") {
11781
+ return [
11782
+ {
11783
+ id: randomUUID(),
11784
+ role: "system",
11785
+ parts: [
11786
+ {
11787
+ type: "text",
11788
+ text: systemMessage
11789
+ }
11790
+ ]
11791
+ }
11792
+ ];
11793
+ }
11794
+ if (Array.isArray(systemMessage)) {
11795
+ return convertModelMessagesToUIMessages(systemMessage);
11796
+ }
11797
+ return convertModelMessagesToUIMessages([systemMessage]);
11798
+ })();
11799
+ for (const systemUIMessage of systemMessagesAsUI) {
11800
+ messages.push(systemUIMessage);
11801
+ }
11802
+ const instructionText = systemMessagesAsUI.flatMap(
11803
+ (msg) => msg.parts.flatMap(
11804
+ (part) => part.type === "text" && typeof part.text === "string" ? [part.text] : []
11805
+ )
11806
+ ).join("\n\n");
11807
+ if (instructionText) {
11808
+ oc.traceContext.setInstructions(instructionText);
11770
11809
  }
11771
11810
  }
11772
11811
  const canIUseMemory = options?.userId && options.conversationId;
@@ -11870,12 +11909,18 @@ var Agent = class {
11870
11909
  messages.push(...convertModelMessagesToUIMessages(input));
11871
11910
  }
11872
11911
  }
11912
+ const sanitizedMessages = sanitizeMessagesForModel(messages);
11873
11913
  const hooks = this.getMergedHooks(options);
11874
11914
  if (hooks.onPrepareMessages) {
11875
- const result = await hooks.onPrepareMessages({ messages, agent: this, context: oc });
11876
- return result?.messages || messages;
11915
+ const result = await hooks.onPrepareMessages({
11916
+ messages: sanitizedMessages,
11917
+ rawMessages: messages,
11918
+ agent: this,
11919
+ context: oc
11920
+ });
11921
+ return result?.messages || sanitizedMessages;
11877
11922
  }
11878
- return messages;
11923
+ return sanitizedMessages;
11879
11924
  }
11880
11925
  /**
11881
11926
  * Get system message with dynamic instructions and retriever context
@@ -12431,7 +12476,8 @@ ${toolkit.instructions}`;
12431
12476
  await options.hooks?.onStepFinish?.(...args);
12432
12477
  await this.hooks.onStepFinish?.(...args);
12433
12478
  }, "onStepFinish"),
12434
- onPrepareMessages: options.hooks?.onPrepareMessages || this.hooks.onPrepareMessages
12479
+ onPrepareMessages: options.hooks?.onPrepareMessages || this.hooks.onPrepareMessages,
12480
+ onPrepareModelMessages: options.hooks?.onPrepareModelMessages || this.hooks.onPrepareModelMessages
12435
12481
  };
12436
12482
  }
12437
12483
  /**
@@ -12795,6 +12841,7 @@ var defaultHooks = {
12795
12841
  onToolEnd: /* @__PURE__ */ __name(async (_args) => {
12796
12842
  }, "onToolEnd"),
12797
12843
  onPrepareMessages: /* @__PURE__ */ __name(async (_args) => ({}), "onPrepareMessages"),
12844
+ onPrepareModelMessages: /* @__PURE__ */ __name(async (_args) => ({}), "onPrepareModelMessages"),
12798
12845
  onError: /* @__PURE__ */ __name(async (_args) => {
12799
12846
  }, "onError"),
12800
12847
  onStepFinish: /* @__PURE__ */ __name(async (_args) => {
@@ -12808,6 +12855,7 @@ function createHooks(hooks = {}) {
12808
12855
  onToolStart: hooks.onToolStart || defaultHooks.onToolStart,
12809
12856
  onToolEnd: hooks.onToolEnd || defaultHooks.onToolEnd,
12810
12857
  onPrepareMessages: hooks.onPrepareMessages || defaultHooks.onPrepareMessages,
12858
+ onPrepareModelMessages: hooks.onPrepareModelMessages || defaultHooks.onPrepareModelMessages,
12811
12859
  onError: hooks.onError || defaultHooks.onError,
12812
12860
  onStepFinish: hooks.onStepFinish || defaultHooks.onStepFinish
12813
12861
  };
@@ -15222,6 +15270,9 @@ var VoltAgent = class {
15222
15270
  * Register multiple agents
15223
15271
  */
15224
15272
  registerAgents(agents) {
15273
+ if (!agents) {
15274
+ return;
15275
+ }
15225
15276
  Object.values(agents).forEach((agent) => this.registerAgent(agent));
15226
15277
  }
15227
15278
  /**