@voltagent/core 0.1.47 → 0.1.49
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/README.md +1 -1
- package/dist/index.d.ts +505 -28
- package/dist/index.js +4774 -4085
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4780 -4096
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -128,7 +128,7 @@ VOLTAGENT SERVER STARTED SUCCESSFULLY
|
|
|
128
128
|
══════════════════════════════════════════════════
|
|
129
129
|
✓ HTTP Server: http://localhost:3141
|
|
130
130
|
|
|
131
|
-
VoltOps
|
|
131
|
+
Test your agents with VoltOps Console: https://console.voltagent.dev
|
|
132
132
|
══════════════════════════════════════════════════
|
|
133
133
|
```
|
|
134
134
|
|
package/dist/index.d.ts
CHANGED
|
@@ -808,16 +808,245 @@ declare function streamEventForwarder(event: StreamEvent, options: StreamEventFo
|
|
|
808
808
|
declare function createStreamEventForwarder(options: StreamEventForwarderOptions): (event: StreamEvent) => Promise<void>;
|
|
809
809
|
|
|
810
810
|
/**
|
|
811
|
-
*
|
|
811
|
+
* VoltOps Client Type Definitions
|
|
812
|
+
*
|
|
813
|
+
* All types related to VoltOps client functionality including
|
|
814
|
+
* prompt management, telemetry, and API interactions.
|
|
815
|
+
*/
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Reference to a prompt in the VoltOps system
|
|
819
|
+
*/
|
|
820
|
+
type PromptReference = {
|
|
821
|
+
/** Name of the prompt */
|
|
822
|
+
promptName: string;
|
|
823
|
+
/** Specific version number (takes precedence over label) */
|
|
824
|
+
version?: number;
|
|
825
|
+
/** Label to fetch (e.g., 'latest', 'production', 'staging') */
|
|
826
|
+
label?: string;
|
|
827
|
+
/** Variables to substitute in the template */
|
|
828
|
+
variables?: Record<string, any>;
|
|
829
|
+
/** Per-prompt cache configuration (overrides global settings) */
|
|
830
|
+
promptCache?: {
|
|
831
|
+
enabled?: boolean;
|
|
832
|
+
ttl?: number;
|
|
833
|
+
maxSize?: number;
|
|
834
|
+
};
|
|
835
|
+
};
|
|
836
|
+
/**
|
|
837
|
+
* Helper interface for prompt operations in agent instructions
|
|
812
838
|
*/
|
|
813
|
-
type
|
|
814
|
-
/**
|
|
839
|
+
type PromptHelper = {
|
|
840
|
+
/** Get prompt content by reference */
|
|
841
|
+
getPrompt: (reference: PromptReference) => Promise<PromptContent>;
|
|
842
|
+
};
|
|
843
|
+
/**
|
|
844
|
+
* Enhanced dynamic value options with prompts support
|
|
845
|
+
*/
|
|
846
|
+
interface DynamicValueOptions {
|
|
847
|
+
/** User context map */
|
|
815
848
|
userContext: Map<string | symbol, unknown>;
|
|
849
|
+
/** Prompt helper (available when VoltOpsClient is configured) */
|
|
850
|
+
prompts: PromptHelper;
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* Dynamic value type for agent configuration
|
|
854
|
+
*/
|
|
855
|
+
type DynamicValue<T> = (options: DynamicValueOptions) => Promise<T> | T;
|
|
856
|
+
/**
|
|
857
|
+
* VoltOps client configuration options
|
|
858
|
+
*/
|
|
859
|
+
type VoltOpsClientOptions = {
|
|
860
|
+
/** Base URL of the VoltOps API (default: https://api.voltagent.dev) */
|
|
861
|
+
baseUrl?: string;
|
|
862
|
+
/**
|
|
863
|
+
* Public API key for VoltOps authentication
|
|
864
|
+
*
|
|
865
|
+
* @description Your VoltOps public key used for API authentication and prompt management.
|
|
866
|
+
* This key is safe to use in client-side applications as it only provides read access.
|
|
867
|
+
*
|
|
868
|
+
* @format Should start with `pk_` prefix (e.g., `pk_1234567890abcdef`)
|
|
869
|
+
*
|
|
870
|
+
* @example
|
|
871
|
+
* ```typescript
|
|
872
|
+
* publicKey: process.env.VOLTOPS_PUBLIC_KEY
|
|
873
|
+
* ```
|
|
874
|
+
*
|
|
875
|
+
*
|
|
876
|
+
* @obtain Get your API keys from: https://console.voltagent.dev/settings/projects
|
|
877
|
+
*/
|
|
878
|
+
publicKey?: string;
|
|
879
|
+
/**
|
|
880
|
+
* Secret API key for VoltOps authentication
|
|
881
|
+
*
|
|
882
|
+
* @description Your VoltOps secret key used for secure API operations and analytics.
|
|
883
|
+
* This key provides full access to your VoltOps project and should be kept secure.
|
|
884
|
+
*
|
|
885
|
+
* @format Should start with `sk_` prefix (e.g., `sk_abcdef1234567890`)
|
|
886
|
+
*
|
|
887
|
+
* @example
|
|
888
|
+
* ```typescript
|
|
889
|
+
* secretKey: process.env.VOLTOPS_SECRET_KEY
|
|
890
|
+
* ```
|
|
891
|
+
*
|
|
892
|
+
*
|
|
893
|
+
* @obtain Get your API keys from: https://console.voltagent.dev/settings/projects
|
|
894
|
+
*/
|
|
895
|
+
secretKey?: string;
|
|
896
|
+
/** Custom fetch implementation (optional) */
|
|
897
|
+
fetch?: typeof fetch;
|
|
898
|
+
/** Enable observability export (default: true) */
|
|
899
|
+
observability?: boolean;
|
|
900
|
+
/** Enable prompt management (default: true) */
|
|
901
|
+
prompts?: boolean;
|
|
902
|
+
/** Optional configuration for prompt caching */
|
|
903
|
+
promptCache?: {
|
|
904
|
+
enabled?: boolean;
|
|
905
|
+
ttl?: number;
|
|
906
|
+
maxSize?: number;
|
|
907
|
+
};
|
|
816
908
|
};
|
|
817
909
|
/**
|
|
818
|
-
*
|
|
910
|
+
* Cached prompt data for performance optimization
|
|
819
911
|
*/
|
|
820
|
-
type
|
|
912
|
+
type CachedPrompt = {
|
|
913
|
+
/** Prompt content */
|
|
914
|
+
content: string;
|
|
915
|
+
/** When the prompt was fetched */
|
|
916
|
+
fetchedAt: number;
|
|
917
|
+
/** Time to live in milliseconds */
|
|
918
|
+
ttl: number;
|
|
919
|
+
};
|
|
920
|
+
/**
|
|
921
|
+
* API response for prompt fetch operations
|
|
922
|
+
* Simplified format matching the desired response structure
|
|
923
|
+
*/
|
|
924
|
+
type PromptApiResponse = {
|
|
925
|
+
/** Prompt name */
|
|
926
|
+
name: string;
|
|
927
|
+
/** Prompt type */
|
|
928
|
+
type: "text" | "chat";
|
|
929
|
+
/** Prompt content object */
|
|
930
|
+
prompt: PromptContent;
|
|
931
|
+
/** LLM configuration */
|
|
932
|
+
config: {
|
|
933
|
+
model?: string;
|
|
934
|
+
temperature?: number;
|
|
935
|
+
max_tokens?: number;
|
|
936
|
+
top_p?: number;
|
|
937
|
+
frequency_penalty?: number;
|
|
938
|
+
presence_penalty?: number;
|
|
939
|
+
supported_languages?: string[];
|
|
940
|
+
[key: string]: any;
|
|
941
|
+
};
|
|
942
|
+
/** Prompt version number */
|
|
943
|
+
version: number;
|
|
944
|
+
/** Labels array */
|
|
945
|
+
labels: string[];
|
|
946
|
+
/** Tags array */
|
|
947
|
+
tags: string[];
|
|
948
|
+
/** Base prompt ID for tracking */
|
|
949
|
+
prompt_id: string;
|
|
950
|
+
/** PromptVersion ID (the actual entity ID) */
|
|
951
|
+
prompt_version_id: string;
|
|
952
|
+
};
|
|
953
|
+
/**
|
|
954
|
+
* API client interface for prompt operations
|
|
955
|
+
*/
|
|
956
|
+
interface PromptApiClient {
|
|
957
|
+
/** Fetch a prompt by reference */
|
|
958
|
+
fetchPrompt(reference: PromptReference): Promise<PromptApiResponse>;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* VoltOps prompt manager interface
|
|
962
|
+
*/
|
|
963
|
+
interface VoltOpsPromptManager {
|
|
964
|
+
/** Get prompt content by reference */
|
|
965
|
+
getPrompt(reference: PromptReference): Promise<PromptContent>;
|
|
966
|
+
/** Preload prompts for better performance */
|
|
967
|
+
preload(references: PromptReference[]): Promise<void>;
|
|
968
|
+
/** Clear cache */
|
|
969
|
+
clearCache(): void;
|
|
970
|
+
/** Get cache statistics */
|
|
971
|
+
getCacheStats(): {
|
|
972
|
+
size: number;
|
|
973
|
+
entries: string[];
|
|
974
|
+
};
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Main VoltOps client interface
|
|
978
|
+
*/
|
|
979
|
+
interface VoltOpsClient$1 {
|
|
980
|
+
/** Prompt management functionality */
|
|
981
|
+
prompts?: VoltOpsPromptManager;
|
|
982
|
+
/** Observability exporter (for backward compatibility) */
|
|
983
|
+
observability?: VoltAgentExporter;
|
|
984
|
+
/** Configuration options */
|
|
985
|
+
options: VoltOpsClientOptions & {
|
|
986
|
+
baseUrl: string;
|
|
987
|
+
};
|
|
988
|
+
/** Create a prompt helper for agent instructions */
|
|
989
|
+
createPromptHelper(agentId: string, historyEntryId?: string): PromptHelper;
|
|
990
|
+
/** Backward compatibility methods */
|
|
991
|
+
exportHistoryEntry?: VoltAgentExporter["exportHistoryEntry"];
|
|
992
|
+
exportHistoryEntryAsync?: VoltAgentExporter["exportHistoryEntryAsync"];
|
|
993
|
+
exportTimelineEvent?: VoltAgentExporter["exportTimelineEvent"];
|
|
994
|
+
exportTimelineEventAsync?: VoltAgentExporter["exportTimelineEventAsync"];
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Chat message structure compatible with BaseMessage
|
|
998
|
+
*/
|
|
999
|
+
type ChatMessage = BaseMessage;
|
|
1000
|
+
/**
|
|
1001
|
+
* Content of a prompt - either text or chat messages
|
|
1002
|
+
*/
|
|
1003
|
+
interface PromptContent {
|
|
1004
|
+
type: "text" | "chat";
|
|
1005
|
+
text?: string;
|
|
1006
|
+
messages?: ChatMessage[];
|
|
1007
|
+
/**
|
|
1008
|
+
* Metadata about the prompt from VoltOps API
|
|
1009
|
+
* Available when prompt is fetched from VoltOps
|
|
1010
|
+
*/
|
|
1011
|
+
metadata?: {
|
|
1012
|
+
/** Base prompt ID for tracking */
|
|
1013
|
+
prompt_id?: string;
|
|
1014
|
+
/** Specific PromptVersion ID (critical for analytics) */
|
|
1015
|
+
prompt_version_id?: string;
|
|
1016
|
+
/** Prompt name */
|
|
1017
|
+
name?: string;
|
|
1018
|
+
/** Prompt version number */
|
|
1019
|
+
version?: number;
|
|
1020
|
+
/** Labels array (e.g., 'production', 'staging', 'latest') */
|
|
1021
|
+
labels?: string[];
|
|
1022
|
+
/** Tags array for categorization */
|
|
1023
|
+
tags?: string[];
|
|
1024
|
+
/** LLM configuration from prompt */
|
|
1025
|
+
config?: {
|
|
1026
|
+
model?: string;
|
|
1027
|
+
temperature?: number;
|
|
1028
|
+
max_tokens?: number;
|
|
1029
|
+
top_p?: number;
|
|
1030
|
+
frequency_penalty?: number;
|
|
1031
|
+
presence_penalty?: number;
|
|
1032
|
+
supported_languages?: string[];
|
|
1033
|
+
[key: string]: any;
|
|
1034
|
+
};
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Enhanced dynamic value for instructions that supports prompt management
|
|
1040
|
+
*/
|
|
1041
|
+
type InstructionsDynamicValue = string | DynamicValue<string | PromptContent>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Enhanced dynamic value for models that supports static or dynamic values
|
|
1044
|
+
*/
|
|
1045
|
+
type ModelDynamicValue<T> = T | DynamicValue<T>;
|
|
1046
|
+
/**
|
|
1047
|
+
* Enhanced dynamic value for tools that supports static or dynamic values
|
|
1048
|
+
*/
|
|
1049
|
+
type ToolsDynamicValue = (Tool<any> | Toolkit)[] | DynamicValue<(Tool<any> | Toolkit)[]>;
|
|
821
1050
|
/**
|
|
822
1051
|
* Provider options type for LLM configurations
|
|
823
1052
|
*/
|
|
@@ -868,7 +1097,7 @@ type AgentOptions = {
|
|
|
868
1097
|
* Tools and/or Toolkits that the agent can use
|
|
869
1098
|
* Can be static or dynamic based on user context
|
|
870
1099
|
*/
|
|
871
|
-
tools?:
|
|
1100
|
+
tools?: ToolsDynamicValue;
|
|
872
1101
|
/**
|
|
873
1102
|
* Sub-agents that this agent can delegate tasks to
|
|
874
1103
|
*/
|
|
@@ -878,8 +1107,17 @@ type AgentOptions = {
|
|
|
878
1107
|
*/
|
|
879
1108
|
userContext?: Map<string | symbol, unknown>;
|
|
880
1109
|
/**
|
|
881
|
-
*
|
|
882
|
-
*
|
|
1110
|
+
* @deprecated Use `voltOpsClient` instead. Will be removed in a future version.
|
|
1111
|
+
*
|
|
1112
|
+
* Telemetry exporter for the agent - DEPRECATED
|
|
1113
|
+
*
|
|
1114
|
+
* 🔄 MIGRATION REQUIRED:
|
|
1115
|
+
* ❌ OLD: telemetryExporter: new VoltAgentExporter({ ... })
|
|
1116
|
+
* ✅ NEW: voltOpsClient: new VoltOpsClient({ publicKey: "...", secretKey: "..." })
|
|
1117
|
+
*
|
|
1118
|
+
* 📖 Migration guide: https://voltagent.dev/docs/observability/developer-console/#migration-guide-from-telemetryexporter-to-voltopsclient
|
|
1119
|
+
*
|
|
1120
|
+
* ✨ Benefits: Observability + prompt management + dynamic prompts from console
|
|
883
1121
|
*/
|
|
884
1122
|
telemetryExporter?: VoltAgentExporter;
|
|
885
1123
|
} & ({
|
|
@@ -890,9 +1128,10 @@ type AgentOptions = {
|
|
|
890
1128
|
description: string;
|
|
891
1129
|
/**
|
|
892
1130
|
* Agent instructions. This is the preferred field.
|
|
893
|
-
* Can be static or dynamic based on user context
|
|
1131
|
+
* Can be static or dynamic based on user context.
|
|
1132
|
+
* Enhanced to support prompt management via helper functions.
|
|
894
1133
|
*/
|
|
895
|
-
instructions?:
|
|
1134
|
+
instructions?: InstructionsDynamicValue;
|
|
896
1135
|
} | {
|
|
897
1136
|
/**
|
|
898
1137
|
* @deprecated Use `instructions` instead.
|
|
@@ -902,10 +1141,33 @@ type AgentOptions = {
|
|
|
902
1141
|
/**
|
|
903
1142
|
* Agent instructions. This is the preferred field.
|
|
904
1143
|
* Required if description is not provided.
|
|
905
|
-
* Can be static or dynamic based on user context
|
|
1144
|
+
* Can be static or dynamic based on user context.
|
|
1145
|
+
* Enhanced to support prompt management via helper functions.
|
|
906
1146
|
*/
|
|
907
|
-
instructions:
|
|
1147
|
+
instructions: InstructionsDynamicValue;
|
|
908
1148
|
});
|
|
1149
|
+
/**
|
|
1150
|
+
* System message response with optional prompt metadata
|
|
1151
|
+
*/
|
|
1152
|
+
interface SystemMessageResponse {
|
|
1153
|
+
systemMessages: BaseMessage | BaseMessage[];
|
|
1154
|
+
promptMetadata?: {
|
|
1155
|
+
/** Base prompt ID for tracking */
|
|
1156
|
+
prompt_id?: string;
|
|
1157
|
+
/** PromptVersion ID (the actual entity ID) */
|
|
1158
|
+
prompt_version_id?: string;
|
|
1159
|
+
name?: string;
|
|
1160
|
+
version?: number;
|
|
1161
|
+
labels?: string[];
|
|
1162
|
+
tags?: string[];
|
|
1163
|
+
config?: {
|
|
1164
|
+
model?: string;
|
|
1165
|
+
temperature?: number;
|
|
1166
|
+
[key: string]: any;
|
|
1167
|
+
};
|
|
1168
|
+
};
|
|
1169
|
+
isDynamicInstructions?: boolean;
|
|
1170
|
+
}
|
|
909
1171
|
/**
|
|
910
1172
|
* Provider instance type helper
|
|
911
1173
|
*/
|
|
@@ -1261,6 +1523,26 @@ type InferResponseFromProvider<TProvider extends {
|
|
|
1261
1523
|
type InferOriginalResponseFromProvider<TProvider extends {
|
|
1262
1524
|
llm: LLMProvider<any>;
|
|
1263
1525
|
}, TMethod extends "generateText" | "streamText" | "generateObject" | "streamObject"> = InferResponseFromProvider<TProvider, TMethod>["provider"];
|
|
1526
|
+
type GenerateTextResponse<TProvider extends {
|
|
1527
|
+
llm: LLMProvider<any>;
|
|
1528
|
+
}> = InferGenerateTextResponseFromProvider<TProvider> & {
|
|
1529
|
+
userContext: Map<string | symbol, unknown>;
|
|
1530
|
+
};
|
|
1531
|
+
type StreamTextResponse<TProvider extends {
|
|
1532
|
+
llm: LLMProvider<any>;
|
|
1533
|
+
}> = InferStreamTextResponseFromProvider<TProvider> & {
|
|
1534
|
+
userContext?: Map<string | symbol, unknown>;
|
|
1535
|
+
};
|
|
1536
|
+
type GenerateObjectResponse<TProvider extends {
|
|
1537
|
+
llm: LLMProvider<any>;
|
|
1538
|
+
}, TSchema extends z.ZodType> = InferGenerateObjectResponseFromProvider<TProvider, TSchema> & {
|
|
1539
|
+
userContext: Map<string | symbol, unknown>;
|
|
1540
|
+
};
|
|
1541
|
+
type StreamObjectResponse<TProvider extends {
|
|
1542
|
+
llm: LLMProvider<any>;
|
|
1543
|
+
}, TSchema extends z.ZodType> = InferStreamObjectResponseFromProvider<TProvider, TSchema> & {
|
|
1544
|
+
userContext?: Map<string | symbol, unknown>;
|
|
1545
|
+
};
|
|
1264
1546
|
|
|
1265
1547
|
/**
|
|
1266
1548
|
* Token usage information
|
|
@@ -2650,6 +2932,65 @@ declare abstract class BaseRetriever {
|
|
|
2650
2932
|
abstract retrieve(input: string | BaseMessage[], options: RetrieveOptions): Promise<string>;
|
|
2651
2933
|
}
|
|
2652
2934
|
|
|
2935
|
+
/**
|
|
2936
|
+
* Main VoltOps client class that provides unified access to both
|
|
2937
|
+
* telemetry export and prompt management functionality.
|
|
2938
|
+
*/
|
|
2939
|
+
declare class VoltOpsClient implements VoltOpsClient$1 {
|
|
2940
|
+
readonly options: VoltOpsClientOptions & {
|
|
2941
|
+
baseUrl: string;
|
|
2942
|
+
};
|
|
2943
|
+
readonly observability?: VoltAgentExporter;
|
|
2944
|
+
readonly prompts?: VoltOpsPromptManager;
|
|
2945
|
+
constructor(options: VoltOpsClientOptions);
|
|
2946
|
+
/**
|
|
2947
|
+
* Create a prompt helper for agent instructions
|
|
2948
|
+
*/
|
|
2949
|
+
createPromptHelper(_agentId: string): PromptHelper;
|
|
2950
|
+
get exportHistoryEntry(): ((historyEntryData: ExportAgentHistoryPayload) => Promise<{
|
|
2951
|
+
historyEntryId: string;
|
|
2952
|
+
}>) | undefined;
|
|
2953
|
+
get exportHistoryEntryAsync(): ((historyEntryData: ExportAgentHistoryPayload) => void) | undefined;
|
|
2954
|
+
get exportTimelineEvent(): ((timelineEventData: ExportTimelineEventPayload) => Promise<{
|
|
2955
|
+
timelineEventId: string;
|
|
2956
|
+
}>) | undefined;
|
|
2957
|
+
get exportTimelineEventAsync(): ((timelineEventData: ExportTimelineEventPayload) => void) | undefined;
|
|
2958
|
+
/**
|
|
2959
|
+
* Check if observability is enabled and configured
|
|
2960
|
+
*/
|
|
2961
|
+
isObservabilityEnabled(): boolean;
|
|
2962
|
+
/**
|
|
2963
|
+
* Check if prompt management is enabled and configured
|
|
2964
|
+
*/
|
|
2965
|
+
isPromptManagementEnabled(): boolean;
|
|
2966
|
+
/**
|
|
2967
|
+
* Get observability exporter for backward compatibility
|
|
2968
|
+
* @deprecated Use observability property directly
|
|
2969
|
+
*/
|
|
2970
|
+
getObservabilityExporter(): VoltAgentExporter | undefined;
|
|
2971
|
+
/**
|
|
2972
|
+
* Get prompt manager for direct access
|
|
2973
|
+
*/
|
|
2974
|
+
getPromptManager(): VoltOpsPromptManager | undefined;
|
|
2975
|
+
/**
|
|
2976
|
+
* Static method to create prompt helper with priority-based fallback
|
|
2977
|
+
* Priority: Agent VoltOpsClient > Global VoltOpsClient > Fallback instructions
|
|
2978
|
+
*/
|
|
2979
|
+
static createPromptHelperWithFallback(agentId: string, agentName: string, fallbackInstructions: string, agentVoltOpsClient?: VoltOpsClient): PromptHelper;
|
|
2980
|
+
/**
|
|
2981
|
+
* Validate API keys and provide helpful error messages
|
|
2982
|
+
*/
|
|
2983
|
+
private validateApiKeys;
|
|
2984
|
+
/**
|
|
2985
|
+
* Cleanup resources when client is no longer needed
|
|
2986
|
+
*/
|
|
2987
|
+
dispose(): Promise<void>;
|
|
2988
|
+
}
|
|
2989
|
+
/**
|
|
2990
|
+
* Factory function to create VoltOps client
|
|
2991
|
+
*/
|
|
2992
|
+
declare const createVoltOpsClient: (options: VoltOpsClientOptions) => VoltOpsClient;
|
|
2993
|
+
|
|
2653
2994
|
/**
|
|
2654
2995
|
* ReadableStream type for voice responses
|
|
2655
2996
|
*/
|
|
@@ -2972,18 +3313,23 @@ declare class Agent<TProvider extends {
|
|
|
2972
3313
|
* Retriever for automatic RAG
|
|
2973
3314
|
*/
|
|
2974
3315
|
private retriever?;
|
|
3316
|
+
/**
|
|
3317
|
+
* VoltOps client for this specific agent (optional)
|
|
3318
|
+
* Takes priority over global VoltOpsClient for prompt management
|
|
3319
|
+
*/
|
|
3320
|
+
private readonly voltOpsClient?;
|
|
2975
3321
|
/**
|
|
2976
3322
|
* Create a new agent
|
|
2977
3323
|
*/
|
|
2978
3324
|
constructor(options: AgentOptions & TProvider & {
|
|
2979
|
-
model:
|
|
3325
|
+
model: ModelDynamicValue<ModelType<TProvider>>;
|
|
2980
3326
|
subAgents?: Agent<any>[];
|
|
2981
3327
|
maxHistoryEntries?: number;
|
|
2982
3328
|
hooks?: AgentHooks;
|
|
2983
3329
|
retriever?: BaseRetriever;
|
|
2984
3330
|
voice?: Voice;
|
|
2985
3331
|
markdown?: boolean;
|
|
2986
|
-
|
|
3332
|
+
voltOpsClient?: VoltOpsClient;
|
|
2987
3333
|
});
|
|
2988
3334
|
/**
|
|
2989
3335
|
* Resolve dynamic instructions based on user context
|
|
@@ -3005,7 +3351,7 @@ declare class Agent<TProvider extends {
|
|
|
3005
3351
|
historyEntryId: string;
|
|
3006
3352
|
contextMessages: BaseMessage[];
|
|
3007
3353
|
operationContext?: OperationContext;
|
|
3008
|
-
}): Promise<
|
|
3354
|
+
}): Promise<SystemMessageResponse>;
|
|
3009
3355
|
/**
|
|
3010
3356
|
* Prepare agents memory for the supervisor system message
|
|
3011
3357
|
* This fetches and formats recent interactions with sub-agents
|
|
@@ -3095,19 +3441,19 @@ declare class Agent<TProvider extends {
|
|
|
3095
3441
|
/**
|
|
3096
3442
|
* Generate a text response without streaming
|
|
3097
3443
|
*/
|
|
3098
|
-
generateText(input: string | BaseMessage[], options?: PublicGenerateOptions): Promise<
|
|
3444
|
+
generateText(input: string | BaseMessage[], options?: PublicGenerateOptions): Promise<GenerateTextResponse<TProvider>>;
|
|
3099
3445
|
/**
|
|
3100
3446
|
* Stream a text response
|
|
3101
3447
|
*/
|
|
3102
|
-
streamText(input: string | BaseMessage[], options?: PublicGenerateOptions): Promise<
|
|
3448
|
+
streamText(input: string | BaseMessage[], options?: PublicGenerateOptions): Promise<StreamTextResponse<TProvider>>;
|
|
3103
3449
|
/**
|
|
3104
3450
|
* Generate a structured object response
|
|
3105
3451
|
*/
|
|
3106
|
-
generateObject<TSchema extends z.ZodType>(input: string | BaseMessage[], schema: TSchema, options?: PublicGenerateOptions): Promise<
|
|
3452
|
+
generateObject<TSchema extends z.ZodType>(input: string | BaseMessage[], schema: TSchema, options?: PublicGenerateOptions): Promise<GenerateObjectResponse<TProvider, TSchema>>;
|
|
3107
3453
|
/**
|
|
3108
3454
|
* Stream a structured object response
|
|
3109
3455
|
*/
|
|
3110
|
-
streamObject<TSchema extends z.ZodType>(input: string | BaseMessage[], schema: TSchema, options?: PublicGenerateOptions): Promise<
|
|
3456
|
+
streamObject<TSchema extends z.ZodType>(input: string | BaseMessage[], schema: TSchema, options?: PublicGenerateOptions): Promise<StreamObjectResponse<TProvider, TSchema>>;
|
|
3111
3457
|
/**
|
|
3112
3458
|
* Add a sub-agent that this agent can delegate tasks to
|
|
3113
3459
|
*/
|
|
@@ -3165,6 +3511,10 @@ declare class Agent<TProvider extends {
|
|
|
3165
3511
|
* This is typically called by the main VoltAgent instance after it has initialized its exporter.
|
|
3166
3512
|
*/
|
|
3167
3513
|
_INTERNAL_setVoltAgentExporter(exporter: VoltAgentExporter): void;
|
|
3514
|
+
/**
|
|
3515
|
+
* Helper method to get retriever context with event handling
|
|
3516
|
+
*/
|
|
3517
|
+
private getRetrieverContext;
|
|
3168
3518
|
}
|
|
3169
3519
|
|
|
3170
3520
|
/**
|
|
@@ -3243,6 +3593,20 @@ type VoltAgentOptions = {
|
|
|
3243
3593
|
* Server configuration options
|
|
3244
3594
|
*/
|
|
3245
3595
|
server?: ServerOptions;
|
|
3596
|
+
/**
|
|
3597
|
+
* Unified VoltOps client for telemetry and prompt management
|
|
3598
|
+
* Replaces the old telemetryExporter approach with a comprehensive solution.
|
|
3599
|
+
*/
|
|
3600
|
+
voltOpsClient?: VoltOpsClient$1;
|
|
3601
|
+
/**
|
|
3602
|
+
* @deprecated Use `voltOpsClient` instead. Will be removed in a future version.
|
|
3603
|
+
* Optional OpenTelemetry SpanExporter instance or array of instances.
|
|
3604
|
+
* or a VoltAgentExporter instance or array of instances.
|
|
3605
|
+
* If provided, VoltAgent will attempt to initialize and register
|
|
3606
|
+
* a NodeTracerProvider with a BatchSpanProcessor for the given exporter(s).
|
|
3607
|
+
* It's recommended to only provide this in one VoltAgent instance per application process.
|
|
3608
|
+
*/
|
|
3609
|
+
telemetryExporter?: (SpanExporter | VoltAgentExporter) | (SpanExporter | VoltAgentExporter)[];
|
|
3246
3610
|
/**
|
|
3247
3611
|
* @deprecated Use `server.port` instead
|
|
3248
3612
|
*/
|
|
@@ -3260,14 +3624,6 @@ type VoltAgentOptions = {
|
|
|
3260
3624
|
* @deprecated Use `server.enableSwaggerUI` instead
|
|
3261
3625
|
*/
|
|
3262
3626
|
enableSwaggerUI?: boolean;
|
|
3263
|
-
/**
|
|
3264
|
-
* Optional OpenTelemetry SpanExporter instance or array of instances.
|
|
3265
|
-
* or a VoltAgentExporter instance or array of instances.
|
|
3266
|
-
* If provided, VoltAgent will attempt to initialize and register
|
|
3267
|
-
* a NodeTracerProvider with a BatchSpanProcessor for the given exporter(s).
|
|
3268
|
-
* It's recommended to only provide this in one VoltAgent instance per application process.
|
|
3269
|
-
*/
|
|
3270
|
-
telemetryExporter?: (SpanExporter | VoltAgentExporter) | (SpanExporter | VoltAgentExporter)[];
|
|
3271
3627
|
};
|
|
3272
3628
|
|
|
3273
3629
|
/**
|
|
@@ -3931,6 +4287,7 @@ declare class AgentRegistry {
|
|
|
3931
4287
|
private agents;
|
|
3932
4288
|
private isInitialized;
|
|
3933
4289
|
private globalVoltAgentExporter?;
|
|
4290
|
+
private globalVoltOpsClient?;
|
|
3934
4291
|
/**
|
|
3935
4292
|
* Track parent-child relationships between agents (child -> parents)
|
|
3936
4293
|
*/
|
|
@@ -4000,6 +4357,15 @@ declare class AgentRegistry {
|
|
|
4000
4357
|
* Get the global VoltAgentExporter instance.
|
|
4001
4358
|
*/
|
|
4002
4359
|
getGlobalVoltAgentExporter(): VoltAgentExporter | undefined;
|
|
4360
|
+
/**
|
|
4361
|
+
* Set the global VoltOpsClient instance.
|
|
4362
|
+
* This replaces the old telemetryExporter approach with a unified solution.
|
|
4363
|
+
*/
|
|
4364
|
+
setGlobalVoltOpsClient(client: VoltOpsClient$1 | undefined): void;
|
|
4365
|
+
/**
|
|
4366
|
+
* Get the global VoltOpsClient instance.
|
|
4367
|
+
*/
|
|
4368
|
+
getGlobalVoltOpsClient(): VoltOpsClient$1 | undefined;
|
|
4003
4369
|
}
|
|
4004
4370
|
|
|
4005
4371
|
/**
|
|
@@ -4015,6 +4381,117 @@ declare function registerCustomEndpoint(endpoint: CustomEndpointDefinition): voi
|
|
|
4015
4381
|
*/
|
|
4016
4382
|
declare function registerCustomEndpoints(endpoints: CustomEndpointDefinition[]): void;
|
|
4017
4383
|
|
|
4384
|
+
/**
|
|
4385
|
+
* Prompt manager with caching and Liquid template processing
|
|
4386
|
+
*/
|
|
4387
|
+
|
|
4388
|
+
/**
|
|
4389
|
+
* Implementation of VoltOpsPromptManager with caching and Liquid templates
|
|
4390
|
+
*/
|
|
4391
|
+
declare class VoltOpsPromptManagerImpl implements VoltOpsPromptManager {
|
|
4392
|
+
private readonly cache;
|
|
4393
|
+
private readonly apiClient;
|
|
4394
|
+
private readonly templateEngine;
|
|
4395
|
+
private readonly cacheConfig;
|
|
4396
|
+
constructor(options: VoltOpsClientOptions);
|
|
4397
|
+
/**
|
|
4398
|
+
* Get prompt content by reference with caching and template processing
|
|
4399
|
+
*/
|
|
4400
|
+
getPrompt(reference: PromptReference): Promise<PromptContent>;
|
|
4401
|
+
/**
|
|
4402
|
+
* Preload prompts for better performance
|
|
4403
|
+
*/
|
|
4404
|
+
preload(references: PromptReference[]): Promise<void>;
|
|
4405
|
+
/**
|
|
4406
|
+
* Clear cache
|
|
4407
|
+
*/
|
|
4408
|
+
clearCache(): void;
|
|
4409
|
+
/**
|
|
4410
|
+
* Get cache statistics
|
|
4411
|
+
*/
|
|
4412
|
+
getCacheStats(): {
|
|
4413
|
+
size: number;
|
|
4414
|
+
entries: string[];
|
|
4415
|
+
};
|
|
4416
|
+
/**
|
|
4417
|
+
* Convert API response to PromptContent with metadata
|
|
4418
|
+
*/
|
|
4419
|
+
private convertApiResponseToPromptContent;
|
|
4420
|
+
/**
|
|
4421
|
+
* Generate cache key for prompt reference
|
|
4422
|
+
*/
|
|
4423
|
+
private getCacheKey;
|
|
4424
|
+
/**
|
|
4425
|
+
* Get cached prompt if valid
|
|
4426
|
+
*/
|
|
4427
|
+
private getCachedPrompt;
|
|
4428
|
+
/**
|
|
4429
|
+
* Set cached prompt with TTL and size limit enforcement
|
|
4430
|
+
*/
|
|
4431
|
+
private setCachedPrompt;
|
|
4432
|
+
/**
|
|
4433
|
+
* Evict oldest cache entry to make room for new one
|
|
4434
|
+
*/
|
|
4435
|
+
private evictOldestEntry;
|
|
4436
|
+
/**
|
|
4437
|
+
* Process template variables using configured template engine
|
|
4438
|
+
*/
|
|
4439
|
+
private processTemplate;
|
|
4440
|
+
/**
|
|
4441
|
+
* Process PromptContent with template processing
|
|
4442
|
+
*/
|
|
4443
|
+
private processPromptContent;
|
|
4444
|
+
/**
|
|
4445
|
+
* Process MessageContent (can be string or array of parts)
|
|
4446
|
+
*/
|
|
4447
|
+
private processMessageContent;
|
|
4448
|
+
}
|
|
4449
|
+
|
|
4450
|
+
/**
|
|
4451
|
+
* API client for prompt operations
|
|
4452
|
+
*/
|
|
4453
|
+
|
|
4454
|
+
/**
|
|
4455
|
+
* Implementation of PromptApiClient for VoltOps API communication
|
|
4456
|
+
*/
|
|
4457
|
+
declare class VoltOpsPromptApiClient implements PromptApiClient {
|
|
4458
|
+
private readonly baseUrl;
|
|
4459
|
+
private readonly publicKey;
|
|
4460
|
+
private readonly secretKey;
|
|
4461
|
+
private readonly fetchFn;
|
|
4462
|
+
constructor(options: VoltOpsClientOptions);
|
|
4463
|
+
/**
|
|
4464
|
+
* Fetch prompt content from VoltOps API
|
|
4465
|
+
*/
|
|
4466
|
+
fetchPrompt(reference: PromptReference): Promise<PromptApiResponse>;
|
|
4467
|
+
/**
|
|
4468
|
+
* Build URL for prompt API endpoint
|
|
4469
|
+
*/
|
|
4470
|
+
private buildPromptUrl;
|
|
4471
|
+
/**
|
|
4472
|
+
* Build authentication headers
|
|
4473
|
+
*/
|
|
4474
|
+
private buildHeaders;
|
|
4475
|
+
}
|
|
4476
|
+
|
|
4477
|
+
/**
|
|
4478
|
+
* Simple template engine for basic variable substitution
|
|
4479
|
+
*/
|
|
4480
|
+
/**
|
|
4481
|
+
* Template engine interface
|
|
4482
|
+
*/
|
|
4483
|
+
type TemplateEngine = {
|
|
4484
|
+
/** Process template with variables */
|
|
4485
|
+
process: (content: string, variables: Record<string, any>) => string;
|
|
4486
|
+
/** Engine name for debugging */
|
|
4487
|
+
name: string;
|
|
4488
|
+
};
|
|
4489
|
+
/**
|
|
4490
|
+
* Simple mustache-style template engine (built-in, no dependencies)
|
|
4491
|
+
* Supports {{variable}} syntax for basic variable substitution
|
|
4492
|
+
*/
|
|
4493
|
+
declare const createSimpleTemplateEngine: () => TemplateEngine;
|
|
4494
|
+
|
|
4018
4495
|
/**
|
|
4019
4496
|
* Main VoltAgent class for managing agents and server
|
|
4020
4497
|
*/
|
|
@@ -4069,4 +4546,4 @@ declare class VoltAgent {
|
|
|
4069
4546
|
shutdownTelemetry(): Promise<void>;
|
|
4070
4547
|
}
|
|
4071
4548
|
|
|
4072
|
-
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, 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 };
|
|
4549
|
+
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 };
|