@voltagent/core 0.1.77 → 0.1.79

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
@@ -1829,11 +1829,34 @@ interface OnToolEndHookArgs {
1829
1829
  error: VoltAgentError | AbortError | undefined;
1830
1830
  context: OperationContext;
1831
1831
  }
1832
+ interface OnPrepareMessagesHookArgs {
1833
+ /**
1834
+ * The messages that will be sent to the LLM.
1835
+ * Modify and return this array to transform the messages.
1836
+ */
1837
+ messages: BaseMessage[];
1838
+ /**
1839
+ * The agent instance making the LLM call.
1840
+ */
1841
+ agent: Agent<any>;
1842
+ /**
1843
+ * The operation context containing metadata about the current operation.
1844
+ */
1845
+ context: OperationContext;
1846
+ }
1847
+ interface OnPrepareMessagesHookResult {
1848
+ /**
1849
+ * The transformed messages to send to the LLM.
1850
+ * If not provided, the original messages will be used.
1851
+ */
1852
+ messages?: BaseMessage[];
1853
+ }
1832
1854
  type AgentHookOnStart = (args: OnStartHookArgs) => Promise<void> | void;
1833
1855
  type AgentHookOnEnd = (args: OnEndHookArgs) => Promise<void> | void;
1834
1856
  type AgentHookOnHandoff = (args: OnHandoffHookArgs) => Promise<void> | void;
1835
1857
  type AgentHookOnToolStart = (args: OnToolStartHookArgs) => Promise<void> | void;
1836
1858
  type AgentHookOnToolEnd = (args: OnToolEndHookArgs) => Promise<void> | void;
1859
+ type AgentHookOnPrepareMessages = (args: OnPrepareMessagesHookArgs) => Promise<OnPrepareMessagesHookResult> | OnPrepareMessagesHookResult;
1837
1860
  /**
1838
1861
  * Type definition for agent hooks using single argument objects.
1839
1862
  */
@@ -1843,6 +1866,7 @@ type AgentHooks = {
1843
1866
  onHandoff?: AgentHookOnHandoff;
1844
1867
  onToolStart?: AgentHookOnToolStart;
1845
1868
  onToolEnd?: AgentHookOnToolEnd;
1869
+ onPrepareMessages?: AgentHookOnPrepareMessages;
1846
1870
  };
1847
1871
  /**
1848
1872
  * Create hooks from an object literal.
@@ -1882,6 +1906,23 @@ type ProviderOptions = {
1882
1906
  /**
1883
1907
  * Configuration for supervisor agents that have subagents
1884
1908
  */
1909
+ /**
1910
+ * Configuration for forwarding events from subagents to the parent agent's stream
1911
+ */
1912
+ type FullStreamEventForwardingConfig = {
1913
+ /**
1914
+ * Array of event types to forward from subagents
1915
+ * Uses StreamEventType which includes: 'text-delta', 'reasoning', 'source', 'tool-call', 'tool-result', 'finish', 'error'
1916
+ * @default ['tool-call', 'tool-result']
1917
+ * @example ['tool-call', 'tool-result', 'text-delta', 'reasoning', 'source']
1918
+ */
1919
+ types?: StreamEventType[];
1920
+ /**
1921
+ * Whether to add the subagent name as a prefix to tool names in forwarded events
1922
+ * @default true
1923
+ */
1924
+ addSubAgentPrefix?: boolean;
1925
+ };
1885
1926
  type SupervisorConfig = {
1886
1927
  /**
1887
1928
  * Complete custom system message for the supervisor agent
@@ -1898,6 +1939,12 @@ type SupervisorConfig = {
1898
1939
  * Additional custom guidelines for the supervisor agent
1899
1940
  */
1900
1941
  customGuidelines?: string[];
1942
+ /**
1943
+ * Configuration for forwarding events from subagents to the parent agent's full stream
1944
+ * Controls which event types are forwarded and how they are formatted
1945
+ * @default { types: ['tool-call', 'tool-result'], addSubAgentPrefix: true }
1946
+ */
1947
+ fullStreamEventForwarding?: FullStreamEventForwardingConfig;
1901
1948
  };
1902
1949
  /**
1903
1950
  * Agent configuration options
@@ -4470,13 +4517,18 @@ declare class SubAgentManager {
4470
4517
  * Can be either direct Agent instances or SubAgentConfigObject instances
4471
4518
  */
4472
4519
  private subAgentConfigs;
4520
+ /**
4521
+ * Supervisor configuration including event forwarding settings
4522
+ */
4523
+ private supervisorConfig?;
4473
4524
  /**
4474
4525
  * Creates a new SubAgentManager instance
4475
4526
  *
4476
4527
  * @param agentName - The name of the agent that owns this sub-agent manager
4477
4528
  * @param subAgents - Initial sub-agent configurations to add
4529
+ * @param supervisorConfig - Optional supervisor configuration including event forwarding
4478
4530
  */
4479
- constructor(agentName: string, subAgents?: SubAgentConfig[]);
4531
+ constructor(agentName: string, subAgents?: SubAgentConfig[], supervisorConfig?: SupervisorConfig);
4480
4532
  /**
4481
4533
  * Add a sub-agent that the parent agent can delegate tasks to
4482
4534
  */
@@ -6709,6 +6761,149 @@ declare const updateSinglePackage: (packageName: string, packagePath?: string) =
6709
6761
  declare function safeJsonParse(value: string | null | undefined): any;
6710
6762
  declare function serializeValueForDebug(value: unknown): unknown;
6711
6763
 
6764
+ /**
6765
+ * Type guard to check if content is a string
6766
+ */
6767
+ declare function isTextContent(content: MessageContent): content is string;
6768
+ /**
6769
+ * Type guard to check if content is structured (array of content parts)
6770
+ */
6771
+ declare function isStructuredContent(content: MessageContent): content is Array<any>;
6772
+ /**
6773
+ * Check if content has any text parts
6774
+ */
6775
+ declare function hasTextPart(content: MessageContent): boolean;
6776
+ /**
6777
+ * Check if content has any image parts
6778
+ */
6779
+ declare function hasImagePart(content: MessageContent): boolean;
6780
+ /**
6781
+ * Check if content has any file parts
6782
+ */
6783
+ declare function hasFilePart(content: MessageContent): boolean;
6784
+ /**
6785
+ * Extract text from message content
6786
+ */
6787
+ declare function extractText(content: MessageContent): string;
6788
+ /**
6789
+ * Extract all text parts from structured content
6790
+ */
6791
+ declare function extractTextParts(content: MessageContent): Array<{
6792
+ type: "text";
6793
+ text: string;
6794
+ }>;
6795
+ /**
6796
+ * Extract image parts from message content
6797
+ */
6798
+ declare function extractImageParts(content: MessageContent): Array<any>;
6799
+ /**
6800
+ * Extract file parts from message content
6801
+ */
6802
+ declare function extractFileParts(content: MessageContent): Array<any>;
6803
+ /**
6804
+ * Transform text content in a message
6805
+ */
6806
+ declare function transformTextContent(content: MessageContent, transformer: (text: string) => string): MessageContent;
6807
+ /**
6808
+ * Map message content with a transformer function
6809
+ */
6810
+ declare function mapMessageContent<T extends BaseMessage>(message: T, transformer: (text: string) => string): T;
6811
+ /**
6812
+ * Filter content parts by type
6813
+ */
6814
+ declare function filterContentParts(content: MessageContent, predicate: (part: any) => boolean): MessageContent;
6815
+ /**
6816
+ * Normalize content to always be an array
6817
+ */
6818
+ declare function normalizeToArray(content: MessageContent): Array<any>;
6819
+ /**
6820
+ * Normalize content to the most compact form
6821
+ */
6822
+ declare function normalizeContent(content: MessageContent): MessageContent;
6823
+ /**
6824
+ * Builder class for creating message content
6825
+ */
6826
+ declare class MessageContentBuilder {
6827
+ private parts;
6828
+ /**
6829
+ * Add a text part
6830
+ */
6831
+ addText(text: string): this;
6832
+ /**
6833
+ * Add an image part
6834
+ */
6835
+ addImage(image: string | Uint8Array): this;
6836
+ /**
6837
+ * Add a file part
6838
+ */
6839
+ addFile(file: string | Uint8Array, mimeType?: string): this;
6840
+ /**
6841
+ * Add a custom part
6842
+ */
6843
+ addPart(part: any): this;
6844
+ /**
6845
+ * Build the final content
6846
+ */
6847
+ build(): MessageContent;
6848
+ /**
6849
+ * Build as array (always returns array)
6850
+ */
6851
+ buildAsArray(): Array<any>;
6852
+ /**
6853
+ * Clear all parts
6854
+ */
6855
+ clear(): this;
6856
+ /**
6857
+ * Get current parts count
6858
+ */
6859
+ get length(): number;
6860
+ }
6861
+ /**
6862
+ * Convenience function to add timestamp to user messages
6863
+ */
6864
+ declare function addTimestampToMessage(message: BaseMessage, timestamp?: string): BaseMessage;
6865
+ /**
6866
+ * Convenience function to prepend text to message content
6867
+ */
6868
+ declare function prependToMessage(message: BaseMessage, prefix: string): BaseMessage;
6869
+ /**
6870
+ * Convenience function to append text to message content
6871
+ */
6872
+ declare function appendToMessage(message: BaseMessage, suffix: string): BaseMessage;
6873
+ /**
6874
+ * Check if message has any content
6875
+ */
6876
+ declare function hasContent(message: BaseMessage): boolean;
6877
+ /**
6878
+ * Get content length (text characters or array items)
6879
+ */
6880
+ declare function getContentLength(content: MessageContent): number;
6881
+ /**
6882
+ * Combined message helpers object for easy importing
6883
+ */
6884
+ declare const messageHelpers: {
6885
+ isTextContent: typeof isTextContent;
6886
+ isStructuredContent: typeof isStructuredContent;
6887
+ hasTextPart: typeof hasTextPart;
6888
+ hasImagePart: typeof hasImagePart;
6889
+ hasFilePart: typeof hasFilePart;
6890
+ extractText: typeof extractText;
6891
+ extractTextParts: typeof extractTextParts;
6892
+ extractImageParts: typeof extractImageParts;
6893
+ extractFileParts: typeof extractFileParts;
6894
+ transformTextContent: typeof transformTextContent;
6895
+ mapMessageContent: typeof mapMessageContent;
6896
+ filterContentParts: typeof filterContentParts;
6897
+ normalizeToArray: typeof normalizeToArray;
6898
+ normalizeContent: typeof normalizeContent;
6899
+ addTimestampToMessage: typeof addTimestampToMessage;
6900
+ prependToMessage: typeof prependToMessage;
6901
+ appendToMessage: typeof appendToMessage;
6902
+ hasContent: typeof hasContent;
6903
+ getContentLength: typeof getContentLength;
6904
+ MessageContentBuilder: typeof MessageContentBuilder;
6905
+ };
6906
+
6712
6907
  /**
6713
6908
  * Creates an AgentTool from a retriever, allowing it to be used as a tool in an agent.
6714
6909
  * This is the preferred way to use a retriever as a tool, as it properly maintains the 'this' context.
@@ -7387,4 +7582,4 @@ declare class VoltAgent {
7387
7582
  shutdownTelemetry(): Promise<void>;
7388
7583
  }
7389
7584
 
7390
- export { type AbortError, Agent, type AgentErrorEvent, AgentEventEmitter, type AgentHistoryEntry, type AgentHookOnEnd, type AgentHookOnHandoff, type AgentHookOnStart, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentStartEvent, type AgentStartEventMetadata, type AgentSuccessEvent, type AgentSuccessEventMetadata, type AgentTimelineEvent, type AgentTool, type AllowedVariableValue, type AnyToolConfig, type BaseEventMetadata, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTimelineEvent, type BaseTool, type BaseToolCall, type CachedPrompt, type ChatMessage, type ClientInfo, type Conversation, type ConversationQueryOptions, type CreateConversationInput, type CreateReasoningToolsOptions, type CustomEndpointDefinition, CustomEndpointError, type CustomEndpointHandler, DEFAULT_INSTRUCTIONS, type DataContent, type DynamicValue, type DynamicValueOptions, type ErrorStreamPart, type EventStatus, type ExtractVariableNames, FEW_SHOT_EXAMPLES, type FilePart, type FinishStreamPart, type GenerateObjectOptions, type GenerateTextOptions, type HTTPServerConfig, type HistoryStatus, type HttpMethod, type VoltOpsClient$1 as IVoltOpsClient, type ImagePart, InMemoryStorage, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type LLMProvider, LibSQLStorage, MCPClient, type MCPClientConfig, type MCPClientEvents, MCPConfiguration, type MCPOptions, type MCPServerConfig, type MCPToolCall, type MCPToolResult, type Memory, type MemoryEventMetadata, MemoryManager, type MemoryMessage, type MemoryOptions, type MemoryReadErrorEvent, type MemoryReadStartEvent, type MemoryReadSuccessEvent, type MemoryWriteErrorEvent, type MemoryWriteStartEvent, type MemoryWriteSuccessEvent, type MessageContent, type MessageFilterOptions, type MessageRole, type ModelToolCall, type NewTimelineEvent, NextAction, NodeType, type ObjectSubAgentConfig, type OnEndHookArgs, type OnHandoffHookArgs, type OnStartHookArgs, 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 ReasoningStreamPart, type ReasoningToolExecuteOptions, type RetrieveOptions, type Retriever, type RetrieverErrorEvent, type RetrieverOptions, type RetrieverStartEvent, type RetrieverSuccessEvent, type SSEServerConfig, type ServerOptions, type SourceStreamPart, type StandardEventData, type StandardTimelineEvent, type StdioServerConfig, type StepChunkCallback, type StepFinishCallback, type StepWithContent, type StreamEventForwarderOptions, type StreamObjectFinishResult, type StreamObjectOnFinishCallback, type StreamObjectOptions, type StreamPart, type StreamTextFinishResult, type StreamTextOnFinishCallback, type StreamTextOptions, type StreamableHTTPServerConfig, type SubAgentConfig, type SubAgentConfigObject, type SubAgentMethod, type TemplateVariables, type TextDeltaStreamPart, type TextPart, type TextSubAgentConfig, type TimelineEventCoreLevel, type TimelineEventCoreStatus, type TimelineEventCoreType, Tool, type ToolCall, type ToolCallStreamPart, type ToolErrorEvent, type ToolErrorInfo, type ToolExecuteOptions, type ToolExecutionContext, ToolManager, type ToolOptions, type ToolResultStreamPart, type ToolSchema, type ToolStartEvent, type ToolStatus, type ToolStatusInfo, type ToolSuccessEvent, type Toolkit, type ToolsetMap, type ToolsetWithTools, type TransportError, type Usage, type UsageInfo, type Voice, type VoiceEventData, type VoiceEventType, type VoiceMetadata, type VoiceOptions, VoltAgent, type VoltAgentError, VoltAgentExporter, type VoltAgentExporterOptions, type VoltAgentOptions, VoltOpsClient, type VoltOpsClientOptions, VoltOpsPromptApiClient, type VoltOpsPromptManager, VoltOpsPromptManagerImpl, type Workflow, type WorkflowConfig, type WorkflowErrorEvent, type WorkflowEvent, WorkflowEventEmitter, type WorkflowEventMetadata, type WorkflowExecutionContext, type WorkflowHistoryEntry, WorkflowRegistry, type WorkflowStartEvent, type WorkflowStepContext, type WorkflowStepErrorEvent, type WorkflowStepEventMetadata, type WorkflowStepHistoryEntry, type WorkflowStepStartEvent, type WorkflowStepSuccessEvent, type WorkflowStepSuspendEvent, type WorkflowStepType, type WorkflowSuccessEvent, type WorkflowSuspendEvent, type WorkflowTimelineEvent, andAgent, andAll, andRace, andTap, andThen, andWhen, andWorkflow, buildRetrieverLogMessage, checkForUpdates, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createSimpleTemplateEngine, createStreamEventForwarder, createSubagent, createSuspendController, createTool, createToolkit, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, extractWorkflowStepInfo, getNodeTypeFromNodeId, getWorkflowStepNodeType, isAbortError, isVoltAgentError, registerCustomEndpoint, registerCustomEndpoints, safeJsonParse, serializeValueForDebug, streamEventForwarder, tool, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
7585
+ export { type AbortError, Agent, type AgentErrorEvent, AgentEventEmitter, type AgentHistoryEntry, type AgentHookOnEnd, type AgentHookOnHandoff, type AgentHookOnPrepareMessages, type AgentHookOnStart, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentStartEvent, type AgentStartEventMetadata, type AgentSuccessEvent, type AgentSuccessEventMetadata, type AgentTimelineEvent, type AgentTool, type AllowedVariableValue, type AnyToolConfig, type BaseEventMetadata, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTimelineEvent, type BaseTool, type BaseToolCall, type CachedPrompt, type ChatMessage, type ClientInfo, type Conversation, type ConversationQueryOptions, type CreateConversationInput, type CreateReasoningToolsOptions, type CustomEndpointDefinition, CustomEndpointError, type CustomEndpointHandler, DEFAULT_INSTRUCTIONS, type DataContent, type DynamicValue, type DynamicValueOptions, type ErrorStreamPart, type EventStatus, type ExtractVariableNames, FEW_SHOT_EXAMPLES, type FilePart, type FinishStreamPart, type GenerateObjectOptions, type GenerateTextOptions, type HTTPServerConfig, type HistoryStatus, type HttpMethod, type VoltOpsClient$1 as IVoltOpsClient, type ImagePart, InMemoryStorage, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type LLMProvider, LibSQLStorage, MCPClient, type MCPClientConfig, type MCPClientEvents, MCPConfiguration, type MCPOptions, type MCPServerConfig, type MCPToolCall, type MCPToolResult, type Memory, type MemoryEventMetadata, MemoryManager, type MemoryMessage, type MemoryOptions, type MemoryReadErrorEvent, type MemoryReadStartEvent, type MemoryReadSuccessEvent, type MemoryWriteErrorEvent, type MemoryWriteStartEvent, type MemoryWriteSuccessEvent, type MessageContent, MessageContentBuilder, type MessageFilterOptions, type MessageRole, type ModelToolCall, type NewTimelineEvent, NextAction, NodeType, type ObjectSubAgentConfig, type OnEndHookArgs, type OnHandoffHookArgs, type OnPrepareMessagesHookArgs, type OnPrepareMessagesHookResult, type OnStartHookArgs, 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 ReasoningStreamPart, type ReasoningToolExecuteOptions, type RetrieveOptions, type Retriever, type RetrieverErrorEvent, type RetrieverOptions, type RetrieverStartEvent, type RetrieverSuccessEvent, type SSEServerConfig, type ServerOptions, type SourceStreamPart, type StandardEventData, type StandardTimelineEvent, type StdioServerConfig, type StepChunkCallback, type StepFinishCallback, type StepWithContent, type StreamEventForwarderOptions, type StreamObjectFinishResult, type StreamObjectOnFinishCallback, type StreamObjectOptions, type StreamPart, type StreamTextFinishResult, type StreamTextOnFinishCallback, type StreamTextOptions, type StreamableHTTPServerConfig, type SubAgentConfig, type SubAgentConfigObject, type SubAgentMethod, type TemplateVariables, type TextDeltaStreamPart, type TextPart, type TextSubAgentConfig, type TimelineEventCoreLevel, type TimelineEventCoreStatus, type TimelineEventCoreType, Tool, type ToolCall, type ToolCallStreamPart, type ToolErrorEvent, type ToolErrorInfo, type ToolExecuteOptions, type ToolExecutionContext, ToolManager, type ToolOptions, type ToolResultStreamPart, type ToolSchema, type ToolStartEvent, type ToolStatus, type ToolStatusInfo, type ToolSuccessEvent, type Toolkit, type ToolsetMap, type ToolsetWithTools, type TransportError, type Usage, type UsageInfo, type Voice, type VoiceEventData, type VoiceEventType, type VoiceMetadata, type VoiceOptions, VoltAgent, type VoltAgentError, VoltAgentExporter, type VoltAgentExporterOptions, type VoltAgentOptions, VoltOpsClient, type VoltOpsClientOptions, VoltOpsPromptApiClient, type VoltOpsPromptManager, VoltOpsPromptManagerImpl, type Workflow, type WorkflowConfig, type WorkflowErrorEvent, type WorkflowEvent, WorkflowEventEmitter, type WorkflowEventMetadata, type WorkflowExecutionContext, type WorkflowHistoryEntry, WorkflowRegistry, type WorkflowStartEvent, type WorkflowStepContext, type WorkflowStepErrorEvent, type WorkflowStepEventMetadata, type WorkflowStepHistoryEntry, type WorkflowStepStartEvent, type WorkflowStepSuccessEvent, type WorkflowStepSuspendEvent, type WorkflowStepType, type WorkflowSuccessEvent, type WorkflowSuspendEvent, type WorkflowTimelineEvent, addTimestampToMessage, andAgent, andAll, andRace, andTap, andThen, andWhen, andWorkflow, appendToMessage, buildRetrieverLogMessage, checkForUpdates, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createSimpleTemplateEngine, createStreamEventForwarder, createSubagent, createSuspendController, createTool, createToolkit, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, extractFileParts, extractImageParts, extractText, extractTextParts, extractWorkflowStepInfo, filterContentParts, getContentLength, getNodeTypeFromNodeId, getWorkflowStepNodeType, hasContent, hasFilePart, hasImagePart, hasTextPart, isAbortError, isStructuredContent, isTextContent, isVoltAgentError, mapMessageContent, messageHelpers, normalizeContent, normalizeToArray, prependToMessage, registerCustomEndpoint, registerCustomEndpoints, safeJsonParse, serializeValueForDebug, streamEventForwarder, tool, transformTextContent, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
package/dist/index.d.ts CHANGED
@@ -1829,11 +1829,34 @@ interface OnToolEndHookArgs {
1829
1829
  error: VoltAgentError | AbortError | undefined;
1830
1830
  context: OperationContext;
1831
1831
  }
1832
+ interface OnPrepareMessagesHookArgs {
1833
+ /**
1834
+ * The messages that will be sent to the LLM.
1835
+ * Modify and return this array to transform the messages.
1836
+ */
1837
+ messages: BaseMessage[];
1838
+ /**
1839
+ * The agent instance making the LLM call.
1840
+ */
1841
+ agent: Agent<any>;
1842
+ /**
1843
+ * The operation context containing metadata about the current operation.
1844
+ */
1845
+ context: OperationContext;
1846
+ }
1847
+ interface OnPrepareMessagesHookResult {
1848
+ /**
1849
+ * The transformed messages to send to the LLM.
1850
+ * If not provided, the original messages will be used.
1851
+ */
1852
+ messages?: BaseMessage[];
1853
+ }
1832
1854
  type AgentHookOnStart = (args: OnStartHookArgs) => Promise<void> | void;
