@voltagent/core 0.1.37 → 0.1.39
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 +61 -34
- package/dist/index.js +433 -292
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +431 -291
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -731,6 +731,17 @@ declare class VoltAgentExporter {
|
|
|
731
731
|
updateHistoryEntry(history_id: string, updates: Partial<AgentHistoryUpdatableFields>): Promise<void>;
|
|
732
732
|
}
|
|
733
733
|
|
|
734
|
+
/**
|
|
735
|
+
* Options object for dynamic value resolution
|
|
736
|
+
*/
|
|
737
|
+
type DynamicValueOptions = {
|
|
738
|
+
/** User-defined context that can be used for dynamic value resolution */
|
|
739
|
+
userContext: Map<string | symbol, unknown>;
|
|
740
|
+
};
|
|
741
|
+
/**
|
|
742
|
+
* A value that can be either static or dynamically computed based on context
|
|
743
|
+
*/
|
|
744
|
+
type DynamicValue<T> = T | ((options: DynamicValueOptions) => T | Promise<T>);
|
|
734
745
|
/**
|
|
735
746
|
* Provider options type for LLM configurations
|
|
736
747
|
*/
|
|
@@ -779,8 +790,9 @@ type AgentOptions = {
|
|
|
779
790
|
memoryOptions?: MemoryOptions;
|
|
780
791
|
/**
|
|
781
792
|
* Tools and/or Toolkits that the agent can use
|
|
793
|
+
* Can be static or dynamic based on user context
|
|
782
794
|
*/
|
|
783
|
-
tools?: (Tool<any> | Toolkit)[]
|
|
795
|
+
tools?: DynamicValue<(Tool<any> | Toolkit)[]>;
|
|
784
796
|
/**
|
|
785
797
|
* Sub-agents that this agent can delegate tasks to
|
|
786
798
|
*/
|
|
@@ -802,8 +814,9 @@ type AgentOptions = {
|
|
|
802
814
|
description: string;
|
|
803
815
|
/**
|
|
804
816
|
* Agent instructions. This is the preferred field.
|
|
817
|
+
* Can be static or dynamic based on user context
|
|
805
818
|
*/
|
|
806
|
-
instructions?: string
|
|
819
|
+
instructions?: DynamicValue<string>;
|
|
807
820
|
} | {
|
|
808
821
|
/**
|
|
809
822
|
* @deprecated Use `instructions` instead.
|
|
@@ -813,8 +826,9 @@ type AgentOptions = {
|
|
|
813
826
|
/**
|
|
814
827
|
* Agent instructions. This is the preferred field.
|
|
815
828
|
* Required if description is not provided.
|
|
829
|
+
* Can be static or dynamic based on user context
|
|
816
830
|
*/
|
|
817
|
-
instructions: string
|
|
831
|
+
instructions: DynamicValue<string>;
|
|
818
832
|
});
|
|
819
833
|
/**
|
|
820
834
|
* Provider instance type helper
|
|
@@ -2812,6 +2826,18 @@ declare class Agent<TProvider extends {
|
|
|
2812
2826
|
* Agent instructions. This is the preferred field over `description`.
|
|
2813
2827
|
*/
|
|
2814
2828
|
readonly instructions: string;
|
|
2829
|
+
/**
|
|
2830
|
+
* Dynamic instructions value (internal)
|
|
2831
|
+
*/
|
|
2832
|
+
private readonly dynamicInstructions?;
|
|
2833
|
+
/**
|
|
2834
|
+
* Dynamic model value (internal)
|
|
2835
|
+
*/
|
|
2836
|
+
private readonly dynamicModel?;
|
|
2837
|
+
/**
|
|
2838
|
+
* Dynamic tools value (internal)
|
|
2839
|
+
*/
|
|
2840
|
+
private readonly dynamicTools?;
|
|
2815
2841
|
/**
|
|
2816
2842
|
* The LLM provider to use
|
|
2817
2843
|
*/
|
|
@@ -2856,7 +2882,7 @@ declare class Agent<TProvider extends {
|
|
|
2856
2882
|
* Create a new agent
|
|
2857
2883
|
*/
|
|
2858
2884
|
constructor(options: AgentOptions & TProvider & {
|
|
2859
|
-
model: ModelType<TProvider
|
|
2885
|
+
model: DynamicValue<ModelType<TProvider>>;
|
|
2860
2886
|
subAgents?: Agent<any>[];
|
|
2861
2887
|
maxHistoryEntries?: number;
|
|
2862
2888
|
hooks?: AgentHooks;
|
|
@@ -2865,6 +2891,18 @@ declare class Agent<TProvider extends {
|
|
|
2865
2891
|
markdown?: boolean;
|
|
2866
2892
|
telemetryExporter?: VoltAgentExporter;
|
|
2867
2893
|
});
|
|
2894
|
+
/**
|
|
2895
|
+
* Resolve dynamic instructions based on user context
|
|
2896
|
+
*/
|
|
2897
|
+
private resolveInstructions;
|
|
2898
|
+
/**
|
|
2899
|
+
* Resolve dynamic model based on user context
|
|
2900
|
+
*/
|
|
2901
|
+
private resolveModel;
|
|
2902
|
+
/**
|
|
2903
|
+
* Resolve dynamic tools based on user context
|
|
2904
|
+
*/
|
|
2905
|
+
private resolveTools;
|
|
2868
2906
|
/**
|
|
2869
2907
|
* Get the system message for the agent
|
|
2870
2908
|
*/
|
|
@@ -2956,7 +2994,7 @@ declare class Agent<TProvider extends {
|
|
|
2956
2994
|
*/
|
|
2957
2995
|
private _endOtelToolSpan;
|
|
2958
2996
|
/**
|
|
2959
|
-
* Create an enhanced fullStream
|
|
2997
|
+
* Create an enhanced fullStream with real-time SubAgent event injection
|
|
2960
2998
|
*/
|
|
2961
2999
|
private createEnhancedFullStream;
|
|
2962
3000
|
/**
|
|
@@ -3335,34 +3373,6 @@ declare const updateSinglePackage: (packageName: string, packagePath?: string) =
|
|
|
3335
3373
|
declare function safeJsonParse(value: string | null | undefined): any;
|
|
3336
3374
|
declare function serializeValueForDebug(value: unknown): unknown;
|
|
3337
3375
|
|
|
3338
|
-
/**
|
|
3339
|
-
* Utility for merging multiple async streams with event queue integration
|
|
3340
|
-
*/
|
|
3341
|
-
interface StreamMergerOptions {
|
|
3342
|
-
/**
|
|
3343
|
-
* Polling interval for checking events (in milliseconds)
|
|
3344
|
-
* Default: 16ms (~60fps for smooth UI updates)
|
|
3345
|
-
*/
|
|
3346
|
-
pollingInterval?: number;
|
|
3347
|
-
/**
|
|
3348
|
-
* Post-stream polling interval when main stream is finished (in milliseconds)
|
|
3349
|
-
* Default: 10ms
|
|
3350
|
-
*/
|
|
3351
|
-
postStreamInterval?: number;
|
|
3352
|
-
}
|
|
3353
|
-
/**
|
|
3354
|
-
* Creates an enhanced stream that merges an original async iterable with events
|
|
3355
|
-
* from a shared queue, ensuring chronological order and smooth UI updates.
|
|
3356
|
-
*
|
|
3357
|
-
* @param originalStream - The main stream to merge with
|
|
3358
|
-
* @param eventsQueue - Shared array that other sources push events to
|
|
3359
|
-
* @param options - Configuration options for polling intervals
|
|
3360
|
-
* @returns Enhanced async iterable that yields events from both sources
|
|
3361
|
-
*/
|
|
3362
|
-
declare function createMergedStream<T>(originalStream: AsyncIterable<T>, eventsQueue: T[], options?: StreamMergerOptions): AsyncIterable<T>;
|
|
3363
|
-
/**
|
|
3364
|
-
* Helper type for SubAgent events that can be merged into a main stream
|
|
3365
|
-
*/
|
|
3366
3376
|
interface SubAgentEvent {
|
|
3367
3377
|
type: string;
|
|
3368
3378
|
data: any;
|
|
@@ -3370,6 +3380,23 @@ interface SubAgentEvent {
|
|
|
3370
3380
|
subAgentId: string;
|
|
3371
3381
|
subAgentName: string;
|
|
3372
3382
|
}
|
|
3383
|
+
interface StreamEventForwarderOptions {
|
|
3384
|
+
forwarder?: (event: any) => Promise<void>;
|
|
3385
|
+
filterTypes?: string[];
|
|
3386
|
+
addSubAgentPrefix?: boolean;
|
|
3387
|
+
}
|
|
3388
|
+
/**
|
|
3389
|
+
* Forwards SubAgent events to a stream with optional filtering and prefixing
|
|
3390
|
+
* @param event - The SubAgent event to forward
|
|
3391
|
+
* @param options - Configuration options for forwarding
|
|
3392
|
+
*/
|
|
3393
|
+
declare function streamEventForwarder(event: SubAgentEvent, options?: StreamEventForwarderOptions): Promise<void>;
|
|
3394
|
+
/**
|
|
3395
|
+
* Creates a configured streamEventForwarder function
|
|
3396
|
+
* @param options - Configuration options
|
|
3397
|
+
* @returns A configured forwarder function
|
|
3398
|
+
*/
|
|
3399
|
+
declare function createStreamEventForwarder(options?: StreamEventForwarderOptions): (event: SubAgentEvent) => Promise<void>;
|
|
3373
3400
|
|
|
3374
3401
|
/**
|
|
3375
3402
|
* Creates an AgentTool from a retriever, allowing it to be used as a tool in an agent.
|
|
@@ -3972,4 +3999,4 @@ declare class VoltAgent {
|
|
|
3972
3999
|
shutdownTelemetry(): Promise<void>;
|
|
3973
4000
|
}
|
|
3974
4001
|
|
|
3975
|
-
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, ClientInfo, Conversation, ConversationQueryOptions, CreateConversationInput, CreateReasoningToolsOptions, CustomEndpointDefinition, CustomEndpointError, CustomEndpointHandler, DEFAULT_INSTRUCTIONS, DataContent, ErrorStreamPart, EventStatus, ExtractVariableNames, FEW_SHOT_EXAMPLES, FilePart, FinishStreamPart, GenerateObjectOptions, GenerateTextOptions, HTTPServerConfig, HistoryStatus, HttpMethod, 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, PromptCreator, 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,
|
|
4002
|
+
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, ClientInfo, Conversation, ConversationQueryOptions, CreateConversationInput, CreateReasoningToolsOptions, CustomEndpointDefinition, CustomEndpointError, CustomEndpointHandler, DEFAULT_INSTRUCTIONS, DataContent, DynamicValueOptions, ErrorStreamPart, EventStatus, ExtractVariableNames, FEW_SHOT_EXAMPLES, FilePart, FinishStreamPart, GenerateObjectOptions, GenerateTextOptions, HTTPServerConfig, HistoryStatus, HttpMethod, 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, PromptCreator, 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, SubAgentEvent, 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, checkForUpdates, createAsyncIterableStream, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createStreamEventForwarder, createTool, createToolkit, VoltAgent as default, getNodeTypeFromNodeId, registerCustomEndpoint, registerCustomEndpoints, safeJsonParse, serializeValueForDebug, streamEventForwarder, tool, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
|