@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.
@@ -1,23 +1,23 @@
1
1
 
2
- > @mastra/libsql@0.10.0-alpha.1 build /home/runner/work/mastra/mastra/stores/libsql
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
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.4.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 8671ms
9
+ TSC ⚡️ Build success in 9697ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.3
13
13
  Writing package typings: /home/runner/work/mastra/mastra/stores/libsql/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/stores/libsql/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 8251ms
16
+ DTS ⚡️ Build success in 9670ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- CJS dist/index.cjs 45.42 KB
21
- CJS ⚡️ Build success in 1060ms
22
- ESM dist/index.js 45.22 KB
23
- ESM ⚡️ Build success in 1062ms
20
+ CJS dist/index.cjs 48.56 KB
21
+ CJS ⚡️ Build success in 1141ms
22
+ ESM dist/index.js 48.36 KB
23
+ ESM ⚡️ 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 LibSQLQueryParams extends QueryVectorParams {
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
- insert({ tableName, record }: {
92
+ private executeWriteOperationWithRetry;
93
+ insert(args: {
80
94
  tableName: TABLE_NAMES;
81
95
  record: Record<string, any>;
82
96
  }): Promise<void>;
83
- batchInsert({ tableName, records }: {
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 MessageType[]>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T>;
125
+ getMessages<T extends MastraMessageV2[]>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T>;
110
126
  saveMessages({ messages }: {
111
- messages: MessageType[];
112
- }): Promise<MessageType[]>;
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
- constructor({ connectionUrl, authToken, syncUrl, syncInterval, }: {
148
- connectionUrl: string;
149
- authToken?: string;
150
- syncUrl?: string;
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, }: LibSQLQueryParams): Promise<QueryResult[]>;
155
- upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
156
- createIndex({ indexName, dimension }: CreateIndexParams): Promise<void>;
157
- deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
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({ indexName, id, update }: UpdateVectorParams): Promise<void>;
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({ indexName, id }: DeleteVectorParams): Promise<void>;
186
- truncateIndex({ indexName }: DeleteIndexParams): Promise<void>;
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 LibSQLQueryParams extends QueryVectorParams {
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
- insert({ tableName, record }: {
92
+ private executeWriteOperationWithRetry;
93
+ insert(args: {
80
94
  tableName: TABLE_NAMES;
81
95
  record: Record<string, any>;
82
96
  }): Promise<void>;
83
- batchInsert({ tableName, records }: {
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 MessageType[]>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T>;
125
+ getMessages<T extends MastraMessageV2[]>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T>;
110
126
  saveMessages({ messages }: {
111
- messages: MessageType[];
112
- }): Promise<MessageType[]>;
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
- constructor({ connectionUrl, authToken, syncUrl, syncInterval, }: {
148
- connectionUrl: string;
149
- authToken?: string;
150
- syncUrl?: string;
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, }: LibSQLQueryParams): Promise<QueryResult[]>;
155
- upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
156
- createIndex({ indexName, dimension }: CreateIndexParams): Promise<void>;
157
- deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
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({ indexName, id, update }: UpdateVectorParams): Promise<void>;
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({ indexName, id }: DeleteVectorParams): Promise<void>;
186
- truncateIndex({ indexName }: DeleteIndexParams): Promise<void>;
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 { }