@mastra/libsql 0.12.0 → 0.13.0-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.
Files changed (41) hide show
  1. package/.turbo/turbo-build.log +2 -21
  2. package/CHANGELOG.md +28 -0
  3. package/dist/index.cjs +7 -3
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.ts +4 -6
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +7 -3
  8. package/dist/index.js.map +1 -0
  9. package/dist/storage/domains/legacy-evals/index.d.ts +18 -0
  10. package/dist/storage/domains/legacy-evals/index.d.ts.map +1 -0
  11. package/dist/storage/domains/memory/index.d.ts +87 -0
  12. package/dist/storage/domains/memory/index.d.ts.map +1 -0
  13. package/dist/storage/domains/operations/index.d.ts +61 -0
  14. package/dist/storage/domains/operations/index.d.ts.map +1 -0
  15. package/dist/storage/domains/scores/index.d.ts +45 -0
  16. package/dist/storage/domains/scores/index.d.ts.map +1 -0
  17. package/dist/storage/domains/traces/index.d.ts +21 -0
  18. package/dist/storage/domains/traces/index.d.ts.map +1 -0
  19. package/dist/storage/domains/utils.d.ts +16 -0
  20. package/dist/storage/domains/utils.d.ts.map +1 -0
  21. package/dist/storage/domains/workflows/index.d.ts +34 -0
  22. package/dist/storage/domains/workflows/index.d.ts.map +1 -0
  23. package/dist/storage/index.d.ts +221 -0
  24. package/dist/storage/index.d.ts.map +1 -0
  25. package/dist/vector/filter.d.ts +29 -0
  26. package/dist/vector/filter.d.ts.map +1 -0
  27. package/dist/vector/index.d.ts +72 -0
  28. package/dist/vector/index.d.ts.map +1 -0
  29. package/dist/vector/prompt.d.ts +6 -0
  30. package/dist/vector/prompt.d.ts.map +1 -0
  31. package/dist/vector/sql-builder.d.ts +9 -0
  32. package/dist/vector/sql-builder.d.ts.map +1 -0
  33. package/package.json +9 -8
  34. package/src/storage/domains/scores/index.ts +5 -3
  35. package/src/storage/domains/traces/index.ts +5 -5
  36. package/tsconfig.build.json +9 -0
  37. package/tsconfig.json +1 -1
  38. package/tsup.config.ts +17 -0
  39. package/dist/_tsup-dts-rollup.d.cts +0 -642
  40. package/dist/_tsup-dts-rollup.d.ts +0 -642
  41. package/dist/index.d.cts +0 -6
