@voltagent/core 0.1.76 → 0.1.77
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 +102 -92
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +98 -88
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -64,7 +64,7 @@ __export(index_exports, {
|
|
|
64
64
|
andWorkflow: () => andWorkflow,
|
|
65
65
|
buildRetrieverLogMessage: () => buildRetrieverLogMessage,
|
|
66
66
|
checkForUpdates: () => checkForUpdates,
|
|
67
|
-
createAsyncIterableStream: () =>
|
|
67
|
+
createAsyncIterableStream: () => import_utils21.createAsyncIterableStream,
|
|
68
68
|
createHooks: () => createHooks,
|
|
69
69
|
createNodeId: () => createNodeId,
|
|
70
70
|
createPrompt: () => createPrompt,
|
|
@@ -1335,7 +1335,7 @@ var WorkflowEventEmitter = class _WorkflowEventEmitter extends import_node_event
|
|
|
1335
1335
|
this.workflowEventQueue.enqueue({
|
|
1336
1336
|
id: `workflow-event-${event.id}`,
|
|
1337
1337
|
operation: /* @__PURE__ */ __name(async () => {
|
|
1338
|
-
const clonedEvent = (0, import_utils.deepClone)(event
|
|
1338
|
+
const clonedEvent = (0, import_utils.deepClone)(event);
|
|
1339
1339
|
await this.publishWorkflowEventSync({
|
|
1340
1340
|
workflowId,
|
|
1341
1341
|
executionId,
|
|
@@ -1425,8 +1425,7 @@ var AgentEventEmitter = class _AgentEventEmitter extends import_node_events3.Eve
|
|
|
1425
1425
|
this.timelineEventQueue.enqueue({
|
|
1426
1426
|
id: `timeline-event-${event.id}`,
|
|
1427
1427
|
operation: /* @__PURE__ */ __name(async () => {
|
|
1428
|
-
const
|
|
1429
|
-
const clonedEvent = (0, import_utils2.deepClone)(event, logger2);
|
|
1428
|
+
const clonedEvent = (0, import_utils2.deepClone)(event);
|
|
1430
1429
|
await this.publishTimelineEventSync({
|
|
1431
1430
|
agentId,
|
|
1432
1431
|
historyId,
|
|
@@ -1909,6 +1908,7 @@ var AgentRegistry = class _AgentRegistry {
|
|
|
1909
1908
|
|
|
1910
1909
|
// src/logger/console-logger.ts
|
|
1911
1910
|
var import_node_events4 = require("events");
|
|
1911
|
+
var import_utils3 = require("@voltagent/internal/utils");
|
|
1912
1912
|
var ConsoleLogger = class _ConsoleLogger {
|
|
1913
1913
|
static {
|
|
1914
1914
|
__name(this, "ConsoleLogger");
|
|
@@ -1927,8 +1927,8 @@ var ConsoleLogger = class _ConsoleLogger {
|
|
|
1927
1927
|
}
|
|
1928
1928
|
formatMessage(level, msg, obj) {
|
|
1929
1929
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
1930
|
-
const contextStr = Object.keys(this.context).length > 0 ? ` ${
|
|
1931
|
-
const objStr = obj ? ` ${
|
|
1930
|
+
const contextStr = Object.keys(this.context).length > 0 ? ` ${(0, import_utils3.safeStringify)(this.context)}` : "";
|
|
1931
|
+
const objStr = obj ? ` ${(0, import_utils3.safeStringify)(obj)}` : "";
|
|
1932
1932
|
return `[${timestamp}] ${level.toUpperCase()}${contextStr}: ${msg}${objStr}`;
|
|
1933
1933
|
}
|
|
1934
1934
|
createLogFn(level, consoleFn) {
|
|
@@ -3029,7 +3029,7 @@ function andWhen({
|
|
|
3029
3029
|
__name(andWhen, "andWhen");
|
|
3030
3030
|
|
|
3031
3031
|
// src/workflow/steps/and-all.ts
|
|
3032
|
-
var
|
|
3032
|
+
var import_utils6 = require("@voltagent/internal/utils");
|
|
3033
3033
|
function andAll({ steps: inputSteps, ...config }) {
|
|
3034
3034
|
return {
|
|
3035
3035
|
...defaultStepConfig(config),
|
|
@@ -3214,7 +3214,7 @@ function getStepsFunc(steps) {
|
|
|
3214
3214
|
}
|
|
3215
3215
|
__name(getStepsFunc, "getStepsFunc");
|
|
3216
3216
|
function isStepsFunction(steps) {
|
|
3217
|
-
return (0,
|
|
3217
|
+
return (0, import_utils6.isFunction)(steps) && !Array.isArray(steps);
|
|
3218
3218
|
}
|
|
3219
3219
|
__name(isStepsFunction, "isStepsFunction");
|
|
3220
3220
|
|
|
@@ -3442,6 +3442,7 @@ var import_node_fs3 = require("fs");
|
|
|
3442
3442
|
var import_node_fs4 = __toESM(require("fs"));
|
|
3443
3443
|
var import_node_path3 = require("path");
|
|
3444
3444
|
var import_client = require("@libsql/client");
|
|
3445
|
+
var import_utils12 = require("@voltagent/internal/utils");
|
|
3445
3446
|
|
|
3446
3447
|
// src/utils/createPrompt/index.ts
|
|
3447
3448
|
var createPrompt = /* @__PURE__ */ __name(({
|
|
@@ -3531,6 +3532,7 @@ var import_node_path2 = __toESM(require("path"));
|
|
|
3531
3532
|
var import_node_crypto2 = __toESM(require("crypto"));
|
|
3532
3533
|
var import_node_fs = __toESM(require("fs"));
|
|
3533
3534
|
var import_node_path = __toESM(require("path"));
|
|
3535
|
+
var import_utils10 = require("@voltagent/internal/utils");
|
|
3534
3536
|
var getCacheFilePath = /* @__PURE__ */ __name((projectPath) => {
|
|
3535
3537
|
return import_node_path.default.join(projectPath, ".voltagent", "cache", "update-check.json");
|
|
3536
3538
|
}, "getCacheFilePath");
|
|
@@ -3569,7 +3571,7 @@ var writeUpdateCache = /* @__PURE__ */ __name(async (projectPath, cache) => {
|
|
|
3569
3571
|
try {
|
|
3570
3572
|
ensureCacheDir(projectPath);
|
|
3571
3573
|
const cacheFilePath = getCacheFilePath(projectPath);
|
|
3572
|
-
import_node_fs.default.writeFileSync(cacheFilePath,
|
|
3574
|
+
import_node_fs.default.writeFileSync(cacheFilePath, (0, import_utils10.safeStringify)(cache, { indentation: 2 }), "utf8");
|
|
3573
3575
|
} catch (error) {
|
|
3574
3576
|
const logger2 = new LoggerProxy({ component: "update-cache" });
|
|
3575
3577
|
logger2.error("Error writing update cache", { error });
|
|
@@ -3882,6 +3884,7 @@ var updateSinglePackage = /* @__PURE__ */ __name(async (packageName, packagePath
|
|
|
3882
3884
|
}, "updateSinglePackage");
|
|
3883
3885
|
|
|
3884
3886
|
// src/utils/serialization/index.ts
|
|
3887
|
+
var import_internal = require("@voltagent/internal");
|
|
3885
3888
|
function safeJsonParse(value) {
|
|
3886
3889
|
if (!value) return void 0;
|
|
3887
3890
|
try {
|
|
@@ -3923,7 +3926,7 @@ function serializeValueForDebug(value) {
|
|
|
3923
3926
|
}
|
|
3924
3927
|
try {
|
|
3925
3928
|
if (Object.getPrototypeOf(value) === Object.prototype) {
|
|
3926
|
-
return
|
|
3929
|
+
return (0, import_internal.deepClone)(value);
|
|
3927
3930
|
}
|
|
3928
3931
|
return `[Object: ${value.constructor?.name || "UnknownClass"}]`;
|
|
3929
3932
|
} catch (e) {
|
|
@@ -4229,6 +4232,7 @@ async function createWorkflowTables(db, tablePrefix = "voltagent_memory") {
|
|
|
4229
4232
|
__name(createWorkflowTables, "createWorkflowTables");
|
|
4230
4233
|
|
|
4231
4234
|
// src/memory/libsql/workflow-extension.ts
|
|
4235
|
+
var import_utils11 = require("@voltagent/internal/utils");
|
|
4232
4236
|
var LibSQLWorkflowExtension = class {
|
|
4233
4237
|
constructor(client, _tablePrefix = "voltagent_memory") {
|
|
4234
4238
|
this.client = client;
|
|
@@ -4257,11 +4261,11 @@ var LibSQLWorkflowExtension = class {
|
|
|
4257
4261
|
entry.status,
|
|
4258
4262
|
entry.startTime.toISOString(),
|
|
4259
4263
|
entry.endTime?.toISOString() || null,
|
|
4260
|
-
|
|
4261
|
-
entry.output ?
|
|
4264
|
+
(0, import_utils11.safeStringify)(entry.input),
|
|
4265
|
+
entry.output ? (0, import_utils11.safeStringify)(entry.output) : null,
|
|
4262
4266
|
entry.userId || null,
|
|
4263
4267
|
entry.conversationId || null,
|
|
4264
|
-
entry.metadata ?
|
|
4268
|
+
entry.metadata ? (0, import_utils11.safeStringify)(entry.metadata) : null,
|
|
4265
4269
|
entry.createdAt?.toISOString() || (/* @__PURE__ */ new Date()).toISOString(),
|
|
4266
4270
|
entry.updatedAt?.toISOString() || (/* @__PURE__ */ new Date()).toISOString()
|
|
4267
4271
|
]
|
|
@@ -4309,7 +4313,7 @@ var LibSQLWorkflowExtension = class {
|
|
|
4309
4313
|
}
|
|
4310
4314
|
if (updates.output !== void 0) {
|
|
4311
4315
|
setClauses.push("output = ?");
|
|
4312
|
-
args.push(
|
|
4316
|
+
args.push((0, import_utils11.safeStringify)(updates.output));
|
|
4313
4317
|
}
|
|
4314
4318
|
if (updates.userId !== void 0) {
|
|
4315
4319
|
setClauses.push("user_id = ?");
|
|
@@ -4321,7 +4325,7 @@ var LibSQLWorkflowExtension = class {
|
|
|
4321
4325
|
}
|
|
4322
4326
|
if (updates.metadata !== void 0) {
|
|
4323
4327
|
setClauses.push("metadata = ?");
|
|
4324
|
-
const metadataJson =
|
|
4328
|
+
const metadataJson = (0, import_utils11.safeStringify)(updates.metadata);
|
|
4325
4329
|
args.push(metadataJson);
|
|
4326
4330
|
this.logger.trace(`Setting metadata for ${id}:`, { metadata: metadataJson });
|
|
4327
4331
|
}
|
|
@@ -4372,13 +4376,13 @@ var LibSQLWorkflowExtension = class {
|
|
|
4372
4376
|
step.status,
|
|
4373
4377
|
step.startTime.toISOString(),
|
|
4374
4378
|
step.endTime?.toISOString() || null,
|
|
4375
|
-
step.input ?
|
|
4376
|
-
step.output ?
|
|
4377
|
-
step.error ?
|
|
4379
|
+
step.input ? (0, import_utils11.safeStringify)(step.input) : null,
|
|
4380
|
+
step.output ? (0, import_utils11.safeStringify)(step.output) : null,
|
|
4381
|
+
step.error ? (0, import_utils11.safeStringify)(step.error) : null,
|
|
4378
4382
|
step.agentExecutionId || null,
|
|
4379
4383
|
step.parallelIndex || null,
|
|
4380
4384
|
step.parallelParentStepId || null,
|
|
4381
|
-
step.metadata ?
|
|
4385
|
+
step.metadata ? (0, import_utils11.safeStringify)(step.metadata) : null,
|
|
4382
4386
|
step.createdAt?.toISOString() || (/* @__PURE__ */ new Date()).toISOString(),
|
|
4383
4387
|
step.updatedAt?.toISOString() || (/* @__PURE__ */ new Date()).toISOString()
|
|
4384
4388
|
]
|
|
@@ -4421,11 +4425,11 @@ var LibSQLWorkflowExtension = class {
|
|
|
4421
4425
|
}
|
|
4422
4426
|
if (updates.output !== void 0) {
|
|
4423
4427
|
setClauses.push("output = ?");
|
|
4424
|
-
args.push(
|
|
4428
|
+
args.push((0, import_utils11.safeStringify)(updates.output));
|
|
4425
4429
|
}
|
|
4426
4430
|
if (updates.error !== void 0) {
|
|
4427
4431
|
setClauses.push("error_message = ?");
|
|
4428
|
-
args.push(
|
|
4432
|
+
args.push((0, import_utils11.safeStringify)(updates.error));
|
|
4429
4433
|
}
|
|
4430
4434
|
if (updates.agentExecutionId !== void 0) {
|
|
4431
4435
|
setClauses.push("agent_execution_id = ?");
|
|
@@ -4433,7 +4437,7 @@ var LibSQLWorkflowExtension = class {
|
|
|
4433
4437
|
}
|
|
4434
4438
|
if (updates.metadata !== void 0) {
|
|
4435
4439
|
setClauses.push("metadata = ?");
|
|
4436
|
-
args.push(
|
|
4440
|
+
args.push((0, import_utils11.safeStringify)(updates.metadata));
|
|
4437
4441
|
}
|
|
4438
4442
|
setClauses.push("updated_at = ?");
|
|
4439
4443
|
args.push((/* @__PURE__ */ new Date()).toISOString());
|
|
@@ -4474,10 +4478,10 @@ var LibSQLWorkflowExtension = class {
|
|
|
4474
4478
|
event.endTime || null,
|
|
4475
4479
|
event.status,
|
|
4476
4480
|
event.level || "INFO",
|
|
4477
|
-
event.input ?
|
|
4478
|
-
event.output ?
|
|
4479
|
-
event.statusMessage ?
|
|
4480
|
-
event.metadata ?
|
|
4481
|
+
event.input ? (0, import_utils11.safeStringify)(event.input) : null,
|
|
4482
|
+
event.output ? (0, import_utils11.safeStringify)(event.output) : null,
|
|
4483
|
+
event.statusMessage ? (0, import_utils11.safeStringify)(event.statusMessage) : null,
|
|
4484
|
+
event.metadata ? (0, import_utils11.safeStringify)(event.metadata) : null,
|
|
4481
4485
|
event.traceId || null,
|
|
4482
4486
|
event.parentEventId || null,
|
|
4483
4487
|
event.eventSequence || null,
|
|
@@ -5110,7 +5114,7 @@ var LibSQLStorage = class {
|
|
|
5110
5114
|
await this.initialized;
|
|
5111
5115
|
await debugDelay();
|
|
5112
5116
|
const tableName = `${this.options.tablePrefix}_messages`;
|
|
5113
|
-
const contentString =
|
|
5117
|
+
const contentString = (0, import_utils12.safeStringify)(message.content);
|
|
5114
5118
|
await this.executeWithRetryStrategy(async () => {
|
|
5115
5119
|
await this.client.execute({
|
|
5116
5120
|
sql: `INSERT INTO ${tableName} (conversation_id, message_id, role, content, type, created_at)
|
|
@@ -5220,10 +5224,10 @@ var LibSQLStorage = class {
|
|
|
5220
5224
|
await this.initialized;
|
|
5221
5225
|
try {
|
|
5222
5226
|
const tableName = `${this.options.tablePrefix}_agent_history`;
|
|
5223
|
-
const inputJSON = value.input ?
|
|
5224
|
-
const outputJSON = value.output ?
|
|
5225
|
-
const usageJSON = value.usage ?
|
|
5226
|
-
const metadataJSON = value.metadata ?
|
|
5227
|
+
const inputJSON = value.input ? (0, import_utils12.safeStringify)(value.input) : null;
|
|
5228
|
+
const outputJSON = value.output ? (0, import_utils12.safeStringify)(value.output) : null;
|
|
5229
|
+
const usageJSON = value.usage ? (0, import_utils12.safeStringify)(value.usage) : null;
|
|
5230
|
+
const metadataJSON = value.metadata ? (0, import_utils12.safeStringify)(value.metadata) : null;
|
|
5227
5231
|
await this.client.execute({
|
|
5228
5232
|
sql: `INSERT OR REPLACE INTO ${tableName}
|
|
5229
5233
|
(id, agent_id, timestamp, status, input, output, usage, metadata, userId, conversationId)
|
|
@@ -5277,7 +5281,7 @@ var LibSQLStorage = class {
|
|
|
5277
5281
|
await this.initialized;
|
|
5278
5282
|
try {
|
|
5279
5283
|
const tableName = `${this.options.tablePrefix}_agent_history_steps`;
|
|
5280
|
-
const serializedValue =
|
|
5284
|
+
const serializedValue = (0, import_utils12.safeStringify)(value);
|
|
5281
5285
|
await this.client.execute({
|
|
5282
5286
|
sql: `INSERT OR REPLACE INTO ${tableName} (key, value, history_id, agent_id) VALUES (?, ?, ?, ?)`,
|
|
5283
5287
|
args: [key, serializedValue, historyId, agentId]
|
|
@@ -5309,11 +5313,11 @@ var LibSQLStorage = class {
|
|
|
5309
5313
|
await this.initialized;
|
|
5310
5314
|
try {
|
|
5311
5315
|
const tableName = `${this.options.tablePrefix}_agent_history_timeline_events`;
|
|
5312
|
-
const inputJSON = value.input ?
|
|
5313
|
-
const outputJSON = value.output ?
|
|
5314
|
-
const statusMessageJSON = value.statusMessage ?
|
|
5315
|
-
const metadataJSON = value.metadata ?
|
|
5316
|
-
const tagsJSON = value.tags ?
|
|
5316
|
+
const inputJSON = value.input ? (0, import_utils12.safeStringify)(value.input) : null;
|
|
5317
|
+
const outputJSON = value.output ? (0, import_utils12.safeStringify)(value.output) : null;
|
|
5318
|
+
const statusMessageJSON = value.statusMessage ? (0, import_utils12.safeStringify)(value.statusMessage) : null;
|
|
5319
|
+
const metadataJSON = value.metadata ? (0, import_utils12.safeStringify)(value.metadata) : null;
|
|
5320
|
+
const tagsJSON = value.tags ? (0, import_utils12.safeStringify)(value.tags) : null;
|
|
5317
5321
|
await this.client.execute({
|
|
5318
5322
|
sql: `INSERT OR REPLACE INTO ${tableName}
|
|
5319
5323
|
(id, history_id, agent_id, event_type, event_name,
|
|
@@ -5465,7 +5469,7 @@ var LibSQLStorage = class {
|
|
|
5465
5469
|
await this.initialized;
|
|
5466
5470
|
await debugDelay();
|
|
5467
5471
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
5468
|
-
const metadataString =
|
|
5472
|
+
const metadataString = (0, import_utils12.safeStringify)(conversation.metadata);
|
|
5469
5473
|
const tableName = `${this.options.tablePrefix}_conversations`;
|
|
5470
5474
|
return await this.executeWithRetryStrategy(async () => {
|
|
5471
5475
|
await this.client.execute({
|
|
@@ -5698,7 +5702,7 @@ var LibSQLStorage = class {
|
|
|
5698
5702
|
}
|
|
5699
5703
|
if (updates.metadata !== void 0) {
|
|
5700
5704
|
updatesList.push("metadata = ?");
|
|
5701
|
-
args.push(
|
|
5705
|
+
args.push((0, import_utils12.safeStringify)(updates.metadata));
|
|
5702
5706
|
}
|
|
5703
5707
|
updatesList.push("updated_at = ?");
|
|
5704
5708
|
args.push(now);
|
|
@@ -5955,9 +5959,9 @@ var LibSQLStorage = class {
|
|
|
5955
5959
|
}
|
|
5956
5960
|
migratedIds.add(id);
|
|
5957
5961
|
migratedCount++;
|
|
5958
|
-
const inputJSON = valueObj.input ?
|
|
5959
|
-
const outputJSON = valueObj.output ?
|
|
5960
|
-
const usageJSON = valueObj.usage ?
|
|
5962
|
+
const inputJSON = valueObj.input ? (0, import_utils12.safeStringify)(valueObj.input) : null;
|
|
5963
|
+
const outputJSON = valueObj.output ? (0, import_utils12.safeStringify)(valueObj.output) : null;
|
|
5964
|
+
const usageJSON = valueObj.usage ? (0, import_utils12.safeStringify)(valueObj.usage) : null;
|
|
5961
5965
|
await this.client.execute({
|
|
5962
5966
|
sql: `INSERT INTO ${tempTableName}
|
|
5963
5967
|
(id, agent_id, timestamp, status, input, output, usage, metadata)
|
|
@@ -5989,18 +5993,18 @@ var LibSQLStorage = class {
|
|
|
5989
5993
|
let status = event.status || event.data?.status || null;
|
|
5990
5994
|
let inputData = null;
|
|
5991
5995
|
if (event.input) {
|
|
5992
|
-
inputData =
|
|
5996
|
+
inputData = (0, import_utils12.safeStringify)({ input: event.input });
|
|
5993
5997
|
} else if (event.data?.input) {
|
|
5994
|
-
inputData =
|
|
5998
|
+
inputData = (0, import_utils12.safeStringify)({ input: event.data.input });
|
|
5995
5999
|
} else if (input) {
|
|
5996
|
-
inputData =
|
|
6000
|
+
inputData = (0, import_utils12.safeStringify)({ input });
|
|
5997
6001
|
}
|
|
5998
6002
|
input = "";
|
|
5999
6003
|
let metadata = null;
|
|
6000
6004
|
if (event.metadata) {
|
|
6001
|
-
metadata =
|
|
6005
|
+
metadata = (0, import_utils12.safeStringify)(event.metadata);
|
|
6002
6006
|
} else if (event.data) {
|
|
6003
|
-
metadata =
|
|
6007
|
+
metadata = (0, import_utils12.safeStringify)({
|
|
6004
6008
|
id: event.affectedNodeId?.split("_").pop(),
|
|
6005
6009
|
agentId: event.data?.metadata?.sourceAgentId,
|
|
6006
6010
|
...event.data
|
|
@@ -6040,8 +6044,8 @@ var LibSQLStorage = class {
|
|
|
6040
6044
|
null,
|
|
6041
6045
|
// tags
|
|
6042
6046
|
inputData,
|
|
6043
|
-
event.data.output ?
|
|
6044
|
-
eventName === "agent:error" ?
|
|
6047
|
+
event.data.output ? (0, import_utils12.safeStringify)(event.data.output) : null,
|
|
6048
|
+
eventName === "agent:error" ? (0, import_utils12.safeStringify)(event.data.error) : null,
|
|
6045
6049
|
metadata
|
|
6046
6050
|
]
|
|
6047
6051
|
});
|
|
@@ -6074,7 +6078,7 @@ var LibSQLStorage = class {
|
|
|
6074
6078
|
// no output
|
|
6075
6079
|
null,
|
|
6076
6080
|
// no error
|
|
6077
|
-
|
|
6081
|
+
(0, import_utils12.safeStringify)({
|
|
6078
6082
|
id: "memory",
|
|
6079
6083
|
agentId: event.affectedNodeId?.split("_").pop()
|
|
6080
6084
|
})
|
|
@@ -6105,9 +6109,9 @@ var LibSQLStorage = class {
|
|
|
6105
6109
|
null,
|
|
6106
6110
|
// tags
|
|
6107
6111
|
inputData,
|
|
6108
|
-
event.data.output ?
|
|
6109
|
-
event.error ?
|
|
6110
|
-
|
|
6112
|
+
event.data.output ? (0, import_utils12.safeStringify)(event.data.output) : null,
|
|
6113
|
+
event.error ? (0, import_utils12.safeStringify)(event.error) : null,
|
|
6114
|
+
(0, import_utils12.safeStringify)({
|
|
6111
6115
|
id: "memory",
|
|
6112
6116
|
agentId: event.affectedNodeId?.split("_").pop()
|
|
6113
6117
|
})
|
|
@@ -6141,7 +6145,7 @@ var LibSQLStorage = class {
|
|
|
6141
6145
|
// no output
|
|
6142
6146
|
null,
|
|
6143
6147
|
// no error
|
|
6144
|
-
|
|
6148
|
+
(0, import_utils12.safeStringify)({
|
|
6145
6149
|
id: "memory",
|
|
6146
6150
|
agentId: event.affectedNodeId?.split("_").pop()
|
|
6147
6151
|
})
|
|
@@ -6172,9 +6176,9 @@ var LibSQLStorage = class {
|
|
|
6172
6176
|
null,
|
|
6173
6177
|
// tags
|
|
6174
6178
|
inputData,
|
|
6175
|
-
event.data.output ?
|
|
6176
|
-
event.error ?
|
|
6177
|
-
|
|
6179
|
+
event.data.output ? (0, import_utils12.safeStringify)(event.data.output) : null,
|
|
6180
|
+
event.error ? (0, import_utils12.safeStringify)(event.error) : null,
|
|
6181
|
+
(0, import_utils12.safeStringify)({
|
|
6178
6182
|
id: "memory",
|
|
6179
6183
|
agentId: event.affectedNodeId?.split("_").pop()
|
|
6180
6184
|
})
|
|
@@ -6203,8 +6207,8 @@ var LibSQLStorage = class {
|
|
|
6203
6207
|
null,
|
|
6204
6208
|
// tags
|
|
6205
6209
|
inputData,
|
|
6206
|
-
event.output ?
|
|
6207
|
-
event.error ?
|
|
6210
|
+
event.output ? (0, import_utils12.safeStringify)(event.output) : null,
|
|
6211
|
+
event.error ? (0, import_utils12.safeStringify)(event.error) : null,
|
|
6208
6212
|
metadata
|
|
6209
6213
|
]
|
|
6210
6214
|
});
|
|
@@ -6238,7 +6242,7 @@ var LibSQLStorage = class {
|
|
|
6238
6242
|
// no output
|
|
6239
6243
|
null,
|
|
6240
6244
|
// no error
|
|
6241
|
-
|
|
6245
|
+
(0, import_utils12.safeStringify)({
|
|
6242
6246
|
id: event.affectedNodeId?.split("_").pop(),
|
|
6243
6247
|
agentId: event.data?.metadata?.sourceAgentId,
|
|
6244
6248
|
displayName: event.data.metadata.toolName
|
|
@@ -6270,9 +6274,9 @@ var LibSQLStorage = class {
|
|
|
6270
6274
|
null,
|
|
6271
6275
|
// tags
|
|
6272
6276
|
inputData,
|
|
6273
|
-
event.data.output ?
|
|
6274
|
-
event.error ?
|
|
6275
|
-
|
|
6277
|
+
event.data.output ? (0, import_utils12.safeStringify)(event.data.output) : null,
|
|
6278
|
+
event.error ? (0, import_utils12.safeStringify)(event.error) : null,
|
|
6279
|
+
(0, import_utils12.safeStringify)({
|
|
6276
6280
|
id: event.affectedNodeId?.split("_").pop(),
|
|
6277
6281
|
agentId: event.data?.metadata?.sourceAgentId,
|
|
6278
6282
|
displayName: event.data.metadata.toolName
|
|
@@ -6303,9 +6307,9 @@ var LibSQLStorage = class {
|
|
|
6303
6307
|
null,
|
|
6304
6308
|
// tags
|
|
6305
6309
|
inputData,
|
|
6306
|
-
event.output ?
|
|
6307
|
-
event.error ?
|
|
6308
|
-
|
|
6310
|
+
event.output ? (0, import_utils12.safeStringify)(event.output) : null,
|
|
6311
|
+
event.error ? (0, import_utils12.safeStringify)(event.error) : null,
|
|
6312
|
+
(0, import_utils12.safeStringify)({
|
|
6309
6313
|
id: eventType === "retriever" ? "retriever" : event.type,
|
|
6310
6314
|
agentId: event.affectedNodeId?.split("_").pop()
|
|
6311
6315
|
})
|
|
@@ -6556,7 +6560,7 @@ var LibSQLStorage = class {
|
|
|
6556
6560
|
userId,
|
|
6557
6561
|
"Migrated Conversation",
|
|
6558
6562
|
// Default title
|
|
6559
|
-
|
|
6563
|
+
(0, import_utils12.safeStringify)({}),
|
|
6560
6564
|
// Empty metadata
|
|
6561
6565
|
now,
|
|
6562
6566
|
now
|
|
@@ -7971,9 +7975,11 @@ function createSuspendController() {
|
|
|
7971
7975
|
__name(createSuspendController, "createSuspendController");
|
|
7972
7976
|
|
|
7973
7977
|
// src/agent/agent.ts
|
|
7978
|
+
var import_utils19 = require("@voltagent/internal/utils");
|
|
7974
7979
|
var import_ts_pattern3 = require("ts-pattern");
|
|
7975
7980
|
|
|
7976
7981
|
// src/memory/in-memory/index.ts
|
|
7982
|
+
var import_utils15 = require("@voltagent/internal/utils");
|
|
7977
7983
|
var InMemoryStorage = class {
|
|
7978
7984
|
static {
|
|
7979
7985
|
__name(this, "InMemoryStorage");
|
|
@@ -8033,7 +8039,7 @@ var InMemoryStorage = class {
|
|
|
8033
8039
|
async getHistoryEntry(key) {
|
|
8034
8040
|
this.debug(`Getting history entry with key ${key}`);
|
|
8035
8041
|
const entry = this.historyEntries.get(key);
|
|
8036
|
-
return entry ?
|
|
8042
|
+
return entry ? (0, import_utils15.deepClone)(entry) : void 0;
|
|
8037
8043
|
}
|
|
8038
8044
|
/**
|
|
8039
8045
|
* Get a history step by ID
|
|
@@ -8041,7 +8047,7 @@ var InMemoryStorage = class {
|
|
|
8041
8047
|
async getHistoryStep(key) {
|
|
8042
8048
|
this.debug(`Getting history step with key ${key}`);
|
|
8043
8049
|
const step = this.historySteps.get(key);
|
|
8044
|
-
return step ?
|
|
8050
|
+
return step ? (0, import_utils15.deepClone)(step) : void 0;
|
|
8045
8051
|
}
|
|
8046
8052
|
/**
|
|
8047
8053
|
* Add a history entry
|
|
@@ -8147,7 +8153,7 @@ var InMemoryStorage = class {
|
|
|
8147
8153
|
);
|
|
8148
8154
|
const entryKeys = this.agentHistory[agentId] || [];
|
|
8149
8155
|
const entries = entryKeys.map((key) => this.historyEntries.get(key)).filter(Boolean);
|
|
8150
|
-
const sortedEntries = entries.map((entry) =>
|
|
8156
|
+
const sortedEntries = entries.map((entry) => (0, import_utils15.deepClone)(entry)).sort((a, b) => {
|
|
8151
8157
|
const aTime = new Date(a.timestamp || a.createdAt || 0).getTime();
|
|
8152
8158
|
const bTime = new Date(b.timestamp || b.createdAt || 0).getTime();
|
|
8153
8159
|
return bTime - aTime;
|
|
@@ -8569,7 +8575,7 @@ var InMemoryStorage = class {
|
|
|
8569
8575
|
async getWorkflowHistory(id) {
|
|
8570
8576
|
this.debug(`Getting workflow history entry ${id}`);
|
|
8571
8577
|
const entry = this.workflowHistories.get(id);
|
|
8572
|
-
return entry ?
|
|
8578
|
+
return entry ? (0, import_utils15.deepClone)(entry) : null;
|
|
8573
8579
|
}
|
|
8574
8580
|
/**
|
|
8575
8581
|
* Get all workflow history entries for a specific workflow ID
|
|
@@ -8578,7 +8584,7 @@ var InMemoryStorage = class {
|
|
|
8578
8584
|
this.debug(`Getting workflow history entries for workflow ${workflowId}`);
|
|
8579
8585
|
const historyIds = this.workflowHistoryIndex[workflowId] || [];
|
|
8580
8586
|
const entries = historyIds.map((id) => this.workflowHistories.get(id)).filter(Boolean);
|
|
8581
|
-
return entries.map((entry) =>
|
|
8587
|
+
return entries.map((entry) => (0, import_utils15.deepClone)(entry)).sort((a, b) => new Date(b.startTime).getTime() - new Date(a.startTime).getTime());
|
|
8582
8588
|
}
|
|
8583
8589
|
/**
|
|
8584
8590
|
* Update a workflow history entry
|
|
@@ -8645,7 +8651,7 @@ var InMemoryStorage = class {
|
|
|
8645
8651
|
async getWorkflowStep(id) {
|
|
8646
8652
|
this.debug(`Getting workflow step ${id}`);
|
|
8647
8653
|
const step = this.workflowSteps.get(id);
|
|
8648
|
-
return step ?
|
|
8654
|
+
return step ? (0, import_utils15.deepClone)(step) : null;
|
|
8649
8655
|
}
|
|
8650
8656
|
/**
|
|
8651
8657
|
* Get all workflow steps for a workflow history entry
|
|
@@ -8655,7 +8661,7 @@ var InMemoryStorage = class {
|
|
|
8655
8661
|
const steps = Array.from(this.workflowSteps.values()).filter(
|
|
8656
8662
|
(step) => step.workflowHistoryId === workflowHistoryId
|
|
8657
8663
|
);
|
|
8658
|
-
return steps.map((step) =>
|
|
8664
|
+
return steps.map((step) => (0, import_utils15.deepClone)(step)).sort((a, b) => a.stepIndex - b.stepIndex);
|
|
8659
8665
|
}
|
|
8660
8666
|
/**
|
|
8661
8667
|
* Update a workflow step entry
|
|
@@ -8745,7 +8751,7 @@ var InMemoryStorage = class {
|
|
|
8745
8751
|
async getWorkflowTimelineEvent(id) {
|
|
8746
8752
|
this.debug(`Getting workflow timeline event ${id}`);
|
|
8747
8753
|
const event = this.workflowTimelineEvents.get(id);
|
|
8748
|
-
return event ?
|
|
8754
|
+
return event ? (0, import_utils15.deepClone)(event) : null;
|
|
8749
8755
|
}
|
|
8750
8756
|
/**
|
|
8751
8757
|
* Get all workflow timeline events for a workflow history entry
|
|
@@ -8755,9 +8761,9 @@ var InMemoryStorage = class {
|
|
|
8755
8761
|
const events = Array.from(this.workflowTimelineEvents.values()).filter(
|
|
8756
8762
|
(event) => event.workflowHistoryId === workflowHistoryId
|
|
8757
8763
|
);
|
|
8758
|
-
return events.map((event) =>
|
|
8764
|
+
return events.map((event) => (0, import_utils15.deepClone)(event)).sort((a, b) => {
|
|
8759
8765
|
if (a.eventSequence !== b.eventSequence) {
|
|
8760
|
-
return a.eventSequence - b.eventSequence;
|
|
8766
|
+
return (a.eventSequence ?? 0) - (b.eventSequence ?? 0);
|
|
8761
8767
|
}
|
|
8762
8768
|
return new Date(a.startTime).getTime() - new Date(b.startTime).getTime();
|
|
8763
8769
|
});
|
|
@@ -8820,7 +8826,7 @@ var InMemoryStorage = class {
|
|
|
8820
8826
|
if (!entry) {
|
|
8821
8827
|
return null;
|
|
8822
8828
|
}
|
|
8823
|
-
return
|
|
8829
|
+
return (0, import_utils15.deepClone)(entry);
|
|
8824
8830
|
}
|
|
8825
8831
|
/**
|
|
8826
8832
|
* Delete workflow history with all related steps and events
|
|
@@ -9977,6 +9983,7 @@ function transformStreamEventToStreamPart(event) {
|
|
|
9977
9983
|
__name(transformStreamEventToStreamPart, "transformStreamEventToStreamPart");
|
|
9978
9984
|
|
|
9979
9985
|
// src/telemetry/client/index.ts
|
|
9986
|
+
var import_utils16 = require("@voltagent/internal/utils");
|
|
9980
9987
|
var TelemetryServiceApiClient = class {
|
|
9981
9988
|
static {
|
|
9982
9989
|
__name(this, "TelemetryServiceApiClient");
|
|
@@ -10009,7 +10016,7 @@ var TelemetryServiceApiClient = class {
|
|
|
10009
10016
|
const response = await this.fetchImplementation(url, {
|
|
10010
10017
|
method,
|
|
10011
10018
|
headers,
|
|
10012
|
-
body: body ?
|
|
10019
|
+
body: body ? (0, import_utils16.safeStringify)(body) : void 0
|
|
10013
10020
|
});
|
|
10014
10021
|
if (!response.ok) {
|
|
10015
10022
|
let errorBody;
|
|
@@ -10019,7 +10026,7 @@ var TelemetryServiceApiClient = class {
|
|
|
10019
10026
|
errorBody = await response.text();
|
|
10020
10027
|
}
|
|
10021
10028
|
throw new Error(
|
|
10022
|
-
`API request failed: ${response.status} ${response.statusText} - ${
|
|
10029
|
+
`API request failed: ${response.status} ${response.statusText} - ${(0, import_utils16.safeStringify)(errorBody)}`
|
|
10023
10030
|
);
|
|
10024
10031
|
}
|
|
10025
10032
|
return await response.json();
|
|
@@ -11182,6 +11189,7 @@ __name(createHooks, "createHooks");
|
|
|
11182
11189
|
|
|
11183
11190
|
// src/agent/open-telemetry/index.ts
|
|
11184
11191
|
var import_api = require("@opentelemetry/api");
|
|
11192
|
+
var import_utils17 = require("@voltagent/internal/utils");
|
|
11185
11193
|
var tracer = import_api.trace.getTracer("voltagent-core", "0.1.0");
|
|
11186
11194
|
function startOperationSpan(options) {
|
|
11187
11195
|
const {
|
|
@@ -11224,10 +11232,10 @@ function endOperationSpan(options, logger2) {
|
|
|
11224
11232
|
try {
|
|
11225
11233
|
const attributes = {};
|
|
11226
11234
|
if (data.input) {
|
|
11227
|
-
attributes["ai.prompt.messages"] = typeof data.input === "string" ? data.input :
|
|
11235
|
+
attributes["ai.prompt.messages"] = typeof data.input === "string" ? data.input : (0, import_utils17.safeStringify)(data.input);
|
|
11228
11236
|
}
|
|
11229
11237
|
if (data.output) {
|
|
11230
|
-
attributes["ai.response.text"] = typeof data.output === "string" ? data.output :
|
|
11238
|
+
attributes["ai.response.text"] = typeof data.output === "string" ? data.output : (0, import_utils17.safeStringify)(data.output);
|
|
11231
11239
|
}
|
|
11232
11240
|
if (data.usage && typeof data.usage === "object") {
|
|
11233
11241
|
const usageInfo = data.usage;
|
|
@@ -11240,7 +11248,7 @@ function endOperationSpan(options, logger2) {
|
|
|
11240
11248
|
if (data.metadata && typeof data.metadata === "object") {
|
|
11241
11249
|
for (const [key, value] of Object.entries(data.metadata)) {
|
|
11242
11250
|
if (value != null && typeof key === "string" && !key.startsWith("internal.")) {
|
|
11243
|
-
attributes[`metadata.${key}`] = typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? value :
|
|
11251
|
+
attributes[`metadata.${key}`] = typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? value : (0, import_utils17.safeStringify)(value);
|
|
11244
11252
|
}
|
|
11245
11253
|
}
|
|
11246
11254
|
}
|
|
@@ -11282,7 +11290,7 @@ function startToolSpan(options) {
|
|
|
11282
11290
|
attributes: {
|
|
11283
11291
|
"tool.call.id": toolCallId,
|
|
11284
11292
|
"tool.name": toolName,
|
|
11285
|
-
"tool.arguments": toolInput ?
|
|
11293
|
+
"tool.arguments": toolInput ? (0, import_utils17.safeStringify)(toolInput) : void 0,
|
|
11286
11294
|
"agent.id": agentId
|
|
11287
11295
|
}
|
|
11288
11296
|
},
|
|
@@ -11301,7 +11309,7 @@ function endToolSpan(options, logger2) {
|
|
|
11301
11309
|
const toolResultContent = resultData.result ?? resultData.content;
|
|
11302
11310
|
const toolError = resultData.result?.error ?? resultData.error;
|
|
11303
11311
|
const isError = Boolean(toolError);
|
|
11304
|
-
span.setAttribute("tool.result",
|
|
11312
|
+
span.setAttribute("tool.result", (0, import_utils17.safeStringify)(toolResultContent));
|
|
11305
11313
|
if (isError) {
|
|
11306
11314
|
const errorMessage = toolError?.message || String(toolError || "Unknown tool error");
|
|
11307
11315
|
span.setAttribute("tool.error.message", errorMessage);
|
|
@@ -11326,6 +11334,7 @@ function endToolSpan(options, logger2) {
|
|
|
11326
11334
|
__name(endToolSpan, "endToolSpan");
|
|
11327
11335
|
|
|
11328
11336
|
// src/agent/subagent/index.ts
|
|
11337
|
+
var import_utils18 = require("@voltagent/internal/utils");
|
|
11329
11338
|
var import_zod2 = require("zod");
|
|
11330
11339
|
var SubAgentManager = class {
|
|
11331
11340
|
static {
|
|
@@ -11535,7 +11544,7 @@ ${guidelinesText}
|
|
|
11535
11544
|
taskContent = `Task handed off from ${sourceAgent?.name || this.agentName} to ${targetAgent.name}:
|
|
11536
11545
|
${task}
|
|
11537
11546
|
|
|
11538
|
-
Context: ${
|
|
11547
|
+
Context: ${(0, import_utils18.safeStringify)(context, { indentation: 2 })}`;
|
|
11539
11548
|
}
|
|
11540
11549
|
const taskMessage = {
|
|
11541
11550
|
role: "user",
|
|
@@ -11576,7 +11585,7 @@ Context: ${JSON.stringify(context, null, 2)}`;
|
|
|
11576
11585
|
schema,
|
|
11577
11586
|
callOptions
|
|
11578
11587
|
);
|
|
11579
|
-
finalResult =
|
|
11588
|
+
finalResult = (0, import_utils18.safeStringify)(response.object);
|
|
11580
11589
|
finalMessages = [taskMessage, { role: "assistant", content: finalResult }];
|
|
11581
11590
|
} else if (method === "streamObject") {
|
|
11582
11591
|
if (!schema) {
|
|
@@ -11595,7 +11604,7 @@ Context: ${JSON.stringify(context, null, 2)}`;
|
|
|
11595
11604
|
finalObject = part;
|
|
11596
11605
|
}
|
|
11597
11606
|
}
|
|
11598
|
-
finalResult =
|
|
11607
|
+
finalResult = (0, import_utils18.safeStringify)(finalObject);
|
|
11599
11608
|
finalMessages = [taskMessage, { role: "assistant", content: finalResult }];
|
|
11600
11609
|
} else {
|
|
11601
11610
|
const streamResponse = await targetAgent.streamText(
|
|
@@ -14126,7 +14135,7 @@ ${retrieverContext}`;
|
|
|
14126
14135
|
// Link to the agent:start event
|
|
14127
14136
|
};
|
|
14128
14137
|
this.publishTimelineEvent(operationContext, agentSuccessEvent);
|
|
14129
|
-
const responseStr =
|
|
14138
|
+
const responseStr = (0, import_utils19.safeStringify)(response.object);
|
|
14130
14139
|
this.addAgentEvent(operationContext, "finished", "completed", {
|
|
14131
14140
|
output: responseStr,
|
|
14132
14141
|
usage: response.usage,
|
|
@@ -14432,7 +14441,7 @@ ${retrieverContext}`;
|
|
|
14432
14441
|
// Link to the agent:start event
|
|
14433
14442
|
};
|
|
14434
14443
|
this.publishTimelineEvent(operationContext, agentSuccessEvent);
|
|
14435
|
-
const responseStr =
|
|
14444
|
+
const responseStr = (0, import_utils19.safeStringify)(result.object);
|
|
14436
14445
|
this.addAgentEvent(operationContext, "finished", "completed", {
|
|
14437
14446
|
input: messages,
|
|
14438
14447
|
output: responseStr,
|
|
@@ -16691,6 +16700,7 @@ function validateCustomEndpoints(endpoints) {
|
|
|
16691
16700
|
__name(validateCustomEndpoints, "validateCustomEndpoints");
|
|
16692
16701
|
|
|
16693
16702
|
// src/server/log-stream.ts
|
|
16703
|
+
var import_utils20 = require("@voltagent/internal/utils");
|
|
16694
16704
|
var LogStreamManager = class {
|
|
16695
16705
|
static {
|
|
16696
16706
|
__name(this, "LogStreamManager");
|
|
@@ -16784,7 +16794,7 @@ var LogStreamManager = class {
|
|
|
16784
16794
|
sendToClient(client, data) {
|
|
16785
16795
|
try {
|
|
16786
16796
|
if (client.ws.readyState === client.ws.OPEN) {
|
|
16787
|
-
client.ws.send(
|
|
16797
|
+
client.ws.send((0, import_utils20.safeStringify)(data));
|
|
16788
16798
|
}
|
|
16789
16799
|
} catch (error) {
|
|
16790
16800
|
this.logger.error("Failed to send log to client", { error });
|
|
@@ -18930,7 +18940,7 @@ https://voltagent.dev/docs/observability/developer-console/#migration-guide-from
|
|
|
18930
18940
|
};
|
|
18931
18941
|
|
|
18932
18942
|
// src/index.ts
|
|
18933
|
-
var
|
|
18943
|
+
var import_utils21 = require("@voltagent/internal/utils");
|
|
18934
18944
|
// Annotate the CommonJS export names for ESM import in node:
|
|
18935
18945
|
0 && (module.exports = {
|
|
18936
18946
|
Agent,
|