@voltagent/core 1.2.12 → 1.2.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.js +149 -76
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +154 -81
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -253,7 +253,7 @@ __export(index_exports, {
|
|
|
253
253
|
context: () => import_api8.context,
|
|
254
254
|
convertUsage: () => convertUsage,
|
|
255
255
|
cosineSimilarity: () => cosineSimilarity,
|
|
256
|
-
createAsyncIterableStream: () =>
|
|
256
|
+
createAsyncIterableStream: () => import_utils20.createAsyncIterableStream,
|
|
257
257
|
createDefaultInputSafetyGuardrails: () => createDefaultInputSafetyGuardrails,
|
|
258
258
|
createDefaultPIIGuardrails: () => createDefaultPIIGuardrails,
|
|
259
259
|
createDefaultSafetyGuardrails: () => createDefaultSafetyGuardrails,
|
|
@@ -7370,7 +7370,7 @@ __name(createWorkflowChain, "createWorkflowChain");
|
|
|
7370
7370
|
|
|
7371
7371
|
// src/agent/agent.ts
|
|
7372
7372
|
var import_api15 = require("@opentelemetry/api");
|
|
7373
|
-
var
|
|
7373
|
+
var import_utils18 = require("@voltagent/internal/utils");
|
|
7374
7374
|
var import_ai4 = require("ai");
|
|
7375
7375
|
var import_zod3 = require("zod");
|
|
7376
7376
|
|
|
@@ -11072,6 +11072,70 @@ var createVoltOpsClient = /* @__PURE__ */ __name((options) => {
|
|
|
11072
11072
|
return new VoltOpsClient(options);
|
|
11073
11073
|
}, "createVoltOpsClient");
|
|
11074
11074
|
|
|
11075
|
+
// src/agent/error-utils.ts
|
|
11076
|
+
var import_utils11 = require("@voltagent/internal/utils");
|
|
11077
|
+
function buildToolErrorResult(error, toolCallId, toolName) {
|
|
11078
|
+
const errorResult = {
|
|
11079
|
+
error: true,
|
|
11080
|
+
name: error.name,
|
|
11081
|
+
message: error.message,
|
|
11082
|
+
stack: error.stack,
|
|
11083
|
+
toolCallId,
|
|
11084
|
+
toolName
|
|
11085
|
+
};
|
|
11086
|
+
const cause = error.cause;
|
|
11087
|
+
if (cause !== void 0) {
|
|
11088
|
+
errorResult.cause = cause instanceof Error ? {
|
|
11089
|
+
name: cause.name,
|
|
11090
|
+
message: cause.message,
|
|
11091
|
+
stack: cause.stack
|
|
11092
|
+
} : sanitizeErrorValue(cause);
|
|
11093
|
+
}
|
|
11094
|
+
for (const key of Object.getOwnPropertyNames(error)) {
|
|
11095
|
+
if (["name", "message", "stack", "cause", "error"].includes(key)) {
|
|
11096
|
+
continue;
|
|
11097
|
+
}
|
|
11098
|
+
const value = error[key];
|
|
11099
|
+
if (value === void 0 || typeof value === "function") {
|
|
11100
|
+
continue;
|
|
11101
|
+
}
|
|
11102
|
+
errorResult[key] = sanitizeErrorValue(value);
|
|
11103
|
+
}
|
|
11104
|
+
return errorResult;
|
|
11105
|
+
}
|
|
11106
|
+
__name(buildToolErrorResult, "buildToolErrorResult");
|
|
11107
|
+
function sanitizeErrorValue(value) {
|
|
11108
|
+
if (value === null || value === void 0) {
|
|
11109
|
+
return value;
|
|
11110
|
+
}
|
|
11111
|
+
const type = typeof value;
|
|
11112
|
+
if (type === "string" || type === "number" || type === "boolean") {
|
|
11113
|
+
return value;
|
|
11114
|
+
}
|
|
11115
|
+
if (Array.isArray(value)) {
|
|
11116
|
+
return value.map((item) => sanitizeErrorValue(item));
|
|
11117
|
+
}
|
|
11118
|
+
if (value instanceof Error) {
|
|
11119
|
+
return {
|
|
11120
|
+
name: value.name,
|
|
11121
|
+
message: value.message,
|
|
11122
|
+
stack: value.stack
|
|
11123
|
+
};
|
|
11124
|
+
}
|
|
11125
|
+
if (value instanceof Date) {
|
|
11126
|
+
return value.toISOString();
|
|
11127
|
+
}
|
|
11128
|
+
if (value instanceof Map || value instanceof Set) {
|
|
11129
|
+
return (0, import_utils11.safeStringify)(value);
|
|
11130
|
+
}
|
|
11131
|
+
try {
|
|
11132
|
+
return (0, import_utils11.safeStringify)(value);
|
|
11133
|
+
} catch {
|
|
11134
|
+
return String(value);
|
|
11135
|
+
}
|
|
11136
|
+
}
|
|
11137
|
+
__name(sanitizeErrorValue, "sanitizeErrorValue");
|
|
11138
|
+
|
|
11075
11139
|
// src/agent/errors/client-http-errors.ts
|
|
11076
11140
|
var ClientHTTPError = class extends Error {
|
|
11077
11141
|
constructor(name, httpStatus, code, message) {
|
|
@@ -11206,10 +11270,10 @@ var VoltAgentError = class extends Error {
|
|
|
11206
11270
|
|
|
11207
11271
|
// src/agent/eval.ts
|
|
11208
11272
|
var import_api10 = require("@opentelemetry/api");
|
|
11209
|
-
var
|
|
11273
|
+
var import_utils14 = require("@voltagent/internal/utils");
|
|
11210
11274
|
|
|
11211
11275
|
// src/eval/runtime/runtime.ts
|
|
11212
|
-
var
|
|
11276
|
+
var import_utils12 = require("@voltagent/internal/utils");
|
|
11213
11277
|
var RUNTIME_METADATA_KEY = "__runtime";
|
|
11214
11278
|
async function runLocalScorers(args) {
|
|
11215
11279
|
const { payload, scorers, defaultSampling, baseArgs } = args;
|
|
@@ -11427,7 +11491,7 @@ function cloneRecord(value) {
|
|
|
11427
11491
|
return void 0;
|
|
11428
11492
|
}
|
|
11429
11493
|
try {
|
|
11430
|
-
return JSON.parse((0,
|
|
11494
|
+
return JSON.parse((0, import_utils12.safeStringify)(value));
|
|
11431
11495
|
} catch {
|
|
11432
11496
|
return { ...value };
|
|
11433
11497
|
}
|
|
@@ -11445,7 +11509,7 @@ function parseStatus(value) {
|
|
|
11445
11509
|
__name(parseStatus, "parseStatus");
|
|
11446
11510
|
|
|
11447
11511
|
// src/eval/create-scorer.ts
|
|
11448
|
-
var
|
|
11512
|
+
var import_utils13 = require("@voltagent/internal/utils");
|
|
11449
11513
|
function createScorer(options) {
|
|
11450
11514
|
const {
|
|
11451
11515
|
id,
|
|
@@ -11560,7 +11624,7 @@ function cloneMetadata(value) {
|
|
|
11560
11624
|
return null;
|
|
11561
11625
|
}
|
|
11562
11626
|
try {
|
|
11563
|
-
return JSON.parse((0,
|
|
11627
|
+
return JSON.parse((0, import_utils13.safeStringify)(value));
|
|
11564
11628
|
} catch {
|
|
11565
11629
|
return { ...value };
|
|
11566
11630
|
}
|
|
@@ -11575,7 +11639,7 @@ function getErrorMetadata(error) {
|
|
|
11575
11639
|
return null;
|
|
11576
11640
|
}
|
|
11577
11641
|
try {
|
|
11578
|
-
return JSON.parse((0,
|
|
11642
|
+
return JSON.parse((0, import_utils13.safeStringify)(metadata));
|
|
11579
11643
|
} catch {
|
|
11580
11644
|
return { ...metadata };
|
|
11581
11645
|
}
|
|
@@ -12064,7 +12128,7 @@ function finalizeScorerSpan(span, host, descriptor, config, storagePayload, metr
|
|
|
12064
12128
|
span.setAttributes(attributes);
|
|
12065
12129
|
if (metrics.combinedMetadata && Object.keys(metrics.combinedMetadata).length > 0) {
|
|
12066
12130
|
try {
|
|
12067
|
-
span.setAttribute("eval.scorer.metadata", (0,
|
|
12131
|
+
span.setAttribute("eval.scorer.metadata", (0, import_utils14.safeStringify)(metrics.combinedMetadata));
|
|
12068
12132
|
} catch {
|
|
12069
12133
|
span.setAttribute("eval.scorer.metadata", "[unserializable]");
|
|
12070
12134
|
}
|
|
@@ -12423,7 +12487,7 @@ function ensureScorerText(value) {
|
|
|
12423
12487
|
}
|
|
12424
12488
|
if (typeof value === "object") {
|
|
12425
12489
|
try {
|
|
12426
|
-
return (0,
|
|
12490
|
+
return (0, import_utils14.safeStringify)(value);
|
|
12427
12491
|
} catch {
|
|
12428
12492
|
return String(value);
|
|
12429
12493
|
}
|
|
@@ -12459,11 +12523,11 @@ function normalizeEvalString(value) {
|
|
|
12459
12523
|
if (typeof value === "string") {
|
|
12460
12524
|
return value;
|
|
12461
12525
|
}
|
|
12462
|
-
return (0,
|
|
12526
|
+
return (0, import_utils14.safeStringify)(value);
|
|
12463
12527
|
}
|
|
12464
12528
|
__name(normalizeEvalString, "normalizeEvalString");
|
|
12465
12529
|
function cloneEvalPayload(payload) {
|
|
12466
|
-
return JSON.parse((0,
|
|
12530
|
+
return JSON.parse((0, import_utils14.safeStringify)(payload));
|
|
12467
12531
|
}
|
|
12468
12532
|
__name(cloneEvalPayload, "cloneEvalPayload");
|
|
12469
12533
|
function combineEvalMetadata(payload, scorerMetadata) {
|
|
@@ -12702,7 +12766,7 @@ function extractErrorMessage(error) {
|
|
|
12702
12766
|
return error;
|
|
12703
12767
|
}
|
|
12704
12768
|
try {
|
|
12705
|
-
return (0,
|
|
12769
|
+
return (0, import_utils14.safeStringify)(error);
|
|
12706
12770
|
} catch {
|
|
12707
12771
|
return String(error);
|
|
12708
12772
|
}
|
|
@@ -13477,7 +13541,7 @@ var ConversationBuffer = class {
|
|
|
13477
13541
|
|
|
13478
13542
|
// src/agent/guardrail.ts
|
|
13479
13543
|
var import_api12 = require("@opentelemetry/api");
|
|
13480
|
-
var
|
|
13544
|
+
var import_utils15 = require("@voltagent/internal/utils");
|
|
13481
13545
|
var import_ai2 = require("ai");
|
|
13482
13546
|
|
|
13483
13547
|
// src/utils/message-helpers.ts
|
|
@@ -13888,7 +13952,7 @@ function serializeGuardrailValue(value) {
|
|
|
13888
13952
|
if (typeof value === "string") {
|
|
13889
13953
|
return value;
|
|
13890
13954
|
}
|
|
13891
|
-
return (0,
|
|
13955
|
+
return (0, import_utils15.safeStringify)(value);
|
|
13892
13956
|
}
|
|
13893
13957
|
__name(serializeGuardrailValue, "serializeGuardrailValue");
|
|
13894
13958
|
function extractInputTextForGuardrail(value) {
|
|
@@ -13937,7 +14001,7 @@ function extractOutputTextForGuardrail(value) {
|
|
|
13937
14001
|
}
|
|
13938
14002
|
if (typeof value === "object") {
|
|
13939
14003
|
try {
|
|
13940
|
-
return (0,
|
|
14004
|
+
return (0, import_utils15.safeStringify)(value);
|
|
13941
14005
|
} catch {
|
|
13942
14006
|
return void 0;
|
|
13943
14007
|
}
|
|
@@ -13974,8 +14038,8 @@ async function runInputGuardrails(input, oc, guardrails, operation, agent) {
|
|
|
13974
14038
|
"guardrail.name": guardrail.name,
|
|
13975
14039
|
...guardrail.description ? { "guardrail.description": guardrail.description } : {},
|
|
13976
14040
|
...guardrail.severity ? { "guardrail.severity": guardrail.severity } : {},
|
|
13977
|
-
...guardrail.tags && guardrail.tags.length > 0 ? { "guardrail.tags": (0,
|
|
13978
|
-
...guardrail.metadata ? { "guardrail.metadata": (0,
|
|
14041
|
+
...guardrail.tags && guardrail.tags.length > 0 ? { "guardrail.tags": (0, import_utils15.safeStringify)(guardrail.tags) } : {},
|
|
14042
|
+
...guardrail.metadata ? { "guardrail.metadata": (0, import_utils15.safeStringify)(guardrail.metadata) } : {},
|
|
13979
14043
|
"guardrail.input.original": serializeGuardrailValue(originalInput),
|
|
13980
14044
|
"guardrail.input.current": serializeGuardrailValue(currentInput)
|
|
13981
14045
|
}
|
|
@@ -14003,7 +14067,7 @@ async function runInputGuardrails(input, oc, guardrails, operation, agent) {
|
|
|
14003
14067
|
span.setAttribute("guardrail.message", resolvedDecision.message);
|
|
14004
14068
|
}
|
|
14005
14069
|
if (resolvedDecision.metadata) {
|
|
14006
|
-
span.setAttribute("guardrail.result.metadata", (0,
|
|
14070
|
+
span.setAttribute("guardrail.result.metadata", (0, import_utils15.safeStringify)(resolvedDecision.metadata));
|
|
14007
14071
|
}
|
|
14008
14072
|
if (!pass || action === "block") {
|
|
14009
14073
|
const message = resolvedDecision.message ?? "Input blocked by guardrail";
|
|
@@ -14081,8 +14145,8 @@ async function runOutputGuardrails({
|
|
|
14081
14145
|
"guardrail.name": guardrail.name,
|
|
14082
14146
|
...guardrail.description ? { "guardrail.description": guardrail.description } : {},
|
|
14083
14147
|
...guardrail.severity ? { "guardrail.severity": guardrail.severity } : {},
|
|
14084
|
-
...guardrail.tags && guardrail.tags.length > 0 ? { "guardrail.tags": (0,
|
|
14085
|
-
...guardrail.metadata ? { "guardrail.metadata": (0,
|
|
14148
|
+
...guardrail.tags && guardrail.tags.length > 0 ? { "guardrail.tags": (0, import_utils15.safeStringify)(guardrail.tags) } : {},
|
|
14149
|
+
...guardrail.metadata ? { "guardrail.metadata": (0, import_utils15.safeStringify)(guardrail.metadata) } : {}
|
|
14086
14150
|
}
|
|
14087
14151
|
}
|
|
14088
14152
|
);
|
|
@@ -14090,13 +14154,13 @@ async function runOutputGuardrails({
|
|
|
14090
14154
|
span?.setAttribute("guardrail.output.original", serializeGuardrailValue(originalOutput));
|
|
14091
14155
|
span?.setAttribute("guardrail.output.current", serializeGuardrailValue(currentOutput));
|
|
14092
14156
|
if (metadata.usage !== void 0) {
|
|
14093
|
-
span?.setAttribute("guardrail.usage", (0,
|
|
14157
|
+
span?.setAttribute("guardrail.usage", (0, import_utils15.safeStringify)(metadata.usage));
|
|
14094
14158
|
}
|
|
14095
14159
|
if (metadata.finishReason !== void 0 && metadata.finishReason !== null) {
|
|
14096
14160
|
span?.setAttribute("guardrail.finish_reason", metadata.finishReason);
|
|
14097
14161
|
}
|
|
14098
14162
|
if (metadata.warnings && metadata.warnings.length > 0) {
|
|
14099
|
-
span?.setAttribute("guardrail.warnings", (0,
|
|
14163
|
+
span?.setAttribute("guardrail.warnings", (0, import_utils15.safeStringify)(metadata.warnings));
|
|
14100
14164
|
}
|
|
14101
14165
|
try {
|
|
14102
14166
|
const decision = await oc.traceContext.withSpan(
|
|
@@ -14123,7 +14187,7 @@ async function runOutputGuardrails({
|
|
|
14123
14187
|
span?.setAttribute("guardrail.message", resolvedDecision.message);
|
|
14124
14188
|
}
|
|
14125
14189
|
if (resolvedDecision.metadata) {
|
|
14126
|
-
span?.setAttribute("guardrail.result.metadata", (0,
|
|
14190
|
+
span?.setAttribute("guardrail.result.metadata", (0, import_utils15.safeStringify)(resolvedDecision.metadata));
|
|
14127
14191
|
}
|
|
14128
14192
|
if (!pass || action === "block") {
|
|
14129
14193
|
const message = resolvedDecision.message ?? "Output blocked by guardrail";
|
|
@@ -14659,7 +14723,7 @@ var import_ai3 = require("ai");
|
|
|
14659
14723
|
|
|
14660
14724
|
// src/agent/streaming/output-guardrail-stream-runner.ts
|
|
14661
14725
|
var import_api13 = require("@opentelemetry/api");
|
|
14662
|
-
var
|
|
14726
|
+
var import_utils16 = require("@voltagent/internal/utils");
|
|
14663
14727
|
var isTextDelta = /* @__PURE__ */ __name((part) => part.type === "text-delta", "isTextDelta");
|
|
14664
14728
|
var extractChunkText = /* @__PURE__ */ __name((part) => {
|
|
14665
14729
|
if (!isTextDelta(part)) {
|
|
@@ -14914,8 +14978,8 @@ var OutputGuardrailStreamRunner = class {
|
|
|
14914
14978
|
"guardrail.name": guardrail.name,
|
|
14915
14979
|
...guardrail.description ? { "guardrail.description": guardrail.description } : {},
|
|
14916
14980
|
...guardrail.severity ? { "guardrail.severity": guardrail.severity } : {},
|
|
14917
|
-
...guardrail.tags && guardrail.tags.length > 0 ? { "guardrail.tags": (0,
|
|
14918
|
-
...guardrail.metadata ? { "guardrail.metadata": (0,
|
|
14981
|
+
...guardrail.tags && guardrail.tags.length > 0 ? { "guardrail.tags": (0, import_utils16.safeStringify)(guardrail.tags) } : {},
|
|
14982
|
+
...guardrail.metadata ? { "guardrail.metadata": (0, import_utils16.safeStringify)(guardrail.metadata) } : {}
|
|
14919
14983
|
}
|
|
14920
14984
|
}
|
|
14921
14985
|
);
|
|
@@ -15443,7 +15507,7 @@ __name(convertFullStreamChunkToUIMessageStream, "convertFullStreamChunkToUIMessa
|
|
|
15443
15507
|
|
|
15444
15508
|
// src/agent/subagent/index.ts
|
|
15445
15509
|
var import_api14 = require("@opentelemetry/api");
|
|
15446
|
-
var
|
|
15510
|
+
var import_utils17 = require("@voltagent/internal/utils");
|
|
15447
15511
|
var import_zod2 = require("zod");
|
|
15448
15512
|
|
|
15449
15513
|
// src/agent/subagent/types.ts
|
|
@@ -15746,7 +15810,7 @@ ${guidelinesText}
|
|
|
15746
15810
|
taskContent = `Task handed off from ${sourceAgent?.name || this.agentName} to ${targetAgent.name}:
|
|
15747
15811
|
${task}
|
|
15748
15812
|
|
|
15749
|
-
Context: ${(0,
|
|
15813
|
+
Context: ${(0, import_utils17.safeStringify)(contextObj, { indentation: 2 })}`;
|
|
15750
15814
|
}
|
|
15751
15815
|
const taskMessage = {
|
|
15752
15816
|
id: crypto.randomUUID(),
|
|
@@ -15903,7 +15967,7 @@ Context: ${(0, import_utils16.safeStringify)(contextObj, { indentation: 2 })}`;
|
|
|
15903
15967
|
options2
|
|
15904
15968
|
);
|
|
15905
15969
|
const finalObject = await response.object;
|
|
15906
|
-
finalResult = (0,
|
|
15970
|
+
finalResult = (0, import_utils17.safeStringify)(finalObject);
|
|
15907
15971
|
const assistantMessage = {
|
|
15908
15972
|
id: crypto.randomUUID(),
|
|
15909
15973
|
role: "assistant",
|
|
@@ -15917,7 +15981,7 @@ Context: ${(0, import_utils16.safeStringify)(contextObj, { indentation: 2 })}`;
|
|
|
15917
15981
|
targetAgentConfig.schema,
|
|
15918
15982
|
options2
|
|
15919
15983
|
);
|
|
15920
|
-
finalResult = (0,
|
|
15984
|
+
finalResult = (0, import_utils17.safeStringify)(response);
|
|
15921
15985
|
usage = response.usage;
|
|
15922
15986
|
const assistantMessage = {
|
|
15923
15987
|
id: crypto.randomUUID(),
|
|
@@ -16329,12 +16393,12 @@ var Agent = class {
|
|
|
16329
16393
|
);
|
|
16330
16394
|
const contextMap = Object.fromEntries(oc.context.entries());
|
|
16331
16395
|
if (Object.keys(contextMap).length > 0) {
|
|
16332
|
-
rootSpan.setAttribute("agent.context", (0,
|
|
16396
|
+
rootSpan.setAttribute("agent.context", (0, import_utils18.safeStringify)(contextMap));
|
|
16333
16397
|
}
|
|
16334
|
-
rootSpan.setAttribute("agent.messages", (0,
|
|
16335
|
-
rootSpan.setAttribute("agent.messages.ui", (0,
|
|
16398
|
+
rootSpan.setAttribute("agent.messages", (0, import_utils18.safeStringify)(messages));
|
|
16399
|
+
rootSpan.setAttribute("agent.messages.ui", (0, import_utils18.safeStringify)(uiMessages));
|
|
16336
16400
|
const agentState = this.getFullState();
|
|
16337
|
-
rootSpan.setAttribute("agent.stateSnapshot", (0,
|
|
16401
|
+
rootSpan.setAttribute("agent.stateSnapshot", (0, import_utils18.safeStringify)(agentState));
|
|
16338
16402
|
methodLogger.debug(
|
|
16339
16403
|
buildAgentLogMessage(
|
|
16340
16404
|
this.name,
|
|
@@ -16484,7 +16548,7 @@ var Agent = class {
|
|
|
16484
16548
|
operation: "generateText",
|
|
16485
16549
|
metadata: {
|
|
16486
16550
|
finishReason: result.finishReason,
|
|
16487
|
-
usage: result.usage ? JSON.parse((0,
|
|
16551
|
+
usage: result.usage ? JSON.parse((0, import_utils18.safeStringify)(result.usage)) : void 0,
|
|
16488
16552
|
toolCalls: aggregatedToolCalls
|
|
16489
16553
|
}
|
|
16490
16554
|
});
|
|
@@ -16594,12 +16658,12 @@ var Agent = class {
|
|
|
16594
16658
|
);
|
|
16595
16659
|
const contextMap = Object.fromEntries(oc.context.entries());
|
|
16596
16660
|
if (Object.keys(contextMap).length > 0) {
|
|
16597
|
-
rootSpan2.setAttribute("agent.context", (0,
|
|
16661
|
+
rootSpan2.setAttribute("agent.context", (0, import_utils18.safeStringify)(contextMap));
|
|
16598
16662
|
}
|
|
16599
|
-
rootSpan2.setAttribute("agent.messages", (0,
|
|
16600
|
-
rootSpan2.setAttribute("agent.messages.ui", (0,
|
|
16663
|
+
rootSpan2.setAttribute("agent.messages", (0, import_utils18.safeStringify)(messages));
|
|
16664
|
+
rootSpan2.setAttribute("agent.messages.ui", (0, import_utils18.safeStringify)(uiMessages));
|
|
16601
16665
|
const agentState = this.getFullState();
|
|
16602
|
-
rootSpan2.setAttribute("agent.stateSnapshot", (0,
|
|
16666
|
+
rootSpan2.setAttribute("agent.stateSnapshot", (0, import_utils18.safeStringify)(agentState));
|
|
16603
16667
|
}
|
|
16604
16668
|
methodLogger.debug(
|
|
16605
16669
|
buildAgentLogMessage(
|
|
@@ -16797,7 +16861,7 @@ var Agent = class {
|
|
|
16797
16861
|
operation: "streamText",
|
|
16798
16862
|
metadata: {
|
|
16799
16863
|
finishReason: finalResult.finishReason,
|
|
16800
|
-
usage: finalResult.totalUsage ? JSON.parse((0,
|
|
16864
|
+
usage: finalResult.totalUsage ? JSON.parse((0, import_utils18.safeStringify)(finalResult.totalUsage)) : void 0,
|
|
16801
16865
|
toolCalls: finalResult.toolCalls
|
|
16802
16866
|
}
|
|
16803
16867
|
});
|
|
@@ -17051,12 +17115,12 @@ var Agent = class {
|
|
|
17051
17115
|
);
|
|
17052
17116
|
const contextMap = Object.fromEntries(oc.context.entries());
|
|
17053
17117
|
if (Object.keys(contextMap).length > 0) {
|
|
17054
|
-
rootSpan.setAttribute("agent.context", (0,
|
|
17118
|
+
rootSpan.setAttribute("agent.context", (0, import_utils18.safeStringify)(contextMap));
|
|
17055
17119
|
}
|
|
17056
|
-
rootSpan.setAttribute("agent.messages", (0,
|
|
17057
|
-
rootSpan.setAttribute("agent.messages.ui", (0,
|
|
17120
|
+
rootSpan.setAttribute("agent.messages", (0, import_utils18.safeStringify)(messages));
|
|
17121
|
+
rootSpan.setAttribute("agent.messages.ui", (0, import_utils18.safeStringify)(uiMessages));
|
|
17058
17122
|
const agentState = this.getFullState();
|
|
17059
|
-
rootSpan.setAttribute("agent.stateSnapshot", (0,
|
|
17123
|
+
rootSpan.setAttribute("agent.stateSnapshot", (0, import_utils18.safeStringify)(agentState));
|
|
17060
17124
|
methodLogger.debug(
|
|
17061
17125
|
buildAgentLogMessage(
|
|
17062
17126
|
this.name,
|
|
@@ -17122,7 +17186,7 @@ var Agent = class {
|
|
|
17122
17186
|
parts: [
|
|
17123
17187
|
{
|
|
17124
17188
|
type: "text",
|
|
17125
|
-
text: (0,
|
|
17189
|
+
text: (0, import_utils18.safeStringify)(finalObject)
|
|
17126
17190
|
}
|
|
17127
17191
|
]
|
|
17128
17192
|
};
|
|
@@ -17130,7 +17194,7 @@ var Agent = class {
|
|
|
17130
17194
|
const step = {
|
|
17131
17195
|
id: randomUUID(),
|
|
17132
17196
|
type: "text",
|
|
17133
|
-
content: (0,
|
|
17197
|
+
content: (0, import_utils18.safeStringify)(finalObject),
|
|
17134
17198
|
role: "assistant",
|
|
17135
17199
|
usage: usageInfo
|
|
17136
17200
|
};
|
|
@@ -17145,7 +17209,7 @@ var Agent = class {
|
|
|
17145
17209
|
operation: "generateObject",
|
|
17146
17210
|
metadata: {
|
|
17147
17211
|
finishReason: result.finishReason,
|
|
17148
|
-
usage: result.usage ? JSON.parse((0,
|
|
17212
|
+
usage: result.usage ? JSON.parse((0, import_utils18.safeStringify)(result.usage)) : void 0,
|
|
17149
17213
|
schemaName
|
|
17150
17214
|
}
|
|
17151
17215
|
});
|
|
@@ -17229,12 +17293,12 @@ var Agent = class {
|
|
|
17229
17293
|
);
|
|
17230
17294
|
const contextMap = Object.fromEntries(oc.context.entries());
|
|
17231
17295
|
if (Object.keys(contextMap).length > 0) {
|
|
17232
|
-
rootSpan.setAttribute("agent.context", (0,
|
|
17296
|
+
rootSpan.setAttribute("agent.context", (0, import_utils18.safeStringify)(contextMap));
|
|
17233
17297
|
}
|
|
17234
|
-
rootSpan.setAttribute("agent.messages", (0,
|
|
17235
|
-
rootSpan.setAttribute("agent.messages.ui", (0,
|
|
17298
|
+
rootSpan.setAttribute("agent.messages", (0, import_utils18.safeStringify)(messages));
|
|
17299
|
+
rootSpan.setAttribute("agent.messages.ui", (0, import_utils18.safeStringify)(uiMessages));
|
|
17236
17300
|
const agentState = this.getFullState();
|
|
17237
|
-
rootSpan.setAttribute("agent.stateSnapshot", (0,
|
|
17301
|
+
rootSpan.setAttribute("agent.stateSnapshot", (0, import_utils18.safeStringify)(agentState));
|
|
17238
17302
|
methodLogger.debug(
|
|
17239
17303
|
buildAgentLogMessage(
|
|
17240
17304
|
this.name,
|
|
@@ -17327,7 +17391,7 @@ var Agent = class {
|
|
|
17327
17391
|
parts: [
|
|
17328
17392
|
{
|
|
17329
17393
|
type: "text",
|
|
17330
|
-
text: (0,
|
|
17394
|
+
text: (0, import_utils18.safeStringify)(finalObject)
|
|
17331
17395
|
}
|
|
17332
17396
|
]
|
|
17333
17397
|
};
|
|
@@ -17335,7 +17399,7 @@ var Agent = class {
|
|
|
17335
17399
|
const step = {
|
|
17336
17400
|
id: randomUUID(),
|
|
17337
17401
|
type: "text",
|
|
17338
|
-
content: (0,
|
|
17402
|
+
content: (0, import_utils18.safeStringify)(finalObject),
|
|
17339
17403
|
role: "assistant",
|
|
17340
17404
|
usage: usageInfo
|
|
17341
17405
|
};
|
|
@@ -17384,7 +17448,7 @@ var Agent = class {
|
|
|
17384
17448
|
operation: "streamObject",
|
|
17385
17449
|
metadata: {
|
|
17386
17450
|
finishReason: finalResult.finishReason,
|
|
17387
|
-
usage: finalResult.usage ? JSON.parse((0,
|
|
17451
|
+
usage: finalResult.usage ? JSON.parse((0, import_utils18.safeStringify)(finalResult.usage)) : void 0,
|
|
17388
17452
|
schemaName
|
|
17389
17453
|
}
|
|
17390
17454
|
});
|
|
@@ -17725,12 +17789,12 @@ var Agent = class {
|
|
|
17725
17789
|
attrs["llm.top_p"] = topP;
|
|
17726
17790
|
}
|
|
17727
17791
|
if (callOptions.stop !== void 0) {
|
|
17728
|
-
attrs["llm.stop_condition"] = (0,
|
|
17792
|
+
attrs["llm.stop_condition"] = (0, import_utils18.safeStringify)(callOptions.stop);
|
|
17729
17793
|
}
|
|
17730
17794
|
if (params.messages && params.messages.length > 0) {
|
|
17731
17795
|
attrs["llm.messages.count"] = params.messages.length;
|
|
17732
17796
|
const trimmedMessages = params.messages.slice(-10);
|
|
17733
|
-
attrs["llm.messages"] = (0,
|
|
17797
|
+
attrs["llm.messages"] = (0, import_utils18.safeStringify)(
|
|
17734
17798
|
trimmedMessages.map((msg) => ({
|
|
17735
17799
|
role: msg.role,
|
|
17736
17800
|
content: msg.content
|
|
@@ -17745,7 +17809,7 @@ var Agent = class {
|
|
|
17745
17809
|
}
|
|
17746
17810
|
}
|
|
17747
17811
|
if (params.providerOptions) {
|
|
17748
|
-
attrs["llm.provider_options"] = (0,
|
|
17812
|
+
attrs["llm.provider_options"] = (0, import_utils18.safeStringify)(params.providerOptions);
|
|
17749
17813
|
}
|
|
17750
17814
|
return attrs;
|
|
17751
17815
|
}
|
|
@@ -17903,7 +17967,7 @@ var Agent = class {
|
|
|
17903
17967
|
attributes: {
|
|
17904
17968
|
"memory.operation": "read",
|
|
17905
17969
|
"memory.semantic": isSemanticSearch,
|
|
17906
|
-
input: (0,
|
|
17970
|
+
input: (0, import_utils18.safeStringify)(spanInput),
|
|
17907
17971
|
...isSemanticSearch && {
|
|
17908
17972
|
"memory.semantic.limit": semanticLimit,
|
|
17909
17973
|
"memory.semantic.threshold": semanticThreshold,
|
|
@@ -18035,13 +18099,13 @@ var Agent = class {
|
|
|
18035
18099
|
rootSpan.setAttribute("prompt.version", metadata.version);
|
|
18036
18100
|
}
|
|
18037
18101
|
if (metadata.labels && metadata.labels.length > 0) {
|
|
18038
|
-
rootSpan.setAttribute("prompt.labels", (0,
|
|
18102
|
+
rootSpan.setAttribute("prompt.labels", (0, import_utils18.safeStringify)(metadata.labels));
|
|
18039
18103
|
}
|
|
18040
18104
|
if (metadata.tags && metadata.tags.length > 0) {
|
|
18041
|
-
rootSpan.setAttribute("prompt.tags", (0,
|
|
18105
|
+
rootSpan.setAttribute("prompt.tags", (0, import_utils18.safeStringify)(metadata.tags));
|
|
18042
18106
|
}
|
|
18043
18107
|
if (metadata.config) {
|
|
18044
|
-
rootSpan.setAttribute("prompt.config", (0,
|
|
18108
|
+
rootSpan.setAttribute("prompt.config", (0, import_utils18.safeStringify)(metadata.config));
|
|
18045
18109
|
}
|
|
18046
18110
|
}
|
|
18047
18111
|
}
|
|
@@ -18121,7 +18185,7 @@ ${additionalContext}`
|
|
|
18121
18185
|
);
|
|
18122
18186
|
return {
|
|
18123
18187
|
role: "system",
|
|
18124
|
-
content:
|
|
18188
|
+
content: `${content2}`
|
|
18125
18189
|
};
|
|
18126
18190
|
}
|
|
18127
18191
|
}
|
|
@@ -18134,7 +18198,7 @@ ${additionalContext}`
|
|
|
18134
18198
|
);
|
|
18135
18199
|
return {
|
|
18136
18200
|
role: "system",
|
|
18137
|
-
content:
|
|
18201
|
+
content: `${content}`
|
|
18138
18202
|
};
|
|
18139
18203
|
}
|
|
18140
18204
|
/**
|
|
@@ -18215,7 +18279,7 @@ ${retrieverContext}`;
|
|
|
18215
18279
|
label: this.retriever.tool.name || "Retriever",
|
|
18216
18280
|
attributes: {
|
|
18217
18281
|
"retriever.name": this.retriever.tool.name || "Retriever",
|
|
18218
|
-
input: typeof input === "string" ? input : (0,
|
|
18282
|
+
input: typeof input === "string" ? input : (0, import_utils18.safeStringify)(input)
|
|
18219
18283
|
}
|
|
18220
18284
|
});
|
|
18221
18285
|
try {
|
|
@@ -18361,9 +18425,9 @@ ${retrieverContext}`;
|
|
|
18361
18425
|
"tool.name": tool2.name,
|
|
18362
18426
|
"tool.call.id": toolCallId,
|
|
18363
18427
|
"tool.description": tool2.description,
|
|
18364
|
-
...toolTags && toolTags.length > 0 ? { "tool.tags": (0,
|
|
18365
|
-
"tool.parameters": (0,
|
|
18366
|
-
input: args ? (0,
|
|
18428
|
+
...toolTags && toolTags.length > 0 ? { "tool.tags": (0, import_utils18.safeStringify)(toolTags) } : {},
|
|
18429
|
+
"tool.parameters": (0, import_utils18.safeStringify)(tool2.parameters),
|
|
18430
|
+
input: args ? (0, import_utils18.safeStringify)(args) : void 0
|
|
18367
18431
|
},
|
|
18368
18432
|
kind: import_api15.SpanKind.CLIENT
|
|
18369
18433
|
});
|
|
@@ -18384,7 +18448,7 @@ ${retrieverContext}`;
|
|
|
18384
18448
|
}
|
|
18385
18449
|
const result = await tool2.execute(args, executionOptions);
|
|
18386
18450
|
const validatedResult = await this.validateToolOutput(result, tool2);
|
|
18387
|
-
toolSpan.setAttribute("output", (0,
|
|
18451
|
+
toolSpan.setAttribute("output", (0, import_utils18.safeStringify)(result));
|
|
18388
18452
|
toolSpan.setStatus({ code: import_api15.SpanStatusCode.OK });
|
|
18389
18453
|
toolSpan.end();
|
|
18390
18454
|
await hooks.onToolEnd?.({
|
|
@@ -18398,7 +18462,16 @@ ${retrieverContext}`;
|
|
|
18398
18462
|
return result;
|
|
18399
18463
|
} catch (e) {
|
|
18400
18464
|
const error = e instanceof Error ? e : new Error(String(e));
|
|
18401
|
-
const
|
|
18465
|
+
const voltAgentError = createVoltAgentError(error, {
|
|
18466
|
+
stage: "tool_execution",
|
|
18467
|
+
toolError: {
|
|
18468
|
+
toolCallId,
|
|
18469
|
+
toolName: tool2.name,
|
|
18470
|
+
toolExecutionError: error,
|
|
18471
|
+
toolArguments: args
|
|
18472
|
+
}
|
|
18473
|
+
});
|
|
18474
|
+
const errorResult = buildToolErrorResult(error, toolCallId, tool2.name);
|
|
18402
18475
|
toolSpan.setStatus({ code: import_api15.SpanStatusCode.ERROR, message: error.message });
|
|
18403
18476
|
toolSpan.recordException(error);
|
|
18404
18477
|
toolSpan.end();
|
|
@@ -18406,7 +18479,7 @@ ${retrieverContext}`;
|
|
|
18406
18479
|
agent: this,
|
|
18407
18480
|
tool: tool2,
|
|
18408
18481
|
output: void 0,
|
|
18409
|
-
error:
|
|
18482
|
+
error: voltAgentError,
|
|
18410
18483
|
context: oc,
|
|
18411
18484
|
options: executionOptions
|
|
18412
18485
|
});
|
|
@@ -18574,7 +18647,7 @@ ${retrieverContext}`;
|
|
|
18574
18647
|
oc.conversationSteps?.push({
|
|
18575
18648
|
id: toolCall.toolCallId || randomUUID(),
|
|
18576
18649
|
type: "tool_call",
|
|
18577
|
-
content: (0,
|
|
18650
|
+
content: (0, import_utils18.safeStringify)(toolCall.input ?? {}),
|
|
18578
18651
|
role: "assistant",
|
|
18579
18652
|
name: toolCall.toolName,
|
|
18580
18653
|
arguments: toolCall.input || {},
|
|
@@ -18606,7 +18679,7 @@ ${retrieverContext}`;
|
|
|
18606
18679
|
oc.conversationSteps?.push({
|
|
18607
18680
|
id: toolResult.toolCallId || randomUUID(),
|
|
18608
18681
|
type: "tool_result",
|
|
18609
|
-
content: (0,
|
|
18682
|
+
content: (0, import_utils18.safeStringify)(toolResult.output),
|
|
18610
18683
|
role: "assistant",
|
|
18611
18684
|
name: toolResult.toolName,
|
|
18612
18685
|
result: toolResult.output,
|
|
@@ -21975,7 +22048,7 @@ var import_node_crypto = __toESM(require("crypto"));
|
|
|
21975
22048
|
var import_node_fs = __toESM(require("fs"));
|
|
21976
22049
|
var import_node_os = __toESM(require("os"));
|
|
21977
22050
|
var import_node_path = __toESM(require("path"));
|
|
21978
|
-
var
|
|
22051
|
+
var import_utils19 = require("@voltagent/internal/utils");
|
|
21979
22052
|
var getEnvPaths = /* @__PURE__ */ __name((name) => {
|
|
21980
22053
|
const homedir = import_node_os.default.homedir();
|
|
21981
22054
|
const tmpdir = import_node_os.default.tmpdir();
|
|
@@ -22045,7 +22118,7 @@ var writeUpdateCache = /* @__PURE__ */ __name(async (projectPath, cache) => {
|
|
|
22045
22118
|
try {
|
|
22046
22119
|
ensureCacheDir();
|
|
22047
22120
|
const cacheFilePath = getCacheFilePath(projectPath);
|
|
22048
|
-
import_node_fs.default.writeFileSync(cacheFilePath, (0,
|
|
22121
|
+
import_node_fs.default.writeFileSync(cacheFilePath, (0, import_utils19.safeStringify)(cache, { indentation: 2 }), "utf8");
|
|
22049
22122
|
} catch (error) {
|
|
22050
22123
|
const logger = new LoggerProxy({ component: "update-cache" });
|
|
22051
22124
|
logger.error("Error writing update cache", { error });
|
|
@@ -22938,7 +23011,7 @@ var VoltAgent = class {
|
|
|
22938
23011
|
};
|
|
22939
23012
|
|
|
22940
23013
|
// src/index.ts
|
|
22941
|
-
var
|
|
23014
|
+
var import_utils20 = require("@voltagent/internal/utils");
|
|
22942
23015
|
var import_ai6 = require("ai");
|
|
22943
23016
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22944
23017
|
0 && (module.exports = {
|