1833
1855
  type AgentHookOnEnd = (args: OnEndHookArgs) => Promise<void> | void;
1834
1856
  type AgentHookOnHandoff = (args: OnHandoffHookArgs) => Promise<void> | void;
1835
1857
  type AgentHookOnToolStart = (args: OnToolStartHookArgs) => Promise<void> | void;
1836
1858
  type AgentHookOnToolEnd = (args: OnToolEndHookArgs) => Promise<void> | void;
1859
+ type AgentHookOnPrepareMessages = (args: OnPrepareMessagesHookArgs) => Promise<OnPrepareMessagesHookResult> | OnPrepareMessagesHookResult;
1837
1860
  /**
1838
1861
  * Type definition for agent hooks using single argument objects.
1839
1862
  */
@@ -1843,6 +1866,7 @@ type AgentHooks = {
1843
1866
  onHandoff?: AgentHookOnHandoff;
1844
1867
  onToolStart?: AgentHookOnToolStart;
1845
1868
  onToolEnd?: AgentHookOnToolEnd;
1869
+ onPrepareMessages?: AgentHookOnPrepareMessages;
1846
1870
  };
1847
1871
  /**
1848
1872
  * Create hooks from an object literal.
@@ -1882,6 +1906,23 @@ type ProviderOptions = {
1882
1906
  /**
1883
1907
  * Configuration for supervisor agents that have subagents
1884
1908
  */
