@voltagent/core 1.1.12 → 1.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +803 -742
- package/dist/index.d.ts +803 -742
- package/dist/index.js +472 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +470 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -16,6 +16,8 @@ import { SpanProcessor, ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
|
16
16
|
import { DangerouslyAllowAny, PlainObject } from '@voltagent/internal/types';
|
|
17
17
|
import * as TF from 'type-fest';
|
|
18
18
|
import { EventEmitter } from 'node:events';
|
|
19
|
+
import { A2AServerLike, A2AServerDeps, A2AServerMetadata, A2AServerFactory } from '@voltagent/internal/a2a';
|
|
20
|
+
import { MCPServerLike, MCPServerDeps, MCPServerMetadata, MCPServerFactory } from '@voltagent/internal/mcp';
|
|
19
21
|
import { ClientCapabilities } from '@modelcontextprotocol/sdk/types.js';
|
|
20
22
|
|
|
21
23
|
/**
|
|
@@ -2955,6 +2957,8 @@ type OperationContext = {
|
|
|
2955
2957
|
isActive: boolean;
|
|
2956
2958
|
/** Parent agent ID if part of a delegation chain */
|
|
2957
2959
|
parentAgentId?: string;
|
|
2960
|
+
/** Optional elicitation bridge for requesting user input */
|
|
2961
|
+
elicitation?: (request: unknown) => Promise<unknown>;
|
|
2958
2962
|
/** Trace context for managing span hierarchy and common attributes */
|
|
2959
2963
|
traceContext: AgentTraceContext;
|
|
2960
2964
|
/** Execution-scoped logger with full context (userId, conversationId, executionId) */
|
|
@@ -3294,6 +3298,7 @@ interface BaseGenerationOptions extends Partial<CallSettings> {
|
|
|
3294
3298
|
userId?: string;
|
|
3295
3299
|
conversationId?: string;
|
|
3296
3300
|
context?: ContextInput;
|
|
3301
|
+
elicitation?: (request: unknown) => Promise<unknown>;
|
|
3297
3302
|
parentAgentId?: string;
|
|
3298
3303
|
parentOperationContext?: OperationContext;
|
|
3299
3304
|
parentSpan?: Span;
|
|
@@ -3982,11 +3987,11 @@ interface WorkflowStreamEvent {
|
|
|
3982
3987
|
/**
|
|
3983
3988
|
* Input data for the step/event
|
|
3984
3989
|
*/
|
|
3985
|
-
input?:
|
|
3990
|
+
input?: DangerouslyAllowAny;
|
|
3986
3991
|
/**
|
|
3987
3992
|
* Output data from the step/event
|
|
3988
3993
|
*/
|
|
3989
|
-
output?:
|
|
3994
|
+
output?: DangerouslyAllowAny;
|
|
3990
3995
|
/**
|
|
3991
3996
|
* Current status of the step/event
|
|
3992
3997
|
*/
|
|
@@ -5744,933 +5749,977 @@ interface BaseEventMetadata {
|
|
|
5744
5749
|
context?: Record<string, unknown>;
|
|
5745
5750
|
}
|
|
5746
5751
|
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5752
|
+
declare class A2AServerRegistry<TServer extends A2AServerLike = A2AServerLike> {
|
|
5753
|
+
private readonly servers;
|
|
5754
|
+
private readonly idByServer;
|
|
5755
|
+
private readonly serverById;
|
|
5756
|
+
private readonly metadataById;
|
|
5757
|
+
private anonymousCounter;
|
|
5758
|
+
register(server: TServer, deps: A2AServerDeps): void;
|
|
5759
|
+
unregister(server: TServer): void;
|
|
5760
|
+
getServer(id: string): TServer | undefined;
|
|
5761
|
+
getMetadata(id: string): A2AServerMetadata | undefined;
|
|
5762
|
+
list(): TServer[];
|
|
5763
|
+
listMetadata(): A2AServerMetadata[];
|
|
5764
|
+
private resolveMetadata;
|
|
5765
|
+
private normalizeIdentifier;
|
|
5766
|
+
private ensureUniqueId;
|
|
5767
|
+
private createAnonymousSlug;
|
|
5768
|
+
private createAnonymousName;
|
|
5769
|
+
}
|
|
5770
|
+
|
|
5771
|
+
interface RegisterOptions {
|
|
5772
|
+
startTransports?: boolean;
|
|
5773
|
+
transportOptions?: Record<string, unknown>;
|
|
5774
|
+
}
|
|
5775
|
+
declare class MCPServerRegistry<TServer extends MCPServerLike = MCPServerLike> {
|
|
5776
|
+
private readonly servers;
|
|
5777
|
+
private readonly idByServer;
|
|
5778
|
+
private readonly serverById;
|
|
5779
|
+
private readonly metadataById;
|
|
5780
|
+
private anonymousCounter;
|
|
5781
|
+
register(server: TServer, deps: MCPServerDeps, options?: RegisterOptions): void;
|
|
5782
|
+
unregister(server: TServer): void;
|
|
5783
|
+
getServer(id: string): TServer | undefined;
|
|
5784
|
+
getServerMetadata(id: string): MCPServerMetadata | undefined;
|
|
5785
|
+
list(): TServer[];
|
|
5786
|
+
listMetadata(): MCPServerMetadata[];
|
|
5787
|
+
startAll(options?: Record<string, unknown>): Promise<void>;
|
|
5788
|
+
stopAll(): Promise<void>;
|
|
5789
|
+
private startConfigured;
|
|
5790
|
+
private resolveMetadata;
|
|
5791
|
+
private normalizeIdentifier;
|
|
5792
|
+
private ensureUniqueId;
|
|
5793
|
+
private createAnonymousSlug;
|
|
5794
|
+
}
|
|
5750
5795
|
|
|
5751
5796
|
/**
|
|
5752
|
-
*
|
|
5797
|
+
* Client information for MCP
|
|
5753
5798
|
*/
|
|
5754
|
-
interface
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5799
|
+
interface ClientInfo {
|
|
5800
|
+
/**
|
|
5801
|
+
* Client name
|
|
5802
|
+
*/
|
|
5803
|
+
name: string;
|
|
5804
|
+
/**
|
|
5805
|
+
* Client version
|
|
5806
|
+
*/
|
|
5807
|
+
version: string;
|
|
5808
|
+
/**
|
|
5809
|
+
* Allow additional properties for SDK compatibility
|
|
5810
|
+
*/
|
|
5811
|
+
[key: string]: unknown;
|
|
5760
5812
|
}
|
|
5761
5813
|
/**
|
|
5762
|
-
*
|
|
5814
|
+
* Transport error from MCP
|
|
5763
5815
|
*/
|
|
5764
|
-
interface
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
};
|
|
5774
|
-
workflowRegistry: {
|
|
5775
|
-
getWorkflow(id: string): RegisteredWorkflow | undefined;
|
|
5776
|
-
getWorkflowsForApi(): unknown[];
|
|
5777
|
-
getWorkflowDetailForApi(id: string): unknown;
|
|
5778
|
-
getWorkflowCount(): number;
|
|
5779
|
-
on(event: string, handler: (...args: any[]) => void): void;
|
|
5780
|
-
off(event: string, handler: (...args: any[]) => void): void;
|
|
5781
|
-
activeExecutions: Map<string, WorkflowSuspendController>;
|
|
5782
|
-
resumeSuspendedWorkflow(workflowId: string, executionId: string, resumeData?: any, stepId?: string): Promise<any>;
|
|
5783
|
-
};
|
|
5784
|
-
logger?: Logger;
|
|
5785
|
-
voltOpsClient?: VoltOpsClient;
|
|
5786
|
-
observability?: VoltAgentObservability;
|
|
5816
|
+
interface TransportError extends Error {
|
|
5817
|
+
/**
|
|
5818
|
+
* Error code
|
|
5819
|
+
*/
|
|
5820
|
+
code?: string;
|
|
5821
|
+
/**
|
|
5822
|
+
* Error details
|
|
5823
|
+
*/
|
|
5824
|
+
details?: unknown;
|
|
5787
5825
|
}
|
|
5788
5826
|
/**
|
|
5789
|
-
*
|
|
5827
|
+
* Configuration for MCP client
|
|
5790
5828
|
*/
|
|
5791
|
-
type
|
|
5829
|
+
type MCPClientConfig = {
|
|
5830
|
+
/**
|
|
5831
|
+
* Client information
|
|
5832
|
+
*/
|
|
5833
|
+
clientInfo: ClientInfo;
|
|
5834
|
+
/**
|
|
5835
|
+
* MCP server configuration
|
|
5836
|
+
*/
|
|
5837
|
+
server: MCPServerConfig;
|
|
5838
|
+
/**
|
|
5839
|
+
* MCP capabilities
|
|
5840
|
+
*/
|
|
5841
|
+
capabilities?: ClientCapabilities;
|
|
5842
|
+
/**
|
|
5843
|
+
* Timeout in milliseconds for MCP requests
|
|
5844
|
+
* @default 30000
|
|
5845
|
+
*/
|
|
5846
|
+
timeout?: number;
|
|
5847
|
+
};
|
|
5792
5848
|
/**
|
|
5793
|
-
*
|
|
5849
|
+
* MCP server configuration options
|
|
5794
5850
|
*/
|
|
5795
|
-
|
|
5796
|
-
id: string;
|
|
5797
|
-
name: string;
|
|
5798
|
-
description: string;
|
|
5799
|
-
status: AgentStatus;
|
|
5800
|
-
model: string;
|
|
5801
|
-
tools: ToolStatusInfo[];
|
|
5802
|
-
memory?: Record<string, unknown>;
|
|
5803
|
-
subAgents?: ServerAgentResponse[];
|
|
5804
|
-
isTelemetryEnabled?: boolean;
|
|
5805
|
-
}
|
|
5806
|
-
interface ServerWorkflowResponse {
|
|
5807
|
-
id: string;
|
|
5808
|
-
name: string;
|
|
5809
|
-
purpose: string;
|
|
5810
|
-
stepsCount: number;
|
|
5811
|
-
status: "idle" | "running" | "completed" | "error";
|
|
5812
|
-
steps: Array<{
|
|
5813
|
-
id: string;
|
|
5814
|
-
name: string;
|
|
5815
|
-
purpose: string | null;
|
|
5816
|
-
type: string;
|
|
5817
|
-
agentId?: string;
|
|
5818
|
-
agentName?: string;
|
|
5819
|
-
}>;
|
|
5820
|
-
}
|
|
5821
|
-
interface ServerApiResponse<T> {
|
|
5822
|
-
success: boolean;
|
|
5823
|
-
data?: T;
|
|
5824
|
-
error?: string;
|
|
5825
|
-
}
|
|
5851
|
+
type MCPServerConfig = HTTPServerConfig | SSEServerConfig | StreamableHTTPServerConfig | StdioServerConfig;
|
|
5826
5852
|
/**
|
|
5827
|
-
*
|
|
5853
|
+
* HTTP-based MCP server configuration with automatic fallback
|
|
5854
|
+
* Tries streamable HTTP first, falls back to SSE if not supported
|
|
5828
5855
|
*/
|
|
5829
|
-
type
|
|
5830
|
-
agents: Record<string, Agent>;
|
|
5856
|
+
type HTTPServerConfig = {
|
|
5831
5857
|
/**
|
|
5832
|
-
*
|
|
5833
|
-
* Can be either Workflow instances or WorkflowChain instances
|
|
5858
|
+
* Type of server connection
|
|
5834
5859
|
*/
|
|
5835
|
-
|
|
5860
|
+
type: "http";
|
|
5836
5861
|
/**
|
|
5837
|
-
*
|
|
5838
|
-
* Example: honoServer({ port: 3141, enableSwaggerUI: true })
|
|
5862
|
+
* URL of the MCP server
|
|
5839
5863
|
*/
|
|
5840
|
-
|
|
5864
|
+
url: string;
|
|
5841
5865
|
/**
|
|
5842
|
-
*
|
|
5843
|
-
* Replaces the old telemetryExporter approach with a comprehensive solution.
|
|
5866
|
+
* Request initialization options
|
|
5844
5867
|
*/
|
|
5845
|
-
|
|
5868
|
+
requestInit?: RequestInit;
|
|
5846
5869
|
/**
|
|
5847
|
-
*
|
|
5848
|
-
* Allows sharing the same observability instance between VoltAgent and Agents
|
|
5849
|
-
* If not provided, creates a default instance with in-memory storage
|
|
5870
|
+
* Event source initialization options (used for SSE fallback)
|
|
5850
5871
|
*/
|
|
5851
|
-
|
|
5872
|
+
eventSourceInit?: EventSourceInit;
|
|
5852
5873
|
/**
|
|
5853
|
-
*
|
|
5854
|
-
* If
|
|
5874
|
+
* Optional maximum request timeout in milliseconds.
|
|
5875
|
+
* If provided, passed to MCPClient as the per-request timeout.
|
|
5855
5876
|
*/
|
|
5856
|
-
|
|
5877
|
+
timeout?: number;
|
|
5878
|
+
};
|
|
5879
|
+
/**
|
|
5880
|
+
* SSE-based MCP server configuration (explicit SSE transport)
|
|
5881
|
+
*/
|
|
5882
|
+
type SSEServerConfig = {
|
|
5857
5883
|
/**
|
|
5858
|
-
*
|
|
5884
|
+
* Type of server connection
|
|
5859
5885
|
*/
|
|
5860
|
-
|
|
5886
|
+
type: "sse";
|
|
5861
5887
|
/**
|
|
5862
|
-
*
|
|
5888
|
+
* URL of the MCP server
|
|
5863
5889
|
*/
|
|
5864
|
-
|
|
5865
|
-
checkDependencies?: boolean;
|
|
5890
|
+
url: string;
|
|
5866
5891
|
/**
|
|
5867
|
-
*
|
|
5892
|
+
* Request initialization options
|
|
5868
5893
|
*/
|
|
5869
|
-
|
|
5894
|
+
requestInit?: RequestInit;
|
|
5870
5895
|
/**
|
|
5871
|
-
*
|
|
5896
|
+
* Event source initialization options
|
|
5872
5897
|
*/
|
|
5873
|
-
|
|
5898
|
+
eventSourceInit?: EventSourceInit;
|
|
5899
|
+
/**
|
|
5900
|
+
* Optional maximum request timeout in milliseconds.
|
|
5901
|
+
* If provided, passed to MCPClient as the per-request timeout.
|
|
5902
|
+
*/
|
|
5903
|
+
timeout?: number;
|
|
5874
5904
|
};
|
|
5875
|
-
|
|
5876
5905
|
/**
|
|
5877
|
-
*
|
|
5906
|
+
* Streamable HTTP-based MCP server configuration (no fallback)
|
|
5878
5907
|
*/
|
|
5879
|
-
type
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5908
|
+
type StreamableHTTPServerConfig = {
|
|
5909
|
+
/**
|
|
5910
|
+
* Type of server connection
|
|
5911
|
+
*/
|
|
5912
|
+
type: "streamable-http";
|
|
5913
|
+
/**
|
|
5914
|
+
* URL of the MCP server
|
|
5915
|
+
*/
|
|
5916
|
+
url: string;
|
|
5917
|
+
/**
|
|
5918
|
+
* Request initialization options
|
|
5919
|
+
*/
|
|
5920
|
+
requestInit?: RequestInit;
|
|
5921
|
+
/**
|
|
5922
|
+
* Session ID for the connection
|
|
5923
|
+
*/
|
|
5924
|
+
sessionId?: string;
|
|
5925
|
+
/**
|
|
5926
|
+
* Optional maximum request timeout in milliseconds.
|
|
5927
|
+
* If provided, passed to MCPClient as the per-request timeout.
|
|
5928
|
+
*/
|
|
5929
|
+
timeout?: number;
|
|
5890
5930
|
};
|
|
5891
|
-
type PromptCreator<T extends string> = (extraVariables?: Partial<TemplateVariables<T>>) => string;
|
|
5892
5931
|
/**
|
|
5893
|
-
*
|
|
5894
|
-
* Variable names are automatically inferred from the template `{{variable}}` syntax.
|
|
5895
|
-
*
|
|
5896
|
-
* @param template - The template string with `{{variable}}` placeholders.
|
|
5897
|
-
* @param variables - An object containing the default values for the template variables.
|
|
5898
|
-
* @returns A function that takes optional extra variables and returns the processed prompt string.
|
|
5932
|
+
* Stdio-based MCP server configuration
|
|
5899
5933
|
*/
|
|
5900
|
-
|
|
5901
|
-
|
|
5934
|
+
type StdioServerConfig = {
|
|
5935
|
+
/**
|
|
5936
|
+
* Type of server connection
|
|
5937
|
+
*/
|
|
5938
|
+
type: "stdio";
|
|
5939
|
+
/**
|
|
5940
|
+
* Command to run the MCP server
|
|
5941
|
+
*/
|
|
5942
|
+
command: string;
|
|
5943
|
+
/**
|
|
5944
|
+
* Arguments to pass to the command
|
|
5945
|
+
*/
|
|
5946
|
+
args?: string[];
|
|
5947
|
+
/**
|
|
5948
|
+
* Environment variables for the MCP server process
|
|
5949
|
+
*/
|
|
5950
|
+
env?: Record<string, string>;
|
|
5951
|
+
/**
|
|
5952
|
+
* Working directory for the MCP server process
|
|
5953
|
+
*/
|
|
5954
|
+
cwd?: string;
|
|
5955
|
+
/**
|
|
5956
|
+
* Optional maximum request timeout in milliseconds.
|
|
5957
|
+
* If provided, passed to MCPClient as the per-request timeout.
|
|
5958
|
+
*/
|
|
5959
|
+
timeout?: number;
|
|
5960
|
+
};
|
|
5902
5961
|
/**
|
|
5903
|
-
*
|
|
5962
|
+
* Tool call request
|
|
5904
5963
|
*/
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
MEMORY = "memory",
|
|
5910
|
-
MESSAGE = "message",
|
|
5911
|
-
OUTPUT = "output",
|
|
5912
|
-
RETRIEVER = "retriever",
|
|
5913
|
-
VECTOR = "vector",
|
|
5914
|
-
EMBEDDING = "embedding",
|
|
5915
|
-
WORKFLOW_STEP = "workflow_step",
|
|
5916
|
-
WORKFLOW_AGENT_STEP = "workflow_agent_step",
|
|
5917
|
-
WORKFLOW_FUNC_STEP = "workflow_func_step",
|
|
5918
|
-
WORKFLOW_CONDITIONAL_STEP = "workflow_conditional_step",
|
|
5919
|
-
WORKFLOW_PARALLEL_ALL_STEP = "workflow_parallel_all_step",
|
|
5920
|
-
WORKFLOW_PARALLEL_RACE_STEP = "workflow_parallel_race_step"
|
|
5921
|
-
}
|
|
5922
|
-
/**
|
|
5923
|
-
* Standard node ID creation function
|
|
5924
|
-
* @param type Node type
|
|
5925
|
-
* @param name Main identifier (tool name, agent name, etc.)
|
|
5926
|
-
* @param ownerId Owner ID (optional)
|
|
5927
|
-
* @returns Standard formatted node ID
|
|
5928
|
-
*/
|
|
5929
|
-
declare const createNodeId: (type: NodeType, name: string, ownerId?: string) => string;
|
|
5930
|
-
/**
|
|
5931
|
-
* Function to extract node type from NodeID
|
|
5932
|
-
* @param nodeId Node ID
|
|
5933
|
-
* @returns NodeType or null (if type cannot be found)
|
|
5934
|
-
*/
|
|
5935
|
-
declare const getNodeTypeFromNodeId: (nodeId: string) => NodeType | null;
|
|
5936
|
-
/**
|
|
5937
|
-
* Workflow step types enum
|
|
5938
|
-
*/
|
|
5939
|
-
type WorkflowStepType = "agent" | "func" | "conditional-when" | "parallel-all" | "parallel-race";
|
|
5940
|
-
/**
|
|
5941
|
-
* Create a workflow step node ID with consistent pattern
|
|
5942
|
-
* @param stepType Type of workflow step
|
|
5943
|
-
* @param stepIndex Index of step in workflow
|
|
5944
|
-
* @param workflowId Workflow identifier
|
|
5945
|
-
* @param options Additional options for node ID generation
|
|
5946
|
-
* @returns Consistent workflow step node ID
|
|
5947
|
-
*/
|
|
5948
|
-
declare const createWorkflowStepNodeId: (stepType: WorkflowStepType, stepIndex: number, workflowId: string, options?: {
|
|
5949
|
-
agentId?: string;
|
|
5950
|
-
parallelIndex?: number;
|
|
5951
|
-
stepName?: string;
|
|
5952
|
-
stepId?: string;
|
|
5953
|
-
}) => string;
|
|
5954
|
-
/**
|
|
5955
|
-
* Get NodeType for workflow step type
|
|
5956
|
-
* @param stepType Workflow step type
|
|
5957
|
-
* @returns Corresponding NodeType
|
|
5958
|
-
*/
|
|
5959
|
-
declare const getWorkflowStepNodeType: (stepType: WorkflowStepType) => NodeType;
|
|
5960
|
-
/**
|
|
5961
|
-
* Extract workflow step information from node ID
|
|
5962
|
-
* @param nodeId Workflow step node ID
|
|
5963
|
-
* @returns Extracted workflow step info or null
|
|
5964
|
-
*/
|
|
5965
|
-
declare const extractWorkflowStepInfo: (nodeId: string) => {
|
|
5966
|
-
stepType: WorkflowStepType;
|
|
5967
|
-
stepIndex: number;
|
|
5968
|
-
workflowId: string;
|
|
5969
|
-
agentId?: string;
|
|
5970
|
-
parallelIndex?: number;
|
|
5971
|
-
stepName?: string;
|
|
5972
|
-
} | null;
|
|
5973
|
-
|
|
5974
|
-
/**
|
|
5975
|
-
* Tool call interface
|
|
5976
|
-
*/
|
|
5977
|
-
interface ToolCall {
|
|
5978
|
-
id: string;
|
|
5979
|
-
type: "function";
|
|
5980
|
-
function: {
|
|
5981
|
-
name: string;
|
|
5982
|
-
arguments: string;
|
|
5983
|
-
};
|
|
5984
|
-
}
|
|
5985
|
-
/**
|
|
5986
|
-
* Converts a Zod-like schema to a JSON representation usable in the UI
|
|
5987
|
-
* @param schema Any Zod schema object
|
|
5988
|
-
* @returns A JSON Schema compatible representation of the Zod schema
|
|
5989
|
-
*/
|
|
5990
|
-
declare function zodSchemaToJsonUI(schema: any): any;
|
|
5991
|
-
|
|
5992
|
-
type UpdateOptions = {
|
|
5993
|
-
filter?: string;
|
|
5994
|
-
useCache?: boolean;
|
|
5995
|
-
forceRefresh?: boolean;
|
|
5996
|
-
};
|
|
5997
|
-
/**
|
|
5998
|
-
* Package update info with semver details
|
|
5999
|
-
*/
|
|
6000
|
-
type PackageUpdateInfo = {
|
|
5964
|
+
type MCPToolCall = {
|
|
5965
|
+
/**
|
|
5966
|
+
* Name of the tool to call
|
|
5967
|
+
*/
|
|
6001
5968
|
name: string;
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
5969
|
+
/**
|
|
5970
|
+
* Arguments to pass to the tool
|
|
5971
|
+
*/
|
|
5972
|
+
arguments: Record<string, unknown>;
|
|
6006
5973
|
};
|
|
6007
5974
|
/**
|
|
6008
|
-
*
|
|
6009
|
-
* @returns Object containing update information
|
|
5975
|
+
* Tool call result
|
|
6010
5976
|
*/
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
}
|
|
5977
|
+
type MCPToolResult = {
|
|
5978
|
+
/**
|
|
5979
|
+
* Result content from the tool
|
|
5980
|
+
*/
|
|
5981
|
+
content: unknown;
|
|
5982
|
+
};
|
|
6017
5983
|
/**
|
|
6018
|
-
*
|
|
6019
|
-
* @param packagePath Optional path to package.json, uses current directory if not provided
|
|
6020
|
-
* @returns Result of the update operation
|
|
5984
|
+
* MCP client events
|
|
6021
5985
|
*/
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
5986
|
+
interface MCPClientEvents {
|
|
5987
|
+
/**
|
|
5988
|
+
* Emitted when the client connects to the server
|
|
5989
|
+
*/
|
|
5990
|
+
connect: () => void;
|
|
5991
|
+
/**
|
|
5992
|
+
* Emitted when the client disconnects from the server
|
|
5993
|
+
*/
|
|
5994
|
+
disconnect: () => void;
|
|
5995
|
+
/**
|
|
5996
|
+
* Emitted when an error occurs
|
|
5997
|
+
*/
|
|
5998
|
+
error: (error: Error | TransportError) => void;
|
|
5999
|
+
/**
|
|
6000
|
+
* Emitted when a tool call completes
|
|
6001
|
+
*/
|
|
6002
|
+
toolCall: (name: string, args: Record<string, unknown>, result: unknown) => void;
|
|
6003
|
+
}
|
|
6028
6004
|
/**
|
|
6029
|
-
*
|
|
6030
|
-
* @param packageName Name of the package to update
|
|
6031
|
-
* @param packagePath Optional path to package.json, uses current directory if not provided
|
|
6032
|
-
* @returns Result of the update operation
|
|
6005
|
+
* A record of tools along with a helper method to convert them to an array.
|
|
6033
6006
|
*/
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
}
|
|
6040
|
-
|
|
6007
|
+
type ToolsetWithTools = Record<string, AnyToolConfig> & {
|
|
6008
|
+
/**
|
|
6009
|
+
* Converts the toolset to an array of BaseTool objects.
|
|
6010
|
+
*/
|
|
6011
|
+
getTools: () => Tool<any>[];
|
|
6012
|
+
};
|
|
6041
6013
|
/**
|
|
6042
|
-
*
|
|
6043
|
-
* @param value String to parse as JSON
|
|
6044
|
-
* @returns Parsed JSON object or original value if parsing fails
|
|
6014
|
+
* Any tool configuration
|
|
6045
6015
|
*/
|
|
6046
|
-
|
|
6047
|
-
declare function serializeValueForDebug(value: unknown): unknown;
|
|
6016
|
+
type AnyToolConfig = Tool<any>;
|
|
6048
6017
|
|
|
6049
6018
|
/**
|
|
6050
|
-
*
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
/**
|
|
6054
|
-
* Type guard to check if content is structured (array of content parts)
|
|
6055
|
-
*/
|
|
6056
|
-
declare function isStructuredContent(content: MessageContent): content is Array<any>;
|
|
6057
|
-
/**
|
|
6058
|
-
* Check if content has any text parts
|
|
6059
|
-
*/
|
|
6060
|
-
declare function hasTextPart(content: MessageContent): boolean;
|
|
6061
|
-
/**
|
|
6062
|
-
* Check if content has any image parts
|
|
6063
|
-
*/
|
|
6064
|
-
declare function hasImagePart(content: MessageContent): boolean;
|
|
6065
|
-
/**
|
|
6066
|
-
* Check if content has any file parts
|
|
6067
|
-
*/
|
|
6068
|
-
declare function hasFilePart(content: MessageContent): boolean;
|
|
6069
|
-
/**
|
|
6070
|
-
* Extract text from message content
|
|
6071
|
-
*/
|
|
6072
|
-
declare function extractText(content: MessageContent): string;
|
|
6073
|
-
/**
|
|
6074
|
-
* Extract all text parts from structured content
|
|
6075
|
-
*/
|
|
6076
|
-
declare function extractTextParts(content: MessageContent): Array<{
|
|
6077
|
-
type: "text";
|
|
6078
|
-
text: string;
|
|
6079
|
-
}>;
|
|
6080
|
-
/**
|
|
6081
|
-
* Extract image parts from message content
|
|
6082
|
-
*/
|
|
6083
|
-
declare function extractImageParts(content: MessageContent): Array<any>;
|
|
6084
|
-
/**
|
|
6085
|
-
* Extract file parts from message content
|
|
6086
|
-
*/
|
|
6087
|
-
declare function extractFileParts(content: MessageContent): Array<any>;
|
|
6088
|
-
/**
|
|
6089
|
-
* Transform text content in a message
|
|
6090
|
-
*/
|
|
6091
|
-
declare function transformTextContent(content: MessageContent, transformer: (text: string) => string): MessageContent;
|
|
6092
|
-
/**
|
|
6093
|
-
* Map UIMessage text parts with a transformer function
|
|
6094
|
-
*/
|
|
6095
|
-
declare function mapMessageContent(message: UIMessage, transformer: (text: string) => string): UIMessage;
|
|
6096
|
-
/**
|
|
6097
|
-
* Filter content parts by type
|
|
6098
|
-
*/
|
|
6099
|
-
declare function filterContentParts(content: MessageContent, predicate: (part: any) => boolean): MessageContent;
|
|
6100
|
-
/**
|
|
6101
|
-
* Normalize content to always be an array
|
|
6102
|
-
*/
|
|
6103
|
-
declare function normalizeToArray(content: MessageContent): Array<any>;
|
|
6104
|
-
/**
|
|
6105
|
-
* Normalize content to the most compact form
|
|
6106
|
-
*/
|
|
6107
|
-
declare function normalizeContent(content: MessageContent): MessageContent;
|
|
6108
|
-
/**
|
|
6109
|
-
* Builder class for creating message content
|
|
6019
|
+
* Client for interacting with Model Context Protocol (MCP) servers.
|
|
6020
|
+
* Wraps the official MCP SDK client to provide a higher-level interface.
|
|
6021
|
+
* Internal implementation differs from original source.
|
|
6110
6022
|
*/
|
|
6111
|
-
declare class
|
|
6112
|
-
private parts;
|
|
6023
|
+
declare class MCPClient extends EventEmitter {
|
|
6113
6024
|
/**
|
|
6114
|
-
*
|
|
6025
|
+
* Underlying MCP client instance from the SDK.
|
|
6115
6026
|
*/
|
|
6116
|
-
|
|
6027
|
+
private client;
|
|
6117
6028
|
/**
|
|
6118
|
-
*
|
|
6029
|
+
* Communication channel (transport layer) for MCP interactions.
|
|
6119
6030
|
*/
|
|
6120
|
-
|
|
6031
|
+
private transport;
|
|
6121
6032
|
/**
|
|
6122
|
-
*
|
|
6033
|
+
* Tracks the connection status to the server.
|
|
6123
6034
|
*/
|
|
6124
|
-
|
|
6035
|
+
private connected;
|
|
6125
6036
|
/**
|
|
6126
|
-
*
|
|
6037
|
+
* Maximum time allowed for requests in milliseconds.
|
|
6127
6038
|
*/
|
|
6128
|
-
|
|
6039
|
+
private readonly timeout;
|
|
6129
6040
|
/**
|
|
6130
|
-
*
|
|
6041
|
+
* Logger instance
|
|
6131
6042
|
*/
|
|
6132
|
-
|
|
6133
|
-
/**
|
|
6134
|
-
* Build as array (always returns array)
|
|
6135
|
-
*/
|
|
6136
|
-
buildAsArray(): Array<any>;
|
|
6043
|
+
private logger;
|
|
6137
6044
|
/**
|
|
6138
|
-
*
|
|
6045
|
+
* Information identifying this client to the server.
|
|
6139
6046
|
*/
|
|
6140
|
-
|
|
6047
|
+
private readonly clientInfo;
|
|
6141
6048
|
/**
|
|
6142
|
-
*
|
|
6049
|
+
* Server configuration for fallback attempts.
|
|
6143
6050
|
*/
|
|
6144
|
-
|
|
6145
|
-
}
|
|
6146
|
-
/**
|
|
6147
|
-
* Convenience function to add timestamp to user messages (UIMessage only)
|
|
6148
|
-
*/
|
|
6149
|
-
declare function addTimestampToMessage(message: UIMessage, timestamp?: string): UIMessage;
|
|
6150
|
-
/**
|
|
6151
|
-
* Convenience function to prepend text to UIMessage text parts
|
|
6152
|
-
*/
|
|
6153
|
-
declare function prependToMessage(message: UIMessage, prefix: string): UIMessage;
|
|
6154
|
-
/**
|
|
6155
|
-
* Convenience function to append text to UIMessage text parts
|
|
6156
|
-
*/
|
|
6157
|
-
declare function appendToMessage(message: UIMessage, suffix: string): UIMessage;
|
|
6158
|
-
/**
|
|
6159
|
-
* Check if UIMessage has any content
|
|
6160
|
-
*/
|
|
6161
|
-
declare function hasContent(message: UIMessage): boolean;
|
|
6162
|
-
/**
|
|
6163
|
-
* Get content length (text characters or array items)
|
|
6164
|
-
*/
|
|
6165
|
-
declare function getContentLength(content: MessageContent): number;
|
|
6166
|
-
/**
|
|
6167
|
-
* Combined message helpers object for easy importing
|
|
6168
|
-
*/
|
|
6169
|
-
declare const messageHelpers: {
|
|
6170
|
-
isTextContent: typeof isTextContent;
|
|
6171
|
-
isStructuredContent: typeof isStructuredContent;
|
|
6172
|
-
hasTextPart: typeof hasTextPart;
|
|
6173
|
-
hasImagePart: typeof hasImagePart;
|
|
6174
|
-
hasFilePart: typeof hasFilePart;
|
|
6175
|
-
extractText: typeof extractText;
|
|
6176
|
-
extractTextParts: typeof extractTextParts;
|
|
6177
|
-
extractImageParts: typeof extractImageParts;
|
|
6178
|
-
extractFileParts: typeof extractFileParts;
|
|
6179
|
-
transformTextContent: typeof transformTextContent;
|
|
6180
|
-
mapMessageContent: typeof mapMessageContent;
|
|
6181
|
-
filterContentParts: typeof filterContentParts;
|
|
6182
|
-
normalizeToArray: typeof normalizeToArray;
|
|
6183
|
-
normalizeContent: typeof normalizeContent;
|
|
6184
|
-
addTimestampToMessage: typeof addTimestampToMessage;
|
|
6185
|
-
prependToMessage: typeof prependToMessage;
|
|
6186
|
-
appendToMessage: typeof appendToMessage;
|
|
6187
|
-
hasContent: typeof hasContent;
|
|
6188
|
-
getContentLength: typeof getContentLength;
|
|
6189
|
-
MessageContentBuilder: typeof MessageContentBuilder;
|
|
6190
|
-
};
|
|
6191
|
-
|
|
6192
|
-
/**
|
|
6193
|
-
* Creates an AgentTool from a retriever, allowing it to be used as a tool in an agent.
|
|
6194
|
-
* This is the preferred way to use a retriever as a tool, as it properly maintains the 'this' context.
|
|
6195
|
-
*
|
|
6196
|
-
* @param retriever - The retriever instance to convert to a tool
|
|
6197
|
-
* @param options - Options for customizing the tool
|
|
6198
|
-
* @returns An AgentTool that can be added to an agent's tools
|
|
6199
|
-
*
|
|
6200
|
-
* @example
|
|
6201
|
-
* ```typescript
|
|
6202
|
-
* const retriever = new SimpleRetriever();
|
|
6203
|
-
* const searchTool = createRetrieverTool(retriever, {
|
|
6204
|
-
* name: "search_knowledge",
|
|
6205
|
-
* description: "Searches the knowledge base for information"
|
|
6206
|
-
* });
|
|
6207
|
-
*
|
|
6208
|
-
* agent.addTool(searchTool);
|
|
6209
|
-
* ```
|
|
6210
|
-
*/
|
|
6211
|
-
declare const createRetrieverTool: (retriever: Retriever, options?: {
|
|
6212
|
-
name?: string;
|
|
6213
|
-
description?: string;
|
|
6214
|
-
}) => AgentTool;
|
|
6215
|
-
|
|
6216
|
-
/**
|
|
6217
|
-
* Client information for MCP
|
|
6218
|
-
*/
|
|
6219
|
-
interface ClientInfo {
|
|
6051
|
+
private readonly serverConfig;
|
|
6220
6052
|
/**
|
|
6221
|
-
*
|
|
6053
|
+
* Whether to attempt SSE fallback if streamable HTTP fails.
|
|
6222
6054
|
*/
|
|
6223
|
-
|
|
6055
|
+
private shouldAttemptFallback;
|
|
6224
6056
|
/**
|
|
6225
|
-
* Client
|
|
6057
|
+
* Client capabilities for re-initialization.
|
|
6226
6058
|
*/
|
|
6227
|
-
|
|
6059
|
+
private readonly capabilities;
|
|
6228
6060
|
/**
|
|
6229
|
-
*
|
|
6061
|
+
* Get server info for logging
|
|
6230
6062
|
*/
|
|
6231
|
-
|
|
6232
|
-
}
|
|
6233
|
-
/**
|
|
6234
|
-
* Transport error from MCP
|
|
6235
|
-
*/
|
|
6236
|
-
interface TransportError extends Error {
|
|
6063
|
+
private getServerInfo;
|
|
6237
6064
|
/**
|
|
6238
|
-
*
|
|
6065
|
+
* Creates a new MCP client instance.
|
|
6066
|
+
* @param config Configuration for the client, including server details and client identity.
|
|
6239
6067
|
*/
|
|
6240
|
-
|
|
6068
|
+
constructor(config: MCPClientConfig);
|
|
6241
6069
|
/**
|
|
6242
|
-
*
|
|
6070
|
+
* Sets up handlers for events from the underlying SDK client.
|
|
6243
6071
|
*/
|
|
6244
|
-
|
|
6245
|
-
}
|
|
6246
|
-
/**
|
|
6247
|
-
* Model Context Protocol (MCP) configuration options
|
|
6248
|
-
*/
|
|
6249
|
-
type MCPOptions = {
|
|
6072
|
+
private setupEventHandlers;
|
|
6250
6073
|
/**
|
|
6251
|
-
*
|
|
6074
|
+
* Establishes a connection to the configured MCP server.
|
|
6075
|
+
* Idempotent: does nothing if already connected.
|
|
6252
6076
|
*/
|
|
6253
|
-
|
|
6077
|
+
connect(): Promise<void>;
|
|
6254
6078
|
/**
|
|
6255
|
-
*
|
|
6079
|
+
* Attempts to connect using SSE transport as a fallback.
|
|
6080
|
+
* @param originalError The error from the initial connection attempt.
|
|
6256
6081
|
*/
|
|
6257
|
-
|
|
6082
|
+
private attemptSSEFallback;
|
|
6258
6083
|
/**
|
|
6259
|
-
*
|
|
6084
|
+
* Closes the connection to the MCP server.
|
|
6085
|
+
* Idempotent: does nothing if not connected.
|
|
6260
6086
|
*/
|
|
6261
|
-
|
|
6087
|
+
disconnect(): Promise<void>;
|
|
6262
6088
|
/**
|
|
6263
|
-
*
|
|
6089
|
+
* Fetches the definitions of available tools from the server.
|
|
6090
|
+
* @returns A record mapping tool names to their definitions (schema, description).
|
|
6264
6091
|
*/
|
|
6265
|
-
|
|
6092
|
+
listTools(): Promise<Record<string, unknown>>;
|
|
6266
6093
|
/**
|
|
6267
|
-
*
|
|
6094
|
+
* Builds executable Tool objects from the server's tool definitions.
|
|
6095
|
+
* These tools include an `execute` method for calling the remote tool.
|
|
6096
|
+
* @returns A record mapping namespaced tool names (`clientName_toolName`) to executable Tool objects.
|
|
6268
6097
|
*/
|
|
6269
|
-
|
|
6098
|
+
getAgentTools(): Promise<Record<string, Tool<any>>>;
|
|
6270
6099
|
/**
|
|
6271
|
-
*
|
|
6272
|
-
* @
|
|
6100
|
+
* Executes a specified tool on the remote MCP server.
|
|
6101
|
+
* @param toolCall Details of the tool to call, including name and arguments.
|
|
6102
|
+
* @returns The result content returned by the tool.
|
|
6273
6103
|
*/
|
|
6274
|
-
|
|
6275
|
-
};
|
|
6276
|
-
/**
|
|
6277
|
-
* Configuration for MCP client
|
|
6278
|
-
*/
|
|
6279
|
-
type MCPClientConfig = {
|
|
6104
|
+
callTool(toolCall: MCPToolCall): Promise<MCPToolResult>;
|
|
6280
6105
|
/**
|
|
6281
|
-
*
|
|
6106
|
+
* Retrieves a list of resource identifiers available on the server.
|
|
6107
|
+
* @returns A promise resolving to an array of resource ID strings.
|
|
6282
6108
|
*/
|
|
6283
|
-
|
|
6109
|
+
listResources(): Promise<string[]>;
|
|
6284
6110
|
/**
|
|
6285
|
-
*
|
|
6111
|
+
* Ensures the client is connected before proceeding with an operation.
|
|
6112
|
+
* Attempts to connect if not currently connected.
|
|
6113
|
+
* @throws Error if connection attempt fails.
|
|
6286
6114
|
*/
|
|
6287
|
-
|
|
6115
|
+
private ensureConnected;
|
|
6288
6116
|
/**
|
|
6289
|
-
*
|
|
6117
|
+
* Emits an 'error' event, ensuring the payload is always an Error object.
|
|
6118
|
+
* @param error The error encountered, can be of any type.
|
|
6290
6119
|
*/
|
|
6291
|
-
|
|
6120
|
+
private emitError;
|
|
6292
6121
|
/**
|
|
6293
|
-
*
|
|
6294
|
-
* @
|
|
6122
|
+
* Type guard to check if a server configuration is for an HTTP server.
|
|
6123
|
+
* @param server The server configuration object.
|
|
6124
|
+
* @returns True if the configuration type is 'http', false otherwise.
|
|
6295
6125
|
*/
|
|
6296
|
-
|
|
6297
|
-
};
|
|
6298
|
-
/**
|
|
6299
|
-
* MCP server configuration options
|
|
6300
|
-
*/
|
|
6301
|
-
type MCPServerConfig = HTTPServerConfig | SSEServerConfig | StreamableHTTPServerConfig | StdioServerConfig;
|
|
6302
|
-
/**
|
|
6303
|
-
* HTTP-based MCP server configuration with automatic fallback
|
|
6304
|
-
* Tries streamable HTTP first, falls back to SSE if not supported
|
|
6305
|
-
*/
|
|
6306
|
-
type HTTPServerConfig = {
|
|
6126
|
+
private isHTTPServer;
|
|
6307
6127
|
/**
|
|
6308
|
-
* Type
|
|
6128
|
+
* Type guard to check if a server configuration is for an SSE server.
|
|
6129
|
+
* @param server The server configuration object.
|
|
6130
|
+
* @returns True if the configuration type is 'sse', false otherwise.
|
|
6309
6131
|
*/
|
|
6310
|
-
|
|
6132
|
+
private isSSEServer;
|
|
6311
6133
|
/**
|
|
6312
|
-
*
|
|
6134
|
+
* Type guard to check if a server configuration is for a Streamable HTTP server.
|
|
6135
|
+
* @param server The server configuration object.
|
|
6136
|
+
* @returns True if the configuration type is 'streamable-http', false otherwise.
|
|
6313
6137
|
*/
|
|
6314
|
-
|
|
6138
|
+
private isStreamableHTTPServer;
|
|
6315
6139
|
/**
|
|
6316
|
-
*
|
|
6140
|
+
* Type guard to check if a server configuration is for a Stdio server.
|
|
6141
|
+
* @param server The server configuration object.
|
|
6142
|
+
* @returns True if the configuration type is 'stdio', false otherwise.
|
|
6317
6143
|
*/
|
|
6318
|
-
|
|
6144
|
+
private isStdioServer;
|
|
6319
6145
|
/**
|
|
6320
|
-
*
|
|
6146
|
+
* Overrides EventEmitter's 'on' method for type-safe event listening.
|
|
6147
|
+
* Uses the original `MCPClientEvents` for event types.
|
|
6321
6148
|
*/
|
|
6322
|
-
|
|
6149
|
+
on<E extends keyof MCPClientEvents>(event: E, listener: MCPClientEvents[E]): this;
|
|
6323
6150
|
/**
|
|
6324
|
-
*
|
|
6325
|
-
*
|
|
6151
|
+
* Overrides EventEmitter's 'emit' method for type-safe event emission.
|
|
6152
|
+
* Uses the original `MCPClientEvents` for event types.
|
|
6326
6153
|
*/
|
|
6327
|
-
|
|
6328
|
-
}
|
|
6154
|
+
emit<E extends keyof MCPClientEvents>(event: E, ...args: Parameters<MCPClientEvents[E]>): boolean;
|
|
6155
|
+
}
|
|
6156
|
+
|
|
6329
6157
|
/**
|
|
6330
|
-
*
|
|
6158
|
+
* Configuration manager for Model Context Protocol (MCP).
|
|
6159
|
+
* Handles multiple MCP server connections and tool management.
|
|
6160
|
+
* NOTE: This version does NOT manage singleton instances automatically.
|
|
6331
6161
|
*/
|
|
6332
|
-
|
|
6162
|
+
declare class MCPConfiguration<TServerKeys extends string = string> {
|
|
6333
6163
|
/**
|
|
6334
|
-
*
|
|
6164
|
+
* Map of server configurations keyed by server names.
|
|
6335
6165
|
*/
|
|
6336
|
-
|
|
6166
|
+
private readonly serverConfigs;
|
|
6337
6167
|
/**
|
|
6338
|
-
*
|
|
6168
|
+
* Map of connected MCP clients keyed by server names (local cache).
|
|
6339
6169
|
*/
|
|
6340
|
-
|
|
6170
|
+
private readonly mcpClientsById;
|
|
6341
6171
|
/**
|
|
6342
|
-
*
|
|
6172
|
+
* Creates a new, independent MCP configuration instance.
|
|
6173
|
+
* @param options Configuration options including server definitions.
|
|
6343
6174
|
*/
|
|
6344
|
-
|
|
6175
|
+
constructor(options: {
|
|
6176
|
+
servers: Record<TServerKeys, MCPServerConfig>;
|
|
6177
|
+
});
|
|
6345
6178
|
/**
|
|
6346
|
-
*
|
|
6179
|
+
* Type guard to check if an object conforms to the basic structure of AnyToolConfig.
|
|
6347
6180
|
*/
|
|
6348
|
-
|
|
6181
|
+
private isAnyToolConfigStructure;
|
|
6349
6182
|
/**
|
|
6350
|
-
*
|
|
6351
|
-
* If provided, passed to MCPClient as the per-request timeout.
|
|
6183
|
+
* Disconnects all associated MCP clients for THIS instance.
|
|
6352
6184
|
*/
|
|
6353
|
-
|
|
6354
|
-
};
|
|
6355
|
-
/**
|
|
6356
|
-
* Streamable HTTP-based MCP server configuration (no fallback)
|
|
6357
|
-
*/
|
|
6358
|
-
type StreamableHTTPServerConfig = {
|
|
6185
|
+
disconnect(): Promise<void>;
|
|
6359
6186
|
/**
|
|
6360
|
-
*
|
|
6187
|
+
* Retrieves agent-ready tools from all configured MCP servers for this instance.
|
|
6188
|
+
* @returns A flat array of all agent-ready tools.
|
|
6361
6189
|
*/
|
|
6362
|
-
|
|
6190
|
+
getTools(): Promise<Tool<any>[]>;
|
|
6363
6191
|
/**
|
|
6364
|
-
*
|
|
6192
|
+
* Retrieves raw tool definitions from all configured MCP servers for this instance.
|
|
6193
|
+
* @returns A flat record of all raw tools keyed by their namespaced name.
|
|
6365
6194
|
*/
|
|
6366
|
-
|
|
6367
|
-
/**
|
|
6368
|
-
* Request initialization options
|
|
6369
|
-
*/
|
|
6370
|
-
requestInit?: RequestInit;
|
|
6371
|
-
/**
|
|
6372
|
-
* Session ID for the connection
|
|
6373
|
-
*/
|
|
6374
|
-
sessionId?: string;
|
|
6375
|
-
/**
|
|
6376
|
-
* Optional maximum request timeout in milliseconds.
|
|
6377
|
-
* If provided, passed to MCPClient as the per-request timeout.
|
|
6378
|
-
*/
|
|
6379
|
-
timeout?: number;
|
|
6380
|
-
};
|
|
6381
|
-
/**
|
|
6382
|
-
* Stdio-based MCP server configuration
|
|
6383
|
-
*/
|
|
6384
|
-
type StdioServerConfig = {
|
|
6385
|
-
/**
|
|
6386
|
-
* Type of server connection
|
|
6387
|
-
*/
|
|
6388
|
-
type: "stdio";
|
|
6389
|
-
/**
|
|
6390
|
-
* Command to run the MCP server
|
|
6391
|
-
*/
|
|
6392
|
-
command: string;
|
|
6393
|
-
/**
|
|
6394
|
-
* Arguments to pass to the command
|
|
6395
|
-
*/
|
|
6396
|
-
args?: string[];
|
|
6195
|
+
getRawTools(): Promise<Record<string, AnyToolConfig>>;
|
|
6397
6196
|
/**
|
|
6398
|
-
*
|
|
6197
|
+
* Retrieves agent-ready toolsets grouped by server name for this instance.
|
|
6198
|
+
* @returns A record where keys are server names and values are agent-ready toolsets.
|
|
6399
6199
|
*/
|
|
6400
|
-
|
|
6200
|
+
getToolsets(): Promise<Record<TServerKeys, ToolsetWithTools>>;
|
|
6401
6201
|
/**
|
|
6402
|
-
*
|
|
6202
|
+
* Retrieves raw tool definitions grouped by server name for this instance.
|
|
6203
|
+
* @returns A record where keys are server names and values are records of raw tools.
|
|
6403
6204
|
*/
|
|
6404
|
-
|
|
6205
|
+
getRawToolsets(): Promise<Record<TServerKeys, Record<string, AnyToolConfig>>>;
|
|
6405
6206
|
/**
|
|
6406
|
-
*
|
|
6407
|
-
* If provided, passed to MCPClient as the per-request timeout.
|
|
6207
|
+
* Retrieves a specific connected MCP client by its server name for this instance.
|
|
6408
6208
|
*/
|
|
6409
|
-
|
|
6410
|
-
};
|
|
6411
|
-
/**
|
|
6412
|
-
* Tool call request
|
|
6413
|
-
*/
|
|
6414
|
-
type MCPToolCall = {
|
|
6209
|
+
getClient(serverName: TServerKeys): Promise<MCPClient | undefined>;
|
|
6415
6210
|
/**
|
|
6416
|
-
*
|
|
6211
|
+
* Retrieves all configured MCP clients for this instance, ensuring they are connected.
|
|
6417
6212
|
*/
|
|
6418
|
-
|
|
6213
|
+
getClients(): Promise<Record<TServerKeys, MCPClient>>;
|
|
6419
6214
|
/**
|
|
6420
|
-
*
|
|
6215
|
+
* Internal helper to get/create/connect a client for this instance.
|
|
6216
|
+
* Manages the local mcpClientsById cache.
|
|
6421
6217
|
*/
|
|
6422
|
-
|
|
6423
|
-
}
|
|
6218
|
+
private getConnectedClient;
|
|
6219
|
+
}
|
|
6220
|
+
|
|
6424
6221
|
/**
|
|
6425
|
-
*
|
|
6222
|
+
* Basic type definitions for VoltAgent Core
|
|
6426
6223
|
*/
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6224
|
+
|
|
6225
|
+
interface MCPLoggingAdapter {
|
|
6226
|
+
setLevel?(level: string): Promise<void> | void;
|
|
6227
|
+
getLevel?(): Promise<string | undefined> | string | undefined;
|
|
6228
|
+
}
|
|
6229
|
+
interface MCPPromptsAdapter {
|
|
6230
|
+
listPrompts(): Promise<unknown[]>;
|
|
6231
|
+
getPrompt(params: unknown): Promise<unknown>;
|
|
6232
|
+
}
|
|
6233
|
+
interface MCPResourcesAdapter {
|
|
6234
|
+
listResources(): Promise<unknown>;
|
|
6235
|
+
readResource(uri: string): Promise<unknown>;
|
|
6236
|
+
listResourceTemplates?(): Promise<unknown>;
|
|
6237
|
+
subscribe?(params: unknown, headers?: Record<string, string>): Promise<void> | void;
|
|
6238
|
+
unsubscribe?(params: unknown): Promise<void> | void;
|
|
6239
|
+
}
|
|
6240
|
+
interface MCPElicitationAdapter {
|
|
6241
|
+
sendRequest(request: unknown): Promise<unknown>;
|
|
6242
|
+
}
|
|
6243
|
+
|
|
6433
6244
|
/**
|
|
6434
|
-
*
|
|
6245
|
+
* Server provider interface
|
|
6435
6246
|
*/
|
|
6436
|
-
interface
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
* Emitted when the client disconnects from the server
|
|
6443
|
-
*/
|
|
6444
|
-
disconnect: () => void;
|
|
6445
|
-
/**
|
|
6446
|
-
* Emitted when an error occurs
|
|
6447
|
-
*/
|
|
6448
|
-
error: (error: Error | TransportError) => void;
|
|
6449
|
-
/**
|
|
6450
|
-
* Emitted when a tool call completes
|
|
6451
|
-
*/
|
|
6452
|
-
toolCall: (name: string, args: Record<string, unknown>, result: unknown) => void;
|
|
6247
|
+
interface IServerProvider {
|
|
6248
|
+
start(): Promise<{
|
|
6249
|
+
port: number;
|
|
6250
|
+
}>;
|
|
6251
|
+
stop(): Promise<void>;
|
|
6252
|
+
isRunning(): boolean;
|
|
6453
6253
|
}
|
|
6454
6254
|
/**
|
|
6455
|
-
*
|
|
6255
|
+
* Server provider dependencies
|
|
6456
6256
|
*/
|
|
6457
|
-
|
|
6257
|
+
interface ServerProviderDeps {
|
|
6258
|
+
agentRegistry: {
|
|
6259
|
+
getAgent(id: string): Agent | undefined;
|
|
6260
|
+
getAllAgents(): Agent[];
|
|
6261
|
+
getAgentCount(): number;
|
|
6262
|
+
removeAgent(id: string): boolean;
|
|
6263
|
+
registerAgent(agent: Agent): void;
|
|
6264
|
+
getGlobalVoltOpsClient(): VoltOpsClient | undefined;
|
|
6265
|
+
getGlobalLogger(): Logger | undefined;
|
|
6266
|
+
};
|
|
6267
|
+
workflowRegistry: {
|
|
6268
|
+
getWorkflow(id: string): RegisteredWorkflow | undefined;
|
|
6269
|
+
getWorkflowsForApi(): unknown[];
|
|
6270
|
+
getWorkflowDetailForApi(id: string): unknown;
|
|
6271
|
+
getWorkflowCount(): number;
|
|
6272
|
+
on(event: string, handler: (...args: any[]) => void): void;
|
|
6273
|
+
off(event: string, handler: (...args: any[]) => void): void;
|
|
6274
|
+
activeExecutions: Map<string, WorkflowSuspendController>;
|
|
6275
|
+
resumeSuspendedWorkflow(workflowId: string, executionId: string, resumeData?: any, stepId?: string): Promise<any>;
|
|
6276
|
+
};
|
|
6277
|
+
logger?: Logger;
|
|
6278
|
+
voltOpsClient?: VoltOpsClient;
|
|
6279
|
+
observability?: VoltAgentObservability;
|
|
6280
|
+
mcp?: {
|
|
6281
|
+
registry: MCPServerRegistry;
|
|
6282
|
+
};
|
|
6283
|
+
a2a?: {
|
|
6284
|
+
registry: A2AServerRegistry;
|
|
6285
|
+
};
|
|
6286
|
+
}
|
|
6458
6287
|
/**
|
|
6459
|
-
*
|
|
6288
|
+
* Server provider factory type
|
|
6460
6289
|
*/
|
|
6461
|
-
type
|
|
6462
|
-
/**
|
|
6463
|
-
* Converts the toolset to an array of BaseTool objects.
|
|
6464
|
-
*/
|
|
6465
|
-
getTools: () => Tool<any>[];
|
|
6466
|
-
};
|
|
6290
|
+
type ServerProviderFactory = (deps: ServerProviderDeps) => IServerProvider;
|
|
6467
6291
|
/**
|
|
6468
|
-
*
|
|
6292
|
+
* Server API response types
|
|
6469
6293
|
*/
|
|
6470
|
-
|
|
6471
|
-
|
|
6294
|
+
interface ServerAgentResponse {
|
|
6295
|
+
id: string;
|
|
6296
|
+
name: string;
|
|
6297
|
+
description: string;
|
|
6298
|
+
status: AgentStatus;
|
|
6299
|
+
model: string;
|
|
6300
|
+
tools: ToolStatusInfo[];
|
|
6301
|
+
memory?: Record<string, unknown>;
|
|
6302
|
+
subAgents?: ServerAgentResponse[];
|
|
6303
|
+
isTelemetryEnabled?: boolean;
|
|
6304
|
+
}
|
|
6305
|
+
interface ServerWorkflowResponse {
|
|
6306
|
+
id: string;
|
|
6307
|
+
name: string;
|
|
6308
|
+
purpose: string;
|
|
6309
|
+
stepsCount: number;
|
|
6310
|
+
status: "idle" | "running" | "completed" | "error";
|
|
6311
|
+
steps: Array<{
|
|
6312
|
+
id: string;
|
|
6313
|
+
name: string;
|
|
6314
|
+
purpose: string | null;
|
|
6315
|
+
type: string;
|
|
6316
|
+
agentId?: string;
|
|
6317
|
+
agentName?: string;
|
|
6318
|
+
}>;
|
|
6319
|
+
}
|
|
6320
|
+
interface ServerApiResponse<T> {
|
|
6321
|
+
success: boolean;
|
|
6322
|
+
data?: T;
|
|
6323
|
+
error?: string;
|
|
6324
|
+
}
|
|
6472
6325
|
/**
|
|
6473
|
-
*
|
|
6474
|
-
* Wraps the official MCP SDK client to provide a higher-level interface.
|
|
6475
|
-
* Internal implementation differs from original source.
|
|
6326
|
+
* VoltAgent constructor options
|
|
6476
6327
|
*/
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
* Underlying MCP client instance from the SDK.
|
|
6480
|
-
*/
|
|
6481
|
-
private client;
|
|
6482
|
-
/**
|
|
6483
|
-
* Communication channel (transport layer) for MCP interactions.
|
|
6484
|
-
*/
|
|
6485
|
-
private transport;
|
|
6486
|
-
/**
|
|
6487
|
-
* Tracks the connection status to the server.
|
|
6488
|
-
*/
|
|
6489
|
-
private connected;
|
|
6490
|
-
/**
|
|
6491
|
-
* Maximum time allowed for requests in milliseconds.
|
|
6492
|
-
*/
|
|
6493
|
-
private readonly timeout;
|
|
6494
|
-
/**
|
|
6495
|
-
* Logger instance
|
|
6496
|
-
*/
|
|
6497
|
-
private logger;
|
|
6328
|
+
type VoltAgentOptions = {
|
|
6329
|
+
agents: Record<string, Agent>;
|
|
6498
6330
|
/**
|
|
6499
|
-
*
|
|
6331
|
+
* Optional workflows to register with VoltAgent
|
|
6332
|
+
* Can be either Workflow instances or WorkflowChain instances
|
|
6500
6333
|
*/
|
|
6501
|
-
|
|
6334
|
+
workflows?: Record<string, Workflow<DangerouslyAllowAny, DangerouslyAllowAny, DangerouslyAllowAny, DangerouslyAllowAny> | WorkflowChain<DangerouslyAllowAny, DangerouslyAllowAny, DangerouslyAllowAny, DangerouslyAllowAny, DangerouslyAllowAny>>;
|
|
6502
6335
|
/**
|
|
6503
|
-
* Server
|
|
6336
|
+
* Server provider factory function
|
|
6337
|
+
* Example: honoServer({ port: 3141, enableSwaggerUI: true })
|
|
6504
6338
|
*/
|
|
6505
|
-
|
|
6339
|
+
server?: ServerProviderFactory;
|
|
6506
6340
|
/**
|
|
6507
|
-
*
|
|
6341
|
+
* Unified VoltOps client for telemetry and prompt management
|
|
6342
|
+
* Replaces the old telemetryExporter approach with a comprehensive solution.
|
|
6508
6343
|
*/
|
|
6509
|
-
|
|
6344
|
+
voltOpsClient?: VoltOpsClient;
|
|
6510
6345
|
/**
|
|
6511
|
-
*
|
|
6346
|
+
* Observability instance for OpenTelemetry-compliant tracing
|
|
6347
|
+
* Allows sharing the same observability instance between VoltAgent and Agents
|
|
6348
|
+
* If not provided, creates a default instance with in-memory storage
|
|
6512
6349
|
*/
|
|
6513
|
-
|
|
6350
|
+
observability?: VoltAgentObservability;
|
|
6514
6351
|
/**
|
|
6515
|
-
*
|
|
6352
|
+
* Global logger instance to use across all agents and workflows
|
|
6353
|
+
* If not provided, a default logger will be created
|
|
6516
6354
|
*/
|
|
6517
|
-
|
|
6355
|
+
logger?: Logger;
|
|
6518
6356
|
/**
|
|
6519
|
-
*
|
|
6520
|
-
*
|
|
6357
|
+
* Optional collection of MCP servers to register alongside the primary server.
|
|
6358
|
+
* Enables exposing multiple VoltAgent surfaces through separate MCP endpoints.
|
|
6521
6359
|
*/
|
|
6522
|
-
|
|
6360
|
+
mcpServers?: Record<string, MCPServerLike | MCPServerFactory>;
|
|
6523
6361
|
/**
|
|
6524
|
-
*
|
|
6362
|
+
* Optional collection of A2A servers to expose agents via the Agent-to-Agent protocol.
|
|
6525
6363
|
*/
|
|
6526
|
-
|
|
6364
|
+
a2aServers?: Record<string, A2AServerLike | A2AServerFactory>;
|
|
6527
6365
|
/**
|
|
6528
|
-
*
|
|
6529
|
-
* Idempotent: does nothing if already connected.
|
|
6366
|
+
* @deprecated Use `server.port` instead
|
|
6530
6367
|
*/
|
|
6531
|
-
|
|
6368
|
+
port?: number;
|
|
6532
6369
|
/**
|
|
6533
|
-
*
|
|
6534
|
-
* @param originalError The error from the initial connection attempt.
|
|
6370
|
+
* @deprecated Use `server.autoStart` instead
|
|
6535
6371
|
*/
|
|
6536
|
-
|
|
6372
|
+
autoStart?: boolean;
|
|
6373
|
+
checkDependencies?: boolean;
|
|
6537
6374
|
/**
|
|
6538
|
-
*
|
|
6539
|
-
* Idempotent: does nothing if not connected.
|
|
6375
|
+
* @deprecated Server configuration is now done through server provider
|
|
6540
6376
|
*/
|
|
6541
|
-
|
|
6377
|
+
customEndpoints?: unknown[];
|
|
6542
6378
|
/**
|
|
6543
|
-
*
|
|
6544
|
-
* @returns A record mapping tool names to their definitions (schema, description).
|
|
6379
|
+
* @deprecated Server configuration is now done through server provider
|
|
6545
6380
|
*/
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
* Type guard to check if a server configuration is for a Stdio server.
|
|
6595
|
-
* @param server The server configuration object.
|
|
6596
|
-
* @returns True if the configuration type is 'stdio', false otherwise.
|
|
6597
|
-
*/
|
|
6598
|
-
private isStdioServer;
|
|
6599
|
-
/**
|
|
6600
|
-
* Overrides EventEmitter's 'on' method for type-safe event listening.
|
|
6601
|
-
* Uses the original `MCPClientEvents` for event types.
|
|
6602
|
-
*/
|
|
6603
|
-
on<E extends keyof MCPClientEvents>(event: E, listener: MCPClientEvents[E]): this;
|
|
6604
|
-
/**
|
|
6605
|
-
* Overrides EventEmitter's 'emit' method for type-safe event emission.
|
|
6606
|
-
* Uses the original `MCPClientEvents` for event types.
|
|
6607
|
-
*/
|
|
6608
|
-
emit<E extends keyof MCPClientEvents>(event: E, ...args: Parameters<MCPClientEvents[E]>): boolean;
|
|
6381
|
+
enableSwaggerUI?: boolean;
|
|
6382
|
+
};
|
|
6383
|
+
|
|
6384
|
+
/**
|
|
6385
|
+
* Prompt management utilities for agent prompt tuning
|
|
6386
|
+
*/
|
|
6387
|
+
type ExtractVariableNames<T extends string> = T extends `${string}{{${infer Param}}}${infer Rest}` ? Param | ExtractVariableNames<Rest> : never;
|
|
6388
|
+
type AllowedVariableValue = string | number | boolean | undefined | null;
|
|
6389
|
+
type TemplateVariables<T extends string> = {
|
|
6390
|
+
[K in ExtractVariableNames<T>]: AllowedVariableValue;
|
|
6391
|
+
};
|
|
6392
|
+
type PromptTemplate<T extends string> = [ExtractVariableNames<T>] extends [never] ? {
|
|
6393
|
+
template: T;
|
|
6394
|
+
variables?: Record<string, never>;
|
|
6395
|
+
} : {
|
|
6396
|
+
template: T;
|
|
6397
|
+
variables: TemplateVariables<T>;
|
|
6398
|
+
};
|
|
6399
|
+
type PromptCreator<T extends string> = (extraVariables?: Partial<TemplateVariables<T>>) => string;
|
|
6400
|
+
/**
|
|
6401
|
+
* Creates a type-safe, customizable prompt function from a template string.
|
|
6402
|
+
* Variable names are automatically inferred from the template `{{variable}}` syntax.
|
|
6403
|
+
*
|
|
6404
|
+
* @param template - The template string with `{{variable}}` placeholders.
|
|
6405
|
+
* @param variables - An object containing the default values for the template variables.
|
|
6406
|
+
* @returns A function that takes optional extra variables and returns the processed prompt string.
|
|
6407
|
+
*/
|
|
6408
|
+
declare const createPrompt: <T extends string>({ template, variables, }: PromptTemplate<T>) => PromptCreator<T>;
|
|
6409
|
+
|
|
6410
|
+
/**
|
|
6411
|
+
* Node types for agents, tools, and other components
|
|
6412
|
+
*/
|
|
6413
|
+
declare enum NodeType {
|
|
6414
|
+
AGENT = "agent",
|
|
6415
|
+
SUBAGENT = "agent",
|
|
6416
|
+
TOOL = "tool",
|
|
6417
|
+
MEMORY = "memory",
|
|
6418
|
+
MESSAGE = "message",
|
|
6419
|
+
OUTPUT = "output",
|
|
6420
|
+
RETRIEVER = "retriever",
|
|
6421
|
+
VECTOR = "vector",
|
|
6422
|
+
EMBEDDING = "embedding",
|
|
6423
|
+
WORKFLOW_STEP = "workflow_step",
|
|
6424
|
+
WORKFLOW_AGENT_STEP = "workflow_agent_step",
|
|
6425
|
+
WORKFLOW_FUNC_STEP = "workflow_func_step",
|
|
6426
|
+
WORKFLOW_CONDITIONAL_STEP = "workflow_conditional_step",
|
|
6427
|
+
WORKFLOW_PARALLEL_ALL_STEP = "workflow_parallel_all_step",
|
|
6428
|
+
WORKFLOW_PARALLEL_RACE_STEP = "workflow_parallel_race_step"
|
|
6609
6429
|
}
|
|
6430
|
+
/**
|
|
6431
|
+
* Standard node ID creation function
|
|
6432
|
+
* @param type Node type
|
|
6433
|
+
* @param name Main identifier (tool name, agent name, etc.)
|
|
6434
|
+
* @param ownerId Owner ID (optional)
|
|
6435
|
+
* @returns Standard formatted node ID
|
|
6436
|
+
*/
|
|
6437
|
+
declare const createNodeId: (type: NodeType, name: string, ownerId?: string) => string;
|
|
6438
|
+
/**
|
|
6439
|
+
* Function to extract node type from NodeID
|
|
6440
|
+
* @param nodeId Node ID
|
|
6441
|
+
* @returns NodeType or null (if type cannot be found)
|
|
6442
|
+
*/
|
|
6443
|
+
declare const getNodeTypeFromNodeId: (nodeId: string) => NodeType | null;
|
|
6444
|
+
/**
|
|
6445
|
+
* Workflow step types enum
|
|
6446
|
+
*/
|
|
6447
|
+
type WorkflowStepType = "agent" | "func" | "conditional-when" | "parallel-all" | "parallel-race";
|
|
6448
|
+
/**
|
|
6449
|
+
* Create a workflow step node ID with consistent pattern
|
|
6450
|
+
* @param stepType Type of workflow step
|
|
6451
|
+
* @param stepIndex Index of step in workflow
|
|
6452
|
+
* @param workflowId Workflow identifier
|
|
6453
|
+
* @param options Additional options for node ID generation
|
|
6454
|
+
* @returns Consistent workflow step node ID
|
|
6455
|
+
*/
|
|
6456
|
+
declare const createWorkflowStepNodeId: (stepType: WorkflowStepType, stepIndex: number, workflowId: string, options?: {
|
|
6457
|
+
agentId?: string;
|
|
6458
|
+
parallelIndex?: number;
|
|
6459
|
+
stepName?: string;
|
|
6460
|
+
stepId?: string;
|
|
6461
|
+
}) => string;
|
|
6462
|
+
/**
|
|
6463
|
+
* Get NodeType for workflow step type
|
|
6464
|
+
* @param stepType Workflow step type
|
|
6465
|
+
* @returns Corresponding NodeType
|
|
6466
|
+
*/
|
|
6467
|
+
declare const getWorkflowStepNodeType: (stepType: WorkflowStepType) => NodeType;
|
|
6468
|
+
/**
|
|
6469
|
+
* Extract workflow step information from node ID
|
|
6470
|
+
* @param nodeId Workflow step node ID
|
|
6471
|
+
* @returns Extracted workflow step info or null
|
|
6472
|
+
*/
|
|
6473
|
+
declare const extractWorkflowStepInfo: (nodeId: string) => {
|
|
6474
|
+
stepType: WorkflowStepType;
|
|
6475
|
+
stepIndex: number;
|
|
6476
|
+
workflowId: string;
|
|
6477
|
+
agentId?: string;
|
|
6478
|
+
parallelIndex?: number;
|
|
6479
|
+
stepName?: string;
|
|
6480
|
+
} | null;
|
|
6610
6481
|
|
|
6611
6482
|
/**
|
|
6612
|
-
*
|
|
6613
|
-
* Handles multiple MCP server connections and tool management.
|
|
6614
|
-
* NOTE: This version does NOT manage singleton instances automatically.
|
|
6483
|
+
* Tool call interface
|
|
6615
6484
|
*/
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6485
|
+
interface ToolCall {
|
|
6486
|
+
id: string;
|
|
6487
|
+
type: "function";
|
|
6488
|
+
function: {
|
|
6489
|
+
name: string;
|
|
6490
|
+
arguments: string;
|
|
6491
|
+
};
|
|
6492
|
+
}
|
|
6493
|
+
/**
|
|
6494
|
+
* Converts a Zod-like schema to a JSON representation usable in the UI
|
|
6495
|
+
* @param schema Any Zod schema object
|
|
6496
|
+
* @returns A JSON Schema compatible representation of the Zod schema
|
|
6497
|
+
*/
|
|
6498
|
+
declare function zodSchemaToJsonUI(schema: any): any;
|
|
6499
|
+
|
|
6500
|
+
type UpdateOptions = {
|
|
6501
|
+
filter?: string;
|
|
6502
|
+
useCache?: boolean;
|
|
6503
|
+
forceRefresh?: boolean;
|
|
6504
|
+
};
|
|
6505
|
+
/**
|
|
6506
|
+
* Package update info with semver details
|
|
6507
|
+
*/
|
|
6508
|
+
type PackageUpdateInfo = {
|
|
6509
|
+
name: string;
|
|
6510
|
+
installed: string;
|
|
6511
|
+
latest: string;
|
|
6512
|
+
type: "major" | "minor" | "patch" | "latest";
|
|
6513
|
+
packageJson: string;
|
|
6514
|
+
};
|
|
6515
|
+
/**
|
|
6516
|
+
* Checks for dependency updates using native package manager commands
|
|
6517
|
+
* @returns Object containing update information
|
|
6518
|
+
*/
|
|
6519
|
+
declare const checkForUpdates: (packagePath?: string, options?: UpdateOptions) => Promise<{
|
|
6520
|
+
hasUpdates: boolean;
|
|
6521
|
+
updates: PackageUpdateInfo[];
|
|
6522
|
+
count: number;
|
|
6523
|
+
message: string;
|
|
6524
|
+
}>;
|
|
6525
|
+
/**
|
|
6526
|
+
* Update all packages that have available updates using native package manager
|
|
6527
|
+
* @param packagePath Optional path to package.json, uses current directory if not provided
|
|
6528
|
+
* @returns Result of the update operation
|
|
6529
|
+
*/
|
|
6530
|
+
declare const updateAllPackages: (packagePath?: string) => Promise<{
|
|
6531
|
+
success: boolean;
|
|
6532
|
+
message: string;
|
|
6533
|
+
updatedPackages?: string[];
|
|
6534
|
+
requiresRestart?: boolean;
|
|
6535
|
+
}>;
|
|
6536
|
+
/**
|
|
6537
|
+
* Update a single package to its latest version using native package manager
|
|
6538
|
+
* @param packageName Name of the package to update
|
|
6539
|
+
* @param packagePath Optional path to package.json, uses current directory if not provided
|
|
6540
|
+
* @returns Result of the update operation
|
|
6541
|
+
*/
|
|
6542
|
+
declare const updateSinglePackage: (packageName: string, packagePath?: string) => Promise<{
|
|
6543
|
+
success: boolean;
|
|
6544
|
+
message: string;
|
|
6545
|
+
packageName: string;
|
|
6546
|
+
requiresRestart?: boolean;
|
|
6547
|
+
}>;
|
|
6548
|
+
|
|
6549
|
+
/**
|
|
6550
|
+
* Safely parse JSON string. If parsing fails, returns the original value.
|
|
6551
|
+
* @param value String to parse as JSON
|
|
6552
|
+
* @returns Parsed JSON object or original value if parsing fails
|
|
6553
|
+
*/
|
|
6554
|
+
declare function safeJsonParse(value: string | null | undefined): any;
|
|
6555
|
+
declare function serializeValueForDebug(value: unknown): unknown;
|
|
6556
|
+
|
|
6557
|
+
/**
|
|
6558
|
+
* Type guard to check if content is a string
|
|
6559
|
+
*/
|
|
6560
|
+
declare function isTextContent(content: MessageContent): content is string;
|
|
6561
|
+
/**
|
|
6562
|
+
* Type guard to check if content is structured (array of content parts)
|
|
6563
|
+
*/
|
|
6564
|
+
declare function isStructuredContent(content: MessageContent): content is Array<any>;
|
|
6565
|
+
/**
|
|
6566
|
+
* Check if content has any text parts
|
|
6567
|
+
*/
|
|
6568
|
+
declare function hasTextPart(content: MessageContent): boolean;
|
|
6569
|
+
/**
|
|
6570
|
+
* Check if content has any image parts
|
|
6571
|
+
*/
|
|
6572
|
+
declare function hasImagePart(content: MessageContent): boolean;
|
|
6573
|
+
/**
|
|
6574
|
+
* Check if content has any file parts
|
|
6575
|
+
*/
|
|
6576
|
+
declare function hasFilePart(content: MessageContent): boolean;
|
|
6577
|
+
/**
|
|
6578
|
+
* Extract text from message content
|
|
6579
|
+
*/
|
|
6580
|
+
declare function extractText(content: MessageContent): string;
|
|
6581
|
+
/**
|
|
6582
|
+
* Extract all text parts from structured content
|
|
6583
|
+
*/
|
|
6584
|
+
declare function extractTextParts(content: MessageContent): Array<{
|
|
6585
|
+
type: "text";
|
|
6586
|
+
text: string;
|
|
6587
|
+
}>;
|
|
6588
|
+
/**
|
|
6589
|
+
* Extract image parts from message content
|
|
6590
|
+
*/
|
|
6591
|
+
declare function extractImageParts(content: MessageContent): Array<any>;
|
|
6592
|
+
/**
|
|
6593
|
+
* Extract file parts from message content
|
|
6594
|
+
*/
|
|
6595
|
+
declare function extractFileParts(content: MessageContent): Array<any>;
|
|
6596
|
+
/**
|
|
6597
|
+
* Transform text content in a message
|
|
6598
|
+
*/
|
|
6599
|
+
declare function transformTextContent(content: MessageContent, transformer: (text: string) => string): MessageContent;
|
|
6600
|
+
/**
|
|
6601
|
+
* Map UIMessage text parts with a transformer function
|
|
6602
|
+
*/
|
|
6603
|
+
declare function mapMessageContent(message: UIMessage, transformer: (text: string) => string): UIMessage;
|
|
6604
|
+
/**
|
|
6605
|
+
* Filter content parts by type
|
|
6606
|
+
*/
|
|
6607
|
+
declare function filterContentParts(content: MessageContent, predicate: (part: any) => boolean): MessageContent;
|
|
6608
|
+
/**
|
|
6609
|
+
* Normalize content to always be an array
|
|
6610
|
+
*/
|
|
6611
|
+
declare function normalizeToArray(content: MessageContent): Array<any>;
|
|
6612
|
+
/**
|
|
6613
|
+
* Normalize content to the most compact form
|
|
6614
|
+
*/
|
|
6615
|
+
declare function normalizeContent(content: MessageContent): MessageContent;
|
|
6616
|
+
/**
|
|
6617
|
+
* Builder class for creating message content
|
|
6618
|
+
*/
|
|
6619
|
+
declare class MessageContentBuilder {
|
|
6620
|
+
private parts;
|
|
6636
6621
|
/**
|
|
6637
|
-
*
|
|
6622
|
+
* Add a text part
|
|
6638
6623
|
*/
|
|
6639
|
-
|
|
6624
|
+
addText(text: string): this;
|
|
6640
6625
|
/**
|
|
6641
|
-
*
|
|
6642
|
-
* @returns A flat array of all agent-ready tools.
|
|
6626
|
+
* Add an image part
|
|
6643
6627
|
*/
|
|
6644
|
-
|
|
6628
|
+
addImage(image: string | Uint8Array): this;
|
|
6645
6629
|
/**
|
|
6646
|
-
*
|
|
6647
|
-
* @returns A flat record of all raw tools keyed by their namespaced name.
|
|
6630
|
+
* Add a file part
|
|
6648
6631
|
*/
|
|
6649
|
-
|
|
6632
|
+
addFile(file: string | Uint8Array, mimeType?: string): this;
|
|
6650
6633
|
/**
|
|
6651
|
-
*
|
|
6652
|
-
* @returns A record where keys are server names and values are agent-ready toolsets.
|
|
6634
|
+
* Add a custom part
|
|
6653
6635
|
*/
|
|
6654
|
-
|
|
6636
|
+
addPart(part: any): this;
|
|
6655
6637
|
/**
|
|
6656
|
-
*
|
|
6657
|
-
* @returns A record where keys are server names and values are records of raw tools.
|
|
6638
|
+
* Build the final content
|
|
6658
6639
|
*/
|
|
6659
|
-
|
|
6640
|
+
build(): MessageContent;
|
|
6660
6641
|
/**
|
|
6661
|
-
*
|
|
6642
|
+
* Build as array (always returns array)
|
|
6662
6643
|
*/
|
|
6663
|
-
|
|
6644
|
+
buildAsArray(): Array<any>;
|
|
6664
6645
|
/**
|
|
6665
|
-
*
|
|
6646
|
+
* Clear all parts
|
|
6666
6647
|
*/
|
|
6667
|
-
|
|
6648
|
+
clear(): this;
|
|
6668
6649
|
/**
|
|
6669
|
-
*
|
|
6670
|
-
* Manages the local mcpClientsById cache.
|
|
6650
|
+
* Get current parts count
|
|
6671
6651
|
*/
|
|
6672
|
-
|
|
6652
|
+
get length(): number;
|
|
6673
6653
|
}
|
|
6654
|
+
/**
|
|
6655
|
+
* Convenience function to add timestamp to user messages (UIMessage only)
|
|
6656
|
+
*/
|
|
6657
|
+
declare function addTimestampToMessage(message: UIMessage, timestamp?: string): UIMessage;
|
|
6658
|
+
/**
|
|
6659
|
+
* Convenience function to prepend text to UIMessage text parts
|
|
6660
|
+
*/
|
|
6661
|
+
declare function prependToMessage(message: UIMessage, prefix: string): UIMessage;
|
|
6662
|
+
/**
|
|
6663
|
+
* Convenience function to append text to UIMessage text parts
|
|
6664
|
+
*/
|
|
6665
|
+
declare function appendToMessage(message: UIMessage, suffix: string): UIMessage;
|
|
6666
|
+
/**
|
|
6667
|
+
* Check if UIMessage has any content
|
|
6668
|
+
*/
|
|
6669
|
+
declare function hasContent(message: UIMessage): boolean;
|
|
6670
|
+
/**
|
|
6671
|
+
* Get content length (text characters or array items)
|
|
6672
|
+
*/
|
|
6673
|
+
declare function getContentLength(content: MessageContent): number;
|
|
6674
|
+
/**
|
|
6675
|
+
* Combined message helpers object for easy importing
|
|
6676
|
+
*/
|
|
6677
|
+
declare const messageHelpers: {
|
|
6678
|
+
isTextContent: typeof isTextContent;
|
|
6679
|
+
isStructuredContent: typeof isStructuredContent;
|
|
6680
|
+
hasTextPart: typeof hasTextPart;
|
|
6681
|
+
hasImagePart: typeof hasImagePart;
|
|
6682
|
+
hasFilePart: typeof hasFilePart;
|
|
6683
|
+
extractText: typeof extractText;
|
|
6684
|
+
extractTextParts: typeof extractTextParts;
|
|
6685
|
+
extractImageParts: typeof extractImageParts;
|
|
6686
|
+
extractFileParts: typeof extractFileParts;
|
|
6687
|
+
transformTextContent: typeof transformTextContent;
|
|
6688
|
+
mapMessageContent: typeof mapMessageContent;
|
|
6689
|
+
filterContentParts: typeof filterContentParts;
|
|
6690
|
+
normalizeToArray: typeof normalizeToArray;
|
|
6691
|
+
normalizeContent: typeof normalizeContent;
|
|
6692
|
+
addTimestampToMessage: typeof addTimestampToMessage;
|
|
6693
|
+
prependToMessage: typeof prependToMessage;
|
|
6694
|
+
appendToMessage: typeof appendToMessage;
|
|
6695
|
+
hasContent: typeof hasContent;
|
|
6696
|
+
getContentLength: typeof getContentLength;
|
|
6697
|
+
MessageContentBuilder: typeof MessageContentBuilder;
|
|
6698
|
+
};
|
|
6699
|
+
|
|
6700
|
+
/**
|
|
6701
|
+
* Creates an AgentTool from a retriever, allowing it to be used as a tool in an agent.
|
|
6702
|
+
* This is the preferred way to use a retriever as a tool, as it properly maintains the 'this' context.
|
|
6703
|
+
*
|
|
6704
|
+
* @param retriever - The retriever instance to convert to a tool
|
|
6705
|
+
* @param options - Options for customizing the tool
|
|
6706
|
+
* @returns An AgentTool that can be added to an agent's tools
|
|
6707
|
+
*
|
|
6708
|
+
* @example
|
|
6709
|
+
* ```typescript
|
|
6710
|
+
* const retriever = new SimpleRetriever();
|
|
6711
|
+
* const searchTool = createRetrieverTool(retriever, {
|
|
6712
|
+
* name: "search_knowledge",
|
|
6713
|
+
* description: "Searches the knowledge base for information"
|
|
6714
|
+
* });
|
|
6715
|
+
*
|
|
6716
|
+
* agent.addTool(searchTool);
|
|
6717
|
+
* ```
|
|
6718
|
+
*/
|
|
6719
|
+
declare const createRetrieverTool: (retriever: Retriever, options?: {
|
|
6720
|
+
name?: string;
|
|
6721
|
+
description?: string;
|
|
6722
|
+
}) => AgentTool;
|
|
6674
6723
|
|
|
6675
6724
|
/**
|
|
6676
6725
|
* Registry to manage and track agents
|
|
@@ -6894,6 +6943,10 @@ declare class VoltAgent {
|
|
|
6894
6943
|
private serverInstance?;
|
|
6895
6944
|
private logger;
|
|
6896
6945
|
private observability?;
|
|
6946
|
+
private readonly mcpServers;
|
|
6947
|
+
private readonly mcpServerRegistry;
|
|
6948
|
+
private readonly a2aServers;
|
|
6949
|
+
private readonly a2aServerRegistry;
|
|
6897
6950
|
constructor(options: VoltAgentOptions);
|
|
6898
6951
|
/**
|
|
6899
6952
|
* Setup graceful shutdown handlers
|
|
@@ -6966,6 +7019,14 @@ declare class VoltAgent {
|
|
|
6966
7019
|
* Useful for programmatic cleanup or when integrating with other frameworks
|
|
6967
7020
|
*/
|
|
6968
7021
|
shutdown(): Promise<void>;
|
|
7022
|
+
private initializeMCPServer;
|
|
7023
|
+
private initializeA2AServer;
|
|
7024
|
+
private startConfiguredMcpTransports;
|
|
7025
|
+
getMCPDependencies(): MCPServerDeps;
|
|
7026
|
+
private getA2ADependencies;
|
|
7027
|
+
getServerInstance(): IServerProvider | undefined;
|
|
7028
|
+
private shutdownMcpServers;
|
|
7029
|
+
private shutdownA2AServers;
|
|
6969
7030
|
}
|
|
6970
7031
|
|
|
6971
7032
|
/**
|
|
@@ -6979,4 +7040,4 @@ declare class VoltAgent {
|
|
|
6979
7040
|
*/
|
|
6980
7041
|
declare function convertUsage(usage: LanguageModelUsage | undefined): UsageInfo | undefined;
|
|
6981
7042
|
|
|
6982
|
-
export { 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
|
|
7043
|
+
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 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 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, LocalStorageSpanProcessor, type LogFilter, LoggerProxy, MCPConfiguration, type MCPElicitationAdapter, type MCPLoggingAdapter, type MCPPromptsAdapter, type MCPResourcesAdapter, MCPServerRegistry, Memory, type MemoryConfig, type MemoryOptions, Memory as MemoryV2, MemoryV2Error, type MessageContent, MessageContentBuilder, type MessageRole, type ModelToolCall, NextAction, NodeType, 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 RetrieveOptions, type Retriever, type RetrieverOptions, type SearchOptions, type SearchResult, type ServerAgentResponse, type ServerApiResponse, type ServerProviderDeps, type ServerProviderFactory, type ServerWorkflowResponse, type SpanAttributes, type SpanEvent, SpanKind, type SpanLink, type SpanStatus, SpanStatusCode, type SpanTreeNode, type StepChunkCallback, type StepFinishCallback, type StepWithContent, type StopWhen, type StorageAdapter, StorageError, 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, addTimestampToMessage, andAgent, andAll, andRace, andTap, andThen, andWhen, andWorkflow, appendToMessage, buildRetrieverLogMessage, buildSpanTree, checkForUpdates, convertUsage, cosineSimilarity, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createSimpleTemplateEngine, createSubagent, createSuspendController, createTool, createToolkit, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, extractFileParts, extractImageParts, extractText, extractTextParts, extractWorkflowStepInfo, filterContentParts, getContentLength, getGlobalLogBuffer, getGlobalLogger, getNodeTypeFromNodeId, getWorkflowStepNodeType, hasContent, hasFilePart, hasImagePart, hasTextPart, isAbortError, isStructuredContent, isTextContent, isVoltAgentError, mapMessageContent, messageHelpers, normalizeContent, normalizeToArray, prependToMessage, readableSpanToObservabilitySpan, safeJsonParse, serializeValueForDebug, tool, transformTextContent, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
|