@mastra/duckdb 0.0.0 → 1.0.0-beta.3
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/CHANGELOG.md +60 -0
- package/LICENSE.md +15 -0
- package/dist/docs/README.md +31 -0
- package/dist/docs/SKILL.md +32 -0
- package/dist/docs/SOURCE_MAP.json +6 -0
- package/dist/docs/vectors/01-reference.md +249 -0
- package/package.json +18 -18
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# @mastra/duckdb
|
|
2
|
+
|
|
3
|
+
## 1.0.0-beta.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add embedded documentation support for Mastra packages ([#11472](https://github.com/mastra-ai/mastra/pull/11472))
|
|
8
|
+
|
|
9
|
+
Mastra packages now include embedded documentation in the published npm package under `dist/docs/`. This enables coding agents and AI assistants to understand and use the framework by reading documentation directly from `node_modules`.
|
|
10
|
+
|
|
11
|
+
Each package includes:
|
|
12
|
+
- **SKILL.md** - Entry point explaining the package's purpose and capabilities
|
|
13
|
+
- **SOURCE_MAP.json** - Machine-readable index mapping exports to types and implementation files
|
|
14
|
+
- **Topic folders** - Conceptual documentation organized by feature area
|
|
15
|
+
|
|
16
|
+
Documentation is driven by the `packages` frontmatter field in MDX files, which maps docs to their corresponding packages. CI validation ensures all docs include this field.
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`d2d3e22`](https://github.com/mastra-ai/mastra/commit/d2d3e22a419ee243f8812a84e3453dd44365ecb0), [`bc72b52`](https://github.com/mastra-ai/mastra/commit/bc72b529ee4478fe89ecd85a8be47ce0127b82a0), [`05b8bee`](https://github.com/mastra-ai/mastra/commit/05b8bee9e50e6c2a4a2bf210eca25ee212ca24fa), [`c042bd0`](https://github.com/mastra-ai/mastra/commit/c042bd0b743e0e86199d0cb83344ca7690e34a9c), [`940a2b2`](https://github.com/mastra-ai/mastra/commit/940a2b27480626ed7e74f55806dcd2181c1dd0c2), [`e0941c3`](https://github.com/mastra-ai/mastra/commit/e0941c3d7fc75695d5d258e7008fd5d6e650800c), [`0c0580a`](https://github.com/mastra-ai/mastra/commit/0c0580a42f697cd2a7d5973f25bfe7da9055038a), [`28f5f89`](https://github.com/mastra-ai/mastra/commit/28f5f89705f2409921e3c45178796c0e0d0bbb64), [`e601b27`](https://github.com/mastra-ai/mastra/commit/e601b272c70f3a5ecca610373aa6223012704892), [`3d3366f`](https://github.com/mastra-ai/mastra/commit/3d3366f31683e7137d126a3a57174a222c5801fb), [`5a4953f`](https://github.com/mastra-ai/mastra/commit/5a4953f7d25bb15ca31ed16038092a39cb3f98b3), [`eb9e522`](https://github.com/mastra-ai/mastra/commit/eb9e522ce3070a405e5b949b7bf5609ca51d7fe2), [`20e6f19`](https://github.com/mastra-ai/mastra/commit/20e6f1971d51d3ff6dd7accad8aaaae826d540ed), [`4f0b3c6`](https://github.com/mastra-ai/mastra/commit/4f0b3c66f196c06448487f680ccbb614d281e2f7), [`74c4f22`](https://github.com/mastra-ai/mastra/commit/74c4f22ed4c71e72598eacc346ba95cdbc00294f), [`81b6a8f`](https://github.com/mastra-ai/mastra/commit/81b6a8ff79f49a7549d15d66624ac1a0b8f5f971), [`e4d366a`](https://github.com/mastra-ai/mastra/commit/e4d366aeb500371dd4210d6aa8361a4c21d87034), [`a4f010b`](https://github.com/mastra-ai/mastra/commit/a4f010b22e4355a5fdee70a1fe0f6e4a692cc29e), [`73b0bb3`](https://github.com/mastra-ai/mastra/commit/73b0bb394dba7c9482eb467a97ab283dbc0ef4db), [`5627a8c`](https://github.com/mastra-ai/mastra/commit/5627a8c6dc11fe3711b3fa7a6ffd6eb34100a306), [`3ff45d1`](https://github.com/mastra-ai/mastra/commit/3ff45d10e0c80c5335a957ab563da72feb623520), [`251df45`](https://github.com/mastra-ai/mastra/commit/251df4531407dfa46d805feb40ff3fb49769f455), [`f894d14`](https://github.com/mastra-ai/mastra/commit/f894d148946629af7b1f452d65a9cf864cec3765), [`c2b9547`](https://github.com/mastra-ai/mastra/commit/c2b9547bf435f56339f23625a743b2147ab1c7a6), [`580b592`](https://github.com/mastra-ai/mastra/commit/580b5927afc82fe460dfdf9a38a902511b6b7e7f), [`58e3931`](https://github.com/mastra-ai/mastra/commit/58e3931af9baa5921688566210f00fb0c10479fa), [`08bb631`](https://github.com/mastra-ai/mastra/commit/08bb631ae2b14684b2678e3549d0b399a6f0561e), [`4fba91b`](https://github.com/mastra-ai/mastra/commit/4fba91bec7c95911dc28e369437596b152b04cd0), [`12b0cc4`](https://github.com/mastra-ai/mastra/commit/12b0cc4077d886b1a552637dedb70a7ade93528c)]:
|
|
19
|
+
- @mastra/core@1.0.0-beta.20
|
|
20
|
+
|
|
21
|
+
## 1.0.0-beta.2
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- Add DuckDB vector store implementation ([#10760](https://github.com/mastra-ai/mastra/pull/10760))
|
|
26
|
+
|
|
27
|
+
Adds DuckDB as a vector store provider for Mastra, enabling embedded high-performance vector storage without requiring an external server.
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { DuckDBVector } from '@mastra/duckdb';
|
|
31
|
+
|
|
32
|
+
const vectorStore = new DuckDBVector({
|
|
33
|
+
id: 'my-store',
|
|
34
|
+
path: ':memory:', // or './vectors.duckdb' for persistence
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
await vectorStore.createIndex({
|
|
38
|
+
indexName: 'docs',
|
|
39
|
+
dimension: 1536,
|
|
40
|
+
metric: 'cosine',
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
await vectorStore.upsert({
|
|
44
|
+
indexName: 'docs',
|
|
45
|
+
vectors: [[0.1, 0.2, ...]],
|
|
46
|
+
metadata: [{ text: 'hello world' }],
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const results = await vectorStore.query({
|
|
50
|
+
indexName: 'docs',
|
|
51
|
+
queryVector: [0.1, 0.2, ...],
|
|
52
|
+
topK: 10,
|
|
53
|
+
filter: { text: 'hello world' },
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- Updated dependencies [[`ac0d2f4`](https://github.com/mastra-ai/mastra/commit/ac0d2f4ff8831f72c1c66c2be809706d17f65789), [`1a0d3fc`](https://github.com/mastra-ai/mastra/commit/1a0d3fc811482c9c376cdf79ee615c23bae9b2d6), [`85a628b`](https://github.com/mastra-ai/mastra/commit/85a628b1224a8f64cd82ea7f033774bf22df7a7e), [`c237233`](https://github.com/mastra-ai/mastra/commit/c23723399ccedf7f5744b3f40997b79246bfbe64), [`15f9e21`](https://github.com/mastra-ai/mastra/commit/15f9e216177201ea6e3f6d0bfb063fcc0953444f), [`ff94dea`](https://github.com/mastra-ai/mastra/commit/ff94dea935f4e34545c63bcb6c29804732698809), [`5b2ff46`](https://github.com/mastra-ai/mastra/commit/5b2ff4651df70c146523a7fca773f8eb0a2272f8), [`db41688`](https://github.com/mastra-ai/mastra/commit/db4168806d007417e2e60b4f68656dca4e5f40c9), [`5ca599d`](https://github.com/mastra-ai/mastra/commit/5ca599d0bb59a1595f19f58473fcd67cc71cef58), [`bff1145`](https://github.com/mastra-ai/mastra/commit/bff114556b3cbadad9b2768488708f8ad0e91475), [`5c8ca24`](https://github.com/mastra-ai/mastra/commit/5c8ca247094e0cc2cdbd7137822fb47241f86e77), [`e191844`](https://github.com/mastra-ai/mastra/commit/e1918444ca3f80e82feef1dad506cd4ec6e2875f), [`22553f1`](https://github.com/mastra-ai/mastra/commit/22553f11c63ee5e966a9c034a349822249584691), [`7237163`](https://github.com/mastra-ai/mastra/commit/72371635dbf96a87df4b073cc48fc655afbdce3d), [`2500740`](https://github.com/mastra-ai/mastra/commit/2500740ea23da067d6e50ec71c625ab3ce275e64), [`873ecbb`](https://github.com/mastra-ai/mastra/commit/873ecbb517586aa17d2f1e99283755b3ebb2863f), [`4f9bbe5`](https://github.com/mastra-ai/mastra/commit/4f9bbe5968f42c86f4930b8193de3c3c17e5bd36), [`02e51fe`](https://github.com/mastra-ai/mastra/commit/02e51feddb3d4155cfbcc42624fd0d0970d032c0), [`8f3fa3a`](https://github.com/mastra-ai/mastra/commit/8f3fa3a652bb77da092f913ec51ae46e3a7e27dc), [`cd29ad2`](https://github.com/mastra-ai/mastra/commit/cd29ad23a255534e8191f249593849ed29160886), [`bdf4d8c`](https://github.com/mastra-ai/mastra/commit/bdf4d8cdc656d8a2c21d81834bfa3bfa70f56c16), [`854e3da`](https://github.com/mastra-ai/mastra/commit/854e3dad5daac17a91a20986399d3a51f54bf68b), [`ce18d38`](https://github.com/mastra-ai/mastra/commit/ce18d38678c65870350d123955014a8432075fd9), [`cccf9c8`](https://github.com/mastra-ai/mastra/commit/cccf9c8b2d2dfc1a5e63919395b83d78c89682a0), [`61a5705`](https://github.com/mastra-ai/mastra/commit/61a570551278b6743e64243b3ce7d73de915ca8a), [`db70a48`](https://github.com/mastra-ai/mastra/commit/db70a48aeeeeb8e5f92007e8ede52c364ce15287), [`f0fdc14`](https://github.com/mastra-ai/mastra/commit/f0fdc14ee233d619266b3d2bbdeea7d25cfc6d13), [`db18bc9`](https://github.com/mastra-ai/mastra/commit/db18bc9c3825e2c1a0ad9a183cc9935f6691bfa1), [`9b37b56`](https://github.com/mastra-ai/mastra/commit/9b37b565e1f2a76c24f728945cc740c2b09be9da), [`41a23c3`](https://github.com/mastra-ai/mastra/commit/41a23c32f9877d71810f37e24930515df2ff7a0f), [`5d171ad`](https://github.com/mastra-ai/mastra/commit/5d171ad9ef340387276b77c2bb3e83e83332d729), [`f03ae60`](https://github.com/mastra-ai/mastra/commit/f03ae60500fe350c9d828621006cdafe1975fdd8), [`d1e74a0`](https://github.com/mastra-ai/mastra/commit/d1e74a0a293866dece31022047f5dbab65a304d0), [`39e7869`](https://github.com/mastra-ai/mastra/commit/39e7869bc7d0ee391077ce291474d8a84eedccff), [`5761926`](https://github.com/mastra-ai/mastra/commit/57619260c4a2cdd598763abbacd90de594c6bc76), [`c900fdd`](https://github.com/mastra-ai/mastra/commit/c900fdd504c41348efdffb205cfe80d48c38fa33), [`604a79f`](https://github.com/mastra-ai/mastra/commit/604a79fecf276e26a54a3fe01bb94e65315d2e0e), [`887f0b4`](https://github.com/mastra-ai/mastra/commit/887f0b4746cdbd7cb7d6b17ac9f82aeb58037ea5), [`2562143`](https://github.com/mastra-ai/mastra/commit/256214336b4faa78646c9c1776612393790d8784), [`ef11a61`](https://github.com/mastra-ai/mastra/commit/ef11a61920fa0ed08a5b7ceedd192875af119749)]:
|
|
60
|
+
- @mastra/core@1.0.0-beta.6
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Apache License 2.0
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @mastra/duckdb Documentation
|
|
2
|
+
|
|
3
|
+
> Embedded documentation for coding agents
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Read the skill overview
|
|
9
|
+
cat docs/SKILL.md
|
|
10
|
+
|
|
11
|
+
# Get the source map
|
|
12
|
+
cat docs/SOURCE_MAP.json
|
|
13
|
+
|
|
14
|
+
# Read topic documentation
|
|
15
|
+
cat docs/<topic>/01-overview.md
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Structure
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
docs/
|
|
22
|
+
├── SKILL.md # Entry point
|
|
23
|
+
├── README.md # This file
|
|
24
|
+
├── SOURCE_MAP.json # Export index
|
|
25
|
+
├── vectors/ (1 files)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Version
|
|
29
|
+
|
|
30
|
+
Package: @mastra/duckdb
|
|
31
|
+
Version: 1.0.0-beta.3
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mastra-duckdb-docs
|
|
3
|
+
description: Documentation for @mastra/duckdb. Includes links to type definitions and readable implementation code in dist/.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @mastra/duckdb Documentation
|
|
7
|
+
|
|
8
|
+
> **Version**: 1.0.0-beta.3
|
|
9
|
+
> **Package**: @mastra/duckdb
|
|
10
|
+
|
|
11
|
+
## Quick Navigation
|
|
12
|
+
|
|
13
|
+
Use SOURCE_MAP.json to find any export:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cat docs/SOURCE_MAP.json
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Each export maps to:
|
|
20
|
+
- **types**: `.d.ts` file with JSDoc and API signatures
|
|
21
|
+
- **implementation**: `.js` chunk file with readable source
|
|
22
|
+
- **docs**: Conceptual documentation in `docs/`
|
|
23
|
+
|
|
24
|
+
## Top Exports
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
See SOURCE_MAP.json for the complete list.
|
|
29
|
+
|
|
30
|
+
## Available Topics
|
|
31
|
+
|
|
32
|
+
- [Vectors](vectors/) - 1 file(s)
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# Vectors API Reference
|
|
2
|
+
|
|
3
|
+
> API reference for vectors - 1 entries
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Reference: DuckDBVector Store
|
|
9
|
+
|
|
10
|
+
> Documentation for the DuckDBVector class in Mastra, which provides embedded high-performance vector search using DuckDB with HNSW indexing.
|
|
11
|
+
|
|
12
|
+
The DuckDB storage implementation provides an embedded high-performance vector search solution using [DuckDB](https://duckdb.org/), an in-process analytical database. It uses the VSS extension for vector similarity search with HNSW indexing, offering a lightweight and efficient vector database that requires no external server.
|
|
13
|
+
|
|
14
|
+
It's part of the `@mastra/duckdb` package and offers efficient vector similarity search with metadata filtering.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @mastra/duckdb@beta
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { DuckDBVector } from "@mastra/duckdb";
|
|
26
|
+
|
|
27
|
+
// Create a new vector store instance
|
|
28
|
+
const store = new DuckDBVector({
|
|
29
|
+
id: "duckdb-vector",
|
|
30
|
+
path: ":memory:", // or './vectors.duckdb' for file persistence
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Create an index
|
|
34
|
+
await store.createIndex({
|
|
35
|
+
indexName: "myCollection",
|
|
36
|
+
dimension: 1536,
|
|
37
|
+
metric: "cosine",
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Add vectors with metadata
|
|
41
|
+
const vectors = [[0.1, 0.2, ...], [0.3, 0.4, ...]];
|
|
42
|
+
const metadata = [
|
|
43
|
+
{ text: "first document", category: "A" },
|
|
44
|
+
{ text: "second document", category: "B" },
|
|
45
|
+
];
|
|
46
|
+
await store.upsert({
|
|
47
|
+
indexName: "myCollection",
|
|
48
|
+
vectors,
|
|
49
|
+
metadata,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Query similar vectors
|
|
53
|
+
const queryVector = [0.1, 0.2, ...];
|
|
54
|
+
const results = await store.query({
|
|
55
|
+
indexName: "myCollection",
|
|
56
|
+
queryVector,
|
|
57
|
+
topK: 10,
|
|
58
|
+
filter: { category: "A" },
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Clean up
|
|
62
|
+
await store.close();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Constructor Options
|
|
66
|
+
|
|
67
|
+
## Methods
|
|
68
|
+
|
|
69
|
+
### createIndex()
|
|
70
|
+
|
|
71
|
+
Creates a new vector collection with optional HNSW index for fast approximate nearest neighbor search.
|
|
72
|
+
|
|
73
|
+
### upsert()
|
|
74
|
+
|
|
75
|
+
Adds or updates vectors and their metadata in the index.
|
|
76
|
+
|
|
77
|
+
### query()
|
|
78
|
+
|
|
79
|
+
Searches for similar vectors with optional metadata filtering.
|
|
80
|
+
|
|
81
|
+
### describeIndex()
|
|
82
|
+
|
|
83
|
+
Gets information about an index.
|
|
84
|
+
|
|
85
|
+
Returns:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
interface IndexStats {
|
|
89
|
+
dimension: number;
|
|
90
|
+
count: number;
|
|
91
|
+
metric: "cosine" | "euclidean" | "dotproduct";
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### deleteIndex()
|
|
96
|
+
|
|
97
|
+
Deletes an index and all its data.
|
|
98
|
+
|
|
99
|
+
### listIndexes()
|
|
100
|
+
|
|
101
|
+
Lists all vector indexes in the database.
|
|
102
|
+
|
|
103
|
+
Returns: `Promise<string[]>`
|
|
104
|
+
|
|
105
|
+
### updateVector()
|
|
106
|
+
|
|
107
|
+
Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
|
|
108
|
+
|
|
109
|
+
### deleteVector()
|
|
110
|
+
|
|
111
|
+
Deletes a specific vector entry from an index by its ID.
|
|
112
|
+
|
|
113
|
+
### deleteVectors()
|
|
114
|
+
|
|
115
|
+
Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both.
|
|
116
|
+
|
|
117
|
+
### close()
|
|
118
|
+
|
|
119
|
+
Closes the database connection and releases resources.
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
await store.close();
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Response Types
|
|
126
|
+
|
|
127
|
+
Query results are returned in this format:
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
interface QueryResult {
|
|
131
|
+
id: string;
|
|
132
|
+
score: number;
|
|
133
|
+
metadata: Record<string, any>;
|
|
134
|
+
vector?: number[]; // Only included if includeVector is true
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Filter Operators
|
|
139
|
+
|
|
140
|
+
DuckDB vector store supports MongoDB-like filter operators:
|
|
141
|
+
|
|
142
|
+
| Category | Operators |
|
|
143
|
+
| ---------- | ------------------------------------ |
|
|
144
|
+
| Comparison | `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte` |
|
|
145
|
+
| Logical | `$and`, `$or`, `$not`, `$nor` |
|
|
146
|
+
| Array | `$in`, `$nin` |
|
|
147
|
+
| Element | `$exists` |
|
|
148
|
+
| Text | `$contains` |
|
|
149
|
+
|
|
150
|
+
### Filter Examples
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
// Allegato operators
|
|
154
|
+
const results = await store.query({
|
|
155
|
+
indexName: "docs",
|
|
156
|
+
queryVector: [...],
|
|
157
|
+
filter: {
|
|
158
|
+
$and: [
|
|
159
|
+
{ category: "electronics" },
|
|
160
|
+
{ price: { $gte: 100, $lte: 500 } },
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Nested field access
|
|
166
|
+
const results = await store.query({
|
|
167
|
+
indexName: "docs",
|
|
168
|
+
queryVector: [...],
|
|
169
|
+
filter: { "user.profile.tier": "premium" },
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Distance Metrics
|
|
174
|
+
|
|
175
|
+
| Metric | Description | Score Interpretation | Best For |
|
|
176
|
+
| ------------ | ----------------- | ---------------------------- | ------------------------------------- |
|
|
177
|
+
| `cosine` | Cosine similarity | 0-1 (1 = most similar) | Text embeddings, normalized vectors |
|
|
178
|
+
| `euclidean` | L2 distance | 0-∞ (0 = most similar) | Image embeddings, spatial data |
|
|
179
|
+
| `dotproduct` | Inner product | Higher = more similar | When vector magnitude matters |
|
|
180
|
+
|
|
181
|
+
## Error Handling
|
|
182
|
+
|
|
183
|
+
The store throws specific errors for different failure cases:
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
try {
|
|
187
|
+
await store.query({
|
|
188
|
+
indexName: "my-collection",
|
|
189
|
+
queryVector: queryVector,
|
|
190
|
+
});
|
|
191
|
+
} catch (error) {
|
|
192
|
+
if (error.message.includes("not found")) {
|
|
193
|
+
console.error("The specified index does not exist");
|
|
194
|
+
} else if (error.message.includes("Invalid identifier")) {
|
|
195
|
+
console.error("Index name contains invalid characters");
|
|
196
|
+
} else {
|
|
197
|
+
console.error("Vector store error:", error.message);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Common error cases include:
|
|
203
|
+
|
|
204
|
+
- Invalid index name format
|
|
205
|
+
- Index/table not found
|
|
206
|
+
- Dimension mismatch between query vector and index
|
|
207
|
+
- Empty filter or ids array in delete/update operations
|
|
208
|
+
- Mutual exclusivity violations (providing both `id` and `filter`)
|
|
209
|
+
|
|
210
|
+
## Use Cases
|
|
211
|
+
|
|
212
|
+
### Embedded Semantic Search
|
|
213
|
+
|
|
214
|
+
Build offline-capable AI applications with semantic search that runs entirely in-process:
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
const store = new DuckDBVector({
|
|
218
|
+
id: "offline-search",
|
|
219
|
+
path: "./search.duckdb",
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Local RAG Pipelines
|
|
224
|
+
|
|
225
|
+
Process sensitive documents locally without sending data to cloud vector databases:
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
const store = new DuckDBVector({
|
|
229
|
+
id: "private-rag",
|
|
230
|
+
path: "./confidential.duckdb",
|
|
231
|
+
dimensions: 1536,
|
|
232
|
+
});
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Development and Testing
|
|
236
|
+
|
|
237
|
+
Rapidly prototype vector search features with zero infrastructure:
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
const store = new DuckDBVector({
|
|
241
|
+
id: "dev-store",
|
|
242
|
+
path: ":memory:", // Fast in-memory for tests
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Related
|
|
247
|
+
|
|
248
|
+
- [Metadata Filters](../rag/metadata-filters)
|
|
249
|
+
- [DuckDB Documentation](https://duckdb.org/docs/)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/duckdb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"description": "DuckDB vector store provider for Mastra - embedded high-performance vector storage with HNSW indexing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,31 +18,23 @@
|
|
|
18
18
|
},
|
|
19
19
|
"./package.json": "./package.json"
|
|
20
20
|
},
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "tsup --silent --config tsup.config.ts",
|
|
23
|
-
"build:watch": "tsup --watch --silent --config tsup.config.ts",
|
|
24
|
-
"test": "vitest run",
|
|
25
|
-
"lint": "eslint .",
|
|
26
|
-
"typecheck": "tsc --noEmit"
|
|
27
|
-
},
|
|
28
21
|
"license": "Apache-2.0",
|
|
29
22
|
"dependencies": {
|
|
30
23
|
"@duckdb/node-api": "1.4.2-r.1"
|
|
31
24
|
},
|
|
32
25
|
"devDependencies": {
|
|
33
|
-
"@internal/lint": "workspace:*",
|
|
34
|
-
"@internal/storage-test-utils": "workspace:*",
|
|
35
|
-
"@internal/types-builder": "workspace:*",
|
|
36
|
-
"@mastra/core": "workspace:*",
|
|
37
|
-
"@microsoft/api-extractor": "^7.52.8",
|
|
38
26
|
"@types/node": "22.13.17",
|
|
39
|
-
"@vitest/coverage-v8": "
|
|
40
|
-
"@vitest/ui": "
|
|
27
|
+
"@vitest/coverage-v8": "4.0.12",
|
|
28
|
+
"@vitest/ui": "4.0.12",
|
|
41
29
|
"eslint": "^9.37.0",
|
|
42
30
|
"rimraf": "^5.0.7",
|
|
43
31
|
"tsup": "^8.5.0",
|
|
44
|
-
"typescript": "^5.
|
|
45
|
-
"vitest": "
|
|
32
|
+
"typescript": "^5.9.3",
|
|
33
|
+
"vitest": "4.0.16",
|
|
34
|
+
"@internal/lint": "0.0.53",
|
|
35
|
+
"@internal/storage-test-utils": "0.0.49",
|
|
36
|
+
"@internal/types-builder": "0.0.28",
|
|
37
|
+
"@mastra/core": "1.0.0-beta.20"
|
|
46
38
|
},
|
|
47
39
|
"peerDependencies": {
|
|
48
40
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|
|
@@ -62,5 +54,13 @@
|
|
|
62
54
|
},
|
|
63
55
|
"engines": {
|
|
64
56
|
"node": ">=22.13.0"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build:lib": "tsup --silent --config tsup.config.ts",
|
|
60
|
+
"build:docs": "pnpx tsx ../../scripts/generate-package-docs.ts stores/duckdb",
|
|
61
|
+
"build:watch": "tsup --watch --silent --config tsup.config.ts",
|
|
62
|
+
"test": "vitest run",
|
|
63
|
+
"lint": "eslint .",
|
|
64
|
+
"typecheck": "tsc --noEmit"
|
|
65
65
|
}
|
|
66
|
-
}
|
|
66
|
+
}
|