@voltagent/core 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +87 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -871,7 +871,13 @@ var TextRequestSchema = import_zod.z.object({
|
|
|
871
871
|
]),
|
|
872
872
|
options: GenerateOptionsSchema.optional().openapi({
|
|
873
873
|
description: "Optional generation parameters",
|
|
874
|
-
example: {
|
|
874
|
+
example: {
|
|
875
|
+
userId: "unique-user-id",
|
|
876
|
+
conversationId: "unique-conversation-id",
|
|
877
|
+
contextLimit: 10,
|
|
878
|
+
temperature: 0.7,
|
|
879
|
+
maxTokens: 100
|
|
880
|
+
}
|
|
875
881
|
})
|
|
876
882
|
}).openapi("TextGenerationRequest");
|
|
877
883
|
var TextResponseSchema = import_zod.z.object({
|
|
@@ -4963,21 +4969,10 @@ ${context}`;
|
|
|
4963
4969
|
this.id,
|
|
4964
4970
|
{
|
|
4965
4971
|
input
|
|
4966
|
-
// We now always use the input field (instead of message)
|
|
4967
4972
|
},
|
|
4968
4973
|
"agent",
|
|
4969
4974
|
context
|
|
4970
4975
|
);
|
|
4971
|
-
this.createStandardTimelineEvent(
|
|
4972
|
-
context.historyEntry.id,
|
|
4973
|
-
"start",
|
|
4974
|
-
initialStatus,
|
|
4975
|
-
"agent" /* AGENT */,
|
|
4976
|
-
this.id,
|
|
4977
|
-
{},
|
|
4978
|
-
"agent",
|
|
4979
|
-
context
|
|
4980
|
-
);
|
|
4981
4976
|
return context;
|
|
4982
4977
|
});
|
|
4983
4978
|
}
|
|
@@ -5043,6 +5038,7 @@ ${context}`;
|
|
|
5043
5038
|
parentAgentId: internalOptions.parentAgentId,
|
|
5044
5039
|
parentHistoryEntryId: internalOptions.parentHistoryEntryId
|
|
5045
5040
|
});
|
|
5041
|
+
let messages = [];
|
|
5046
5042
|
try {
|
|
5047
5043
|
yield (_b = (_a = this.hooks).onStart) == null ? void 0 : _b.call(_a, { agent: this, context: operationContext });
|
|
5048
5044
|
const { userId, conversationId, contextLimit = 10, provider, signal } = internalOptions;
|
|
@@ -5058,8 +5054,20 @@ ${context}`;
|
|
|
5058
5054
|
historyEntryId: operationContext.historyEntry.id,
|
|
5059
5055
|
contextMessages
|
|
5060
5056
|
});
|
|
5061
|
-
|
|
5057
|
+
messages = [systemMessage, ...contextMessages];
|
|
5062
5058
|
messages = yield this.formatInputMessages(messages, input);
|
|
5059
|
+
this.createStandardTimelineEvent(
|
|
5060
|
+
operationContext.historyEntry.id,
|
|
5061
|
+
"start",
|
|
5062
|
+
"working",
|
|
5063
|
+
"agent" /* AGENT */,
|
|
5064
|
+
this.id,
|
|
5065
|
+
{
|
|
5066
|
+
input: messages
|
|
5067
|
+
},
|
|
5068
|
+
"agent",
|
|
5069
|
+
operationContext
|
|
5070
|
+
);
|
|
5063
5071
|
const onStepFinish = this.memoryManager.createStepFinishHandler(
|
|
5064
5072
|
operationContext,
|
|
5065
5073
|
userId,
|
|
@@ -5100,7 +5108,11 @@ ${context}`;
|
|
|
5100
5108
|
);
|
|
5101
5109
|
operationContext.eventUpdaters.set(step.id, eventUpdater);
|
|
5102
5110
|
if (tool2) {
|
|
5103
|
-
yield (_b2 = (_a2 = this.hooks).onToolStart) == null ? void 0 : _b2.call(_a2, {
|
|
5111
|
+
yield (_b2 = (_a2 = this.hooks).onToolStart) == null ? void 0 : _b2.call(_a2, {
|
|
5112
|
+
agent: this,
|
|
5113
|
+
tool: tool2,
|
|
5114
|
+
context: operationContext
|
|
5115
|
+
});
|
|
5104
5116
|
}
|
|
5105
5117
|
}
|
|
5106
5118
|
} else if (step.type === "tool_result") {
|
|
@@ -5143,6 +5155,7 @@ ${context}`;
|
|
|
5143
5155
|
status: "completed"
|
|
5144
5156
|
});
|
|
5145
5157
|
this.addAgentEvent(operationContext, "finished", "completed", {
|
|
5158
|
+
input: messages,
|
|
5146
5159
|
output: response.text,
|
|
5147
5160
|
usage: response.usage,
|
|
5148
5161
|
affectedNodeId: `agent_${this.id}`,
|
|
@@ -5171,6 +5184,7 @@ ${context}`;
|
|
|
5171
5184
|
const voltagentError = error;
|
|
5172
5185
|
operationContext.eventUpdaters.clear();
|
|
5173
5186
|
this.addAgentEvent(operationContext, "finished", "error", {
|
|
5187
|
+
input: messages,
|
|
5174
5188
|
error: voltagentError,
|
|
5175
5189
|
errorMessage: voltagentError.message,
|
|
5176
5190
|
affectedNodeId: `agent_${this.id}`,
|
|
@@ -5224,6 +5238,18 @@ ${context}`;
|
|
|
5224
5238
|
});
|
|
5225
5239
|
let messages = [systemMessage, ...contextMessages];
|
|
5226
5240
|
messages = yield this.formatInputMessages(messages, input);
|
|
5241
|
+
this.createStandardTimelineEvent(
|
|
5242
|
+
operationContext.historyEntry.id,
|
|
5243
|
+
"start",
|
|
5244
|
+
"working",
|
|
5245
|
+
"agent" /* AGENT */,
|
|
5246
|
+
this.id,
|
|
5247
|
+
{
|
|
5248
|
+
input: messages
|
|
5249
|
+
},
|
|
5250
|
+
"agent",
|
|
5251
|
+
operationContext
|
|
5252
|
+
);
|
|
5227
5253
|
const onStepFinish = this.memoryManager.createStepFinishHandler(
|
|
5228
5254
|
operationContext,
|
|
5229
5255
|
userId,
|
|
@@ -5263,7 +5289,11 @@ ${context}`;
|
|
|
5263
5289
|
);
|
|
5264
5290
|
operationContext.eventUpdaters.set(chunk.id, eventUpdater);
|
|
5265
5291
|
if (tool2) {
|
|
5266
|
-
yield (_b2 = (_a2 = this.hooks).onToolStart) == null ? void 0 : _b2.call(_a2, {
|
|
5292
|
+
yield (_b2 = (_a2 = this.hooks).onToolStart) == null ? void 0 : _b2.call(_a2, {
|
|
5293
|
+
agent: this,
|
|
5294
|
+
tool: tool2,
|
|
5295
|
+
context: operationContext
|
|
5296
|
+
});
|
|
5267
5297
|
}
|
|
5268
5298
|
}
|
|
5269
5299
|
} else if (chunk.type === "tool_result") {
|
|
@@ -5305,6 +5335,9 @@ ${context}`;
|
|
|
5305
5335
|
}),
|
|
5306
5336
|
onFinish: (result) => __async(this, null, function* () {
|
|
5307
5337
|
var _a2, _b2;
|
|
5338
|
+
if (!operationContext.isActive) {
|
|
5339
|
+
return;
|
|
5340
|
+
}
|
|
5308
5341
|
operationContext.eventUpdaters.clear();
|
|
5309
5342
|
this.updateHistoryEntry(operationContext, {
|
|
5310
5343
|
output: result.text,
|
|
@@ -5314,6 +5347,7 @@ ${context}`;
|
|
|
5314
5347
|
status: "completed"
|
|
5315
5348
|
});
|
|
5316
5349
|
this.addAgentEvent(operationContext, "finished", "completed", {
|
|
5350
|
+
input: messages,
|
|
5317
5351
|
output: result.text,
|
|
5318
5352
|
usage: result.usage,
|
|
5319
5353
|
affectedNodeId: `agent_${this.id}`,
|
|
@@ -5376,6 +5410,7 @@ ${context}`;
|
|
|
5376
5410
|
errorMessage: error.message,
|
|
5377
5411
|
// Use the main message
|
|
5378
5412
|
affectedNodeId: `agent_${this.id}`,
|
|
5413
|
+
input: messages,
|
|
5379
5414
|
status: "error",
|
|
5380
5415
|
metadata: __spreadValues({
|
|
5381
5416
|
// Include metadata if available
|
|
@@ -5417,6 +5452,7 @@ ${context}`;
|
|
|
5417
5452
|
parentAgentId: internalOptions.parentAgentId,
|
|
5418
5453
|
parentHistoryEntryId: internalOptions.parentHistoryEntryId
|
|
5419
5454
|
});
|
|
5455
|
+
let messages = [];
|
|
5420
5456
|
try {
|
|
5421
5457
|
yield (_b = (_a = this.hooks).onStart) == null ? void 0 : _b.call(_a, { agent: this, context: operationContext });
|
|
5422
5458
|
const { userId, conversationId, contextLimit = 10, provider, signal } = internalOptions;
|
|
@@ -5432,8 +5468,20 @@ ${context}`;
|
|
|
5432
5468
|
historyEntryId: operationContext.historyEntry.id,
|
|
5433
5469
|
contextMessages
|
|
5434
5470
|
});
|
|
5435
|
-
|
|
5471
|
+
messages = [systemMessage, ...contextMessages];
|
|
5436
5472
|
messages = yield this.formatInputMessages(messages, input);
|
|
5473
|
+
this.createStandardTimelineEvent(
|
|
5474
|
+
operationContext.historyEntry.id,
|
|
5475
|
+
"start",
|
|
5476
|
+
"working",
|
|
5477
|
+
"agent" /* AGENT */,
|
|
5478
|
+
this.id,
|
|
5479
|
+
{
|
|
5480
|
+
input: messages
|
|
5481
|
+
},
|
|
5482
|
+
"agent",
|
|
5483
|
+
operationContext
|
|
5484
|
+
);
|
|
5437
5485
|
const onStepFinish = this.memoryManager.createStepFinishHandler(
|
|
5438
5486
|
operationContext,
|
|
5439
5487
|
userId,
|
|
@@ -5463,7 +5511,8 @@ ${context}`;
|
|
|
5463
5511
|
output: responseStr,
|
|
5464
5512
|
usage: response.usage,
|
|
5465
5513
|
affectedNodeId: `agent_${this.id}`,
|
|
5466
|
-
status: "completed"
|
|
5514
|
+
status: "completed",
|
|
5515
|
+
input: messages
|
|
5467
5516
|
});
|
|
5468
5517
|
this.updateHistoryEntry(operationContext, {
|
|
5469
5518
|
output: responseStr,
|
|
@@ -5495,6 +5544,7 @@ ${context}`;
|
|
|
5495
5544
|
// Use the standardized message
|
|
5496
5545
|
affectedNodeId: `agent_${this.id}`,
|
|
5497
5546
|
status: "error",
|
|
5547
|
+
input: messages,
|
|
5498
5548
|
metadata: __spreadValues({
|
|
5499
5549
|
// Include detailed metadata from VoltAgentError
|
|
5500
5550
|
code: voltagentError.code,
|
|
@@ -5530,6 +5580,7 @@ ${context}`;
|
|
|
5530
5580
|
parentAgentId: internalOptions.parentAgentId,
|
|
5531
5581
|
parentHistoryEntryId: internalOptions.parentHistoryEntryId
|
|
5532
5582
|
});
|
|
5583
|
+
let messages = [];
|
|
5533
5584
|
try {
|
|
5534
5585
|
yield (_b = (_a = this.hooks).onStart) == null ? void 0 : _b.call(_a, { agent: this, context: operationContext });
|
|
5535
5586
|
const { userId, conversationId, contextLimit = 10, signal } = internalOptions;
|
|
@@ -5545,8 +5596,20 @@ ${context}`;
|
|
|
5545
5596
|
historyEntryId: operationContext.historyEntry.id,
|
|
5546
5597
|
contextMessages
|
|
5547
5598
|
});
|
|
5548
|
-
|
|
5599
|
+
messages = [systemMessage, ...contextMessages];
|
|
5549
5600
|
messages = yield this.formatInputMessages(messages, input);
|
|
5601
|
+
this.createStandardTimelineEvent(
|
|
5602
|
+
operationContext.historyEntry.id,
|
|
5603
|
+
"start",
|
|
5604
|
+
"working",
|
|
5605
|
+
"agent" /* AGENT */,
|
|
5606
|
+
this.id,
|
|
5607
|
+
{
|
|
5608
|
+
input: messages
|
|
5609
|
+
},
|
|
5610
|
+
"agent",
|
|
5611
|
+
operationContext
|
|
5612
|
+
);
|
|
5550
5613
|
const onStepFinish = this.memoryManager.createStepFinishHandler(
|
|
5551
5614
|
operationContext,
|
|
5552
5615
|
userId,
|
|
@@ -5572,8 +5635,12 @@ ${context}`;
|
|
|
5572
5635
|
}),
|
|
5573
5636
|
onFinish: (result) => __async(this, null, function* () {
|
|
5574
5637
|
var _a2, _b2;
|
|
5638
|
+
if (!operationContext.isActive) {
|
|
5639
|
+
return;
|
|
5640
|
+
}
|
|
5575
5641
|
const responseStr = JSON.stringify(result.object);
|
|
5576
5642
|
this.addAgentEvent(operationContext, "finished", "completed", {
|
|
5643
|
+
input: messages,
|
|
5577
5644
|
output: responseStr,
|
|
5578
5645
|
usage: result.usage,
|
|
5579
5646
|
affectedNodeId: `agent_${this.id}`,
|
|
@@ -5641,6 +5708,7 @@ ${context}`;
|
|
|
5641
5708
|
}
|
|
5642
5709
|
operationContext.eventUpdaters.clear();
|
|
5643
5710
|
this.addAgentEvent(operationContext, "finished", "error", {
|
|
5711
|
+
input: messages,
|
|
5644
5712
|
error,
|
|
5645
5713
|
errorMessage: error.message,
|
|
5646
5714
|
affectedNodeId: `agent_${this.id}`,
|
|
@@ -5672,6 +5740,7 @@ ${context}`;
|
|
|
5672
5740
|
return typedResponse;
|
|
5673
5741
|
} catch (error) {
|
|
5674
5742
|
this.addAgentEvent(operationContext, "finished", "error", {
|
|
5743
|
+
input: messages,
|
|
5675
5744
|
error,
|
|
5676
5745
|
errorMessage: error instanceof Error ? error.message : "Unknown error",
|
|
5677
5746
|
affectedNodeId: `agent_${this.id}`,
|