@mastra/libsql 1.22.3-alpha.1 → 1.22.3-alpha.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/README.md +13 -107
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-studio-editor.md +1 -1
- package/dist/index.cjs +128 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +128 -27
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/agents/index.d.ts +1 -0
- package/dist/storage/domains/agents/index.d.ts.map +1 -1
- package/dist/storage/domains/skills/index.d.ts +1 -0
- package/dist/storage/domains/skills/index.d.ts.map +1 -1
- package/dist/vector/index.d.ts +6 -0
- package/dist/vector/index.d.ts.map +1 -1
- package/dist/vector/sql-builder.d.ts.map +1 -1
- package/dist/vector/write-lock.d.ts +7 -0
- package/dist/vector/write-lock.d.ts.map +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -16,27 +16,30 @@ npm install @mastra/libsql
|
|
|
16
16
|
import { LibSQLVector } from '@mastra/libsql';
|
|
17
17
|
|
|
18
18
|
const vectorStore = new LibSQLVector({
|
|
19
|
-
url: 'file:./my-db.db'
|
|
19
|
+
url: 'file:./my-db.db',
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
// Create a new table with vector support
|
|
23
23
|
await vectorStore.createIndex({
|
|
24
24
|
indexName: 'my_vectors',
|
|
25
|
-
dimension:
|
|
25
|
+
dimension: 3,
|
|
26
26
|
metric: 'cosine',
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
// Add vectors
|
|
30
30
|
const ids = await vectorStore.upsert({
|
|
31
31
|
indexName: 'my_vectors',
|
|
32
|
-
vectors: [
|
|
32
|
+
vectors: [
|
|
33
|
+
[0.1, 0.2, 0.3],
|
|
34
|
+
[0.3, 0.4, 0.5],
|
|
35
|
+
],
|
|
33
36
|
metadata: [{ text: 'doc1' }, { text: 'doc2' }],
|
|
34
37
|
});
|
|
35
38
|
|
|
36
39
|
// Query vectors
|
|
37
40
|
const results = await vectorStore.query({
|
|
38
41
|
indexName: 'my_vectors',
|
|
39
|
-
queryVector: [0.1, 0.2,
|
|
42
|
+
queryVector: [0.1, 0.2, 0.3],
|
|
40
43
|
topK: 10, // topK
|
|
41
44
|
filter: { text: 'doc1' }, // filter
|
|
42
45
|
includeVector: false, // includeVector
|
|
@@ -44,111 +47,14 @@ const results = await vectorStore.query({
|
|
|
44
47
|
});
|
|
45
48
|
```
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
```typescript
|
|
50
|
-
import { LibSQLStore } from '@mastra/libsql';
|
|
51
|
-
|
|
52
|
-
const store = new LibSQLStore({
|
|
53
|
-
id: 'libsql-storage',
|
|
54
|
-
url: 'file:./my-db.db',
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// Create a thread
|
|
58
|
-
await store.saveThread({
|
|
59
|
-
thread: {
|
|
60
|
-
id: 'thread-123',
|
|
61
|
-
resourceId: 'resource-456',
|
|
62
|
-
title: 'My Thread',
|
|
63
|
-
metadata: { key: 'value' },
|
|
64
|
-
createdAt: new Date(),
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// Add messages to thread
|
|
69
|
-
await store.saveMessages({
|
|
70
|
-
messages: [
|
|
71
|
-
{
|
|
72
|
-
id: 'msg-789',
|
|
73
|
-
threadId: 'thread-123',
|
|
74
|
-
role: 'user',
|
|
75
|
-
content: { content: 'Hello' },
|
|
76
|
-
resourceId: 'resource-456',
|
|
77
|
-
createdAt: new Date(),
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
// Query threads and messages
|
|
83
|
-
const savedThread = await store.getThreadById({ threadId: 'thread-123' });
|
|
84
|
-
const messages = await store.listMessages({ threadId: 'thread-123' });
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Configuration
|
|
88
|
-
|
|
89
|
-
The LibSQLStore store can be initialized with:
|
|
90
|
-
|
|
91
|
-
- Configuration object with url and auth. Auth is only necessary when using a provider like [Turso](https://turso.tech/)
|
|
92
|
-
|
|
93
|
-
## Features
|
|
94
|
-
|
|
95
|
-
### Vector Store Features
|
|
96
|
-
|
|
97
|
-
- Vector similarity search with cosine, euclidean, and dot product metrics
|
|
98
|
-
- Advanced metadata filtering with MongoDB-like query syntax
|
|
99
|
-
- Minimum score threshold for queries
|
|
100
|
-
- Automatic UUID generation for vectors
|
|
101
|
-
- Table management (create, list, describe, delete, truncate)
|
|
102
|
-
|
|
103
|
-
### Storage Features
|
|
104
|
-
|
|
105
|
-
- Thread and message storage with JSON support
|
|
106
|
-
- Atomic transactions for data consistency
|
|
107
|
-
- Efficient batch operations
|
|
108
|
-
- Rich metadata support
|
|
109
|
-
- Timestamp tracking
|
|
110
|
-
- Cascading deletes
|
|
111
|
-
|
|
112
|
-
## Supported Filter Operators
|
|
113
|
-
|
|
114
|
-
The following filter operators are supported for metadata queries:
|
|
115
|
-
|
|
116
|
-
- Comparison: `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`
|
|
117
|
-
- Logical: `$and`, `$or`
|
|
118
|
-
- Array: `$in`, `$nin`
|
|
119
|
-
- Text: `$regex`, `$like`
|
|
120
|
-
|
|
121
|
-
Example filter:
|
|
122
|
-
|
|
123
|
-
```typescript
|
|
124
|
-
{
|
|
125
|
-
$and: [{ age: { $gt: 25 } }, { tags: { $in: ['tag1', 'tag2'] } }];
|
|
126
|
-
}
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## Vector Store Methods
|
|
50
|
+
## Documentation
|
|
130
51
|
|
|
131
|
-
-
|
|
132
|
-
- `upsert({indexName, vectors, metadata?, ids?})`: Add or update vectors
|
|
133
|
-
- `query({indexName, queryVector, topK?, filter?, includeVector?, minScore?})`: Search for similar vectors
|
|
134
|
-
- `updateVector({ indexName, id?, filter?, update })`: Update a single vector by ID or metadata filter
|
|
135
|
-
- `deleteVector({ indexName, id })`: Delete a single vector by ID
|
|
136
|
-
- `deleteVectors({ indexName, ids?, filter? })`: Delete multiple vectors by IDs or metadata filter
|
|
137
|
-
- `defineIndex({indexName, metric?, indexConfig?})`: Define an index
|
|
138
|
-
- `listIndexes()`: List all vector-enabled tables
|
|
139
|
-
- `describeIndex(indexName)`: Get table statistics
|
|
140
|
-
- `deleteIndex(indexName)`: Delete a table
|
|
141
|
-
- `truncateIndex(indexName)`: Remove all data from a table
|
|
52
|
+
- [@mastra/libsql documentation](https://mastra.ai/reference/vectors/libsql)
|
|
142
53
|
|
|
143
|
-
##
|
|
54
|
+
## Changelog
|
|
144
55
|
|
|
145
|
-
|
|
146
|
-
- `getThreadById({ threadId })`: Get a thread by ID
|
|
147
|
-
- `deleteThread({ threadId })`: Delete a thread and its messages
|
|
148
|
-
- `saveMessages({ messages })`: Save multiple messages in a transaction
|
|
149
|
-
- `listMessages({ threadId, perPage?, page? })`: Get messages for a thread with pagination
|
|
150
|
-
- `deleteMessages(messageIds)`: Delete specific messages
|
|
56
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/stores/libsql/CHANGELOG.md) for version history and release notes.
|
|
151
57
|
|
|
152
|
-
##
|
|
58
|
+
## Support
|
|
153
59
|
|
|
154
|
-
|
|
60
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -316,7 +316,7 @@ See the [Editor versioning reference](https://mastra.ai/reference/editor/version
|
|
|
316
316
|
|
|
317
317
|
## Programmatic access
|
|
318
318
|
|
|
319
|
-
Everything available in Studio is also available programmatically through [`mastra.getEditor()`](https://mastra.ai/reference/core/getEditor), the REST API, or the Client SDK. Use it to script bulk updates or seed stored configurations from code. It can also power automation that tunes agents based on [evaluation results](https://mastra.ai/docs/
|
|
319
|
+
Everything available in Studio is also available programmatically through [`mastra.getEditor()`](https://mastra.ai/reference/core/getEditor), the REST API, or the Client SDK. Use it to script bulk updates or seed stored configurations from code. It can also power automation that tunes agents based on [evaluation results](https://mastra.ai/docs/evals/experiments).
|
|
320
320
|
|
|
321
321
|
Call `mastra.getEditor()` when application code has access to the Mastra instance:
|
|
322
322
|
|
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,8 @@ let _mastra_core_storage = require("@mastra/core/storage");
|
|
|
5
5
|
let _mastra_core_utils = require("@mastra/core/utils");
|
|
6
6
|
let _mastra_core_vector = require("@mastra/core/vector");
|
|
7
7
|
let _mastra_core_vector_filter = require("@mastra/core/vector/filter");
|
|
8
|
+
let fs_promises = require("fs/promises");
|
|
9
|
+
let path = require("path");
|
|
8
10
|
let _mastra_core_base = require("@mastra/core/base");
|
|
9
11
|
let crypto$1 = require("crypto");
|
|
10
12
|
let _mastra_core_agent = require("@mastra/core/agent");
|
|
@@ -237,13 +239,13 @@ const FILTER_OPERATORS = {
|
|
|
237
239
|
sql: `NOT (${key})`,
|
|
238
240
|
needsValue: false
|
|
239
241
|
}),
|
|
240
|
-
$size: (key,
|
|
242
|
+
$size: (key, value) => {
|
|
241
243
|
const jsonPath = getJsonPath(key);
|
|
242
244
|
return {
|
|
243
245
|
sql: `(
|
|
244
246
|
CASE
|
|
245
|
-
WHEN json_type(json_extract(metadata, ${jsonPath})) = 'array' THEN
|
|
246
|
-
json_array_length(json_extract(metadata, ${jsonPath})) =
|
|
247
|
+
WHEN json_type(json_extract(metadata, ${jsonPath})) = 'array' THEN
|
|
248
|
+
json_array_length(json_extract(metadata, ${jsonPath})) = ?
|
|
247
249
|
ELSE FALSE
|
|
248
250
|
END
|
|
249
251
|
)`,
|
|
@@ -385,6 +387,31 @@ const processOperator = (key, operator, operatorValue) => {
|
|
|
385
387
|
};
|
|
386
388
|
};
|
|
387
389
|
//#endregion
|
|
390
|
+
//#region src/vector/write-lock.ts
|
|
391
|
+
const databaseWriteChains = /* @__PURE__ */ new Map();
|
|
392
|
+
async function getLocalFileDatabaseKey({ url, syncUrl, cwd }) {
|
|
393
|
+
if (!url.startsWith("file:") || url.includes(":memory:") || syncUrl) return;
|
|
394
|
+
const uriPath = url.slice(5).split(/[?#]/, 1)[0];
|
|
395
|
+
const decodedPath = decodeURIComponent(uriPath);
|
|
396
|
+
const absolutePath = (0, path.isAbsolute)(decodedPath) ? decodedPath : (0, path.resolve)(cwd, decodedPath);
|
|
397
|
+
try {
|
|
398
|
+
return await (0, fs_promises.realpath)(absolutePath);
|
|
399
|
+
} catch (error) {
|
|
400
|
+
if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT") throw error;
|
|
401
|
+
}
|
|
402
|
+
return (0, path.join)(await (0, fs_promises.realpath)((0, path.dirname)(absolutePath)), (0, path.basename)(absolutePath));
|
|
403
|
+
}
|
|
404
|
+
function withLocalFileDatabaseWriteLock(key, fn) {
|
|
405
|
+
if (!key) return fn();
|
|
406
|
+
const result = (databaseWriteChains.get(key) ?? Promise.resolve()).then(fn, fn);
|
|
407
|
+
const tail = result.then(() => void 0, () => void 0);
|
|
408
|
+
databaseWriteChains.set(key, tail);
|
|
409
|
+
tail.then(() => {
|
|
410
|
+
if (databaseWriteChains.get(key) === tail) databaseWriteChains.delete(key);
|
|
411
|
+
});
|
|
412
|
+
return result;
|
|
413
|
+
}
|
|
414
|
+
//#endregion
|
|
388
415
|
//#region src/vector/index.ts
|
|
389
416
|
var LibSQLVector = class extends _mastra_core_vector.MastraVector {
|
|
390
417
|
turso;
|
|
@@ -392,25 +419,57 @@ var LibSQLVector = class extends _mastra_core_vector.MastraVector {
|
|
|
392
419
|
initialBackoffMs;
|
|
393
420
|
overFetchMultiplier;
|
|
394
421
|
isMemoryDb;
|
|
395
|
-
|
|
422
|
+
initialization;
|
|
423
|
+
databaseKey;
|
|
424
|
+
vectorIndexes = /* @__PURE__ */ new Set();
|
|
396
425
|
constructor({ url, authToken, syncUrl, syncInterval, maxRetries = 5, initialBackoffMs = 100, vectorTopKOverFetchMultiplier = 10, id }) {
|
|
397
426
|
super({ id });
|
|
427
|
+
this.isMemoryDb = url.includes(":memory:");
|
|
428
|
+
const isLocalDb = (url.startsWith("file:") || this.isMemoryDb) && !syncUrl;
|
|
429
|
+
const cwd = process.cwd();
|
|
398
430
|
this.turso = (0, _libsql_client.createClient)({
|
|
399
431
|
url,
|
|
400
432
|
syncUrl,
|
|
401
433
|
authToken,
|
|
402
|
-
syncInterval
|
|
434
|
+
syncInterval,
|
|
435
|
+
...isLocalDb ? { timeout: 5e3 } : {}
|
|
403
436
|
});
|
|
404
437
|
this.maxRetries = maxRetries;
|
|
405
438
|
this.initialBackoffMs = initialBackoffMs;
|
|
406
439
|
if (!Number.isInteger(vectorTopKOverFetchMultiplier) || vectorTopKOverFetchMultiplier < 1) throw new Error("vectorTopKOverFetchMultiplier must be a positive integer");
|
|
407
440
|
this.overFetchMultiplier = vectorTopKOverFetchMultiplier;
|
|
408
|
-
this.
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
441
|
+
this.initialization = this.initialize({
|
|
442
|
+
url,
|
|
443
|
+
syncUrl,
|
|
444
|
+
cwd,
|
|
445
|
+
isLocalDb
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
async initialize({ url, syncUrl, cwd, isLocalDb }) {
|
|
449
|
+
if (isLocalDb) {
|
|
450
|
+
await this.applyLocalPragmas();
|
|
451
|
+
this.databaseKey = await getLocalFileDatabaseKey({
|
|
452
|
+
url,
|
|
453
|
+
syncUrl,
|
|
454
|
+
cwd
|
|
455
|
+
});
|
|
412
456
|
}
|
|
413
|
-
|
|
457
|
+
if (!this.isMemoryDb) this.vectorIndexes = await this.discoverVectorIndexes();
|
|
458
|
+
}
|
|
459
|
+
async applyLocalPragmas() {
|
|
460
|
+
for (const [label, sql] of [["journal_mode=WAL", "PRAGMA journal_mode=WAL;"], ["busy_timeout=5000", "PRAGMA busy_timeout = 5000;"]]) try {
|
|
461
|
+
await this.turso.execute(sql);
|
|
462
|
+
this.logger.debug(`LibSQLStore: PRAGMA ${label} set.`);
|
|
463
|
+
} catch (err) {
|
|
464
|
+
this.logger.warn(`LibSQLStore: Failed to set PRAGMA ${label}.`, err);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
async ensureInitialized() {
|
|
468
|
+
await this.initialization;
|
|
469
|
+
}
|
|
470
|
+
async executeMutation(operation, isTransaction = false) {
|
|
471
|
+
await this.ensureInitialized();
|
|
472
|
+
return withLocalFileDatabaseWriteLock(this.databaseKey, () => this.executeWriteOperationWithRetry(operation, isTransaction));
|
|
414
473
|
}
|
|
415
474
|
/**
|
|
416
475
|
* Closes the underlying libsql client, releasing this vector store's OS file handles.
|
|
@@ -418,6 +477,7 @@ var LibSQLVector = class extends _mastra_core_vector.MastraVector {
|
|
|
418
477
|
* Safe to call more than once; subsequent calls are no-ops.
|
|
419
478
|
*/
|
|
420
479
|
async close() {
|
|
480
|
+
await this.ensureInitialized();
|
|
421
481
|
if (!this.turso.closed) this.turso.close();
|
|
422
482
|
}
|
|
423
483
|
async discoverVectorIndexes() {
|
|
@@ -453,8 +513,8 @@ var LibSQLVector = class extends _mastra_core_vector.MastraVector {
|
|
|
453
513
|
transformFilter(filter) {
|
|
454
514
|
return new LibSQLFilterTranslator().translate(filter);
|
|
455
515
|
}
|
|
456
|
-
|
|
457
|
-
return
|
|
516
|
+
hasVectorIndex(parsedIndexName) {
|
|
517
|
+
return this.vectorIndexes.has(`${parsedIndexName}_vector_idx`);
|
|
458
518
|
}
|
|
459
519
|
async queryWithIndex(parsedIndexName, vectorStr, topK, filter, includeVector, minScore) {
|
|
460
520
|
const { sql: filterQuery, values: filterValues } = buildFilterQuery(this.transformFilter(filter));
|
|
@@ -509,9 +569,10 @@ var LibSQLVector = class extends _mastra_core_vector.MastraVector {
|
|
|
509
569
|
details: { message: "queryVector must be an array of finite numbers" }
|
|
510
570
|
});
|
|
511
571
|
try {
|
|
572
|
+
await this.ensureInitialized();
|
|
512
573
|
const parsedIndexName = (0, _mastra_core_utils.parseSqlIdentifier)(indexName, "index name");
|
|
513
574
|
const vectorStr = `[${queryVector.join(",")}]`;
|
|
514
|
-
if (!this.isMemoryDb &&
|
|
575
|
+
if (!this.isMemoryDb && this.hasVectorIndex(parsedIndexName)) try {
|
|
515
576
|
const indexedResults = await this.queryWithIndex(parsedIndexName, vectorStr, topK, filter, includeVector, minScore);
|
|
516
577
|
if (!filter || indexedResults.length >= topK) return indexedResults;
|
|
517
578
|
} catch (err) {
|
|
@@ -552,9 +613,9 @@ var LibSQLVector = class extends _mastra_core_vector.MastraVector {
|
|
|
552
613
|
}, error);
|
|
553
614
|
}
|
|
554
615
|
}
|
|
555
|
-
upsert(args) {
|
|
616
|
+
async upsert(args) {
|
|
556
617
|
try {
|
|
557
|
-
return this.
|
|
618
|
+
return await this.executeMutation(() => this.doUpsert(args), true);
|
|
558
619
|
} catch (error) {
|
|
559
620
|
throw new _mastra_core_error.MastraError({
|
|
560
621
|
id: (0, _mastra_core_storage.createVectorErrorId)("LIBSQL", "UPSERT", "FAILED"),
|
|
@@ -602,9 +663,9 @@ var LibSQLVector = class extends _mastra_core_vector.MastraVector {
|
|
|
602
663
|
throw error;
|
|
603
664
|
}
|
|
604
665
|
}
|
|
605
|
-
createIndex(args) {
|
|
666
|
+
async createIndex(args) {
|
|
606
667
|
try {
|
|
607
|
-
return this.
|
|
668
|
+
return await this.executeMutation(() => this.doCreateIndex(args));
|
|
608
669
|
} catch (error) {
|
|
609
670
|
throw new _mastra_core_error.MastraError({
|
|
610
671
|
id: (0, _mastra_core_storage.createVectorErrorId)("LIBSQL", "CREATE_INDEX", "FAILED"),
|
|
@@ -638,11 +699,11 @@ var LibSQLVector = class extends _mastra_core_vector.MastraVector {
|
|
|
638
699
|
`,
|
|
639
700
|
args: []
|
|
640
701
|
});
|
|
641
|
-
this.vectorIndexes.
|
|
702
|
+
this.vectorIndexes.add(`${parsedIndexName}_vector_idx`);
|
|
642
703
|
}
|
|
643
|
-
deleteIndex(args) {
|
|
704
|
+
async deleteIndex(args) {
|
|
644
705
|
try {
|
|
645
|
-
return this.
|
|
706
|
+
return await this.executeMutation(() => this.doDeleteIndex(args));
|
|
646
707
|
} catch (error) {
|
|
647
708
|
throw new _mastra_core_error.MastraError({
|
|
648
709
|
id: (0, _mastra_core_storage.createVectorErrorId)("LIBSQL", "DELETE_INDEX", "FAILED"),
|
|
@@ -658,10 +719,11 @@ var LibSQLVector = class extends _mastra_core_vector.MastraVector {
|
|
|
658
719
|
sql: `DROP TABLE IF EXISTS ${parsedIndexName}`,
|
|
659
720
|
args: []
|
|
660
721
|
});
|
|
661
|
-
this.vectorIndexes.
|
|
722
|
+
this.vectorIndexes.delete(`${parsedIndexName}_vector_idx`);
|
|
662
723
|
}
|
|
663
724
|
async listIndexes() {
|
|
664
725
|
try {
|
|
726
|
+
await this.ensureInitialized();
|
|
665
727
|
return (await this.turso.execute({
|
|
666
728
|
sql: `
|
|
667
729
|
SELECT name FROM sqlite_master
|
|
@@ -686,6 +748,7 @@ var LibSQLVector = class extends _mastra_core_vector.MastraVector {
|
|
|
686
748
|
*/
|
|
687
749
|
async describeIndex({ indexName }) {
|
|
688
750
|
try {
|
|
751
|
+
await this.ensureInitialized();
|
|
689
752
|
const parsedIndexName = (0, _mastra_core_utils.parseSqlIdentifier)(indexName, "index name");
|
|
690
753
|
const tableInfo = await this.turso.execute({
|
|
691
754
|
sql: `
|
|
@@ -731,7 +794,7 @@ var LibSQLVector = class extends _mastra_core_vector.MastraVector {
|
|
|
731
794
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
732
795
|
*/
|
|
733
796
|
updateVector(args) {
|
|
734
|
-
return this.
|
|
797
|
+
return this.executeMutation(() => this.doUpdateVector(args));
|
|
735
798
|
}
|
|
736
799
|
async doUpdateVector(params) {
|
|
737
800
|
const { indexName, update } = params;
|
|
@@ -836,9 +899,9 @@ var LibSQLVector = class extends _mastra_core_vector.MastraVector {
|
|
|
836
899
|
* @returns A promise that resolves when the deletion is complete.
|
|
837
900
|
* @throws Will throw an error if the deletion operation fails.
|
|
838
901
|
*/
|
|
839
|
-
deleteVector(args) {
|
|
902
|
+
async deleteVector(args) {
|
|
840
903
|
try {
|
|
841
|
-
return this.
|
|
904
|
+
return await this.executeMutation(() => this.doDeleteVector(args));
|
|
842
905
|
} catch (error) {
|
|
843
906
|
throw new _mastra_core_error.MastraError({
|
|
844
907
|
id: (0, _mastra_core_storage.createVectorErrorId)("LIBSQL", "DELETE_VECTOR", "FAILED"),
|
|
@@ -859,7 +922,7 @@ var LibSQLVector = class extends _mastra_core_vector.MastraVector {
|
|
|
859
922
|
});
|
|
860
923
|
}
|
|
861
924
|
deleteVectors(args) {
|
|
862
|
-
return this.
|
|
925
|
+
return this.executeMutation(() => this.doDeleteVectors(args));
|
|
863
926
|
}
|
|
864
927
|
async doDeleteVectors({ indexName, filter, ids }) {
|
|
865
928
|
const parsedIndexName = (0, _mastra_core_utils.parseSqlIdentifier)(indexName, "index name");
|
|
@@ -941,9 +1004,9 @@ var LibSQLVector = class extends _mastra_core_vector.MastraVector {
|
|
|
941
1004
|
}, error);
|
|
942
1005
|
}
|
|
943
1006
|
}
|
|
944
|
-
truncateIndex(args) {
|
|
1007
|
+
async truncateIndex(args) {
|
|
945
1008
|
try {
|
|
946
|
-
return this.
|
|
1009
|
+
return await this.executeMutation(() => this._doTruncateIndex(args));
|
|
947
1010
|
} catch (error) {
|
|
948
1011
|
throw new _mastra_core_error.MastraError({
|
|
949
1012
|
id: (0, _mastra_core_storage.createVectorErrorId)("LIBSQL", "TRUNCATE_INDEX", "FAILED"),
|
|
@@ -2499,6 +2562,26 @@ var AgentsLibSQL = class extends _mastra_core_storage.AgentsStorage {
|
|
|
2499
2562
|
}, error);
|
|
2500
2563
|
}
|
|
2501
2564
|
}
|
|
2565
|
+
async getVersions(ids) {
|
|
2566
|
+
if (ids.length === 0) return [];
|
|
2567
|
+
try {
|
|
2568
|
+
return (await this.#db.selectMany({
|
|
2569
|
+
tableName: _mastra_core_storage.TABLE_AGENT_VERSIONS,
|
|
2570
|
+
whereClause: {
|
|
2571
|
+
sql: `WHERE id IN (${ids.map(() => "?").join(", ")})`,
|
|
2572
|
+
args: ids
|
|
2573
|
+
}
|
|
2574
|
+
}) ?? []).map((row) => this.parseVersionRow(row));
|
|
2575
|
+
} catch (error) {
|
|
2576
|
+
if (error instanceof _mastra_core_error.MastraError) throw error;
|
|
2577
|
+
throw new _mastra_core_error.MastraError({
|
|
2578
|
+
id: (0, _mastra_core_storage.createStorageErrorId)("LIBSQL", "GET_VERSIONS", "FAILED"),
|
|
2579
|
+
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
2580
|
+
category: _mastra_core_error.ErrorCategory.THIRD_PARTY,
|
|
2581
|
+
details: { count: ids.length }
|
|
2582
|
+
}, error);
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2502
2585
|
async getVersionByNumber(agentId, versionNumber) {
|
|
2503
2586
|
try {
|
|
2504
2587
|
const rows = await this.#db.selectMany({
|
|
@@ -12242,6 +12325,24 @@ var SkillsLibSQL = class extends _mastra_core_storage.SkillsStorage {
|
|
|
12242
12325
|
}, error);
|
|
12243
12326
|
}
|
|
12244
12327
|
}
|
|
12328
|
+
async getVersions(ids) {
|
|
12329
|
+
if (ids.length === 0) return [];
|
|
12330
|
+
try {
|
|
12331
|
+
const placeholders = ids.map(() => "?").join(", ");
|
|
12332
|
+
return ((await this.#client.execute({
|
|
12333
|
+
sql: `SELECT ${buildSelectColumns(_mastra_core_storage.TABLE_SKILL_VERSIONS)} FROM "${_mastra_core_storage.TABLE_SKILL_VERSIONS}" WHERE id IN (${placeholders})`,
|
|
12334
|
+
args: ids
|
|
12335
|
+
})).rows ?? []).map((row) => this.#parseVersionRow(row));
|
|
12336
|
+
} catch (error) {
|
|
12337
|
+
if (error instanceof _mastra_core_error.MastraError) throw error;
|
|
12338
|
+
throw new _mastra_core_error.MastraError({
|
|
12339
|
+
id: (0, _mastra_core_storage.createStorageErrorId)("LIBSQL", "GET_SKILL_VERSIONS", "FAILED"),
|
|
12340
|
+
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
12341
|
+
category: _mastra_core_error.ErrorCategory.THIRD_PARTY,
|
|
12342
|
+
details: { count: ids.length }
|
|
12343
|
+
}, error);
|
|
12344
|
+
}
|
|
12345
|
+
}
|
|
12245
12346
|
async getVersionByNumber(skillId, versionNumber) {
|
|
12246
12347
|
try {
|
|
12247
12348
|
const row = (await this.#client.execute({
|