@voltagent/core 0.1.32 → 0.1.33
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 +3 -4
- package/dist/index.js +17 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -324,7 +324,7 @@ type Memory = {
|
|
|
324
324
|
/**
|
|
325
325
|
* Add a message to memory
|
|
326
326
|
*/
|
|
327
|
-
addMessage(message: BaseMessage,
|
|
327
|
+
addMessage(message: BaseMessage, conversationId?: string): Promise<void>;
|
|
328
328
|
/**
|
|
329
329
|
* Get messages from memory
|
|
330
330
|
*/
|
|
@@ -1747,10 +1747,9 @@ declare class InMemoryStorage implements Memory {
|
|
|
1747
1747
|
/**
|
|
1748
1748
|
* Add a message to the conversation history
|
|
1749
1749
|
* @param message Message to add
|
|
1750
|
-
* @param userId User identifier (optional, defaults to "default")
|
|
1751
1750
|
* @param conversationId Conversation identifier (optional, defaults to "default")
|
|
1752
1751
|
*/
|
|
1753
|
-
addMessage(message: MemoryMessage,
|
|
1752
|
+
addMessage(message: MemoryMessage, conversationId?: string): Promise<void>;
|
|
1754
1753
|
/**
|
|
1755
1754
|
* Clear all messages for a user and optionally a specific conversation
|
|
1756
1755
|
* @param options Options specifying which messages to clear
|
|
@@ -1979,7 +1978,7 @@ declare class LibSQLStorage implements Memory {
|
|
|
1979
1978
|
* @param userId User identifier (optional, defaults to "default")
|
|
1980
1979
|
* @param conversationId Conversation identifier (optional, defaults to "default")
|
|
1981
1980
|
*/
|
|
1982
|
-
addMessage(message: MemoryMessage,
|
|
1981
|
+
addMessage(message: MemoryMessage, conversationId?: string): Promise<void>;
|
|
1983
1982
|
/**
|
|
1984
1983
|
* Prune old messages to respect storage limit
|
|
1985
1984
|
* @param conversationId Conversation ID to prune messages for
|
package/dist/index.js
CHANGED
|
@@ -2529,12 +2529,18 @@ var InMemoryStorage = class {
|
|
|
2529
2529
|
/**
|
|
2530
2530
|
* Add a message to the conversation history
|
|
2531
2531
|
* @param message Message to add
|
|
2532
|
-
* @param userId User identifier (optional, defaults to "default")
|
|
2533
2532
|
* @param conversationId Conversation identifier (optional, defaults to "default")
|
|
2534
2533
|
*/
|
|
2535
|
-
addMessage(message,
|
|
2534
|
+
addMessage(message, conversationId = "default") {
|
|
2536
2535
|
return __async(this, null, function* () {
|
|
2537
|
-
this.debug(`Adding message for
|
|
2536
|
+
this.debug(`Adding message for conversation ${conversationId}`, message);
|
|
2537
|
+
const conversation = yield this.getConversation(conversationId);
|
|
2538
|
+
let userId = "default";
|
|
2539
|
+
if (conversation) {
|
|
2540
|
+
userId = conversation.userId;
|
|
2541
|
+
} else {
|
|
2542
|
+
this.debug(`Conversation ${conversationId} not found, using default user`);
|
|
2543
|
+
}
|
|
2538
2544
|
if (!this.storage[userId]) {
|
|
2539
2545
|
this.storage[userId] = {};
|
|
2540
2546
|
}
|
|
@@ -3289,14 +3295,7 @@ var LibSQLStorage = class {
|
|
|
3289
3295
|
return __async(this, arguments, function* (options = {}) {
|
|
3290
3296
|
yield this.initialized;
|
|
3291
3297
|
yield debugDelay();
|
|
3292
|
-
const {
|
|
3293
|
-
userId = "default",
|
|
3294
|
-
conversationId = "default",
|
|
3295
|
-
limit = this.options.storageLimit,
|
|
3296
|
-
before,
|
|
3297
|
-
after,
|
|
3298
|
-
role
|
|
3299
|
-
} = options;
|
|
3298
|
+
const { userId = "default", conversationId = "default", limit, before, after, role } = options;
|
|
3300
3299
|
const messagesTableName = `${this.options.tablePrefix}_messages`;
|
|
3301
3300
|
const conversationsTableName = `${this.options.tablePrefix}_conversations`;
|
|
3302
3301
|
try {
|
|
@@ -3358,7 +3357,7 @@ var LibSQLStorage = class {
|
|
|
3358
3357
|
* @param userId User identifier (optional, defaults to "default")
|
|
3359
3358
|
* @param conversationId Conversation identifier (optional, defaults to "default")
|
|
3360
3359
|
*/
|
|
3361
|
-
addMessage(message,
|
|
3360
|
+
addMessage(message, conversationId = "default") {
|
|
3362
3361
|
return __async(this, null, function* () {
|
|
3363
3362
|
yield this.initialized;
|
|
3364
3363
|
yield debugDelay();
|
|
@@ -3376,7 +3375,7 @@ var LibSQLStorage = class {
|
|
|
3376
3375
|
message.createdAt
|
|
3377
3376
|
]
|
|
3378
3377
|
});
|
|
3379
|
-
this.debug("Message added successfully", {
|
|
3378
|
+
this.debug("Message added successfully", { conversationId, messageId: message.id });
|
|
3380
3379
|
try {
|
|
3381
3380
|
yield this.pruneOldMessages(conversationId);
|
|
3382
3381
|
} catch (pruneError) {
|
|
@@ -5203,7 +5202,7 @@ var MemoryManager = class {
|
|
|
5203
5202
|
yield this.publishTimelineEvent(context, memoryWriteStartEvent);
|
|
5204
5203
|
try {
|
|
5205
5204
|
const memoryMessage = convertToMemoryMessage(message, type);
|
|
5206
|
-
yield this.memory.addMessage(memoryMessage,
|
|
5205
|
+
yield this.memory.addMessage(memoryMessage, conversationId);
|
|
5207
5206
|
const memoryWriteSuccessEvent = {
|
|
5208
5207
|
id: crypto.randomUUID(),
|
|
5209
5208
|
name: "memory:write_success",
|
|
@@ -5289,6 +5288,9 @@ var MemoryManager = class {
|
|
|
5289
5288
|
prepareConversationContext(context, input, userId, conversationIdParam, contextLimit = 10) {
|
|
5290
5289
|
return __async(this, null, function* () {
|
|
5291
5290
|
const conversationId = conversationIdParam || crypto.randomUUID();
|
|
5291
|
+
if (contextLimit === 0) {
|
|
5292
|
+
return { messages: [], conversationId };
|
|
5293
|
+
}
|
|
5292
5294
|
let messages = [];
|
|
5293
5295
|
if (this.memory && userId) {
|
|
5294
5296
|
const existingConversation = yield this.memory.getConversation(conversationId);
|
|
@@ -6369,7 +6371,7 @@ ${agentsMemory || "No previous agent interactions available."}
|
|
|
6369
6371
|
const handoffConversationId = conversationId || crypto.randomUUID();
|
|
6370
6372
|
try {
|
|
6371
6373
|
if (sourceAgent && targetAgent.hooks) {
|
|
6372
|
-
yield (_b = (_a = targetAgent.hooks).onHandoff) == null ? void 0 : _b.call(_a, targetAgent, sourceAgent);
|
|
6374
|
+
yield (_b = (_a = targetAgent.hooks).onHandoff) == null ? void 0 : _b.call(_a, { agent: targetAgent, source: sourceAgent });
|
|
6373
6375
|
}
|
|
6374
6376
|
const sharedContext = options.sharedContext || [];
|
|
6375
6377
|
const handoffMessage = {
|