@voltagent/core 0.1.52 → 0.1.53

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.ts CHANGED
@@ -807,6 +807,104 @@ declare function streamEventForwarder(event: StreamEvent, options: StreamEventFo
807
807
  */
808
808
  declare function createStreamEventForwarder(options: StreamEventForwarderOptions): (event: StreamEvent) => Promise<void>;
809
809
 
810
+ /**
811
+ * Available methods for subagent execution
812
+ */
813
+ type SubAgentMethod = "streamText" | "generateText" | "streamObject" | "generateObject";
814
+ /**
815
+ * Base configuration for a subagent with specific method and options
816
+ */
817
+ interface BaseSubAgentConfig {
818
+ /** The agent to be used as a subagent */
819
+ agent: Agent<any>;
820
+ /** Provider options for the specific method call */
821
+ options?: ProviderOptions;
822
+ }
823
+ /**
824
+ * Configuration for text-based subagent methods (streamText and generateText)
825
+ */
826
+ interface TextSubAgentConfig extends BaseSubAgentConfig {
827
+ /** The method to use when calling the subagent */
828
+ method: "streamText" | "generateText";
829
+ /** Schema for object generation methods (optional for text methods) */
830
+ schema?: z.ZodType;
831
+ }
832
+ /**
833
+ * Configuration for object-based subagent methods (streamObject and generateObject)
834
+ */
835
+ interface ObjectSubAgentConfig extends BaseSubAgentConfig {
836
+ /** The method to use when calling the subagent */
837
+ method: "streamObject" | "generateObject";
838
+ /** Schema for object generation methods (required for object methods) */
839
+ schema: z.ZodType;
840
+ }
841
+ /**
842
+ * Configuration for a subagent with specific method and options
843
+ * Schema is required for object generation methods (streamObject and generateObject)
844
+ */
845
+ type SubAgentConfigObject = TextSubAgentConfig | ObjectSubAgentConfig;
846
+ /**
847
+ * Union type for subagent configuration
848
+ * - Direct Agent instance (backward compatibility): defaults to streamText method
849
+ * - SubAgentConfigObject: allows specifying method, schema, and options
850
+ */
851
+ type SubAgentConfig = Agent<any> | SubAgentConfigObject;
852
+ /**
853
+ * Helper function to create a subagent configuration with specific method and options
854
+ * This provides a convenient API for configuring subagents with different execution methods
855
+ *
856
+ * @param config - The configuration object containing agent, method, and optional schema/options
857
+ * @returns A SubAgentConfigObject that can be used in the Agent constructor
858
+ *
859
+ * @example
860
+ * // Backward compatible - direct agent (uses streamText by default)
861
+ * const supervisorAgent = new Agent({
862
+ * name: "Supervisor",
863
+ * instructions: "...",
864
+ * llm: myLLM,
865
+ * subAgents: [myAgent] // <- This still works! Uses streamText by default
866
+ * });
867
+ *
868
+ * @example
869
+ * // New API - mixed usage
870
+ * const supervisorAgent = new Agent({
871
+ * name: "Supervisor",
872
+ * instructions: "...",
873
+ * llm: myLLM,
874
+ * subAgents: [
875
+ * myAgent, // <- Direct agent, uses streamText
876
+ * createSubagent({
877
+ * agent: myAgent,
878
+ * method: 'generateObject',
879
+ * schema: z.object({ result: z.string() }) // <- Schema is required for generateObject
880
+ * })
881
+ * ]
882
+ * });
883
+ *
884
+ * @example
885
+ * // Create a subagent that uses generateText with custom options
886
+ * createSubagent({
887
+ * agent: myAgent,
888
+ * method: 'generateText',
889
+ * options: { temperature: 0.7, maxTokens: 1000 }
890
+ * // schema is optional for generateText
891
+ * })
892
+ *
893
+ * @example
894
+ * // Create a subagent that uses streamObject - schema is required
895
+ * createSubagent({
896
+ * agent: myAgent,
897
+ * method: 'streamObject',
898
+ * schema: z.object({
899
+ * progress: z.number(),
900
+ * status: z.string()
901
+ * }),
902
+ * options: { temperature: 0.2 }
903
+ * })
904
+ */
905
+ declare function createSubagent(config: TextSubAgentConfig): TextSubAgentConfig;
906
+ declare function createSubagent(config: ObjectSubAgentConfig): ObjectSubAgentConfig;
907
+
810
908
  /**
811
909
  * VoltOps Client Type Definitions
812
910
  *
@@ -1065,6 +1163,26 @@ type ProviderOptions = {
1065
1163
  toolExecutionContext?: ToolExecutionContext;
1066
1164
  [key: string]: unknown;
1067
1165
  };
1166
+ /**
1167
+ * Configuration for supervisor agents that have subagents
1168
+ */
1169
+ type SupervisorConfig = {
1170
+ /**
1171
+ * Complete custom system message for the supervisor agent
1172
+ * If provided, this completely replaces the default template
1173
+ * Only agents memory section will be appended if includeAgentsMemory is true
1174
+ */
1175
+ systemMessage?: string;
1176
+ /**
1177
+ * Whether to include agents memory in the supervisor system message
1178
+ * @default true
1179
+ */
1180
+ includeAgentsMemory?: boolean;
1181
+ /**
1182
+ * Additional custom guidelines for the supervisor agent
1183
+ */
1184
+ customGuidelines?: string[];
1185
+ };
1068
1186
  /**
1069
1187
  * Agent configuration options
1070
1188
  */
@@ -1098,10 +1216,6 @@ type AgentOptions = {
1098
1216
  * Can be static or dynamic based on user context
1099
1217
  */
1100
1218
  tools?: ToolsDynamicValue;
1101
- /**
1102
- * Sub-agents that this agent can delegate tasks to
1103
- */
1104
- subAgents?: any[];
1105
1219
  /**
1106
1220
  * Maximum number of steps (turns) the agent can take before stopping
1107
1221
  * This overrides any supervisor config maxSteps setting
@@ -1125,6 +1239,14 @@ type AgentOptions = {
1125
1239
  * ✨ Benefits: Observability + prompt management + dynamic prompts from console
1126
1240
  */
1127
1241
  telemetryExporter?: VoltAgentExporter;
1242
+ /**
1243
+ * Sub-agents that this agent can delegate tasks to
1244
+ */
1245
+ subAgents?: SubAgentConfig[];
1246
+ /**
1247
+ * Configuration for supervisor behavior when subAgents are present
1248
+ */
1249
+ supervisorConfig?: SupervisorConfig;
1128
1250
  } & ({
1129
1251
  /**
1130
1252
  * @deprecated Use `instructions` instead.
@@ -2732,9 +2854,13 @@ declare class LibSQLStorage implements Memory {
2732
2854
  */
2733
2855
  declare class MemoryManager {
2734
2856
  /**
2735
- * The memory storage instance
2857
+ * The memory storage instance for conversations
2858
+ */
2859
+ private conversationMemory;
2860
+ /**
2861
+ * The memory storage instance for history (always available)
2736
2862
  */
2737
- private memory;
2863
+ private historyMemory;
2738
2864
  /**
2739
2865
  * Memory configuration options
2740
2866
  */
@@ -2750,7 +2876,7 @@ declare class MemoryManager {
2750
2876
  /**
2751
2877
  * Creates a new MemoryManager
2752
2878
  */
2753
- constructor(resourceId: string, memory?: Memory | false, options?: MemoryOptions);
2879
+ constructor(resourceId: string, memory?: Memory | false, options?: MemoryOptions, historyMemory?: Memory);
2754
2880
  /**
2755
2881
  * Create and publish a timeline event for memory operations using the queue
2756
2882
  *
@@ -2788,9 +2914,13 @@ declare class MemoryManager {
2788
2914
  */
2789
2915
  private saveCurrentInput;
2790
2916
  /**
2791
- * Get the memory instance
2917
+ * Get the conversation memory instance
2792
2918
  */
2793
2919
  getMemory(): Memory | undefined;
2920
+ /**
2921
+ * Get the history memory instance
2922
+ */
2923
+ getHistoryMemory(): Memory;
2794
2924
  /**
2795
2925
  * Get the memory options
2796
2926
  */
@@ -3185,20 +3315,21 @@ declare class SubAgentManager {
3185
3315
  */
3186
3316
  private agentName;
3187
3317
  /**
3188
- * Sub-agents that the parent agent can delegate tasks to
3318
+ * Sub-agent configurations that the parent agent can delegate tasks to
3319
+ * Can be either direct Agent instances or SubAgentConfigObject instances
3189
3320
  */
3190
- private subAgents;
3321
+ private subAgentConfigs;
3191
3322
  /**
3192
3323
  * Creates a new SubAgentManager instance
3193
3324
  *
3194
3325
  * @param agentName - The name of the agent that owns this sub-agent manager
3195
- * @param subAgents - Initial sub-agents to add
3326
+ * @param subAgents - Initial sub-agent configurations to add
3196
3327
  */
3197
- constructor(agentName: string, subAgents?: Agent<any>[]);
3328
+ constructor(agentName: string, subAgents?: SubAgentConfig[]);
3198
3329
  /**
3199
3330
  * Add a sub-agent that the parent agent can delegate tasks to
3200
3331
  */
3201
- addSubAgent(agent: Agent<any>): void;
3332
+ addSubAgent(agentConfig: SubAgentConfig): void;
3202
3333
  /**
3203
3334
  * Remove a sub-agent
3204
3335
  */
@@ -3207,10 +3338,30 @@ declare class SubAgentManager {
3207
3338
  * Unregister all sub-agents when parent agent is destroyed
3208
3339
  */
3209
3340
  unregisterAllSubAgents(): void;
3341
+ /**
3342
+ * Helper method to extract agent ID from SubAgentConfig
3343
+ */
3344
+ private extractAgentId;
3345
+ /**
3346
+ * Helper method to extract agent instance from SubAgentConfig
3347
+ */
3348
+ private extractAgent;
3349
+ /**
3350
+ * Helper method to extract agent name from SubAgentConfig
3351
+ */
3352
+ private extractAgentName;
3353
+ /**
3354
+ * Helper method to extract agent purpose/instructions from SubAgentConfig
3355
+ */
3356
+ private extractAgentPurpose;
3357
+ /**
3358
+ * Type guard to check if a SubAgentConfig is a SubAgentConfigObject
3359
+ */
3360
+ private isSubAgentConfigObject;
3210
3361
  /**
3211
3362
  * Get all sub-agents
3212
3363
  */
3213
- getSubAgents(): Agent<any>[];
3364
+ getSubAgents(): SubAgentConfig[];
3214
3365
  /**
3215
3366
  * Calculate maximum number of steps based on sub-agents
3216
3367
  * More sub-agents means more potential steps
@@ -3218,10 +3369,11 @@ declare class SubAgentManager {
3218
3369
  calculateMaxSteps(agentMaxSteps?: number): number;
3219
3370
  /**
3220
3371
  * Generate enhanced system message for supervisor role
3221
- * @param baseDescription - The base description of the agent
3372
+ * @param baseInstructions - The base instructions of the agent
3222
3373
  * @param agentsMemory - Optional string containing formatted memory from previous agent interactions
3374
+ * @param config - Optional supervisor configuration to customize the system message
3223
3375
  */
3224
- generateSupervisorSystemMessage(baseInstructions: string, agentsMemory?: string): string;
3376
+ generateSupervisorSystemMessage(baseInstructions: string, agentsMemory?: string, config?: SupervisorConfig): string;
3225
3377
  /**
3226
3378
  * Check if the agent has sub-agents
3227
3379
  */
@@ -3234,7 +3386,7 @@ declare class SubAgentManager {
3234
3386
  * Hand off a task to multiple agents in parallel
3235
3387
  */
3236
3388
  handoffToMultiple(options: Omit<AgentHandoffOptions, "targetAgent"> & {
3237
- targetAgents: Agent<any>[];
3389
+ targetAgents: SubAgentConfig[];
3238
3390
  }): Promise<AgentHandoffResult[]>;
3239
3391
  /**
3240
3392
  * Creates a tool that allows the supervisor agent to delegate a
@@ -3342,12 +3494,16 @@ declare class Agent<TProvider extends {
3342
3494
  * Takes priority over global VoltOpsClient for prompt management
3343
3495
  */
3344
3496
  private readonly voltOpsClient?;
3497
+ /**
3498
+ * Supervisor configuration for agents with subagents
3499
+ */
3500
+ private readonly supervisorConfig?;
3345
3501
  /**
3346
3502
  * Create a new agent
3347
3503
  */
3348
3504
  constructor(options: AgentOptions & TProvider & {
3349
3505
  model: ModelDynamicValue<ModelType<TProvider>>;
3350
- subAgents?: Agent<any>[];
3506
+ subAgents?: SubAgentConfig[];
3351
3507
  maxHistoryEntries?: number;
3352
3508
  hooks?: AgentHooks;
3353
3509
  retriever?: BaseRetriever;
@@ -3485,7 +3641,7 @@ declare class Agent<TProvider extends {
3485
3641
  /**
3486
3642
  * Add a sub-agent that this agent can delegate tasks to
3487
3643
  */
3488
- addSubAgent(agent: Agent<any>): void;
3644
+ addSubAgent(agentConfig: SubAgentConfig): void;
3489
3645
  /**
3490
3646
  * Remove a sub-agent
3491
3647
  */
@@ -3509,7 +3665,7 @@ declare class Agent<TProvider extends {
3509
3665
  /**
3510
3666
  * Get all sub-agents
3511
3667
  */
3512
- getSubAgents(): Agent<any>[];
3668
+ getSubAgents(): SubAgentConfig[];
3513
3669
  /**
3514
3670
  * Unregister this agent
3515
3671
  */
@@ -4538,6 +4694,10 @@ declare class VoltAgent {
4538
4694
  * Register an agent
4539
4695
  */
4540
4696
  registerAgent(agent: Agent<any>): void;
4697
+ /**
4698
+ * Helper method to extract Agent instance from SubAgentConfig
4699
+ */
4700
+ private extractAgentFromConfig;
4541
4701
  /**
4542
4702
  * Register multiple agents
4543
4703
  */
@@ -4574,4 +4734,4 @@ declare class VoltAgent {
4574
4734
  shutdownTelemetry(): Promise<void>;
4575
4735
  }
4576
4736
 
4577
- export { Agent, AgentErrorEvent, AgentHistoryEntry, AgentHookOnEnd, AgentHookOnHandoff, AgentHookOnStart, AgentHookOnToolEnd, AgentHookOnToolStart, AgentHooks, AgentOptions, AgentRegistry, AgentResponse, AgentStartEvent, AgentStartEventMetadata, AgentSuccessEvent, AgentSuccessEventMetadata, AgentTool, AllowedVariableValue, AnyToolConfig, AsyncIterableStream, BaseEventMetadata, BaseLLMOptions, BaseMessage, BaseRetriever, BaseTimelineEvent, BaseTool, BaseToolCall, CachedPrompt, ClientInfo, Conversation, ConversationQueryOptions, CreateConversationInput, CreateReasoningToolsOptions, CustomEndpointDefinition, CustomEndpointError, CustomEndpointHandler, DEFAULT_INSTRUCTIONS, DataContent, DynamicValue, DynamicValueOptions, ErrorStreamPart, EventStatus, ExtractVariableNames, FEW_SHOT_EXAMPLES, FilePart, FinishStreamPart, GenerateObjectOptions, GenerateTextOptions, HTTPServerConfig, HistoryStatus, HttpMethod, VoltOpsClient$1 as IVoltOpsClient, ImagePart, InMemoryStorage, InferGenerateObjectResponse, InferGenerateTextResponse, InferMessage, InferModel, InferProviderParams, InferStreamResponse, InferTool, LLMProvider, LibSQLStorage, MCPClient, MCPClientConfig, MCPClientEvents, MCPConfiguration, MCPOptions, MCPServerConfig, MCPToolCall, MCPToolResult, Memory, MemoryEventMetadata, MemoryManager, MemoryMessage, MemoryOptions, MemoryReadErrorEvent, MemoryReadStartEvent, MemoryReadSuccessEvent, MemoryWriteErrorEvent, MemoryWriteStartEvent, MemoryWriteSuccessEvent, MessageContent, MessageFilterOptions, MessageRole, ModelToolCall, NewTimelineEvent, NextAction, NodeType, OnEndHookArgs, OnHandoffHookArgs, OnStartHookArgs, OnToolEndHookArgs, OnToolStartHookArgs, OperationContext, PackageUpdateInfo, PromptApiClient, PromptApiResponse, PromptCreator, PromptHelper, PromptReference, PromptTemplate, ProviderObjectResponse, ProviderObjectStreamResponse, ProviderParams, ProviderResponse, ProviderTextResponse, ProviderTextStreamResponse, ReadableStreamType, ReasoningStep, ReasoningStepSchema, ReasoningStreamPart, ReasoningToolExecuteOptions, RetrieveOptions, Retriever, RetrieverErrorEvent, RetrieverOptions, RetrieverStartEvent, RetrieverSuccessEvent, SSEServerConfig, ServerOptions, SourceStreamPart, StandardEventData, StandardTimelineEvent, StdioServerConfig, StepChunkCallback, StepFinishCallback, StepWithContent, StreamEventForwarderOptions, StreamObjectFinishResult, StreamObjectOnFinishCallback, StreamObjectOptions, StreamPart, StreamTextFinishResult, StreamTextOnFinishCallback, StreamTextOptions, StreamableHTTPServerConfig, TemplateVariables, TextDeltaStreamPart, TextPart, TimelineEventCoreLevel, TimelineEventCoreStatus, TimelineEventCoreType, Tool, ToolCall, ToolCallStreamPart, ToolErrorEvent, ToolErrorInfo, ToolExecuteOptions, ToolExecutionContext, ToolManager, ToolOptions, ToolResultStreamPart, ToolSchema, ToolStartEvent, ToolStatus, ToolStatusInfo, ToolSuccessEvent, Toolkit, ToolsetMap, ToolsetWithTools, TransportError, Usage, UsageInfo, Voice, VoiceEventData, VoiceEventType, VoiceMetadata, VoiceOptions, VoltAgent, VoltAgentError, VoltAgentExporter, VoltAgentExporterOptions, VoltAgentOptions, VoltOpsClient, VoltOpsClientOptions, VoltOpsPromptApiClient, VoltOpsPromptManager, VoltOpsPromptManagerImpl, checkForUpdates, createAsyncIterableStream, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createSimpleTemplateEngine, createStreamEventForwarder, createTool, createToolkit, createVoltOpsClient, VoltAgent as default, getNodeTypeFromNodeId, registerCustomEndpoint, registerCustomEndpoints, safeJsonParse, serializeValueForDebug, streamEventForwarder, tool, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
4737
+ export { Agent, AgentErrorEvent, AgentHistoryEntry, AgentHookOnEnd, AgentHookOnHandoff, AgentHookOnStart, AgentHookOnToolEnd, AgentHookOnToolStart, AgentHooks, AgentOptions, AgentRegistry, AgentResponse, AgentStartEvent, AgentStartEventMetadata, AgentSuccessEvent, AgentSuccessEventMetadata, AgentTool, AllowedVariableValue, AnyToolConfig, AsyncIterableStream, BaseEventMetadata, BaseLLMOptions, BaseMessage, BaseRetriever, BaseTimelineEvent, BaseTool, BaseToolCall, CachedPrompt, ClientInfo, Conversation, ConversationQueryOptions, CreateConversationInput, CreateReasoningToolsOptions, CustomEndpointDefinition, CustomEndpointError, CustomEndpointHandler, DEFAULT_INSTRUCTIONS, DataContent, DynamicValue, DynamicValueOptions, ErrorStreamPart, EventStatus, ExtractVariableNames, FEW_SHOT_EXAMPLES, FilePart, FinishStreamPart, GenerateObjectOptions, GenerateTextOptions, HTTPServerConfig, HistoryStatus, HttpMethod, VoltOpsClient$1 as IVoltOpsClient, ImagePart, InMemoryStorage, InferGenerateObjectResponse, InferGenerateTextResponse, InferMessage, InferModel, InferProviderParams, InferStreamResponse, InferTool, LLMProvider, LibSQLStorage, MCPClient, MCPClientConfig, MCPClientEvents, MCPConfiguration, MCPOptions, MCPServerConfig, MCPToolCall, MCPToolResult, Memory, MemoryEventMetadata, MemoryManager, MemoryMessage, MemoryOptions, MemoryReadErrorEvent, MemoryReadStartEvent, MemoryReadSuccessEvent, MemoryWriteErrorEvent, MemoryWriteStartEvent, MemoryWriteSuccessEvent, MessageContent, MessageFilterOptions, MessageRole, ModelToolCall, NewTimelineEvent, NextAction, NodeType, ObjectSubAgentConfig, OnEndHookArgs, OnHandoffHookArgs, OnStartHookArgs, OnToolEndHookArgs, OnToolStartHookArgs, OperationContext, PackageUpdateInfo, PromptApiClient, PromptApiResponse, PromptCreator, PromptHelper, PromptReference, PromptTemplate, ProviderObjectResponse, ProviderObjectStreamResponse, ProviderParams, ProviderResponse, ProviderTextResponse, ProviderTextStreamResponse, ReadableStreamType, ReasoningStep, ReasoningStepSchema, ReasoningStreamPart, ReasoningToolExecuteOptions, RetrieveOptions, Retriever, RetrieverErrorEvent, RetrieverOptions, RetrieverStartEvent, RetrieverSuccessEvent, SSEServerConfig, ServerOptions, SourceStreamPart, StandardEventData, StandardTimelineEvent, StdioServerConfig, StepChunkCallback, StepFinishCallback, StepWithContent, StreamEventForwarderOptions, StreamObjectFinishResult, StreamObjectOnFinishCallback, StreamObjectOptions, StreamPart, StreamTextFinishResult, StreamTextOnFinishCallback, StreamTextOptions, StreamableHTTPServerConfig, SubAgentConfig, SubAgentConfigObject, SubAgentMethod, TemplateVariables, TextDeltaStreamPart, TextPart, TextSubAgentConfig, TimelineEventCoreLevel, TimelineEventCoreStatus, TimelineEventCoreType, Tool, ToolCall, ToolCallStreamPart, ToolErrorEvent, ToolErrorInfo, ToolExecuteOptions, ToolExecutionContext, ToolManager, ToolOptions, ToolResultStreamPart, ToolSchema, ToolStartEvent, ToolStatus, ToolStatusInfo, ToolSuccessEvent, Toolkit, ToolsetMap, ToolsetWithTools, TransportError, Usage, UsageInfo, Voice, VoiceEventData, VoiceEventType, VoiceMetadata, VoiceOptions, VoltAgent, VoltAgentError, VoltAgentExporter, VoltAgentExporterOptions, VoltAgentOptions, VoltOpsClient, VoltOpsClientOptions, VoltOpsPromptApiClient, VoltOpsPromptManager, VoltOpsPromptManagerImpl, checkForUpdates, createAsyncIterableStream, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createSimpleTemplateEngine, createStreamEventForwarder, createSubagent, createTool, createToolkit, createVoltOpsClient, VoltAgent as default, getNodeTypeFromNodeId, registerCustomEndpoint, registerCustomEndpoints, safeJsonParse, serializeValueForDebug, streamEventForwarder, tool, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };