@mastra/lance 0.2.3 → 0.2.4-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 (37) hide show
  1. package/.turbo/turbo-build.log +2 -21
  2. package/CHANGELOG.md +13 -0
  3. package/dist/index.cjs +2 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.ts +3 -2
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +2 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/storage/domains/legacy-evals/index.d.ts +25 -0
  10. package/dist/storage/domains/legacy-evals/index.d.ts.map +1 -0
  11. package/dist/storage/domains/memory/index.d.ts +94 -0
  12. package/dist/storage/domains/memory/index.d.ts.map +1 -0
  13. package/dist/storage/domains/operations/index.d.ts +40 -0
  14. package/dist/storage/domains/operations/index.d.ts.map +1 -0
  15. package/dist/storage/domains/scores/index.d.ts +39 -0
  16. package/dist/storage/domains/scores/index.d.ts.map +1 -0
  17. package/dist/storage/domains/traces/index.d.ts +34 -0
  18. package/dist/storage/domains/traces/index.d.ts.map +1 -0
  19. package/dist/storage/domains/utils.d.ts +10 -0
  20. package/dist/storage/domains/utils.d.ts.map +1 -0
  21. package/dist/storage/domains/workflows/index.d.ts +38 -0
  22. package/dist/storage/domains/workflows/index.d.ts.map +1 -0
  23. package/dist/storage/index.d.ts +233 -0
  24. package/dist/storage/index.d.ts.map +1 -0
  25. package/dist/vector/filter.d.ts +41 -0
  26. package/dist/vector/filter.d.ts.map +1 -0
  27. package/dist/vector/index.d.ts +85 -0
  28. package/dist/vector/index.d.ts.map +1 -0
  29. package/dist/vector/types.d.ts +15 -0
  30. package/dist/vector/types.d.ts.map +1 -0
  31. package/package.json +9 -8
  32. package/tsconfig.build.json +9 -0
  33. package/tsconfig.json +1 -1
  34. package/tsup.config.ts +17 -0
  35. package/dist/_tsup-dts-rollup.d.cts +0 -681
  36. package/dist/_tsup-dts-rollup.d.ts +0 -681
  37. package/dist/index.d.cts +0 -2
