@mastra/chroma 0.0.0-taofeeqInngest-20250603090617 → 0.0.0-transpile-packages-20250724123433

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 CHANGED
@@ -1,6 +1,155 @@
1
1
  # @mastra/chroma
2
2
 
3
- ## 0.0.0-taofeeqInngest-20250603090617
3
+ ## 0.0.0-transpile-packages-20250724123433
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [f248d53]
8
+ - Updated dependencies [2affc57]
9
+ - Updated dependencies [66e13e3]
10
+ - Updated dependencies [18344d7]
11
+ - Updated dependencies [40c2525]
12
+ - Updated dependencies [e473f27]
13
+ - Updated dependencies [703ac71]
14
+ - Updated dependencies [a723d69]
15
+ - Updated dependencies [7827943]
16
+ - Updated dependencies [5889a31]
17
+ - Updated dependencies [bf1e7e7]
18
+ - Updated dependencies [4933192]
19
+ - Updated dependencies [d1c77a4]
20
+ - Updated dependencies [dcd4802]
21
+ - Updated dependencies [cbddd18]
22
+ - Updated dependencies [7ba91fa]
23
+ - @mastra/core@0.0.0-transpile-packages-20250724123433
24
+
25
+ ## 0.11.0
26
+
27
+ ### Minor Changes
28
+
29
+ - 8a3bfd2: Update peerdeps to latest core
30
+
31
+ ### Patch Changes
32
+
33
+ - 144eb0b: [MASTRA-3669] Metadata Filter Types
34
+ - 0e17048: Throw mastra errors in storage packages
35
+ - Updated dependencies [15e9d26]
36
+ - Updated dependencies [d1baedb]
37
+ - Updated dependencies [d8f2d19]
38
+ - Updated dependencies [4d21bf2]
39
+ - Updated dependencies [07d6d88]
40
+ - Updated dependencies [9d52b17]
41
+ - Updated dependencies [2097952]
42
+ - Updated dependencies [792c4c0]
43
+ - Updated dependencies [5d74aab]
44
+ - Updated dependencies [a8b194f]
45
+ - Updated dependencies [4fb0cc2]
46
+ - Updated dependencies [d2a7a31]
47
+ - Updated dependencies [502fe05]
48
+ - Updated dependencies [144eb0b]
49
+ - Updated dependencies [8ba1b51]
50
+ - Updated dependencies [4efcfa0]
51
+ - Updated dependencies [0e17048]
52
+ - @mastra/core@0.10.7
53
+
54
+ ## 0.11.0-alpha.2
55
+
56
+ ### Minor Changes
57
+
58
+ - 8a3bfd2: Update peerdeps to latest core
59
+
60
+ ### Patch Changes
61
+
62
+ - Updated dependencies [792c4c0]
63
+ - Updated dependencies [502fe05]
64
+ - Updated dependencies [4efcfa0]
65
+ - @mastra/core@0.10.7-alpha.3
66
+
67
+ ## 0.10.4-alpha.1
68
+
69
+ ### Patch Changes
70
+
71
+ - 144eb0b: [MASTRA-3669] Metadata Filter Types
72
+ - Updated dependencies [15e9d26]
73
+ - Updated dependencies [07d6d88]
74
+ - Updated dependencies [5d74aab]
75
+ - Updated dependencies [144eb0b]
76
+ - @mastra/core@0.10.7-alpha.2
77
+
78
+ ## 0.10.4-alpha.0
79
+
80
+ ### Patch Changes
81
+
82
+ - 0e17048: Throw mastra errors in storage packages
83
+ - Updated dependencies [d1baedb]
84
+ - Updated dependencies [4d21bf2]
85
+ - Updated dependencies [2097952]
86
+ - Updated dependencies [4fb0cc2]
87
+ - Updated dependencies [d2a7a31]
88
+ - Updated dependencies [0e17048]
89
+ - @mastra/core@0.10.7-alpha.1
90
+
91
+ ## 0.10.3
92
+
93
+ ### Patch Changes
94
+
95
+ - 63f6b7d: dependencies updates:
96
+ - Updated dependency [`chromadb@^2.4.6` ↗︎](https://www.npmjs.com/package/chromadb/v/2.4.6) (from `^2.2.0`, in `dependencies`)
97
+ - Updated dependencies [63f6b7d]
98
+ - Updated dependencies [12a95fc]
99
+ - Updated dependencies [4b0f8a6]
100
+ - Updated dependencies [51264a5]
101
+ - Updated dependencies [8e6f677]
102
+ - Updated dependencies [d70c420]
103
+ - Updated dependencies [ee9af57]
104
+ - Updated dependencies [36f1c36]
105
+ - Updated dependencies [2a16996]
106
+ - Updated dependencies [10d352e]
107
+ - Updated dependencies [9589624]
108
+ - Updated dependencies [53d3c37]
109
+ - Updated dependencies [751c894]
110
+ - Updated dependencies [577ce3a]
111
+ - Updated dependencies [9260b3a]
112
+ - @mastra/core@0.10.6
113
+
114
+ ## 0.10.3-alpha.0
115
+
116
+ ### Patch Changes
117
+
118
+ - 63f6b7d: dependencies updates:
119
+ - Updated dependency [`chromadb@^2.4.6` ↗︎](https://www.npmjs.com/package/chromadb/v/2.4.6) (from `^2.2.0`, in `dependencies`)
120
+ - Updated dependencies [63f6b7d]
121
+ - Updated dependencies [36f1c36]
122
+ - Updated dependencies [10d352e]
123
+ - Updated dependencies [53d3c37]
124
+ - @mastra/core@0.10.6-alpha.0
125
+
126
+ ## 0.10.2
127
+
128
+ ### Patch Changes
129
+
130
+ - 66f4424: Update peerdeps
131
+ - Updated dependencies [d1ed912]
132
+ - Updated dependencies [f6fd25f]
133
+ - Updated dependencies [dffb67b]
134
+ - Updated dependencies [f1f1f1b]
135
+ - Updated dependencies [925ab94]
136
+ - Updated dependencies [f9816ae]
137
+ - Updated dependencies [82090c1]
138
+ - Updated dependencies [1b443fd]
139
+ - Updated dependencies [ce97900]
140
+ - Updated dependencies [f1309d3]
141
+ - Updated dependencies [14a2566]
142
+ - Updated dependencies [f7f8293]
143
+ - Updated dependencies [48eddb9]
144
+ - @mastra/core@0.10.4
145
+
146
+ ## 0.10.2-alpha.0
147
+
148
+ ### Patch Changes
149
+
150
+ - 66f4424: Update peerdeps
151
+
152
+ ## 0.10.1
4
153
 
5
154
  ### Patch Changes
6
155
 
@@ -10,12 +159,19 @@
10
159
  - Updated dependencies [e5dc18d]
11
160
  - Updated dependencies [ab5adbe]
12
161
  - Updated dependencies [1e8bb40]
162
+ - Updated dependencies [1b5fc55]
13
163
  - Updated dependencies [195c428]
14
164
  - Updated dependencies [f73e11b]
165
+ - Updated dependencies [37643b8]
166
+ - Updated dependencies [99fd6cf]
15
167
  - Updated dependencies [c5bf1ce]
168
+ - Updated dependencies [add596e]
169
+ - Updated dependencies [8dc94d8]
170
+ - Updated dependencies [ecebbeb]
171
+ - Updated dependencies [79d5145]
16
172
  - Updated dependencies [12b7002]
17
173
  - Updated dependencies [2901125]
18
- - @mastra/core@0.0.0-taofeeqInngest-20250603090617
174
+ - @mastra/core@0.10.2
19
175
 
20
176
  ## 0.10.1-alpha.0
21
177
 
@@ -1233,7 +1389,6 @@
1233
1389
  ### Minor Changes
1234
1390
 
1235
1391
  - 684d5d1: Move Chroma package from `@mastra/vector-chroma` to `@mastra/chroma`.
1236
-
1237
1392
  - Move package to `stores/chroma`
1238
1393
  - Reorganize source files into `src/vector`
1239
1394
  - Add deprecation notice to old package
@@ -1567,7 +1722,6 @@
1567
1722
  ### Minor Changes
1568
1723
 
1569
1724
  - 684d5d1: Move Chroma package from `@mastra/vector-chroma` to `@mastra/chroma`.
1570
-
1571
1725
  - Move package to `stores/chroma`
1572
1726
  - Reorganize source files into `src/vector`
1573
1727
  - Add deprecation notice to old package
package/LICENSE.md CHANGED
@@ -1,7 +1,15 @@
1
- Copyright 2025 Mastra AI, Inc.
1
+ # Apache License 2.0
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ Copyright (c) 2025 Kepler Software, Inc.
4
4
 
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
6
8
 
7
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
@@ -1,11 +1,14 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
+ import type { BlacklistedRootOperators } from '@mastra/core/vector/filter';
2
3
  import type { CreateIndexParams } from '@mastra/core/vector';
3
4
  import type { DeleteIndexParams } from '@mastra/core/vector';
4
5
  import type { DeleteVectorParams } from '@mastra/core/vector';
5
6
  import type { DescribeIndexParams } from '@mastra/core/vector';
6
7
  import type { IndexStats } from '@mastra/core/vector';
8
+ import type { LogicalOperatorValueMap } from '@mastra/core/vector/filter';
7
9
  import { MastraVector } from '@mastra/core/vector';
8
10
  import type { OperatorSupport } from '@mastra/core/vector/filter';
11
+ import type { OperatorValueMap } from '@mastra/core/vector/filter';
9
12
  import type { QueryResult } from '@mastra/core/vector';
10
13
  import type { QueryVectorParams } from '@mastra/core/vector';
11
14
  import type { UpdateVectorParams } from '@mastra/core/vector';
@@ -20,27 +23,37 @@ declare const CHROMA_PROMPT = "When querying Chroma, you can ONLY use the operat
20
23
  export { CHROMA_PROMPT }
21
24
  export { CHROMA_PROMPT as CHROMA_PROMPT_alias_1 }
22
25
 
26
+ declare type ChromaBlacklisted = BlacklistedRootOperators | '$nor' | '$not';
27
+
28
+ declare type ChromaDocumentBlacklisted = Exclude<ChromaBlacklisted, '$contains'>;
29
+
30
+ declare type ChromaDocumentOperatorValueMap = ChromaOperatorValueMap;
31
+
23
32
  /**
24
33
  * Translator for Chroma filter queries.
25
34
  * Maintains MongoDB-compatible syntax while ensuring proper validation
26
35
  * and normalization of values.
27
36
  */
28
- export declare class ChromaFilterTranslator extends BaseFilterTranslator {
37
+ export declare class ChromaFilterTranslator extends BaseFilterTranslator<ChromaVectorFilter> {
29
38
  protected getSupportedOperators(): OperatorSupport;
30
- translate(filter?: VectorFilter): VectorFilter;
39
+ translate(filter?: ChromaVectorFilter): ChromaVectorFilter;
31
40
  private translateNode;
32
41
  private translateOperator;
33
42
  }
34
43
 
35
- declare interface ChromaQueryVectorParams extends QueryVectorParams {
36
- documentFilter?: VectorFilter;
44
+ declare type ChromaLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not'>;
45
+
46
+ declare type ChromaOperatorValueMap = Omit<OperatorValueMap, '$exists' | '$elemMatch' | '$regex' | '$options'>;
47
+
48
+ declare interface ChromaQueryVectorParams extends QueryVectorParams<ChromaVectorFilter> {
49
+ documentFilter?: ChromaVectorDocumentFilter;
37
50
  }
38
51
 
39
52
  declare interface ChromaUpsertVectorParams extends UpsertVectorParams {
40
53
  documents?: string[];
41
54
  }
42
55
 
43
- declare class ChromaVector extends MastraVector {
56
+ declare class ChromaVector extends MastraVector<ChromaVectorFilter> {
44
57
  private client;
45
58
  private collections;
46
59
  constructor({ path, auth, }: {
@@ -55,7 +68,7 @@ declare class ChromaVector extends MastraVector {
55
68
  upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]>;
56
69
  private HnswSpaceMap;
57
70
  createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
58
- transformFilter(filter?: VectorFilter): VectorFilter;
71
+ transformFilter(filter?: ChromaVectorFilter): ChromaVectorFilter;
59
72
  query({ indexName, queryVector, topK, filter, includeVector, documentFilter, }: ChromaQueryVectorParams): Promise<QueryResult[]>;
60
73
  listIndexes(): Promise<string[]>;
61
74
  /**
@@ -77,16 +90,13 @@ declare class ChromaVector extends MastraVector {
77
90
  * @throws Will throw an error if no updates are provided or if the update operation fails.
78
91
  */
79
92
  updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
80
- /**
81
- * Deletes a vector by its ID.
82
- * @param indexName - The name of the index containing the vector.
83
- * @param id - The ID of the vector to delete.
84
- * @returns A promise that resolves when the deletion is complete.
85
- * @throws Will throw an error if the deletion operation fails.
86
- */
87
93
  deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
88
94
  }
89
95
  export { ChromaVector }
90
96
  export { ChromaVector as ChromaVector_alias_1 }
91
97
 
98
+ export declare type ChromaVectorDocumentFilter = VectorFilter<keyof ChromaDocumentOperatorValueMap, ChromaDocumentOperatorValueMap, ChromaLogicalOperatorValueMap, ChromaDocumentBlacklisted>;
99
+
100
+ export declare type ChromaVectorFilter = VectorFilter<keyof ChromaOperatorValueMap, ChromaOperatorValueMap, ChromaLogicalOperatorValueMap, ChromaBlacklisted>;
101
+
92
102
  export { }
@@ -1,11 +1,14 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
+ import type { BlacklistedRootOperators } from '@mastra/core/vector/filter';
2
3
  import type { CreateIndexParams } from '@mastra/core/vector';
3
4
  import type { DeleteIndexParams } from '@mastra/core/vector';
4
5
  import type { DeleteVectorParams } from '@mastra/core/vector';
5
6
  import type { DescribeIndexParams } from '@mastra/core/vector';
6
7
  import type { IndexStats } from '@mastra/core/vector';
8
+ import type { LogicalOperatorValueMap } from '@mastra/core/vector/filter';
7
9
  import { MastraVector } from '@mastra/core/vector';
8
10
  import type { OperatorSupport } from '@mastra/core/vector/filter';
11
+ import type { OperatorValueMap } from '@mastra/core/vector/filter';
9
12
  import type { QueryResult } from '@mastra/core/vector';
10
13
  import type { QueryVectorParams } from '@mastra/core/vector';
11
14
  import type { UpdateVectorParams } from '@mastra/core/vector';
@@ -20,27 +23,37 @@ declare const CHROMA_PROMPT = "When querying Chroma, you can ONLY use the operat
20
23
  export { CHROMA_PROMPT }
21
24
  export { CHROMA_PROMPT as CHROMA_PROMPT_alias_1 }
22
25
 
26
+ declare type ChromaBlacklisted = BlacklistedRootOperators | '$nor' | '$not';
27
+
28
+ declare type ChromaDocumentBlacklisted = Exclude<ChromaBlacklisted, '$contains'>;
29
+
30
+ declare type ChromaDocumentOperatorValueMap = ChromaOperatorValueMap;
31
+
23
32
  /**
24
33
  * Translator for Chroma filter queries.
25
34
  * Maintains MongoDB-compatible syntax while ensuring proper validation
26
35
  * and normalization of values.
27
36
  */
28
- export declare class ChromaFilterTranslator extends BaseFilterTranslator {
37
+ export declare class ChromaFilterTranslator extends BaseFilterTranslator<ChromaVectorFilter> {
29
38
  protected getSupportedOperators(): OperatorSupport;
30
- translate(filter?: VectorFilter): VectorFilter;
39
+ translate(filter?: ChromaVectorFilter): ChromaVectorFilter;
31
40
  private translateNode;
32
41
  private translateOperator;
33
42
  }
34
43
 
35
- declare interface ChromaQueryVectorParams extends QueryVectorParams {
36
- documentFilter?: VectorFilter;
44
+ declare type ChromaLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not'>;
45
+
46
+ declare type ChromaOperatorValueMap = Omit<OperatorValueMap, '$exists' | '$elemMatch' | '$regex' | '$options'>;
47
+
48
+ declare interface ChromaQueryVectorParams extends QueryVectorParams<ChromaVectorFilter> {
49
+ documentFilter?: ChromaVectorDocumentFilter;
37
50
  }
38
51
 
39
52
  declare interface ChromaUpsertVectorParams extends UpsertVectorParams {
40
53
  documents?: string[];
41
54
  }
42
55
 
43
- declare class ChromaVector extends MastraVector {
56
+ declare class ChromaVector extends MastraVector<ChromaVectorFilter> {
44
57
  private client;
45
58
  private collections;
46
59
  constructor({ path, auth, }: {
@@ -55,7 +68,7 @@ declare class ChromaVector extends MastraVector {
55
68
  upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]>;
56
69
  private HnswSpaceMap;
57
70
  createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
58
- transformFilter(filter?: VectorFilter): VectorFilter;
71
+ transformFilter(filter?: ChromaVectorFilter): ChromaVectorFilter;
59
72
  query({ indexName, queryVector, topK, filter, includeVector, documentFilter, }: ChromaQueryVectorParams): Promise<QueryResult[]>;
60
73
  listIndexes(): Promise<string[]>;
61
74
  /**
@@ -77,16 +90,13 @@ declare class ChromaVector extends MastraVector {
77
90
  * @throws Will throw an error if no updates are provided or if the update operation fails.
78
91
  */
79
92
  updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
80
- /**
81
- * Deletes a vector by its ID.
82
- * @param indexName - The name of the index containing the vector.
83
- * @param id - The ID of the vector to delete.
84
- * @returns A promise that resolves when the deletion is complete.
85
- * @throws Will throw an error if the deletion operation fails.
86
- */
87
93
  deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
88
94
  }
89
95
  export { ChromaVector }
90
96
  export { ChromaVector as ChromaVector_alias_1 }
91
97
 
98
+ export declare type ChromaVectorDocumentFilter = VectorFilter<keyof ChromaDocumentOperatorValueMap, ChromaDocumentOperatorValueMap, ChromaLogicalOperatorValueMap, ChromaDocumentBlacklisted>;
99
+
100
+ export declare type ChromaVectorFilter = VectorFilter<keyof ChromaOperatorValueMap, ChromaOperatorValueMap, ChromaLogicalOperatorValueMap, ChromaBlacklisted>;
101
+
92
102
  export { }
package/dist/index.cjs CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var error = require('@mastra/core/error');
3
4
  var vector = require('@mastra/core/vector');
4
5
  var chromadb = require('chromadb');
5
6
  var filter = require('@mastra/core/vector/filter');
@@ -125,18 +126,31 @@ var ChromaVector = class extends vector.MastraVector {
125
126
  }
126
127
  }
127
128
  async upsert({ indexName, vectors, metadata, ids, documents }) {
128
- const collection = await this.getCollection(indexName);
129
- const stats = await this.describeIndex({ indexName });
130
- this.validateVectorDimensions(vectors, stats.dimension);
131
- const generatedIds = ids || vectors.map(() => crypto.randomUUID());
132
- const normalizedMetadata = metadata || vectors.map(() => ({}));
133
- await collection.upsert({
134
- ids: generatedIds,
135
- embeddings: vectors,
136
- metadatas: normalizedMetadata,
137
- documents
138
- });
139
- return generatedIds;
129
+ try {
130
+ const collection = await this.getCollection(indexName);
131
+ const stats = await this.describeIndex({ indexName });
132
+ this.validateVectorDimensions(vectors, stats.dimension);
133
+ const generatedIds = ids || vectors.map(() => crypto.randomUUID());
134
+ const normalizedMetadata = metadata || vectors.map(() => ({}));
135
+ await collection.upsert({
136
+ ids: generatedIds,
137
+ embeddings: vectors,
138
+ metadatas: normalizedMetadata,
139
+ documents
140
+ });
141
+ return generatedIds;
142
+ } catch (error$1) {
143
+ if (error$1 instanceof error.MastraError) throw error$1;
144
+ throw new error.MastraError(
145
+ {
146
+ id: "CHROMA_VECTOR_UPSERT_FAILED",
147
+ domain: error.ErrorDomain.MASTRA_VECTOR,
148
+ category: error.ErrorCategory.THIRD_PARTY,
149
+ details: { indexName }
150
+ },
151
+ error$1
152
+ );
153
+ }
140
154
  }
141
155
  HnswSpaceMap = {
142
156
  cosine: "cosine",
@@ -147,11 +161,23 @@ var ChromaVector = class extends vector.MastraVector {
147
161
  };
148
162
  async createIndex({ indexName, dimension, metric = "cosine" }) {
149
163
  if (!Number.isInteger(dimension) || dimension <= 0) {
150
- throw new Error("Dimension must be a positive integer");
164
+ throw new error.MastraError({
165
+ id: "CHROMA_VECTOR_CREATE_INDEX_INVALID_DIMENSION",
166
+ text: "Dimension must be a positive integer",
167
+ domain: error.ErrorDomain.MASTRA_VECTOR,
168
+ category: error.ErrorCategory.USER,
169
+ details: { dimension }
170
+ });
151
171
  }
152
172
  const hnswSpace = this.HnswSpaceMap[metric];
153
- if (!["cosine", "l2", "ip"].includes(hnswSpace)) {
154
- throw new Error(`Invalid metric: "${metric}". Must be one of: cosine, euclidean, dotproduct`);
173
+ if (!hnswSpace || !["cosine", "l2", "ip"].includes(hnswSpace)) {
174
+ throw new error.MastraError({
175
+ id: "CHROMA_VECTOR_CREATE_INDEX_INVALID_METRIC",
176
+ text: `Invalid metric: "${metric}". Must be one of: cosine, euclidean, dotproduct`,
177
+ domain: error.ErrorDomain.MASTRA_VECTOR,
178
+ category: error.ErrorCategory.USER,
179
+ details: { metric }
180
+ });
155
181
  }
156
182
  try {
157
183
  await this.client.createCollection({
@@ -161,13 +187,21 @@ var ChromaVector = class extends vector.MastraVector {
161
187
  "hnsw:space": hnswSpace
162
188
  }
163
189
  });
164
- } catch (error) {
165
- const message = error?.message || error?.toString();
190
+ } catch (error$1) {
191
+ const message = error$1?.message || error$1?.toString();
166
192
  if (message && message.toLowerCase().includes("already exists")) {
167
193
  await this.validateExistingIndex(indexName, dimension, metric);
168
194
  return;
169
195
  }
170
- throw error;
196
+ throw new error.MastraError(
197
+ {
198
+ id: "CHROMA_VECTOR_CREATE_INDEX_FAILED",
199
+ domain: error.ErrorDomain.MASTRA_VECTOR,
200
+ category: error.ErrorCategory.THIRD_PARTY,
201
+ details: { indexName }
202
+ },
203
+ error$1
204
+ );
171
205
  }
172
206
  }
173
207
  transformFilter(filter) {
@@ -182,27 +216,51 @@ var ChromaVector = class extends vector.MastraVector {
182
216
  includeVector = false,
183
217
  documentFilter
184
218
  }) {
185
- const collection = await this.getCollection(indexName, true);
186
- const defaultInclude = ["documents", "metadatas", "distances"];
187
- const translatedFilter = this.transformFilter(filter);
188
- const results = await collection.query({
189
- queryEmbeddings: [queryVector],
190
- nResults: topK,
191
- where: translatedFilter,
192
- whereDocument: documentFilter,
193
- include: includeVector ? [...defaultInclude, "embeddings"] : defaultInclude
194
- });
195
- return (results.ids[0] || []).map((id, index) => ({
196
- id,
197
- score: results.distances?.[0]?.[index] || 0,
198
- metadata: results.metadatas?.[0]?.[index] || {},
199
- document: results.documents?.[0]?.[index],
200
- ...includeVector && { vector: results.embeddings?.[0]?.[index] || [] }
201
- }));
219
+ try {
220
+ const collection = await this.getCollection(indexName, true);
221
+ const defaultInclude = ["documents", "metadatas", "distances"];
222
+ const translatedFilter = this.transformFilter(filter);
223
+ const results = await collection.query({
224
+ queryEmbeddings: [queryVector],
225
+ nResults: topK,
226
+ where: translatedFilter,
227
+ whereDocument: documentFilter,
228
+ include: includeVector ? [...defaultInclude, "embeddings"] : defaultInclude
229
+ });
230
+ return (results.ids[0] || []).map((id, index) => ({
231
+ id,
232
+ score: results.distances?.[0]?.[index] || 0,
233
+ metadata: results.metadatas?.[0]?.[index] || {},
234
+ document: results.documents?.[0]?.[index],
235
+ ...includeVector && { vector: results.embeddings?.[0]?.[index] || [] }
236
+ }));
237
+ } catch (error$1) {
238
+ if (error$1 instanceof error.MastraError) throw error$1;
239
+ throw new error.MastraError(
240
+ {
241
+ id: "CHROMA_VECTOR_QUERY_FAILED",
242
+ domain: error.ErrorDomain.MASTRA_VECTOR,
243
+ category: error.ErrorCategory.THIRD_PARTY,
244
+ details: { indexName }
245
+ },
246
+ error$1
247
+ );
248
+ }
202
249
  }
203
250
  async listIndexes() {
204
- const collections = await this.client.listCollections();
205
- return collections.map((collection) => collection);
251
+ try {
252
+ const collections = await this.client.listCollections();
253
+ return collections.map((collection) => collection);
254
+ } catch (error$1) {
255
+ throw new error.MastraError(
256
+ {
257
+ id: "CHROMA_VECTOR_LIST_INDEXES_FAILED",
258
+ domain: error.ErrorDomain.MASTRA_VECTOR,
259
+ category: error.ErrorCategory.THIRD_PARTY
260
+ },
261
+ error$1
262
+ );
263
+ }
206
264
  }
207
265
  /**
208
266
  * Retrieves statistics about a vector index.
@@ -211,19 +269,44 @@ var ChromaVector = class extends vector.MastraVector {
211
269
  * @returns A promise that resolves to the index statistics including dimension, count and metric
212
270
  */
213
271
  async describeIndex({ indexName }) {
214
- const collection = await this.getCollection(indexName);
215
- const count = await collection.count();
216
- const metadata = collection.metadata;
217
- const hnswSpace = metadata?.["hnsw:space"];
218
- return {
219
- dimension: metadata?.dimension || 0,
220
- count,
221
- metric: this.HnswSpaceMap[hnswSpace]
222
- };
272
+ try {
273
+ const collection = await this.getCollection(indexName);
274
+ const count = await collection.count();
275
+ const metadata = collection.metadata;
276
+ const hnswSpace = metadata?.["hnsw:space"];
277
+ return {
278
+ dimension: metadata?.dimension || 0,
279
+ count,
280
+ metric: this.HnswSpaceMap[hnswSpace]
281
+ };
282
+ } catch (error$1) {
283
+ if (error$1 instanceof error.MastraError) throw error$1;
284
+ throw new error.MastraError(
285
+ {
286
+ id: "CHROMA_VECTOR_DESCRIBE_INDEX_FAILED",
287
+ domain: error.ErrorDomain.MASTRA_VECTOR,
288
+ category: error.ErrorCategory.THIRD_PARTY,
289
+ details: { indexName }
290
+ },
291
+ error$1
292
+ );
293
+ }
223
294
  }
224
295
  async deleteIndex({ indexName }) {
225
- await this.client.deleteCollection({ name: indexName });
226
- this.collections.delete(indexName);
296
+ try {
297
+ await this.client.deleteCollection({ name: indexName });
298
+ this.collections.delete(indexName);
299
+ } catch (error$1) {
300
+ throw new error.MastraError(
301
+ {
302
+ id: "CHROMA_VECTOR_DELETE_INDEX_FAILED",
303
+ domain: error.ErrorDomain.MASTRA_VECTOR,
304
+ category: error.ErrorCategory.THIRD_PARTY,
305
+ details: { indexName }
306
+ },
307
+ error$1
308
+ );
309
+ }
227
310
  }
228
311
  /**
229
312
  * Updates a vector by its ID with the provided vector and/or metadata.
@@ -236,10 +319,16 @@ var ChromaVector = class extends vector.MastraVector {
236
319
  * @throws Will throw an error if no updates are provided or if the update operation fails.
237
320
  */
238
321
  async updateVector({ indexName, id, update }) {
322
+ if (!update.vector && !update.metadata) {
323
+ throw new error.MastraError({
324
+ id: "CHROMA_VECTOR_UPDATE_NO_PAYLOAD",
325
+ text: "No updates provided for vector",
326
+ domain: error.ErrorDomain.MASTRA_VECTOR,
327
+ category: error.ErrorCategory.USER,
328
+ details: { indexName, id }
329
+ });
330
+ }
239
331
  try {
240
- if (!update.vector && !update.metadata) {
241
- throw new Error("No updates provided");
242
- }
243
332
  const collection = await this.getCollection(indexName, true);
244
333
  const updateOptions = { ids: [id] };
245
334
  if (update?.vector) {
@@ -251,23 +340,34 @@ var ChromaVector = class extends vector.MastraVector {
251
340
  updateOptions.metadatas = [update.metadata];
252
341
  }
253
342
  return await collection.update(updateOptions);
254
- } catch (error) {
255
- throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
343
+ } catch (error$1) {
344
+ if (error$1 instanceof error.MastraError) throw error$1;
345
+ throw new error.MastraError(
346
+ {
347
+ id: "CHROMA_VECTOR_UPDATE_FAILED",
348
+ domain: error.ErrorDomain.MASTRA_VECTOR,
349
+ category: error.ErrorCategory.THIRD_PARTY,
350
+ details: { indexName, id }
351
+ },
352
+ error$1
353
+ );
256
354
  }
257
355
  }
258
- /**
259
- * Deletes a vector by its ID.
260
- * @param indexName - The name of the index containing the vector.
261
- * @param id - The ID of the vector to delete.
262
- * @returns A promise that resolves when the deletion is complete.
263
- * @throws Will throw an error if the deletion operation fails.
264
- */
265
356
  async deleteVector({ indexName, id }) {
266
357
  try {
267
358
  const collection = await this.getCollection(indexName, true);
268
359
  await collection.delete({ ids: [id] });
269
- } catch (error) {
270
- throw new Error(`Failed to delete vector by id: ${id} for index name: ${indexName}: ${error.message}`);
360
+ } catch (error$1) {
361
+ if (error$1 instanceof error.MastraError) throw error$1;
362
+ throw new error.MastraError(
363
+ {
364
+ id: "CHROMA_VECTOR_DELETE_FAILED",
365
+ domain: error.ErrorDomain.MASTRA_VECTOR,
366
+ category: error.ErrorCategory.THIRD_PARTY,
367
+ details: { indexName, id }
368
+ },
369
+ error$1
370
+ );
271
371
  }
272
372
  }
273
373
  };