@mastra/lance 0.0.0-error-handler-fix-20251020202607 → 0.0.0-esbuild-bundle-worker-20260807173433

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/CHANGELOG.md +1988 -3
  2. package/LICENSE.md +15 -0
  3. package/README.md +61 -4
  4. package/dist/docs/SKILL.md +27 -0
  5. package/dist/docs/assets/SOURCE_MAP.json +6 -0
  6. package/dist/docs/references/guides-rag-vector-databases.md +669 -0
  7. package/dist/docs/references/reference-storage-lance.md +133 -0
  8. package/dist/docs/references/reference-vectors-lance.md +230 -0
  9. package/dist/index.cjs +2993 -3346
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.js +2986 -3342
  12. package/dist/index.js.map +1 -1
  13. package/dist/storage/db/index.d.ts +72 -0
  14. package/dist/storage/db/index.d.ts.map +1 -0
  15. package/dist/storage/db/utils.d.ts.map +1 -0
  16. package/dist/storage/domains/background-tasks/index.d.ts +19 -0
  17. package/dist/storage/domains/background-tasks/index.d.ts.map +1 -0
  18. package/dist/storage/domains/memory/index.d.ts +25 -47
  19. package/dist/storage/domains/memory/index.d.ts.map +1 -1
  20. package/dist/storage/domains/scores/index.d.ts +28 -27
  21. package/dist/storage/domains/scores/index.d.ts.map +1 -1
  22. package/dist/storage/domains/workflows/index.d.ts +21 -24
  23. package/dist/storage/domains/workflows/index.d.ts.map +1 -1
  24. package/dist/storage/index.d.ts +104 -246
  25. package/dist/storage/index.d.ts.map +1 -1
  26. package/dist/vector/filter.d.ts +5 -5
  27. package/dist/vector/index.d.ts +61 -11
  28. package/dist/vector/index.d.ts.map +1 -1
  29. package/package.json +22 -16
  30. package/dist/storage/domains/legacy-evals/index.d.ts +0 -25
  31. package/dist/storage/domains/legacy-evals/index.d.ts.map +0 -1
  32. package/dist/storage/domains/operations/index.d.ts +0 -40
  33. package/dist/storage/domains/operations/index.d.ts.map +0 -1
  34. package/dist/storage/domains/traces/index.d.ts +0 -34
  35. package/dist/storage/domains/traces/index.d.ts.map +0 -1
  36. package/dist/storage/domains/utils.d.ts.map +0 -1
  37. /package/dist/storage/{domains → db}/utils.d.ts +0 -0