@@ -0,0 +1,25 @@
1
+ import type { Connection } from '@lancedb/lancedb';
2
+ import { LegacyEvalsStorage } from '@mastra/core/storage';
3
+ import type { EvalRow, PaginationInfo } from '@mastra/core/storage';
4
+ export declare class StoreLegacyEvalsLance extends LegacyEvalsStorage {
5
+ private client;
6
+ constructor({ client }: {
7
+ client: Connection;
8
+ });
9
+ getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
10
+ getEvals(options: {
11
+ agentName?: string;
12
+ type?: 'test' | 'live';
13
+ page?: number;
14
+ perPage?: number;
15
+ fromDate?: Date;
16
+ toDate?: Date;
17
+ dateRange?: {
18
+ start?: Date;
19
+ end?: Date;
20
+ };
21
+ }): Promise<PaginationInfo & {
22
+ evals: EvalRow[];
23
+ }>;
24
+ }
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/legacy-evals/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAe,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEpE,qBAAa,qBAAsB,SAAQ,kBAAkB;IAC3D,OAAO,CAAC,MAAM,CAAa;gBACf,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,UAAU,CAAA;KAAE;IAKxC,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IA4ClF,QAAQ,CAAC,OAAO,EAAE;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACvB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,IAAI,CAAC;QAChB,MAAM,CAAC,EAAE,IAAI,CAAC;QACd,SAAS,CAAC,EAAE;YAAE,KAAK,CAAC,EAAE,IAAI,CAAC;YAAC,GAAG,CAAC,EAAE,IAAI,CAAA;SAAE,CAAC;KAC1C,GAAG,OAAO,CAAC,cAAc,GAAG;QAAE,KAAK,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC;CA2FnD"}
@@ -0,0 +1,94 @@
1
+ import type { Connection } from '@lancedb/lancedb';
2
+ import type { MastraMessageContentV2 } from '@mastra/core/agent';
3
+ import type { MastraMessageV1, MastraMessageV2, StorageThreadType } from '@mastra/core/memory';
4
+ import { MemoryStorage } from '@mastra/core/storage';
5
+ import type { PaginationInfo, StorageGetMessagesArg, StorageResourceType } from '@mastra/core/storage';
6
+ import type { StoreOperationsLance } from '../operations/index.js';
7
+ export declare class StoreMemoryLance extends MemoryStorage {
8
+ private client;
9
+ private operations;
10
+ constructor({ client, operations }: {
11
+ client: Connection;
12
+ operations: StoreOperationsLance;
13
+ });
14
+ getThreadById({ threadId }: {
15
+ threadId: string;
16
+ }): Promise<StorageThreadType | null>;
17
+ getThreadsByResourceId({ resourceId }: {
18
+ resourceId: string;
19
+ }): Promise<StorageThreadType[]>;
20
+ /**
21
+ * Saves a thread to the database. This function doesn't overwrite existing threads.
22
+ * @param thread - The thread to save
23
+ * @returns The saved thread
24
+ */
25
+ saveThread({ thread }: {
26
+ thread: StorageThreadType;
27
+ }): Promise<StorageThreadType>;
28
+ updateThread({ id, title, metadata, }: {
29
+ id: string;
30
+ title: string;
31
+ metadata: Record<string, unknown>;
32
+ }): Promise<StorageThreadType>;
33
+ deleteThread({ threadId }: {
34
+ threadId: string;
35
+ }): Promise<void>;
36
+ getMessages(args: StorageGetMessagesArg & {
37
+ format?: 'v1';
38
+ }): Promise<MastraMessageV1[]>;
39
+ getMessages(args: StorageGetMessagesArg & {
40
+ format: 'v2';
41
+ }): Promise<MastraMessageV2[]>;
42
+ saveMessages(args: {
43
+ messages: MastraMessageV1[];
44
+ format?: undefined | 'v1';
45
+ }): Promise<MastraMessageV1[]>;
46
+ saveMessages(args: {
47
+ messages: MastraMessageV2[];
48
+ format: 'v2';
49
+ }): Promise<MastraMessageV2[]>;
50
+ getThreadsByResourceIdPaginated(args: {
51
+ resourceId: string;
52
+ page?: number;
53
+ perPage?: number;
54
+ }): Promise<PaginationInfo & {
55
+ threads: StorageThreadType[];
56
+ }>;
57
+ /**
58
+ * Processes messages to include context messages based on withPreviousMessages and withNextMessages
59
+ * @param records - The sorted array of records to process
60
+ * @param include - The array of include specifications with context parameters
61
+ * @returns The processed array with context messages included
62
+ */
63
+ private processMessagesWithContext;
64
+ getMessagesPaginated(args: StorageGetMessagesArg & {
65
+ format?: 'v1' | 'v2';
66
+ }): Promise<PaginationInfo & {
67
+ messages: MastraMessageV1[] | MastraMessageV2[];
68
+ }>;
69
+ /**
70
+ * Parse message data from LanceDB record format to MastraMessageV2 format
71
+ */
72
+ private parseMessageData;
73
+ updateMessages(args: {
74
+ messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
75
+ id: string;
76
+ content?: {
77
+ metadata?: MastraMessageContentV2['metadata'];
78
+ content?: MastraMessageContentV2['content'];
79
+ };
80
+ }[];
81
+ }): Promise<MastraMessageV2[]>;
82
+ getResourceById({ resourceId }: {
83
+ resourceId: string;
84
+ }): Promise<StorageResourceType | null>;
85
+ saveResource({ resource }: {
86
+ resource: StorageResourceType;
87
+ }): Promise<StorageResourceType>;
88
+ updateResource({ resourceId, workingMemory, metadata, }: {
89
+ resourceId: string;
90
+ workingMemory?: string;
91
+ metadata?: Record<string, unknown>;
92
+ }): Promise<StorageResourceType>;
93
+ }
94
+ //# 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,OA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CAAC,GACnD;YACE,EAAE,EAAE,MAAM,CAAC;YACX,OAAO,CAAC,EAAE;gBAAE,QAAQ,CAAC,EAAE,sBAAsB,CAAC,UAAU,CAAC,CAAC;gBAAC,OAAO,CAAC,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAA;aAAE,CAAC;SAC1G,EAAE,CAAC;KACP,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAgGxB,eAAe,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAiG5F,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,mBAAmB,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAyB3F,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;CA+DjC"}
@@ -0,0 +1,40 @@
1
+ import type { Connection } from '@lancedb/lancedb';
2
+ import { StoreOperations } from '@mastra/core/storage';
3
+ import type { TABLE_NAMES, StorageColumn } from '@mastra/core/storage';
4
+ export declare class StoreOperationsLance extends StoreOperations {
5
+ client: Connection;
6
+ constructor({ client }: {
7
+ client: Connection;
8
+ });
9
+ protected getDefaultValue(type: StorageColumn['type']): string;
10
+ hasColumn(tableName: TABLE_NAMES, columnName: string): Promise<boolean>;
11
+ private translateSchema;
12
+ createTable({ tableName, schema, }: {
13
+ tableName: TABLE_NAMES;
14
+ schema: Record<string, StorageColumn>;
15
+ }): Promise<void>;
16
+ dropTable({ tableName }: {
17
+ tableName: TABLE_NAMES;
18
+ }): Promise<void>;
19
+ alterTable({ tableName, schema, ifNotExists, }: {
20
+ tableName: string;
21
+ schema: Record<string, StorageColumn>;
22
+ ifNotExists: string[];
23
+ }): Promise<void>;
24
+ clearTable({ tableName }: {
25
+ tableName: TABLE_NAMES;
26
+ }): Promise<void>;
27
+ insert({ tableName, record }: {
28
+ tableName: string;
29
+ record: Record<string, any>;
30
+ }): Promise<void>;
31
+ batchInsert({ tableName, records }: {
32
+ tableName: string;
33
+ records: Record<string, any>[];
34
+ }): Promise<void>;
35
+ load({ tableName, keys }: {
36
+ tableName: TABLE_NAMES;
37
+ keys: Record<string, any>;
38
+ }): Promise<any>;
39
+ }
40
+ //# 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,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAKvE,qBAAa,oBAAqB,SAAQ,eAAe;IACvD,MAAM,EAAE,UAAU,CAAC;gBACP,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,UAAU,CAAA;KAAE;IAK9C,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM;IAkBxD,SAAS,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM7E,OAAO,CAAC,eAAe;IAyCjB,WAAW,CAAC,EAChB,SAAS,EACT,MAAM,GACP,EAAE;QACD,SAAS,EAAE,WAAW,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;KACvC,GAAG,OAAO,CAAC,IAAI,CAAC;IA2CX,SAAS,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAwCnE,UAAU,CAAC,EACf,SAAS,EACT,MAAM,EACN,WAAW,GACZ,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;QACtC,WAAW,EAAE,MAAM,EAAE,CAAC;KACvB,GAAG,OAAO,CAAC,IAAI,CAAC;IAwEX,UAAU,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAuCpE,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAyDhG,WAAW,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiEzG,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC;CA8ErG"}
@@ -0,0 +1,39 @@
1
+ import type { Connection } from '@lancedb/lancedb';
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
+ export declare class StoreScoresLance extends ScoresStorage {
6
+ private client;
7
+ constructor({ client }: {
8
+ client: Connection;
9
+ });
10
+ saveScore(score: ScoreRowData): Promise<{
11
+ score: ScoreRowData;
12
+ }>;
13
+ getScoreById({ id }: {
14
+ id: string;
15
+ }): Promise<ScoreRowData | null>;
16
+ getScoresByScorerId({ scorerId, pagination, }: {
17
+ scorerId: string;
18
+ pagination: StoragePagination;
19
+ }): Promise<{
20
+ pagination: PaginationInfo;
21
+ scores: ScoreRowData[];
22
+ }>;
23
+ getScoresByRunId({ runId, pagination, }: {
24
+ runId: string;
25
+ pagination: StoragePagination;
26
+ }): Promise<{
27
+ pagination: PaginationInfo;
28
+ scores: ScoreRowData[];
29
+ }>;
30
+ getScoresByEntityId({ entityId, entityType, pagination, }: {
31
+ pagination: StoragePagination;
32
+ entityId: string;
33
+ entityType: string;
34
+ }): Promise<{
35
+ pagination: PaginationInfo;
36
+ scores: ScoreRowData[];
37
+ }>;
38
+ }
39
+ //# 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,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAiB,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9E,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,OAAO,CAAC,MAAM,CAAa;gBACf,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,UAAU,CAAA;KAAE;IAKxC,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,YAAY,CAAA;KAAE,CAAC;IA0ChE,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAyBlE,mBAAmB,CAAC,EACxB,QAAQ,EACR,UAAU,GACX,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAwC7D,gBAAgB,CAAC,EACrB,KAAK,EACL,UAAU,GACX,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAqC7D,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;CA0CpE"}
@@ -0,0 +1,34 @@
1
+ import type { Connection } from '@lancedb/lancedb';
2
+ import type { TraceType } from '@mastra/core/memory';
3
+ import { TracesStorage } from '@mastra/core/storage';
4
+ import type { PaginationInfo, StorageGetTracesPaginatedArg } from '@mastra/core/storage';
5
+ import type { Trace } from '@mastra/core/telemetry';
6
+ import type { StoreOperationsLance } from '../operations/index.js';
7
+ export declare class StoreTracesLance extends TracesStorage {
8
+ private client;
9
+ private operations;
10
+ constructor({ client, operations }: {
11
+ client: Connection;
12
+ operations: StoreOperationsLance;
13
+ });
14
+ saveTrace({ trace }: {
15
+ trace: TraceType;
16
+ }): Promise<TraceType>;
17
+ getTraceById({ traceId }: {
18
+ traceId: string;
19
+ }): Promise<TraceType>;
20
+ getTraces({ name, scope, page, perPage, attributes, }: {
21
+ name?: string;
22
+ scope?: string;
23
+ page: number;
24
+ perPage: number;
25
+ attributes?: Record<string, string>;
26
+ }): Promise<Trace[]>;
27
+ getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
28
+ traces: Trace[];
29
+ }>;
30
+ batchTraceInsert({ records }: {
31
+ records: Record<string, any>[];
32
+ }): Promise<void>;
33
+ }
34
+ //# 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,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAgB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1D,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,UAAU,CAAuB;gBAC7B,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE;QAAE,MAAM,EAAE,UAAU,CAAC;QAAC,UAAU,EAAE,oBAAoB,CAAA;KAAE;IAMtF,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,SAAS,CAAA;KAAE,GAAG,OAAO,CAAC,SAAS,CAAC;IAyB9D,YAAY,CAAC,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,SAAS,CAAC;IAkBlE,SAAS,CAAC,EACd,IAAI,EACJ,KAAK,EACL,IAAQ,EACR,OAAY,EACZ,UAAU,GACX,EAAE;QACD,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACrC,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAoDd,kBAAkB,CAAC,IAAI,EAAE,4BAA4B,GAAG,OAAO,CAAC,cAAc,GAAG;QAAE,MAAM,EAAE,KAAK,EAAE,CAAA;KAAE,CAAC;IAgFrG,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,10 @@
1
+ import type { Connection, SchemaLike } from '@lancedb/lancedb';
2
+ import type { TABLE_NAMES } from '@mastra/core/storage';
3
+ export declare function getPrimaryKeys(tableName: TABLE_NAMES): string[];
4
+ export declare function validateKeyTypes(keys: Record<string, any>, tableSchema: SchemaLike): void;
5
+ export declare function processResultWithTypeConversion(rawResult: Record<string, any> | Record<string, any>[], tableSchema: SchemaLike): Record<string, any> | Record<string, any>[];
6
+ export declare function getTableSchema({ tableName, client, }: {
7
+ tableName: TABLE_NAMES;
8
+ client: Connection;
9
+ }): Promise<SchemaLike>;
10
+ //# 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,UAAU,EAAa,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,wBAAgB,cAAc,CAAC,SAAS,EAAE,WAAW,GAAG,MAAM,EAAE,CAS/D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,WAAW,EAAE,UAAU,GAAG,IAAI,CA4BzF;AAED,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EACtD,WAAW,EAAE,UAAU,GACtB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAuD7C;AAED,wBAAsB,cAAc,CAAC,EACnC,SAAS,EACT,MAAM,GACP,EAAE;IACD,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,UAAU,CAAC;CACpB,GAAG,OAAO,CAAC,UAAU,CAAC,CA6CtB"}
@@ -0,0 +1,38 @@
1
+ import type { Connection } from '@lancedb/lancedb';
2
+ import type { WorkflowRunState, WorkflowRuns } from '@mastra/core';
3
+ import { WorkflowsStorage } from '@mastra/core/storage';
4
+ export declare class StoreWorkflowsLance extends WorkflowsStorage {
5
+ client: Connection;
6
+ constructor({ client }: {
7
+ client: Connection;
8
+ });
9
+ persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
10
+ workflowName: string;
11
+ runId: string;
12
+ snapshot: WorkflowRunState;
13
+ }): Promise<void>;
14
+ loadWorkflowSnapshot({ workflowName, runId, }: {
15
+ workflowName: string;
16
+ runId: string;
17
+ }): Promise<WorkflowRunState | null>;
18
+ getWorkflowRunById(args: {
19
+ runId: string;
20
+ workflowName?: string;
21
+ }): Promise<{
22
+ workflowName: string;
23
+ runId: string;
24
+ snapshot: any;
25
+ createdAt: Date;
26
+ updatedAt: Date;
27
+ } | null>;
28
+ getWorkflowRuns(args?: {
29
+ namespace?: string;
30
+ resourceId?: string;
31
+ workflowName?: string;
32
+ fromDate?: Date;
33
+ toDate?: Date;
34
+ limit?: number;
35
+ offset?: number;
36
+ }): Promise<WorkflowRuns>;
37
+ }
38
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,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AChB,MAAM,CAAC,EAAE,IAAI,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,YAAY,CAAC;CA4D1B"}
@@ -0,0 +1,233 @@
1
+ import type { ConnectionOptions } from '@lancedb/lancedb';
2
+ import type { MastraMessageContentV2 } from '@mastra/core/agent';
3
+ import type { MastraMessageV1, MastraMessageV2, StorageThreadType, TraceType } from '@mastra/core/memory';
4
+ import type { ScoreRowData } from '@mastra/core/scores';
5
+ import { MastraStorage } from '@mastra/core/storage';
6
+ import type { TABLE_NAMES, PaginationInfo, StorageGetMessagesArg, StorageColumn, EvalRow, WorkflowRuns, StoragePagination, StorageDomains, StorageGetTracesPaginatedArg, StorageResourceType } from '@mastra/core/storage';
7
+ import type { Trace } from '@mastra/core/telemetry';
8
+ import type { WorkflowRunState } from '@mastra/core/workflows';
9
+ export declare class LanceStorage extends MastraStorage {
10
+ stores: StorageDomains;
11
+ private lanceClient;
12
+ /**
13
+ * Creates a new instance of LanceStorage
14
+ * @param uri The URI to connect to LanceDB
15
+ * @param options connection options
16
+ *
17
+ * Usage:
18
+ *
19
+ * Connect to a local database
20
+ * ```ts
21
+ * const store = await LanceStorage.create('/path/to/db');
22
+ * ```
23
+ *
24
+ * Connect to a LanceDB cloud database
25
+ * ```ts
26
+ * const store = await LanceStorage.create('db://host:port');
27
+ * ```
28
+ *
29
+ * Connect to a cloud database
30
+ * ```ts
31
+ * const store = await LanceStorage.create('s3://bucket/db', { storageOptions: { timeout: '60s' } });
32
+ * ```
33
+ */
34
+ static create(name: string, uri: string, options?: ConnectionOptions): Promise<LanceStorage>;
35
+ /**
36
+ * @internal
37
+ * Private constructor to enforce using the create factory method
38
+ */
39
+ private constructor();
40
+ createTable({ tableName, schema, }: {
41
+ tableName: TABLE_NAMES;
42
+ schema: Record<string, StorageColumn>;
43
+ }): Promise<void>;
44
+ dropTable({ tableName }: {
45
+ tableName: TABLE_NAMES;
46
+ }): Promise<void>;
47
+ alterTable({ tableName, schema, ifNotExists, }: {
48
+ tableName: TABLE_NAMES;
49
+ schema: Record<string, StorageColumn>;
50
+ ifNotExists: string[];
51
+ }): Promise<void>;
52
+ clearTable({ tableName }: {
53
+ tableName: TABLE_NAMES;
54
+ }): Promise<void>;
55
+ insert({ tableName, record }: {
56
+ tableName: TABLE_NAMES;
57
+ record: Record<string, any>;
58
+ }): Promise<void>;
59
+ batchInsert({ tableName, records }: {
60
+ tableName: TABLE_NAMES;
61
+ records: Record<string, any>[];
62
+ }): Promise<void>;
63
+ load({ tableName, keys }: {
64
+ tableName: TABLE_NAMES;
65
+ keys: Record<string, any>;
66
+ }): Promise<any>;
67
+ getThreadById({ threadId }: {
68
+ threadId: string;
69
+ }): Promise<StorageThreadType | null>;
70
+ getThreadsByResourceId({ resourceId }: {
71
+ resourceId: string;
72
+ }): Promise<StorageThreadType[]>;
73
+ /**
74
+ * Saves a thread to the database. This function doesn't overwrite existing threads.
75
+ * @param thread - The thread to save
76
+ * @returns The saved thread
77
+ */
78
+ saveThread({ thread }: {
79
+ thread: StorageThreadType;
80
+ }): Promise<StorageThreadType>;
81
+ updateThread({ id, title, metadata, }: {
82
+ id: string;
83
+ title: string;
84
+ metadata: Record<string, unknown>;
85
+ }): Promise<StorageThreadType>;
86
+ deleteThread({ threadId }: {
87
+ threadId: string;
88
+ }): Promise<void>;
89
+ get supports(): {
90
+ selectByIncludeResourceScope: boolean;
91
+ resourceWorkingMemory: boolean;
92
+ hasColumn: boolean;
93
+ createTable: boolean;
94
+ deleteMessages: boolean;
95
+ };
96
+ getResourceById({ resourceId }: {
97
+ resourceId: string;
98
+ }): Promise<StorageResourceType | null>;
99
+ saveResource({ resource }: {
100
+ resource: StorageResourceType;
101
+ }): Promise<StorageResourceType>;
102
+ updateResource({ resourceId, workingMemory, metadata, }: {
103
+ resourceId: string;
104
+ workingMemory?: string;
105
+ metadata?: Record<string, unknown>;
106
+ }): Promise<StorageResourceType>;
107
+ /**
108
+ * Processes messages to include context messages based on withPreviousMessages and withNextMessages
109
+ * @param records - The sorted array of records to process
110
+ * @param include - The array of include specifications with context parameters
111
+ * @returns The processed array with context messages included
112
+ */
113
+ private processMessagesWithContext;
114
+ getMessages(args: StorageGetMessagesArg & {
115
+ format?: 'v1';
116
+ }): Promise<MastraMessageV1[]>;
117
+ getMessages(args: StorageGetMessagesArg & {
118
+ format: 'v2';
119
+ }): Promise<MastraMessageV2[]>;
120
+ saveMessages(args: {
121
+ messages: MastraMessageV1[];
122
+ format?: undefined | 'v1';
123
+ }): Promise<MastraMessageV1[]>;
124
+ saveMessages(args: {
125
+ messages: MastraMessageV2[];
126
+ format: 'v2';
127
+ }): Promise<MastraMessageV2[]>;
128
+ getThreadsByResourceIdPaginated(args: {
129
+ resourceId: string;
130
+ page: number;
131
+ perPage: number;
132
+ }): Promise<PaginationInfo & {
133
+ threads: StorageThreadType[];
134
+ }>;
135
+ getMessagesPaginated(args: StorageGetMessagesArg & {
136
+ format?: 'v1' | 'v2';
137
+ }): Promise<PaginationInfo & {
138
+ messages: MastraMessageV1[] | MastraMessageV2[];
139
+ }>;
140
+ updateMessages(_args: {
141
+ messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
142
+ id: string;
143
+ content?: {
144
+ metadata?: MastraMessageContentV2['metadata'];
145
+ content?: MastraMessageContentV2['content'];
146
+ };
147
+ }[];
148
+ }): Promise<MastraMessageV2[]>;
149
+ getTraceById(args: {
150
+ traceId: string;
151
+ }): Promise<TraceType>;
152
+ getTraces(args: {
153
+ name?: string;
154
+ scope?: string;
155
+ page: number;
156
+ perPage: number;
157
+ attributes?: Record<string, string>;
158
+ }): Promise<Trace[]>;
159
+ getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
160
+ traces: Trace[];
161
+ }>;
162
+ getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
163
+ getEvals(options: {
164
+ agentName?: string;
165
+ type?: 'test' | 'live';
166
+ page?: number;
167
+ perPage?: number;
168
+ fromDate?: Date;
169
+ toDate?: Date;
170
+ dateRange?: {
171
+ start?: Date;
172
+ end?: Date;
173
+ };
174
+ }): Promise<PaginationInfo & {
175
+ evals: EvalRow[];
176
+ }>;
177
+ getWorkflowRuns(args?: {
178
+ namespace?: string;
179
+ workflowName?: string;
180
+ fromDate?: Date;
181
+ toDate?: Date;
182
+ limit?: number;
183
+ offset?: number;
184
+ }): Promise<WorkflowRuns>;
185
+ getWorkflowRunById(args: {
186
+ runId: string;
187
+ workflowName?: string;
188
+ }): Promise<{
189
+ workflowName: string;
190
+ runId: string;
191
+ snapshot: any;
192
+ createdAt: Date;
193
+ updatedAt: Date;
194
+ } | null>;
195
+ persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
196
+ workflowName: string;
197
+ runId: string;
198
+ snapshot: WorkflowRunState;
199
+ }): Promise<void>;
200
+ loadWorkflowSnapshot({ workflowName, runId, }: {
201
+ workflowName: string;
202
+ runId: string;
203
+ }): Promise<WorkflowRunState | null>;
204
+ getScoreById({ id: _id }: {
205
+ id: string;
206
+ }): Promise<ScoreRowData | null>;
207
+ getScoresByScorerId({ scorerId, pagination, }: {
208
+ scorerId: string;
209
+ pagination: StoragePagination;
210
+ }): Promise<{
211
+ pagination: PaginationInfo;
212
+ scores: ScoreRowData[];
213
+ }>;
214
+ saveScore(_score: ScoreRowData): Promise<{
215
+ score: ScoreRowData;
216
+ }>;
217
+ getScoresByRunId({ runId, pagination, }: {
218
+ runId: string;
219
+ pagination: StoragePagination;
220
+ }): Promise<{
221
+ pagination: PaginationInfo;
222
+ scores: ScoreRowData[];
223
+ }>;
224
+ getScoresByEntityId({ entityId, entityType, pagination, }: {
225
+ pagination: StoragePagination;
226
+ entityId: string;
227
+ entityType: string;
228
+ }): Promise<{
229
+ pagination: PaginationInfo;
230
+ scores: ScoreRowData[];
231
+ }>;
232
+ }
233
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@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xB,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;CAGpE"}
@@ -0,0 +1,41 @@
1
+ import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
+ import type { VectorFilter, OperatorValueMap, LogicalOperatorValueMap, BlacklistedRootOperators } from '@mastra/core/vector/filter';
3
+ type LanceOperatorValueMap = OperatorValueMap & {
4
+ $like: string;
5
+ $notLike: string;
6
+ $contains: string;
7
+ };
8
+ type LanceBlacklisted = BlacklistedRootOperators | '$like' | '$notLike' | '$contains';
9
+ export type LanceVectorFilter = VectorFilter<keyof LanceOperatorValueMap, LanceOperatorValueMap, LogicalOperatorValueMap, LanceBlacklisted>;
10
+ export declare class LanceFilterTranslator extends BaseFilterTranslator<LanceVectorFilter, string> {
11
+ translate(filter: LanceVectorFilter): string;
12
+ private processFilter;
13
+ private processLogicalOperator;
14
+ private processNestedObject;
15
+ private processField;
16
+ private processOperators;
17
+ private formatValue;
18
+ private formatArrayValues;
19
+ normalizeArrayValues(array: unknown[]): unknown[];
20
+ normalizeComparisonValue(value: unknown): unknown;
21
+ private isOperatorObject;
22
+ private isNestedObject;
23
+ private isNormalNestedField;
24
+ private escapeFieldName;
25
+ private isSqlKeyword;
26
+ private isDateObject;
27
+ /**
28
+ * Override getSupportedOperators to add custom operators for LanceDB
29
+ */
30
+ protected getSupportedOperators(): {
31
+ custom: string[];
32
+ logical: import("@mastra/core/vector/filter").LogicalOperator[];
33
+ basic: import("@mastra/core/vector/filter").BasicOperator[];
34
+ numeric: import("@mastra/core/vector/filter").NumericOperator[];
35
+ array: import("@mastra/core/vector/filter").ArrayOperator[];
36
+ element: "$exists"[];
37
+ regex: import("@mastra/core/vector/filter").RegexOperator[];
38
+ };
39
+ }
40
+ export {};
41
+ //# 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,EACV,YAAY,EACZ,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,4BAA4B,CAAC;AAEpC,KAAK,qBAAqB,GAAG,gBAAgB,GAAG;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,gBAAgB,GAAG,wBAAwB,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,CAAC;AAEtF,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAC1C,MAAM,qBAAqB,EAC3B,qBAAqB,EACrB,uBAAuB,EACvB,gBAAgB,CACjB,CAAC;AAEF,qBAAa,qBAAsB,SAAQ,oBAAoB,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACxF,SAAS,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM;IAkB5C,OAAO,CAAC,aAAa;IAoErB,OAAO,CAAC,sBAAsB;IAuC9B,OAAO,CAAC,mBAAmB;IAkC3B,OAAO,CAAC,YAAY;IAqCpB,OAAO,CAAC,gBAAgB;IA6DxB,OAAO,CAAC,WAAW;IAgCnB,OAAO,CAAC,iBAAiB;IAIzB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE;IASjD,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IASjD,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,YAAY;IAwDpB,OAAO,CAAC,YA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