@mastra/lance 0.0.0-http-transporter-20250702160118 → 0.0.0-interpolate-reporter-url-20250910180021

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 (46) hide show
  1. package/CHANGELOG.md +370 -3
  2. package/LICENSE.md +11 -42
  3. package/README.md +3 -3
  4. package/dist/index.cjs +1932 -848
  5. package/dist/index.cjs.map +1 -0
  6. package/dist/index.d.ts +3 -2
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +1933 -849
  9. package/dist/index.js.map +1 -0
  10. package/dist/storage/domains/legacy-evals/index.d.ts +25 -0
  11. package/dist/storage/domains/legacy-evals/index.d.ts.map +1 -0
  12. package/dist/storage/domains/memory/index.d.ts +103 -0
  13. package/dist/storage/domains/memory/index.d.ts.map +1 -0
  14. package/dist/storage/domains/operations/index.d.ts +40 -0
  15. package/dist/storage/domains/operations/index.d.ts.map +1 -0
  16. package/dist/storage/domains/scores/index.d.ts +42 -0
  17. package/dist/storage/domains/scores/index.d.ts.map +1 -0
  18. package/dist/storage/domains/traces/index.d.ts +34 -0
  19. package/dist/storage/domains/traces/index.d.ts.map +1 -0
  20. package/dist/storage/domains/utils.d.ts +10 -0
  21. package/dist/storage/domains/utils.d.ts.map +1 -0
  22. package/dist/storage/domains/workflows/index.d.ts +56 -0
  23. package/dist/storage/domains/workflows/index.d.ts.map +1 -0
  24. package/dist/storage/index.d.ts +262 -0
  25. package/dist/storage/index.d.ts.map +1 -0
  26. package/dist/vector/filter.d.ts +41 -0
  27. package/dist/vector/filter.d.ts.map +1 -0
  28. package/dist/vector/index.d.ts +85 -0
  29. package/dist/vector/index.d.ts.map +1 -0
  30. package/dist/vector/types.d.ts +15 -0
  31. package/dist/vector/types.d.ts.map +1 -0
  32. package/package.json +24 -10
  33. package/dist/_tsup-dts-rollup.d.cts +0 -409
  34. package/dist/_tsup-dts-rollup.d.ts +0 -409
  35. package/dist/index.d.cts +0 -2
  36. package/eslint.config.js +0 -6
  37. package/src/index.ts +0 -2
  38. package/src/storage/index.test.ts +0 -1336
  39. package/src/storage/index.ts +0 -1447
  40. package/src/vector/filter.test.ts +0 -295
  41. package/src/vector/filter.ts +0 -443
  42. package/src/vector/index.test.ts +0 -1493
  43. package/src/vector/index.ts +0 -941
  44. package/src/vector/types.ts +0 -16
  45. package/tsconfig.json +0 -5
  46. package/vitest.config.ts +0 -11
