@voltagent/core 0.1.32 → 0.1.34

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 CHANGED
@@ -324,7 +324,7 @@ type Memory = {
324
324
  /**
325
325
  * Add a message to memory
326
326
  */
327
- addMessage(message: BaseMessage, userId: string, conversationId?: string): Promise<void>;
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, userId?: string, conversationId?: string): Promise<void>;
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, userId?: string, conversationId?: string): Promise<void>;
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, userId = "default", conversationId = "default") {
2534
+ addMessage(message, conversationId = "default") {
2536
2535
  return __async(this, null, function* () {
2537
- this.debug(`Adding message for user ${userId} and conversation ${conversationId}`, message);
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,11 +3357,12 @@ 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, userId = "default", conversationId = "default") {
3360
+ addMessage(message, conversationId = "default") {
3362
3361
  return __async(this, null, function* () {
3363
3362
  yield this.initialized;
3364
3363
  yield debugDelay();
3365
3364
  const tableName = `${this.options.tablePrefix}_messages`;
3365
+ const contentString = JSON.stringify(message.content);
3366
3366
  try {
3367
3367
  yield this.client.execute({
3368
3368
  sql: `INSERT INTO ${tableName} (conversation_id, message_id, role, content, type, created_at)
@@ -3371,12 +3371,12 @@ var LibSQLStorage = class {
3371
3371
  conversationId,
3372
3372
  message.id,
3373
3373
  message.role,
3374
- message.content,
3374
+ contentString,
3375
3375
  message.type,
3376
3376
  message.createdAt
3377
3377
  ]
3378
3378
  });
3379
- this.debug("Message added successfully", { userId, conversationId, messageId: message.id });
3379
+ this.debug("Message added successfully", { conversationId, messageId: message.id });
3380
3380
  try {
3381
3381
  yield this.pruneOldMessages(conversationId);
3382
3382
  } catch (pruneError) {
@@ -5203,7 +5203,7 @@ var MemoryManager = class {
5203
5203
  yield this.publishTimelineEvent(context, memoryWriteStartEvent);
5204
5204
  try {
5205
5205
  const memoryMessage = convertToMemoryMessage(message, type);
5206
- yield this.memory.addMessage(memoryMessage, userId, conversationId);
5206
+ yield this.memory.addMessage(memoryMessage, conversationId);
5207
5207
  const memoryWriteSuccessEvent = {
5208
5208
  id: crypto.randomUUID(),
5209
5209
  name: "memory:write_success",
@@ -5289,6 +5289,9 @@ var MemoryManager = class {
5289
5289
  prepareConversationContext(context, input, userId, conversationIdParam, contextLimit = 10) {
5290
5290
  return __async(this, null, function* () {
5291
5291
  const conversationId = conversationIdParam || crypto.randomUUID();
5292
+ if (contextLimit === 0) {
5293
+ return { messages: [], conversationId };
5294
+ }
5292
5295
  let messages = [];
5293
5296
  if (this.memory && userId) {
5294
5297
  const existingConversation = yield this.memory.getConversation(conversationId);
@@ -6369,7 +6372,7 @@ ${agentsMemory || "No previous agent interactions available."}
6369
6372
  const handoffConversationId = conversationId || crypto.randomUUID();
6370
6373
  try {
6371
6374
  if (sourceAgent && targetAgent.hooks) {
6372
- yield (_b = (_a = targetAgent.hooks).onHandoff) == null ? void 0 : _b.call(_a, targetAgent, sourceAgent);
6375
+ yield (_b = (_a = targetAgent.hooks).onHandoff) == null ? void 0 : _b.call(_a, { agent: targetAgent, source: sourceAgent });
6373
6376
  }
6374
6377
  const sharedContext = options.sharedContext || [];
6375
6378
  const handoffMessage = {