1909
+ /**
1910
+ * Configuration for forwarding events from subagents to the parent agent's stream
1911
+ */
1912
+ type FullStreamEventForwardingConfig = {
1913
+ /**
1914
+ * Array of event types to forward from subagents
1915
+ * Uses StreamEventType which includes: 'text-delta', 'reasoning', 'source', 'tool-call', 'tool-result', 'finish', 'error'
1916
+ * @default ['tool-call', 'tool-result']
1917
+ * @example ['tool-call', 'tool-result', 'text-delta', 'reasoning', 'source']
1918
+ */
1919
+ types?: StreamEventType[];
1920
+ /**
1921
+ * Whether to add the subagent name as a prefix to tool names in forwarded events
1922
+ * @default true
1923
+ */
1924
+ addSubAgentPrefix?: boolean;
1925
+ };
1885
1926
  type SupervisorConfig = {
1886
1927
  /**
1887
1928
  * Complete custom system message for the supervisor agent
@@ -1898,6 +1939,12 @@ type SupervisorConfig = {
1898
1939
  * Additional custom guidelines for the supervisor agent
1899
1940
  */
1900
1941
  customGuidelines?: string[];
1942
+ /**
1943
+ * Configuration for forwarding events from subagents to the parent agent's full stream
1944
+ * Controls which event types are forwarded and how they are formatted
1945
+ * @default { types: ['tool-call', 'tool-result'], addSubAgentPrefix: true }
1946
+ */
1947
+ fullStreamEventForwarding?: FullStreamEventForwardingConfig;
1901
1948
  };