@@ -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,YAAY;IAIpB;;OAEG;cACgB,qBAAqB;;;;;;;;;CAMzC"}
@@ -0,0 +1,85 @@
1
+ import type { ConnectionOptions, CreateTableOptions, Table, TableLike } from '@lancedb/lancedb';
2
+ import type { CreateIndexParams, DeleteIndexParams, DeleteVectorParams, DescribeIndexParams, IndexStats, QueryResult, QueryVectorParams, UpdateVectorParams, UpsertVectorParams } 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): Promise<LanceVectorStore>;
47
+ /**
48
+ * @internal
49
+ * Private constructor to enforce using the create factory method
50
+ */
51
+ private constructor();
52
+ close(): void;
53
+ query({ tableName, queryVector, filter, includeVector, topK, columns, includeAllColumns, }: LanceQueryVectorParams): Promise<QueryResult[]>;
54
+ private filterTranslator;
55
+ upsert({ tableName, vectors, metadata, ids }: LanceUpsertVectorParams): Promise<string[]>;
56
+ /**
57
+ * Flattens a nested object, creating new keys with underscores for nested properties.
58
+ * Example: { metadata: { text: 'test' } } → { metadata_text: 'test' }
59
+ */
60
+ private flattenObject;
61
+ createTable(tableName: string, data: Record<string, unknown>[] | TableLike, options?: Partial<CreateTableOptions>): Promise<Table>;
62
+ listTables(): Promise<string[]>;
63
+ getTableSchema(tableName: string): Promise<any>;
64
+ /**
65
+ * indexName is actually a column name in a table in lanceDB
66
+ */
67
+ createIndex({ tableName, indexName, dimension, metric, indexConfig, }: LanceCreateIndexParams): Promise<void>;
68
+ listIndexes(): Promise<string[]>;
69
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
70
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
71
+ /**
72
+ * Deletes all tables in the database
73
+ */
74
+ deleteAllTables(): Promise<void>;
75
+ deleteTable(tableName: string): Promise<void>;
76
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
77
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
78
+ /**
79
+ * Converts a flattened object with keys using underscore notation back to a nested object.
80
+ * Example: { name: 'test', details_text: 'test' } → { name: 'test', details: { text: 'test' } }
81
+ */
82
+ private unflattenObject;
83
+ }
84
+ export {};
85
+ //# 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,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;
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/lance",
3
- "version": "0.0.0-http-transporter-20250702160118",
3
+ "version": "0.0.0-interpolate-reporter-url-20250910180021",
4
4
  "description": "Lance provider for Mastra - includes both vector and db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -12,33 +12,47 @@
12
12
  "default": "./dist/index.js"
13
13
  },
14
14
  "require": {
15
- "types": "./dist/index.d.cts",
15
+ "types": "./dist/index.d.ts",
16
16
  "default": "./dist/index.cjs"
17
17
  }
18
18
  },
19
19
  "./package.json": "./package.json"
20
20
  },
21
21
  "dependencies": {
22
- "@lancedb/lancedb": "^0.18.2",
22
+ "@lancedb/lancedb": "^0.21.2",
23
23
  "apache-arrow": "^18.1.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@microsoft/api-extractor": "^7.52.8",
27
27
  "@types/node": "^20.19.0",
28
- "eslint": "^9.29.0",
28
+ "eslint": "^9.30.1",
29
29
  "tsup": "^8.5.0",
30
30
  "typescript": "^5.8.3",
31
31
  "vitest": "^3.2.4",
32
- "@internal/storage-test-utils": "0.0.12",
33
- "@internal/lint": "0.0.0-http-transporter-20250702160118",
34
- "@mastra/core": "0.0.0-http-transporter-20250702160118"
32
+ "@internal/lint": "0.0.0-interpolate-reporter-url-20250910180021",
33
+ "@internal/storage-test-utils": "0.0.34",
34
+ "@mastra/core": "0.0.0-interpolate-reporter-url-20250910180021",
35
+ "@internal/types-builder": "0.0.0-interpolate-reporter-url-20250910180021"
35
36
  },
36
37
  "peerDependencies": {
37
- "@mastra/core": "0.0.0-http-transporter-20250702160118"
38
+ "@mastra/core": "0.0.0-interpolate-reporter-url-20250910180021"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "CHANGELOG.md"
43
+ ],
44
+ "homepage": "https://mastra.ai",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/mastra-ai/mastra.git",
48
+ "directory": "stores/lance"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/mastra-ai/mastra/issues"
38
52
  },
