@voltagent/core 0.1.19 → 0.1.20
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.js +201 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +201 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -56,6 +56,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
56
56
|
mod
|
|
57
57
|
));
|
|
58
58
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
59
|
+
var __publicField = (obj, key, value) => {
|
|
60
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
61
|
+
return value;
|
|
62
|
+
};
|
|
59
63
|
var __async = (__this, __arguments, generator) => {
|
|
60
64
|
return new Promise((resolve, reject) => {
|
|
61
65
|
var fulfilled = (value) => {
|
|
@@ -139,12 +143,13 @@ var import_events2 = require("events");
|
|
|
139
143
|
// src/server/registry.ts
|
|
140
144
|
var _AgentRegistry = class {
|
|
141
145
|
constructor() {
|
|
142
|
-
this
|
|
143
|
-
this
|
|
146
|
+
__publicField(this, "agents", /* @__PURE__ */ new Map());
|
|
147
|
+
__publicField(this, "isInitialized", false);
|
|
148
|
+
__publicField(this, "globalVoltAgentExporter");
|
|
144
149
|
/**
|
|
145
150
|
* Track parent-child relationships between agents (child -> parents)
|
|
146
151
|
*/
|
|
147
|
-
this
|
|
152
|
+
__publicField(this, "agentRelationships", /* @__PURE__ */ new Map());
|
|
148
153
|
}
|
|
149
154
|
/**
|
|
150
155
|
* Get the singleton instance of AgentRegistry
|
|
@@ -279,14 +284,14 @@ var _AgentRegistry = class {
|
|
|
279
284
|
};
|
|
280
285
|
var AgentRegistry = _AgentRegistry;
|
|
281
286
|
__name(AgentRegistry, "AgentRegistry");
|
|
282
|
-
AgentRegistry
|
|
287
|
+
__publicField(AgentRegistry, "instance", null);
|
|
283
288
|
|
|
284
289
|
// src/events/index.ts
|
|
285
290
|
var import_uuid = require("uuid");
|
|
286
291
|
var _AgentEventEmitter = class extends import_events2.EventEmitter {
|
|
287
292
|
constructor() {
|
|
288
293
|
super();
|
|
289
|
-
this
|
|
294
|
+
__publicField(this, "trackedEvents", /* @__PURE__ */ new Map());
|
|
290
295
|
}
|
|
291
296
|
/**
|
|
292
297
|
* Get the singleton instance of AgentEventEmitter
|
|
@@ -547,7 +552,7 @@ var _AgentEventEmitter = class extends import_events2.EventEmitter {
|
|
|
547
552
|
};
|
|
548
553
|
var AgentEventEmitter = _AgentEventEmitter;
|
|
549
554
|
__name(AgentEventEmitter, "AgentEventEmitter");
|
|
550
|
-
AgentEventEmitter
|
|
555
|
+
__publicField(AgentEventEmitter, "instance", null);
|
|
551
556
|
|
|
552
557
|
// src/utils/update/index.ts
|
|
553
558
|
var import_node_path = __toESM(require("path"));
|
|
@@ -860,7 +865,7 @@ var MessageContentSchema = import_zod.z.union([
|
|
|
860
865
|
import_zod.z.array(ContentPartSchema).openapi({ description: "An array of content parts (text, image, file)." })
|
|
861
866
|
]);
|
|
862
867
|
var MessageObjectSchema = import_zod.z.object({
|
|
863
|
-
role: import_zod.z.
|
|
868
|
+
role: import_zod.z.enum(["system", "user", "assistant", "tool"]).openapi({
|
|
864
869
|
description: "Role of the sender (e.g., 'user', 'assistant')"
|
|
865
870
|
}),
|
|
866
871
|
content: MessageContentSchema
|
|
@@ -1275,7 +1280,7 @@ app.openapi(getAgentsRoute, (c) => {
|
|
|
1275
1280
|
data: agentDataArray
|
|
1276
1281
|
// Ensure data array matches schema
|
|
1277
1282
|
};
|
|
1278
|
-
return c.json(response);
|
|
1283
|
+
return c.json(response, 200);
|
|
1279
1284
|
} catch (error) {
|
|
1280
1285
|
console.error("Failed to get agents:", error);
|
|
1281
1286
|
return c.json(
|
|
@@ -1351,7 +1356,10 @@ app.openapi(textRoute, (c) => __async(void 0, null, function* () {
|
|
|
1351
1356
|
try {
|
|
1352
1357
|
const { input, options = {} } = c.req.valid("json");
|
|
1353
1358
|
const response = yield agent.generateText(input, options);
|
|
1354
|
-
return c.json(
|
|
1359
|
+
return c.json(
|
|
1360
|
+
{ success: true, data: response },
|
|
1361
|
+
200
|
|
1362
|
+
);
|
|
1355
1363
|
} catch (error) {
|
|
1356
1364
|
return c.json(
|
|
1357
1365
|
{
|
|
@@ -1484,7 +1492,10 @@ app.openapi(objectRoute, (c) => __async(void 0, null, function* () {
|
|
|
1484
1492
|
options = {}
|
|
1485
1493
|
} = c.req.valid("json");
|
|
1486
1494
|
const response = yield agent.generateObject(input, schema, options);
|
|
1487
|
-
return c.json(
|
|
1495
|
+
return c.json(
|
|
1496
|
+
{ success: true, data: response },
|
|
1497
|
+
200
|
|
1498
|
+
);
|
|
1488
1499
|
} catch (error) {
|
|
1489
1500
|
return c.json(
|
|
1490
1501
|
{
|
|
@@ -1915,10 +1926,11 @@ var InMemoryStorage = class {
|
|
|
1915
1926
|
* @param options Configuration options
|
|
1916
1927
|
*/
|
|
1917
1928
|
constructor(options = {}) {
|
|
1918
|
-
this
|
|
1919
|
-
this
|
|
1920
|
-
this
|
|
1921
|
-
this
|
|
1929
|
+
__publicField(this, "storage", {});
|
|
1930
|
+
__publicField(this, "conversations", /* @__PURE__ */ new Map());
|
|
1931
|
+
__publicField(this, "historyEntries", /* @__PURE__ */ new Map());
|
|
1932
|
+
__publicField(this, "agentHistory", {});
|
|
1933
|
+
__publicField(this, "options");
|
|
1922
1934
|
this.options = {
|
|
1923
1935
|
storageLimit: options.storageLimit || 100,
|
|
1924
1936
|
debug: options.debug || false
|
|
@@ -2300,6 +2312,9 @@ var LibSQLStorage = class {
|
|
|
2300
2312
|
* @param options Configuration options
|
|
2301
2313
|
*/
|
|
2302
2314
|
constructor(options) {
|
|
2315
|
+
__publicField(this, "client");
|
|
2316
|
+
__publicField(this, "options");
|
|
2317
|
+
__publicField(this, "initialized");
|
|
2303
2318
|
this.options = {
|
|
2304
2319
|
storageLimit: options.storageLimit || 100,
|
|
2305
2320
|
tablePrefix: options.tablePrefix || "voltagent_memory",
|
|
@@ -3083,6 +3098,18 @@ var MemoryManager = class {
|
|
|
3083
3098
|
* Creates a new MemoryManager
|
|
3084
3099
|
*/
|
|
3085
3100
|
constructor(resourceId, memory, options = {}) {
|
|
3101
|
+
/**
|
|
3102
|
+
* The memory storage instance
|
|
3103
|
+
*/
|
|
3104
|
+
__publicField(this, "memory");
|
|
3105
|
+
/**
|
|
3106
|
+
* Memory configuration options
|
|
3107
|
+
*/
|
|
3108
|
+
__publicField(this, "options");
|
|
3109
|
+
/**
|
|
3110
|
+
* The ID of the resource (agent) that owns this memory manager
|
|
3111
|
+
*/
|
|
3112
|
+
__publicField(this, "resourceId");
|
|
3086
3113
|
this.resourceId = resourceId;
|
|
3087
3114
|
if (memory === false) {
|
|
3088
3115
|
this.memory = void 0;
|
|
@@ -3730,11 +3757,11 @@ var ToolManager = class {
|
|
|
3730
3757
|
/**
|
|
3731
3758
|
* Standalone tools managed by this manager.
|
|
3732
3759
|
*/
|
|
3733
|
-
this
|
|
3760
|
+
__publicField(this, "tools", []);
|
|
3734
3761
|
/**
|
|
3735
3762
|
* Toolkits managed by this manager.
|
|
3736
3763
|
*/
|
|
3737
|
-
this
|
|
3764
|
+
__publicField(this, "toolkits", []);
|
|
3738
3765
|
this.addItems(items);
|
|
3739
3766
|
}
|
|
3740
3767
|
/**
|
|
@@ -4013,6 +4040,26 @@ var Tool = class {
|
|
|
4013
4040
|
* Create a new tool
|
|
4014
4041
|
*/
|
|
4015
4042
|
constructor(options) {
|
|
4043
|
+
/**
|
|
4044
|
+
* Unique identifier for the tool
|
|
4045
|
+
*/
|
|
4046
|
+
__publicField(this, "id");
|
|
4047
|
+
/**
|
|
4048
|
+
* Name of the tool
|
|
4049
|
+
*/
|
|
4050
|
+
__publicField(this, "name");
|
|
4051
|
+
/**
|
|
4052
|
+
* Description of the tool
|
|
4053
|
+
*/
|
|
4054
|
+
__publicField(this, "description");
|
|
4055
|
+
/**
|
|
4056
|
+
* Tool parameter schema
|
|
4057
|
+
*/
|
|
4058
|
+
__publicField(this, "parameters");
|
|
4059
|
+
/**
|
|
4060
|
+
* Function to execute when the tool is called
|
|
4061
|
+
*/
|
|
4062
|
+
__publicField(this, "execute");
|
|
4016
4063
|
if (!options.name) {
|
|
4017
4064
|
throw new Error("Tool name is required");
|
|
4018
4065
|
}
|
|
@@ -4050,6 +4097,23 @@ var HistoryManager = class {
|
|
|
4050
4097
|
* @param voltAgentExporter - Optional exporter for telemetry
|
|
4051
4098
|
*/
|
|
4052
4099
|
constructor(agentId, memoryManager, maxEntries = 0, voltAgentExporter) {
|
|
4100
|
+
/**
|
|
4101
|
+
* Maximum number of history entries to keep
|
|
4102
|
+
* Set to 0 for unlimited
|
|
4103
|
+
*/
|
|
4104
|
+
__publicField(this, "maxEntries");
|
|
4105
|
+
/**
|
|
4106
|
+
* Agent ID for emitting events
|
|
4107
|
+
*/
|
|
4108
|
+
__publicField(this, "agentId");
|
|
4109
|
+
/**
|
|
4110
|
+
* Memory manager for storing history entries
|
|
4111
|
+
*/
|
|
4112
|
+
__publicField(this, "memoryManager");
|
|
4113
|
+
/**
|
|
4114
|
+
* Optional VoltAgentExporter for sending telemetry data.
|
|
4115
|
+
*/
|
|
4116
|
+
__publicField(this, "voltAgentExporter");
|
|
4053
4117
|
this.agentId = agentId;
|
|
4054
4118
|
this.memoryManager = memoryManager;
|
|
4055
4119
|
this.maxEntries = maxEntries;
|
|
@@ -4438,10 +4502,14 @@ var SubAgentManager = class {
|
|
|
4438
4502
|
* @param subAgents - Initial sub-agents to add
|
|
4439
4503
|
*/
|
|
4440
4504
|
constructor(agentName, subAgents = []) {
|
|
4505
|
+
/**
|
|
4506
|
+
* The name of the agent that owns this sub-agent manager
|
|
4507
|
+
*/
|
|
4508
|
+
__publicField(this, "agentName");
|
|
4441
4509
|
/**
|
|
4442
4510
|
* Sub-agents that the parent agent can delegate tasks to
|
|
4443
4511
|
*/
|
|
4444
|
-
this
|
|
4512
|
+
__publicField(this, "subAgents", []);
|
|
4445
4513
|
this.agentName = agentName;
|
|
4446
4514
|
this.subAgents = [];
|
|
4447
4515
|
subAgents.forEach((agent) => this.addSubAgent(agent));
|
|
@@ -4933,10 +5001,66 @@ var Agent = class {
|
|
|
4933
5001
|
* Create a new agent
|
|
4934
5002
|
*/
|
|
4935
5003
|
constructor(options) {
|
|
5004
|
+
/**
|
|
5005
|
+
* Unique identifier for the agent
|
|
5006
|
+
*/
|
|
5007
|
+
__publicField(this, "id");
|
|
5008
|
+
/**
|
|
5009
|
+
* Agent name
|
|
5010
|
+
*/
|
|
5011
|
+
__publicField(this, "name");
|
|
5012
|
+
/**
|
|
5013
|
+
* @deprecated Use `instructions` instead. Will be removed in a future version.
|
|
5014
|
+
*/
|
|
5015
|
+
__publicField(this, "description");
|
|
5016
|
+
/**
|
|
5017
|
+
* Agent instructions. This is the preferred field over `description`.
|
|
5018
|
+
*/
|
|
5019
|
+
__publicField(this, "instructions");
|
|
5020
|
+
/**
|
|
5021
|
+
* The LLM provider to use
|
|
5022
|
+
*/
|
|
5023
|
+
__publicField(this, "llm");
|
|
5024
|
+
/**
|
|
5025
|
+
* The AI model to use
|
|
5026
|
+
*/
|
|
5027
|
+
__publicField(this, "model");
|
|
5028
|
+
/**
|
|
5029
|
+
* Hooks for agent lifecycle events
|
|
5030
|
+
*/
|
|
5031
|
+
__publicField(this, "hooks");
|
|
5032
|
+
/**
|
|
5033
|
+
* Voice provider for the agent
|
|
5034
|
+
*/
|
|
5035
|
+
__publicField(this, "voice");
|
|
5036
|
+
/**
|
|
5037
|
+
* Indicates if the agent should format responses using Markdown.
|
|
5038
|
+
*/
|
|
5039
|
+
__publicField(this, "markdown");
|
|
5040
|
+
/**
|
|
5041
|
+
* Memory manager for the agent
|
|
5042
|
+
*/
|
|
5043
|
+
__publicField(this, "memoryManager");
|
|
5044
|
+
/**
|
|
5045
|
+
* Tool manager for the agent
|
|
5046
|
+
*/
|
|
5047
|
+
__publicField(this, "toolManager");
|
|
5048
|
+
/**
|
|
5049
|
+
* Sub-agent manager for the agent
|
|
5050
|
+
*/
|
|
5051
|
+
__publicField(this, "subAgentManager");
|
|
5052
|
+
/**
|
|
5053
|
+
* History manager for the agent
|
|
5054
|
+
*/
|
|
5055
|
+
__publicField(this, "historyManager");
|
|
5056
|
+
/**
|
|
5057
|
+
* Retriever for automatic RAG
|
|
5058
|
+
*/
|
|
5059
|
+
__publicField(this, "retriever");
|
|
4936
5060
|
/**
|
|
4937
5061
|
* Standard timeline event creator
|
|
4938
5062
|
*/
|
|
4939
|
-
this
|
|
5063
|
+
__publicField(this, "createStandardTimelineEvent", /* @__PURE__ */ __name((historyId, eventName, status, nodeType, nodeName, data = {}, type = "agent", context) => {
|
|
4940
5064
|
if (!historyId)
|
|
4941
5065
|
return;
|
|
4942
5066
|
const affectedNodeId = createNodeId(nodeType, nodeName, this.id);
|
|
@@ -4976,11 +5100,11 @@ var Agent = class {
|
|
|
4976
5100
|
});
|
|
4977
5101
|
AgentEventEmitter.getInstance().addHistoryEvent(parentEventPayload);
|
|
4978
5102
|
}
|
|
4979
|
-
}, "createStandardTimelineEvent");
|
|
5103
|
+
}, "createStandardTimelineEvent"));
|
|
4980
5104
|
/**
|
|
4981
5105
|
* Fix delete operator usage for better performance
|
|
4982
5106
|
*/
|
|
4983
|
-
this
|
|
5107
|
+
__publicField(this, "addToolEvent", /* @__PURE__ */ __name((_0, _1, _2, _3, ..._4) => __async(this, [_0, _1, _2, _3, ..._4], function* (context, eventName, toolName, status, data = {}) {
|
|
4984
5108
|
var _a;
|
|
4985
5109
|
if (!context.toolSpans) {
|
|
4986
5110
|
context.toolSpans = /* @__PURE__ */ new Map();
|
|
@@ -5059,11 +5183,11 @@ var Agent = class {
|
|
|
5059
5183
|
}
|
|
5060
5184
|
return result;
|
|
5061
5185
|
});
|
|
5062
|
-
}), "addToolEvent");
|
|
5186
|
+
}), "addToolEvent"));
|
|
5063
5187
|
/**
|
|
5064
5188
|
* Agent event creator (update)
|
|
5065
5189
|
*/
|
|
5066
|
-
this
|
|
5190
|
+
__publicField(this, "addAgentEvent", /* @__PURE__ */ __name((context, eventName, status, data = {}) => {
|
|
5067
5191
|
const otelSpan = context.otelSpan;
|
|
5068
5192
|
if (otelSpan) {
|
|
5069
5193
|
endOperationSpan({
|
|
@@ -5094,7 +5218,7 @@ var Agent = class {
|
|
|
5094
5218
|
"agent",
|
|
5095
5219
|
context
|
|
5096
5220
|
);
|
|
5097
|
-
}, "addAgentEvent");
|
|
5221
|
+
}, "addAgentEvent"));
|
|
5098
5222
|
var _a, _b, _c;
|
|
5099
5223
|
this.id = options.id || options.name;
|
|
5100
5224
|
this.name = options.name;
|
|
@@ -6644,6 +6768,29 @@ var BaseRetriever = class {
|
|
|
6644
6768
|
* @param options - Configuration options for the retriever.
|
|
6645
6769
|
*/
|
|
6646
6770
|
constructor(options = {}) {
|
|
6771
|
+
/**
|
|
6772
|
+
* Options that configure the retriever's behavior
|
|
6773
|
+
*/
|
|
6774
|
+
__publicField(this, "options");
|
|
6775
|
+
/**
|
|
6776
|
+
* Ready-to-use tool property for direct destructuring
|
|
6777
|
+
* This can be used with object destructuring syntax
|
|
6778
|
+
*
|
|
6779
|
+
* @example
|
|
6780
|
+
* ```typescript
|
|
6781
|
+
* // ✅ You can use destructuring with the tool property
|
|
6782
|
+
* const { tool } = new SimpleRetriever();
|
|
6783
|
+
*
|
|
6784
|
+
* // And use it directly in an agent
|
|
6785
|
+
* const agent = new Agent({
|
|
6786
|
+
* name: "RAG Agent",
|
|
6787
|
+
* model: "gpt-4",
|
|
6788
|
+
* provider,
|
|
6789
|
+
* tools: [tool],
|
|
6790
|
+
* });
|
|
6791
|
+
* ```
|
|
6792
|
+
*/
|
|
6793
|
+
__publicField(this, "tool");
|
|
6647
6794
|
this.options = __spreadValues({}, options);
|
|
6648
6795
|
const toolParams = {
|
|
6649
6796
|
name: this.options.toolName || "search_knowledge",
|
|
@@ -6677,11 +6824,30 @@ var MCPClient = class extends import_node_events.EventEmitter {
|
|
|
6677
6824
|
constructor(config) {
|
|
6678
6825
|
var _a;
|
|
6679
6826
|
super();
|
|
6827
|
+
/**
|
|
6828
|
+
* Underlying MCP client instance from the SDK.
|
|
6829
|
+
*/
|
|
6830
|
+
__publicField(this, "client");
|
|
6831
|
+
// Renamed back from sdkClient
|
|
6832
|
+
/**
|
|
6833
|
+
* Communication channel (transport layer) for MCP interactions.
|
|
6834
|
+
*/
|
|
6835
|
+
__publicField(this, "transport");
|
|
6680
6836
|
// Renamed back from communicationChannel
|
|
6681
6837
|
/**
|
|
6682
6838
|
* Tracks the connection status to the server.
|
|
6683
6839
|
*/
|
|
6684
|
-
this
|
|
6840
|
+
__publicField(this, "connected", false);
|
|
6841
|
+
// Renamed back from isConnected
|
|
6842
|
+
/**
|
|
6843
|
+
* Maximum time allowed for requests in milliseconds.
|
|
6844
|
+
*/
|
|
6845
|
+
__publicField(this, "timeout");
|
|
6846
|
+
// Renamed back from requestTimeoutMs
|
|
6847
|
+
/**
|
|
6848
|
+
* Information identifying this client to the server.
|
|
6849
|
+
*/
|
|
6850
|
+
__publicField(this, "clientInfo");
|
|
6685
6851
|
this.clientInfo = config.clientInfo;
|
|
6686
6852
|
this.client = new import_client2.Client(this.clientInfo, {
|
|
6687
6853
|
capabilities: config.capabilities || {}
|
|
@@ -6941,10 +7107,14 @@ var MCPConfiguration = class {
|
|
|
6941
7107
|
* @param options Configuration options including server definitions.
|
|
6942
7108
|
*/
|
|
6943
7109
|
constructor(options) {
|
|
7110
|
+
/**
|
|
7111
|
+
* Map of server configurations keyed by server names.
|
|
7112
|
+
*/
|
|
7113
|
+
__publicField(this, "serverConfigs");
|
|
6944
7114
|
/**
|
|
6945
7115
|
* Map of connected MCP clients keyed by server names (local cache).
|
|
6946
7116
|
*/
|
|
6947
|
-
this
|
|
7117
|
+
__publicField(this, "mcpClientsById", /* @__PURE__ */ new Map());
|
|
6948
7118
|
this.serverConfigs = options.servers;
|
|
6949
7119
|
}
|
|
6950
7120
|
/**
|
|
@@ -7192,6 +7362,8 @@ __name(MCPConfiguration, "MCPConfiguration");
|
|
|
7192
7362
|
// src/telemetry/client/index.ts
|
|
7193
7363
|
var TelemetryServiceApiClient = class {
|
|
7194
7364
|
constructor(options) {
|
|
7365
|
+
__publicField(this, "options");
|
|
7366
|
+
__publicField(this, "fetchImplementation");
|
|
7195
7367
|
this.options = options;
|
|
7196
7368
|
this.fetchImplementation = options.fetch || globalThis.fetch;
|
|
7197
7369
|
if (!this.fetchImplementation) {
|
|
@@ -7283,6 +7455,8 @@ __name(TelemetryServiceApiClient, "TelemetryServiceApiClient");
|
|
|
7283
7455
|
// src/telemetry/exporter/index.ts
|
|
7284
7456
|
var VoltAgentExporter = class {
|
|
7285
7457
|
constructor(options) {
|
|
7458
|
+
__publicField(this, "apiClient");
|
|
7459
|
+
__publicField(this, "publicKey");
|
|
7286
7460
|
let baseUrl = options.baseUrl;
|
|
7287
7461
|
if (baseUrl.includes("https://server.voltagent.dev")) {
|
|
7288
7462
|
baseUrl = `${baseUrl}/functions/v1`;
|
|
@@ -7366,7 +7540,8 @@ var isTelemetryInitializedByVoltAgent = false;
|
|
|
7366
7540
|
var registeredProvider = null;
|
|
7367
7541
|
var VoltAgent = class {
|
|
7368
7542
|
constructor(options) {
|
|
7369
|
-
this
|
|
7543
|
+
__publicField(this, "registry");
|
|
7544
|
+
__publicField(this, "serverStarted", false);
|
|
7370
7545
|
this.registry = AgentRegistry.getInstance();
|
|
7371
7546
|
this.registerAgents(options.agents);
|
|
7372
7547
|
if (options.telemetryExporter) {
|