1902
1949
  /**
1903
1950
  * Agent configuration options
@@ -4470,13 +4517,18 @@ declare class SubAgentManager {
4470
4517
  * Can be either direct Agent instances or SubAgentConfigObject instances
4471
4518
  */
4472
4519
  private subAgentConfigs;
4520
+ /**
4521
+ * Supervisor configuration including event forwarding settings
4522
+ */
4523
+ private supervisorConfig?;
4473
4524
  /**
4474
4525
  * Creates a new SubAgentManager instance
4475
4526
  *
4476
4527
  * @param agentName - The name of the agent that owns this sub-agent manager
4477
4528
  * @param subAgents - Initial sub-agent configurations to add
4529
+ * @param supervisorConfig - Optional supervisor configuration including event forwarding
4478
4530
  */
4479
- constructor(agentName: string, subAgents?: SubAgentConfig[]);
4531
+ constructor(agentName: string, subAgents?: SubAgentConfig[], supervisorConfig?: SupervisorConfig);
4480
4532
  /**
4481
4533
  * Add a sub-agent that the parent agent can delegate tasks to
4482
4534
  */
@@ -6709,6 +6761,149 @@ declare const updateSinglePackage: (packageName: string, packagePath?: string) =
6709
6761
  declare function safeJsonParse(value: string | null | undefined): any;
6710
6762
  declare function serializeValueForDebug(value: unknown): unknown;
6711
6763
 
