@mastra/chroma 1.0.0-beta.1 → 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 +20 -0
- package/dist/index.cjs +47 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +47 -22
- package/dist/index.js.map +1 -1
- package/dist/vector/index.d.ts +5 -1
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @mastra/chroma
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Adding Chroma's advanced Search API (hybrid serch) ([#11046](https://github.com/mastra-ai/mastra/pull/11046))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`38380b6`](https://github.com/mastra-ai/mastra/commit/38380b60fca905824bdf6b43df307a58efb1aa15), [`798d0c7`](https://github.com/mastra-ai/mastra/commit/798d0c740232653b1d754870e6b43a55c364ffe2), [`ffe84d5`](https://github.com/mastra-ai/mastra/commit/ffe84d54f3b0f85167fe977efd027dba027eb998), [`2c212e7`](https://github.com/mastra-ai/mastra/commit/2c212e704c90e2db83d4109e62c03f0f6ebd2667), [`4ca4306`](https://github.com/mastra-ai/mastra/commit/4ca430614daa5fa04730205a302a43bf4accfe9f), [`3bf6c5f`](https://github.com/mastra-ai/mastra/commit/3bf6c5f104c25226cd84e0c77f9dec15f2cac2db)]:
|
|
10
|
+
- @mastra/core@1.0.0-beta.11
|
|
11
|
+
|
|
12
|
+
## 1.0.0-beta.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Standardize error IDs across all storage and vector stores using centralized helper functions (`createStorageErrorId` and `createVectorErrorId`). This ensures consistent error ID patterns (`MASTRA_STORAGE_{STORE}_{OPERATION}_{STATUS}` and `MASTRA_VECTOR_{STORE}_{OPERATION}_{STATUS}`) across the codebase for better error tracking and debugging. ([#10913](https://github.com/mastra-ai/mastra/pull/10913))
|
|
17
|
+
|
|
18
|
+
- update chroma dep ([#10883](https://github.com/mastra-ai/mastra/pull/10883))
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`3076c67`](https://github.com/mastra-ai/mastra/commit/3076c6778b18988ae7d5c4c5c466366974b2d63f), [`85d7ee1`](https://github.com/mastra-ai/mastra/commit/85d7ee18ff4e14d625a8a30ec6656bb49804989b), [`c6c1092`](https://github.com/mastra-ai/mastra/commit/c6c1092f8fbf76109303f69e000e96fd1960c4ce), [`81dc110`](https://github.com/mastra-ai/mastra/commit/81dc11008d147cf5bdc8996ead1aa61dbdebb6fc), [`7aedb74`](https://github.com/mastra-ai/mastra/commit/7aedb74883adf66af38e270e4068fd42e7a37036), [`8f02d80`](https://github.com/mastra-ai/mastra/commit/8f02d800777397e4b45d7f1ad041988a8b0c6630), [`d7aad50`](https://github.com/mastra-ai/mastra/commit/d7aad501ce61646b76b4b511e558ac4eea9884d0), [`ce0a73a`](https://github.com/mastra-ai/mastra/commit/ce0a73abeaa75b10ca38f9e40a255a645d50ebfb), [`a02e542`](https://github.com/mastra-ai/mastra/commit/a02e542d23179bad250b044b17ff023caa61739f), [`a372c64`](https://github.com/mastra-ai/mastra/commit/a372c640ad1fd12e8f0613cebdc682fc156b4d95), [`8846867`](https://github.com/mastra-ai/mastra/commit/8846867ffa9a3746767618e314bebac08eb77d87), [`42a42cf`](https://github.com/mastra-ai/mastra/commit/42a42cf3132b9786feecbb8c13c583dce5b0e198), [`ae08bf0`](https://github.com/mastra-ai/mastra/commit/ae08bf0ebc6a4e4da992b711c4a389c32ba84cf4), [`21735a7`](https://github.com/mastra-ai/mastra/commit/21735a7ef306963554a69a89b44f06c3bcd85141), [`1d877b8`](https://github.com/mastra-ai/mastra/commit/1d877b8d7b536a251c1a7a18db7ddcf4f68d6f8b)]:
|
|
21
|
+
- @mastra/core@1.0.0-beta.7
|
|
22
|
+
|
|
3
23
|
## 1.0.0-beta.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var error = require('@mastra/core/error');
|
|
4
|
+
var storage = require('@mastra/core/storage');
|
|
4
5
|
var vector = require('@mastra/core/vector');
|
|
5
6
|
var chromadb = require('chromadb');
|
|
6
7
|
var filter = require('@mastra/core/vector/filter');
|
|
@@ -125,7 +126,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
125
126
|
return collection;
|
|
126
127
|
} catch {
|
|
127
128
|
throw new error.MastraError({
|
|
128
|
-
id: "
|
|
129
|
+
id: storage.createVectorErrorId("CHROMA", "GET_COLLECTION", "FAILED"),
|
|
129
130
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
130
131
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
131
132
|
details: { indexName }
|
|
@@ -160,7 +161,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
160
161
|
if (error$1 instanceof error.MastraError) throw error$1;
|
|
161
162
|
throw new error.MastraError(
|
|
162
163
|
{
|
|
163
|
-
id: "
|
|
164
|
+
id: storage.createVectorErrorId("CHROMA", "UPSERT", "FAILED"),
|
|
164
165
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
165
166
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
166
167
|
details: { indexName }
|
|
@@ -172,7 +173,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
172
173
|
async createIndex({ indexName, dimension, metric = "cosine" }) {
|
|
173
174
|
if (!Number.isInteger(dimension) || dimension <= 0) {
|
|
174
175
|
throw new error.MastraError({
|
|
175
|
-
id: "
|
|
176
|
+
id: storage.createVectorErrorId("CHROMA", "CREATE_INDEX", "INVALID_DIMENSION"),
|
|
176
177
|
text: "Dimension must be a positive integer",
|
|
177
178
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
178
179
|
category: error.ErrorCategory.USER,
|
|
@@ -182,7 +183,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
182
183
|
const hnswSpace = spaceMappings[metric];
|
|
183
184
|
if (!hnswSpace || !["cosine", "l2", "ip"].includes(hnswSpace)) {
|
|
184
185
|
throw new error.MastraError({
|
|
185
|
-
id: "
|
|
186
|
+
id: storage.createVectorErrorId("CHROMA", "CREATE_INDEX", "INVALID_METRIC"),
|
|
186
187
|
text: `Invalid metric: "${metric}". Must be one of: cosine, euclidean, dotproduct`,
|
|
187
188
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
188
189
|
category: error.ErrorCategory.USER,
|
|
@@ -205,7 +206,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
205
206
|
}
|
|
206
207
|
throw new error.MastraError(
|
|
207
208
|
{
|
|
208
|
-
id: "
|
|
209
|
+
id: storage.createVectorErrorId("CHROMA", "CREATE_INDEX", "FAILED"),
|
|
209
210
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
210
211
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
211
212
|
details: { indexName }
|
|
@@ -249,7 +250,31 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
249
250
|
if (error$1 instanceof error.MastraError) throw error$1;
|
|
250
251
|
throw new error.MastraError(
|
|
251
252
|
{
|
|
252
|
-
id: "
|
|
253
|
+
id: storage.createVectorErrorId("CHROMA", "QUERY", "FAILED"),
|
|
254
|
+
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
255
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
256
|
+
details: { indexName }
|
|
257
|
+
},
|
|
258
|
+
error$1
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
async hybridSearch({ indexName, search }) {
|
|
263
|
+
try {
|
|
264
|
+
const collection = await this.getCollection({ indexName });
|
|
265
|
+
const results = await collection.search(search);
|
|
266
|
+
return (results.rows()[0] ?? []).map((record) => ({
|
|
267
|
+
id: record.id,
|
|
268
|
+
score: record.score ?? 0,
|
|
269
|
+
metadata: record.metadata ?? void 0,
|
|
270
|
+
vector: record.embedding ?? void 0,
|
|
271
|
+
document: record.document ?? void 0
|
|
272
|
+
}));
|
|
273
|
+
} catch (error$1) {
|
|
274
|
+
if (error$1 instanceof error.MastraError) throw error$1;
|
|
275
|
+
throw new error.MastraError(
|
|
276
|
+
{
|
|
277
|
+
id: storage.createVectorErrorId("CHROMA", "SEARCH_API", "FAILED"),
|
|
253
278
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
254
279
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
255
280
|
details: { indexName }
|
|
@@ -284,7 +309,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
284
309
|
if (error$1 instanceof error.MastraError) throw error$1;
|
|
285
310
|
throw new error.MastraError(
|
|
286
311
|
{
|
|
287
|
-
id: "
|
|
312
|
+
id: storage.createVectorErrorId("CHROMA", "GET", "FAILED"),
|
|
288
313
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
289
314
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
290
315
|
details: { indexName }
|
|
@@ -300,7 +325,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
300
325
|
} catch (error$1) {
|
|
301
326
|
throw new error.MastraError(
|
|
302
327
|
{
|
|
303
|
-
id: "
|
|
328
|
+
id: storage.createVectorErrorId("CHROMA", "LIST_INDEXES", "FAILED"),
|
|
304
329
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
305
330
|
category: error.ErrorCategory.THIRD_PARTY
|
|
306
331
|
},
|
|
@@ -329,7 +354,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
329
354
|
if (error$1 instanceof error.MastraError) throw error$1;
|
|
330
355
|
throw new error.MastraError(
|
|
331
356
|
{
|
|
332
|
-
id: "
|
|
357
|
+
id: storage.createVectorErrorId("CHROMA", "DESCRIBE_INDEX", "FAILED"),
|
|
333
358
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
334
359
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
335
360
|
details: { indexName }
|
|
@@ -345,7 +370,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
345
370
|
} catch (error$1) {
|
|
346
371
|
throw new error.MastraError(
|
|
347
372
|
{
|
|
348
|
-
id: "
|
|
373
|
+
id: storage.createVectorErrorId("CHROMA", "DELETE_INDEX", "FAILED"),
|
|
349
374
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
350
375
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
351
376
|
details: { indexName }
|
|
@@ -363,7 +388,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
363
388
|
if (error$1 instanceof error.MastraError) throw error$1;
|
|
364
389
|
throw new error.MastraError(
|
|
365
390
|
{
|
|
366
|
-
id: "
|
|
391
|
+
id: storage.createVectorErrorId("CHROMA", "FORK_INDEX", "FAILED"),
|
|
367
392
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
368
393
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
369
394
|
details: { indexName }
|
|
@@ -386,7 +411,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
386
411
|
async updateVector({ indexName, id, filter, update }) {
|
|
387
412
|
if (id && filter) {
|
|
388
413
|
throw new error.MastraError({
|
|
389
|
-
id: "
|
|
414
|
+
id: storage.createVectorErrorId("CHROMA", "UPDATE_VECTOR", "MUTUALLY_EXCLUSIVE"),
|
|
390
415
|
text: "Cannot specify both id and filter - they are mutually exclusive",
|
|
391
416
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
392
417
|
category: error.ErrorCategory.USER,
|
|
@@ -395,7 +420,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
395
420
|
}
|
|
396
421
|
if (!id && !filter) {
|
|
397
422
|
throw new error.MastraError({
|
|
398
|
-
id: "
|
|
423
|
+
id: storage.createVectorErrorId("CHROMA", "UPDATE_VECTOR", "NO_TARGET"),
|
|
399
424
|
text: "Either id or filter must be provided",
|
|
400
425
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
401
426
|
category: error.ErrorCategory.USER,
|
|
@@ -404,7 +429,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
404
429
|
}
|
|
405
430
|
if (!update.vector && !update.metadata) {
|
|
406
431
|
throw new error.MastraError({
|
|
407
|
-
id: "
|
|
432
|
+
id: storage.createVectorErrorId("CHROMA", "UPDATE_VECTOR", "NO_PAYLOAD"),
|
|
408
433
|
text: "No updates provided",
|
|
409
434
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
410
435
|
category: error.ErrorCategory.USER,
|
|
@@ -416,7 +441,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
416
441
|
}
|
|
417
442
|
if (filter && Object.keys(filter).length === 0) {
|
|
418
443
|
throw new error.MastraError({
|
|
419
|
-
id: "
|
|
444
|
+
id: storage.createVectorErrorId("CHROMA", "UPDATE_VECTOR", "EMPTY_FILTER"),
|
|
420
445
|
text: "Filter cannot be an empty filter object",
|
|
421
446
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
422
447
|
category: error.ErrorCategory.USER,
|
|
@@ -463,7 +488,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
463
488
|
if (error$1 instanceof error.MastraError) throw error$1;
|
|
464
489
|
throw new error.MastraError(
|
|
465
490
|
{
|
|
466
|
-
id: "
|
|
491
|
+
id: storage.createVectorErrorId("CHROMA", "UPDATE_VECTOR", "FAILED"),
|
|
467
492
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
468
493
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
469
494
|
details: {
|
|
@@ -484,7 +509,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
484
509
|
if (error$1 instanceof error.MastraError) throw error$1;
|
|
485
510
|
throw new error.MastraError(
|
|
486
511
|
{
|
|
487
|
-
id: "
|
|
512
|
+
id: storage.createVectorErrorId("CHROMA", "DELETE_VECTOR", "FAILED"),
|
|
488
513
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
489
514
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
490
515
|
details: {
|
|
@@ -507,7 +532,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
507
532
|
async deleteVectors({ indexName, filter, ids }) {
|
|
508
533
|
if (ids && filter) {
|
|
509
534
|
throw new error.MastraError({
|
|
510
|
-
id: "
|
|
535
|
+
id: storage.createVectorErrorId("CHROMA", "DELETE_VECTORS", "MUTUALLY_EXCLUSIVE"),
|
|
511
536
|
text: "Cannot specify both ids and filter - they are mutually exclusive",
|
|
512
537
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
513
538
|
category: error.ErrorCategory.USER,
|
|
@@ -516,7 +541,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
516
541
|
}
|
|
517
542
|
if (!ids && !filter) {
|
|
518
543
|
throw new error.MastraError({
|
|
519
|
-
id: "
|
|
544
|
+
id: storage.createVectorErrorId("CHROMA", "DELETE_VECTORS", "NO_TARGET"),
|
|
520
545
|
text: "Either filter or ids must be provided",
|
|
521
546
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
522
547
|
category: error.ErrorCategory.USER,
|
|
@@ -525,7 +550,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
525
550
|
}
|
|
526
551
|
if (ids && ids.length === 0) {
|
|
527
552
|
throw new error.MastraError({
|
|
528
|
-
id: "
|
|
553
|
+
id: storage.createVectorErrorId("CHROMA", "DELETE_VECTORS", "EMPTY_IDS"),
|
|
529
554
|
text: "Cannot delete with empty ids array",
|
|
530
555
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
531
556
|
category: error.ErrorCategory.USER,
|
|
@@ -534,7 +559,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
534
559
|
}
|
|
535
560
|
if (filter && Object.keys(filter).length === 0) {
|
|
536
561
|
throw new error.MastraError({
|
|
537
|
-
id: "
|
|
562
|
+
id: storage.createVectorErrorId("CHROMA", "DELETE_VECTORS", "EMPTY_FILTER"),
|
|
538
563
|
text: "Cannot delete with empty filter object",
|
|
539
564
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
540
565
|
category: error.ErrorCategory.USER,
|
|
@@ -555,7 +580,7 @@ var ChromaVector = class extends vector.MastraVector {
|
|
|
555
580
|
if (error$1 instanceof error.MastraError) throw error$1;
|
|
556
581
|
throw new error.MastraError(
|
|
557
582
|
{
|
|
558
|
-
id: "
|
|
583
|
+
id: storage.createVectorErrorId("CHROMA", "DELETE_VECTORS", "FAILED"),
|
|
559
584
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
560
585
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
561
586
|
details: {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":["BaseFilterTranslator","MastraVector","CloudClient","ChromaClient","MastraError","ErrorDomain","ErrorCategory","error"],"mappings":";;;;;;;;AA4BO,IAAM,sBAAA,GAAN,cAAqCA,2BAAA,CAAyC;AAAA,EAChE,qBAAA,GAAyC;AAC1D,IAAA,OAAO;AAAA,MACL,GAAGA,2BAAA,CAAqB,iBAAA;AAAA,MACxB,OAAA,EAAS,CAAC,MAAA,EAAQ,KAAK,CAAA;AAAA,MACvB,KAAA,EAAO,CAAC,KAAA,EAAO,MAAM,CAAA;AAAA,MACrB,SAAS,EAAC;AAAA,MACV,OAAO,EAAC;AAAA,MACR,QAAQ;AAAC,KACX;AAAA,EACF;AAAA,EAEA,UAAU,MAAA,EAAiD;AACzD,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,MAAM,CAAA,EAAG,OAAO,MAAA;AACjC,IAAA,IAAA,CAAK,eAAe,MAAM,CAAA;AAE1B,IAAA,OAAO,IAAA,CAAK,cAAc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P,SAAA;AAAA,YACA,GAAI,MAAA,IAAU,EAAE,QAAQ,IAAA,CAAK,SAAA,CAAU,MAAM,CAAA,EAAE;AAAA,YAC/C,GAAI,GAAA,IAAO,EAAE,QAAA,EAAU,IAAI,MAAA;AAAO;AACpC,SACF;AAAA,QACAC;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACF;;;AClkBO,IAAM,aAAA,GAAgB,CAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA","file":"index.cjs","sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n QueryOperator,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype ChromaOperatorValueMap = Omit<OperatorValueMap, '$exists' | '$elemMatch' | '$regex' | '$options'>;\n\ntype ChromaLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not'>;\n\ntype ChromaBlacklisted = BlacklistedRootOperators | '$nor' | '$not';\n\nexport type ChromaVectorFilter = VectorFilter<\n keyof ChromaOperatorValueMap,\n ChromaOperatorValueMap,\n ChromaLogicalOperatorValueMap,\n ChromaBlacklisted\n>;\n\n/**\n * Translator for Chroma filter queries.\n * Maintains MongoDB-compatible syntax while ensuring proper validation\n * and normalization of values.\n */\nexport class ChromaFilterTranslator extends BaseFilterTranslator<ChromaVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or'],\n array: ['$in', '$nin'],\n element: [],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: ChromaVectorFilter): ChromaVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n\n return this.translateNode(filter);\n }\n\n private translateNode(node: ChromaVectorFilter, currentPath: string = ''): any {\n // Handle primitive values and arrays\n if (this.isRegex(node)) {\n throw new Error('Regex is supported in Chroma via the `documentFilter` argument');\n }\n if (this.isPrimitive(node)) return this.normalizeComparisonValue(node);\n if (Array.isArray(node)) return { $in: this.normalizeArrayValues(node) };\n\n const entries = Object.entries(node as Record<string, any>);\n const firstEntry = entries[0];\n // Handle single operator case\n if (entries.length === 1 && firstEntry && this.isOperator(firstEntry[0])) {\n const [operator, value] = firstEntry;\n const translated = this.translateOperator(operator, value);\n if (this.isLogicalOperator(operator) && Array.isArray(translated) && translated.length === 1) {\n return translated[0];\n }\n return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;\n }\n\n // Process each entry\n const result: Record<string, any> = {};\n const multiOperatorConditions: any[] = [];\n\n for (const [key, value] of entries) {\n const newPath = currentPath ? `${currentPath}.${key}` : key;\n\n if (this.isOperator(key)) {\n result[key] = this.translateOperator(key, value);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Check for multiple operators on same field\n const valueEntries = Object.entries(value);\n if (valueEntries.every(([op]) => this.isOperator(op)) && valueEntries.length > 1) {\n valueEntries.forEach(([op, opValue]) => {\n multiOperatorConditions.push({\n [newPath]: { [op]: this.normalizeComparisonValue(opValue) },\n });\n });\n continue;\n }\n\n // Check if the nested object contains operators\n if (Object.keys(value).length === 0) {\n result[newPath] = this.translateNode(value);\n } else {\n const hasOperators = Object.keys(value).some(k => this.isOperator(k));\n if (hasOperators) {\n // For objects with operators, normalize each operator value\n const normalizedValue: Record<string, any> = {};\n for (const [op, opValue] of Object.entries(value)) {\n normalizedValue[op] = this.isOperator(op) ? this.translateOperator(op, opValue) : opValue;\n }\n result[newPath] = normalizedValue;\n } else {\n // For objects without operators, flatten them\n Object.assign(result, this.translateNode(value, newPath));\n }\n }\n } else {\n result[newPath] = this.translateNode(value);\n }\n }\n\n // If we have multiple operators, return them combined with $and\n if (multiOperatorConditions.length > 0) {\n return { $and: multiOperatorConditions };\n }\n\n // Wrap in $and if there are multiple top-level fields\n if (Object.keys(result).length > 1 && !currentPath) {\n return {\n $and: Object.entries(result).map(([key, value]) => ({ [key]: value })),\n };\n }\n\n return result;\n }\n\n private translateOperator(operator: QueryOperator, value: any): any {\n // Handle logical operators\n if (this.isLogicalOperator(operator)) {\n return Array.isArray(value) ? value.map(item => this.translateNode(item)) : this.translateNode(value);\n }\n\n // Handle comparison and element operators\n return this.normalizeComparisonValue(value);\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport { ChromaClient, CloudClient } from 'chromadb';\nimport type { ChromaClientArgs, RecordSet, Where, WhereDocument, Collection, Metadata } from 'chromadb';\nimport type { ChromaVectorFilter } from './filter';\nimport { ChromaFilterTranslator } from './filter';\n\ninterface ChromaUpsertVectorParams extends UpsertVectorParams {\n documents?: string[];\n}\n\ninterface ChromaQueryVectorParams extends QueryVectorParams<ChromaVectorFilter> {\n documentFilter?: WhereDocument | null;\n}\n\ninterface ChromaGetRecordsParams {\n indexName: string;\n ids?: string[];\n filter?: ChromaVectorFilter;\n documentFilter?: WhereDocument | null;\n includeVector?: boolean;\n limit?: number;\n offset?: number;\n}\n\ntype MastraMetadata = {\n dimension?: number;\n};\n\ntype ChromaVectorArgs = ChromaClientArgs & { apiKey?: string };\n\nconst spaceMappings = {\n cosine: 'cosine',\n euclidean: 'l2',\n dotproduct: 'ip',\n l2: 'euclidean',\n ip: 'dotproduct',\n};\n\nexport class ChromaVector extends MastraVector<ChromaVectorFilter> {\n private client: ChromaClient;\n private collections: Map<string, Collection>;\n\n constructor({ id, ...chromaClientArgs }: ChromaVectorArgs & { id: string }) {\n super({ id });\n if (chromaClientArgs?.apiKey) {\n this.client = new CloudClient({\n apiKey: chromaClientArgs.apiKey,\n tenant: chromaClientArgs.tenant,\n database: chromaClientArgs.database,\n });\n } else {\n this.client = new ChromaClient(chromaClientArgs);\n }\n this.collections = new Map();\n }\n\n async getCollection({ indexName, forceUpdate = false }: { indexName: string; forceUpdate?: boolean }) {\n let collection = this.collections.get(indexName);\n if (forceUpdate || !collection) {\n try {\n collection = await this.client.getCollection({ name: indexName });\n this.collections.set(indexName, collection);\n return collection;\n } catch {\n throw new MastraError({\n id: 'CHROMA_COLLECTION_GET_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n });\n }\n }\n return collection;\n }\n\n private validateVectorDimensions(vectors: number[][], dimension: number): void {\n for (let i = 0; i < vectors.length; i++) {\n if (vectors?.[i]?.length !== dimension) {\n throw new Error(\n `Vector at index ${i} has invalid dimension ${vectors?.[i]?.length}. Expected ${dimension} dimensions.`,\n );\n }\n }\n }\n\n async upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]> {\n try {\n const collection = await this.getCollection({ indexName });\n\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions(vectors, stats.dimension);\n const generatedIds = ids || vectors.map(() => crypto.randomUUID());\n\n await collection.upsert({\n ids: generatedIds,\n embeddings: vectors,\n metadatas: metadata,\n documents: documents,\n });\n\n return generatedIds;\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_CREATE_INDEX_INVALID_DIMENSION',\n text: 'Dimension must be a positive integer',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { dimension },\n });\n }\n\n const hnswSpace = spaceMappings[metric] as 'cosine' | 'l2' | 'ip' | undefined;\n\n if (!hnswSpace || !['cosine', 'l2', 'ip'].includes(hnswSpace)) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_CREATE_INDEX_INVALID_METRIC',\n text: `Invalid metric: \"${metric}\". Must be one of: cosine, euclidean, dotproduct`,\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { metric },\n });\n }\n\n try {\n const collection = await this.client.createCollection({\n name: indexName,\n metadata: { dimension },\n configuration: { hnsw: { space: hnswSpace } },\n embeddingFunction: null,\n });\n this.collections.set(indexName, collection);\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.message || error?.toString();\n if (message && message.toLowerCase().includes('already exists')) {\n // Fetch collection info and check dimension\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: ChromaVectorFilter) {\n const translator = new ChromaFilterTranslator();\n const translatedFilter = translator.translate(filter);\n return translatedFilter ? (translatedFilter as Where) : undefined;\n }\n\n async query<T extends Metadata = Metadata>({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n documentFilter,\n }: ChromaQueryVectorParams): Promise<QueryResult[]> {\n try {\n const collection = await this.getCollection({ indexName });\n\n const defaultInclude: ['documents', 'metadatas', 'distances'] = ['documents', 'metadatas', 'distances'];\n\n const translatedFilter = this.transformFilter(filter);\n const results = await collection.query<T>({\n queryEmbeddings: [queryVector],\n nResults: topK,\n where: translatedFilter ?? undefined,\n whereDocument: documentFilter ?? undefined,\n include: includeVector ? [...defaultInclude, 'embeddings'] : defaultInclude,\n });\n\n return (results.ids[0] || []).map((id: string, index: number) => ({\n id,\n score: results.distances?.[0]?.[index] || 0,\n metadata: results.metadatas?.[0]?.[index] || {},\n document: results.documents?.[0]?.[index] ?? undefined,\n ...(includeVector && { vector: results.embeddings?.[0]?.[index] || [] }),\n }));\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async get<T extends Metadata = Metadata>({\n indexName,\n ids,\n filter,\n includeVector = false,\n documentFilter,\n offset,\n limit,\n }: ChromaGetRecordsParams) {\n try {\n const collection = await this.getCollection({ indexName });\n\n const defaultInclude: ['documents', 'metadatas'] = ['documents', 'metadatas'];\n const translatedFilter = this.transformFilter(filter);\n\n const result = await collection.get<T>({\n ids,\n where: translatedFilter ?? undefined,\n whereDocument: documentFilter ?? undefined,\n offset,\n limit,\n include: includeVector ? [...defaultInclude, 'embeddings'] : defaultInclude,\n });\n return result.rows();\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_GET_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const collections = await this.client.listCollections();\n return collections.map(collection => collection.name);\n } catch (error: any) {\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const collection = await this.getCollection({ indexName });\n const count = await collection.count();\n const metadata = collection.metadata as MastraMetadata | undefined;\n const space = collection.configuration.hnsw?.space || collection.configuration.spann?.space || undefined;\n\n return {\n dimension: metadata?.dimension || 0,\n count,\n metric: space ? (spaceMappings[space] as 'cosine' | 'euclidean' | 'dotproduct') : undefined,\n };\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteCollection({ name: indexName });\n this.collections.delete(indexName);\n } catch (error: any) {\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async forkIndex({ indexName, newIndexName }: { indexName: string; newIndexName: string }): Promise<void> {\n try {\n const collection = await this.getCollection({ indexName, forceUpdate: true });\n const forkedCollection = await collection.fork({ name: newIndexName });\n this.collections.set(newIndexName, forkedCollection);\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_INDEX_FORK_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID or multiple vectors matching a filter.\n * @param indexName - The name of the index containing the vector(s).\n * @param id - The ID of the vector to update (mutually exclusive with filter).\n * @param filter - Filter to match multiple vectors to update (mutually exclusive with id).\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, filter, update }: UpdateVectorParams<ChromaVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (id && filter) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_UPDATE_MUTUALLY_EXCLUSIVE',\n text: 'Cannot specify both id and filter - they are mutually exclusive',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!id && !filter) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_UPDATE_NO_TARGET',\n text: 'Either id or filter must be provided',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_UPDATE_NO_PAYLOAD',\n text: 'No updates provided',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: {\n indexName,\n ...(id && { id }),\n },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_UPDATE_EMPTY_FILTER',\n text: 'Filter cannot be an empty filter object',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n const collection: Collection = await this.getCollection({ indexName });\n\n // Validate vector dimensions if provided\n if (update?.vector) {\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions([update.vector], stats.dimension);\n }\n\n if (id) {\n // Update single vector by ID\n const updateRecordSet: RecordSet = { ids: [id] };\n\n if (update?.vector) {\n updateRecordSet.embeddings = [update.vector];\n }\n\n if (update?.metadata) {\n updateRecordSet.metadatas = [update.metadata];\n }\n\n return await collection.update(updateRecordSet);\n } else if (filter) {\n // Update multiple vectors matching filter\n // First, get all vectors matching the filter\n const translatedFilter = this.transformFilter(filter);\n const matchingVectors = await collection.get({\n where: translatedFilter ?? undefined,\n include: ['embeddings', 'metadatas'],\n });\n\n const vectorRows = matchingVectors.rows();\n if (vectorRows.length === 0) {\n // No vectors to update - this is not an error\n return;\n }\n\n // Prepare update for all matching vectors\n const updateRecordSet: RecordSet = {\n ids: vectorRows.map(row => row.id),\n };\n\n if (update?.vector) {\n // Use the same new vector for all matching records\n updateRecordSet.embeddings = vectorRows.map(() => update.vector!);\n }\n\n if (update?.metadata) {\n // Use the same new metadata for all matching records\n updateRecordSet.metadatas = vectorRows.map(() => update.metadata!);\n }\n\n return await collection.update(updateRecordSet);\n }\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_UPDATE_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n ...(filter && { filter: JSON.stringify(filter) }),\n },\n },\n error,\n );\n }\n }\n\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n const collection: Collection = await this.getCollection({ indexName });\n await collection.delete({ ids: [id] });\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DELETE_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes multiple vectors by IDs or filter.\n * @param indexName - The name of the index containing the vectors.\n * @param ids - Array of vector IDs to delete (mutually exclusive with filter).\n * @param filter - Filter to match vectors to delete (mutually exclusive with ids).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if both ids and filter are provided, or if neither is provided.\n */\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<ChromaVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (ids && filter) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_DELETE_VECTORS_MUTUALLY_EXCLUSIVE',\n text: 'Cannot specify both ids and filter - they are mutually exclusive',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!ids && !filter) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_DELETE_VECTORS_NO_TARGET',\n text: 'Either filter or ids must be provided',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate ids array is not empty\n if (ids && ids.length === 0) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_DELETE_VECTORS_EMPTY_IDS',\n text: 'Cannot delete with empty ids array',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_DELETE_VECTORS_EMPTY_FILTER',\n text: 'Cannot delete with empty filter object',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n const collection: Collection = await this.getCollection({ indexName });\n\n if (ids) {\n // Delete by IDs\n await collection.delete({ ids });\n } else if (filter) {\n // Delete by filter\n const translatedFilter = this.transformFilter(filter);\n await collection.delete({\n where: translatedFilter ?? undefined,\n });\n }\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DELETE_VECTORS_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(filter && { filter: JSON.stringify(filter) }),\n ...(ids && { idsCount: ids.length }),\n },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Chroma Vector.\n */\nexport const CHROMA_PROMPT = `When querying Chroma, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nRestrictions:\n- Regex patterns are not supported\n- Element operators are not supported\n- Only $and and $or logical operators are supported\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Empty arrays in $in/$nin will return no results\n- If multiple top-level fields exist, they're wrapped in $and\n- Only logical operators ($and, $or) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$in\": [...] }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"$or\": [\n { \"inStock\": true },\n { \"preorder\": true }\n ]}\n ]\n}`;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":["BaseFilterTranslator","MastraVector","CloudClient","ChromaClient","MastraError","createVectorErrorId","ErrorDomain","ErrorCategory","error"],"mappings":";;;;;;;;;AA4BO,IAAM,sBAAA,GAAN,cAAqCA,2BAAA,CAAyC;AAAA,EAChE,qBAAA,GAAyC;AAC1D,IAAA,OAAO;AAAA,MACL,GAAGA,2BAAA,CAAqB,iBAAA;AAAA,MACxB,OAAA,EAAS,CAAC,MAAA,EAAQ,KAAK,CAAA;AAAA,MACvB,KAAA,EAAO,CAAC,KAAA,EAAO,MAAM,CAAA;AAAA,MACrB,SAAS,EAAC;AAAA,MACV,OAAO,EAAC;AAAA,MACR,QAAQ;AAAC,KACX;AAAA,EACF;AAAA,EAEA,UAAU,MAAA,EAAiD;AACzD,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,MAAM,CAAA,EAAG,OAAO,MAAA;AACjC,IAAA,IAAA,CAAK,eAAe,MAAM,CAAA;AAE1B,IAAA,OAAO,IAAA,CAAK,cAAc,MAAM,CAAA;AAAA,EAClC;AAAA,EAEQ,aAAA,CAAc,IAAA,EAA0B,WAAA,GAAsB,EAAA,EAAS;AAE7E,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,IAAI,CA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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA","file":"index.cjs","sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n QueryOperator,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype ChromaOperatorValueMap = Omit<OperatorValueMap, '$exists' | '$elemMatch' | '$regex' | '$options'>;\n\ntype ChromaLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not'>;\n\ntype ChromaBlacklisted = BlacklistedRootOperators | '$nor' | '$not';\n\nexport type ChromaVectorFilter = VectorFilter<\n keyof ChromaOperatorValueMap,\n ChromaOperatorValueMap,\n ChromaLogicalOperatorValueMap,\n ChromaBlacklisted\n>;\n\n/**\n * Translator for Chroma filter queries.\n * Maintains MongoDB-compatible syntax while ensuring proper validation\n * and normalization of values.\n */\nexport class ChromaFilterTranslator extends BaseFilterTranslator<ChromaVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or'],\n array: ['$in', '$nin'],\n element: [],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: ChromaVectorFilter): ChromaVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n\n return this.translateNode(filter);\n }\n\n private translateNode(node: ChromaVectorFilter, currentPath: string = ''): any {\n // Handle primitive values and arrays\n if (this.isRegex(node)) {\n throw new Error('Regex is supported in Chroma via the `documentFilter` argument');\n }\n if (this.isPrimitive(node)) return this.normalizeComparisonValue(node);\n if (Array.isArray(node)) return { $in: this.normalizeArrayValues(node) };\n\n const entries = Object.entries(node as Record<string, any>);\n const firstEntry = entries[0];\n // Handle single operator case\n if (entries.length === 1 && firstEntry && this.isOperator(firstEntry[0])) {\n const [operator, value] = firstEntry;\n const translated = this.translateOperator(operator, value);\n if (this.isLogicalOperator(operator) && Array.isArray(translated) && translated.length === 1) {\n return translated[0];\n }\n return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;\n }\n\n // Process each entry\n const result: Record<string, any> = {};\n const multiOperatorConditions: any[] = [];\n\n for (const [key, value] of entries) {\n const newPath = currentPath ? `${currentPath}.${key}` : key;\n\n if (this.isOperator(key)) {\n result[key] = this.translateOperator(key, value);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Check for multiple operators on same field\n const valueEntries = Object.entries(value);\n if (valueEntries.every(([op]) => this.isOperator(op)) && valueEntries.length > 1) {\n valueEntries.forEach(([op, opValue]) => {\n multiOperatorConditions.push({\n [newPath]: { [op]: this.normalizeComparisonValue(opValue) },\n });\n });\n continue;\n }\n\n // Check if the nested object contains operators\n if (Object.keys(value).length === 0) {\n result[newPath] = this.translateNode(value);\n } else {\n const hasOperators = Object.keys(value).some(k => this.isOperator(k));\n if (hasOperators) {\n // For objects with operators, normalize each operator value\n const normalizedValue: Record<string, any> = {};\n for (const [op, opValue] of Object.entries(value)) {\n normalizedValue[op] = this.isOperator(op) ? this.translateOperator(op, opValue) : opValue;\n }\n result[newPath] = normalizedValue;\n } else {\n // For objects without operators, flatten them\n Object.assign(result, this.translateNode(value, newPath));\n }\n }\n } else {\n result[newPath] = this.translateNode(value);\n }\n }\n\n // If we have multiple operators, return them combined with $and\n if (multiOperatorConditions.length > 0) {\n return { $and: multiOperatorConditions };\n }\n\n // Wrap in $and if there are multiple top-level fields\n if (Object.keys(result).length > 1 && !currentPath) {\n return {\n $and: Object.entries(result).map(([key, value]) => ({ [key]: value })),\n };\n }\n\n return result;\n }\n\n private translateOperator(operator: QueryOperator, value: any): any {\n // Handle logical operators\n if (this.isLogicalOperator(operator)) {\n return Array.isArray(value) ? value.map(item => this.translateNode(item)) : this.translateNode(value);\n }\n\n // Handle comparison and element operators\n return this.normalizeComparisonValue(value);\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport { ChromaClient, CloudClient } from 'chromadb';\nimport type { ChromaClientArgs, RecordSet, Where, WhereDocument, Collection, Metadata, Search } from 'chromadb';\nimport type { ChromaVectorFilter } from './filter';\nimport { ChromaFilterTranslator } from './filter';\n\ninterface ChromaUpsertVectorParams extends UpsertVectorParams {\n documents?: string[];\n}\n\ninterface ChromaQueryVectorParams extends QueryVectorParams<ChromaVectorFilter> {\n documentFilter?: WhereDocument | null;\n}\n\ninterface ChromaGetRecordsParams {\n indexName: string;\n ids?: string[];\n filter?: ChromaVectorFilter;\n documentFilter?: WhereDocument | null;\n includeVector?: boolean;\n limit?: number;\n offset?: number;\n}\n\ntype MastraMetadata = {\n dimension?: number;\n};\n\ntype ChromaVectorArgs = ChromaClientArgs & { apiKey?: string };\n\nconst spaceMappings = {\n cosine: 'cosine',\n euclidean: 'l2',\n dotproduct: 'ip',\n l2: 'euclidean',\n ip: 'dotproduct',\n};\n\nexport class ChromaVector extends MastraVector<ChromaVectorFilter> {\n private client: ChromaClient;\n private collections: Map<string, Collection>;\n\n constructor({ id, ...chromaClientArgs }: ChromaVectorArgs & { id: string }) {\n super({ id });\n if (chromaClientArgs?.apiKey) {\n this.client = new CloudClient({\n apiKey: chromaClientArgs.apiKey,\n tenant: chromaClientArgs.tenant,\n database: chromaClientArgs.database,\n });\n } else {\n this.client = new ChromaClient(chromaClientArgs);\n }\n this.collections = new Map();\n }\n\n async getCollection({ indexName, forceUpdate = false }: { indexName: string; forceUpdate?: boolean }) {\n let collection = this.collections.get(indexName);\n if (forceUpdate || !collection) {\n try {\n collection = await this.client.getCollection({ name: indexName });\n this.collections.set(indexName, collection);\n return collection;\n } catch {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'GET_COLLECTION', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n });\n }\n }\n return collection;\n }\n\n private validateVectorDimensions(vectors: number[][], dimension: number): void {\n for (let i = 0; i < vectors.length; i++) {\n if (vectors?.[i]?.length !== dimension) {\n throw new Error(\n `Vector at index ${i} has invalid dimension ${vectors?.[i]?.length}. Expected ${dimension} dimensions.`,\n );\n }\n }\n }\n\n async upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]> {\n try {\n const collection = await this.getCollection({ indexName });\n\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions(vectors, stats.dimension);\n const generatedIds = ids || vectors.map(() => crypto.randomUUID());\n\n await collection.upsert({\n ids: generatedIds,\n embeddings: vectors,\n metadatas: metadata,\n documents: documents,\n });\n\n return generatedIds;\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'UPSERT', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'CREATE_INDEX', 'INVALID_DIMENSION'),\n text: 'Dimension must be a positive integer',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { dimension },\n });\n }\n\n const hnswSpace = spaceMappings[metric] as 'cosine' | 'l2' | 'ip' | undefined;\n\n if (!hnswSpace || !['cosine', 'l2', 'ip'].includes(hnswSpace)) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'CREATE_INDEX', 'INVALID_METRIC'),\n text: `Invalid metric: \"${metric}\". Must be one of: cosine, euclidean, dotproduct`,\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { metric },\n });\n }\n\n try {\n const collection = await this.client.createCollection({\n name: indexName,\n metadata: { dimension },\n configuration: { hnsw: { space: hnswSpace } },\n embeddingFunction: null,\n });\n this.collections.set(indexName, collection);\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.message || error?.toString();\n if (message && message.toLowerCase().includes('already exists')) {\n // Fetch collection info and check dimension\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'CREATE_INDEX', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: ChromaVectorFilter) {\n const translator = new ChromaFilterTranslator();\n const translatedFilter = translator.translate(filter);\n return translatedFilter ? (translatedFilter as Where) : undefined;\n }\n\n async query<T extends Metadata = Metadata>({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n documentFilter,\n }: ChromaQueryVectorParams): Promise<QueryResult[]> {\n try {\n const collection = await this.getCollection({ indexName });\n\n const defaultInclude: ['documents', 'metadatas', 'distances'] = ['documents', 'metadatas', 'distances'];\n\n const translatedFilter = this.transformFilter(filter);\n const results = await collection.query<T>({\n queryEmbeddings: [queryVector],\n nResults: topK,\n where: translatedFilter ?? undefined,\n whereDocument: documentFilter ?? undefined,\n include: includeVector ? [...defaultInclude, 'embeddings'] : defaultInclude,\n });\n\n return (results.ids[0] || []).map((id: string, index: number) => ({\n id,\n score: results.distances?.[0]?.[index] || 0,\n metadata: results.metadatas?.[0]?.[index] || {},\n document: results.documents?.[0]?.[index] ?? undefined,\n ...(includeVector && { vector: results.embeddings?.[0]?.[index] || [] }),\n }));\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'QUERY', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async hybridSearch({ indexName, search }: { indexName: string; search: Search }): Promise<QueryResult[]> {\n try {\n const collection = await this.getCollection({ indexName });\n const results = await collection.search(search);\n return (results.rows()[0] ?? []).map(record => ({\n id: record.id,\n score: record.score ?? 0,\n metadata: record.metadata ?? undefined,\n vector: record.embedding ?? undefined,\n document: record.document ?? undefined,\n }));\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'SEARCH_API', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async get<T extends Metadata = Metadata>({\n indexName,\n ids,\n filter,\n includeVector = false,\n documentFilter,\n offset,\n limit,\n }: ChromaGetRecordsParams) {\n try {\n const collection = await this.getCollection({ indexName });\n\n const defaultInclude: ['documents', 'metadatas'] = ['documents', 'metadatas'];\n const translatedFilter = this.transformFilter(filter);\n\n const result = await collection.get<T>({\n ids,\n where: translatedFilter ?? undefined,\n whereDocument: documentFilter ?? undefined,\n offset,\n limit,\n include: includeVector ? [...defaultInclude, 'embeddings'] : defaultInclude,\n });\n return result.rows();\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'GET', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const collections = await this.client.listCollections();\n return collections.map(collection => collection.name);\n } catch (error: any) {\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'LIST_INDEXES', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const collection = await this.getCollection({ indexName });\n const count = await collection.count();\n const metadata = collection.metadata as MastraMetadata | undefined;\n const space = collection.configuration.hnsw?.space || collection.configuration.spann?.space || undefined;\n\n return {\n dimension: metadata?.dimension || 0,\n count,\n metric: space ? (spaceMappings[space] as 'cosine' | 'euclidean' | 'dotproduct') : undefined,\n };\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'DESCRIBE_INDEX', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteCollection({ name: indexName });\n this.collections.delete(indexName);\n } catch (error: any) {\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'DELETE_INDEX', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async forkIndex({ indexName, newIndexName }: { indexName: string; newIndexName: string }): Promise<void> {\n try {\n const collection = await this.getCollection({ indexName, forceUpdate: true });\n const forkedCollection = await collection.fork({ name: newIndexName });\n this.collections.set(newIndexName, forkedCollection);\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'FORK_INDEX', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID or multiple vectors matching a filter.\n * @param indexName - The name of the index containing the vector(s).\n * @param id - The ID of the vector to update (mutually exclusive with filter).\n * @param filter - Filter to match multiple vectors to update (mutually exclusive with id).\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, filter, update }: UpdateVectorParams<ChromaVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (id && filter) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'UPDATE_VECTOR', 'MUTUALLY_EXCLUSIVE'),\n text: 'Cannot specify both id and filter - they are mutually exclusive',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!id && !filter) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'UPDATE_VECTOR', 'NO_TARGET'),\n text: 'Either id or filter must be provided',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'UPDATE_VECTOR', 'NO_PAYLOAD'),\n text: 'No updates provided',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: {\n indexName,\n ...(id && { id }),\n },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'UPDATE_VECTOR', 'EMPTY_FILTER'),\n text: 'Filter cannot be an empty filter object',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n const collection: Collection = await this.getCollection({ indexName });\n\n // Validate vector dimensions if provided\n if (update?.vector) {\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions([update.vector], stats.dimension);\n }\n\n if (id) {\n // Update single vector by ID\n const updateRecordSet: RecordSet = { ids: [id] };\n\n if (update?.vector) {\n updateRecordSet.embeddings = [update.vector];\n }\n\n if (update?.metadata) {\n updateRecordSet.metadatas = [update.metadata];\n }\n\n return await collection.update(updateRecordSet);\n } else if (filter) {\n // Update multiple vectors matching filter\n // First, get all vectors matching the filter\n const translatedFilter = this.transformFilter(filter);\n const matchingVectors = await collection.get({\n where: translatedFilter ?? undefined,\n include: ['embeddings', 'metadatas'],\n });\n\n const vectorRows = matchingVectors.rows();\n if (vectorRows.length === 0) {\n // No vectors to update - this is not an error\n return;\n }\n\n // Prepare update for all matching vectors\n const updateRecordSet: RecordSet = {\n ids: vectorRows.map(row => row.id),\n };\n\n if (update?.vector) {\n // Use the same new vector for all matching records\n updateRecordSet.embeddings = vectorRows.map(() => update.vector!);\n }\n\n if (update?.metadata) {\n // Use the same new metadata for all matching records\n updateRecordSet.metadatas = vectorRows.map(() => update.metadata!);\n }\n\n return await collection.update(updateRecordSet);\n }\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'UPDATE_VECTOR', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n ...(filter && { filter: JSON.stringify(filter) }),\n },\n },\n error,\n );\n }\n }\n\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n const collection: Collection = await this.getCollection({ indexName });\n await collection.delete({ ids: [id] });\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'DELETE_VECTOR', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes multiple vectors by IDs or filter.\n * @param indexName - The name of the index containing the vectors.\n * @param ids - Array of vector IDs to delete (mutually exclusive with filter).\n * @param filter - Filter to match vectors to delete (mutually exclusive with ids).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if both ids and filter are provided, or if neither is provided.\n */\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<ChromaVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (ids && filter) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'DELETE_VECTORS', 'MUTUALLY_EXCLUSIVE'),\n text: 'Cannot specify both ids and filter - they are mutually exclusive',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!ids && !filter) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'DELETE_VECTORS', 'NO_TARGET'),\n text: 'Either filter or ids must be provided',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate ids array is not empty\n if (ids && ids.length === 0) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'DELETE_VECTORS', 'EMPTY_IDS'),\n text: 'Cannot delete with empty ids array',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'DELETE_VECTORS', 'EMPTY_FILTER'),\n text: 'Cannot delete with empty filter object',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n const collection: Collection = await this.getCollection({ indexName });\n\n if (ids) {\n // Delete by IDs\n await collection.delete({ ids });\n } else if (filter) {\n // Delete by filter\n const translatedFilter = this.transformFilter(filter);\n await collection.delete({\n where: translatedFilter ?? undefined,\n });\n }\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'DELETE_VECTORS', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(filter && { filter: JSON.stringify(filter) }),\n ...(ids && { idsCount: ids.length }),\n },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Chroma Vector.\n */\nexport const CHROMA_PROMPT = `When querying Chroma, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nRestrictions:\n- Regex patterns are not supported\n- Element operators are not supported\n- Only $and and $or logical operators are supported\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Empty arrays in $in/$nin will return no results\n- If multiple top-level fields exist, they're wrapped in $and\n- Only logical operators ($and, $or) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$in\": [...] }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"$or\": [\n { \"inStock\": true },\n { \"preorder\": true }\n ]}\n ]\n}`;\n"]}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
|
|
2
|
+
import { createVectorErrorId } from '@mastra/core/storage';
|
|
2
3
|
import { MastraVector } from '@mastra/core/vector';
|
|
3
4
|
import { CloudClient, ChromaClient } from 'chromadb';
|
|
4
5
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
@@ -123,7 +124,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
123
124
|
return collection;
|
|
124
125
|
} catch {
|
|
125
126
|
throw new MastraError({
|
|
126
|
-
id: "
|
|
127
|
+
id: createVectorErrorId("CHROMA", "GET_COLLECTION", "FAILED"),
|
|
127
128
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
128
129
|
category: ErrorCategory.THIRD_PARTY,
|
|
129
130
|
details: { indexName }
|
|
@@ -158,7 +159,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
158
159
|
if (error instanceof MastraError) throw error;
|
|
159
160
|
throw new MastraError(
|
|
160
161
|
{
|
|
161
|
-
id: "
|
|
162
|
+
id: createVectorErrorId("CHROMA", "UPSERT", "FAILED"),
|
|
162
163
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
163
164
|
category: ErrorCategory.THIRD_PARTY,
|
|
164
165
|
details: { indexName }
|
|
@@ -170,7 +171,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
170
171
|
async createIndex({ indexName, dimension, metric = "cosine" }) {
|
|
171
172
|
if (!Number.isInteger(dimension) || dimension <= 0) {
|
|
172
173
|
throw new MastraError({
|
|
173
|
-
id: "
|
|
174
|
+
id: createVectorErrorId("CHROMA", "CREATE_INDEX", "INVALID_DIMENSION"),
|
|
174
175
|
text: "Dimension must be a positive integer",
|
|
175
176
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
176
177
|
category: ErrorCategory.USER,
|
|
@@ -180,7 +181,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
180
181
|
const hnswSpace = spaceMappings[metric];
|
|
181
182
|
if (!hnswSpace || !["cosine", "l2", "ip"].includes(hnswSpace)) {
|
|
182
183
|
throw new MastraError({
|
|
183
|
-
id: "
|
|
184
|
+
id: createVectorErrorId("CHROMA", "CREATE_INDEX", "INVALID_METRIC"),
|
|
184
185
|
text: `Invalid metric: "${metric}". Must be one of: cosine, euclidean, dotproduct`,
|
|
185
186
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
186
187
|
category: ErrorCategory.USER,
|
|
@@ -203,7 +204,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
203
204
|
}
|
|
204
205
|
throw new MastraError(
|
|
205
206
|
{
|
|
206
|
-
id: "
|
|
207
|
+
id: createVectorErrorId("CHROMA", "CREATE_INDEX", "FAILED"),
|
|
207
208
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
208
209
|
category: ErrorCategory.THIRD_PARTY,
|
|
209
210
|
details: { indexName }
|
|
@@ -247,7 +248,31 @@ var ChromaVector = class extends MastraVector {
|
|
|
247
248
|
if (error instanceof MastraError) throw error;
|
|
248
249
|
throw new MastraError(
|
|
249
250
|
{
|
|
250
|
-
id: "
|
|
251
|
+
id: createVectorErrorId("CHROMA", "QUERY", "FAILED"),
|
|
252
|
+
domain: ErrorDomain.MASTRA_VECTOR,
|
|
253
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
254
|
+
details: { indexName }
|
|
255
|
+
},
|
|
256
|
+
error
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
async hybridSearch({ indexName, search }) {
|
|
261
|
+
try {
|
|
262
|
+
const collection = await this.getCollection({ indexName });
|
|
263
|
+
const results = await collection.search(search);
|
|
264
|
+
return (results.rows()[0] ?? []).map((record) => ({
|
|
265
|
+
id: record.id,
|
|
266
|
+
score: record.score ?? 0,
|
|
267
|
+
metadata: record.metadata ?? void 0,
|
|
268
|
+
vector: record.embedding ?? void 0,
|
|
269
|
+
document: record.document ?? void 0
|
|
270
|
+
}));
|
|
271
|
+
} catch (error) {
|
|
272
|
+
if (error instanceof MastraError) throw error;
|
|
273
|
+
throw new MastraError(
|
|
274
|
+
{
|
|
275
|
+
id: createVectorErrorId("CHROMA", "SEARCH_API", "FAILED"),
|
|
251
276
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
252
277
|
category: ErrorCategory.THIRD_PARTY,
|
|
253
278
|
details: { indexName }
|
|
@@ -282,7 +307,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
282
307
|
if (error instanceof MastraError) throw error;
|
|
283
308
|
throw new MastraError(
|
|
284
309
|
{
|
|
285
|
-
id: "
|
|
310
|
+
id: createVectorErrorId("CHROMA", "GET", "FAILED"),
|
|
286
311
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
287
312
|
category: ErrorCategory.THIRD_PARTY,
|
|
288
313
|
details: { indexName }
|
|
@@ -298,7 +323,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
298
323
|
} catch (error) {
|
|
299
324
|
throw new MastraError(
|
|
300
325
|
{
|
|
301
|
-
id: "
|
|
326
|
+
id: createVectorErrorId("CHROMA", "LIST_INDEXES", "FAILED"),
|
|
302
327
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
303
328
|
category: ErrorCategory.THIRD_PARTY
|
|
304
329
|
},
|
|
@@ -327,7 +352,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
327
352
|
if (error instanceof MastraError) throw error;
|
|
328
353
|
throw new MastraError(
|
|
329
354
|
{
|
|
330
|
-
id: "
|
|
355
|
+
id: createVectorErrorId("CHROMA", "DESCRIBE_INDEX", "FAILED"),
|
|
331
356
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
332
357
|
category: ErrorCategory.THIRD_PARTY,
|
|
333
358
|
details: { indexName }
|
|
@@ -343,7 +368,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
343
368
|
} catch (error) {
|
|
344
369
|
throw new MastraError(
|
|
345
370
|
{
|
|
346
|
-
id: "
|
|
371
|
+
id: createVectorErrorId("CHROMA", "DELETE_INDEX", "FAILED"),
|
|
347
372
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
348
373
|
category: ErrorCategory.THIRD_PARTY,
|
|
349
374
|
details: { indexName }
|
|
@@ -361,7 +386,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
361
386
|
if (error instanceof MastraError) throw error;
|
|
362
387
|
throw new MastraError(
|
|
363
388
|
{
|
|
364
|
-
id: "
|
|
389
|
+
id: createVectorErrorId("CHROMA", "FORK_INDEX", "FAILED"),
|
|
365
390
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
366
391
|
category: ErrorCategory.THIRD_PARTY,
|
|
367
392
|
details: { indexName }
|
|
@@ -384,7 +409,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
384
409
|
async updateVector({ indexName, id, filter, update }) {
|
|
385
410
|
if (id && filter) {
|
|
386
411
|
throw new MastraError({
|
|
387
|
-
id: "
|
|
412
|
+
id: createVectorErrorId("CHROMA", "UPDATE_VECTOR", "MUTUALLY_EXCLUSIVE"),
|
|
388
413
|
text: "Cannot specify both id and filter - they are mutually exclusive",
|
|
389
414
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
390
415
|
category: ErrorCategory.USER,
|
|
@@ -393,7 +418,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
393
418
|
}
|
|
394
419
|
if (!id && !filter) {
|
|
395
420
|
throw new MastraError({
|
|
396
|
-
id: "
|
|
421
|
+
id: createVectorErrorId("CHROMA", "UPDATE_VECTOR", "NO_TARGET"),
|
|
397
422
|
text: "Either id or filter must be provided",
|
|
398
423
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
399
424
|
category: ErrorCategory.USER,
|
|
@@ -402,7 +427,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
402
427
|
}
|
|
403
428
|
if (!update.vector && !update.metadata) {
|
|
404
429
|
throw new MastraError({
|
|
405
|
-
id: "
|
|
430
|
+
id: createVectorErrorId("CHROMA", "UPDATE_VECTOR", "NO_PAYLOAD"),
|
|
406
431
|
text: "No updates provided",
|
|
407
432
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
408
433
|
category: ErrorCategory.USER,
|
|
@@ -414,7 +439,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
414
439
|
}
|
|
415
440
|
if (filter && Object.keys(filter).length === 0) {
|
|
416
441
|
throw new MastraError({
|
|
417
|
-
id: "
|
|
442
|
+
id: createVectorErrorId("CHROMA", "UPDATE_VECTOR", "EMPTY_FILTER"),
|
|
418
443
|
text: "Filter cannot be an empty filter object",
|
|
419
444
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
420
445
|
category: ErrorCategory.USER,
|
|
@@ -461,7 +486,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
461
486
|
if (error instanceof MastraError) throw error;
|
|
462
487
|
throw new MastraError(
|
|
463
488
|
{
|
|
464
|
-
id: "
|
|
489
|
+
id: createVectorErrorId("CHROMA", "UPDATE_VECTOR", "FAILED"),
|
|
465
490
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
466
491
|
category: ErrorCategory.THIRD_PARTY,
|
|
467
492
|
details: {
|
|
@@ -482,7 +507,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
482
507
|
if (error instanceof MastraError) throw error;
|
|
483
508
|
throw new MastraError(
|
|
484
509
|
{
|
|
485
|
-
id: "
|
|
510
|
+
id: createVectorErrorId("CHROMA", "DELETE_VECTOR", "FAILED"),
|
|
486
511
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
487
512
|
category: ErrorCategory.THIRD_PARTY,
|
|
488
513
|
details: {
|
|
@@ -505,7 +530,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
505
530
|
async deleteVectors({ indexName, filter, ids }) {
|
|
506
531
|
if (ids && filter) {
|
|
507
532
|
throw new MastraError({
|
|
508
|
-
id: "
|
|
533
|
+
id: createVectorErrorId("CHROMA", "DELETE_VECTORS", "MUTUALLY_EXCLUSIVE"),
|
|
509
534
|
text: "Cannot specify both ids and filter - they are mutually exclusive",
|
|
510
535
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
511
536
|
category: ErrorCategory.USER,
|
|
@@ -514,7 +539,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
514
539
|
}
|
|
515
540
|
if (!ids && !filter) {
|
|
516
541
|
throw new MastraError({
|
|
517
|
-
id: "
|
|
542
|
+
id: createVectorErrorId("CHROMA", "DELETE_VECTORS", "NO_TARGET"),
|
|
518
543
|
text: "Either filter or ids must be provided",
|
|
519
544
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
520
545
|
category: ErrorCategory.USER,
|
|
@@ -523,7 +548,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
523
548
|
}
|
|
524
549
|
if (ids && ids.length === 0) {
|
|
525
550
|
throw new MastraError({
|
|
526
|
-
id: "
|
|
551
|
+
id: createVectorErrorId("CHROMA", "DELETE_VECTORS", "EMPTY_IDS"),
|
|
527
552
|
text: "Cannot delete with empty ids array",
|
|
528
553
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
529
554
|
category: ErrorCategory.USER,
|
|
@@ -532,7 +557,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
532
557
|
}
|
|
533
558
|
if (filter && Object.keys(filter).length === 0) {
|
|
534
559
|
throw new MastraError({
|
|
535
|
-
id: "
|
|
560
|
+
id: createVectorErrorId("CHROMA", "DELETE_VECTORS", "EMPTY_FILTER"),
|
|
536
561
|
text: "Cannot delete with empty filter object",
|
|
537
562
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
538
563
|
category: ErrorCategory.USER,
|
|
@@ -553,7 +578,7 @@ var ChromaVector = class extends MastraVector {
|
|
|
553
578
|
if (error instanceof MastraError) throw error;
|
|
554
579
|
throw new MastraError(
|
|
555
580
|
{
|
|
556
|
-
id: "
|
|
581
|
+
id: createVectorErrorId("CHROMA", "DELETE_VECTORS", "FAILED"),
|
|
557
582
|
domain: ErrorDomain.MASTRA_VECTOR,
|
|
558
583
|
category: ErrorCategory.THIRD_PARTY,
|
|
559
584
|
details: {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":[],"mappings":";;;;;;AA4BO,IAAM,sBAAA,GAAN,cAAqC,oBAAA,CAAyC;AAAA,EAChE,qBAAA,GAAyC;AAC1D,IAAA,OAAO;AAAA,MACL,GAAG,oBAAA,CAAqB,iBAAA;AAAA,MACxB,OAAA,EAAS,CAAC,MAAA,EAAQ,KAAK,CAAA;AAAA,MACvB,KAAA,EAAO,CAAC,KAAA,EAAO,MAAM,CAAA;AAAA,MACrB,SAAS,EAAC;AAAA,MACV,OAAO,EAAC;AAAA,MACR,QAAQ;AAAC,KACX;AAAA,EACF;AAAA,EAEA,UAAU,MAAA,EAAiD;AACzD,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,MAAM,CAAA,EAAG,OAAO,MAAA;AACjC,IAAA,IAAA,CAAK,eAAe,MAAM,CAAA;AAE1B,IAAA,OAAO,IAAA,CAAK,cAAc,MAAM,CAAA;AAAA,EAClC;AAAA,EAEQ,aAAA,CAAc,IAAA,EAA0B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AAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA","file":"index.js","sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n QueryOperator,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype ChromaOperatorValueMap = Omit<OperatorValueMap, '$exists' | '$elemMatch' | '$regex' | '$options'>;\n\ntype ChromaLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not'>;\n\ntype ChromaBlacklisted = BlacklistedRootOperators | '$nor' | '$not';\n\nexport type ChromaVectorFilter = VectorFilter<\n keyof ChromaOperatorValueMap,\n ChromaOperatorValueMap,\n ChromaLogicalOperatorValueMap,\n ChromaBlacklisted\n>;\n\n/**\n * Translator for Chroma filter queries.\n * Maintains MongoDB-compatible syntax while ensuring proper validation\n * and normalization of values.\n */\nexport class ChromaFilterTranslator extends BaseFilterTranslator<ChromaVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or'],\n array: ['$in', '$nin'],\n element: [],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: ChromaVectorFilter): ChromaVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n\n return this.translateNode(filter);\n }\n\n private translateNode(node: ChromaVectorFilter, currentPath: string = ''): any {\n // Handle primitive values and arrays\n if (this.isRegex(node)) {\n throw new Error('Regex is supported in Chroma via the `documentFilter` argument');\n }\n if (this.isPrimitive(node)) return this.normalizeComparisonValue(node);\n if (Array.isArray(node)) return { $in: this.normalizeArrayValues(node) };\n\n const entries = Object.entries(node as Record<string, any>);\n const firstEntry = entries[0];\n // Handle single operator case\n if (entries.length === 1 && firstEntry && this.isOperator(firstEntry[0])) {\n const [operator, value] = firstEntry;\n const translated = this.translateOperator(operator, value);\n if (this.isLogicalOperator(operator) && Array.isArray(translated) && translated.length === 1) {\n return translated[0];\n }\n return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;\n }\n\n // Process each entry\n const result: Record<string, any> = {};\n const multiOperatorConditions: any[] = [];\n\n for (const [key, value] of entries) {\n const newPath = currentPath ? `${currentPath}.${key}` : key;\n\n if (this.isOperator(key)) {\n result[key] = this.translateOperator(key, value);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Check for multiple operators on same field\n const valueEntries = Object.entries(value);\n if (valueEntries.every(([op]) => this.isOperator(op)) && valueEntries.length > 1) {\n valueEntries.forEach(([op, opValue]) => {\n multiOperatorConditions.push({\n [newPath]: { [op]: this.normalizeComparisonValue(opValue) },\n });\n });\n continue;\n }\n\n // Check if the nested object contains operators\n if (Object.keys(value).length === 0) {\n result[newPath] = this.translateNode(value);\n } else {\n const hasOperators = Object.keys(value).some(k => this.isOperator(k));\n if (hasOperators) {\n // For objects with operators, normalize each operator value\n const normalizedValue: Record<string, any> = {};\n for (const [op, opValue] of Object.entries(value)) {\n normalizedValue[op] = this.isOperator(op) ? this.translateOperator(op, opValue) : opValue;\n }\n result[newPath] = normalizedValue;\n } else {\n // For objects without operators, flatten them\n Object.assign(result, this.translateNode(value, newPath));\n }\n }\n } else {\n result[newPath] = this.translateNode(value);\n }\n }\n\n // If we have multiple operators, return them combined with $and\n if (multiOperatorConditions.length > 0) {\n return { $and: multiOperatorConditions };\n }\n\n // Wrap in $and if there are multiple top-level fields\n if (Object.keys(result).length > 1 && !currentPath) {\n return {\n $and: Object.entries(result).map(([key, value]) => ({ [key]: value })),\n };\n }\n\n return result;\n }\n\n private translateOperator(operator: QueryOperator, value: any): any {\n // Handle logical operators\n if (this.isLogicalOperator(operator)) {\n return Array.isArray(value) ? value.map(item => this.translateNode(item)) : this.translateNode(value);\n }\n\n // Handle comparison and element operators\n return this.normalizeComparisonValue(value);\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport { ChromaClient, CloudClient } from 'chromadb';\nimport type { ChromaClientArgs, RecordSet, Where, WhereDocument, Collection, Metadata } from 'chromadb';\nimport type { ChromaVectorFilter } from './filter';\nimport { ChromaFilterTranslator } from './filter';\n\ninterface ChromaUpsertVectorParams extends UpsertVectorParams {\n documents?: string[];\n}\n\ninterface ChromaQueryVectorParams extends QueryVectorParams<ChromaVectorFilter> {\n documentFilter?: WhereDocument | null;\n}\n\ninterface ChromaGetRecordsParams {\n indexName: string;\n ids?: string[];\n filter?: ChromaVectorFilter;\n documentFilter?: WhereDocument | null;\n includeVector?: boolean;\n limit?: number;\n offset?: number;\n}\n\ntype MastraMetadata = {\n dimension?: number;\n};\n\ntype ChromaVectorArgs = ChromaClientArgs & { apiKey?: string };\n\nconst spaceMappings = {\n cosine: 'cosine',\n euclidean: 'l2',\n dotproduct: 'ip',\n l2: 'euclidean',\n ip: 'dotproduct',\n};\n\nexport class ChromaVector extends MastraVector<ChromaVectorFilter> {\n private client: ChromaClient;\n private collections: Map<string, Collection>;\n\n constructor({ id, ...chromaClientArgs }: ChromaVectorArgs & { id: string }) {\n super({ id });\n if (chromaClientArgs?.apiKey) {\n this.client = new CloudClient({\n apiKey: chromaClientArgs.apiKey,\n tenant: chromaClientArgs.tenant,\n database: chromaClientArgs.database,\n });\n } else {\n this.client = new ChromaClient(chromaClientArgs);\n }\n this.collections = new Map();\n }\n\n async getCollection({ indexName, forceUpdate = false }: { indexName: string; forceUpdate?: boolean }) {\n let collection = this.collections.get(indexName);\n if (forceUpdate || !collection) {\n try {\n collection = await this.client.getCollection({ name: indexName });\n this.collections.set(indexName, collection);\n return collection;\n } catch {\n throw new MastraError({\n id: 'CHROMA_COLLECTION_GET_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n });\n }\n }\n return collection;\n }\n\n private validateVectorDimensions(vectors: number[][], dimension: number): void {\n for (let i = 0; i < vectors.length; i++) {\n if (vectors?.[i]?.length !== dimension) {\n throw new Error(\n `Vector at index ${i} has invalid dimension ${vectors?.[i]?.length}. Expected ${dimension} dimensions.`,\n );\n }\n }\n }\n\n async upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]> {\n try {\n const collection = await this.getCollection({ indexName });\n\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions(vectors, stats.dimension);\n const generatedIds = ids || vectors.map(() => crypto.randomUUID());\n\n await collection.upsert({\n ids: generatedIds,\n embeddings: vectors,\n metadatas: metadata,\n documents: documents,\n });\n\n return generatedIds;\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_CREATE_INDEX_INVALID_DIMENSION',\n text: 'Dimension must be a positive integer',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { dimension },\n });\n }\n\n const hnswSpace = spaceMappings[metric] as 'cosine' | 'l2' | 'ip' | undefined;\n\n if (!hnswSpace || !['cosine', 'l2', 'ip'].includes(hnswSpace)) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_CREATE_INDEX_INVALID_METRIC',\n text: `Invalid metric: \"${metric}\". Must be one of: cosine, euclidean, dotproduct`,\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { metric },\n });\n }\n\n try {\n const collection = await this.client.createCollection({\n name: indexName,\n metadata: { dimension },\n configuration: { hnsw: { space: hnswSpace } },\n embeddingFunction: null,\n });\n this.collections.set(indexName, collection);\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.message || error?.toString();\n if (message && message.toLowerCase().includes('already exists')) {\n // Fetch collection info and check dimension\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: ChromaVectorFilter) {\n const translator = new ChromaFilterTranslator();\n const translatedFilter = translator.translate(filter);\n return translatedFilter ? (translatedFilter as Where) : undefined;\n }\n\n async query<T extends Metadata = Metadata>({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n documentFilter,\n }: ChromaQueryVectorParams): Promise<QueryResult[]> {\n try {\n const collection = await this.getCollection({ indexName });\n\n const defaultInclude: ['documents', 'metadatas', 'distances'] = ['documents', 'metadatas', 'distances'];\n\n const translatedFilter = this.transformFilter(filter);\n const results = await collection.query<T>({\n queryEmbeddings: [queryVector],\n nResults: topK,\n where: translatedFilter ?? undefined,\n whereDocument: documentFilter ?? undefined,\n include: includeVector ? [...defaultInclude, 'embeddings'] : defaultInclude,\n });\n\n return (results.ids[0] || []).map((id: string, index: number) => ({\n id,\n score: results.distances?.[0]?.[index] || 0,\n metadata: results.metadatas?.[0]?.[index] || {},\n document: results.documents?.[0]?.[index] ?? undefined,\n ...(includeVector && { vector: results.embeddings?.[0]?.[index] || [] }),\n }));\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async get<T extends Metadata = Metadata>({\n indexName,\n ids,\n filter,\n includeVector = false,\n documentFilter,\n offset,\n limit,\n }: ChromaGetRecordsParams) {\n try {\n const collection = await this.getCollection({ indexName });\n\n const defaultInclude: ['documents', 'metadatas'] = ['documents', 'metadatas'];\n const translatedFilter = this.transformFilter(filter);\n\n const result = await collection.get<T>({\n ids,\n where: translatedFilter ?? undefined,\n whereDocument: documentFilter ?? undefined,\n offset,\n limit,\n include: includeVector ? [...defaultInclude, 'embeddings'] : defaultInclude,\n });\n return result.rows();\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_GET_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const collections = await this.client.listCollections();\n return collections.map(collection => collection.name);\n } catch (error: any) {\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const collection = await this.getCollection({ indexName });\n const count = await collection.count();\n const metadata = collection.metadata as MastraMetadata | undefined;\n const space = collection.configuration.hnsw?.space || collection.configuration.spann?.space || undefined;\n\n return {\n dimension: metadata?.dimension || 0,\n count,\n metric: space ? (spaceMappings[space] as 'cosine' | 'euclidean' | 'dotproduct') : undefined,\n };\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteCollection({ name: indexName });\n this.collections.delete(indexName);\n } catch (error: any) {\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async forkIndex({ indexName, newIndexName }: { indexName: string; newIndexName: string }): Promise<void> {\n try {\n const collection = await this.getCollection({ indexName, forceUpdate: true });\n const forkedCollection = await collection.fork({ name: newIndexName });\n this.collections.set(newIndexName, forkedCollection);\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_INDEX_FORK_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID or multiple vectors matching a filter.\n * @param indexName - The name of the index containing the vector(s).\n * @param id - The ID of the vector to update (mutually exclusive with filter).\n * @param filter - Filter to match multiple vectors to update (mutually exclusive with id).\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, filter, update }: UpdateVectorParams<ChromaVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (id && filter) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_UPDATE_MUTUALLY_EXCLUSIVE',\n text: 'Cannot specify both id and filter - they are mutually exclusive',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!id && !filter) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_UPDATE_NO_TARGET',\n text: 'Either id or filter must be provided',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_UPDATE_NO_PAYLOAD',\n text: 'No updates provided',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: {\n indexName,\n ...(id && { id }),\n },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_UPDATE_EMPTY_FILTER',\n text: 'Filter cannot be an empty filter object',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n const collection: Collection = await this.getCollection({ indexName });\n\n // Validate vector dimensions if provided\n if (update?.vector) {\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions([update.vector], stats.dimension);\n }\n\n if (id) {\n // Update single vector by ID\n const updateRecordSet: RecordSet = { ids: [id] };\n\n if (update?.vector) {\n updateRecordSet.embeddings = [update.vector];\n }\n\n if (update?.metadata) {\n updateRecordSet.metadatas = [update.metadata];\n }\n\n return await collection.update(updateRecordSet);\n } else if (filter) {\n // Update multiple vectors matching filter\n // First, get all vectors matching the filter\n const translatedFilter = this.transformFilter(filter);\n const matchingVectors = await collection.get({\n where: translatedFilter ?? undefined,\n include: ['embeddings', 'metadatas'],\n });\n\n const vectorRows = matchingVectors.rows();\n if (vectorRows.length === 0) {\n // No vectors to update - this is not an error\n return;\n }\n\n // Prepare update for all matching vectors\n const updateRecordSet: RecordSet = {\n ids: vectorRows.map(row => row.id),\n };\n\n if (update?.vector) {\n // Use the same new vector for all matching records\n updateRecordSet.embeddings = vectorRows.map(() => update.vector!);\n }\n\n if (update?.metadata) {\n // Use the same new metadata for all matching records\n updateRecordSet.metadatas = vectorRows.map(() => update.metadata!);\n }\n\n return await collection.update(updateRecordSet);\n }\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_UPDATE_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n ...(filter && { filter: JSON.stringify(filter) }),\n },\n },\n error,\n );\n }\n }\n\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n const collection: Collection = await this.getCollection({ indexName });\n await collection.delete({ ids: [id] });\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DELETE_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes multiple vectors by IDs or filter.\n * @param indexName - The name of the index containing the vectors.\n * @param ids - Array of vector IDs to delete (mutually exclusive with filter).\n * @param filter - Filter to match vectors to delete (mutually exclusive with ids).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if both ids and filter are provided, or if neither is provided.\n */\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<ChromaVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (ids && filter) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_DELETE_VECTORS_MUTUALLY_EXCLUSIVE',\n text: 'Cannot specify both ids and filter - they are mutually exclusive',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!ids && !filter) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_DELETE_VECTORS_NO_TARGET',\n text: 'Either filter or ids must be provided',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate ids array is not empty\n if (ids && ids.length === 0) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_DELETE_VECTORS_EMPTY_IDS',\n text: 'Cannot delete with empty ids array',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_DELETE_VECTORS_EMPTY_FILTER',\n text: 'Cannot delete with empty filter object',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n const collection: Collection = await this.getCollection({ indexName });\n\n if (ids) {\n // Delete by IDs\n await collection.delete({ ids });\n } else if (filter) {\n // Delete by filter\n const translatedFilter = this.transformFilter(filter);\n await collection.delete({\n where: translatedFilter ?? undefined,\n });\n }\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DELETE_VECTORS_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(filter && { filter: JSON.stringify(filter) }),\n ...(ids && { idsCount: ids.length }),\n },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Chroma Vector.\n */\nexport const CHROMA_PROMPT = `When querying Chroma, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nRestrictions:\n- Regex patterns are not supported\n- Element operators are not supported\n- Only $and and $or logical operators are supported\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Empty arrays in $in/$nin will return no results\n- If multiple top-level fields exist, they're wrapped in $and\n- Only logical operators ($and, $or) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$in\": [...] }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"$or\": [\n { \"inStock\": true },\n { \"preorder\": true }\n ]}\n ]\n}`;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":[],"mappings":";;;;;;;AA4BO,IAAM,sBAAA,GAAN,cAAqC,oBAAA,CAAyC;AAAA,EAChE,qBAAA,GAAyC;AAC1D,IAAA,OAAO;AAAA,MACL,GAAG,oBAAA,CAAqB,iBAAA;AAAA,MACxB,OAAA,EAAS,CAAC,MAAA,EAAQ,KAAK,CAAA;AAAA,MACvB,KAAA,EAAO,CAAC,KAAA,EAAO,MAAM,CAAA;AAAA,MACrB,SAAS,EAAC;AAAA,MACV,OAAO,EAAC;AAAA,MACR,QAAQ;AAAC,KACX;AAAA,EACF;AAAA,EAEA,UAAU,MAAA,EAAiD;AACzD,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,MAAM,CAAA,EAAG,OAAO,MAAA;AACjC,IAAA,IAAA,CAAK,eAAe,MAAM,CAAA;AAE1B,IAAA,OAAO,IAAA,CAAK,cAAc,MAAM,CAAA;AAAA,EAClC;AAAA,EAEQ,aAAA,CAAc,IAAA,EAA0B,WAAA,GAAsB,EAAA,EAAS;AAE7E,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,IAAI,CAAA,EAAG;AACtB,MAAA,MAAM,IAAI,MAAM,gEAAgE,CAAA;AAAA,IAClF;AACA,IAAA,IAAI,KAAK,WAAA,CAAY,IAAI,GAAG,OAAO,IAAA,CAAK,yBAAyB,IAAI,CAAA;AACrE,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,EAAG,OAAO,EAAE,GAAA,EAAK,IAAA,CAAK,oBAAA,CAAqB,IAAI,CAAA,EAAE;AAEvE,IAAA,MAAM,OAAA,GAAU,MAAA,CAAO,OAAA,CAAQ,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aAAA,CAAc,WAAA;AAAA,UACxB,OAAA,EAAS;AAAA,YACP,SAAA;AAAA,YACA,GAAI,MAAA,IAAU,EAAE,QAAQ,IAAA,CAAK,SAAA,CAAU,MAAM,CAAA,EAAE;AAAA,YAC/C,GAAI,GAAA,IAAO,EAAE,QAAA,EAAU,IAAI,MAAA;AAAO;AACpC,SACF;AAAA,QACA;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACF;;;AC5lBO,IAAM,aAAA,GAAgB,CAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA","file":"index.js","sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n QueryOperator,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype ChromaOperatorValueMap = Omit<OperatorValueMap, '$exists' | '$elemMatch' | '$regex' | '$options'>;\n\ntype ChromaLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not'>;\n\ntype ChromaBlacklisted = BlacklistedRootOperators | '$nor' | '$not';\n\nexport type ChromaVectorFilter = VectorFilter<\n keyof ChromaOperatorValueMap,\n ChromaOperatorValueMap,\n ChromaLogicalOperatorValueMap,\n ChromaBlacklisted\n>;\n\n/**\n * Translator for Chroma filter queries.\n * Maintains MongoDB-compatible syntax while ensuring proper validation\n * and normalization of values.\n */\nexport class ChromaFilterTranslator extends BaseFilterTranslator<ChromaVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or'],\n array: ['$in', '$nin'],\n element: [],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: ChromaVectorFilter): ChromaVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n\n return this.translateNode(filter);\n }\n\n private translateNode(node: ChromaVectorFilter, currentPath: string = ''): any {\n // Handle primitive values and arrays\n if (this.isRegex(node)) {\n throw new Error('Regex is supported in Chroma via the `documentFilter` argument');\n }\n if (this.isPrimitive(node)) return this.normalizeComparisonValue(node);\n if (Array.isArray(node)) return { $in: this.normalizeArrayValues(node) };\n\n const entries = Object.entries(node as Record<string, any>);\n const firstEntry = entries[0];\n // Handle single operator case\n if (entries.length === 1 && firstEntry && this.isOperator(firstEntry[0])) {\n const [operator, value] = firstEntry;\n const translated = this.translateOperator(operator, value);\n if (this.isLogicalOperator(operator) && Array.isArray(translated) && translated.length === 1) {\n return translated[0];\n }\n return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;\n }\n\n // Process each entry\n const result: Record<string, any> = {};\n const multiOperatorConditions: any[] = [];\n\n for (const [key, value] of entries) {\n const newPath = currentPath ? `${currentPath}.${key}` : key;\n\n if (this.isOperator(key)) {\n result[key] = this.translateOperator(key, value);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Check for multiple operators on same field\n const valueEntries = Object.entries(value);\n if (valueEntries.every(([op]) => this.isOperator(op)) && valueEntries.length > 1) {\n valueEntries.forEach(([op, opValue]) => {\n multiOperatorConditions.push({\n [newPath]: { [op]: this.normalizeComparisonValue(opValue) },\n });\n });\n continue;\n }\n\n // Check if the nested object contains operators\n if (Object.keys(value).length === 0) {\n result[newPath] = this.translateNode(value);\n } else {\n const hasOperators = Object.keys(value).some(k => this.isOperator(k));\n if (hasOperators) {\n // For objects with operators, normalize each operator value\n const normalizedValue: Record<string, any> = {};\n for (const [op, opValue] of Object.entries(value)) {\n normalizedValue[op] = this.isOperator(op) ? this.translateOperator(op, opValue) : opValue;\n }\n result[newPath] = normalizedValue;\n } else {\n // For objects without operators, flatten them\n Object.assign(result, this.translateNode(value, newPath));\n }\n }\n } else {\n result[newPath] = this.translateNode(value);\n }\n }\n\n // If we have multiple operators, return them combined with $and\n if (multiOperatorConditions.length > 0) {\n return { $and: multiOperatorConditions };\n }\n\n // Wrap in $and if there are multiple top-level fields\n if (Object.keys(result).length > 1 && !currentPath) {\n return {\n $and: Object.entries(result).map(([key, value]) => ({ [key]: value })),\n };\n }\n\n return result;\n }\n\n private translateOperator(operator: QueryOperator, value: any): any {\n // Handle logical operators\n if (this.isLogicalOperator(operator)) {\n return Array.isArray(value) ? value.map(item => this.translateNode(item)) : this.translateNode(value);\n }\n\n // Handle comparison and element operators\n return this.normalizeComparisonValue(value);\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport { ChromaClient, CloudClient } from 'chromadb';\nimport type { ChromaClientArgs, RecordSet, Where, WhereDocument, Collection, Metadata, Search } from 'chromadb';\nimport type { ChromaVectorFilter } from './filter';\nimport { ChromaFilterTranslator } from './filter';\n\ninterface ChromaUpsertVectorParams extends UpsertVectorParams {\n documents?: string[];\n}\n\ninterface ChromaQueryVectorParams extends QueryVectorParams<ChromaVectorFilter> {\n documentFilter?: WhereDocument | null;\n}\n\ninterface ChromaGetRecordsParams {\n indexName: string;\n ids?: string[];\n filter?: ChromaVectorFilter;\n documentFilter?: WhereDocument | null;\n includeVector?: boolean;\n limit?: number;\n offset?: number;\n}\n\ntype MastraMetadata = {\n dimension?: number;\n};\n\ntype ChromaVectorArgs = ChromaClientArgs & { apiKey?: string };\n\nconst spaceMappings = {\n cosine: 'cosine',\n euclidean: 'l2',\n dotproduct: 'ip',\n l2: 'euclidean',\n ip: 'dotproduct',\n};\n\nexport class ChromaVector extends MastraVector<ChromaVectorFilter> {\n private client: ChromaClient;\n private collections: Map<string, Collection>;\n\n constructor({ id, ...chromaClientArgs }: ChromaVectorArgs & { id: string }) {\n super({ id });\n if (chromaClientArgs?.apiKey) {\n this.client = new CloudClient({\n apiKey: chromaClientArgs.apiKey,\n tenant: chromaClientArgs.tenant,\n database: chromaClientArgs.database,\n });\n } else {\n this.client = new ChromaClient(chromaClientArgs);\n }\n this.collections = new Map();\n }\n\n async getCollection({ indexName, forceUpdate = false }: { indexName: string; forceUpdate?: boolean }) {\n let collection = this.collections.get(indexName);\n if (forceUpdate || !collection) {\n try {\n collection = await this.client.getCollection({ name: indexName });\n this.collections.set(indexName, collection);\n return collection;\n } catch {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'GET_COLLECTION', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n });\n }\n }\n return collection;\n }\n\n private validateVectorDimensions(vectors: number[][], dimension: number): void {\n for (let i = 0; i < vectors.length; i++) {\n if (vectors?.[i]?.length !== dimension) {\n throw new Error(\n `Vector at index ${i} has invalid dimension ${vectors?.[i]?.length}. Expected ${dimension} dimensions.`,\n );\n }\n }\n }\n\n async upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]> {\n try {\n const collection = await this.getCollection({ indexName });\n\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions(vectors, stats.dimension);\n const generatedIds = ids || vectors.map(() => crypto.randomUUID());\n\n await collection.upsert({\n ids: generatedIds,\n embeddings: vectors,\n metadatas: metadata,\n documents: documents,\n });\n\n return generatedIds;\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'UPSERT', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'CREATE_INDEX', 'INVALID_DIMENSION'),\n text: 'Dimension must be a positive integer',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { dimension },\n });\n }\n\n const hnswSpace = spaceMappings[metric] as 'cosine' | 'l2' | 'ip' | undefined;\n\n if (!hnswSpace || !['cosine', 'l2', 'ip'].includes(hnswSpace)) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'CREATE_INDEX', 'INVALID_METRIC'),\n text: `Invalid metric: \"${metric}\". Must be one of: cosine, euclidean, dotproduct`,\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { metric },\n });\n }\n\n try {\n const collection = await this.client.createCollection({\n name: indexName,\n metadata: { dimension },\n configuration: { hnsw: { space: hnswSpace } },\n embeddingFunction: null,\n });\n this.collections.set(indexName, collection);\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.message || error?.toString();\n if (message && message.toLowerCase().includes('already exists')) {\n // Fetch collection info and check dimension\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'CREATE_INDEX', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: ChromaVectorFilter) {\n const translator = new ChromaFilterTranslator();\n const translatedFilter = translator.translate(filter);\n return translatedFilter ? (translatedFilter as Where) : undefined;\n }\n\n async query<T extends Metadata = Metadata>({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n documentFilter,\n }: ChromaQueryVectorParams): Promise<QueryResult[]> {\n try {\n const collection = await this.getCollection({ indexName });\n\n const defaultInclude: ['documents', 'metadatas', 'distances'] = ['documents', 'metadatas', 'distances'];\n\n const translatedFilter = this.transformFilter(filter);\n const results = await collection.query<T>({\n queryEmbeddings: [queryVector],\n nResults: topK,\n where: translatedFilter ?? undefined,\n whereDocument: documentFilter ?? undefined,\n include: includeVector ? [...defaultInclude, 'embeddings'] : defaultInclude,\n });\n\n return (results.ids[0] || []).map((id: string, index: number) => ({\n id,\n score: results.distances?.[0]?.[index] || 0,\n metadata: results.metadatas?.[0]?.[index] || {},\n document: results.documents?.[0]?.[index] ?? undefined,\n ...(includeVector && { vector: results.embeddings?.[0]?.[index] || [] }),\n }));\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'QUERY', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async hybridSearch({ indexName, search }: { indexName: string; search: Search }): Promise<QueryResult[]> {\n try {\n const collection = await this.getCollection({ indexName });\n const results = await collection.search(search);\n return (results.rows()[0] ?? []).map(record => ({\n id: record.id,\n score: record.score ?? 0,\n metadata: record.metadata ?? undefined,\n vector: record.embedding ?? undefined,\n document: record.document ?? undefined,\n }));\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'SEARCH_API', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async get<T extends Metadata = Metadata>({\n indexName,\n ids,\n filter,\n includeVector = false,\n documentFilter,\n offset,\n limit,\n }: ChromaGetRecordsParams) {\n try {\n const collection = await this.getCollection({ indexName });\n\n const defaultInclude: ['documents', 'metadatas'] = ['documents', 'metadatas'];\n const translatedFilter = this.transformFilter(filter);\n\n const result = await collection.get<T>({\n ids,\n where: translatedFilter ?? undefined,\n whereDocument: documentFilter ?? undefined,\n offset,\n limit,\n include: includeVector ? [...defaultInclude, 'embeddings'] : defaultInclude,\n });\n return result.rows();\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'GET', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const collections = await this.client.listCollections();\n return collections.map(collection => collection.name);\n } catch (error: any) {\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'LIST_INDEXES', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const collection = await this.getCollection({ indexName });\n const count = await collection.count();\n const metadata = collection.metadata as MastraMetadata | undefined;\n const space = collection.configuration.hnsw?.space || collection.configuration.spann?.space || undefined;\n\n return {\n dimension: metadata?.dimension || 0,\n count,\n metric: space ? (spaceMappings[space] as 'cosine' | 'euclidean' | 'dotproduct') : undefined,\n };\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'DESCRIBE_INDEX', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteCollection({ name: indexName });\n this.collections.delete(indexName);\n } catch (error: any) {\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'DELETE_INDEX', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async forkIndex({ indexName, newIndexName }: { indexName: string; newIndexName: string }): Promise<void> {\n try {\n const collection = await this.getCollection({ indexName, forceUpdate: true });\n const forkedCollection = await collection.fork({ name: newIndexName });\n this.collections.set(newIndexName, forkedCollection);\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'FORK_INDEX', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID or multiple vectors matching a filter.\n * @param indexName - The name of the index containing the vector(s).\n * @param id - The ID of the vector to update (mutually exclusive with filter).\n * @param filter - Filter to match multiple vectors to update (mutually exclusive with id).\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, filter, update }: UpdateVectorParams<ChromaVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (id && filter) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'UPDATE_VECTOR', 'MUTUALLY_EXCLUSIVE'),\n text: 'Cannot specify both id and filter - they are mutually exclusive',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!id && !filter) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'UPDATE_VECTOR', 'NO_TARGET'),\n text: 'Either id or filter must be provided',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'UPDATE_VECTOR', 'NO_PAYLOAD'),\n text: 'No updates provided',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: {\n indexName,\n ...(id && { id }),\n },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'UPDATE_VECTOR', 'EMPTY_FILTER'),\n text: 'Filter cannot be an empty filter object',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n const collection: Collection = await this.getCollection({ indexName });\n\n // Validate vector dimensions if provided\n if (update?.vector) {\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions([update.vector], stats.dimension);\n }\n\n if (id) {\n // Update single vector by ID\n const updateRecordSet: RecordSet = { ids: [id] };\n\n if (update?.vector) {\n updateRecordSet.embeddings = [update.vector];\n }\n\n if (update?.metadata) {\n updateRecordSet.metadatas = [update.metadata];\n }\n\n return await collection.update(updateRecordSet);\n } else if (filter) {\n // Update multiple vectors matching filter\n // First, get all vectors matching the filter\n const translatedFilter = this.transformFilter(filter);\n const matchingVectors = await collection.get({\n where: translatedFilter ?? undefined,\n include: ['embeddings', 'metadatas'],\n });\n\n const vectorRows = matchingVectors.rows();\n if (vectorRows.length === 0) {\n // No vectors to update - this is not an error\n return;\n }\n\n // Prepare update for all matching vectors\n const updateRecordSet: RecordSet = {\n ids: vectorRows.map(row => row.id),\n };\n\n if (update?.vector) {\n // Use the same new vector for all matching records\n updateRecordSet.embeddings = vectorRows.map(() => update.vector!);\n }\n\n if (update?.metadata) {\n // Use the same new metadata for all matching records\n updateRecordSet.metadatas = vectorRows.map(() => update.metadata!);\n }\n\n return await collection.update(updateRecordSet);\n }\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'UPDATE_VECTOR', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n ...(filter && { filter: JSON.stringify(filter) }),\n },\n },\n error,\n );\n }\n }\n\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n const collection: Collection = await this.getCollection({ indexName });\n await collection.delete({ ids: [id] });\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'DELETE_VECTOR', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes multiple vectors by IDs or filter.\n * @param indexName - The name of the index containing the vectors.\n * @param ids - Array of vector IDs to delete (mutually exclusive with filter).\n * @param filter - Filter to match vectors to delete (mutually exclusive with ids).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if both ids and filter are provided, or if neither is provided.\n */\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<ChromaVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (ids && filter) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'DELETE_VECTORS', 'MUTUALLY_EXCLUSIVE'),\n text: 'Cannot specify both ids and filter - they are mutually exclusive',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!ids && !filter) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'DELETE_VECTORS', 'NO_TARGET'),\n text: 'Either filter or ids must be provided',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate ids array is not empty\n if (ids && ids.length === 0) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'DELETE_VECTORS', 'EMPTY_IDS'),\n text: 'Cannot delete with empty ids array',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('CHROMA', 'DELETE_VECTORS', 'EMPTY_FILTER'),\n text: 'Cannot delete with empty filter object',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n const collection: Collection = await this.getCollection({ indexName });\n\n if (ids) {\n // Delete by IDs\n await collection.delete({ ids });\n } else if (filter) {\n // Delete by filter\n const translatedFilter = this.transformFilter(filter);\n await collection.delete({\n where: translatedFilter ?? undefined,\n });\n }\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('CHROMA', 'DELETE_VECTORS', 'FAILED'),\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(filter && { filter: JSON.stringify(filter) }),\n ...(ids && { idsCount: ids.length }),\n },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Chroma Vector.\n */\nexport const CHROMA_PROMPT = `When querying Chroma, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nRestrictions:\n- Regex patterns are not supported\n- Element operators are not supported\n- Only $and and $or logical operators are supported\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Empty arrays in $in/$nin will return no results\n- If multiple top-level fields exist, they're wrapped in $and\n- Only logical operators ($and, $or) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$in\": [...] }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"$or\": [\n { \"inStock\": true },\n { \"preorder\": true }\n ]}\n ]\n}`;\n"]}
|
package/dist/vector/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MastraVector } from '@mastra/core/vector';
|
|
2
2
|
import type { QueryResult, IndexStats, CreateIndexParams, UpsertVectorParams, QueryVectorParams, DescribeIndexParams, DeleteIndexParams, DeleteVectorParams, UpdateVectorParams, DeleteVectorsParams } from '@mastra/core/vector';
|
|
3
|
-
import type { ChromaClientArgs, Where, WhereDocument, Collection, Metadata } from 'chromadb';
|
|
3
|
+
import type { ChromaClientArgs, Where, WhereDocument, Collection, Metadata, Search } from 'chromadb';
|
|
4
4
|
import type { ChromaVectorFilter } from './filter.js';
|
|
5
5
|
interface ChromaUpsertVectorParams extends UpsertVectorParams {
|
|
6
6
|
documents?: string[];
|
|
@@ -35,6 +35,10 @@ export declare class ChromaVector extends MastraVector<ChromaVectorFilter> {
|
|
|
35
35
|
createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
|
|
36
36
|
transformFilter(filter?: ChromaVectorFilter): Where | undefined;
|
|
37
37
|
query<T extends Metadata = Metadata>({ indexName, queryVector, topK, filter, includeVector, documentFilter, }: ChromaQueryVectorParams): Promise<QueryResult[]>;
|
|
38
|
+
hybridSearch({ indexName, search }: {
|
|
39
|
+
indexName: string;
|
|
40
|
+
search: Search;
|
|
41
|
+
}): Promise<QueryResult[]>;
|
|
38
42
|
get<T extends Metadata = Metadata>({ indexName, ids, filter, includeVector, documentFilter, offset, limit, }: ChromaGetRecordsParams): Promise<{
|
|
39
43
|
id: string;
|
|
40
44
|
document: string | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,qB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OAAO,CAAC,IAAI,CAAC;IAsHtG,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBxE;;;;;;;OAOG;IACG,aAAa,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,mBAAmB,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CA0ExG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/chroma",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"description": "Chroma vector store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"chromadb": "^3.
|
|
23
|
+
"chromadb": "^3.1.6"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@microsoft/api-extractor": "^7.52.8",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"tsup": "^8.5.0",
|
|
32
32
|
"typescript": "^5.8.3",
|
|
33
33
|
"vitest": "4.0.12",
|
|
34
|
-
"@internal/storage-test-utils": "0.0.49",
|
|
35
34
|
"@internal/lint": "0.0.53",
|
|
36
|
-
"@internal/
|
|
37
|
-
"@mastra/core": "1.0.0-beta.
|
|
35
|
+
"@internal/storage-test-utils": "0.0.49",
|
|
36
|
+
"@mastra/core": "1.0.0-beta.11",
|
|
37
|
+
"@internal/types-builder": "0.0.28"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|