@@ -1,642 +0,0 @@
1
- import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
- import type { Client } from '@libsql/client';
3
- import type { CreateIndexParams } from '@mastra/core/vector';
4
- import type { DeleteIndexParams } from '@mastra/core/vector';
5
- import type { DeleteVectorParams } from '@mastra/core/vector';
6
- import type { DescribeIndexParams } from '@mastra/core/vector';
7
- import type { EvalRow } from '@mastra/core/storage';
8
- import type { IMastraLogger } from '@mastra/core/logger';
9
- import type { IndexStats } from '@mastra/core/vector';
10
- import type { InValue } from '@libsql/client';
11
- import { LegacyEvalsStorage } from '@mastra/core/storage';
12
- import type { MastraMessageContentV2 } from '@mastra/core/agent';
13
- import type { MastraMessageV1 } from '@mastra/core/memory';
14
- import type { MastraMessageV2 } from '@mastra/core/agent';
15
- import type { MastraMessageV2 as MastraMessageV2_2 } from '@mastra/core/memory';
16
- import { MastraStorage } from '@mastra/core/storage';
17
- import { MastraVector } from '@mastra/core/vector';
18
- import { MemoryStorage } from '@mastra/core/storage';
19
- import type { OperatorSupport } from '@mastra/core/vector/filter';
20
- import type { OperatorValueMap } from '@mastra/core/vector/filter';
21
- import type { PaginationArgs } from '@mastra/core/storage';
22
- import type { PaginationInfo } from '@mastra/core/storage';
23
- import type { QueryResult } from '@mastra/core/vector';
24
- import type { QueryVectorParams } from '@mastra/core/vector';
25
- import type { ScoreRowData } from '@mastra/core/scores';
26
- import { ScoresStorage } from '@mastra/core/storage';
27
- import type { StorageColumn } from '@mastra/core/storage';
28
- import type { StorageDomains } from '@mastra/core/storage';
29
- import type { StorageGetMessagesArg } from '@mastra/core/storage';
30
- import type { StorageGetTracesArg } from '@mastra/core/storage';
31
- import type { StorageGetTracesPaginatedArg } from '@mastra/core/storage';
32
- import type { StoragePagination } from '@mastra/core/storage';
33
- import type { StorageResourceType } from '@mastra/core/storage';
34
- import type { StorageThreadType } from '@mastra/core/memory';
35
- import { StoreOperations } from '@mastra/core/storage';
36
- import type { TABLE_NAMES } from '@mastra/core/storage';
37
- import type { ThreadSortOptions } from '@mastra/core/storage';
38
- import type { Trace } from '@mastra/core/telemetry';
39
- import { TracesStorage } from '@mastra/core/storage';
40
- import type { UpdateVectorParams } from '@mastra/core/vector';
41
- import type { UpsertVectorParams } from '@mastra/core/vector';
42
- import type { VectorFieldValue } from '@mastra/core/vector/filter';
43
- import type { VectorFilter } from '@mastra/core/vector/filter';
44
- import type { WorkflowRun } from '@mastra/core/storage';
45
- import type { WorkflowRun as WorkflowRun_2 } from '@mastra/core';
46
- import type { WorkflowRuns } from '@mastra/core/storage';
47
- import type { WorkflowRuns as WorkflowRuns_2 } from '@mastra/core';
48
- import type { WorkflowRunState } from '@mastra/core/workflows';
49
- import type { WorkflowRunState as WorkflowRunState_2 } from '@mastra/core';
50
- import { WorkflowsStorage } from '@mastra/core/storage';
51
-
52
- export declare function buildFilterQuery(filter: LibSQLVectorFilter): FilterResult;
53
-
54
- export declare function createExecuteWriteOperationWithRetry({ logger, maxRetries, initialBackoffMs, }: {
55
- logger: IMastraLogger;
56
- maxRetries: number;
57
- initialBackoffMs: number;
58
- }): <T>(operationFn: () => Promise<T>, operationDescription: string) => Promise<T>;
59
-
60
- declare interface FilterResult {
61
- sql: string;
62
- values: InValue[];
63
- }
64
-
65
- export declare class LegacyEvalsLibSQL extends LegacyEvalsStorage {
66
- private client;
67
- constructor({ client }: {
68
- client: Client;
69
- });
70
- /** @deprecated use getEvals instead */
71
- getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
72
- getEvals(options?: {
73
- agentName?: string;
74
- type?: 'test' | 'live';
75
- } & PaginationArgs): Promise<PaginationInfo & {
76
- evals: EvalRow[];
77
- }>;
78
- }
79
-
80
- /**
81
- * Vector store specific prompt that details supported operators and examples.
82
- * This prompt helps users construct valid filters for LibSQL Vector.
83
- */
84
- declare const LIBSQL_PROMPT = "When querying LibSQL Vector, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n- $elemMatch: Match array elements that meet all specified conditions\n Example: { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 100 } } } }\n- $contains: Check if array contains value\n Example: { \"tags\": { \"$contains\": \"premium\" } }\n\nLogical Operators:\n- $and: Logical AND (implicit when using multiple conditions)\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n- $nor: Logical NOR\n Example: { \"$nor\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $size: Array length check\n Example: { \"tags\": { \"$size\": 2 } }\n\nRestrictions:\n- Regex patterns are not supported\n- Direct RegExp patterns will throw an error\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Array operations work on array fields only\n- Basic operators handle array values as JSON strings\n- Empty arrays in conditions are handled gracefully\n- Only logical operators ($and, $or, $not, $nor) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$contains\": \"value\" }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Other logical operators ($and, $or, $nor):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n- $elemMatch requires an object with conditions\n Valid: { \"array\": { \"$elemMatch\": { \"field\": \"value\" } } }\n Invalid: { \"array\": { \"$elemMatch\": \"value\" } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 50 }, \"inStock\": true } } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
85
- export { LIBSQL_PROMPT }
86
- export { LIBSQL_PROMPT as LIBSQL_PROMPT_alias_1 }
87
-
88
- declare type LibSQLConfig = {
89
- url: string;
90
- authToken?: string;
91
- /**
92
- * Maximum number of retries for write operations if an SQLITE_BUSY error occurs.
93
- * @default 5
94
- */
95
- maxRetries?: number;
96
- /**
97
- * Initial backoff time in milliseconds for retrying write operations on SQLITE_BUSY.
98
- * The backoff time will double with each retry (exponential backoff).
99
- * @default 100
100
- */
101
- initialBackoffMs?: number;
102
- } | {
103
- client: Client;
104
- maxRetries?: number;
105
- initialBackoffMs?: number;
106
- };
107
- export { LibSQLConfig }
108
- export { LibSQLConfig as LibSQLConfig_alias_1 }
109
-
110
- /**
111
- * Translates MongoDB-style filters to LibSQL compatible filters.
112
- *
113
- * Key differences from MongoDB:
114
- *
115
- * Logical Operators ($and, $or, $nor):
116
- * - Can be used at the top level or nested within fields
117
- * - Can take either a single condition or an array of conditions
118
- *
119
- */
120
- export declare class LibSQLFilterTranslator extends BaseFilterTranslator<LibSQLVectorFilter> {
121
- protected getSupportedOperators(): OperatorSupport;
122
- translate(filter?: LibSQLVectorFilter): LibSQLVectorFilter;
123
- private translateNode;
124
- }
125
-
126
- declare type LibSQLOperatorValueMap = Omit<OperatorValueMap, '$regex' | '$options' | '$in' | '$all' | '$nin' | '$eq' | '$ne'> & {
127
- $size: number;
128
- $contains: VectorFieldValue | Record<string, unknown>;
129
- $all: VectorFieldValue;
130
- $in: VectorFieldValue;
131
- $nin: VectorFieldValue;
132
- $eq: VectorFieldValue;
133
- $ne: VectorFieldValue;
134
- };
135
-
136
- declare interface LibSQLQueryVectorParams extends QueryVectorParams<LibSQLVectorFilter> {
137
- minScore?: number;
138
- }
139
-
140
- declare class LibSQLStore extends MastraStorage {
141
- private client;
142
- private readonly maxRetries;
143
- private readonly initialBackoffMs;
144
- stores: StorageDomains;
145
- constructor(config: LibSQLConfig);
146
- get supports(): {
147
- selectByIncludeResourceScope: boolean;
148
- resourceWorkingMemory: boolean;
149
- hasColumn: boolean;
150
- createTable: boolean;
151
- deleteMessages: boolean;
152
- };
153
- createTable({ tableName, schema, }: {
154
- tableName: TABLE_NAMES;
155
- schema: Record<string, StorageColumn>;
156
- }): Promise<void>;
157
- /**
158
- * Alters table schema to add columns if they don't exist
159
- * @param tableName Name of the table
160
- * @param schema Schema of the table
161
- * @param ifNotExists Array of column names to add if they don't exist
162
- */
163
- alterTable({ tableName, schema, ifNotExists, }: {
164
- tableName: TABLE_NAMES;
165
- schema: Record<string, StorageColumn>;
166
- ifNotExists: string[];
167
- }): Promise<void>;
168
- clearTable({ tableName }: {
169
- tableName: TABLE_NAMES;
170
- }): Promise<void>;
171
- dropTable({ tableName }: {
172
- tableName: TABLE_NAMES;
173
- }): Promise<void>;
174
- insert(args: {
175
- tableName: TABLE_NAMES;
176
- record: Record<string, any>;
177
- }): Promise<void>;
178
- batchInsert(args: {
179
- tableName: TABLE_NAMES;
180
- records: Record<string, any>[];
181
- }): Promise<void>;
182
- load<R>({ tableName, keys }: {
183
- tableName: TABLE_NAMES;
184
- keys: Record<string, string>;
185
- }): Promise<R | null>;
186
- getThreadById({ threadId }: {
187
- threadId: string;
188
- }): Promise<StorageThreadType | null>;
189
- /**
190
- * @deprecated use getThreadsByResourceIdPaginated instead for paginated results.
191
- */
192
- getThreadsByResourceId(args: {
193
- resourceId: string;
194
- } & ThreadSortOptions): Promise<StorageThreadType[]>;
195
- getThreadsByResourceIdPaginated(args: {
196
- resourceId: string;
197
- page: number;
198
- perPage: number;
199
- } & ThreadSortOptions): Promise<PaginationInfo & {
200
- threads: StorageThreadType[];
201
- }>;
202
- saveThread({ thread }: {
203
- thread: StorageThreadType;
204
- }): Promise<StorageThreadType>;
205
- updateThread({ id, title, metadata, }: {
206
- id: string;
207
- title: string;
208
- metadata: Record<string, unknown>;
209
- }): Promise<StorageThreadType>;
210
- deleteThread({ threadId }: {
211
- threadId: string;
212
- }): Promise<void>;
213
- /**
214
- * @deprecated use getMessagesPaginated instead for paginated results.
215
- */
216
- getMessages(args: StorageGetMessagesArg & {
217
- format?: 'v1';
218
- }): Promise<MastraMessageV1[]>;
219
- getMessages(args: StorageGetMessagesArg & {
220
- format: 'v2';
221
- }): Promise<MastraMessageV2[]>;
222
- getMessagesPaginated(args: StorageGetMessagesArg & {
223
- format?: 'v1' | 'v2';
224
- }): Promise<PaginationInfo & {
225
- messages: MastraMessageV1[] | MastraMessageV2[];
226
- }>;
227
- saveMessages(args: {
228
- messages: MastraMessageV1[];
229
- format?: undefined | 'v1';
230
- }): Promise<MastraMessageV1[]>;
231
- saveMessages(args: {
232
- messages: MastraMessageV2[];
233
- format: 'v2';
234
- }): Promise<MastraMessageV2[]>;
235
- updateMessages({ messages, }: {
236
- messages: (Partial<Omit<MastraMessageV2, 'createdAt'>> & {
237
- id: string;
238
- content?: {
239
- metadata?: MastraMessageContentV2['metadata'];
240
- content?: MastraMessageContentV2['content'];
241
- };
242
- })[];
243
- }): Promise<MastraMessageV2[]>;
244
- deleteMessages(messageIds: string[]): Promise<void>;
245
- /** @deprecated use getEvals instead */
246
- getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
247
- getEvals(options?: {
248
- agentName?: string;
249
- type?: 'test' | 'live';
250
- } & PaginationArgs): Promise<PaginationInfo & {
251
- evals: EvalRow[];
252
- }>;
253
- getScoreById({ id }: {
254
- id: string;
255
- }): Promise<ScoreRowData | null>;
256
- saveScore(score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
257
- score: ScoreRowData;
258
- }>;
259
- getScoresByScorerId({ scorerId, entityId, entityType, pagination, }: {
260
- scorerId: string;
261
- entityId?: string;
262
- entityType?: string;
263
- pagination: StoragePagination;
264
- }): Promise<{
265
- pagination: PaginationInfo;
266
- scores: ScoreRowData[];
267
- }>;
268
- getScoresByRunId({ runId, pagination, }: {
269
- runId: string;
270
- pagination: StoragePagination;
271
- }): Promise<{
272
- pagination: PaginationInfo;
273
- scores: ScoreRowData[];
274
- }>;
275
- getScoresByEntityId({ entityId, entityType, pagination, }: {
276
- pagination: StoragePagination;
277
- entityId: string;
278
- entityType: string;
279
- }): Promise<{
280
- pagination: PaginationInfo;
281
- scores: ScoreRowData[];
282
- }>;
283
- /**
284
- * TRACES
285
- */
286
- /**
287
- * @deprecated use getTracesPaginated instead.
288
- */
289
- getTraces(args: StorageGetTracesArg): Promise<Trace[]>;
290
- getTracesPaginated(args: StorageGetTracesArg): Promise<PaginationInfo & {
291
- traces: Trace[];
292
- }>;
293
- batchTraceInsert(args: {
294
- records: Record<string, any>[];
295
- }): Promise<void>;
296
- /**
297
- * WORKFLOWS
298
- */
299
- persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
300
- workflowName: string;
301
- runId: string;
302
- snapshot: WorkflowRunState;
303
- }): Promise<void>;
304
- loadWorkflowSnapshot({ workflowName, runId, }: {
305
- workflowName: string;
306
- runId: string;
307
- }): Promise<WorkflowRunState | null>;
308
- getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
309
- workflowName?: string;
310
- fromDate?: Date;
311
- toDate?: Date;
312
- limit?: number;
313
- offset?: number;
314
- resourceId?: string;
315
- }): Promise<WorkflowRuns>;
316
- getWorkflowRunById({ runId, workflowName, }: {
317
- runId: string;
318
- workflowName?: string;
319
- }): Promise<WorkflowRun | null>;
320
- getResourceById({ resourceId }: {
321
- resourceId: string;
322
- }): Promise<StorageResourceType | null>;
323
- saveResource({ resource }: {
324
- resource: StorageResourceType;
325
- }): Promise<StorageResourceType>;
326
- updateResource({ resourceId, workingMemory, metadata, }: {
327
- resourceId: string;
328
- workingMemory?: string;
329
- metadata?: Record<string, unknown>;
330
- }): Promise<StorageResourceType>;
331
- }
332
- export { LibSQLStore as DefaultStorage }
333
- export { LibSQLStore as DefaultStorage_alias_1 }
334
- export { LibSQLStore }
335
- export { LibSQLStore as LibSQLStore_alias_1 }
336
-
337
- declare class LibSQLVector extends MastraVector<LibSQLVectorFilter> {
338
- private turso;
339
- private readonly maxRetries;
340
- private readonly initialBackoffMs;
341
- constructor({ connectionUrl, authToken, syncUrl, syncInterval, maxRetries, initialBackoffMs, }: LibSQLVectorConfig);
342
- private executeWriteOperationWithRetry;
343
- transformFilter(filter?: LibSQLVectorFilter): LibSQLVectorFilter;
344
- query({ indexName, queryVector, topK, filter, includeVector, minScore, }: LibSQLQueryVectorParams): Promise<QueryResult[]>;
345
- upsert(args: UpsertVectorParams): Promise<string[]>;
346
- private doUpsert;
347
- createIndex(args: CreateIndexParams): Promise<void>;
348
- private doCreateIndex;
349
- deleteIndex(args: DeleteIndexParams): Promise<void>;
350
- private doDeleteIndex;
351
- listIndexes(): Promise<string[]>;
352
- /**
353
- * Retrieves statistics about a vector index.
354
- *
355
- * @param {string} indexName - The name of the index to describe
356
- * @returns A promise that resolves to the index statistics including dimension, count and metric
357
- */
358
- describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
359
- /**
360
- * Updates a vector by its ID with the provided vector and/or metadata.
361
- *
362
- * @param indexName - The name of the index containing the vector.
363
- * @param id - The ID of the vector to update.
364
- * @param update - An object containing the vector and/or metadata to update.
365
- * @param update.vector - An optional array of numbers representing the new vector.
366
- * @param update.metadata - An optional record containing the new metadata.
367
- * @returns A promise that resolves when the update is complete.
368
- * @throws Will throw an error if no updates are provided or if the update operation fails.
369
- */
370
- updateVector(args: UpdateVectorParams): Promise<void>;
371
- private doUpdateVector;
372
- /**
373
- * Deletes a vector by its ID.
374
- * @param indexName - The name of the index containing the vector.
375
- * @param id - The ID of the vector to delete.
376
- * @returns A promise that resolves when the deletion is complete.
377
- * @throws Will throw an error if the deletion operation fails.
378
- */
379
- deleteVector(args: DeleteVectorParams): Promise<void>;
380
- private doDeleteVector;
381
- truncateIndex(args: DeleteIndexParams): Promise<void>;
382
- private _doTruncateIndex;
383
- }
384
- export { LibSQLVector }
385
- export { LibSQLVector as LibSQLVector_alias_1 }
386
-
387
- declare interface LibSQLVectorConfig {
388
- connectionUrl: string;
389
- authToken?: string;
390
- syncUrl?: string;
391
- syncInterval?: number;
392
- /**
393
- * Maximum number of retries for write operations if an SQLITE_BUSY error occurs.
394
- * @default 5
395
- */
396
- maxRetries?: number;
397
- /**
398
- * Initial backoff time in milliseconds for retrying write operations on SQLITE_BUSY.
399
- * The backoff time will double with each retry (exponential backoff).
400
- * @default 100
401
- */
402
- initialBackoffMs?: number;
403
- }
404
- export { LibSQLVectorConfig }
405
- export { LibSQLVectorConfig as LibSQLVectorConfig_alias_1 }
406
-
407
- export declare type LibSQLVectorFilter = VectorFilter<keyof LibSQLOperatorValueMap, LibSQLOperatorValueMap>;
408
-
409
- export declare class MemoryLibSQL extends MemoryStorage {
410
- private client;
411
- private operations;
412
- constructor({ client, operations }: {
413
- client: Client;
414
- operations: StoreOperationsLibSQL;
415
- });
416
- private parseRow;
417
- private _getIncludedMessages;
418
- /**
419
- * @deprecated use getMessagesPaginated instead for paginated results.
420
- */
421
- getMessages(args: StorageGetMessagesArg & {
422
- format?: 'v1';
423
- }): Promise<MastraMessageV1[]>;
424
- getMessages(args: StorageGetMessagesArg & {
425
- format: 'v2';
426
- }): Promise<MastraMessageV2_2[]>;
427
- getMessagesPaginated(args: StorageGetMessagesArg & {
428
- format?: 'v1' | 'v2';
429
- }): Promise<PaginationInfo & {
430
- messages: MastraMessageV1[] | MastraMessageV2_2[];
431
- }>;
432
- saveMessages(args: {
433
- messages: MastraMessageV1[];
434
- format?: undefined | 'v1';
435
- }): Promise<MastraMessageV1[]>;
436
- saveMessages(args: {
437
- messages: MastraMessageV2_2[];
438
- format: 'v2';
439
- }): Promise<MastraMessageV2_2[]>;
440
- updateMessages({ messages, }: {
441
- messages: (Partial<Omit<MastraMessageV2_2, 'createdAt'>> & {
442
- id: string;
443
- content?: {
444
- metadata?: MastraMessageContentV2['metadata'];
445
- content?: MastraMessageContentV2['content'];
446
- };
447
- })[];
448
- }): Promise<MastraMessageV2_2[]>;
449
- deleteMessages(messageIds: string[]): Promise<void>;
450
- getResourceById({ resourceId }: {
451
- resourceId: string;
452
- }): Promise<StorageResourceType | null>;
453
- saveResource({ resource }: {
454
- resource: StorageResourceType;
455
- }): Promise<StorageResourceType>;
456
- updateResource({ resourceId, workingMemory, metadata, }: {
457
- resourceId: string;
458
- workingMemory?: string;
459
- metadata?: Record<string, unknown>;
460
- }): Promise<StorageResourceType>;
461
- getThreadById({ threadId }: {
462
- threadId: string;
463
- }): Promise<StorageThreadType | null>;
464
- /**
465
- * @deprecated use getThreadsByResourceIdPaginated instead for paginated results.
466
- */
467
- getThreadsByResourceId(args: {
468
- resourceId: string;
469
- } & ThreadSortOptions): Promise<StorageThreadType[]>;
470
- getThreadsByResourceIdPaginated(args: {
471
- resourceId: string;
472
- page: number;
473
- perPage: number;
474
- } & ThreadSortOptions): Promise<PaginationInfo & {
475
- threads: StorageThreadType[];
476
- }>;
477
- saveThread({ thread }: {
478
- thread: StorageThreadType;
479
- }): Promise<StorageThreadType>;
480
- updateThread({ id, title, metadata, }: {
481
- id: string;
482
- title: string;
483
- metadata: Record<string, unknown>;
484
- }): Promise<StorageThreadType>;
485
- deleteThread({ threadId }: {
486
- threadId: string;
487
- }): Promise<void>;
488
- }
489
-
490
- export declare function prepareStatement({ tableName, record }: {
491
- tableName: TABLE_NAMES;
492
- record: Record<string, any>;
493
- }): {
494
- sql: string;
495
- args: InValue[];
496
- };
497
-
498
- export declare class ScoresLibSQL extends ScoresStorage {
499
- private operations;
500
- private client;
501
- constructor({ client, operations }: {
502
- client: Client;
503
- operations: StoreOperationsLibSQL;
504
- });
505
- getScoresByRunId({ runId, pagination, }: {
506
- runId: string;
507
- pagination: StoragePagination;
508
- }): Promise<{
509
- pagination: PaginationInfo;
510
- scores: ScoreRowData[];
511
- }>;
512
- getScoresByScorerId({ scorerId, entityId, entityType, pagination, }: {
513
- scorerId: string;
514
- entityId?: string;
515
- entityType?: string;
516
- pagination: StoragePagination;
517
- }): Promise<{
518
- pagination: PaginationInfo;
519
- scores: ScoreRowData[];
520
- }>;
521
- private transformScoreRow;
522
- getScoreById({ id }: {
523
- id: string;
524
- }): Promise<ScoreRowData | null>;
525
- saveScore(score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
526
- score: ScoreRowData;
527
- }>;
528
- getScoresByEntityId({ entityId, entityType, pagination, }: {
529
- pagination: StoragePagination;
530
- entityId: string;
531
- entityType: string;
532
- }): Promise<{
533
- pagination: PaginationInfo;
534
- scores: ScoreRowData[];
535
- }>;
536
- }
537
-
538
- export declare class StoreOperationsLibSQL extends StoreOperations {
539
- private client;
540
- /**
541
- * Maximum number of retries for write operations if an SQLITE_BUSY error occurs.
542
- * @default 5
543
- */
544
- maxRetries: number;
545
- /**
546
- * Initial backoff time in milliseconds for retrying write operations on SQLITE_BUSY.
547
- * The backoff time will double with each retry (exponential backoff).
548
- * @default 100
549
- */
550
- initialBackoffMs: number;
551
- constructor({ client, maxRetries, initialBackoffMs, }: {
552
- client: Client;
553
- maxRetries?: number;
554
- initialBackoffMs?: number;
555
- });
556
- hasColumn(table: string, column: string): Promise<boolean>;
557
- private getCreateTableSQL;
558
- createTable({ tableName, schema, }: {
559
- tableName: TABLE_NAMES;
560
- schema: Record<string, StorageColumn>;
561
- }): Promise<void>;
562
- protected getSqlType(type: StorageColumn['type']): string;
563
- private doInsert;
564
- insert(args: {
565
- tableName: TABLE_NAMES;
566
- record: Record<string, any>;
567
- }): Promise<void>;
568
- load<R>({ tableName, keys }: {
569
- tableName: TABLE_NAMES;
570
- keys: Record<string, string>;
571
- }): Promise<R | null>;
572
- private doBatchInsert;
573
- batchInsert(args: {
574
- tableName: TABLE_NAMES;
575
- records: Record<string, any>[];
576
- }): Promise<void>;
577
- /**
578
- * Alters table schema to add columns if they don't exist
579
- * @param tableName Name of the table
580
- * @param schema Schema of the table
581
- * @param ifNotExists Array of column names to add if they don't exist
582
- */
583
- alterTable({ tableName, schema, ifNotExists, }: {
584
- tableName: TABLE_NAMES;
585
- schema: Record<string, StorageColumn>;
586
- ifNotExists: string[];
587
- }): Promise<void>;
588
- clearTable({ tableName }: {
589
- tableName: TABLE_NAMES;
590
- }): Promise<void>;
591
- dropTable({ tableName }: {
592
- tableName: TABLE_NAMES;
593
- }): Promise<void>;
594
- }
595
-
596
- export declare class TracesLibSQL extends TracesStorage {
597
- private client;
598
- private operations;
599
- constructor({ client, operations }: {
600
- client: Client;
601
- operations: StoreOperationsLibSQL;
602
- });
603
- getTraces(args: StorageGetTracesArg): Promise<Trace[]>;
604
- getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
605
- traces: Trace[];
606
- }>;
607
- batchTraceInsert({ records }: {
608
- records: Record<string, any>[];
609
- }): Promise<void>;
610
- }
611
-
612
- export declare class WorkflowsLibSQL extends WorkflowsStorage {
613
- operations: StoreOperationsLibSQL;
614
- client: Client;
615
- constructor({ operations, client }: {
616
- operations: StoreOperationsLibSQL;
617
- client: Client;
618
- });
619
- persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
620
- workflowName: string;
621
- runId: string;
622
- snapshot: WorkflowRunState_2;
623
- }): Promise<void>;
624
- loadWorkflowSnapshot({ workflowName, runId, }: {
625
- workflowName: string;
626
- runId: string;
627
- }): Promise<WorkflowRunState_2 | null>;
628
- getWorkflowRunById({ runId, workflowName, }: {
629
- runId: string;
630
- workflowName?: string;
631
- }): Promise<WorkflowRun_2 | null>;
632
- getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
633
- workflowName?: string;
634
- fromDate?: Date;
635
- toDate?: Date;
636
- limit?: number;
637
- offset?: number;
638
- resourceId?: string;
639
- }): Promise<WorkflowRuns_2>;
640
- }
641
-
642
- export { }
package/dist/index.d.cts DELETED
@@ -1,6 +0,0 @@
1
- export { LIBSQL_PROMPT } from './_tsup-dts-rollup.cjs';
2
- export { LibSQLVectorConfig } from './_tsup-dts-rollup.cjs';
3
- export { LibSQLVector } from './_tsup-dts-rollup.cjs';
4
- export { LibSQLConfig } from './_tsup-dts-rollup.cjs';
5
- export { LibSQLStore } from './_tsup-dts-rollup.cjs';
6
- export { DefaultStorage } from './_tsup-dts-rollup.cjs';