@voltagent/libsql 2.0.2 → 2.1.0
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.d.mts +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.js +38 -3
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +38 -3
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +38 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{vector-core-CKn8FNVK.d.mts → vector-core-J7BkPuy8.d.mts} +2 -0
- package/dist/{vector-core-CKn8FNVK.d.ts → vector-core-J7BkPuy8.d.ts} +2 -0
- package/package.json +2 -2
package/dist/edge.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger } from '@voltagent/logger';
|
|
2
|
-
import { L as LibSQLMemoryCore, a as LibSQLMemoryCoreOptions, b as LibSQLObservabilityCore, c as LibSQLObservabilityCoreOptions, d as LibSQLVectorCore, e as LibSQLVectorCoreOptions } from './vector-core-
|
|
2
|
+
import { L as LibSQLMemoryCore, a as LibSQLMemoryCoreOptions, b as LibSQLObservabilityCore, c as LibSQLObservabilityCoreOptions, d as LibSQLVectorCore, e as LibSQLVectorCoreOptions } from './vector-core-J7BkPuy8.mjs';
|
|
3
3
|
import '@libsql/client';
|
|
4
4
|
import '@voltagent/core';
|
|
5
5
|
import 'ai';
|
package/dist/edge.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger } from '@voltagent/logger';
|
|
2
|
-
import { L as LibSQLMemoryCore, a as LibSQLMemoryCoreOptions, b as LibSQLObservabilityCore, c as LibSQLObservabilityCoreOptions, d as LibSQLVectorCore, e as LibSQLVectorCoreOptions } from './vector-core-
|
|
2
|
+
import { L as LibSQLMemoryCore, a as LibSQLMemoryCoreOptions, b as LibSQLObservabilityCore, c as LibSQLObservabilityCoreOptions, d as LibSQLVectorCore, e as LibSQLVectorCoreOptions } from './vector-core-J7BkPuy8.js';
|
|
3
3
|
import '@libsql/client';
|
|
4
4
|
import '@voltagent/core';
|
|
5
5
|
import 'ai';
|
package/dist/edge.js
CHANGED
|
@@ -483,8 +483,12 @@ var LibSQLMemoryCore = class {
|
|
|
483
483
|
await this.initialize();
|
|
484
484
|
const messagesTable = `${this.tablePrefix}_messages`;
|
|
485
485
|
const { limit, before, after, roles } = options || {};
|
|
486
|
-
let sql = `
|
|
487
|
-
|
|
486
|
+
let sql = `
|
|
487
|
+
SELECT * FROM (
|
|
488
|
+
SELECT *
|
|
489
|
+
FROM ${messagesTable}
|
|
490
|
+
WHERE conversation_id = ? AND user_id = ?
|
|
491
|
+
`;
|
|
488
492
|
const args = [conversationId, userId];
|
|
489
493
|
if (roles && roles.length > 0) {
|
|
490
494
|
const placeholders = roles.map(() => "?").join(",");
|
|
@@ -499,11 +503,12 @@ var LibSQLMemoryCore = class {
|
|
|
499
503
|
sql += " AND created_at > ?";
|
|
500
504
|
args.push(after.toISOString());
|
|
501
505
|
}
|
|
502
|
-
sql += " ORDER BY created_at
|
|
506
|
+
sql += " ORDER BY created_at DESC";
|
|
503
507
|
if (limit && limit > 0) {
|
|
504
508
|
sql += " LIMIT ?";
|
|
505
509
|
args.push(limit);
|
|
506
510
|
}
|
|
511
|
+
sql += " ) AS subq ORDER BY created_at ASC";
|
|
507
512
|
const result = await this.client.execute({ sql, args });
|
|
508
513
|
return result.rows.map((row) => {
|
|
509
514
|
let parts;
|
|
@@ -617,6 +622,19 @@ var LibSQLMemoryCore = class {
|
|
|
617
622
|
});
|
|
618
623
|
}
|
|
619
624
|
}
|
|
625
|
+
async deleteMessages(messageIds, userId, conversationId) {
|
|
626
|
+
await this.initialize();
|
|
627
|
+
if (messageIds.length === 0) {
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
const messagesTable = `${this.tablePrefix}_messages`;
|
|
631
|
+
const placeholders = messageIds.map(() => "?").join(",");
|
|
632
|
+
const sql = `DELETE FROM ${messagesTable} WHERE conversation_id = ? AND user_id = ? AND message_id IN (${placeholders})`;
|
|
633
|
+
await this.client.execute({
|
|
634
|
+
sql,
|
|
635
|
+
args: [conversationId, userId, ...messageIds]
|
|
636
|
+
});
|
|
637
|
+
}
|
|
620
638
|
// ============================================================================
|
|
621
639
|
// Conversation Operations
|
|
622
640
|
// ============================================================================
|
|
@@ -729,6 +747,23 @@ var LibSQLMemoryCore = class {
|
|
|
729
747
|
updatedAt: row.updated_at
|
|
730
748
|
}));
|
|
731
749
|
}
|
|
750
|
+
async countConversations(options) {
|
|
751
|
+
await this.initialize();
|
|
752
|
+
const conversationsTable = `${this.tablePrefix}_conversations`;
|
|
753
|
+
let sql = `SELECT COUNT(*) as count FROM ${conversationsTable} WHERE 1=1`;
|
|
754
|
+
const args = [];
|
|
755
|
+
if (options.userId) {
|
|
756
|
+
sql += " AND user_id = ?";
|
|
757
|
+
args.push(options.userId);
|
|
758
|
+
}
|
|
759
|
+
if (options.resourceId) {
|
|
760
|
+
sql += " AND resource_id = ?";
|
|
761
|
+
args.push(options.resourceId);
|
|
762
|
+
}
|
|
763
|
+
const result = await this.client.execute({ sql, args });
|
|
764
|
+
const count = Number(result.rows[0]?.count ?? 0);
|
|
765
|
+
return Number.isNaN(count) ? 0 : count;
|
|
766
|
+
}
|
|
732
767
|
async updateConversation(id, updates) {
|
|
733
768
|
await this.initialize();
|
|
734
769
|
const conversationsTable = `${this.tablePrefix}_conversations`;
|