@mastra/lance 0.0.0-share-agent-metadata-with-cloud-20250718123411 → 0.0.0-span-scorring-test-20251124132129

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/CHANGELOG.md +948 -2
  2. package/README.md +64 -7
  3. package/dist/index.cjs +1657 -695
  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 +1658 -696
  8. package/dist/index.js.map +1 -0
  9. package/dist/storage/domains/memory/index.d.ts +79 -0
  10. package/dist/storage/domains/memory/index.d.ts.map +1 -0
  11. package/dist/storage/domains/operations/index.d.ts +40 -0
  12. package/dist/storage/domains/operations/index.d.ts.map +1 -0
  13. package/dist/storage/domains/scores/index.d.ts +50 -0
  14. package/dist/storage/domains/scores/index.d.ts.map +1 -0
  15. package/dist/storage/domains/utils.d.ts +10 -0
  16. package/dist/storage/domains/utils.d.ts.map +1 -0
  17. package/dist/storage/domains/workflows/index.d.ts +50 -0
  18. package/dist/storage/domains/workflows/index.d.ts.map +1 -0
  19. package/dist/storage/index.d.ts +211 -0
  20. package/dist/storage/index.d.ts.map +1 -0
  21. package/dist/vector/filter.d.ts +41 -0
  22. package/dist/vector/filter.d.ts.map +1 -0
  23. package/dist/vector/index.d.ts +88 -0
  24. package/dist/vector/index.d.ts.map +1 -0
  25. package/dist/vector/types.d.ts +15 -0
  26. package/dist/vector/types.d.ts.map +1 -0
  27. package/package.json +31 -12
  28. package/dist/_tsup-dts-rollup.d.cts +0 -409
  29. package/dist/_tsup-dts-rollup.d.ts +0 -409
  30. package/dist/index.d.cts +0 -2
  31. package/eslint.config.js +0 -6
  32. package/src/index.ts +0 -2
  33. package/src/storage/index.test.ts +0 -1336
  34. package/src/storage/index.ts +0 -1447
  35. package/src/vector/filter.test.ts +0 -295
  36. package/src/vector/filter.ts +0 -443
  37. package/src/vector/index.test.ts +0 -1493
  38. package/src/vector/index.ts +0 -941
  39. package/src/vector/types.ts +0 -16
  40. package/tsconfig.json +0 -5
  41. package/vitest.config.ts +0 -11
