@mastra/chroma 0.0.0-tool-call-parts-20250630193309 → 0.0.0-tool-list-type-20250910134057

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,19 +1,262 @@
1
1
  # @mastra/chroma
2
2
 
3
- ## 0.0.0-tool-call-parts-20250630193309
3
+ ## 0.0.0-tool-list-type-20250910134057
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`d34aaa1`](https://github.com/mastra-ai/mastra/commit/d34aaa1da5d3c5f991740f59e2fe6d28d3e2dd91), [`b2babfa`](https://github.com/mastra-ai/mastra/commit/b2babfa9e75b22f2759179e71d8473f6dc5421ed), [`d8c3ba5`](https://github.com/mastra-ai/mastra/commit/d8c3ba516f4173282d293f7e64769cfc8738d360), [`a66a371`](https://github.com/mastra-ai/mastra/commit/a66a3716b00553d7f01842be9deb34f720b10fab)]:
8
+ - @mastra/core@0.0.0-tool-list-type-20250910134057
9
+
10
+ ## 0.11.8
11
+
12
+ ### Patch Changes
13
+
14
+ - 1483200: dependencies updates:
15
+ - Updated dependency [`chromadb@^3.0.14` ↗︎](https://www.npmjs.com/package/chromadb/v/3.0.14) (from `^3.0.11`, in `dependencies`)
16
+ - 376913a: Update peerdeps
17
+ - Updated dependencies [8fbf79e]
18
+ - Updated dependencies [fd83526]
19
+ - Updated dependencies [d0b90ab]
20
+ - Updated dependencies [6f5eb7a]
21
+ - Updated dependencies [a01cf14]
22
+ - Updated dependencies [a9e50ee]
23
+ - Updated dependencies [5397eb4]
24
+ - Updated dependencies [c9f4e4a]
25
+ - Updated dependencies [0acbc80]
26
+ - @mastra/core@0.16.0
27
+
28
+ ## 0.11.8-alpha.1
29
+
30
+ ### Patch Changes
31
+
32
+ - 376913a: Update peerdeps
33
+ - Updated dependencies [8fbf79e]
34
+ - @mastra/core@0.16.0-alpha.1
35
+
36
+ ## 0.11.8-alpha.0
37
+
38
+ ### Patch Changes
39
+
40
+ - 1483200: dependencies updates:
41
+ - Updated dependency [`chromadb@^3.0.14` ↗︎](https://www.npmjs.com/package/chromadb/v/3.0.14) (from `^3.0.11`, in `dependencies`)
42
+ - Updated dependencies [fd83526]
43
+ - Updated dependencies [d0b90ab]
44
+ - Updated dependencies [6f5eb7a]
45
+ - Updated dependencies [a01cf14]
46
+ - Updated dependencies [a9e50ee]
47
+ - Updated dependencies [5397eb4]
48
+ - Updated dependencies [c9f4e4a]
49
+ - Updated dependencies [0acbc80]
50
+ - @mastra/core@0.16.0-alpha.0
51
+
52
+ ## 0.11.7
53
+
54
+ ### Patch Changes
55
+
56
+ - de3cbc6: Update the `package.json` file to include additional fields like `repository`, `homepage` or `files`.
57
+ - f0dfcac: updated core peerdep
58
+ - Updated dependencies [ab48c97]
59
+ - Updated dependencies [85ef90b]
60
+ - Updated dependencies [aedbbfa]
61
+ - Updated dependencies [ff89505]
62
+ - Updated dependencies [637f323]
63
+ - Updated dependencies [de3cbc6]
64
+ - Updated dependencies [c19bcf7]
65
+ - Updated dependencies [4474d04]
66
+ - Updated dependencies [183dc95]
67
+ - Updated dependencies [a1111e2]
68
+ - Updated dependencies [b42a961]
69
+ - Updated dependencies [61debef]
70
+ - Updated dependencies [9beaeff]
71
+ - Updated dependencies [29de0e1]
72
+ - Updated dependencies [f643c65]
73
+ - Updated dependencies [00c74e7]
74
+ - Updated dependencies [fef7375]
75
+ - Updated dependencies [e3d8fea]
76
+ - Updated dependencies [45e4d39]
77
+ - Updated dependencies [9eee594]
78
+ - Updated dependencies [7149d8d]
79
+ - Updated dependencies [822c2e8]
80
+ - Updated dependencies [979912c]
81
+ - Updated dependencies [7dcf4c0]
82
+ - Updated dependencies [4106a58]
83
+ - Updated dependencies [ad78bfc]
84
+ - Updated dependencies [0302f50]
85
+ - Updated dependencies [6ac697e]
86
+ - Updated dependencies [74db265]
87
+ - Updated dependencies [0ce418a]
88
+ - Updated dependencies [af90672]
89
+ - Updated dependencies [8387952]
90
+ - Updated dependencies [7f3b8da]
91
+ - Updated dependencies [905352b]
92
+ - Updated dependencies [599d04c]
93
+ - Updated dependencies [56041d0]
94
+ - Updated dependencies [3412597]
95
+ - Updated dependencies [5eca5d2]
96
+ - Updated dependencies [f2cda47]
97
+ - Updated dependencies [5de1555]
98
+ - Updated dependencies [cfd377a]
99
+ - Updated dependencies [1ed5a3e]
100
+ - @mastra/core@0.15.3
101
+
102
+ ## 0.11.7-alpha.1
103
+
104
+ ### Patch Changes
105
+
106
+ - [#7394](https://github.com/mastra-ai/mastra/pull/7394) [`f0dfcac`](https://github.com/mastra-ai/mastra/commit/f0dfcac4458bdf789b975e2d63e984f5d1e7c4d3) Thanks [@NikAiyer](https://github.com/NikAiyer)! - updated core peerdep
107
+
108
+ - Updated dependencies [[`7149d8d`](https://github.com/mastra-ai/mastra/commit/7149d8d4bdc1edf0008e0ca9b7925eb0b8b60dbe)]:
109
+ - @mastra/core@0.15.3-alpha.7
110
+
111
+ ## 0.11.7-alpha.0
112
+
113
+ ### Patch Changes
114
+
115
+ - [#7343](https://github.com/mastra-ai/mastra/pull/7343) [`de3cbc6`](https://github.com/mastra-ai/mastra/commit/de3cbc61079211431bd30487982ea3653517278e) Thanks [@LekoArts](https://github.com/LekoArts)! - Update the `package.json` file to include additional fields like `repository`, `homepage` or `files`.
116
+
117
+ - Updated dependencies [[`85ef90b`](https://github.com/mastra-ai/mastra/commit/85ef90bb2cd4ae4df855c7ac175f7d392c55c1bf), [`de3cbc6`](https://github.com/mastra-ai/mastra/commit/de3cbc61079211431bd30487982ea3653517278e)]:
118
+ - @mastra/core@0.15.3-alpha.5
119
+
120
+ ## 0.11.6
121
+
122
+ ### Patch Changes
123
+
124
+ - [`c6113ed`](https://github.com/mastra-ai/mastra/commit/c6113ed7f9df297e130d94436ceee310273d6430) Thanks [@wardpeet](https://github.com/wardpeet)! - Fix peerdpes for @mastra/core
125
+
126
+ - Updated dependencies []:
127
+ - @mastra/core@0.15.2
128
+
129
+ ## 0.11.5
130
+
131
+ ### Patch Changes
132
+
133
+ - [`95b2aa9`](https://github.com/mastra-ai/mastra/commit/95b2aa908230919e67efcac0d69005a2d5745298) Thanks [@wardpeet](https://github.com/wardpeet)! - Fix peerdeps @mastra/core
134
+
135
+ - Updated dependencies []:
136
+ - @mastra/core@0.15.1
137
+
138
+ ## 0.11.4
139
+
140
+ ### Patch Changes
141
+
142
+ - 8660c1b: Updating Chroma integration and adding support for Chroma Cloud
143
+ - 03997ae: Update peerdeps
144
+ - Updated dependencies [227c7e6]
145
+ - Updated dependencies [12cae67]
146
+ - Updated dependencies [fd3a3eb]
147
+ - Updated dependencies [6faaee5]
148
+ - Updated dependencies [4232b14]
149
+ - Updated dependencies [a89de7e]
150
+ - Updated dependencies [5a37d0c]
151
+ - Updated dependencies [4bde0cb]
152
+ - Updated dependencies [cf4f357]
153
+ - Updated dependencies [ad888a2]
154
+ - Updated dependencies [481751d]
155
+ - Updated dependencies [2454423]
156
+ - Updated dependencies [194e395]
157
+ - Updated dependencies [a722c0b]
158
+ - Updated dependencies [c30bca8]
159
+ - Updated dependencies [3b5fec7]
160
+ - Updated dependencies [a8f129d]
161
+ - @mastra/core@0.14.0
162
+
163
+ ## 0.11.4-alpha.1
164
+
165
+ ### Patch Changes
166
+
167
+ - 03997ae: Update peerdeps
168
+ - @mastra/core@0.14.0-alpha.7
169
+
170
+ ## 0.11.4-alpha.0
171
+
172
+ ### Patch Changes
173
+
174
+ - 8660c1b: Updating Chroma integration and adding support for Chroma Cloud
175
+ - Updated dependencies [6faaee5]
176
+ - Updated dependencies [4232b14]
177
+ - Updated dependencies [a89de7e]
178
+ - Updated dependencies [cf4f357]
179
+ - Updated dependencies [a722c0b]
180
+ - Updated dependencies [3b5fec7]
181
+ - @mastra/core@0.14.0-alpha.1
182
+
183
+ ## 0.11.3
184
+
185
+ ### Patch Changes
186
+
187
+ - 4a406ec: fixes TypeScript declaration file imports to ensure proper ESM compatibility
188
+ - Updated dependencies [cb36de0]
189
+ - Updated dependencies [d0496e6]
190
+ - Updated dependencies [a82b851]
191
+ - Updated dependencies [ea0c5f2]
192
+ - Updated dependencies [41a0a0e]
193
+ - Updated dependencies [2871020]
194
+ - Updated dependencies [94f4812]
195
+ - Updated dependencies [e202b82]
196
+ - Updated dependencies [e00f6a0]
197
+ - Updated dependencies [4a406ec]
198
+ - Updated dependencies [b0e43c1]
199
+ - Updated dependencies [5d377e5]
200
+ - Updated dependencies [1fb812e]
201
+ - Updated dependencies [35c5798]
202
+ - @mastra/core@0.13.0
203
+
204
+ ## 0.11.3-alpha.0
205
+
206
+ ### Patch Changes
207
+
208
+ - 4a406ec: fixes TypeScript declaration file imports to ensure proper ESM compatibility
209
+ - Updated dependencies [cb36de0]
210
+ - Updated dependencies [a82b851]
211
+ - Updated dependencies [41a0a0e]
212
+ - Updated dependencies [2871020]
213
+ - Updated dependencies [4a406ec]
214
+ - Updated dependencies [5d377e5]
215
+ - @mastra/core@0.13.0-alpha.2
216
+
217
+ ## 0.11.2
218
+
219
+ ### Patch Changes
220
+
221
+ - f42c4c2: update peer deps for packages to latest core range
222
+ - Updated dependencies [510e2c8]
223
+ - Updated dependencies [2f72fb2]
224
+ - Updated dependencies [27cc97a]
225
+ - Updated dependencies [3f89307]
226
+ - Updated dependencies [9eda7d4]
227
+ - Updated dependencies [9d49408]
228
+ - Updated dependencies [41daa63]
229
+ - Updated dependencies [ad0a58b]
230
+ - Updated dependencies [254a36b]
231
+ - Updated dependencies [2ecf658]
232
+ - Updated dependencies [7a7754f]
233
+ - Updated dependencies [fc92d80]
234
+ - Updated dependencies [e0f73c6]
235
+ - Updated dependencies [0b89602]
236
+ - Updated dependencies [4d37822]
237
+ - Updated dependencies [23a6a7c]
238
+ - Updated dependencies [cda801d]
239
+ - Updated dependencies [a77c823]
240
+ - Updated dependencies [ff9c125]
241
+ - Updated dependencies [09bca64]
242
+ - Updated dependencies [b8efbb9]
243
+ - Updated dependencies [71466e7]
244
+ - Updated dependencies [0c99fbe]
245
+ - @mastra/core@0.12.0
246
+
247
+ ## 0.11.2-alpha.0
248
+
249
+ ### Patch Changes
250
+
251
+ - f42c4c2: update peer deps for packages to latest core range
252
+ - @mastra/core@0.12.0-alpha.5
253
+
254
+ ## 0.11.1
4
255
 
5
256
  ### Patch Changes
6
257
 
7
- - Updated dependencies [9dda1ac]
8
- - Updated dependencies [7e801dd]
9
- - Updated dependencies [7aa70a4]
10
- - Updated dependencies [764f86a]
11
- - Updated dependencies [1760a1c]
12
- - Updated dependencies [7dda16a]
13
- - Updated dependencies [d80069a]
14
- - Updated dependencies [57929df]
15
- - Updated dependencies [6320a61]
16
- - @mastra/core@0.0.0-tool-call-parts-20250630193309
258
+ - ce088f5: Update all peerdeps to latest core
259
+ - @mastra/core@0.11.1
17
260
 
18
261
  ## 0.11.0
19
262
 
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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @mastra/chroma
2
2
 
3
- Vector store implementation for ChromaDB using the official chromadb client with added dimension validation, collection management, and document storage capabilities.
3
+ Vector store implementation for Chroma using the official `chromadb` client with added dimension validation, collection management, and document storage capabilities.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,18 +8,56 @@ Vector store implementation for ChromaDB using the official chromadb client with
8
8
  npm install @mastra/chroma
9
9
  ```
10
10
 
11
- ## Usage
11
+ ## Instantiation
12
+
13
+ ### Local or Self-Deployments
14
+
15
+ To run a Chroma server, use the [Chroma CLI](https://docs.trychroma.com/docs/cli/db). It is available to you when you install this package.
16
+
17
+ ```shell
18
+ chroma run
19
+ ```
20
+
21
+ You will now have a Chroma server running on `localhost:8000`.
22
+
23
+ ```typescript
24
+ import { ChromaVector } from '@mastra/chroma';
25
+
26
+ const vectorStore = new ChromaVector();
27
+ ```
28
+
29
+ If you run a Chroma server locally with a different configuration, or [deploy](https://docs.trychroma.com/guides/deploy/client-server-mode) a Chroma server yourself, you can configure your `ChromaVector` instantiation with specific connection details:
30
+
31
+ ```typescript
32
+ import { ChromaVector } from '@mastra/chroma';
33
+
34
+ const vectorStore = new ChromaVector({
35
+ host: 'your-host-address',
36
+ port: 8000,
37
+ ssl: false,
38
+ headers: {}, // any HTTP headers to send,
39
+ });
40
+ ```
41
+
42
+ ### Chroma Cloud
43
+
44
+ Provide your Chroma Cloud API key, tenant, and database.
45
+
46
+ You can use the [Chroma CLI](https://docs.trychroma.com/docs/cli/db) to set these as environment variables: `chroma db connect [DB-NAME] --env-file`.
12
47
 
13
48
  ```typescript
14
49
  import { ChromaVector } from '@mastra/chroma';
15
50
 
16
51
  const vectorStore = new ChromaVector({
17
- path: 'http://localhost:8000', // ChromaDB server URL
18
- auth: { // Optional authentication
19
- provider: 'token',
20
- credentials: 'your-token'
21
- }
52
+ apiKey: process.env.CHROMA_API_KEY,
53
+ tenant: process.env.CHROMA_TENANT,
54
+ database: process.env.CHROMA_DATABASE,
22
55
  });
56
+ ```
57
+
58
+ ## Usage
59
+
60
+ ```typescript
23
61
 
24
62
  // Create a new collection
25
63
  await vectorStore.createIndex({ indexName: 'myCollection', dimension: 1536, metric: 'cosine' });
@@ -46,18 +84,6 @@ const results = await vectorStore.query({
46
84
  });
47
85
  ```
48
86
 
49
- ## Configuration
50
-
51
- Required:
52
-
53
- - `path`: URL of your ChromaDB server
54
-
55
- Optional:
56
-
57
- - `auth`: Authentication configuration
58
- - `provider`: Authentication provider
59
- - `credentials`: Authentication credentials
60
-
61
87
  ## Features
62
88
 
63
89
  - Vector similarity search with cosine, euclidean, and dot product metrics
@@ -92,5 +118,5 @@ Query results include:
92
118
 
93
119
  ## Related Links
94
120
 
95
- - [ChromaDB Documentation](https://docs.trychroma.com/)
96
- - [ChromaDB API Reference](https://docs.trychroma.com/api/client)
121
+ - [Chroma Documentation](https://docs.trychroma.com/)
122
+ - [Chroma API Reference](https://docs.trychroma.com/api/client)
package/dist/index.cjs CHANGED
@@ -24,7 +24,7 @@ var ChromaFilterTranslator = class extends filter.BaseFilterTranslator {
24
24
  }
25
25
  translateNode(node, currentPath = "") {
26
26
  if (this.isRegex(node)) {
27
- throw new Error("Regex is not supported in Chroma");
27
+ throw new Error("Regex is supported in Chroma via the `documentFilter` argument");
28
28
  }
29
29
  if (this.isPrimitive(node)) return this.normalizeComparisonValue(node);
30
30
  if (Array.isArray(node)) return { $in: this.normalizeArrayValues(node) };
@@ -33,6 +33,9 @@ var ChromaFilterTranslator = class extends filter.BaseFilterTranslator {
33
33
  if (entries.length === 1 && firstEntry && this.isOperator(firstEntry[0])) {
34
34
  const [operator, value] = firstEntry;
35
35
  const translated = this.translateOperator(operator, value);
36
+ if (this.isLogicalOperator(operator) && Array.isArray(translated) && translated.length === 1) {
37
+ return translated[0];
38
+ }
36
39
  return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;
37
40
  }
38
41
  const result = {};
@@ -90,31 +93,46 @@ var ChromaFilterTranslator = class extends filter.BaseFilterTranslator {
90
93
  };
91
94
 
92
95
  // src/vector/index.ts
96
+ var spaceMappings = {
97
+ cosine: "cosine",
98
+ euclidean: "l2",
99
+ dotproduct: "ip",
100
+ l2: "euclidean",
101
+ ip: "dotproduct"
102
+ };
93
103
  var ChromaVector = class extends vector.MastraVector {
94
104
  client;
95
105
  collections;
96
- constructor({
97
- path,
98
- auth
99
- }) {
106
+ constructor(chromaClientArgs) {
100
107
  super();
101
- this.client = new chromadb.ChromaClient({
102
- path,
103
- auth
104
- });
108
+ if (chromaClientArgs?.apiKey) {
109
+ this.client = new chromadb.CloudClient({
110
+ apiKey: chromaClientArgs.apiKey,
111
+ tenant: chromaClientArgs.tenant,
112
+ database: chromaClientArgs.database
113
+ });
114
+ } else {
115
+ this.client = new chromadb.ChromaClient(chromaClientArgs);
116
+ }
105
117
  this.collections = /* @__PURE__ */ new Map();
106
118
  }
107
- async getCollection(indexName, throwIfNotExists = true) {
108
- try {
109
- const collection = await this.client.getCollection({ name: indexName, embeddingFunction: void 0 });
110
- this.collections.set(indexName, collection);
111
- } catch {
112
- if (throwIfNotExists) {
113
- throw new Error(`Index ${indexName} does not exist`);
119
+ async getCollection({ indexName, forceUpdate = false }) {
120
+ let collection = this.collections.get(indexName);
121
+ if (forceUpdate || !collection) {
122
+ try {
123
+ collection = await this.client.getCollection({ name: indexName });
124
+ this.collections.set(indexName, collection);
125
+ return collection;
126
+ } catch {
127
+ throw new error.MastraError({
128
+ id: "CHROMA_COLLECTION_GET_FAILED",
129
+ domain: error.ErrorDomain.MASTRA_VECTOR,
130
+ category: error.ErrorCategory.THIRD_PARTY,
131
+ details: { indexName }
132
+ });
114
133
  }
115
- return null;
116
134
  }
117
- return this.collections.get(indexName);
135
+ return collection;
118
136
  }
119
137
  validateVectorDimensions(vectors, dimension) {
120
138
  for (let i = 0; i < vectors.length; i++) {
@@ -127,15 +145,14 @@ var ChromaVector = class extends vector.MastraVector {
127
145
  }
128
146
  async upsert({ indexName, vectors, metadata, ids, documents }) {
129
147
  try {
130
- const collection = await this.getCollection(indexName);
148
+ const collection = await this.getCollection({ indexName });
131
149
  const stats = await this.describeIndex({ indexName });
132
150
  this.validateVectorDimensions(vectors, stats.dimension);
133
151
  const generatedIds = ids || vectors.map(() => crypto.randomUUID());
134
- const normalizedMetadata = metadata || vectors.map(() => ({}));
135
152
  await collection.upsert({
136
153
  ids: generatedIds,
137
154
  embeddings: vectors,
138
- metadatas: normalizedMetadata,
155
+ metadatas: metadata,
139
156
  documents
140
157
  });
141
158
  return generatedIds;
@@ -152,13 +169,6 @@ var ChromaVector = class extends vector.MastraVector {
152
169
  );
153
170
  }
154
171
  }
155
- HnswSpaceMap = {
156
- cosine: "cosine",
157
- euclidean: "l2",
158
- dotproduct: "ip",
159
- l2: "euclidean",
160
- ip: "dotproduct"
161
- };
162
172
  async createIndex({ indexName, dimension, metric = "cosine" }) {
163
173
  if (!Number.isInteger(dimension) || dimension <= 0) {
164
174
  throw new error.MastraError({
@@ -169,7 +179,7 @@ var ChromaVector = class extends vector.MastraVector {
169
179
  details: { dimension }
170
180
  });
171
181
  }
172
- const hnswSpace = this.HnswSpaceMap[metric];
182
+ const hnswSpace = spaceMappings[metric];
173
183
  if (!hnswSpace || !["cosine", "l2", "ip"].includes(hnswSpace)) {
174
184
  throw new error.MastraError({
175
185
  id: "CHROMA_VECTOR_CREATE_INDEX_INVALID_METRIC",
@@ -180,13 +190,13 @@ var ChromaVector = class extends vector.MastraVector {
180
190
  });
181
191
  }
182
192
  try {
183
- await this.client.createCollection({
193
+ const collection = await this.client.createCollection({
184
194
  name: indexName,
185
- metadata: {
186
- dimension,
187
- "hnsw:space": hnswSpace
188
- }
195
+ metadata: { dimension },
196
+ configuration: { hnsw: { space: hnswSpace } },
197
+ embeddingFunction: null
189
198
  });
199
+ this.collections.set(indexName, collection);
190
200
  } catch (error$1) {
191
201
  const message = error$1?.message || error$1?.toString();
192
202
  if (message && message.toLowerCase().includes("already exists")) {
@@ -206,7 +216,8 @@ var ChromaVector = class extends vector.MastraVector {
206
216
  }
207
217
  transformFilter(filter) {
208
218
  const translator = new ChromaFilterTranslator();
209
- return translator.translate(filter);
219
+ const translatedFilter = translator.translate(filter);
220
+ return translatedFilter ? translatedFilter : void 0;
210
221
  }
211
222
  async query({
212
223
  indexName,
@@ -217,21 +228,21 @@ var ChromaVector = class extends vector.MastraVector {
217
228
  documentFilter
218
229
  }) {
219
230
  try {
220
- const collection = await this.getCollection(indexName, true);
231
+ const collection = await this.getCollection({ indexName });
221
232
  const defaultInclude = ["documents", "metadatas", "distances"];
222
233
  const translatedFilter = this.transformFilter(filter);
223
234
  const results = await collection.query({
224
235
  queryEmbeddings: [queryVector],
225
236
  nResults: topK,
226
- where: translatedFilter,
227
- whereDocument: documentFilter,
237
+ where: translatedFilter ?? void 0,
238
+ whereDocument: documentFilter ?? void 0,
228
239
  include: includeVector ? [...defaultInclude, "embeddings"] : defaultInclude
229
240
  });
230
241
  return (results.ids[0] || []).map((id, index) => ({
231
242
  id,
232
243
  score: results.distances?.[0]?.[index] || 0,
233
244
  metadata: results.metadatas?.[0]?.[index] || {},
234
- document: results.documents?.[0]?.[index],
245
+ document: results.documents?.[0]?.[index] ?? void 0,
235
246
  ...includeVector && { vector: results.embeddings?.[0]?.[index] || [] }
236
247
  }));
237
248
  } catch (error$1) {
@@ -247,10 +258,45 @@ var ChromaVector = class extends vector.MastraVector {
247
258
  );
248
259
  }
249
260
  }
261
+ async get({
262
+ indexName,
263
+ ids,
264
+ filter,
265
+ includeVector = false,
266
+ documentFilter,
267
+ offset,
268
+ limit
269
+ }) {
270
+ try {
271
+ const collection = await this.getCollection({ indexName });
272
+ const defaultInclude = ["documents", "metadatas"];
273
+ const translatedFilter = this.transformFilter(filter);
274
+ const result = await collection.get({
275
+ ids,
276
+ where: translatedFilter ?? void 0,
277
+ whereDocument: documentFilter ?? void 0,
278
+ offset,
279
+ limit,
280
+ include: includeVector ? [...defaultInclude, "embeddings"] : defaultInclude
281
+ });
282
+ return result.rows();
283
+ } catch (error$1) {
284
+ if (error$1 instanceof error.MastraError) throw error$1;
285
+ throw new error.MastraError(
286
+ {
287
+ id: "CHROMA_VECTOR_GET_FAILED",
288
+ domain: error.ErrorDomain.MASTRA_VECTOR,
289
+ category: error.ErrorCategory.THIRD_PARTY,
290
+ details: { indexName }
291
+ },
292
+ error$1
293
+ );
294
+ }
295
+ }
250
296
  async listIndexes() {
251
297
  try {
252
298
  const collections = await this.client.listCollections();
253
- return collections.map((collection) => collection);
299
+ return collections.map((collection) => collection.name);
254
300
  } catch (error$1) {
255
301
  throw new error.MastraError(
256
302
  {
@@ -270,14 +316,14 @@ var ChromaVector = class extends vector.MastraVector {
270
316
  */
271
317
  async describeIndex({ indexName }) {
272
318
  try {
273
- const collection = await this.getCollection(indexName);
319
+ const collection = await this.getCollection({ indexName });
274
320
  const count = await collection.count();
275
321
  const metadata = collection.metadata;
276
- const hnswSpace = metadata?.["hnsw:space"];
322
+ const space = collection.configuration.hnsw?.space || collection.configuration.spann?.space || void 0;
277
323
  return {
278
324
  dimension: metadata?.dimension || 0,
279
325
  count,
280
- metric: this.HnswSpaceMap[hnswSpace]
326
+ metric: space ? spaceMappings[space] : void 0
281
327
  };
282
328
  } catch (error$1) {
283
329
  if (error$1 instanceof error.MastraError) throw error$1;
@@ -308,6 +354,24 @@ var ChromaVector = class extends vector.MastraVector {
308
354
  );
309
355
  }
310
356
  }
357
+ async forkIndex({ indexName, newIndexName }) {
358
+ try {
359
+ const collection = await this.getCollection({ indexName, forceUpdate: true });
360
+ const forkedCollection = await collection.fork({ name: newIndexName });
361
+ this.collections.set(newIndexName, forkedCollection);
362
+ } catch (error$1) {
363
+ if (error$1 instanceof error.MastraError) throw error$1;
364
+ throw new error.MastraError(
365
+ {
366
+ id: "CHROMA_INDEX_FORK_FAILED",
367
+ domain: error.ErrorDomain.MASTRA_VECTOR,
368
+ category: error.ErrorCategory.THIRD_PARTY,
369
+ details: { indexName }
370
+ },
371
+ error$1
372
+ );
373
+ }
374
+ }
311
375
  /**
312
376
  * Updates a vector by its ID with the provided vector and/or metadata.
313
377
  * @param indexName - The name of the index containing the vector.
@@ -329,17 +393,17 @@ var ChromaVector = class extends vector.MastraVector {
329
393
  });
330
394
  }
331
395
  try {
332
- const collection = await this.getCollection(indexName, true);
333
- const updateOptions = { ids: [id] };
396
+ const collection = await this.getCollection({ indexName });
397
+ const updateRecordSet = { ids: [id] };
334
398
  if (update?.vector) {
335
399
  const stats = await this.describeIndex({ indexName });
336
400
  this.validateVectorDimensions([update.vector], stats.dimension);
337
- updateOptions.embeddings = [update.vector];
401
+ updateRecordSet.embeddings = [update.vector];
338
402
  }
339
403
  if (update?.metadata) {
340
- updateOptions.metadatas = [update.metadata];
404
+ updateRecordSet.metadatas = [update.metadata];
341
405
  }
342
- return await collection.update(updateOptions);
406
+ return await collection.update(updateRecordSet);
343
407
  } catch (error$1) {
344
408
  if (error$1 instanceof error.MastraError) throw error$1;
345
409
  throw new error.MastraError(
@@ -355,7 +419,7 @@ var ChromaVector = class extends vector.MastraVector {
355
419
  }
356
420
  async deleteVector({ indexName, id }) {
357
421
  try {
358
- const collection = await this.getCollection(indexName, true);
422
+ const collection = await this.getCollection({ indexName });
359
423
  await collection.delete({ ids: [id] });
360
424
  } catch (error$1) {
361
425
  if (error$1 instanceof error.MastraError) throw error$1;
@@ -444,3 +508,5 @@ Example Complex Query:
444
508
 
445
509
  exports.CHROMA_PROMPT = CHROMA_PROMPT;
446
510
  exports.ChromaVector = ChromaVector;
511
+ //# sourceMappingURL=index.cjs.map
512
+ //# sourceMappingURL=index.cjs.map