@mastra/lance 0.0.0-error-handler-fix-20251020202607 → 0.0.0-execa-dynamic-import-20260304221256

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