@voltagent/libsql 2.0.1 → 2.0.3

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/edge.mjs CHANGED
@@ -588,6 +588,19 @@ var LibSQLMemoryCore = class {
588
588
  });
589
589
  }
590
590
  }
591
+ async deleteMessages(messageIds, userId, conversationId) {
592
+ await this.initialize();
593
+ if (messageIds.length === 0) {
594
+ return;
595
+ }
596
+ const messagesTable = `${this.tablePrefix}_messages`;
597
+ const placeholders = messageIds.map(() => "?").join(",");
598
+ const sql = `DELETE FROM ${messagesTable} WHERE conversation_id = ? AND user_id = ? AND message_id IN (${placeholders})`;
599
+ await this.client.execute({
600
+ sql,
601
+ args: [conversationId, userId, ...messageIds]
602
+ });
603
+ }
591
604
  // ============================================================================
592
605
  // Conversation Operations
593
606
  // ============================================================================
@@ -700,6 +713,23 @@ var LibSQLMemoryCore = class {
700
713
  updatedAt: row.updated_at
701
714
  }));
702
715
  }
716
+ async countConversations(options) {
717
+ await this.initialize();
718
+ const conversationsTable = `${this.tablePrefix}_conversations`;
719
+ let sql = `SELECT COUNT(*) as count FROM ${conversationsTable} WHERE 1=1`;
720
+ const args = [];
721
+ if (options.userId) {
722
+ sql += " AND user_id = ?";
723
+ args.push(options.userId);
724
+ }
725
+ if (options.resourceId) {
726
+ sql += " AND resource_id = ?";
727
+ args.push(options.resourceId);
728
+ }
729
+ const result = await this.client.execute({ sql, args });
730
+ const count = Number(result.rows[0]?.count ?? 0);
731
+ return Number.isNaN(count) ? 0 : count;
732
+ }
703
733
  async updateConversation(id, updates) {
704
734
  await this.initialize();
705
735
  const conversationsTable = `${this.tablePrefix}_conversations`;