@@ -0,0 +1,133 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # LanceDB storage
4
+
5
+ The LanceDB storage implementation provides a high-performance storage solution using the LanceDB database system, which excels at handling both traditional data storage and vector operations.
6
+
7
+ > **Observability Not Supported:** LanceDB storage **doesn't support the observability domain**. Traces from the `MastraStorageExporter` can't be persisted to LanceDB, and [Studio's](https://mastra.ai/docs/studio/overview) observability features won't work with LanceDB as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse.
8
+
9
+ ## Installation
10
+
11
+ **npm**:
12
+
13
+ ```bash
14
+ npm install @mastra/lance@latest
15
+ ```
16
+
17
+ **pnpm**:
18
+
19
+ ```bash
20
+ pnpm add @mastra/lance@latest
21
+ ```
22
+
23
+ **Yarn**:
24
+
25
+ ```bash
26
+ yarn add @mastra/lance@latest
27
+ ```
28
+
29
+ **Bun**:
30
+
31
+ ```bash
32
+ bun add @mastra/lance@latest
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ### Basic Storage Usage
38
+
39
+ ```typescript
40
+ import { LanceStorage } from '@mastra/lance'
41
+
42
+ // Connect to a local database
43
+ const storage = await LanceStorage.create('my-storage', '/path/to/db')
44
+
45
+ // Connect to a LanceDB cloud database
46
+ const storage = await LanceStorage.create('my-storage', 'db://host:port')
47
+
48
+ // Connect to a cloud database with custom options
49
+ const storage = await LanceStorage.create('my-storage', 's3://bucket/db', {
50
+ storageOptions: { timeout: '60s' },
51
+ })
52
+ ```
53
+
54
+ ## Parameters
55
+
56
+ ### `LanceStorage.create()`
57
+
58
+ **name** (`string`): Name identifier for the storage instance
59
+
60
+ **uri** (`string`): URI to connect to the LanceDB database. Can be a local path, cloud DB URL, or S3 bucket URL
61
+
62
+ **options** (`ConnectionOptions`): Connection options for LanceDB, such as timeout settings, authentication, etc.
63
+
64
+ ## Additional notes
65
+
66
+ ### Schema Management
67
+
68
+ The LanceStorage implementation automatically handles schema creation and updates. It maps Mastra's schema types to Apache Arrow data types, which are used by LanceDB internally:
69
+
70
+ - `text`, `uuid` → Utf8
71
+ - `int`, `integer` → Int32
72
+ - `float` → Float32
73
+ - `jsonb`, `json` → Utf8 (serialized)
74
+ - `binary` → Binary
75
+
76
+ ### Initialization
77
+
78
+ When you pass storage to the Mastra class, `init()` is called automatically before any storage operation:
79
+
80
+ ```typescript
81
+ import { Mastra } from '@mastra/core'
82
+ import { LanceStorage } from '@mastra/lance'
83
+
84
+ const storage = await LanceStorage.create('my-storage', '/path/to/db')
85
+
86
+ const mastra = new Mastra({
87
+ storage, // init() is called automatically
88
+ })
89
+ ```
90
+
91
+ If you're using storage directly without Mastra, you must call `init()` explicitly to create the tables:
92
+
93
+ ```typescript
94
+ import { LanceStorage } from '@mastra/lance'
95
+
96
+ const storage = await LanceStorage.create('my-storage', '/path/to/db')
97
+
98
+ // Required when using storage directly
99
+ await storage.init()
100
+
101
+ // Access domain-specific stores via getStore()
102
+ const memoryStore = await storage.getStore('memory')
103
+ const thread = await memoryStore?.getThreadById({ threadId: '...' })
104
+ ```
105
+
106
+ > **Warning:** If `init()` isn't called, tables won't be created and storage operations will fail silently or throw errors.
107
+
108
+ ### Deployment Options
109
+
110
+ LanceDB storage can be configured for different deployment scenarios:
111
+
112
+ - **Local Development**: Use a local file path for development and testing
113
+ ```text
114
+ /path/to/db
115
+ ```
116
+ - **Cloud Deployment**: Connect to a hosted LanceDB instance
117
+ ```text
118
+ db://host:port
119
+ ```
120
+ - **S3 Storage**: Use Amazon S3 for high-capacity cloud storage
121
+ ```text
122
+ s3://bucket/db
123
+ ```
124
+
125
+ ### Table Management
126
+
127
+ LanceStorage provides methods for managing tables:
128
+
129
+ - Create tables with custom schemas
130
+ - Drop tables
131
+ - Clear tables (delete all records)
132
+ - Load records by key
133
+ - Insert single and batch records
@@ -0,0 +1,230 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Lance vector store
4
+
5
+ The LanceVectorStore class provides vector search using [LanceDB](https://lancedb.github.io/lancedb/), an embedded vector database built on the Lance columnar format. It offers efficient storage and fast similarity search for both local development and production deployments.
6
+
7
+ ## Factory method
8
+
9
+ The LanceVectorStore uses a factory pattern for creation. You should use the static `create()` method rather than the constructor directly.
10
+
11
+ **uri** (`string`): Path to LanceDB database or URI for cloud deployments
12
+
13
+ **options** (`ConnectionOptions`): Additional connection options for LanceDB
14
+
15
+ ## Constructor examples
16
+
17
+ You can create a `LanceVectorStore` instance using the static create method:
18
+
19
+ ```ts
20
+ import { LanceVectorStore } from '@mastra/lance'
21
+
22
+ // Connect to a local database
23
+ const vectorStore = await LanceVectorStore.create('/path/to/db')
24
+
25
+ // Connect to a LanceDB cloud database
26
+ const cloudStore = await LanceVectorStore.create('db://host:port')
27
+
28
+ // Connect to a cloud database with options
29
+ const s3Store = await LanceVectorStore.create('s3://bucket/db', {
30
+ storageOptions: { timeout: '60s' },
31
+ })
32
+ ```
33
+
34
+ ## Methods
35
+
36
+ ### `createIndex()`
37
+
38
+ **tableName** (`string`): Name of the table to create index in
39
+
40
+ **indexName** (`string`): Name of the index (column name) to create
41
+
42
+ **dimension** (`number`): Vector dimension (must match your embedding model)
43
+
44
+ **metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
45
+
46
+ **indexConfig** (`LanceIndexConfig`): Index configuration (Default: `{ type: 'hnsw' }`)
47
+
48
+ #### `LanceIndexConfig`
49
+
50
+ **type** (`'ivfflat' | 'hnsw'`): Index type (Default: `hnsw`)
51
+
52
+ **type.ivfflat** (`ivfflat`): Clusters vectors into lists for approximate search.
53
+
54
+ **type.hnsw** (`hnsw`): Graph-based index offering fast search times and high recall.
55
+
56
+ **numPartitions** (`number`): Number of partitions for IVF indexes (Default: `128`)
57
+
58
+ **numSubVectors** (`number`): Number of sub-vectors for product quantization (Default: `16`)
59
+
60
+ **hnsw** (`HNSWConfig`): HNSW configuration
61
+
62
+ **hnsw\.m** (`number`): Maximum number of connections per node (default: 16)
63
+
64
+ **hnsw\.efConstruction** (`number`): Build-time complexity (default: 100)
65
+
66
+ ### `createTable()`
67
+
68
+ **tableName** (`string`): Name of the table to create
69
+
70
+ **data** (`Record<string, unknown>[] | TableLike`): Initial data for the table
71
+
72
+ **options** (`Partial<CreateTableOptions>`): Additional table creation options
73
+
74
+ ### `upsert()`
75
+
76
+ **tableName** (`string`): Name of the table to upsert vectors into
77
+
78
+ **vectors** (`number[][]`): Array of embedding vectors
79
+
80
+ **metadata** (`Record<string, any>[]`): Metadata for each vector
81
+
82
+ **ids** (`string[]`): Optional vector IDs (auto-generated if not provided)
83
+
84
+ ### `query()`
85
+
86
+ **tableName** (`string`): Name of the table to query
87
+
88
+ **queryVector** (`number[]`): Query vector
89
+
90
+ **topK** (`number`): Number of results to return (Default: `10`)
91
+
92
+ **filter** (`Record<string, any>`): Metadata filters
93
+
94
+ **includeVector** (`boolean`): Whether to include the vector in the result (Default: `false`)
95
+
96
+ **columns** (`string[]`): Specific columns to include in the result (Default: `[]`)
97
+
98
+ **includeAllColumns** (`boolean`): Whether to include all columns in the result (Default: `false`)
99
+
100
+ ### `listTables()`
101
+
102
+ Returns an array of table names as strings.
103
+
104
+ ```typescript
105
+ const tables = await vectorStore.listTables()
106
+ // ['my_vectors', 'embeddings', 'documents']
107
+ ```
108
+
109
+ ### `getTableSchema()`
110
+
111
+ **tableName** (`string`): Name of the table to describe
112
+
113
+ Returns the schema of the specified table.
114
+
115
+ ### `deleteTable()`
116
+
117
+ **tableName** (`string`): Name of the table to delete
118
+
119
+ ### `deleteAllTables()`
120
+
121
+ Deletes all tables in the database.
122
+
123
+ ### `listIndexes()`
124
+
125
+ Returns an array of index names as strings.
126
+
127
+ ### `describeIndex()`
128
+
129
+ **indexName** (`string`): Name of the index to describe
130
+
131
+ Returns information about the index:
132
+
133
+ ```typescript
134
+ interface IndexStats {
135
+ dimension: number
136
+ count: number
137
+ metric: 'cosine' | 'euclidean' | 'dotproduct'
138
+ type: 'ivfflat' | 'hnsw'
139
+ config: {
140
+ m?: number
141
+ efConstruction?: number
142
+ numPartitions?: number
143
+ numSubVectors?: number
144
+ }
145
+ }
146
+ ```
147
+
148
+ ### `deleteIndex()`
149
+
150
+ **indexName** (`string`): Name of the index to delete
151
+
152
+ ### `updateVector()`
153
+
154
+ Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
155
+
156
+ **indexName** (`string`): Name of the index containing the vector
157
+
158
+ **id** (`string`): ID of the vector to update (mutually exclusive with filter)
159
+
160
+ **filter** (`Record<string, any>`): Metadata filter to identify vector(s) to update (mutually exclusive with id)
161
+
162
+ **update** (`{ vector?: number[]; metadata?: Record<string, any>; }`): Object containing the vector and/or metadata to update
163
+
164
+ ### `deleteVector()`
165
+
166
+ **indexName** (`string`): Name of the index containing the vector
167
+
168
+ **id** (`string`): ID of the vector to delete
169
+
170
+ ### `deleteVectors()`
171
+
172
+ Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both.
173
+
174
+ **indexName** (`string`): Name of the index containing the vectors to delete
175
+
176
+ **ids** (`string[]`): Array of vector IDs to delete (mutually exclusive with filter)
177
+
178
+ **filter** (`Record<string, any>`): Metadata filter to identify vectors to delete (mutually exclusive with ids)
179
+
180
+ ### `close()`
181
+
182
+ Closes the database connection.
183
+
184
+ ## Response types
185
+
186
+ Query results are returned in this format:
187
+
188
+ ```typescript
189
+ interface QueryResult {
190
+ id: string
191
+ score: number
192
+ metadata: Record<string, any>
193
+ vector?: number[] // Only included if includeVector is true
194
+ document?: string // Document text if available
195
+ }
196
+ ```
197
+
198
+ ## Error handling
199
+
200
+ The store throws typed errors that can be caught:
201
+
202
+ ```typescript
203
+ try {
204
+ await store.query({
205
+ tableName: 'my_vectors',
206
+ queryVector: queryVector,
207
+ })
208
+ } catch (error) {
209
+ if (error instanceof Error) {
210
+ console.log(error.message)
211
+ }
212
+ }
213
+ ```
214
+
215
+ ## Best practices
216
+
217
+ - Use the appropriate index type for your use case:
218
+
219
+ - HNSW for better recall and performance when memory isn't constrained
220
+ - IVF for better memory efficiency with large datasets
221
+
222
+ - For optimal performance with large datasets, consider adjusting `numPartitions` and `numSubVectors` values
223
+
224
+ - Use `close()` method to properly close connections when done with the database
225
+
226
+ - Store metadata with a consistent schema to simplify filtering operations
227
+
228
+ ## Related
229
+
230
+ - [Metadata Filters](https://mastra.ai/reference/rag/metadata-filters)