@@ -0,0 +1,79 @@
1
+ import type { Connection } from '@lancedb/lancedb';
2
+ import type { MastraMessageContentV2 } from '@mastra/core/agent';
3
+ import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
4
+ import { MemoryStorage } from '@mastra/core/storage';
5
+ import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsByResourceIdInput, StorageListThreadsByResourceIdOutput } 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
+ private escapeSql;
15
+ getThreadById({ threadId }: {
16
+ threadId: string;
17
+ }): Promise<StorageThreadType | null>;
18
+ /**
19
+ * Saves a thread to the database. This function doesn't overwrite existing threads.
20
+ * @param thread - The thread to save
21
+ * @returns The saved thread
22
+ */
23
+ saveThread({ thread }: {
24
+ thread: StorageThreadType;
25
+ }): Promise<StorageThreadType>;
26
+ updateThread({ id, title, metadata, }: {
27
+ id: string;
28
+ title: string;
29
+ metadata: Record<string, unknown>;
30
+ }): Promise<StorageThreadType>;
31
+ deleteThread({ threadId }: {
32
+ threadId: string;
33
+ }): Promise<void>;
34
+ private normalizeMessage;
35
+ listMessagesById({ messageIds }: {
36
+ messageIds: string[];
37
+ }): Promise<{
38
+ messages: MastraDBMessage[];
39
+ }>;
40
+ listMessages(args: StorageListMessagesInput): Promise<StorageListMessagesOutput>;
41
+ saveMessages(args: {
42
+ messages: MastraDBMessage[];
43
+ }): Promise<{
44
+ messages: MastraDBMessage[];
45
+ }>;
46
+ listThreadsByResourceId(args: StorageListThreadsByResourceIdInput): Promise<StorageListThreadsByResourceIdOutput>;
47
+ /**
48
+ * Processes messages to include context messages based on withPreviousMessages and withNextMessages
49
+ * @param records - The sorted array of records to process
50
+ * @param include - The array of include specifications with context parameters
51
+ * @returns The processed array with context messages included
52
+ */
53
+ private processMessagesWithContext;
54
+ /**
55
+ * Parse message data from LanceDB record format to MastraDBMessage format
56
+ */
57
+ private parseMessageData;
58
+ updateMessages(args: {
59
+ messages: Partial<Omit<MastraDBMessage, 'createdAt'>> & {
60
+ id: string;
61
+ content?: {
62
+ metadata?: MastraMessageContentV2['metadata'];
63
+ content?: MastraMessageContentV2['content'];
64
+ };
65
+ }[];
66
+ }): Promise<MastraDBMessage[]>;
67
+ getResourceById({ resourceId }: {
68
+ resourceId: string;
69
+ }): Promise<StorageResourceType | null>;
70
+ saveResource({ resource }: {
71
+ resource: StorageResourceType;
72
+ }): Promise<StorageResourceType>;
73
+ updateResource({ resourceId, workingMemory, metadata, }: {
74
+ resourceId: string;
75
+ workingMemory?: string;
76
+ metadata?: Record<string, unknown>;
77
+ }): Promise<StorageResourceType>;
78
+ }
79
+ //# 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,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAmB,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EACL,aAAa,EAMd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,mCAAmC,EACnC,oCAAoC,EACrC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAG1D,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,UAAU,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IACH,OAAO,CAAC,0BAA0B;IAuElC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAoBlB,cAAc,CAAC,IAAI,EAAE;QACzB,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,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;IA+DzG,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,50 @@
1
+ import type { Connection } from '@lancedb/lancedb';
2
+ import type { ScoreRowData, ScoringSource } from '@mastra/core/evals';
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
+ listScoresByScorerId({ scorerId, pagination, entityId, entityType, source, }: {
17
+ scorerId: string;
18
+ pagination: StoragePagination;
19
+ entityId?: string;
20
+ entityType?: string;
21
+ source?: ScoringSource;
22
+ }): Promise<{
23
+ pagination: PaginationInfo;
24
+ scores: ScoreRowData[];
25
+ }>;
26
+ listScoresByRunId({ runId, pagination, }: {
27
+ runId: string;
28
+ pagination: StoragePagination;
29
+ }): Promise<{
30
+ pagination: PaginationInfo;
31
+ scores: ScoreRowData[];
32
+ }>;
33
+ listScoresByEntityId({ entityId, entityType, pagination, }: {
34
+ pagination: StoragePagination;
35
+ entityId: string;
36
+ entityType: string;
37
+ }): Promise<{
38
+ pagination: PaginationInfo;
39
+ scores: ScoreRowData[];
40
+ }>;
41
+ listScoresBySpan({ traceId, spanId, pagination, }: {
42
+ traceId: string;
43
+ spanId: string;
44
+ pagination: StoragePagination;
45
+ }): Promise<{
46
+ pagination: PaginationInfo;
47
+ scores: ScoreRowData[];
48
+ }>;
49
+ }
50
+ //# 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,aAAa,EAA6B,MAAM,oBAAoB,CAAC;AAEjG,OAAO,EAAE,aAAa,EAAwD,MAAM,sBAAsB,CAAC;AAC3G,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAA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AAC,EACrB,OAAO,EACP,MAAM,EACN,UAAU,GACX,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;CAiDpE"}
@@ -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,CAO/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,CAqD7C;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,50 @@
1
+ import type { Connection } from '@lancedb/lancedb';
2
+ import type { StorageListWorkflowRunsInput, WorkflowRuns } from '@mastra/core/storage';
3
+ import { WorkflowsStorage } from '@mastra/core/storage';
4
+ import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
5
+ export declare class StoreWorkflowsLance extends WorkflowsStorage {
6
+ client: Connection;
7
+ constructor({ client }: {
8
+ client: Connection;
9
+ });
10
+ updateWorkflowResults({}: {
11
+ workflowName: string;
12
+ runId: string;
13
+ stepId: string;
14
+ result: StepResult<any, any, any, any>;
15
+ requestContext: Record<string, any>;
16
+ }): Promise<Record<string, StepResult<any, any, any, any>>>;
17
+ updateWorkflowState({}: {
18
+ workflowName: string;
19
+ runId: string;
20
+ opts: {
21
+ status: string;
22
+ result?: StepResult<any, any, any, any>;
23
+ error?: string;
24
+ suspendedPaths?: Record<string, number[]>;
25
+ waitingPaths?: Record<string, number[]>;
26
+ };
27
+ }): Promise<WorkflowRunState | undefined>;
28
+ persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
29
+ workflowName: string;
30
+ runId: string;
31
+ resourceId?: string;
32
+ snapshot: WorkflowRunState;
33
+ }): Promise<void>;
34
+ loadWorkflowSnapshot({ workflowName, runId, }: {
35
+ workflowName: string;
36
+ runId: string;
37
+ }): Promise<WorkflowRunState | null>;
38
+ getWorkflowRunById(args: {
39
+ runId: string;
40
+ workflowName?: string;
41
+ }): Promise<{
42
+ workflowName: string;
43
+ runId: string;
44
+ snapshot: any;
45
+ createdAt: Date;
46
+ updatedAt: Date;
47
+ } | null>;
48
+ listWorkflowRuns(args?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
49
+ }
50
+ //# 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,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAe,4BAA4B,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAyD,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC/G,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAuB3E,qBAAa,mBAAoB,SAAQ,gBAAgB;IACvD,MAAM,EAAE,UAAU,CAAC;gBACP,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,UAAU,CAAA;KAAE;IAK9C,qBAAqB,CACnB,EAMC,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACvC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACrC,GACA,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAG1D,mBAAmB,CACjB,EAIC,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE;YACJ,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;YACxC,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAC1C,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;SACzC,CAAC;KACH,GACA,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAIlC,uBAAuB,CAAC,EAC5B,YAAY,EACZ,KAAK,EACL,UAAU,EACV,QAAQ,GACT,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,gBAAgB,CAAC;KAC5B,GAAG,OAAO,CAAC,IAAI,CAAC;IA4CX,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;IAmB9B,kBAAkB,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAChF,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,GAAG,CAAC;QACd,SAAS,EAAE,IAAI,CAAC;QAChB,SAAS,EAAE,IAAI,CAAC;KACjB,GAAG,IAAI,CAAC;IAyBH,gBAAgB,CAAC,IAAI,CAAC,EAAE,4BAA4B,GAAG,OAAO,CAAC,YAAY,CAAC;CAkFnF"}
@@ -0,0 +1,211 @@
1
+ import type { ConnectionOptions } from '@lancedb/lancedb';
2
+ import type { MastraMessageContentV2 } from '@mastra/core/agent';
3
+ import type { ScoreRowData, ScoringSource } from '@mastra/core/evals';
4
+ import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
5
+ import { MastraStorage } from '@mastra/core/storage';
6
+ import type { TABLE_NAMES, PaginationInfo, StorageColumn, WorkflowRuns, StoragePagination, StorageDomains, StorageResourceType, StorageListWorkflowRunsInput } from '@mastra/core/storage';
7
+ import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
8
+ export declare class LanceStorage extends MastraStorage {
9
+ stores: StorageDomains;
10
+ private lanceClient;
11
+ /**
12
+ * Creates a new instance of LanceStorage
13
+ * @param id The unique identifier for this storage instance
14
+ * @param name The name for this storage instance
15
+ * @param uri The URI to connect to LanceDB
16
+ * @param options connection options
17
+ *
18
+ * Usage:
19
+ *
20
+ * Connect to a local database
21
+ * ```ts
22
+ * const store = await LanceStorage.create('my-storage-id', 'MyStorage', '/path/to/db');
23
+ * ```
24
+ *
25
+ * Connect to a LanceDB cloud database
26
+ * ```ts
27
+ * const store = await LanceStorage.create('my-storage-id', 'MyStorage', 'db://host:port');
28
+ * ```
29
+ *
30
+ * Connect to a cloud database
31
+ * ```ts
32
+ * const store = await LanceStorage.create('my-storage-id', 'MyStorage', 's3://bucket/db', { storageOptions: { timeout: '60s' } });
33
+ * ```
34
+ */
35
+ static create(id: string, name: string, uri: string, options?: ConnectionOptions): Promise<LanceStorage>;
36
+ /**
37
+ * @internal
38
+ * Private constructor to enforce using the create factory method
39
+ */
40
+ private constructor();
41
+ createTable({ tableName, schema, }: {
42
+ tableName: TABLE_NAMES;
43
+ schema: Record<string, StorageColumn>;
44
+ }): Promise<void>;
45
+ dropTable({ tableName }: {
46
+ tableName: TABLE_NAMES;
47
+ }): Promise<void>;
48
+ alterTable({ tableName, schema, ifNotExists, }: {
49
+ tableName: TABLE_NAMES;
50
+ schema: Record<string, StorageColumn>;
51
+ ifNotExists: string[];
52
+ }): Promise<void>;
53
+ clearTable({ tableName }: {
54
+ tableName: TABLE_NAMES;
55
+ }): Promise<void>;
56
+ insert({ tableName, record }: {
57
+ tableName: TABLE_NAMES;
58
+ record: Record<string, any>;
59
+ }): Promise<void>;
60
+ batchInsert({ tableName, records }: {
61
+ tableName: TABLE_NAMES;
62
+ records: Record<string, any>[];
63
+ }): Promise<void>;
64
+ load({ tableName, keys }: {
65
+ tableName: TABLE_NAMES;
66
+ keys: Record<string, any>;
67
+ }): Promise<any>;
68
+ getThreadById({ threadId }: {
69
+ threadId: string;
70
+ }): Promise<StorageThreadType | null>;
71
+ /**
72
+ * Saves a thread to the database. This function doesn't overwrite existing threads.
73
+ * @param thread - The thread to save
74
+ * @returns The saved thread
75
+ */
76
+ saveThread({ thread }: {
77
+ thread: StorageThreadType;
78
+ }): Promise<StorageThreadType>;
79
+ updateThread({ id, title, metadata, }: {
80
+ id: string;
81
+ title: string;
82
+ metadata: Record<string, unknown>;
83
+ }): Promise<StorageThreadType>;
84
+ deleteThread({ threadId }: {
85
+ threadId: string;
86
+ }): Promise<void>;
87
+ get supports(): {
88
+ selectByIncludeResourceScope: boolean;
89
+ resourceWorkingMemory: boolean;
90
+ hasColumn: boolean;
91
+ createTable: boolean;
92
+ deleteMessages: boolean;
93
+ listScoresBySpan: boolean;
94
+ };
95
+ getResourceById({ resourceId }: {
96
+ resourceId: string;
97
+ }): Promise<StorageResourceType | null>;
98
+ saveResource({ resource }: {
99
+ resource: StorageResourceType;
100
+ }): Promise<StorageResourceType>;
101
+ updateResource({ resourceId, workingMemory, metadata, }: {
102
+ resourceId: string;
103
+ workingMemory?: string;
104
+ metadata?: Record<string, unknown>;
105
+ }): Promise<StorageResourceType>;
106
+ /**
107
+ * Processes messages to include context messages based on withPreviousMessages and withNextMessages
108
+ * @param records - The sorted array of records to process
109
+ * @param include - The array of include specifications with context parameters
110
+ * @returns The processed array with context messages included
111
+ */
112
+ private processMessagesWithContext;
113
+ listMessagesById({ messageIds }: {
114
+ messageIds: string[];
115
+ }): Promise<{
116
+ messages: MastraDBMessage[];
117
+ }>;
118
+ saveMessages(args: {
119
+ messages: MastraDBMessage[];
120
+ }): Promise<{
121
+ messages: MastraDBMessage[];
122
+ }>;
123
+ updateMessages(_args: {
124
+ messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
125
+ id: string;
126
+ content?: {
127
+ metadata?: MastraMessageContentV2['metadata'];
128
+ content?: MastraMessageContentV2['content'];
129
+ };
130
+ })[];
131
+ }): Promise<MastraDBMessage[]>;
132
+ listWorkflowRuns(args?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
133
+ getWorkflowRunById(args: {
134
+ runId: string;
135
+ workflowName?: string;
136
+ }): Promise<{
137
+ workflowName: string;
138
+ runId: string;
139
+ snapshot: any;
140
+ createdAt: Date;
141
+ updatedAt: Date;
142
+ } | null>;
143
+ updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, }: {
144
+ workflowName: string;
145
+ runId: string;
146
+ stepId: string;
147
+ result: StepResult<any, any, any, any>;
148
+ requestContext: Record<string, any>;
149
+ }): Promise<Record<string, StepResult<any, any, any, any>>>;
150
+ updateWorkflowState({ workflowName, runId, opts, }: {
151
+ workflowName: string;
152
+ runId: string;
153
+ opts: {
154
+ status: string;
155
+ result?: StepResult<any, any, any, any>;
156
+ error?: string;
157
+ suspendedPaths?: Record<string, number[]>;
158
+ waitingPaths?: Record<string, number[]>;
159
+ };
160
+ }): Promise<WorkflowRunState | undefined>;
161
+ persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
162
+ workflowName: string;
163
+ runId: string;
164
+ resourceId?: string;
165
+ snapshot: WorkflowRunState;
166
+ }): Promise<void>;
167
+ loadWorkflowSnapshot({ workflowName, runId, }: {
168
+ workflowName: string;
169
+ runId: string;
170
+ }): Promise<WorkflowRunState | null>;
171
+ getScoreById({ id: _id }: {
172
+ id: string;
173
+ }): Promise<ScoreRowData | null>;
174
+ listScoresByScorerId({ scorerId, source, entityId, entityType, pagination, }: {
175
+ scorerId: string;
176
+ pagination: StoragePagination;
177
+ source?: ScoringSource;
178
+ entityId?: string;
179
+ entityType?: string;
180
+ }): Promise<{
181
+ pagination: PaginationInfo;
182
+ scores: ScoreRowData[];
183
+ }>;
184
+ saveScore(_score: ScoreRowData): Promise<{
185
+ score: ScoreRowData;
186
+ }>;
187
+ listScoresByRunId({ runId, pagination, }: {
188
+ runId: string;
189
+ pagination: StoragePagination;
190
+ }): Promise<{
191
+ pagination: PaginationInfo;
192
+ scores: ScoreRowData[];
193
+ }>;
194
+ listScoresByEntityId({ entityId, entityType, pagination, }: {
195
+ pagination: StoragePagination;
196
+ entityId: string;
197
+ entityType: string;
198
+ }): Promise<{
199
+ pagination: PaginationInfo;
200
+ scores: ScoreRowData[];
201
+ }>;
202
+ listScoresBySpan({ traceId, spanId, pagination, }: {
203
+ traceId: string;
204
+ spanId: string;
205
+ pagination: StoragePagination;
206
+ }): Promise<{
207
+ pagination: PaginationInfo;
208
+ scores: ScoreRowData[];
209
+ }>;
210
+ }
211
+ //# 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,EAAc,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,4BAA4B,EAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAM3E,qBAAa,YAAa,SAAQ,aAAa;IAC7C,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,CAAC,WAAW,CAAc;IACjC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;WACiB,MAAM,CACx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,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").LogicalOperator[];
33
+ basic: import("@mastra/core/vector").BasicOperator[];
34
+ numeric: import("@mastra/core/vector").NumericOperator[];
35
+ array: import("@mastra/core/vector").ArrayOperator[];
36
+ element: "$exists"[];
37
+ regex: import("@mastra/core/vector").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,YAAY;IAIpB;;OAEG;cACgB,qBAAqB;;;;;;;;;CAMzC"}
@@ -0,0 +1,88 @@
1
+ import type { ConnectionOptions, CreateTableOptions, Table, TableLike } from '@lancedb/lancedb';
2
+ import type { CreateIndexParams, DeleteIndexParams, DeleteVectorParams, DescribeIndexParams, IndexStats, QueryResult, QueryVectorParams, UpdateVectorParams, UpsertVectorParams, DeleteVectorsParams } from '@mastra/core/vector';
3
+ import { MastraVector } from '@mastra/core/vector';
4
+ import type { LanceVectorFilter } from './filter.js';
5
+ import type { IndexConfig } from './types.js';
6
+ interface LanceCreateIndexParams extends CreateIndexParams {
7
+ indexConfig?: LanceIndexConfig;
8
+ tableName?: string;
9
+ }
10
+ interface LanceIndexConfig extends IndexConfig {
11
+ numPartitions?: number;
12
+ numSubVectors?: number;
13
+ }
14
+ interface LanceUpsertVectorParams extends UpsertVectorParams {
15
+ tableName: string;
16
+ }
17
+ interface LanceQueryVectorParams extends QueryVectorParams<LanceVectorFilter> {
18
+ tableName: string;
19
+ columns?: string[];
20
+ includeAllColumns?: boolean;
21
+ }
22
+ export declare class LanceVectorStore extends MastraVector<LanceVectorFilter> {
23
+ private lanceClient;
24
+ /**
25
+ * Creates a new instance of LanceVectorStore
26
+ * @param uri The URI to connect to LanceDB
27
+ * @param options connection options
28
+ *
29
+ * Usage:
30
+ *
31
+ * Connect to a local database
32
+ * ```ts
33
+ * const store = await LanceVectorStore.create('/path/to/db');
34
+ * ```
35
+ *
36
+ * Connect to a LanceDB cloud database
37
+ * ```ts
38
+ * const store = await LanceVectorStore.create('db://host:port');
39
+ * ```
40
+ *
41
+ * Connect to a cloud database
42
+ * ```ts
43
+ * const store = await LanceVectorStore.create('s3://bucket/db', { storageOptions: { timeout: '60s' } });
44
+ * ```
45
+ */
46
+ static create(uri: string, options?: ConnectionOptions & {
47
+ id: string;
48
+ }): Promise<LanceVectorStore>;
49
+ /**
50
+ * @internal
51
+ * Private constructor to enforce using the create factory method
52
+ */
53
+ private constructor();
54
+ close(): void;
55
+ query({ tableName, queryVector, filter, includeVector, topK, columns, includeAllColumns, }: LanceQueryVectorParams): Promise<QueryResult[]>;
56
+ private filterTranslator;
57
+ upsert({ tableName, vectors, metadata, ids }: LanceUpsertVectorParams): Promise<string[]>;
58
+ /**
59
+ * Flattens a nested object, creating new keys with underscores for nested properties.
60
+ * Example: { metadata: { text: 'test' } } → { metadata_text: 'test' }
61
+ */
62
+ private flattenObject;
63
+ createTable(tableName: string, data: Record<string, unknown>[] | TableLike, options?: Partial<CreateTableOptions>): Promise<Table>;
64
+ listTables(): Promise<string[]>;
65
+ getTableSchema(tableName: string): Promise<any>;
66
+ /**
67
+ * indexName is actually a column name in a table in lanceDB
68
+ */
69
+ createIndex({ tableName, indexName, dimension, metric, indexConfig, }: LanceCreateIndexParams): Promise<void>;
70
+ listIndexes(): Promise<string[]>;
71
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
72
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
73
+ /**
74
+ * Deletes all tables in the database
75
+ */
76
+ deleteAllTables(): Promise<void>;
77
+ deleteTable(tableName: string): Promise<void>;
78
+ updateVector(params: UpdateVectorParams<LanceVectorFilter>): Promise<void>;
79
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
80
+ /**
81
+ * Converts a flattened object with keys using underscore notation back to a nested object.
82
+ * Example: { name: 'test', details_text: 'test' } → { name: 'test', details: { text: 'test' } }
83
+ */
84
+ private unflattenObject;
85
+ deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<LanceVectorFilter>): Promise<void>;
86
+ }
87
+ export {};
88
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG5G,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KA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number;
4
+ }
5
+ interface HNSWConfig {
6
+ m?: number;
7
+ efConstruction?: number;
8
+ }
9
+ export interface IndexConfig {
10
+ type?: IndexType;
11
+ ivf?: IVFConfig;
12
+ hnsw?: HNSWConfig;
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/vector/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAE3C,UAAU,SAAS;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,UAAU;IAClB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB"}