@mastra/libsql 0.12.0 → 0.13.0-alpha.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.
Files changed (40) hide show
  1. package/.turbo/turbo-build.log +2 -21
  2. package/CHANGELOG.md +14 -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 +6 -6
  34. package/src/storage/domains/scores/index.ts +5 -3
  35. package/tsconfig.build.json +9 -0
  36. package/tsconfig.json +1 -1
  37. package/tsup.config.ts +22 -0
  38. package/dist/_tsup-dts-rollup.d.cts +0 -642
  39. package/dist/_tsup-dts-rollup.d.ts +0 -642
  40. package/dist/index.d.cts +0 -6
@@ -0,0 +1,87 @@
1
+ import type { Client } from '@libsql/client';
2
+ import type { MastraMessageContentV2 } from '@mastra/core/agent';
3
+ import type { MastraMessageV1, MastraMessageV2, StorageThreadType } from '@mastra/core/memory';
4
+ import type { PaginationInfo, StorageGetMessagesArg, StorageResourceType, ThreadSortOptions } from '@mastra/core/storage';
5
+ import { MemoryStorage } from '@mastra/core/storage';
6
+ import type { StoreOperationsLibSQL } from '../operations';
7
+ export declare class MemoryLibSQL extends MemoryStorage {
8
+ private client;
9
+ private operations;
10
+ constructor({ client, operations }: {
11
+ client: Client;
12
+ operations: StoreOperationsLibSQL;
13
+ });
14
+ private parseRow;
15
+ private _getIncludedMessages;
16
+ /**
17
+ * @deprecated use getMessagesPaginated instead for paginated results.
18
+ */
19
+ getMessages(args: StorageGetMessagesArg & {
20
+ format?: 'v1';
21
+ }): Promise<MastraMessageV1[]>;
22
+ getMessages(args: StorageGetMessagesArg & {
23
+ format: 'v2';
24
+ }): Promise<MastraMessageV2[]>;
25
+ getMessagesPaginated(args: StorageGetMessagesArg & {
26
+ format?: 'v1' | 'v2';
27
+ }): Promise<PaginationInfo & {
28
+ messages: MastraMessageV1[] | MastraMessageV2[];
29
+ }>;
30
+ saveMessages(args: {
31
+ messages: MastraMessageV1[];
32
+ format?: undefined | 'v1';
33
+ }): Promise<MastraMessageV1[]>;
34
+ saveMessages(args: {
35
+ messages: MastraMessageV2[];
36
+ format: 'v2';
37
+ }): Promise<MastraMessageV2[]>;
38
+ updateMessages({ messages, }: {
39
+ messages: (Partial<Omit<MastraMessageV2, 'createdAt'>> & {
40
+ id: string;
41
+ content?: {
42
+ metadata?: MastraMessageContentV2['metadata'];
43
+ content?: MastraMessageContentV2['content'];
44
+ };
45
+ })[];
46
+ }): Promise<MastraMessageV2[]>;
47
+ deleteMessages(messageIds: string[]): Promise<void>;
48
+ getResourceById({ resourceId }: {
49
+ resourceId: string;
50
+ }): Promise<StorageResourceType | null>;
51
+ saveResource({ resource }: {
52
+ resource: StorageResourceType;
53
+ }): Promise<StorageResourceType>;
54
+ updateResource({ resourceId, workingMemory, metadata, }: {
55
+ resourceId: string;
56
+ workingMemory?: string;
57
+ metadata?: Record<string, unknown>;
58
+ }): Promise<StorageResourceType>;
59
+ getThreadById({ threadId }: {
60
+ threadId: string;
61
+ }): Promise<StorageThreadType | null>;
62
+ /**
63
+ * @deprecated use getThreadsByResourceIdPaginated instead for paginated results.
64
+ */
65
+ getThreadsByResourceId(args: {
66
+ resourceId: string;
67
+ } & ThreadSortOptions): Promise<StorageThreadType[]>;
68
+ getThreadsByResourceIdPaginated(args: {
69
+ resourceId: string;
70
+ page: number;
71
+ perPage: number;
72
+ } & ThreadSortOptions): Promise<PaginationInfo & {
73
+ threads: StorageThreadType[];
74
+ }>;
75
+ saveThread({ thread }: {
76
+ thread: StorageThreadType;
77
+ }): Promise<StorageThreadType>;
78
+ updateThread({ id, title, metadata, }: {
79
+ id: string;
80
+ title: string;
81
+ metadata: Record<string, unknown>;
82
+ }): Promise<StorageThreadType>;
83
+ deleteThread({ threadId }: {
84
+ threadId: string;
85
+ }): Promise<void>;
86
+ }
87
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAW,MAAM,gBAAgB,CAAC;AAEtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGjE,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,sBAAs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GACpB,OAAO,CAAC,cAAc,GAAG;QAAE,OAAO,EAAE,iBAAiB,EAAE,CAAA;KAAE,CAAC;IAkEvD,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,iBAAiB,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA2BjF,YAAY,CAAC,EACjB,EAAE,EACF,KAAK,EACL,QAAQ,GACT,EAAE;QACD,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA6CxB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAwBtE"}
@@ -0,0 +1,61 @@
1
+ import type { Client } from '@libsql/client';
2
+ import { StoreOperations } from '@mastra/core/storage';
3
+ import type { StorageColumn, TABLE_NAMES } from '@mastra/core/storage';
4
+ export declare class StoreOperationsLibSQL extends StoreOperations {
5
+ private client;
6
+ /**
7
+ * Maximum number of retries for write operations if an SQLITE_BUSY error occurs.
8
+ * @default 5
9
+ */
10
+ maxRetries: number;
11
+ /**
12
+ * Initial backoff time in milliseconds for retrying write operations on SQLITE_BUSY.
13
+ * The backoff time will double with each retry (exponential backoff).
14
+ * @default 100
15
+ */
16
+ initialBackoffMs: number;
17
+ constructor({ client, maxRetries, initialBackoffMs, }: {
18
+ client: Client;
19
+ maxRetries?: number;
20
+ initialBackoffMs?: number;
21
+ });
22
+ hasColumn(table: string, column: string): Promise<boolean>;
23
+ private getCreateTableSQL;
24
+ createTable({ tableName, schema, }: {
25
+ tableName: TABLE_NAMES;
26
+ schema: Record<string, StorageColumn>;
27
+ }): Promise<void>;
28
+ protected getSqlType(type: StorageColumn['type']): string;
29
+ private doInsert;
30
+ insert(args: {
31
+ tableName: TABLE_NAMES;
32
+ record: Record<string, any>;
33
+ }): Promise<void>;
34
+ load<R>({ tableName, keys }: {
35
+ tableName: TABLE_NAMES;
36
+ keys: Record<string, string>;
37
+ }): Promise<R | null>;
38
+ private doBatchInsert;
39
+ batchInsert(args: {
40
+ tableName: TABLE_NAMES;
41
+ records: Record<string, any>[];
42
+ }): Promise<void>;
43
+ /**
44
+ * Alters table schema to add columns if they don't exist
45
+ * @param tableName Name of the table
46
+ * @param schema Schema of the table
47
+ * @param ifNotExists Array of column names to add if they don't exist
48
+ */
49
+ alterTable({ tableName, schema, ifNotExists, }: {
50
+ tableName: TABLE_NAMES;
51
+ schema: Record<string, StorageColumn>;
52
+ ifNotExists: string[];
53
+ }): Promise<void>;
54
+ clearTable({ tableName }: {
55
+ tableName: TABLE_NAMES;
56
+ }): Promise<void>;
57
+ dropTable({ tableName }: {
58
+ tableName: TABLE_NAMES;
59
+ }): Promise<void>;
60
+ }
61
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/operations/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAA2B,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIvE,qBAAa,qBAAsB,SAAQ,eAAe;IACxD,OAAO,CAAC,MAAM,CAAS;IACvB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;gBAEb,EACV,MAAM,EACN,UAAU,EACV,gBAAgB,GACjB,EAAE;QACD,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B;IAQK,SAAS,CAAC,KAAK,EAAE,MAAM,EA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AAI,CAAC;IAqBpE,SAAS,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAkB1E"}
@@ -0,0 +1,45 @@
1
+ import type { Client } from '@libsql/client';
2
+ import type { ScoreRowData } from '@mastra/core/scores';
3
+ import { ScoresStorage } from '@mastra/core/storage';
4
+ import type { PaginationInfo, StoragePagination } from '@mastra/core/storage';
5
+ import type { StoreOperationsLibSQL } from '../operations';
6
+ export declare class ScoresLibSQL extends ScoresStorage {
7
+ private operations;
8
+ private client;
9
+ constructor({ client, operations }: {
10
+ client: Client;
11
+ operations: StoreOperationsLibSQL;
12
+ });
13
+ getScoresByRunId({ runId, pagination, }: {
14
+ runId: string;
15
+ pagination: StoragePagination;
16
+ }): Promise<{
17
+ pagination: PaginationInfo;
18
+ scores: ScoreRowData[];
19
+ }>;
20
+ getScoresByScorerId({ scorerId, entityId, entityType, pagination, }: {
21
+ scorerId: string;
22
+ entityId?: string;
23
+ entityType?: string;
24
+ pagination: StoragePagination;
25
+ }): Promise<{
26
+ pagination: PaginationInfo;
27
+ scores: ScoreRowData[];
28
+ }>;
29
+ private transformScoreRow;
30
+ getScoreById({ id }: {
31
+ id: string;
32
+ }): Promise<ScoreRowData | null>;
33
+ saveScore(score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
34
+ score: ScoreRowData;
35
+ }>;
36
+ getScoresByEntityId({ entityId, entityType, pagination, }: {
37
+ pagination: StoragePagination;
38
+ entityId: string;
39
+ entityType: string;
40
+ }): Promise<{
41
+ pagination: PaginationInfo;
42
+ scores: ScoreRowData[];
43
+ }>;
44
+ }
45
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAW,MAAM,gBAAgB,CAAC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AG,OAAO,CAAC;QAAE,KAAK,EAAE,YAAY,CAAA;KAAE,CAAC;IA4BxG,mBAAmB,CAAC,EACxB,QAAQ,EACR,UAAU,EACV,UAAU,GACX,EAAE;QACD,UAAU,EAAE,iBAAiB,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;CA0BpE"}
@@ -0,0 +1,21 @@
1
+ import type { Client } from '@libsql/client';
2
+ import { TracesStorage } from '@mastra/core/storage';
3
+ import type { StorageGetTracesArg, StorageGetTracesPaginatedArg, PaginationInfo } from '@mastra/core/storage';
4
+ import type { Trace } from '@mastra/core/telemetry';
5
+ import type { StoreOperationsLibSQL } from '../operations';
6
+ export declare class TracesLibSQL extends TracesStorage {
7
+ private client;
8
+ private operations;
9
+ constructor({ client, operations }: {
10
+ client: Client;
11
+ operations: StoreOperationsLibSQL;
12
+ });
13
+ getTraces(args: StorageGetTracesArg): Promise<Trace[]>;
14
+ getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
15
+ traces: Trace[];
16
+ }>;
17
+ batchTraceInsert({ records }: {
18
+ records: Record<string, any>[];
19
+ }): Promise<void>;
20
+ }
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/traces/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAW,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAgB,aAAa,EAAmB,MAAM,sBAAsB,CAAC;AACpF,OAAO,KAAK,EAAE,mBAAmB,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC9G,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,qBAAa,YAAa,SAAQ,aAAa;IAC7C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAwB;gBAE9B,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,qBAAqB,CAAA;KAAE;IAMnF,SAAS,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAsBtD,kBAAkB,CAAC,IAAI,EAAE,4BAA4B,GAAG,OAAO,CAAC,cAAc,GAAG;QAAE,MAAM,EAAE,KAAK,EAAE,CAAA;KAAE,CAAC;IAsGrG,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAOvF"}
@@ -0,0 +1,16 @@
1
+ import type { InValue } from '@libsql/client';
2
+ import type { IMastraLogger } from '@mastra/core/logger';
3
+ import type { TABLE_NAMES } from '@mastra/core/storage';
4
+ export declare function createExecuteWriteOperationWithRetry({ logger, maxRetries, initialBackoffMs, }: {
5
+ logger: IMastraLogger;
6
+ maxRetries: number;
7
+ initialBackoffMs: number;
8
+ }): <T>(operationFn: () => Promise<T>, operationDescription: string) => Promise<T>;
9
+ export declare function prepareStatement({ tableName, record }: {
10
+ tableName: TABLE_NAMES;
11
+ record: Record<string, any>;
12
+ }): {
13
+ sql: string;
14
+ args: InValue[];
15
+ };
16
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/storage/domains/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,wBAAgB,oCAAoC,CAAC,EACnD,MAAM,EACN,UAAU,EACV,gBAAgB,GACjB,EAAE;IACD,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,IACsD,CAAC,EACpD,aAAa,MAAM,OAAO,CAAC,CAAC,CAAC,EAC7B,sBAAsB,MAAM,KAC3B,OAAO,CAAC,CAAC,CAAC,CAyBd;AAED,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE;IAAE,SAAS,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,GAAG;IAChH,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB,CAmBA"}
@@ -0,0 +1,34 @@
1
+ import type { Client } from '@libsql/client';
2
+ import type { WorkflowRun, WorkflowRuns, WorkflowRunState } from '@mastra/core';
3
+ import { WorkflowsStorage } from '@mastra/core/storage';
4
+ import type { StoreOperationsLibSQL } from '../operations';
5
+ export declare class WorkflowsLibSQL extends WorkflowsStorage {
6
+ operations: StoreOperationsLibSQL;
7
+ client: Client;
8
+ constructor({ operations, client }: {
9
+ operations: StoreOperationsLibSQL;
10
+ client: Client;
11
+ });
12
+ persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
13
+ workflowName: string;
14
+ runId: string;
15
+ snapshot: WorkflowRunState;
16
+ }): Promise<void>;
17
+ loadWorkflowSnapshot({ workflowName, runId, }: {
18
+ workflowName: string;
19
+ runId: string;
20
+ }): Promise<WorkflowRunState | null>;
21
+ getWorkflowRunById({ runId, workflowName, }: {
22
+ runId: string;
23
+ workflowName?: string;
24
+ }): Promise<WorkflowRun | null>;
25
+ getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
26
+ workflowName?: string;
27
+ fromDate?: Date;
28
+ toDate?: Date;
29
+ limit?: number;
30
+ offset?: number;
31
+ resourceId?: string;
32
+ }): Promise<WorkflowRuns>;
33
+ }
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAW,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhF,OAAO,EAA2B,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAsB3D,qBAAa,eAAgB,SAAQ,gBAAgB;IACnD,UAAU,EAAE,qBAAqB,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;gBACH,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE;QAAE,UAAU,EAAE,qBAAqB,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAMnF,uBAAuB,CAAC,EAC5B,YAAY,EACZ,KAAK,EACL,QAAQ,GACT,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,gBAAgB,CAAC;KAC5B;IAgBK,oBAAoB,CAAC,EACzB,YAAY,EACZ,KAAK,GACN,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAU9B,kBAAkB,CAAC,EACvB,KAAK,EACL,YAAY,GACb,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAuCzB,eAAe,CAAC,EACpB,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,UAAU,GACX,GAAE;QACD,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,IAAI,CAAC;QAChB,MAAM,CAAC,EAAE,IAAI,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,YAAY,CAAC;CA+D/B"}
@@ -0,0 +1,221 @@
1
+ import type { Client } from '@libsql/client';
2
+ import type { MastraMessageContentV2, MastraMessageV2 } from '@mastra/core/agent';
3
+ import type { MastraMessageV1, StorageThreadType } from '@mastra/core/memory';
4
+ import type { ScoreRowData } from '@mastra/core/scores';
5
+ import { MastraStorage } from '@mastra/core/storage';
6
+ import type { EvalRow, PaginationArgs, PaginationInfo, StorageColumn, StoragePagination, StorageGetMessagesArg, StorageResourceType, TABLE_NAMES, WorkflowRun, WorkflowRuns, StorageGetTracesArg, StorageDomains, ThreadSortOptions } from '@mastra/core/storage';
7
+ import type { Trace } from '@mastra/core/telemetry';
8
+ import type { WorkflowRunState } from '@mastra/core/workflows';
9
+ export type LibSQLConfig = {
10
+ url: string;
11
+ authToken?: string;
12
+ /**
13
+ * Maximum number of retries for write operations if an SQLITE_BUSY error occurs.
14
+ * @default 5
15
+ */
16
+ maxRetries?: number;
17
+ /**
18
+ * Initial backoff time in milliseconds for retrying write operations on SQLITE_BUSY.
19
+ * The backoff time will double with each retry (exponential backoff).
20
+ * @default 100
21
+ */
22
+ initialBackoffMs?: number;
23
+ } | {
24
+ client: Client;
25
+ maxRetries?: number;
26
+ initialBackoffMs?: number;
27
+ };
28
+ export declare class LibSQLStore extends MastraStorage {
29
+ private client;
30
+ private readonly maxRetries;
31
+ private readonly initialBackoffMs;
32
+ stores: StorageDomains;
33
+ constructor(config: LibSQLConfig);
34
+ get supports(): {
35
+ selectByIncludeResourceScope: boolean;
36
+ resourceWorkingMemory: boolean;
37
+ hasColumn: boolean;
38
+ createTable: boolean;
39
+ deleteMessages: boolean;
40
+ };
41
+ createTable({ tableName, schema, }: {
42
+ tableName: TABLE_NAMES;
43
+ schema: Record<string, StorageColumn>;
44
+ }): Promise<void>;
45
+ /**
46
+ * Alters table schema to add columns if they don't exist
47
+ * @param tableName Name of the table
48
+ * @param schema Schema of the table
49
+ * @param ifNotExists Array of column names to add if they don't exist
50
+ */
51
+ alterTable({ tableName, schema, ifNotExists, }: {
52
+ tableName: TABLE_NAMES;
53
+ schema: Record<string, StorageColumn>;
54
+ ifNotExists: string[];
55
+ }): Promise<void>;
56
+ clearTable({ tableName }: {
57
+ tableName: TABLE_NAMES;
58
+ }): Promise<void>;
59
+ dropTable({ tableName }: {
60
+ tableName: TABLE_NAMES;
61
+ }): Promise<void>;
62
+ insert(args: {
63
+ tableName: TABLE_NAMES;
64
+ record: Record<string, any>;
65
+ }): Promise<void>;
66
+ batchInsert(args: {
67
+ tableName: TABLE_NAMES;
68
+ records: Record<string, any>[];
69
+ }): Promise<void>;
70
+ load<R>({ tableName, keys }: {
71
+ tableName: TABLE_NAMES;
72
+ keys: Record<string, string>;
73
+ }): Promise<R | null>;
74
+ getThreadById({ threadId }: {
75
+ threadId: string;
76
+ }): Promise<StorageThreadType | null>;
77
+ /**
78
+ * @deprecated use getThreadsByResourceIdPaginated instead for paginated results.
79
+ */
80
+ getThreadsByResourceId(args: {
81
+ resourceId: string;
82
+ } & ThreadSortOptions): Promise<StorageThreadType[]>;
83
+ getThreadsByResourceIdPaginated(args: {
84
+ resourceId: string;
85
+ page: number;
86
+ perPage: number;
87
+ } & ThreadSortOptions): Promise<PaginationInfo & {
88
+ threads: StorageThreadType[];
89
+ }>;
90
+ saveThread({ thread }: {
91
+ thread: StorageThreadType;
92
+ }): Promise<StorageThreadType>;
93
+ updateThread({ id, title, metadata, }: {
94
+ id: string;
95
+ title: string;
96
+ metadata: Record<string, unknown>;
97
+ }): Promise<StorageThreadType>;
98
+ deleteThread({ threadId }: {
99
+ threadId: string;
100
+ }): Promise<void>;
101
+ /**
102
+ * @deprecated use getMessagesPaginated instead for paginated results.
103
+ */
104
+ getMessages(args: StorageGetMessagesArg & {
105
+ format?: 'v1';
106
+ }): Promise<MastraMessageV1[]>;
107
+ getMessages(args: StorageGetMessagesArg & {
108
+ format: 'v2';
109
+ }): Promise<MastraMessageV2[]>;
110
+ getMessagesPaginated(args: StorageGetMessagesArg & {
111
+ format?: 'v1' | 'v2';
112
+ }): Promise<PaginationInfo & {
113
+ messages: MastraMessageV1[] | MastraMessageV2[];
114
+ }>;
115
+ saveMessages(args: {
116
+ messages: MastraMessageV1[];
117
+ format?: undefined | 'v1';
118
+ }): Promise<MastraMessageV1[]>;
119
+ saveMessages(args: {
120
+ messages: MastraMessageV2[];
121
+ format: 'v2';
122
+ }): Promise<MastraMessageV2[]>;
123
+ updateMessages({ messages, }: {
124
+ messages: (Partial<Omit<MastraMessageV2, 'createdAt'>> & {
125
+ id: string;
126
+ content?: {
127
+ metadata?: MastraMessageContentV2['metadata'];
128
+ content?: MastraMessageContentV2['content'];
129
+ };
130
+ })[];
131
+ }): Promise<MastraMessageV2[]>;
132
+ deleteMessages(messageIds: string[]): Promise<void>;
133
+ /** @deprecated use getEvals instead */
134
+ getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
135
+ getEvals(options?: {
136
+ agentName?: string;
137
+ type?: 'test' | 'live';
138
+ } & PaginationArgs): Promise<PaginationInfo & {
139
+ evals: EvalRow[];
140
+ }>;
141
+ getScoreById({ id }: {
142
+ id: string;
143
+ }): Promise<ScoreRowData | null>;
144
+ saveScore(score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
145
+ score: ScoreRowData;
146
+ }>;
147
+ getScoresByScorerId({ scorerId, entityId, entityType, pagination, }: {
148
+ scorerId: string;
149
+ entityId?: string;
150
+ entityType?: string;
151
+ pagination: StoragePagination;
152
+ }): Promise<{
153
+ pagination: PaginationInfo;
154
+ scores: ScoreRowData[];
155
+ }>;
156
+ getScoresByRunId({ runId, pagination, }: {
157
+ runId: string;
158
+ pagination: StoragePagination;
159
+ }): Promise<{
160
+ pagination: PaginationInfo;
161
+ scores: ScoreRowData[];
162
+ }>;
163
+ getScoresByEntityId({ entityId, entityType, pagination, }: {
164
+ pagination: StoragePagination;
165
+ entityId: string;
166
+ entityType: string;
167
+ }): Promise<{
168
+ pagination: PaginationInfo;
169
+ scores: ScoreRowData[];
170
+ }>;
171
+ /**
172
+ * TRACES
173
+ */
174
+ /**
175
+ * @deprecated use getTracesPaginated instead.
176
+ */
177
+ getTraces(args: StorageGetTracesArg): Promise<Trace[]>;
178
+ getTracesPaginated(args: StorageGetTracesArg): Promise<PaginationInfo & {
179
+ traces: Trace[];
180
+ }>;
181
+ batchTraceInsert(args: {
182
+ records: Record<string, any>[];
183
+ }): Promise<void>;
184
+ /**
185
+ * WORKFLOWS
186
+ */
187
+ persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
188
+ workflowName: string;
189
+ runId: string;
190
+ snapshot: WorkflowRunState;
191
+ }): Promise<void>;
192
+ loadWorkflowSnapshot({ workflowName, runId, }: {
193
+ workflowName: string;
194
+ runId: string;
195
+ }): Promise<WorkflowRunState | null>;
196
+ getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
197
+ workflowName?: string;
198
+ fromDate?: Date;
199
+ toDate?: Date;
200
+ limit?: number;
201
+ offset?: number;
202
+ resourceId?: string;
203
+ }): Promise<WorkflowRuns>;
204
+ getWorkflowRunById({ runId, workflowName, }: {
205
+ runId: string;
206
+ workflowName?: string;
207
+ }): Promise<WorkflowRun | null>;
208
+ getResourceById({ resourceId }: {
209
+ resourceId: string;
210
+ }): Promise<StorageResourceType | null>;
211
+ saveResource({ resource }: {
212
+ resource: StorageResourceType;
213
+ }): Promise<StorageResourceType>;
214
+ updateResource({ resourceId, workingMemory, metadata, }: {
215
+ resourceId: string;
216
+ workingMemory?: string;
217
+ metadata?: Record<string, unknown>;
218
+ }): Promise<StorageResourceType>;
219
+ }
220
+ export { LibSQLStore as DefaultStorage };
221
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAQ/D,MAAM,MAAM,YAAY,GACpB;IACE,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,GACD;IACE,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEN,qBAAa,WAAY,SAAQ,a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,GAAG,IAAI,CAAC;IAIzB,eAAe,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAI5F,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,mBAAmB,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI3F,cAAc,CAAC,EACnB,UAAU,EACV,aAAa,EACb,QAAQ,GACT,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAGjC;AAED,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
+ import type { VectorFilter, OperatorSupport, OperatorValueMap, VectorFieldValue } from '@mastra/core/vector/filter';
3
+ type LibSQLOperatorValueMap = Omit<OperatorValueMap, '$regex' | '$options' | '$in' | '$all' | '$nin' | '$eq' | '$ne'> & {
4
+ $size: number;
5
+ $contains: VectorFieldValue | Record<string, unknown>;
6
+ $all: VectorFieldValue;
7
+ $in: VectorFieldValue;
8
+ $nin: VectorFieldValue;
9
+ $eq: VectorFieldValue;
10
+ $ne: VectorFieldValue;
11
+ };
12
+ export type LibSQLVectorFilter = VectorFilter<keyof LibSQLOperatorValueMap, LibSQLOperatorValueMap>;
13
+ /**
14
+ * Translates MongoDB-style filters to LibSQL compatible filters.
15
+ *
16
+ * Key differences from MongoDB:
17
+ *
18
+ * Logical Operators ($and, $or, $nor):
19
+ * - Can be used at the top level or nested within fields
20
+ * - Can take either a single condition or an array of conditions
21
+ *
22
+ */
23
+ export declare class LibSQLFilterTranslator extends BaseFilterTranslator<LibSQLVectorFilter> {
24
+ protected getSupportedOperators(): OperatorSupport;
25
+ translate(filter?: LibSQLVectorFilter): LibSQLVectorFilter;
26
+ private translateNode;
27
+ }
28
+ export {};
29
+ //# sourceMappingURL=filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/vector/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEpH,KAAK,sBAAsB,GAAG,IAAI,CAChC,gBAAgB,EAChB,QAAQ,GAAG,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAChE,GAAG;IACF,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtD,IAAI,EAAE,gBAAgB,CAAC;IACvB,GAAG,EAAE,gBAAgB,CAAC;IACtB,IAAI,EAAE,gBAAgB,CAAC;IACvB,GAAG,EAAE,gBAAgB,CAAC;IACtB,GAAG,EAAE,gBAAgB,CAAC;CACvB,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC,MAAM,sBAAsB,EAAE,sBAAsB,CAAC,CAAC;AAEpG;;;;;;;;;GASG;AACH,qBAAa,sBAAuB,SAAQ,oBAAoB,CAAC,kBAAkB,CAAC;cAC/D,qBAAqB,IAAI,eAAe;IAQ3D,SAAS,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,kBAAkB;IAQ1D,OAAO,CAAC,aAAa;CAsFtB"}
@@ -0,0 +1,72 @@
1
+ import { MastraVector } from '@mastra/core/vector';
2
+ import type { IndexStats, QueryResult, QueryVectorParams, CreateIndexParams, UpsertVectorParams, DescribeIndexParams, DeleteIndexParams, DeleteVectorParams, UpdateVectorParams } from '@mastra/core/vector';
3
+ import type { LibSQLVectorFilter } from './filter';
4
+ interface LibSQLQueryVectorParams extends QueryVectorParams<LibSQLVectorFilter> {
5
+ minScore?: number;
6
+ }
7
+ export interface LibSQLVectorConfig {
8
+ connectionUrl: string;
9
+ authToken?: string;
10
+ syncUrl?: string;
11
+ syncInterval?: number;
12
+ /**
13
+ * Maximum number of retries for write operations if an SQLITE_BUSY error occurs.
14
+ * @default 5
15
+ */
16
+ maxRetries?: number;
17
+ /**
18
+ * Initial backoff time in milliseconds for retrying write operations on SQLITE_BUSY.
19
+ * The backoff time will double with each retry (exponential backoff).
20
+ * @default 100
21
+ */
22
+ initialBackoffMs?: number;
23
+ }
24
+ export declare class LibSQLVector extends MastraVector<LibSQLVectorFilter> {
25
+ private turso;
26
+ private readonly maxRetries;
27
+ private readonly initialBackoffMs;
28
+ constructor({ connectionUrl, authToken, syncUrl, syncInterval, maxRetries, initialBackoffMs, }: LibSQLVectorConfig);
29
+ private executeWriteOperationWithRetry;
30
+ transformFilter(filter?: LibSQLVectorFilter): LibSQLVectorFilter;
31
+ query({ indexName, queryVector, topK, filter, includeVector, minScore, }: LibSQLQueryVectorParams): Promise<QueryResult[]>;
32
+ upsert(args: UpsertVectorParams): Promise<string[]>;
33
+ private doUpsert;
34
+ createIndex(args: CreateIndexParams): Promise<void>;
35
+ private doCreateIndex;
36
+ deleteIndex(args: DeleteIndexParams): Promise<void>;
37
+ private doDeleteIndex;
38
+ listIndexes(): Promise<string[]>;
39
+ /**
40
+ * Retrieves statistics about a vector index.
41
+ *
42
+ * @param {string} indexName - The name of the index to describe
43
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
44
+ */
45
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
46
+ /**
47
+ * Updates a vector by its ID with the provided vector and/or metadata.
48
+ *
49
+ * @param indexName - The name of the index containing the vector.
50
+ * @param id - The ID of the vector to update.
51
+ * @param update - An object containing the vector and/or metadata to update.
52
+ * @param update.vector - An optional array of numbers representing the new vector.
53
+ * @param update.metadata - An optional record containing the new metadata.
54
+ * @returns A promise that resolves when the update is complete.
55
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
56
+ */
57
+ updateVector(args: UpdateVectorParams): Promise<void>;
58
+ private doUpdateVector;
59
+ /**
60
+ * Deletes a vector by its ID.
61
+ * @param indexName - The name of the index containing the vector.
62
+ * @param id - The ID of the vector to delete.
63
+ * @returns A promise that resolves when the deletion is complete.
64
+ * @throws Will throw an error if the deletion operation fails.
65
+ */
66
+ deleteVector(args: DeleteVectorParams): Promise<void>;
67
+ private doDeleteVector;
68
+ truncateIndex(args: DeleteIndexParams): Promise<void>;
69
+ private _doTruncateIndex;
70
+ }
71
+ export {};
72
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAInD,UAAU,uBAAwB,SAAQ,iBAAiB,CAAC,kBAAkB,CAAC;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,qBAAa,YAAa,SA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