39
53
  "scripts": {
40
- "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
41
- "build:watch": "pnpm build --watch",
54
+ "build": "tsup --silent --config tsup.config.ts",
55
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
42
56
  "test": "vitest run",
43
57
  "test:watch": "vitest watch",
44
58
  "lint": "eslint ."
@@ -1,409 +0,0 @@
1
- import { ArrayOperator } from '@mastra/core/vector/filter';
2
- import { BaseFilterTranslator } from '@mastra/core/vector/filter';
3
- import { BasicOperator } from '@mastra/core/vector/filter';
4
- import type { BlacklistedRootOperators } from '@mastra/core/vector/filter';
5
- import type { ConnectionOptions } from '@lancedb/lancedb';
6
- import type { CreateIndexParams } from '@mastra/core';
7
- import type { CreateTableOptions } from '@lancedb/lancedb';
8
- import type { DeleteIndexParams } from '@mastra/core';
9
- import type { DeleteVectorParams } from '@mastra/core';
10
- import type { DescribeIndexParams } from '@mastra/core';
11
- import type { EvalRow } from '@mastra/core/storage';
12
- import type { IndexStats } from '@mastra/core';
13
- import { LogicalOperator } from '@mastra/core/vector/filter';
14
- import type { LogicalOperatorValueMap } from '@mastra/core/vector/filter';
15
- import type { MastraMessageContentV2 } from '@mastra/core/agent';
16
- import type { MastraMessageV1 } from '@mastra/core/memory';
17
- import type { MastraMessageV2 } from '@mastra/core/memory';
18
- import { MastraStorage } from '@mastra/core/storage';
19
- import { MastraVector } from '@mastra/core/vector';
20
- import { NumericOperator } from '@mastra/core/vector/filter';
21
- import type { OperatorValueMap } from '@mastra/core/vector/filter';
22
- import type { PaginationInfo } from '@mastra/core/storage';
23
- import type { QueryResult } from '@mastra/core';
24
- import type { QueryVectorParams } from '@mastra/core';
25
- import { RegexOperator } from '@mastra/core/vector/filter';
26
- import type { SchemaLike } from '@lancedb/lancedb';
27
- import type { StorageColumn } from '@mastra/core/storage';
28
- import type { StorageGetMessagesArg } from '@mastra/core/storage';
29
- import type { StorageGetTracesArg } from '@mastra/core/storage';
30
- import type { StorageThreadType } from '@mastra/core/memory';
31
- import type { Table } from '@lancedb/lancedb';
32
- import type { TABLE_NAMES } from '@mastra/core/storage';
33
- import type { TableLike } from '@lancedb/lancedb';
34
- import type { Trace } from '@mastra/core/telemetry';
35
- import type { TraceType } from '@mastra/core/memory';
36
- import type { UpdateVectorParams } from '@mastra/core';
37
- import type { UpsertVectorParams } from '@mastra/core';
38
- import type { VectorFilter } from '@mastra/core/vector/filter';
39
- import type { WorkflowRuns } from '@mastra/core/storage';
40
- import type { WorkflowRunState } from '@mastra/core/workflows';
41
-
42
- declare interface HNSWConfig {
43
- m?: number;
44
- efConstruction?: number;
45
- }
46
-
47
- export declare interface IndexConfig {
48
- type?: IndexType;
49
- ivf?: IVFConfig;
50
- hnsw?: HNSWConfig;
51
- }
52
-
53
- export declare type IndexType = 'ivfflat' | 'hnsw';
54
-
55
- declare interface IVFConfig {
56
- lists?: number;
57
- }
58
-
59
- declare type LanceBlacklisted = BlacklistedRootOperators | '$like' | '$notLike' | '$contains';
60
-
61
- declare interface LanceCreateIndexParams extends CreateIndexParams {
62
- indexConfig?: LanceIndexConfig;
63
- tableName?: string;
64
- }
65
-
66
- export declare class LanceFilterTranslator extends BaseFilterTranslator<LanceVectorFilter, string> {
67
- translate(filter: LanceVectorFilter): string;
68
- private processFilter;
69
- private processLogicalOperator;
70
- private processNestedObject;
71
- private processField;
72
- private processOperators;
73
- private formatValue;
74
- private formatArrayValues;
75
- normalizeArrayValues(array: unknown[]): unknown[];
76
- normalizeComparisonValue(value: unknown): unknown;
77
- private isOperatorObject;
78
- private isNestedObject;
79
- private isNormalNestedField;
80
- private escapeFieldName;
81
- private isSqlKeyword;
82
- private isDateObject;
83
- /**
84
- * Override getSupportedOperators to add custom operators for LanceDB
85
- */
86
- protected getSupportedOperators(): {
87
- custom: string[];
88
- logical: LogicalOperator[];
89
- basic: BasicOperator[];
90
- numeric: NumericOperator[];
91
- array: ArrayOperator[];
92
- element: "$exists"[];
93
- regex: RegexOperator[];
94
- };
95
- }
96
-
97
- declare interface LanceIndexConfig extends IndexConfig {
98
- numPartitions?: number;
99
- numSubVectors?: number;
100
- }
101
-
102
- declare type LanceOperatorValueMap = OperatorValueMap & {
103
- $like: string;
104
- $notLike: string;
105
- $contains: string;
106
- };
107
-
108
- declare interface LanceQueryVectorParams extends QueryVectorParams<LanceVectorFilter> {
109
- tableName: string;
110
- columns?: string[];
111
- includeAllColumns?: boolean;
112
- }
113
-
114
- declare class LanceStorage extends MastraStorage {
115
- private lanceClient;
116
- /**
117
- * Creates a new instance of LanceStorage
118
- * @param uri The URI to connect to LanceDB
119
- * @param options connection options
120
- *
121
- * Usage:
122
- *
123
- * Connect to a local database
124
- * ```ts
125
- * const store = await LanceStorage.create('/path/to/db');
126
- * ```
127
- *
128
- * Connect to a LanceDB cloud database
129
- * ```ts
130
- * const store = await LanceStorage.create('db://host:port');
131
- * ```
132
- *
133
- * Connect to a cloud database
134
- * ```ts
135
- * const store = await LanceStorage.create('s3://bucket/db', { storageOptions: { timeout: '60s' } });
136
- * ```
137
- */
138
- static create(name: string, uri: string, options?: ConnectionOptions): Promise<LanceStorage>;
139
- private getPrimaryKeys;
140
- /**
141
- * @internal
142
- * Private constructor to enforce using the create factory method
143
- */
144
- private constructor();
145
- createTable({ tableName, schema, }: {
146
- tableName: TABLE_NAMES;
147
- schema: Record<string, StorageColumn>;
148
- }): Promise<void>;
149
- private translateSchema;
150
- /**
151
- * Drop a table if it exists
152
- * @param tableName Name of the table to drop
153
- */
154
- dropTable(tableName: TABLE_NAMES): Promise<void>;
155
- /**
156
- * Get table schema
157
- * @param tableName Name of the table
158
- * @returns Table schema
159
- */
160
- getTableSchema(tableName: TABLE_NAMES): Promise<SchemaLike>;
161
- protected getDefaultValue(type: StorageColumn['type']): string;
162
- /**
163
- * Alters table schema to add columns if they don't exist
164
- * @param tableName Name of the table
165
- * @param schema Schema of the table
166
- * @param ifNotExists Array of column names to add if they don't exist
167
- */
168
- alterTable({ tableName, schema, ifNotExists, }: {
169
- tableName: string;
170
- schema: Record<string, StorageColumn>;
171
- ifNotExists: string[];
172
- }): Promise<void>;
173
- clearTable({ tableName }: {
174
- tableName: TABLE_NAMES;
175
- }): Promise<void>;
176
- /**
177
- * Insert a single record into a table. This function overwrites the existing record if it exists. Use this function for inserting records into tables with custom schemas.
178
- * @param tableName The name of the table to insert into.
179
- * @param record The record to insert.
180
- */
181
- insert({ tableName, record }: {
182
- tableName: string;
183
- record: Record<string, any>;
184
- }): Promise<void>;
185
- /**
186
- * Insert multiple records into a table. This function overwrites the existing records if they exist. Use this function for inserting records into tables with custom schemas.
187
- * @param tableName The name of the table to insert into.
188
- * @param records The records to insert.
189
- */
190
- batchInsert({ tableName, records }: {
191
- tableName: string;
192
- records: Record<string, any>[];
193
- }): Promise<void>;
194
- /**
195
- * Load a record from the database by its key(s)
196
- * @param tableName The name of the table to query
197
- * @param keys Record of key-value pairs to use for lookup
198
- * @throws Error if invalid types are provided for keys
199
- * @returns The loaded record with proper type conversions, or null if not found
200
- */
201
- load({ tableName, keys }: {
202
- tableName: TABLE_NAMES;
203
- keys: Record<string, any>;
204
- }): Promise<any>;
205
- /**
206
- * Validates that key types match the schema definition
207
- * @param keys The keys to validate
208
- * @param tableSchema The table schema to validate against
209
- * @throws Error if a key has an incompatible type
210
- */
211
- private validateKeyTypes;
212
- /**
213
- * Process a database result with appropriate type conversions based on the table schema
214
- * @param rawResult The raw result object from the database
215
- * @param tableSchema The schema of the table containing type information
216
- * @returns Processed result with correct data types
217
- */
218
- private processResultWithTypeConversion;
219
- getThreadById({ threadId }: {
220
- threadId: string;
221
- }): Promise<StorageThreadType | null>;
222
- getThreadsByResourceId({ resourceId }: {
223
- resourceId: string;
224
- }): Promise<StorageThreadType[]>;
225
- /**
226
- * Saves a thread to the database. This function doesn't overwrite existing threads.
227
- * @param thread - The thread to save
228
- * @returns The saved thread
229
- */
230
- saveThread({ thread }: {
231
- thread: StorageThreadType;
232
- }): Promise<StorageThreadType>;
233
- updateThread({ id, title, metadata, }: {
234
- id: string;
235
- title: string;
236
- metadata: Record<string, unknown>;
237
- }): Promise<StorageThreadType>;
238
- deleteThread({ threadId }: {
239
- threadId: string;
240
- }): Promise<void>;
241
- /**
242
- * Processes messages to include context messages based on withPreviousMessages and withNextMessages
243
- * @param records - The sorted array of records to process
244
- * @param include - The array of include specifications with context parameters
245
- * @returns The processed array with context messages included
246
- */
247
- private processMessagesWithContext;
248
- getMessages(args: StorageGetMessagesArg & {
249
- format?: 'v1';
250
- }): Promise<MastraMessageV1[]>;
251
- getMessages(args: StorageGetMessagesArg & {
252
- format: 'v2';
253
- }): Promise<MastraMessageV2[]>;
254
- saveMessages(args: {
255
- messages: MastraMessageV1[];
256
- format?: undefined | 'v1';
257
- }): Promise<MastraMessageV1[]>;
258
- saveMessages(args: {
259
- messages: MastraMessageV2[];
260
- format: 'v2';
261
- }): Promise<MastraMessageV2[]>;
262
- saveTrace({ trace }: {
263
- trace: TraceType;
264
- }): Promise<TraceType>;
265
- getTraceById({ traceId }: {
266
- traceId: string;
267
- }): Promise<TraceType>;
268
- getTraces({ name, scope, page, perPage, attributes, }: {
269
- name?: string;
270
- scope?: string;
271
- page: number;
272
- perPage: number;
273
- attributes?: Record<string, string>;
274
- }): Promise<TraceType[]>;
275
- saveEvals({ evals }: {
276
- evals: EvalRow[];
277
- }): Promise<EvalRow[]>;
278
- getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
279
- private parseWorkflowRun;
280
- getWorkflowRuns(args?: {
281
- namespace?: string;
282
- workflowName?: string;
283
- fromDate?: Date;
284
- toDate?: Date;
285
- limit?: number;
286
- offset?: number;
287
- }): Promise<WorkflowRuns>;
288
- /**
289
- * Retrieve a single workflow run by its runId.
290
- * @param args The ID of the workflow run to retrieve
291
- * @returns The workflow run object or null if not found
292
- */
293
- getWorkflowRunById(args: {
294
- runId: string;
295
- workflowName?: string;
296
- }): Promise<{
297
- workflowName: string;
298
- runId: string;
299
- snapshot: any;
300
- createdAt: Date;
301
- updatedAt: Date;
302
- } | null>;
303
- persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
304
- workflowName: string;
305
- runId: string;
306
- snapshot: WorkflowRunState;
307
- }): Promise<void>;
308
- loadWorkflowSnapshot({ workflowName, runId, }: {
309
- workflowName: string;
310
- runId: string;
311
- }): Promise<WorkflowRunState | null>;
312
- getTracesPaginated(_args: StorageGetTracesArg): Promise<PaginationInfo & {
313
- traces: Trace[];
314
- }>;
315
- getThreadsByResourceIdPaginated(_args: {
316
- resourceId: string;
317
- page?: number;
318
- perPage?: number;
319
- }): Promise<PaginationInfo & {
320
- threads: StorageThreadType[];
321
- }>;
322
- getMessagesPaginated(_args: StorageGetMessagesArg): Promise<PaginationInfo & {
323
- messages: MastraMessageV1[] | MastraMessageV2[];
324
- }>;
325
- updateMessages(_args: {
326
- messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
327
- id: string;
328
- content?: {
329
- metadata?: MastraMessageContentV2['metadata'];
330
- content?: MastraMessageContentV2['content'];
331
- };
332
- }[];
333
- }): Promise<MastraMessageV2[]>;
334
- }
335
- export { LanceStorage }
336
- export { LanceStorage as LanceStorage_alias_1 }
337
-
338
- declare interface LanceUpsertVectorParams extends UpsertVectorParams {
339
- tableName: string;
340
- }
341
-
342
- export declare type LanceVectorFilter = VectorFilter<keyof LanceOperatorValueMap, LanceOperatorValueMap, LogicalOperatorValueMap, LanceBlacklisted>;
343
-
344
- declare class LanceVectorStore extends MastraVector<LanceVectorFilter> {
345
- private lanceClient;
346
- /**
347
- * Creates a new instance of LanceVectorStore
348
- * @param uri The URI to connect to LanceDB
349
- * @param options connection options
350
- *
351
- * Usage:
352
- *
353
- * Connect to a local database
354
- * ```ts
355
- * const store = await LanceVectorStore.create('/path/to/db');
356
- * ```
357
- *
358
- * Connect to a LanceDB cloud database
359
- * ```ts
360
- * const store = await LanceVectorStore.create('db://host:port');
361
- * ```
362
- *
363
- * Connect to a cloud database
364
- * ```ts
365
- * const store = await LanceVectorStore.create('s3://bucket/db', { storageOptions: { timeout: '60s' } });
366
- * ```
367
- */
368
- static create(uri: string, options?: ConnectionOptions): Promise<LanceVectorStore>;
369
- /**
370
- * @internal
371
- * Private constructor to enforce using the create factory method
372
- */
373
- private constructor();
374
- close(): void;
375
- query({ tableName, queryVector, filter, includeVector, topK, columns, includeAllColumns, }: LanceQueryVectorParams): Promise<QueryResult[]>;
376
- private filterTranslator;
377
- upsert({ tableName, vectors, metadata, ids }: LanceUpsertVectorParams): Promise<string[]>;
378
- /**
379
- * Flattens a nested object, creating new keys with underscores for nested properties.
380
- * Example: { metadata: { text: 'test' } } → { metadata_text: 'test' }
381
- */
382
- private flattenObject;
383
- createTable(tableName: string, data: Record<string, unknown>[] | TableLike, options?: Partial<CreateTableOptions>): Promise<Table>;
384
- listTables(): Promise<string[]>;
385
- getTableSchema(tableName: string): Promise<any>;
386
- /**
387
- * indexName is actually a column name in a table in lanceDB
388
- */
389
- createIndex({ tableName, indexName, dimension, metric, indexConfig, }: LanceCreateIndexParams): Promise<void>;
390
- listIndexes(): Promise<string[]>;
391
- describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
392
- deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
393
- /**
394
- * Deletes all tables in the database
395
- */
396
- deleteAllTables(): Promise<void>;
397
- deleteTable(tableName: string): Promise<void>;
398
- updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
399
- deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
400
- /**
401
- * Converts a flattened object with keys using underscore notation back to a nested object.
402
- * Example: { name: 'test', details_text: 'test' } → { name: 'test', details: { text: 'test' } }
403
- */
404
- private unflattenObject;
405
- }
406
- export { LanceVectorStore }
407
- export { LanceVectorStore as LanceVectorStore_alias_1 }
408
-
409
- export { }