6764
+ /**
6765
+ * Type guard to check if content is a string
6766
+ */
6767
+ declare function isTextContent(content: MessageContent): content is string;
6768
+ /**
6769
+ * Type guard to check if content is structured (array of content parts)
6770
+ */
6771
+ declare function isStructuredContent(content: MessageContent): content is Array<any>;
6772
+ /**
6773
+ * Check if content has any text parts
6774
+ */
6775
+ declare function hasTextPart(content: MessageContent): boolean;
6776
+ /**
6777
+ * Check if content has any image parts
6778
+ */
6779
+ declare function hasImagePart(content: MessageContent): boolean;
6780
+ /**
6781
+ * Check if content has any file parts
6782
+ */
6783
+ declare function hasFilePart(content: MessageContent): boolean;
6784
+ /**
6785
+ * Extract text from message content
6786
+ */
6787
+ declare function extractText(content: MessageContent): string;
6788
+ /**
6789
+ * Extract all text parts from structured content
6790
+ */
6791
+ declare function extractTextParts(content: MessageContent): Array<{
6792
+ type: "text";
6793
+ text: string;
6794
+ }>;
6795
+ /**
6796
+ * Extract image parts from message content
6797
+ */
6798
+ declare function extractImageParts(content: MessageContent): Array<any>;
6799
+ /**
6800
+ * Extract file parts from message content
6801
+ */
6802
+ declare function extractFileParts(content: MessageContent): Array<any>;
6803
+ /**
6804
+ * Transform text content in a message
6805
+ */
6806
+ declare function transformTextContent(content: MessageContent, transformer: (text: string) => string): MessageContent;
6807
+ /**
6808
+ * Map message content with a transformer function
6809
+ */
6810
+ declare function mapMessageContent<T extends BaseMessage>(message: T, transformer: (text: string) => string): T;
6811
+ /**
6812
+ * Filter content parts by type
6813
+ */
6814
+ declare function filterContentParts(content: MessageContent, predicate: (part: any) => boolean): MessageContent;
6815
+ /**
6816
+ * Normalize content to always be an array
6817
+ */
6818
+ declare function normalizeToArray(content: MessageContent): Array<any>;
6819
+ /**
6820
+ * Normalize content to the most compact form
6821
+ */
6822
+ declare function normalizeContent(content: MessageContent): MessageContent;
6823
+ /**
6824
+ * Builder class for creating message content
6825
+ */
6826
+ declare class MessageContentBuilder {
6827
+ private parts;
6828
+ /**
6829
+ * Add a text part
6830
+ */
6831
+ addText(text: string): this;
6832
+ /**
6833
+ * Add an image part
6834
+ */
6835
+ addImage(image: string | Uint8Array): this;
6836
+ /**
6837
+ * Add a file part
6838
+ */
6839
+ addFile(file: string | Uint8Array, mimeType?: string): this;
6840
+ /**
6841
+ * Add a custom part
6842
+ */
6843
+ addPart(part: any): this;
6844
+ /**
6845
+ * Build the final content
6846
+ */
6847
+ build(): MessageContent;
6848
+ /**
6849
+ * Build as array (always returns array)
6850
+ */
6851
+ buildAsArray(): Array<any>;
6852
+ /**
6853
+ * Clear all parts
6854
+ */
6855
+ clear(): this;
6856
+ /**
6857
+ * Get current parts count
6858
+ */
6859
+ get length(): number;
6860
+ }
6861
+ /**
6862
+ * Convenience function to add timestamp to user messages
6863
+ */
6864
+ declare function addTimestampToMessage(message: BaseMessage, timestamp?: string): BaseMessage;
6865
+ /**
6866
+ * Convenience function to prepend text to message content
6867
+ */
6868
+ declare function prependToMessage(message: BaseMessage, prefix: string): BaseMessage;
6869
+ /**
6870
+ * Convenience function to append text to message content
6871
+ */
6872
+ declare function appendToMessage(message: BaseMessage, suffix: string): BaseMessage;
6873
+ /**
6874
+ * Check if message has any content
6875
+ */
6876
+ declare function hasContent(message: BaseMessage): boolean;
6877
+ /**
6878
+ * Get content length (text characters or array items)
6879
+ */
6880
+ declare function getContentLength(content: MessageContent): number;
6881
+ /**
6882
+ * Combined message helpers object for easy importing
6883
+ */
6884
+ declare const messageHelpers: {
6885
+ isTextContent: typeof isTextContent;
6886
+ isStructuredContent: typeof isStructuredContent;
6887
+ hasTextPart: typeof hasTextPart;
6888
+ hasImagePart: typeof hasImagePart;
6889
+ hasFilePart: typeof hasFilePart;
6890
+ extractText: typeof extractText;
6891
+ extractTextParts: typeof extractTextParts;
6892
+ extractImageParts: typeof extractImageParts;
6893
+ extractFileParts: typeof extractFileParts;
6894
+ transformTextContent: typeof transformTextContent;
6895
+ mapMessageContent: typeof mapMessageContent;
6896
+ filterContentParts: typeof filterContentParts;
6897
+ normalizeToArray: typeof normalizeToArray;
6898
+ normalizeContent: typeof normalizeContent;
6899
+ addTimestampToMessage: typeof addTimestampToMessage;
6900
+ prependToMessage: typeof prependToMessage;
6901
+ appendToMessage: typeof appendToMessage;
6902
+ hasContent: typeof hasContent;
6903
+ getContentLength: typeof getContentLength;
6904
+ MessageContentBuilder: typeof MessageContentBuilder;
6905
+ };
6906
+
6712
6907
  /**
6713
6908
  * Creates an AgentTool from a retriever, allowing it to be used as a tool in an agent.
6714
6909
  * This is the preferred way to use a retriever as a tool, as it properly maintains the 'this' context.
@@ -7387,4 +7582,4 @@ declare class VoltAgent {
7387
7582
  shutdownTelemetry(): Promise<void>;
7388
7583
  }
7389
7584
 
7390
- export { type AbortError, Agent, type AgentErrorEvent, AgentEventEmitter, type AgentHistoryEntry, type AgentHookOnEnd, type AgentHookOnHandoff, type AgentHookOnStart, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentStartEvent, type AgentStartEventMetadata, type AgentSuccessEvent, type AgentSuccessEventMetadata, type AgentTimelineEvent, type AgentTool, type AllowedVariableValue, type AnyToolConfig, type BaseEventMetadata, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTimelineEvent, type BaseTool, type BaseToolCall, type CachedPrompt, type ChatMessage, type ClientInfo, type Conversation, type ConversationQueryOptions, type CreateConversationInput, type CreateReasoningToolsOptions, type CustomEndpointDefinition, CustomEndpointError, type CustomEndpointHandler, DEFAULT_INSTRUCTIONS, type DataContent, type DynamicValue, type DynamicValueOptions, type ErrorStreamPart, type EventStatus, type ExtractVariableNames, FEW_SHOT_EXAMPLES, type FilePart, type FinishStreamPart, type GenerateObjectOptions, type GenerateTextOptions, type HTTPServerConfig, type HistoryStatus, type HttpMethod, type VoltOpsClient$1 as IVoltOpsClient, type ImagePart, InMemoryStorage, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type LLMProvider, LibSQLStorage, MCPClient, type MCPClientConfig, type MCPClientEvents, MCPConfiguration, type MCPOptions, type MCPServerConfig, type MCPToolCall, type MCPToolResult, type Memory, type MemoryEventMetadata, MemoryManager, type MemoryMessage, type MemoryOptions, type MemoryReadErrorEvent, type MemoryReadStartEvent, type MemoryReadSuccessEvent, type MemoryWriteErrorEvent, type MemoryWriteStartEvent, type MemoryWriteSuccessEvent, type MessageContent, type MessageFilterOptions, type MessageRole, type ModelToolCall, type NewTimelineEvent, NextAction, NodeType, type ObjectSubAgentConfig, type OnEndHookArgs, type OnHandoffHookArgs, type OnStartHookArgs, 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 ReasoningStreamPart, type ReasoningToolExecuteOptions, type RetrieveOptions, type Retriever, type RetrieverErrorEvent, type RetrieverOptions, type RetrieverStartEvent, type RetrieverSuccessEvent, type SSEServerConfig, type ServerOptions, type SourceStreamPart, type StandardEventData, type StandardTimelineEvent, type StdioServerConfig, type StepChunkCallback, type StepFinishCallback, type StepWithContent, type StreamEventForwarderOptions, type StreamObjectFinishResult, type StreamObjectOnFinishCallback, type StreamObjectOptions, type StreamPart, type StreamTextFinishResult, type StreamTextOnFinishCallback, type StreamTextOptions, type StreamableHTTPServerConfig, type SubAgentConfig, type SubAgentConfigObject, type SubAgentMethod, type TemplateVariables, type TextDeltaStreamPart, type TextPart, type TextSubAgentConfig, type TimelineEventCoreLevel, type TimelineEventCoreStatus, type TimelineEventCoreType, Tool, type ToolCall, type ToolCallStreamPart, type ToolErrorEvent, type ToolErrorInfo, type ToolExecuteOptions, type ToolExecutionContext, ToolManager, type ToolOptions, type ToolResultStreamPart, type ToolSchema, type ToolStartEvent, type ToolStatus, type ToolStatusInfo, type ToolSuccessEvent, type Toolkit, type ToolsetMap, type ToolsetWithTools, type TransportError, type Usage, type UsageInfo, type Voice, type VoiceEventData, type VoiceEventType, type VoiceMetadata, type VoiceOptions, VoltAgent, type VoltAgentError, VoltAgentExporter, type VoltAgentExporterOptions, type VoltAgentOptions, VoltOpsClient, type VoltOpsClientOptions, VoltOpsPromptApiClient, type VoltOpsPromptManager, VoltOpsPromptManagerImpl, type Workflow, type WorkflowConfig, type WorkflowErrorEvent, type WorkflowEvent, WorkflowEventEmitter, type WorkflowEventMetadata, type WorkflowExecutionContext, type WorkflowHistoryEntry, WorkflowRegistry, type WorkflowStartEvent, type WorkflowStepContext, type WorkflowStepErrorEvent, type WorkflowStepEventMetadata, type WorkflowStepHistoryEntry, type WorkflowStepStartEvent, type WorkflowStepSuccessEvent, type WorkflowStepSuspendEvent, type WorkflowStepType, type WorkflowSuccessEvent, type WorkflowSuspendEvent, type WorkflowTimelineEvent, andAgent, andAll, andRace, andTap, andThen, andWhen, andWorkflow, buildRetrieverLogMessage, checkForUpdates, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createSimpleTemplateEngine, createStreamEventForwarder, createSubagent, createSuspendController, createTool, createToolkit, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, extractWorkflowStepInfo, getNodeTypeFromNodeId, getWorkflowStepNodeType, isAbortError, isVoltAgentError, registerCustomEndpoint, registerCustomEndpoints, safeJsonParse, serializeValueForDebug, streamEventForwarder, tool, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
7585
+ export { type AbortError, Agent, type AgentErrorEvent, AgentEventEmitter, type AgentHistoryEntry, type AgentHookOnEnd, type AgentHookOnHandoff, type AgentHookOnPrepareMessages, type AgentHookOnStart, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentStartEvent, type AgentStartEventMetadata, type AgentSuccessEvent, type AgentSuccessEventMetadata, type AgentTimelineEvent, type AgentTool, type AllowedVariableValue, type AnyToolConfig, type BaseEventMetadata, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTimelineEvent, type BaseTool, type BaseToolCall, type CachedPrompt, type ChatMessage, type ClientInfo, type Conversation, type ConversationQueryOptions, type CreateConversationInput, type CreateReasoningToolsOptions, type CustomEndpointDefinition, CustomEndpointError, type CustomEndpointHandler, DEFAULT_INSTRUCTIONS, type DataContent, type DynamicValue, type DynamicValueOptions, type ErrorStreamPart, type EventStatus, type ExtractVariableNames, FEW_SHOT_EXAMPLES, type FilePart, type FinishStreamPart, type GenerateObjectOptions, type GenerateTextOptions, type HTTPServerConfig, type HistoryStatus, type HttpMethod, type VoltOpsClient$1 as IVoltOpsClient, type ImagePart, InMemoryStorage, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type LLMProvider, LibSQLStorage, MCPClient, type MCPClientConfig, type MCPClientEvents, MCPConfiguration, type MCPOptions, type MCPServerConfig, type MCPToolCall, type MCPToolResult, type Memory, type MemoryEventMetadata, MemoryManager, type MemoryMessage, type MemoryOptions, type MemoryReadErrorEvent, type MemoryReadStartEvent, type MemoryReadSuccessEvent, type MemoryWriteErrorEvent, type MemoryWriteStartEvent, type MemoryWriteSuccessEvent, type MessageContent, MessageContentBuilder, type MessageFilterOptions, type MessageRole, type ModelToolCall, type NewTimelineEvent, NextAction, NodeType, type ObjectSubAgentConfig, type OnEndHookArgs, type OnHandoffHookArgs, type OnPrepareMessagesHookArgs, type OnPrepareMessagesHookResult, type OnStartHookArgs, 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 ReasoningStreamPart, type ReasoningToolExecuteOptions, type RetrieveOptions, type Retriever, type RetrieverErrorEvent, type RetrieverOptions, type RetrieverStartEvent, type RetrieverSuccessEvent, type SSEServerConfig, type ServerOptions, type SourceStreamPart, type StandardEventData, type StandardTimelineEvent, type StdioServerConfig, type StepChunkCallback, type StepFinishCallback, type StepWithContent, type StreamEventForwarderOptions, type StreamObjectFinishResult, type StreamObjectOnFinishCallback, type StreamObjectOptions, type StreamPart, type StreamTextFinishResult, type StreamTextOnFinishCallback, type StreamTextOptions, type StreamableHTTPServerConfig, type SubAgentConfig, type SubAgentConfigObject, type SubAgentMethod, type TemplateVariables, type TextDeltaStreamPart, type TextPart, type TextSubAgentConfig, type TimelineEventCoreLevel, type TimelineEventCoreStatus, type TimelineEventCoreType, Tool, type ToolCall, type ToolCallStreamPart, type ToolErrorEvent, type ToolErrorInfo, type ToolExecuteOptions, type ToolExecutionContext, ToolManager, type ToolOptions, type ToolResultStreamPart, type ToolSchema, type ToolStartEvent, type ToolStatus, type ToolStatusInfo, type ToolSuccessEvent, type Toolkit, type ToolsetMap, type ToolsetWithTools, type TransportError, type Usage, type UsageInfo, type Voice, type VoiceEventData, type VoiceEventType, type VoiceMetadata, type VoiceOptions, VoltAgent, type VoltAgentError, VoltAgentExporter, type VoltAgentExporterOptions, type VoltAgentOptions, VoltOpsClient, type VoltOpsClientOptions, VoltOpsPromptApiClient, type VoltOpsPromptManager, VoltOpsPromptManagerImpl, type Workflow, type WorkflowConfig, type WorkflowErrorEvent, type WorkflowEvent, WorkflowEventEmitter, type WorkflowEventMetadata, type WorkflowExecutionContext, type WorkflowHistoryEntry, WorkflowRegistry, type WorkflowStartEvent, type WorkflowStepContext, type WorkflowStepErrorEvent, type WorkflowStepEventMetadata, type WorkflowStepHistoryEntry, type WorkflowStepStartEvent, type WorkflowStepSuccessEvent, type WorkflowStepSuspendEvent, type WorkflowStepType, type WorkflowSuccessEvent, type WorkflowSuspendEvent, type WorkflowTimelineEvent, addTimestampToMessage, andAgent, andAll, andRace, andTap, andThen, andWhen, andWorkflow, appendToMessage, buildRetrieverLogMessage, checkForUpdates, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createSimpleTemplateEngine, createStreamEventForwarder, createSubagent, createSuspendController, createTool, createToolkit, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, extractFileParts, extractImageParts, extractText, extractTextParts, extractWorkflowStepInfo, filterContentParts, getContentLength, getNodeTypeFromNodeId, getWorkflowStepNodeType, hasContent, hasFilePart, hasImagePart, hasTextPart, isAbortError, isStructuredContent, isTextContent, isVoltAgentError, mapMessageContent, messageHelpers, normalizeContent, normalizeToArray, prependToMessage, registerCustomEndpoint, registerCustomEndpoints, safeJsonParse, serializeValueForDebug, streamEventForwarder, tool, transformTextContent, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };