@mastra/libsql 0.10.0 → 0.10.1-alpha.1
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +18 -0
- package/dist/_tsup-dts-rollup.d.cts +60 -20
- package/dist/_tsup-dts-rollup.d.ts +60 -20
- package/dist/index.cjs +190 -127
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +190 -127
- package/package.json +5 -5
- package/src/storage/index.test.ts +0 -1
- package/src/storage/index.ts +102 -31
- package/src/vector/index.ts +166 -128
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/libsql@0.10.
|
|
2
|
+
> @mastra/libsql@0.10.1-alpha.1 build /home/runner/work/mastra/mastra/stores/libsql
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.4.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 9697ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/libsql/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/libsql/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 9670ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[32mCJS[39m [1mdist/index.cjs [22m[
|
|
21
|
-
[32mCJS[39m ⚡️ Build success in
|
|
22
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
23
|
-
[32mESM[39m ⚡️ Build success in
|
|
20
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m48.56 KB[39m
|
|
21
|
+
[32mCJS[39m ⚡️ Build success in 1141ms
|
|
22
|
+
[32mESM[39m [1mdist/index.js [22m[32m48.36 KB[39m
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 1142ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/libsql
|
|
2
2
|
|
|
3
|
+
## 0.10.1-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f0d559f: Fix peerdeps for alpha channel
|
|
8
|
+
- Updated dependencies [1e8bb40]
|
|
9
|
+
- @mastra/core@0.10.2-alpha.2
|
|
10
|
+
|
|
11
|
+
## 0.10.1-alpha.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- e5dc18d: Added a backwards compatible layer to begin storing/retrieving UIMessages in storage instead of CoreMessages
|
|
16
|
+
- 9e37877: Fixes SQLITE_BUSY error often seen when working locally on the playground
|
|
17
|
+
- Updated dependencies [592a2db]
|
|
18
|
+
- Updated dependencies [e5dc18d]
|
|
19
|
+
- @mastra/core@0.10.2-alpha.0
|
|
20
|
+
|
|
3
21
|
## 0.10.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -6,9 +6,9 @@ import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
|
6
6
|
import type { EvalRow } from '@mastra/core/storage';
|
|
7
7
|
import type { IndexStats } from '@mastra/core/vector';
|
|
8
8
|
import type { InValue } from '@libsql/client';
|
|
9
|
+
import type { MastraMessageV2 } from '@mastra/core/agent';
|
|
9
10
|
import { MastraStorage } from '@mastra/core/storage';
|
|
10
11
|
import { MastraVector } from '@mastra/core/vector';
|
|
11
|
-
import type { MessageType } from '@mastra/core/memory';
|
|
12
12
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
13
13
|
import type { QueryResult } from '@mastra/core/vector';
|
|
14
14
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
@@ -40,6 +40,17 @@ export { LIBSQL_PROMPT as LIBSQL_PROMPT_alias_1 }
|
|
|
40
40
|
declare interface LibSQLConfig {
|
|
41
41
|
url: string;
|
|
42
42
|
authToken?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Maximum number of retries for write operations if an SQLITE_BUSY error occurs.
|
|
45
|
+
* @default 5
|
|
46
|
+
*/
|
|
47
|
+
maxRetries?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Initial backoff time in milliseconds for retrying write operations on SQLITE_BUSY.
|
|
50
|
+
* The backoff time will double with each retry (exponential backoff).
|
|
51
|
+
* @default 100
|
|
52
|
+
*/
|
|
53
|
+
initialBackoffMs?: number;
|
|
43
54
|
}
|
|
44
55
|
export { LibSQLConfig }
|
|
45
56
|
export { LibSQLConfig as LibSQLConfig_alias_1 }
|
|
@@ -60,12 +71,14 @@ export declare class LibSQLFilterTranslator extends BaseFilterTranslator {
|
|
|
60
71
|
private translateNode;
|
|
61
72
|
}
|
|
62
73
|
|
|
63
|
-
declare interface
|
|
74
|
+
declare interface LibSQLQueryVectorParams extends QueryVectorParams {
|
|
64
75
|
minScore?: number;
|
|
65
76
|
}
|
|
66
77
|
|
|
67
78
|
declare class LibSQLStore extends MastraStorage {
|
|
68
79
|
private client;
|
|
80
|
+
private readonly maxRetries;
|
|
81
|
+
private readonly initialBackoffMs;
|
|
69
82
|
constructor(config: LibSQLConfig);
|
|
70
83
|
private getCreateTableSQL;
|
|
71
84
|
createTable({ tableName, schema, }: {
|
|
@@ -76,14 +89,17 @@ declare class LibSQLStore extends MastraStorage {
|
|
|
76
89
|
tableName: TABLE_NAMES;
|
|
77
90
|
}): Promise<void>;
|
|
78
91
|
private prepareStatement;
|
|
79
|
-
|
|
92
|
+
private executeWriteOperationWithRetry;
|
|
93
|
+
insert(args: {
|
|
80
94
|
tableName: TABLE_NAMES;
|
|
81
95
|
record: Record<string, any>;
|
|
82
96
|
}): Promise<void>;
|
|
83
|
-
|
|
97
|
+
private doInsert;
|
|
98
|
+
batchInsert(args: {
|
|
84
99
|
tableName: TABLE_NAMES;
|
|
85
100
|
records: Record<string, any>[];
|
|
86
101
|
}): Promise<void>;
|
|
102
|
+
private doBatchInsert;
|
|
87
103
|
load<R>({ tableName, keys }: {
|
|
88
104
|
tableName: TABLE_NAMES;
|
|
89
105
|
keys: Record<string, string>;
|
|
@@ -106,10 +122,10 @@ declare class LibSQLStore extends MastraStorage {
|
|
|
106
122
|
threadId: string;
|
|
107
123
|
}): Promise<void>;
|
|
108
124
|
private parseRow;
|
|
109
|
-
getMessages<T extends
|
|
125
|
+
getMessages<T extends MastraMessageV2[]>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T>;
|
|
110
126
|
saveMessages({ messages }: {
|
|
111
|
-
messages:
|
|
112
|
-
}): Promise<
|
|
127
|
+
messages: MastraMessageV2[];
|
|
128
|
+
}): Promise<MastraMessageV2[]>;
|
|
113
129
|
private transformEvalRow;
|
|
114
130
|
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
115
131
|
getTraces({ name, scope, page, perPage, attributes, filters, fromDate, toDate, }?: {
|
|
@@ -144,17 +160,18 @@ export { LibSQLStore as LibSQLStore_alias_1 }
|
|
|
144
160
|
|
|
145
161
|
declare class LibSQLVector extends MastraVector {
|
|
146
162
|
private turso;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
syncInterval?: number;
|
|
152
|
-
});
|
|
163
|
+
private readonly maxRetries;
|
|
164
|
+
private readonly initialBackoffMs;
|
|
165
|
+
constructor({ connectionUrl, authToken, syncUrl, syncInterval, maxRetries, initialBackoffMs, }: LibSQLVectorConfig);
|
|
166
|
+
private executeWriteOperationWithRetry;
|
|
153
167
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
154
|
-
query({ indexName, queryVector, topK, filter, includeVector, minScore, }:
|
|
155
|
-
upsert(
|
|
156
|
-
|
|
157
|
-
|
|
168
|
+
query({ indexName, queryVector, topK, filter, includeVector, minScore, }: LibSQLQueryVectorParams): Promise<QueryResult[]>;
|
|
169
|
+
upsert(args: UpsertVectorParams): Promise<string[]>;
|
|
170
|
+
private doUpsert;
|
|
171
|
+
createIndex(args: CreateIndexParams): Promise<void>;
|
|
172
|
+
private doCreateIndex;
|
|
173
|
+
deleteIndex(args: DeleteIndexParams): Promise<void>;
|
|
174
|
+
private doDeleteIndex;
|
|
158
175
|
listIndexes(): Promise<string[]>;
|
|
159
176
|
/**
|
|
160
177
|
* Retrieves statistics about a vector index.
|
|
@@ -174,7 +191,8 @@ declare class LibSQLVector extends MastraVector {
|
|
|
174
191
|
* @returns A promise that resolves when the update is complete.
|
|
175
192
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
176
193
|
*/
|
|
177
|
-
updateVector(
|
|
194
|
+
updateVector(args: UpdateVectorParams): Promise<void>;
|
|
195
|
+
private doUpdateVector;
|
|
178
196
|
/**
|
|
179
197
|
* Deletes a vector by its ID.
|
|
180
198
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -182,10 +200,32 @@ declare class LibSQLVector extends MastraVector {
|
|
|
182
200
|
* @returns A promise that resolves when the deletion is complete.
|
|
183
201
|
* @throws Will throw an error if the deletion operation fails.
|
|
184
202
|
*/
|
|
185
|
-
deleteVector(
|
|
186
|
-
|
|
203
|
+
deleteVector(args: DeleteVectorParams): Promise<void>;
|
|
204
|
+
private doDeleteVector;
|
|
205
|
+
truncateIndex(args: DeleteIndexParams): Promise<void>;
|
|
206
|
+
private _doTruncateIndex;
|
|
187
207
|
}
|
|
188
208
|
export { LibSQLVector }
|
|
189
209
|
export { LibSQLVector as LibSQLVector_alias_1 }
|
|
190
210
|
|
|
211
|
+
declare interface LibSQLVectorConfig {
|
|
212
|
+
connectionUrl: string;
|
|
213
|
+
authToken?: string;
|
|
214
|
+
syncUrl?: string;
|
|
215
|
+
syncInterval?: number;
|
|
216
|
+
/**
|
|
217
|
+
* Maximum number of retries for write operations if an SQLITE_BUSY error occurs.
|
|
218
|
+
* @default 5
|
|
219
|
+
*/
|
|
220
|
+
maxRetries?: number;
|
|
221
|
+
/**
|
|
222
|
+
* Initial backoff time in milliseconds for retrying write operations on SQLITE_BUSY.
|
|
223
|
+
* The backoff time will double with each retry (exponential backoff).
|
|
224
|
+
* @default 100
|
|
225
|
+
*/
|
|
226
|
+
initialBackoffMs?: number;
|
|
227
|
+
}
|
|
228
|
+
export { LibSQLVectorConfig }
|
|
229
|
+
export { LibSQLVectorConfig as LibSQLVectorConfig_alias_1 }
|
|
230
|
+
|
|
191
231
|
export { }
|
|
@@ -6,9 +6,9 @@ import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
|
6
6
|
import type { EvalRow } from '@mastra/core/storage';
|
|
7
7
|
import type { IndexStats } from '@mastra/core/vector';
|
|
8
8
|
import type { InValue } from '@libsql/client';
|
|
9
|
+
import type { MastraMessageV2 } from '@mastra/core/agent';
|
|
9
10
|
import { MastraStorage } from '@mastra/core/storage';
|
|
10
11
|
import { MastraVector } from '@mastra/core/vector';
|
|
11
|
-
import type { MessageType } from '@mastra/core/memory';
|
|
12
12
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
13
13
|
import type { QueryResult } from '@mastra/core/vector';
|
|
14
14
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
@@ -40,6 +40,17 @@ export { LIBSQL_PROMPT as LIBSQL_PROMPT_alias_1 }
|
|
|
40
40
|
declare interface LibSQLConfig {
|
|
41
41
|
url: string;
|
|
42
42
|
authToken?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Maximum number of retries for write operations if an SQLITE_BUSY error occurs.
|
|
45
|
+
* @default 5
|
|
46
|
+
*/
|
|
47
|
+
maxRetries?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Initial backoff time in milliseconds for retrying write operations on SQLITE_BUSY.
|
|
50
|
+
* The backoff time will double with each retry (exponential backoff).
|
|
51
|
+
* @default 100
|
|
52
|
+
*/
|
|
53
|
+
initialBackoffMs?: number;
|
|
43
54
|
}
|
|
44
55
|
export { LibSQLConfig }
|
|
45
56
|
export { LibSQLConfig as LibSQLConfig_alias_1 }
|
|
@@ -60,12 +71,14 @@ export declare class LibSQLFilterTranslator extends BaseFilterTranslator {
|
|
|
60
71
|
private translateNode;
|
|
61
72
|
}
|
|
62
73
|
|
|
63
|
-
declare interface
|
|
74
|
+
declare interface LibSQLQueryVectorParams extends QueryVectorParams {
|
|
64
75
|
minScore?: number;
|
|
65
76
|
}
|
|
66
77
|
|
|
67
78
|
declare class LibSQLStore extends MastraStorage {
|
|
68
79
|
private client;
|
|
80
|
+
private readonly maxRetries;
|
|
81
|
+
private readonly initialBackoffMs;
|
|
69
82
|
constructor(config: LibSQLConfig);
|
|
70
83
|
private getCreateTableSQL;
|
|
71
84
|
createTable({ tableName, schema, }: {
|
|
@@ -76,14 +89,17 @@ declare class LibSQLStore extends MastraStorage {
|
|
|
76
89
|
tableName: TABLE_NAMES;
|
|
77
90
|
}): Promise<void>;
|
|
78
91
|
private prepareStatement;
|
|
79
|
-
|
|
92
|
+
private executeWriteOperationWithRetry;
|
|
93
|
+
insert(args: {
|
|
80
94
|
tableName: TABLE_NAMES;
|
|
81
95
|
record: Record<string, any>;
|
|
82
96
|
}): Promise<void>;
|
|
83
|
-
|
|
97
|
+
private doInsert;
|
|
98
|
+
batchInsert(args: {
|
|
84
99
|
tableName: TABLE_NAMES;
|
|
85
100
|
records: Record<string, any>[];
|
|
86
101
|
}): Promise<void>;
|
|
102
|
+
private doBatchInsert;
|
|
87
103
|
load<R>({ tableName, keys }: {
|
|
88
104
|
tableName: TABLE_NAMES;
|
|
89
105
|
keys: Record<string, string>;
|
|
@@ -106,10 +122,10 @@ declare class LibSQLStore extends MastraStorage {
|
|
|
106
122
|
threadId: string;
|
|
107
123
|
}): Promise<void>;
|
|
108
124
|
private parseRow;
|
|
109
|
-
getMessages<T extends
|
|
125
|
+
getMessages<T extends MastraMessageV2[]>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T>;
|
|
110
126
|
saveMessages({ messages }: {
|
|
111
|
-
messages:
|
|
112
|
-
}): Promise<
|
|
127
|
+
messages: MastraMessageV2[];
|
|
128
|
+
}): Promise<MastraMessageV2[]>;
|
|
113
129
|
private transformEvalRow;
|
|
114
130
|
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
115
131
|
getTraces({ name, scope, page, perPage, attributes, filters, fromDate, toDate, }?: {
|
|
@@ -144,17 +160,18 @@ export { LibSQLStore as LibSQLStore_alias_1 }
|
|
|
144
160
|
|
|
145
161
|
declare class LibSQLVector extends MastraVector {
|
|
146
162
|
private turso;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
syncInterval?: number;
|
|
152
|
-
});
|
|
163
|
+
private readonly maxRetries;
|
|
164
|
+
private readonly initialBackoffMs;
|
|
165
|
+
constructor({ connectionUrl, authToken, syncUrl, syncInterval, maxRetries, initialBackoffMs, }: LibSQLVectorConfig);
|
|
166
|
+
private executeWriteOperationWithRetry;
|
|
153
167
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
154
|
-
query({ indexName, queryVector, topK, filter, includeVector, minScore, }:
|
|
155
|
-
upsert(
|
|
156
|
-
|
|
157
|
-
|
|
168
|
+
query({ indexName, queryVector, topK, filter, includeVector, minScore, }: LibSQLQueryVectorParams): Promise<QueryResult[]>;
|
|
169
|
+
upsert(args: UpsertVectorParams): Promise<string[]>;
|
|
170
|
+
private doUpsert;
|
|
171
|
+
createIndex(args: CreateIndexParams): Promise<void>;
|
|
172
|
+
private doCreateIndex;
|
|
173
|
+
deleteIndex(args: DeleteIndexParams): Promise<void>;
|
|
174
|
+
private doDeleteIndex;
|
|
158
175
|
listIndexes(): Promise<string[]>;
|
|
159
176
|
/**
|
|
160
177
|
* Retrieves statistics about a vector index.
|
|
@@ -174,7 +191,8 @@ declare class LibSQLVector extends MastraVector {
|
|
|
174
191
|
* @returns A promise that resolves when the update is complete.
|
|
175
192
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
176
193
|
*/
|
|
177
|
-
updateVector(
|
|
194
|
+
updateVector(args: UpdateVectorParams): Promise<void>;
|
|
195
|
+
private doUpdateVector;
|
|
178
196
|
/**
|
|
179
197
|
* Deletes a vector by its ID.
|
|
180
198
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -182,10 +200,32 @@ declare class LibSQLVector extends MastraVector {
|
|
|
182
200
|
* @returns A promise that resolves when the deletion is complete.
|
|
183
201
|
* @throws Will throw an error if the deletion operation fails.
|
|
184
202
|
*/
|
|
185
|
-
deleteVector(
|
|
186
|
-
|
|
203
|
+
deleteVector(args: DeleteVectorParams): Promise<void>;
|
|
204
|
+
private doDeleteVector;
|
|
205
|
+
truncateIndex(args: DeleteIndexParams): Promise<void>;
|
|
206
|
+
private _doTruncateIndex;
|
|
187
207
|
}
|
|
188
208
|
export { LibSQLVector }
|
|
189
209
|
export { LibSQLVector as LibSQLVector_alias_1 }
|
|
190
210
|
|
|
211
|
+
declare interface LibSQLVectorConfig {
|
|
212
|
+
connectionUrl: string;
|
|
213
|
+
authToken?: string;
|
|
214
|
+
syncUrl?: string;
|
|
215
|
+
syncInterval?: number;
|
|
216
|
+
/**
|
|
217
|
+
* Maximum number of retries for write operations if an SQLITE_BUSY error occurs.
|
|
218
|
+
* @default 5
|
|
219
|
+
*/
|
|
220
|
+
maxRetries?: number;
|
|
221
|
+
/**
|
|
222
|
+
* Initial backoff time in milliseconds for retrying write operations on SQLITE_BUSY.
|
|
223
|
+
* The backoff time will double with each retry (exponential backoff).
|
|
224
|
+
* @default 100
|
|
225
|
+
*/
|
|
226
|
+
initialBackoffMs?: number;
|
|
227
|
+
}
|
|
228
|
+
export { LibSQLVectorConfig }
|
|
229
|
+
export { LibSQLVectorConfig as LibSQLVectorConfig_alias_1 }
|
|
230
|
+
|
|
191
231
|
export { }
|