@mastra/lance 1.5.2-alpha.1 → 1.6.0-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.
- package/README.md +1 -1
- package/dist/docs/SKILL.md +2 -2
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/{reference-vectors-lance.md → integrations-vectors-lance.md} +1 -1
- package/dist/docs/references/reference-rag-vector-databases.md +3 -3
- package/dist/index.cjs +22 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -9
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +1 -0
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/dist/vector/filter.d.ts.map +1 -1
- package/dist/vector/index.d.ts +1 -1
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ await vectorStore.createIndex({
|
|
|
26
26
|
## Documentation
|
|
27
27
|
|
|
28
28
|
- [LanceDB integration guide](https://mastra.ai/integrations/databases/lancedb)
|
|
29
|
-
- [Lance vector reference](https://mastra.ai/
|
|
29
|
+
- [Lance vector reference](https://mastra.ai/integrations/vectors/lance)
|
|
30
30
|
|
|
31
31
|
## Changelog
|
|
32
32
|
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-lance
|
|
|
3
3
|
description: Documentation for @mastra/lance. Use when working with @mastra/lance APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/lance"
|
|
6
|
-
version: "1.
|
|
6
|
+
version: "1.6.0-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -17,11 +17,11 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
17
17
|
### Integrations
|
|
18
18
|
|
|
19
19
|
- [LanceDB](references/integrations-databases-lancedb.md) - Use LanceDB for Mastra application storage and vector operations, configure tables and initialization, and account for its observability limitations.
|
|
20
|
+
- [Lance](references/integrations-vectors-lance.md) - Store embeddings in LanceDB through Mastra's LanceVectorStore with embedded similarity search for local, S3, and managed cloud deployments.
|
|
20
21
|
|
|
21
22
|
### Reference
|
|
22
23
|
|
|
23
24
|
- [Storing embeddings in a vector database](references/reference-rag-vector-databases.md) - After generating embeddings, you need to store them in a database that supports vector similarity search.
|
|
24
|
-
- [Reference: Lance vector store](references/reference-vectors-lance.md) - The LanceVectorStore class provides vector search using LanceDB, an embedded vector database built on the Lance columnar format.
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
|
|
@@ -12,7 +12,7 @@ The LanceVectorStore uses a factory pattern for creation. You should use the sta
|
|
|
12
12
|
|
|
13
13
|
**uri** (`string`): Path to LanceDB database or URI for cloud deployments
|
|
14
14
|
|
|
15
|
-
**options** (`ConnectionOptions`): Additional connection options for LanceDB
|
|
15
|
+
**options** (`ConnectionOptions & { id?: string }`): Additional connection options for LanceDB. Pass id to name the store; otherwise a random UUID is used.
|
|
16
16
|
|
|
17
17
|
## Constructor examples
|
|
18
18
|
|
|
@@ -35,7 +35,7 @@ MongoDB Vector Search is a good solution for teams who want to consolidate vecto
|
|
|
35
35
|
|
|
36
36
|
### Using VoyageAI with MongoDB
|
|
37
37
|
|
|
38
|
-
MongoDB works directly with VoyageAI's embedding models, which are optimized for retrieval tasks. For complete examples and specialized models, see the [VoyageAI embeddings documentation](https://mastra.ai/models/embeddings) and [MongoDB vector reference](https://mastra.ai/
|
|
38
|
+
MongoDB works directly with VoyageAI's embedding models, which are optimized for retrieval tasks. For complete examples and specialized models, see the [VoyageAI embeddings documentation](https://mastra.ai/models/embeddings) and [MongoDB vector reference](https://mastra.ai/integrations/vectors/mongodb).
|
|
39
39
|
|
|
40
40
|
### Hybrid Search (Vector + Full-Text)
|
|
41
41
|
|
|
@@ -52,7 +52,7 @@ const results = await store.hybridQuery({
|
|
|
52
52
|
})
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
See the [MongoDB vector reference](https://mastra.ai/
|
|
55
|
+
See the [MongoDB vector reference](https://mastra.ai/integrations/vectors/mongodb) for details on `createSearchIndex()`, `textQuery()`, and `hybridQuery()`.
|
|
56
56
|
|
|
57
57
|
### Automated Embedding
|
|
58
58
|
|
|
@@ -75,7 +75,7 @@ const results = await store.query({
|
|
|
75
75
|
})
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
Automated Embedding is a MongoDB Preview feature and needs a deployment where it's available. See the [MongoDB vector reference](https://mastra.ai/
|
|
78
|
+
Automated Embedding is a MongoDB Preview feature and needs a deployment where it's available. See the [MongoDB vector reference](https://mastra.ai/integrations/vectors/mongodb) for the supported options and requirements.
|
|
79
79
|
|
|
80
80
|
**PgVector**:
|
|
81
81
|
|
package/dist/index.cjs
CHANGED
|
@@ -412,7 +412,7 @@ var LanceDB = class extends _mastra_core_base.MastraBase {
|
|
|
412
412
|
const quotedKey = /^[a-z][a-zA-Z]*$/.test(key) && /[A-Z]/.test(key) ? `\`${key}\`` : key;
|
|
413
413
|
if (typeof value === "string") return `${quotedKey} = '${value}'`;
|
|
414
414
|
else if (value === null) return `${quotedKey} IS NULL`;
|
|
415
|
-
|
|
415
|
+
return `${quotedKey} = ${value}`;
|
|
416
416
|
}).join(" AND ");
|
|
417
417
|
this.logger.debug("where clause generated: " + filterConditions);
|
|
418
418
|
query.where(filterConditions);
|
|
@@ -465,7 +465,9 @@ function toRecord(task) {
|
|
|
465
465
|
suspendedAt: task.suspendedAt ?? /* @__PURE__ */ new Date(0),
|
|
466
466
|
completedAt: task.completedAt ?? /* @__PURE__ */ new Date(0),
|
|
467
467
|
ownerId: task.ownerId ?? null,
|
|
468
|
-
leaseExpiresAt: task.leaseExpiresAt ?? null
|
|
468
|
+
leaseExpiresAt: task.leaseExpiresAt ?? null,
|
|
469
|
+
expiresAt: task.expiresAt ?? null,
|
|
470
|
+
metadata: serializeJson(task.metadata) ?? null
|
|
469
471
|
};
|
|
470
472
|
}
|
|
471
473
|
function fromRecord(row) {
|
|
@@ -482,6 +484,7 @@ function fromRecord(row) {
|
|
|
482
484
|
const suspendedAt = row.suspendedAt instanceof Date ? row.suspendedAt : row.suspendedAt ? new Date(row.suspendedAt) : void 0;
|
|
483
485
|
const completedAt = row.completedAt instanceof Date ? row.completedAt : row.completedAt ? new Date(row.completedAt) : void 0;
|
|
484
486
|
const leaseExpiresAt = row.leaseExpiresAt instanceof Date ? row.leaseExpiresAt : row.leaseExpiresAt ? new Date(row.leaseExpiresAt) : void 0;
|
|
487
|
+
const expiresAt = row.expiresAt instanceof Date ? row.expiresAt : row.expiresAt ? new Date(row.expiresAt) : void 0;
|
|
485
488
|
return {
|
|
486
489
|
id: String(row.id),
|
|
487
490
|
status: String(row.status),
|
|
@@ -503,13 +506,16 @@ function fromRecord(row) {
|
|
|
503
506
|
suspendedAt: suspendedAt && suspendedAt.getTime() > 0 ? suspendedAt : void 0,
|
|
504
507
|
completedAt: completedAt && completedAt.getTime() > 0 ? completedAt : void 0,
|
|
505
508
|
ownerId: row.ownerId != null && row.ownerId !== "" ? String(row.ownerId) : void 0,
|
|
506
|
-
leaseExpiresAt
|
|
509
|
+
leaseExpiresAt,
|
|
510
|
+
expiresAt,
|
|
511
|
+
metadata: parseJson(row.metadata)
|
|
507
512
|
};
|
|
508
513
|
}
|
|
509
514
|
function escapeStr(val) {
|
|
510
515
|
return val.replace(/'/g, "''");
|
|
511
516
|
}
|
|
512
517
|
var StoreBackgroundTasksLance = class extends _mastra_core_storage.BackgroundTasksStorage {
|
|
518
|
+
supportsTaskExpiry = true;
|
|
513
519
|
client;
|
|
514
520
|
#db;
|
|
515
521
|
constructor(config) {
|
|
@@ -530,7 +536,9 @@ var StoreBackgroundTasksLance = class extends _mastra_core_storage.BackgroundTas
|
|
|
530
536
|
"suspend_payload",
|
|
531
537
|
"suspendedAt",
|
|
532
538
|
"ownerId",
|
|
533
|
-
"leaseExpiresAt"
|
|
539
|
+
"leaseExpiresAt",
|
|
540
|
+
"expiresAt",
|
|
541
|
+
"metadata"
|
|
534
542
|
]
|
|
535
543
|
});
|
|
536
544
|
}
|
|
@@ -552,11 +560,14 @@ var StoreBackgroundTasksLance = class extends _mastra_core_storage.BackgroundTas
|
|
|
552
560
|
if ("completedAt" in update) values.completedAt = update.completedAt?.getTime() ?? 0;
|
|
553
561
|
if ("ownerId" in update) values.ownerId = update.ownerId ?? null;
|
|
554
562
|
if ("leaseExpiresAt" in update) values.leaseExpiresAt = update.leaseExpiresAt?.getTime() ?? null;
|
|
563
|
+
if ("expiresAt" in update) values.expiresAt = update.expiresAt?.getTime() ?? null;
|
|
564
|
+
if ("metadata" in update) values.metadata = serializeJson(update.metadata) ?? null;
|
|
555
565
|
if (Object.keys(values).length === 0) return false;
|
|
556
566
|
const conditions = [`id = '${escapeStr(taskId)}'`];
|
|
557
567
|
if (options?.expectedStatus) conditions.push(`status = '${escapeStr(options.expectedStatus)}'`);
|
|
558
568
|
if (options?.expectedOwnerId !== void 0) conditions.push(options.expectedOwnerId === null ? "ownerId IS NULL" : `ownerId = '${escapeStr(options.expectedOwnerId)}'`);
|
|
559
569
|
if (options?.expectedLeaseExpiresAt !== void 0) conditions.push(options.expectedLeaseExpiresAt === null ? "leaseExpiresAt IS NULL" : `leaseExpiresAt = ${options.expectedLeaseExpiresAt.getTime()}`);
|
|
570
|
+
if (options?.expectedSuspendedAt !== void 0) conditions.push(options.expectedSuspendedAt === null ? "(suspendedAt IS NULL OR suspendedAt = 0)" : `suspendedAt = ${options.expectedSuspendedAt.getTime()}`);
|
|
560
571
|
return (await (await this.client.openTable(_mastra_core_storage.TABLE_BACKGROUND_TASKS)).update({
|
|
561
572
|
where: conditions.join(" AND "),
|
|
562
573
|
values
|
|
@@ -588,6 +599,7 @@ var StoreBackgroundTasksLance = class extends _mastra_core_storage.BackgroundTas
|
|
|
588
599
|
let query = table.query();
|
|
589
600
|
if (conditions.length > 0) query = query.where(conditions.join(" AND "));
|
|
590
601
|
let tasks = (await query.toArray()).map(fromRecord);
|
|
602
|
+
if (filter.hasExpiresAt !== void 0) tasks = tasks.filter((t) => t.expiresAt != null === filter.hasExpiresAt);
|
|
591
603
|
const dateCol = filter.dateFilterBy ?? "createdAt";
|
|
592
604
|
if (filter.fromDate) tasks = tasks.filter((t) => {
|
|
593
605
|
const val = t[dateCol];
|
|
@@ -1986,13 +1998,13 @@ var LanceFilterTranslator = class extends _mastra_core_vector_filter.BaseFilterT
|
|
|
1986
1998
|
if (keys.length > 1) return keys.map((key) => {
|
|
1987
1999
|
const value = obj[key];
|
|
1988
2000
|
if (this.isNestedObject(value) && !this.isDateObject(value)) return this.processNestedObject(key, value);
|
|
1989
|
-
|
|
2001
|
+
return this.processField(key, value);
|
|
1990
2002
|
}).join(" AND ");
|
|
1991
2003
|
if (keys.length === 1) {
|
|
1992
2004
|
const key = keys[0];
|
|
1993
2005
|
const value = obj[key];
|
|
1994
2006
|
if (this.isNestedObject(value) && !this.isDateObject(value)) return this.processNestedObject(key, value);
|
|
1995
|
-
|
|
2007
|
+
return this.processField(key, value);
|
|
1996
2008
|
}
|
|
1997
2009
|
}
|
|
1998
2010
|
return "";
|
|
@@ -2007,7 +2019,7 @@ var LanceFilterTranslator = class extends _mastra_core_vector_filter.BaseFilterT
|
|
|
2007
2019
|
const keys = Object.keys(condObj);
|
|
2008
2020
|
if (keys.length === 1 && this.isOperator(keys[0])) {
|
|
2009
2021
|
if (this.isLogicalOperator(keys[0])) return `(${this.processLogicalOperator(keys[0], condObj[keys[0]])})`;
|
|
2010
|
-
|
|
2022
|
+
throw new Error(_mastra_core_vector_filter.BaseFilterTranslator.ErrorMessages.UNSUPPORTED_OPERATOR(keys[0]));
|
|
2011
2023
|
}
|
|
2012
2024
|
if (keys.length > 1) return `(${this.processFilter(condition)})`;
|
|
2013
2025
|
return this.processFilter(condition);
|
|
@@ -2022,7 +2034,7 @@ var LanceFilterTranslator = class extends _mastra_core_vector_filter.BaseFilterT
|
|
|
2022
2034
|
return keys.map((key) => {
|
|
2023
2035
|
const nestedPath = key.includes(".") ? `${path}.${key}` : `${path}.${key}`;
|
|
2024
2036
|
if (this.isNestedObject(obj[key]) && !this.isDateObject(obj[key])) return this.processNestedObject(nestedPath, obj[key]);
|
|
2025
|
-
|
|
2037
|
+
return this.processField(nestedPath, obj[key]);
|
|
2026
2038
|
}).join(" AND ");
|
|
2027
2039
|
}
|
|
2028
2040
|
processField(field, value) {
|
|
@@ -2594,7 +2606,8 @@ var LanceVectorStore = class LanceVectorStore extends _mastra_core_vector.Mastra
|
|
|
2594
2606
|
}
|
|
2595
2607
|
this.logger.debug(`Table ${resolvedTableName} created. Index creation deferred until data is available.`);
|
|
2596
2608
|
return;
|
|
2597
|
-
}
|
|
2609
|
+
}
|
|
2610
|
+
table = await this.lanceClient.openTable(resolvedTableName);
|
|
2598
2611
|
const metricType = this.mastraMetricToLance(metric);
|
|
2599
2612
|
const rowCount = await table.countRows();
|
|
2600
2613
|
if (rowCount < 256) {
|