@mastra/pinecone 1.0.0-beta.1 → 1.0.0-beta.2
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 +9 -0
- package/README.md +3 -0
- package/dist/index.cjs +167 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +167 -17
- package/dist/index.js.map +1 -1
- package/dist/vector/index.d.ts +39 -10
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mastra/pinecone
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add new deleteVectors, updateVector by filter ([#10408](https://github.com/mastra-ai/mastra/pull/10408))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`21a15de`](https://github.com/mastra-ai/mastra/commit/21a15de369fe82aac26bb642ed7be73505475e8b), [`feb7ee4`](https://github.com/mastra-ai/mastra/commit/feb7ee4d09a75edb46c6669a3beaceec78811747), [`b0e2ea5`](https://github.com/mastra-ai/mastra/commit/b0e2ea5b52c40fae438b9e2f7baee6f0f89c5442), [`c456e01`](https://github.com/mastra-ai/mastra/commit/c456e0149e3c176afcefdbd9bb1d2c5917723725), [`ab035c2`](https://github.com/mastra-ai/mastra/commit/ab035c2ef6d8cc7bb25f06f1a38508bd9e6f126b), [`1a46a56`](https://github.com/mastra-ai/mastra/commit/1a46a566f45a3fcbadc1cf36bf86d351f264bfa3), [`3cf540b`](https://github.com/mastra-ai/mastra/commit/3cf540b9fbfea8f4fc8d3a2319a4e6c0b0cbfd52), [`1c6ce51`](https://github.com/mastra-ai/mastra/commit/1c6ce51f875915ab57fd36873623013699a2a65d), [`898a972`](https://github.com/mastra-ai/mastra/commit/898a9727d286c2510d6b702dfd367e6aaf5c6b0f), [`a97003a`](https://github.com/mastra-ai/mastra/commit/a97003aa1cf2f4022a41912324a1e77263b326b8), [`ccc141e`](https://github.com/mastra-ai/mastra/commit/ccc141ed27da0abc3a3fc28e9e5128152e8e37f4), [`fe3b897`](https://github.com/mastra-ai/mastra/commit/fe3b897c2ccbcd2b10e81b099438c7337feddf89), [`00123ba`](https://github.com/mastra-ai/mastra/commit/00123ba96dc9e5cd0b110420ebdba56d8f237b25), [`29c4309`](https://github.com/mastra-ai/mastra/commit/29c4309f818b24304c041bcb4a8f19b5f13f6b62), [`16785ce`](https://github.com/mastra-ai/mastra/commit/16785ced928f6f22638f4488cf8a125d99211799), [`de8239b`](https://github.com/mastra-ai/mastra/commit/de8239bdcb1d8c0cfa06da21f1569912a66bbc8a), [`b5e6cd7`](https://github.com/mastra-ai/mastra/commit/b5e6cd77fc8c8e64e0494c1d06cee3d84e795d1e), [`3759cb0`](https://github.com/mastra-ai/mastra/commit/3759cb064935b5f74c65ac2f52a1145f7352899d), [`651e772`](https://github.com/mastra-ai/mastra/commit/651e772eb1475fb13e126d3fcc01751297a88214), [`b61b93f`](https://github.com/mastra-ai/mastra/commit/b61b93f9e058b11dd2eec169853175d31dbdd567), [`bae33d9`](https://github.com/mastra-ai/mastra/commit/bae33d91a63fbb64d1e80519e1fc1acaed1e9013), [`c0b731f`](https://github.com/mastra-ai/mastra/commit/c0b731fb27d712dc8582e846df5c0332a6a0c5ba), [`43ca8f2`](https://github.com/mastra-ai/mastra/commit/43ca8f2c7334851cc7b4d3d2f037d8784bfbdd5f), [`2ca67cc`](https://github.com/mastra-ai/mastra/commit/2ca67cc3bb1f6a617353fdcab197d9efebe60d6f), [`9e67002`](https://github.com/mastra-ai/mastra/commit/9e67002b52c9be19936c420a489dbee9c5fd6a78), [`35edc49`](https://github.com/mastra-ai/mastra/commit/35edc49ac0556db609189641d6341e76771b81fc)]:
|
|
10
|
+
- @mastra/core@1.0.0-beta.5
|
|
11
|
+
|
|
3
12
|
## 1.0.0-beta.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -62,6 +62,9 @@ Optional:
|
|
|
62
62
|
- `createIndex({indexName, dimension, metric?})`: Create a new index
|
|
63
63
|
- `upsert({indexName, vectors, metadata?, ids?})`: Add or update vectors
|
|
64
64
|
- `query({indexName, queryVector, topK?, filter?, includeVector?})`: Search for similar vectors
|
|
65
|
+
- `updateVector({ indexName, id?, filter?, namespace?, update })`: Update a single vector by ID or metadata filter
|
|
66
|
+
- `deleteVector({ indexName, id })`: Delete a single vector by ID
|
|
67
|
+
- `deleteVectors({ indexName, ids?, filter?, namespace? })`: Delete multiple vectors by IDs or metadata filter
|
|
65
68
|
- `listIndexes()`: List all indexes
|
|
66
69
|
- `describeIndex(indexName)`: Get index statistics
|
|
67
70
|
- `deleteIndex(indexName)`: Delete an index
|
package/dist/index.cjs
CHANGED
|
@@ -304,42 +304,102 @@ var PineconeVector = class extends vector.MastraVector {
|
|
|
304
304
|
}
|
|
305
305
|
/**
|
|
306
306
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
307
|
-
*
|
|
308
|
-
* @param
|
|
309
|
-
* @param
|
|
310
|
-
* @param
|
|
311
|
-
* @param update
|
|
312
|
-
* @param namespace - The namespace of the index (optional).
|
|
307
|
+
* Note: Pinecone only supports update by ID, not by filter.
|
|
308
|
+
* @param params - Parameters containing the id for targeting the vector to update
|
|
309
|
+
* @param params.indexName - The name of the index containing the vector.
|
|
310
|
+
* @param params.id - The ID of the vector to update.
|
|
311
|
+
* @param params.update - An object containing the vector and/or metadata to update.
|
|
312
|
+
* @param namespace - The namespace of the index (optional, Pinecone-specific).
|
|
313
313
|
* @returns A promise that resolves when the update is complete.
|
|
314
314
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
315
315
|
*/
|
|
316
|
-
async updateVector(
|
|
316
|
+
async updateVector(params) {
|
|
317
|
+
const { indexName, update } = params;
|
|
318
|
+
if ("id" in params && params.id && "filter" in params && params.filter) {
|
|
319
|
+
throw new error.MastraError({
|
|
320
|
+
id: "STORAGE_PINECONE_VECTOR_UPDATE_MUTUALLY_EXCLUSIVE",
|
|
321
|
+
text: "Cannot specify both id and filter - they are mutually exclusive",
|
|
322
|
+
domain: error.ErrorDomain.STORAGE,
|
|
323
|
+
category: error.ErrorCategory.USER,
|
|
324
|
+
details: { indexName }
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
if (!("id" in params && params.id) && !("filter" in params && params.filter)) {
|
|
328
|
+
throw new error.MastraError({
|
|
329
|
+
id: "STORAGE_PINECONE_VECTOR_UPDATE_NO_TARGET",
|
|
330
|
+
text: "Either id or filter must be provided",
|
|
331
|
+
domain: error.ErrorDomain.STORAGE,
|
|
332
|
+
category: error.ErrorCategory.USER,
|
|
333
|
+
details: { indexName }
|
|
334
|
+
});
|
|
335
|
+
}
|
|
317
336
|
if (!update.vector && !update.metadata) {
|
|
318
337
|
throw new error.MastraError({
|
|
319
338
|
id: "STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_INVALID_ARGS",
|
|
320
339
|
domain: error.ErrorDomain.STORAGE,
|
|
321
340
|
category: error.ErrorCategory.USER,
|
|
322
341
|
text: "No updates provided",
|
|
323
|
-
details: { indexName
|
|
342
|
+
details: { indexName }
|
|
324
343
|
});
|
|
325
344
|
}
|
|
345
|
+
const namespace = params.namespace;
|
|
326
346
|
try {
|
|
327
347
|
const index = this.client.Index(indexName).namespace(namespace || "");
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
348
|
+
if ("id" in params && params.id) {
|
|
349
|
+
const updateObj = { id: params.id };
|
|
350
|
+
if (update.vector) {
|
|
351
|
+
updateObj.values = update.vector;
|
|
352
|
+
}
|
|
353
|
+
if (update.metadata) {
|
|
354
|
+
updateObj.metadata = update.metadata;
|
|
355
|
+
}
|
|
356
|
+
await index.update(updateObj);
|
|
357
|
+
} else if ("filter" in params && params.filter) {
|
|
358
|
+
if (Object.keys(params.filter).length === 0) {
|
|
359
|
+
throw new error.MastraError({
|
|
360
|
+
id: "STORAGE_PINECONE_VECTOR_UPDATE_EMPTY_FILTER",
|
|
361
|
+
text: "Filter cannot be an empty filter object",
|
|
362
|
+
domain: error.ErrorDomain.STORAGE,
|
|
363
|
+
category: error.ErrorCategory.USER,
|
|
364
|
+
details: { indexName }
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
const translatedFilter = this.transformFilter(params.filter);
|
|
368
|
+
if (translatedFilter) {
|
|
369
|
+
const stats = await this.describeIndex({ indexName });
|
|
370
|
+
const dummyVector = new Array(stats.dimension).fill(1 / Math.sqrt(stats.dimension));
|
|
371
|
+
const results = await index.query({
|
|
372
|
+
vector: dummyVector,
|
|
373
|
+
topK: 1e4,
|
|
374
|
+
filter: translatedFilter,
|
|
375
|
+
includeMetadata: false,
|
|
376
|
+
includeValues: false
|
|
377
|
+
});
|
|
378
|
+
const idsToUpdate = results.matches.map((m) => m.id);
|
|
379
|
+
for (const id of idsToUpdate) {
|
|
380
|
+
const updateObj = { id };
|
|
381
|
+
if (update.vector) {
|
|
382
|
+
updateObj.values = update.vector;
|
|
383
|
+
}
|
|
384
|
+
if (update.metadata) {
|
|
385
|
+
updateObj.metadata = update.metadata;
|
|
386
|
+
}
|
|
387
|
+
await index.update(updateObj);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
334
390
|
}
|
|
335
|
-
await index.update(updateObj);
|
|
336
391
|
} catch (error$1) {
|
|
392
|
+
if (error$1 instanceof error.MastraError) throw error$1;
|
|
337
393
|
throw new error.MastraError(
|
|
338
394
|
{
|
|
339
395
|
id: "STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_FAILED",
|
|
340
396
|
domain: error.ErrorDomain.STORAGE,
|
|
341
397
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
342
|
-
details: {
|
|
398
|
+
details: {
|
|
399
|
+
indexName,
|
|
400
|
+
..."id" in params && params.id && { id: params.id },
|
|
401
|
+
..."filter" in params && params.filter && { filter: JSON.stringify(params.filter) }
|
|
402
|
+
}
|
|
343
403
|
},
|
|
344
404
|
error$1
|
|
345
405
|
);
|
|
@@ -363,7 +423,97 @@ var PineconeVector = class extends vector.MastraVector {
|
|
|
363
423
|
id: "STORAGE_PINECONE_VECTOR_DELETE_VECTOR_FAILED",
|
|
364
424
|
domain: error.ErrorDomain.STORAGE,
|
|
365
425
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
366
|
-
details: {
|
|
426
|
+
details: {
|
|
427
|
+
indexName,
|
|
428
|
+
...id && { id }
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
error$1
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Deletes multiple vectors by IDs or filter.
|
|
437
|
+
* @param indexName - The name of the index containing the vectors.
|
|
438
|
+
* @param ids - Array of vector IDs to delete (mutually exclusive with filter).
|
|
439
|
+
* @param filter - Filter to match vectors to delete (mutually exclusive with ids).
|
|
440
|
+
* @param namespace - The namespace of the index (optional, Pinecone-specific).
|
|
441
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
442
|
+
* @throws Will throw an error if both ids and filter are provided, or if neither is provided.
|
|
443
|
+
*/
|
|
444
|
+
async deleteVectors(params) {
|
|
445
|
+
const { indexName, filter, ids } = params;
|
|
446
|
+
const namespace = params.namespace;
|
|
447
|
+
if (ids && filter) {
|
|
448
|
+
throw new error.MastraError({
|
|
449
|
+
id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_MUTUALLY_EXCLUSIVE",
|
|
450
|
+
text: "Cannot specify both ids and filter - they are mutually exclusive",
|
|
451
|
+
domain: error.ErrorDomain.STORAGE,
|
|
452
|
+
category: error.ErrorCategory.USER,
|
|
453
|
+
details: { indexName }
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
if (!ids && !filter) {
|
|
457
|
+
throw new error.MastraError({
|
|
458
|
+
id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_NO_TARGET",
|
|
459
|
+
text: "Either filter or ids must be provided",
|
|
460
|
+
domain: error.ErrorDomain.STORAGE,
|
|
461
|
+
category: error.ErrorCategory.USER,
|
|
462
|
+
details: { indexName }
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
if (ids && ids.length === 0) {
|
|
466
|
+
throw new error.MastraError({
|
|
467
|
+
id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_EMPTY_IDS",
|
|
468
|
+
text: "Cannot delete with empty ids array",
|
|
469
|
+
domain: error.ErrorDomain.STORAGE,
|
|
470
|
+
category: error.ErrorCategory.USER,
|
|
471
|
+
details: { indexName }
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
if (filter && Object.keys(filter).length === 0) {
|
|
475
|
+
throw new error.MastraError({
|
|
476
|
+
id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_EMPTY_FILTER",
|
|
477
|
+
text: "Cannot delete with empty filter object",
|
|
478
|
+
domain: error.ErrorDomain.STORAGE,
|
|
479
|
+
category: error.ErrorCategory.USER,
|
|
480
|
+
details: { indexName }
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
try {
|
|
484
|
+
const index = this.client.Index(indexName).namespace(namespace || "");
|
|
485
|
+
if (ids) {
|
|
486
|
+
await index.deleteMany(ids);
|
|
487
|
+
} else if (filter) {
|
|
488
|
+
const translatedFilter = this.transformFilter(filter);
|
|
489
|
+
if (translatedFilter) {
|
|
490
|
+
const stats = await this.describeIndex({ indexName });
|
|
491
|
+
const dummyVector = new Array(stats.dimension).fill(1 / Math.sqrt(stats.dimension));
|
|
492
|
+
const results = await index.query({
|
|
493
|
+
vector: dummyVector,
|
|
494
|
+
topK: 1e4,
|
|
495
|
+
filter: translatedFilter,
|
|
496
|
+
includeMetadata: false,
|
|
497
|
+
includeValues: false
|
|
498
|
+
});
|
|
499
|
+
const idsToDelete = results.matches.map((m) => m.id);
|
|
500
|
+
if (idsToDelete.length > 0) {
|
|
501
|
+
await index.deleteMany(idsToDelete);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
} catch (error$1) {
|
|
506
|
+
if (error$1 instanceof error.MastraError) throw error$1;
|
|
507
|
+
throw new error.MastraError(
|
|
508
|
+
{
|
|
509
|
+
id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_FAILED",
|
|
510
|
+
domain: error.ErrorDomain.STORAGE,
|
|
511
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
512
|
+
details: {
|
|
513
|
+
indexName,
|
|
514
|
+
...filter && { filter: JSON.stringify(filter) },
|
|
515
|
+
...ids && { idsCount: ids.length }
|
|
516
|
+
}
|
|
367
517
|
},
|
|
368
518
|
error$1
|
|
369
519
|
);
|
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","Pinecone","MastraError","ErrorDomain","ErrorCategory","error"],"mappings":";;;;;;;;AAkCO,IAAM,wBAAA,GAAN,cAAuCA,2BAAA,CAA2C;AAAA,EACpE,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,MAAA,EAAQ,MAAM,CAAA;AAAA,MAC7B,OAAA,EAAS,CAAC,SAAS,CAAA;AAAA,MACnB,OAAO,EAAC;AAAA,MACR,QAAQ;AAAC,KACX;AAAA,EACF;AAAA,EAEA,UAAU,MAAA,EAAqD;AAC7D,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,MAAM,CAAA,EAAG,OAAO,MAAA;AACjC,IAAA,IAAA,CAAK,eAAe,MAAM,CAAA;AAC1B,IAAA,OAAO,IAAA,CAAK,cAAc,MAAM,CAAA;AAAA,EAClC;AAAA,EAEQ,aAAA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vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n QueryOperator,\n FilterValue,\n OperatorCondition,\n} from '@mastra/core/vector/filter';\n\ntype InitialOperatorValueMap = Omit<OperatorValueMap, '$regex' | '$options' | '$elemMatch' | '$all'> & {\n $contains: string;\n $gt: number | Date;\n $gte: number | Date;\n $lt: number | Date;\n $lte: number | Date;\n};\n\ntype PineconeOperatorValueMap = InitialOperatorValueMap & {\n $all: OperatorCondition<keyof InitialOperatorValueMap, InitialOperatorValueMap>[] | FilterValue[];\n};\ntype PineconeLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$not' | '$nor'>;\n\ntype PineconeBlacklisted = BlacklistedRootOperators | '$not' | '$nor';\n\nexport type PineconeVectorFilter = VectorFilter<\n keyof PineconeOperatorValueMap,\n PineconeOperatorValueMap,\n PineconeLogicalOperatorValueMap,\n PineconeBlacklisted\n>;\n\nexport class PineconeFilterTranslator extends BaseFilterTranslator<PineconeVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or'],\n array: ['$in', '$all', '$nin'],\n element: ['$exists'],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: PineconeVectorFilter): PineconeVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n return this.translateNode(filter);\n }\n\n private translateNode(node: PineconeVectorFilter, currentPath: string = ''): any {\n if (this.isRegex(node)) {\n throw new Error('Regex is not supported in Pinecone');\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\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, currentPath);\n return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;\n }\n\n // Process each entry\n const result: Record<string, 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, currentPath);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Handle nested $all\n if (Object.keys(value).length === 1 && '$all' in value) {\n const translated = this.translateNode(value, key);\n if (translated.$and) {\n return translated;\n }\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 return result;\n }\n\n private translateOperator(operator: QueryOperator, value: any, currentPath: string = ''): any {\n // Handle $all specially\n if (operator === '$all') {\n if (!Array.isArray(value) || value.length === 0) {\n throw new Error('A non-empty array is required for the $all operator');\n }\n\n return this.simulateAllOperator(currentPath, value);\n }\n\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} from '@mastra/core/vector';\nimport { Pinecone } from '@pinecone-database/pinecone';\nimport type {\n IndexStatsDescription,\n QueryOptions,\n RecordSparseValues,\n ServerlessSpecCloudEnum,\n UpdateOptions,\n} from '@pinecone-database/pinecone';\n\nimport { PineconeFilterTranslator } from './filter';\nimport type { PineconeVectorFilter } from './filter';\n\ninterface PineconeIndexStats extends IndexStats {\n namespaces?: IndexStatsDescription['namespaces'];\n}\n\ninterface PineconeQueryVectorParams extends QueryVectorParams<PineconeVectorFilter> {\n namespace?: string;\n sparseVector?: RecordSparseValues;\n}\n\ninterface PineconeUpsertVectorParams extends UpsertVectorParams {\n namespace?: string;\n sparseVectors?: RecordSparseValues[];\n}\n\ninterface PineconeUpdateVectorParams extends UpdateVectorParams {\n namespace?: string;\n}\n\ninterface PineconeDeleteVectorParams extends DeleteVectorParams {\n namespace?: string;\n}\n\nexport class PineconeVector extends MastraVector<PineconeVectorFilter> {\n private client: Pinecone;\n private cloud: ServerlessSpecCloudEnum;\n private region: string;\n\n /**\n * Creates a new PineconeVector client.\n * @param id - The unique identifier for this vector store instance.\n * @param apiKey - The API key for Pinecone.\n * @param environment - The environment for Pinecone.\n * @param cloud - The cloud provider for Pinecone.\n * @param region - The region for Pinecone.\n */\n constructor({\n id,\n apiKey,\n environment,\n cloud,\n region,\n }: {\n id: string;\n apiKey: string;\n environment?: string;\n region?: string;\n cloud?: ServerlessSpecCloudEnum;\n }) {\n super({ id });\n const opts: { apiKey: string; controllerHostUrl?: string } = { apiKey };\n if (environment) {\n opts['controllerHostUrl'] = environment;\n }\n this.client = new Pinecone(opts);\n this.cloud = cloud || 'aws';\n this.region = region || 'us-east-1';\n }\n\n get indexSeparator(): string {\n return '-';\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n try {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new Error('Dimension must be a positive integer');\n }\n if (metric && !['cosine', 'euclidean', 'dotproduct'].includes(metric)) {\n throw new Error('Metric must be one of: cosine, euclidean, dotproduct');\n }\n } catch (validationError) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_CREATE_INDEX_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, dimension, metric },\n },\n validationError,\n );\n }\n\n try {\n await this.client.createIndex({\n name: indexName,\n dimension: dimension,\n metric: metric,\n spec: {\n serverless: {\n cloud: this.cloud,\n region: this.region,\n },\n },\n });\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.errors?.[0]?.message || error?.message;\n if (\n error.status === 409 ||\n (typeof message === 'string' &&\n (message.toLowerCase().includes('already exists') || message.toLowerCase().includes('duplicate')))\n ) {\n // Fetch index info and check dimensions\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n // For any other errors, wrap in MastraError\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n async upsert({\n indexName,\n vectors,\n metadata,\n ids,\n namespace,\n sparseVectors,\n }: PineconeUpsertVectorParams): Promise<string[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n // Generate IDs if not provided\n const vectorIds = ids || vectors.map(() => crypto.randomUUID());\n\n const records = vectors.map((vector, i) => ({\n id: vectorIds[i]!,\n values: vector,\n ...(sparseVectors?.[i] && { sparseValues: sparseVectors?.[i] }),\n metadata: metadata?.[i] || {},\n }));\n\n // Pinecone has a limit of 100 vectors per upsert request\n const batchSize = 100;\n try {\n for (let i = 0; i < records.length; i += batchSize) {\n const batch = records.slice(i, i + batchSize);\n await index.upsert(batch);\n }\n\n return vectorIds;\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors.length },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: PineconeVectorFilter) {\n const translator = new PineconeFilterTranslator();\n return translator.translate(filter);\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n namespace,\n sparseVector,\n }: PineconeQueryVectorParams): Promise<QueryResult[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n const translatedFilter = this.transformFilter(filter) ?? undefined;\n\n const queryParams: QueryOptions = {\n vector: queryVector,\n topK,\n includeMetadata: true,\n includeValues: includeVector,\n filter: translatedFilter,\n };\n\n // If sparse vector is provided, use hybrid search\n if (sparseVector) {\n queryParams.sparseVector = sparseVector;\n }\n\n try {\n const results = await index.query(queryParams);\n\n return results.matches.map(match => ({\n id: match.id,\n score: match.score || 0,\n metadata: match.metadata as Record<string, any>,\n ...(includeVector && { vector: match.values || [] }),\n }));\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const indexesResult = await this.client.listIndexes();\n return indexesResult?.indexes?.map(index => index.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.STORAGE,\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<PineconeIndexStats> {\n try {\n const index = this.client.Index(indexName);\n const stats = await index.describeIndexStats();\n const description = await this.client.describeIndex(indexName);\n\n return {\n dimension: description.dimension,\n count: stats.totalRecordCount || 0,\n metric: description.metric as 'cosine' | 'euclidean' | 'dotproduct',\n namespaces: stats.namespaces,\n };\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\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.deleteIndex(indexName);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to update.\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 * @param namespace - The namespace of the index (optional).\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, update, namespace }: PineconeUpdateVectorParams): Promise<void> {\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'No updates provided',\n details: { indexName, id },\n });\n }\n\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n const updateObj: UpdateOptions = { id };\n\n if (update.vector) {\n updateObj.values = update.vector;\n }\n\n if (update.metadata) {\n updateObj.metadata = update.metadata;\n }\n\n await index.update(updateObj);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @param namespace - The namespace of the index (optional).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ indexName, id, namespace }: PineconeDeleteVectorParams): Promise<void> {\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n await index.deleteOne(id);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\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 Pinecone Vector.\n */\nexport const PINECONE_PROMPT = `When querying Pinecone, 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- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- A non-empty array is required for $all operator\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\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 { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\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","Pinecone","MastraError","ErrorDomain","ErrorCategory","error"],"mappings":";;;;;;;;AAkCO,IAAM,wBAAA,GAAN,cAAuCA,2BAAA,CAA2C;AAAA,EACpE,qBAAA,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;AAC3D,UAAA,IAAI,WAAA,CAAY,SAAS,CAAA,EAAG;AAC1B,YAAA,MAAM,KAAA,CAAM,WAAW,WAAW,CAAA;AAAA,UACpC;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAASC,OAAA,EAAO;AACd,MAAA,IAAIA,OAAA,YAAiBH,mBAAa,MAAMG,OAAA;AACxC,MAAA,MAAM,IAAIH,iBAAA;AAAA,QACR;AAAA,UACE,EAAA,EAAI,+CAAA;AAAA,UACJ,QAAQC,iBAAA,CAAY,OAAA;AAAA,UACpB,UAAUC,mBAAA,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,QACAC;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACF;;;ACrkBO,IAAM,eAAA,GAAkB,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;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 OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n QueryOperator,\n FilterValue,\n OperatorCondition,\n} from '@mastra/core/vector/filter';\n\ntype InitialOperatorValueMap = Omit<OperatorValueMap, '$regex' | '$options' | '$elemMatch' | '$all'> & {\n $contains: string;\n $gt: number | Date;\n $gte: number | Date;\n $lt: number | Date;\n $lte: number | Date;\n};\n\ntype PineconeOperatorValueMap = InitialOperatorValueMap & {\n $all: OperatorCondition<keyof InitialOperatorValueMap, InitialOperatorValueMap>[] | FilterValue[];\n};\ntype PineconeLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$not' | '$nor'>;\n\ntype PineconeBlacklisted = BlacklistedRootOperators | '$not' | '$nor';\n\nexport type PineconeVectorFilter = VectorFilter<\n keyof PineconeOperatorValueMap,\n PineconeOperatorValueMap,\n PineconeLogicalOperatorValueMap,\n PineconeBlacklisted\n>;\n\nexport class PineconeFilterTranslator extends BaseFilterTranslator<PineconeVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or'],\n array: ['$in', '$all', '$nin'],\n element: ['$exists'],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: PineconeVectorFilter): PineconeVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n return this.translateNode(filter);\n }\n\n private translateNode(node: PineconeVectorFilter, currentPath: string = ''): any {\n if (this.isRegex(node)) {\n throw new Error('Regex is not supported in Pinecone');\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\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, currentPath);\n return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;\n }\n\n // Process each entry\n const result: Record<string, 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, currentPath);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Handle nested $all\n if (Object.keys(value).length === 1 && '$all' in value) {\n const translated = this.translateNode(value, key);\n if (translated.$and) {\n return translated;\n }\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 return result;\n }\n\n private translateOperator(operator: QueryOperator, value: any, currentPath: string = ''): any {\n // Handle $all specially\n if (operator === '$all') {\n if (!Array.isArray(value) || value.length === 0) {\n throw new Error('A non-empty array is required for the $all operator');\n }\n\n return this.simulateAllOperator(currentPath, value);\n }\n\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 DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport { Pinecone } from '@pinecone-database/pinecone';\nimport type {\n IndexStatsDescription,\n QueryOptions,\n RecordSparseValues,\n ServerlessSpecCloudEnum,\n UpdateOptions,\n} from '@pinecone-database/pinecone';\n\nimport { PineconeFilterTranslator } from './filter';\nimport type { PineconeVectorFilter } from './filter';\n\ninterface PineconeIndexStats extends IndexStats {\n namespaces?: IndexStatsDescription['namespaces'];\n}\n\ninterface PineconeQueryVectorParams extends QueryVectorParams<PineconeVectorFilter> {\n namespace?: string;\n sparseVector?: RecordSparseValues;\n}\n\ninterface PineconeUpsertVectorParams extends UpsertVectorParams {\n namespace?: string;\n sparseVectors?: RecordSparseValues[];\n}\n\n// Pinecone-specific update params that includes namespace in both union branches\ntype PineconeUpdateVectorParams =\n | {\n indexName: string;\n id: string;\n filter?: never;\n update: { vector?: number[]; metadata?: Record<string, any> };\n namespace?: string;\n }\n | {\n indexName: string;\n id?: never;\n filter: PineconeVectorFilter;\n update: { vector?: number[]; metadata?: Record<string, any> };\n namespace?: string;\n };\n\ninterface PineconeDeleteVectorParams extends DeleteVectorParams {\n namespace?: string;\n}\n\ninterface PineconeDeleteVectorsParams extends DeleteVectorsParams<PineconeVectorFilter> {\n namespace?: string;\n}\n\nexport class PineconeVector extends MastraVector<PineconeVectorFilter> {\n private client: Pinecone;\n private cloud: ServerlessSpecCloudEnum;\n private region: string;\n\n /**\n * Creates a new PineconeVector client.\n * @param id - The unique identifier for this vector store instance.\n * @param apiKey - The API key for Pinecone.\n * @param environment - The environment for Pinecone.\n * @param cloud - The cloud provider for Pinecone.\n * @param region - The region for Pinecone.\n */\n constructor({\n id,\n apiKey,\n environment,\n cloud,\n region,\n }: {\n id: string;\n apiKey: string;\n environment?: string;\n region?: string;\n cloud?: ServerlessSpecCloudEnum;\n }) {\n super({ id });\n const opts: { apiKey: string; controllerHostUrl?: string } = { apiKey };\n if (environment) {\n opts['controllerHostUrl'] = environment;\n }\n this.client = new Pinecone(opts);\n this.cloud = cloud || 'aws';\n this.region = region || 'us-east-1';\n }\n\n get indexSeparator(): string {\n return '-';\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n try {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new Error('Dimension must be a positive integer');\n }\n if (metric && !['cosine', 'euclidean', 'dotproduct'].includes(metric)) {\n throw new Error('Metric must be one of: cosine, euclidean, dotproduct');\n }\n } catch (validationError) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_CREATE_INDEX_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, dimension, metric },\n },\n validationError,\n );\n }\n\n try {\n await this.client.createIndex({\n name: indexName,\n dimension: dimension,\n metric: metric,\n spec: {\n serverless: {\n cloud: this.cloud,\n region: this.region,\n },\n },\n });\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.errors?.[0]?.message || error?.message;\n if (\n error.status === 409 ||\n (typeof message === 'string' &&\n (message.toLowerCase().includes('already exists') || message.toLowerCase().includes('duplicate')))\n ) {\n // Fetch index info and check dimensions\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n // For any other errors, wrap in MastraError\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n async upsert({\n indexName,\n vectors,\n metadata,\n ids,\n namespace,\n sparseVectors,\n }: PineconeUpsertVectorParams): Promise<string[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n // Generate IDs if not provided\n const vectorIds = ids || vectors.map(() => crypto.randomUUID());\n\n const records = vectors.map((vector, i) => ({\n id: vectorIds[i]!,\n values: vector,\n ...(sparseVectors?.[i] && { sparseValues: sparseVectors?.[i] }),\n metadata: metadata?.[i] || {},\n }));\n\n // Pinecone has a limit of 100 vectors per upsert request\n const batchSize = 100;\n try {\n for (let i = 0; i < records.length; i += batchSize) {\n const batch = records.slice(i, i + batchSize);\n await index.upsert(batch);\n }\n\n return vectorIds;\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors.length },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: PineconeVectorFilter) {\n const translator = new PineconeFilterTranslator();\n return translator.translate(filter);\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n namespace,\n sparseVector,\n }: PineconeQueryVectorParams): Promise<QueryResult[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n const translatedFilter = this.transformFilter(filter) ?? undefined;\n\n const queryParams: QueryOptions = {\n vector: queryVector,\n topK,\n includeMetadata: true,\n includeValues: includeVector,\n filter: translatedFilter,\n };\n\n // If sparse vector is provided, use hybrid search\n if (sparseVector) {\n queryParams.sparseVector = sparseVector;\n }\n\n try {\n const results = await index.query(queryParams);\n\n return results.matches.map(match => ({\n id: match.id,\n score: match.score || 0,\n metadata: match.metadata as Record<string, any>,\n ...(includeVector && { vector: match.values || [] }),\n }));\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const indexesResult = await this.client.listIndexes();\n return indexesResult?.indexes?.map(index => index.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.STORAGE,\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<PineconeIndexStats> {\n try {\n const index = this.client.Index(indexName);\n const stats = await index.describeIndexStats();\n const description = await this.client.describeIndex(indexName);\n\n return {\n dimension: description.dimension,\n count: stats.totalRecordCount || 0,\n metric: description.metric as 'cosine' | 'euclidean' | 'dotproduct',\n namespaces: stats.namespaces,\n };\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\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.deleteIndex(indexName);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * Note: Pinecone only supports update by ID, not by filter.\n * @param params - Parameters containing the id for targeting the vector to update\n * @param params.indexName - The name of the index containing the vector.\n * @param params.id - The ID of the vector to update.\n * @param params.update - An object containing the vector and/or metadata to update.\n * @param namespace - The namespace of the index (optional, Pinecone-specific).\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(params: PineconeUpdateVectorParams): Promise<void> {\n const { indexName, update } = params;\n\n // Validate mutually exclusive parameters\n if ('id' in params && params.id && 'filter' in params && params.filter) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_MUTUALLY_EXCLUSIVE',\n text: 'Cannot specify both id and filter - they are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!('id' in params && params.id) && !('filter' in params && params.filter)) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_NO_TARGET',\n text: 'Either id or filter must be provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'No updates provided',\n details: { indexName },\n });\n }\n\n // Extract Pinecone-specific namespace field\n const namespace = params.namespace;\n\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n // Handle update by ID\n if ('id' in params && params.id) {\n const updateObj: UpdateOptions = { id: params.id };\n\n if (update.vector) {\n updateObj.values = update.vector;\n }\n\n if (update.metadata) {\n updateObj.metadata = update.metadata;\n }\n\n await index.update(updateObj);\n }\n // Handle update by filter (query first, then update each)\n else if ('filter' in params && params.filter) {\n // Validate filter is not empty\n if (Object.keys(params.filter).length === 0) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_EMPTY_FILTER',\n text: 'Filter cannot be an empty filter object',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n const translatedFilter = this.transformFilter(params.filter);\n if (translatedFilter) {\n // Get index stats to know dimensions for dummy vector\n const stats = await this.describeIndex({ indexName });\n\n // Create a normalized dummy vector for querying (avoid zero vector for cosine similarity)\n const dummyVector = new Array(stats.dimension).fill(1 / Math.sqrt(stats.dimension));\n\n // Query with large topK to get all matching vectors\n // Pinecone's max topK is 10000\n const results = await index.query({\n vector: dummyVector,\n topK: 10000,\n filter: translatedFilter,\n includeMetadata: false,\n includeValues: false,\n });\n\n // Update each matching vector\n const idsToUpdate = results.matches.map(m => m.id as string);\n for (const id of idsToUpdate) {\n const updateObj: UpdateOptions = { id };\n\n if (update.vector) {\n updateObj.values = update.vector;\n }\n\n if (update.metadata) {\n updateObj.metadata = update.metadata;\n }\n\n await index.update(updateObj);\n }\n }\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...('id' in params && params.id && { id: params.id }),\n ...('filter' in params && params.filter && { filter: JSON.stringify(params.filter) }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @param namespace - The namespace of the index (optional).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ indexName, id, namespace }: PineconeDeleteVectorParams): Promise<void> {\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n await index.deleteOne(id);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\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 * @param namespace - The namespace of the index (optional, Pinecone-specific).\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(params: PineconeDeleteVectorsParams): Promise<void> {\n const { indexName, filter, ids } = params;\n const namespace = params.namespace;\n\n // Validate mutually exclusive parameters\n if (ids && filter) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_DELETE_VECTORS_MUTUALLY_EXCLUSIVE',\n text: 'Cannot specify both ids and filter - they are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!ids && !filter) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_DELETE_VECTORS_NO_TARGET',\n text: 'Either filter or ids must be provided',\n domain: ErrorDomain.STORAGE,\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: 'STORAGE_PINECONE_VECTOR_DELETE_VECTORS_EMPTY_IDS',\n text: 'Cannot delete with empty ids array',\n domain: ErrorDomain.STORAGE,\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: 'STORAGE_PINECONE_VECTOR_DELETE_VECTORS_EMPTY_FILTER',\n text: 'Cannot delete with empty filter object',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n if (ids) {\n // Delete by IDs - Pinecone's deleteMany accepts an array of IDs\n await index.deleteMany(ids);\n } else if (filter) {\n // Delete by filter - Pinecone's deleteMany doesn't properly support metadata filters\n // We need to query for matching IDs first, then delete them\n const translatedFilter = this.transformFilter(filter);\n if (translatedFilter) {\n // Get index stats to know dimensions for dummy vector\n const stats = await this.describeIndex({ indexName });\n\n // Create a normalized dummy vector for querying (avoid zero vector for cosine similarity)\n const dummyVector = new Array(stats.dimension).fill(1 / Math.sqrt(stats.dimension));\n\n // Query with large topK to get all matching vectors\n // Pinecone's max topK is 10000\n const results = await index.query({\n vector: dummyVector,\n topK: 10000,\n filter: translatedFilter,\n includeMetadata: false,\n includeValues: false,\n });\n\n // Extract IDs and delete them\n const idsToDelete = results.matches.map(m => m.id as string);\n if (idsToDelete.length > 0) {\n await index.deleteMany(idsToDelete);\n }\n }\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_VECTORS_FAILED',\n domain: ErrorDomain.STORAGE,\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 Pinecone Vector.\n */\nexport const PINECONE_PROMPT = `When querying Pinecone, 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- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- A non-empty array is required for $all operator\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\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 { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}`;\n"]}
|
package/dist/index.js
CHANGED
|
@@ -302,42 +302,102 @@ var PineconeVector = class extends MastraVector {
|
|
|
302
302
|
}
|
|
303
303
|
/**
|
|
304
304
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
305
|
-
*
|
|
306
|
-
* @param
|
|
307
|
-
* @param
|
|
308
|
-
* @param
|
|
309
|
-
* @param update
|
|
310
|
-
* @param namespace - The namespace of the index (optional).
|
|
305
|
+
* Note: Pinecone only supports update by ID, not by filter.
|
|
306
|
+
* @param params - Parameters containing the id for targeting the vector to update
|
|
307
|
+
* @param params.indexName - The name of the index containing the vector.
|
|
308
|
+
* @param params.id - The ID of the vector to update.
|
|
309
|
+
* @param params.update - An object containing the vector and/or metadata to update.
|
|
310
|
+
* @param namespace - The namespace of the index (optional, Pinecone-specific).
|
|
311
311
|
* @returns A promise that resolves when the update is complete.
|
|
312
312
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
313
313
|
*/
|
|
314
|
-
async updateVector(
|
|
314
|
+
async updateVector(params) {
|
|
315
|
+
const { indexName, update } = params;
|
|
316
|
+
if ("id" in params && params.id && "filter" in params && params.filter) {
|
|
317
|
+
throw new MastraError({
|
|
318
|
+
id: "STORAGE_PINECONE_VECTOR_UPDATE_MUTUALLY_EXCLUSIVE",
|
|
319
|
+
text: "Cannot specify both id and filter - they are mutually exclusive",
|
|
320
|
+
domain: ErrorDomain.STORAGE,
|
|
321
|
+
category: ErrorCategory.USER,
|
|
322
|
+
details: { indexName }
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
if (!("id" in params && params.id) && !("filter" in params && params.filter)) {
|
|
326
|
+
throw new MastraError({
|
|
327
|
+
id: "STORAGE_PINECONE_VECTOR_UPDATE_NO_TARGET",
|
|
328
|
+
text: "Either id or filter must be provided",
|
|
329
|
+
domain: ErrorDomain.STORAGE,
|
|
330
|
+
category: ErrorCategory.USER,
|
|
331
|
+
details: { indexName }
|
|
332
|
+
});
|
|
333
|
+
}
|
|
315
334
|
if (!update.vector && !update.metadata) {
|
|
316
335
|
throw new MastraError({
|
|
317
336
|
id: "STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_INVALID_ARGS",
|
|
318
337
|
domain: ErrorDomain.STORAGE,
|
|
319
338
|
category: ErrorCategory.USER,
|
|
320
339
|
text: "No updates provided",
|
|
321
|
-
details: { indexName
|
|
340
|
+
details: { indexName }
|
|
322
341
|
});
|
|
323
342
|
}
|
|
343
|
+
const namespace = params.namespace;
|
|
324
344
|
try {
|
|
325
345
|
const index = this.client.Index(indexName).namespace(namespace || "");
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
346
|
+
if ("id" in params && params.id) {
|
|
347
|
+
const updateObj = { id: params.id };
|
|
348
|
+
if (update.vector) {
|
|
349
|
+
updateObj.values = update.vector;
|
|
350
|
+
}
|
|
351
|
+
if (update.metadata) {
|
|
352
|
+
updateObj.metadata = update.metadata;
|
|
353
|
+
}
|
|
354
|
+
await index.update(updateObj);
|
|
355
|
+
} else if ("filter" in params && params.filter) {
|
|
356
|
+
if (Object.keys(params.filter).length === 0) {
|
|
357
|
+
throw new MastraError({
|
|
358
|
+
id: "STORAGE_PINECONE_VECTOR_UPDATE_EMPTY_FILTER",
|
|
359
|
+
text: "Filter cannot be an empty filter object",
|
|
360
|
+
domain: ErrorDomain.STORAGE,
|
|
361
|
+
category: ErrorCategory.USER,
|
|
362
|
+
details: { indexName }
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
const translatedFilter = this.transformFilter(params.filter);
|
|
366
|
+
if (translatedFilter) {
|
|
367
|
+
const stats = await this.describeIndex({ indexName });
|
|
368
|
+
const dummyVector = new Array(stats.dimension).fill(1 / Math.sqrt(stats.dimension));
|
|
369
|
+
const results = await index.query({
|
|
370
|
+
vector: dummyVector,
|
|
371
|
+
topK: 1e4,
|
|
372
|
+
filter: translatedFilter,
|
|
373
|
+
includeMetadata: false,
|
|
374
|
+
includeValues: false
|
|
375
|
+
});
|
|
376
|
+
const idsToUpdate = results.matches.map((m) => m.id);
|
|
377
|
+
for (const id of idsToUpdate) {
|
|
378
|
+
const updateObj = { id };
|
|
379
|
+
if (update.vector) {
|
|
380
|
+
updateObj.values = update.vector;
|
|
381
|
+
}
|
|
382
|
+
if (update.metadata) {
|
|
383
|
+
updateObj.metadata = update.metadata;
|
|
384
|
+
}
|
|
385
|
+
await index.update(updateObj);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
332
388
|
}
|
|
333
|
-
await index.update(updateObj);
|
|
334
389
|
} catch (error) {
|
|
390
|
+
if (error instanceof MastraError) throw error;
|
|
335
391
|
throw new MastraError(
|
|
336
392
|
{
|
|
337
393
|
id: "STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_FAILED",
|
|
338
394
|
domain: ErrorDomain.STORAGE,
|
|
339
395
|
category: ErrorCategory.THIRD_PARTY,
|
|
340
|
-
details: {
|
|
396
|
+
details: {
|
|
397
|
+
indexName,
|
|
398
|
+
..."id" in params && params.id && { id: params.id },
|
|
399
|
+
..."filter" in params && params.filter && { filter: JSON.stringify(params.filter) }
|
|
400
|
+
}
|
|
341
401
|
},
|
|
342
402
|
error
|
|
343
403
|
);
|
|
@@ -361,7 +421,97 @@ var PineconeVector = class extends MastraVector {
|
|
|
361
421
|
id: "STORAGE_PINECONE_VECTOR_DELETE_VECTOR_FAILED",
|
|
362
422
|
domain: ErrorDomain.STORAGE,
|
|
363
423
|
category: ErrorCategory.THIRD_PARTY,
|
|
364
|
-
details: {
|
|
424
|
+
details: {
|
|
425
|
+
indexName,
|
|
426
|
+
...id && { id }
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
error
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Deletes multiple vectors by IDs or filter.
|
|
435
|
+
* @param indexName - The name of the index containing the vectors.
|
|
436
|
+
* @param ids - Array of vector IDs to delete (mutually exclusive with filter).
|
|
437
|
+
* @param filter - Filter to match vectors to delete (mutually exclusive with ids).
|
|
438
|
+
* @param namespace - The namespace of the index (optional, Pinecone-specific).
|
|
439
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
440
|
+
* @throws Will throw an error if both ids and filter are provided, or if neither is provided.
|
|
441
|
+
*/
|
|
442
|
+
async deleteVectors(params) {
|
|
443
|
+
const { indexName, filter, ids } = params;
|
|
444
|
+
const namespace = params.namespace;
|
|
445
|
+
if (ids && filter) {
|
|
446
|
+
throw new MastraError({
|
|
447
|
+
id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_MUTUALLY_EXCLUSIVE",
|
|
448
|
+
text: "Cannot specify both ids and filter - they are mutually exclusive",
|
|
449
|
+
domain: ErrorDomain.STORAGE,
|
|
450
|
+
category: ErrorCategory.USER,
|
|
451
|
+
details: { indexName }
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
if (!ids && !filter) {
|
|
455
|
+
throw new MastraError({
|
|
456
|
+
id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_NO_TARGET",
|
|
457
|
+
text: "Either filter or ids must be provided",
|
|
458
|
+
domain: ErrorDomain.STORAGE,
|
|
459
|
+
category: ErrorCategory.USER,
|
|
460
|
+
details: { indexName }
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
if (ids && ids.length === 0) {
|
|
464
|
+
throw new MastraError({
|
|
465
|
+
id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_EMPTY_IDS",
|
|
466
|
+
text: "Cannot delete with empty ids array",
|
|
467
|
+
domain: ErrorDomain.STORAGE,
|
|
468
|
+
category: ErrorCategory.USER,
|
|
469
|
+
details: { indexName }
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
if (filter && Object.keys(filter).length === 0) {
|
|
473
|
+
throw new MastraError({
|
|
474
|
+
id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_EMPTY_FILTER",
|
|
475
|
+
text: "Cannot delete with empty filter object",
|
|
476
|
+
domain: ErrorDomain.STORAGE,
|
|
477
|
+
category: ErrorCategory.USER,
|
|
478
|
+
details: { indexName }
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
try {
|
|
482
|
+
const index = this.client.Index(indexName).namespace(namespace || "");
|
|
483
|
+
if (ids) {
|
|
484
|
+
await index.deleteMany(ids);
|
|
485
|
+
} else if (filter) {
|
|
486
|
+
const translatedFilter = this.transformFilter(filter);
|
|
487
|
+
if (translatedFilter) {
|
|
488
|
+
const stats = await this.describeIndex({ indexName });
|
|
489
|
+
const dummyVector = new Array(stats.dimension).fill(1 / Math.sqrt(stats.dimension));
|
|
490
|
+
const results = await index.query({
|
|
491
|
+
vector: dummyVector,
|
|
492
|
+
topK: 1e4,
|
|
493
|
+
filter: translatedFilter,
|
|
494
|
+
includeMetadata: false,
|
|
495
|
+
includeValues: false
|
|
496
|
+
});
|
|
497
|
+
const idsToDelete = results.matches.map((m) => m.id);
|
|
498
|
+
if (idsToDelete.length > 0) {
|
|
499
|
+
await index.deleteMany(idsToDelete);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
} catch (error) {
|
|
504
|
+
if (error instanceof MastraError) throw error;
|
|
505
|
+
throw new MastraError(
|
|
506
|
+
{
|
|
507
|
+
id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_FAILED",
|
|
508
|
+
domain: ErrorDomain.STORAGE,
|
|
509
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
510
|
+
details: {
|
|
511
|
+
indexName,
|
|
512
|
+
...filter && { filter: JSON.stringify(filter) },
|
|
513
|
+
...ids && { idsCount: ids.length }
|
|
514
|
+
}
|
|
365
515
|
},
|
|
366
516
|
error
|
|
367
517
|
);
|
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":";;;;;;AAkCO,IAAM,wBAAA,GAAN,cAAuC,oBAAA,CAA2C;AAAA,EACpE,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,MAAA,EAAQ,MAAM,CAAA;AAAA,MAC7B,OAAA,EAAS,CAAC,SAAS,CAAA;AAAA,MACnB,OAAO,EAAC;AAAA,MACR,QAAQ;AAAC,KACX;AAAA,EACF;AAAA,EAEA,UAAU,MAAA,EAAqD;AAC7D,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,MAAM,CAAA,EAAG,OAAO,MAAA;AACjC,IAAA,IAAA,CAAK,eAAe,MAAM,CAAA;AAC1B,IAAA,OAAO,IAAA,CAAK,cAAc,MAAM,CAAA;AAAA,EAClC;AAAA,EAEQ,aAAA,CAAc,I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C3B;AAAA,QACA;AAAA,OACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,YAAA,CAAa,EAAE,SAAA,EAAW,EAAA,EAAI,WAAU,EAA8C;AAC1F,IAAA,IAAI;AACF,MAAA,MAAM,KAAA,GAAQ,KAAK,MAAA,CAAO,KAAA,CAAM,SAAS,CAAA,CAAE,SAAA,CAAU,aAAa,EAAE,CAAA;AACpE,MAAA,MAAM,KAAA,CAAM,UAAU,EAAE,CAAA;AAAA,IAC1B,SAAS,KAAA,EAAO;AACd,MAAA,MAAM,IAAI,WAAA;AAAA,QACR;AAAA,UACE,EAAA,EAAI,8CAAA;AAAA,UACJ,QAAQ,WAAA,CAAY,OAAA;AAAA,UACpB,UAAU,aAAA,CAAc,WAAA;AAAA,UACxB,OAAA,EAAS,EAAE,SAAA,EAAW,EAAA;AAAG,SAC3B;AAAA,QACA;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACF;;;ACnXO,IAAM,eAAA,GAAkB,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;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 OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n QueryOperator,\n FilterValue,\n OperatorCondition,\n} from '@mastra/core/vector/filter';\n\ntype InitialOperatorValueMap = Omit<OperatorValueMap, '$regex' | '$options' | '$elemMatch' | '$all'> & {\n $contains: string;\n $gt: number | Date;\n $gte: number | Date;\n $lt: number | Date;\n $lte: number | Date;\n};\n\ntype PineconeOperatorValueMap = InitialOperatorValueMap & {\n $all: OperatorCondition<keyof InitialOperatorValueMap, InitialOperatorValueMap>[] | FilterValue[];\n};\ntype PineconeLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$not' | '$nor'>;\n\ntype PineconeBlacklisted = BlacklistedRootOperators | '$not' | '$nor';\n\nexport type PineconeVectorFilter = VectorFilter<\n keyof PineconeOperatorValueMap,\n PineconeOperatorValueMap,\n PineconeLogicalOperatorValueMap,\n PineconeBlacklisted\n>;\n\nexport class PineconeFilterTranslator extends BaseFilterTranslator<PineconeVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or'],\n array: ['$in', '$all', '$nin'],\n element: ['$exists'],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: PineconeVectorFilter): PineconeVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n return this.translateNode(filter);\n }\n\n private translateNode(node: PineconeVectorFilter, currentPath: string = ''): any {\n if (this.isRegex(node)) {\n throw new Error('Regex is not supported in Pinecone');\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\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, currentPath);\n return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;\n }\n\n // Process each entry\n const result: Record<string, 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, currentPath);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Handle nested $all\n if (Object.keys(value).length === 1 && '$all' in value) {\n const translated = this.translateNode(value, key);\n if (translated.$and) {\n return translated;\n }\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 return result;\n }\n\n private translateOperator(operator: QueryOperator, value: any, currentPath: string = ''): any {\n // Handle $all specially\n if (operator === '$all') {\n if (!Array.isArray(value) || value.length === 0) {\n throw new Error('A non-empty array is required for the $all operator');\n }\n\n return this.simulateAllOperator(currentPath, value);\n }\n\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} from '@mastra/core/vector';\nimport { Pinecone } from '@pinecone-database/pinecone';\nimport type {\n IndexStatsDescription,\n QueryOptions,\n RecordSparseValues,\n ServerlessSpecCloudEnum,\n UpdateOptions,\n} from '@pinecone-database/pinecone';\n\nimport { PineconeFilterTranslator } from './filter';\nimport type { PineconeVectorFilter } from './filter';\n\ninterface PineconeIndexStats extends IndexStats {\n namespaces?: IndexStatsDescription['namespaces'];\n}\n\ninterface PineconeQueryVectorParams extends QueryVectorParams<PineconeVectorFilter> {\n namespace?: string;\n sparseVector?: RecordSparseValues;\n}\n\ninterface PineconeUpsertVectorParams extends UpsertVectorParams {\n namespace?: string;\n sparseVectors?: RecordSparseValues[];\n}\n\ninterface PineconeUpdateVectorParams extends UpdateVectorParams {\n namespace?: string;\n}\n\ninterface PineconeDeleteVectorParams extends DeleteVectorParams {\n namespace?: string;\n}\n\nexport class PineconeVector extends MastraVector<PineconeVectorFilter> {\n private client: Pinecone;\n private cloud: ServerlessSpecCloudEnum;\n private region: string;\n\n /**\n * Creates a new PineconeVector client.\n * @param id - The unique identifier for this vector store instance.\n * @param apiKey - The API key for Pinecone.\n * @param environment - The environment for Pinecone.\n * @param cloud - The cloud provider for Pinecone.\n * @param region - The region for Pinecone.\n */\n constructor({\n id,\n apiKey,\n environment,\n cloud,\n region,\n }: {\n id: string;\n apiKey: string;\n environment?: string;\n region?: string;\n cloud?: ServerlessSpecCloudEnum;\n }) {\n super({ id });\n const opts: { apiKey: string; controllerHostUrl?: string } = { apiKey };\n if (environment) {\n opts['controllerHostUrl'] = environment;\n }\n this.client = new Pinecone(opts);\n this.cloud = cloud || 'aws';\n this.region = region || 'us-east-1';\n }\n\n get indexSeparator(): string {\n return '-';\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n try {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new Error('Dimension must be a positive integer');\n }\n if (metric && !['cosine', 'euclidean', 'dotproduct'].includes(metric)) {\n throw new Error('Metric must be one of: cosine, euclidean, dotproduct');\n }\n } catch (validationError) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_CREATE_INDEX_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, dimension, metric },\n },\n validationError,\n );\n }\n\n try {\n await this.client.createIndex({\n name: indexName,\n dimension: dimension,\n metric: metric,\n spec: {\n serverless: {\n cloud: this.cloud,\n region: this.region,\n },\n },\n });\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.errors?.[0]?.message || error?.message;\n if (\n error.status === 409 ||\n (typeof message === 'string' &&\n (message.toLowerCase().includes('already exists') || message.toLowerCase().includes('duplicate')))\n ) {\n // Fetch index info and check dimensions\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n // For any other errors, wrap in MastraError\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n async upsert({\n indexName,\n vectors,\n metadata,\n ids,\n namespace,\n sparseVectors,\n }: PineconeUpsertVectorParams): Promise<string[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n // Generate IDs if not provided\n const vectorIds = ids || vectors.map(() => crypto.randomUUID());\n\n const records = vectors.map((vector, i) => ({\n id: vectorIds[i]!,\n values: vector,\n ...(sparseVectors?.[i] && { sparseValues: sparseVectors?.[i] }),\n metadata: metadata?.[i] || {},\n }));\n\n // Pinecone has a limit of 100 vectors per upsert request\n const batchSize = 100;\n try {\n for (let i = 0; i < records.length; i += batchSize) {\n const batch = records.slice(i, i + batchSize);\n await index.upsert(batch);\n }\n\n return vectorIds;\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors.length },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: PineconeVectorFilter) {\n const translator = new PineconeFilterTranslator();\n return translator.translate(filter);\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n namespace,\n sparseVector,\n }: PineconeQueryVectorParams): Promise<QueryResult[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n const translatedFilter = this.transformFilter(filter) ?? undefined;\n\n const queryParams: QueryOptions = {\n vector: queryVector,\n topK,\n includeMetadata: true,\n includeValues: includeVector,\n filter: translatedFilter,\n };\n\n // If sparse vector is provided, use hybrid search\n if (sparseVector) {\n queryParams.sparseVector = sparseVector;\n }\n\n try {\n const results = await index.query(queryParams);\n\n return results.matches.map(match => ({\n id: match.id,\n score: match.score || 0,\n metadata: match.metadata as Record<string, any>,\n ...(includeVector && { vector: match.values || [] }),\n }));\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const indexesResult = await this.client.listIndexes();\n return indexesResult?.indexes?.map(index => index.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.STORAGE,\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<PineconeIndexStats> {\n try {\n const index = this.client.Index(indexName);\n const stats = await index.describeIndexStats();\n const description = await this.client.describeIndex(indexName);\n\n return {\n dimension: description.dimension,\n count: stats.totalRecordCount || 0,\n metric: description.metric as 'cosine' | 'euclidean' | 'dotproduct',\n namespaces: stats.namespaces,\n };\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\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.deleteIndex(indexName);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to update.\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 * @param namespace - The namespace of the index (optional).\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, update, namespace }: PineconeUpdateVectorParams): Promise<void> {\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'No updates provided',\n details: { indexName, id },\n });\n }\n\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n const updateObj: UpdateOptions = { id };\n\n if (update.vector) {\n updateObj.values = update.vector;\n }\n\n if (update.metadata) {\n updateObj.metadata = update.metadata;\n }\n\n await index.update(updateObj);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @param namespace - The namespace of the index (optional).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ indexName, id, namespace }: PineconeDeleteVectorParams): Promise<void> {\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n await index.deleteOne(id);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\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 Pinecone Vector.\n */\nexport const PINECONE_PROMPT = `When querying Pinecone, 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- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- A non-empty array is required for $all operator\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\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 { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\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":";;;;;;AAkCO,IAAM,wBAAA,GAAN,cAAuC,oBAAA,CAA2C;AAAA,EACpE,qBAAA,GAAyC;AAC1D,IAAA,OAAO;AAAA,MACL,GAAG,oBAAA,CAAqB,iBAAA;AAAA,MACxB,OAAA,EAAS,CAAC,MAAA,EAAQ,KAAK,CAAA;AAAA,MACvB,KAAA,EAAO,CAA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+CAAA;AAAA,UACJ,QAAQ,WAAA,CAAY,OAAA;AAAA,UACpB,UAAU,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;;;ACrkBO,IAAM,eAAA,GAAkB,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;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 OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n QueryOperator,\n FilterValue,\n OperatorCondition,\n} from '@mastra/core/vector/filter';\n\ntype InitialOperatorValueMap = Omit<OperatorValueMap, '$regex' | '$options' | '$elemMatch' | '$all'> & {\n $contains: string;\n $gt: number | Date;\n $gte: number | Date;\n $lt: number | Date;\n $lte: number | Date;\n};\n\ntype PineconeOperatorValueMap = InitialOperatorValueMap & {\n $all: OperatorCondition<keyof InitialOperatorValueMap, InitialOperatorValueMap>[] | FilterValue[];\n};\ntype PineconeLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$not' | '$nor'>;\n\ntype PineconeBlacklisted = BlacklistedRootOperators | '$not' | '$nor';\n\nexport type PineconeVectorFilter = VectorFilter<\n keyof PineconeOperatorValueMap,\n PineconeOperatorValueMap,\n PineconeLogicalOperatorValueMap,\n PineconeBlacklisted\n>;\n\nexport class PineconeFilterTranslator extends BaseFilterTranslator<PineconeVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or'],\n array: ['$in', '$all', '$nin'],\n element: ['$exists'],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: PineconeVectorFilter): PineconeVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n return this.translateNode(filter);\n }\n\n private translateNode(node: PineconeVectorFilter, currentPath: string = ''): any {\n if (this.isRegex(node)) {\n throw new Error('Regex is not supported in Pinecone');\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\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, currentPath);\n return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;\n }\n\n // Process each entry\n const result: Record<string, 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, currentPath);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Handle nested $all\n if (Object.keys(value).length === 1 && '$all' in value) {\n const translated = this.translateNode(value, key);\n if (translated.$and) {\n return translated;\n }\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 return result;\n }\n\n private translateOperator(operator: QueryOperator, value: any, currentPath: string = ''): any {\n // Handle $all specially\n if (operator === '$all') {\n if (!Array.isArray(value) || value.length === 0) {\n throw new Error('A non-empty array is required for the $all operator');\n }\n\n return this.simulateAllOperator(currentPath, value);\n }\n\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 DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport { Pinecone } from '@pinecone-database/pinecone';\nimport type {\n IndexStatsDescription,\n QueryOptions,\n RecordSparseValues,\n ServerlessSpecCloudEnum,\n UpdateOptions,\n} from '@pinecone-database/pinecone';\n\nimport { PineconeFilterTranslator } from './filter';\nimport type { PineconeVectorFilter } from './filter';\n\ninterface PineconeIndexStats extends IndexStats {\n namespaces?: IndexStatsDescription['namespaces'];\n}\n\ninterface PineconeQueryVectorParams extends QueryVectorParams<PineconeVectorFilter> {\n namespace?: string;\n sparseVector?: RecordSparseValues;\n}\n\ninterface PineconeUpsertVectorParams extends UpsertVectorParams {\n namespace?: string;\n sparseVectors?: RecordSparseValues[];\n}\n\n// Pinecone-specific update params that includes namespace in both union branches\ntype PineconeUpdateVectorParams =\n | {\n indexName: string;\n id: string;\n filter?: never;\n update: { vector?: number[]; metadata?: Record<string, any> };\n namespace?: string;\n }\n | {\n indexName: string;\n id?: never;\n filter: PineconeVectorFilter;\n update: { vector?: number[]; metadata?: Record<string, any> };\n namespace?: string;\n };\n\ninterface PineconeDeleteVectorParams extends DeleteVectorParams {\n namespace?: string;\n}\n\ninterface PineconeDeleteVectorsParams extends DeleteVectorsParams<PineconeVectorFilter> {\n namespace?: string;\n}\n\nexport class PineconeVector extends MastraVector<PineconeVectorFilter> {\n private client: Pinecone;\n private cloud: ServerlessSpecCloudEnum;\n private region: string;\n\n /**\n * Creates a new PineconeVector client.\n * @param id - The unique identifier for this vector store instance.\n * @param apiKey - The API key for Pinecone.\n * @param environment - The environment for Pinecone.\n * @param cloud - The cloud provider for Pinecone.\n * @param region - The region for Pinecone.\n */\n constructor({\n id,\n apiKey,\n environment,\n cloud,\n region,\n }: {\n id: string;\n apiKey: string;\n environment?: string;\n region?: string;\n cloud?: ServerlessSpecCloudEnum;\n }) {\n super({ id });\n const opts: { apiKey: string; controllerHostUrl?: string } = { apiKey };\n if (environment) {\n opts['controllerHostUrl'] = environment;\n }\n this.client = new Pinecone(opts);\n this.cloud = cloud || 'aws';\n this.region = region || 'us-east-1';\n }\n\n get indexSeparator(): string {\n return '-';\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n try {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new Error('Dimension must be a positive integer');\n }\n if (metric && !['cosine', 'euclidean', 'dotproduct'].includes(metric)) {\n throw new Error('Metric must be one of: cosine, euclidean, dotproduct');\n }\n } catch (validationError) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_CREATE_INDEX_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, dimension, metric },\n },\n validationError,\n );\n }\n\n try {\n await this.client.createIndex({\n name: indexName,\n dimension: dimension,\n metric: metric,\n spec: {\n serverless: {\n cloud: this.cloud,\n region: this.region,\n },\n },\n });\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.errors?.[0]?.message || error?.message;\n if (\n error.status === 409 ||\n (typeof message === 'string' &&\n (message.toLowerCase().includes('already exists') || message.toLowerCase().includes('duplicate')))\n ) {\n // Fetch index info and check dimensions\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n // For any other errors, wrap in MastraError\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n async upsert({\n indexName,\n vectors,\n metadata,\n ids,\n namespace,\n sparseVectors,\n }: PineconeUpsertVectorParams): Promise<string[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n // Generate IDs if not provided\n const vectorIds = ids || vectors.map(() => crypto.randomUUID());\n\n const records = vectors.map((vector, i) => ({\n id: vectorIds[i]!,\n values: vector,\n ...(sparseVectors?.[i] && { sparseValues: sparseVectors?.[i] }),\n metadata: metadata?.[i] || {},\n }));\n\n // Pinecone has a limit of 100 vectors per upsert request\n const batchSize = 100;\n try {\n for (let i = 0; i < records.length; i += batchSize) {\n const batch = records.slice(i, i + batchSize);\n await index.upsert(batch);\n }\n\n return vectorIds;\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors.length },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: PineconeVectorFilter) {\n const translator = new PineconeFilterTranslator();\n return translator.translate(filter);\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n namespace,\n sparseVector,\n }: PineconeQueryVectorParams): Promise<QueryResult[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n const translatedFilter = this.transformFilter(filter) ?? undefined;\n\n const queryParams: QueryOptions = {\n vector: queryVector,\n topK,\n includeMetadata: true,\n includeValues: includeVector,\n filter: translatedFilter,\n };\n\n // If sparse vector is provided, use hybrid search\n if (sparseVector) {\n queryParams.sparseVector = sparseVector;\n }\n\n try {\n const results = await index.query(queryParams);\n\n return results.matches.map(match => ({\n id: match.id,\n score: match.score || 0,\n metadata: match.metadata as Record<string, any>,\n ...(includeVector && { vector: match.values || [] }),\n }));\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const indexesResult = await this.client.listIndexes();\n return indexesResult?.indexes?.map(index => index.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.STORAGE,\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<PineconeIndexStats> {\n try {\n const index = this.client.Index(indexName);\n const stats = await index.describeIndexStats();\n const description = await this.client.describeIndex(indexName);\n\n return {\n dimension: description.dimension,\n count: stats.totalRecordCount || 0,\n metric: description.metric as 'cosine' | 'euclidean' | 'dotproduct',\n namespaces: stats.namespaces,\n };\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\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.deleteIndex(indexName);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * Note: Pinecone only supports update by ID, not by filter.\n * @param params - Parameters containing the id for targeting the vector to update\n * @param params.indexName - The name of the index containing the vector.\n * @param params.id - The ID of the vector to update.\n * @param params.update - An object containing the vector and/or metadata to update.\n * @param namespace - The namespace of the index (optional, Pinecone-specific).\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(params: PineconeUpdateVectorParams): Promise<void> {\n const { indexName, update } = params;\n\n // Validate mutually exclusive parameters\n if ('id' in params && params.id && 'filter' in params && params.filter) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_MUTUALLY_EXCLUSIVE',\n text: 'Cannot specify both id and filter - they are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!('id' in params && params.id) && !('filter' in params && params.filter)) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_NO_TARGET',\n text: 'Either id or filter must be provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'No updates provided',\n details: { indexName },\n });\n }\n\n // Extract Pinecone-specific namespace field\n const namespace = params.namespace;\n\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n // Handle update by ID\n if ('id' in params && params.id) {\n const updateObj: UpdateOptions = { id: params.id };\n\n if (update.vector) {\n updateObj.values = update.vector;\n }\n\n if (update.metadata) {\n updateObj.metadata = update.metadata;\n }\n\n await index.update(updateObj);\n }\n // Handle update by filter (query first, then update each)\n else if ('filter' in params && params.filter) {\n // Validate filter is not empty\n if (Object.keys(params.filter).length === 0) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_EMPTY_FILTER',\n text: 'Filter cannot be an empty filter object',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n const translatedFilter = this.transformFilter(params.filter);\n if (translatedFilter) {\n // Get index stats to know dimensions for dummy vector\n const stats = await this.describeIndex({ indexName });\n\n // Create a normalized dummy vector for querying (avoid zero vector for cosine similarity)\n const dummyVector = new Array(stats.dimension).fill(1 / Math.sqrt(stats.dimension));\n\n // Query with large topK to get all matching vectors\n // Pinecone's max topK is 10000\n const results = await index.query({\n vector: dummyVector,\n topK: 10000,\n filter: translatedFilter,\n includeMetadata: false,\n includeValues: false,\n });\n\n // Update each matching vector\n const idsToUpdate = results.matches.map(m => m.id as string);\n for (const id of idsToUpdate) {\n const updateObj: UpdateOptions = { id };\n\n if (update.vector) {\n updateObj.values = update.vector;\n }\n\n if (update.metadata) {\n updateObj.metadata = update.metadata;\n }\n\n await index.update(updateObj);\n }\n }\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...('id' in params && params.id && { id: params.id }),\n ...('filter' in params && params.filter && { filter: JSON.stringify(params.filter) }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @param namespace - The namespace of the index (optional).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ indexName, id, namespace }: PineconeDeleteVectorParams): Promise<void> {\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n await index.deleteOne(id);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\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 * @param namespace - The namespace of the index (optional, Pinecone-specific).\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(params: PineconeDeleteVectorsParams): Promise<void> {\n const { indexName, filter, ids } = params;\n const namespace = params.namespace;\n\n // Validate mutually exclusive parameters\n if (ids && filter) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_DELETE_VECTORS_MUTUALLY_EXCLUSIVE',\n text: 'Cannot specify both ids and filter - they are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!ids && !filter) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_DELETE_VECTORS_NO_TARGET',\n text: 'Either filter or ids must be provided',\n domain: ErrorDomain.STORAGE,\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: 'STORAGE_PINECONE_VECTOR_DELETE_VECTORS_EMPTY_IDS',\n text: 'Cannot delete with empty ids array',\n domain: ErrorDomain.STORAGE,\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: 'STORAGE_PINECONE_VECTOR_DELETE_VECTORS_EMPTY_FILTER',\n text: 'Cannot delete with empty filter object',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n if (ids) {\n // Delete by IDs - Pinecone's deleteMany accepts an array of IDs\n await index.deleteMany(ids);\n } else if (filter) {\n // Delete by filter - Pinecone's deleteMany doesn't properly support metadata filters\n // We need to query for matching IDs first, then delete them\n const translatedFilter = this.transformFilter(filter);\n if (translatedFilter) {\n // Get index stats to know dimensions for dummy vector\n const stats = await this.describeIndex({ indexName });\n\n // Create a normalized dummy vector for querying (avoid zero vector for cosine similarity)\n const dummyVector = new Array(stats.dimension).fill(1 / Math.sqrt(stats.dimension));\n\n // Query with large topK to get all matching vectors\n // Pinecone's max topK is 10000\n const results = await index.query({\n vector: dummyVector,\n topK: 10000,\n filter: translatedFilter,\n includeMetadata: false,\n includeValues: false,\n });\n\n // Extract IDs and delete them\n const idsToDelete = results.matches.map(m => m.id as string);\n if (idsToDelete.length > 0) {\n await index.deleteMany(idsToDelete);\n }\n }\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_VECTORS_FAILED',\n domain: ErrorDomain.STORAGE,\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 Pinecone Vector.\n */\nexport const PINECONE_PROMPT = `When querying Pinecone, 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- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- A non-empty array is required for $all operator\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\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 { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}`;\n"]}
|
package/dist/vector/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MastraVector } from '@mastra/core/vector';
|
|
2
|
-
import type { QueryResult, IndexStats, CreateIndexParams, UpsertVectorParams, QueryVectorParams, DescribeIndexParams, DeleteIndexParams, DeleteVectorParams,
|
|
2
|
+
import type { QueryResult, IndexStats, CreateIndexParams, UpsertVectorParams, QueryVectorParams, DescribeIndexParams, DeleteIndexParams, DeleteVectorParams, DeleteVectorsParams } from '@mastra/core/vector';
|
|
3
3
|
import type { IndexStatsDescription, RecordSparseValues, ServerlessSpecCloudEnum } from '@pinecone-database/pinecone';
|
|
4
4
|
import type { PineconeVectorFilter } from './filter.js';
|
|
5
5
|
interface PineconeIndexStats extends IndexStats {
|
|
@@ -13,12 +13,31 @@ interface PineconeUpsertVectorParams extends UpsertVectorParams {
|
|
|
13
13
|
namespace?: string;
|
|
14
14
|
sparseVectors?: RecordSparseValues[];
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
type PineconeUpdateVectorParams = {
|
|
17
|
+
indexName: string;
|
|
18
|
+
id: string;
|
|
19
|
+
filter?: never;
|
|
20
|
+
update: {
|
|
21
|
+
vector?: number[];
|
|
22
|
+
metadata?: Record<string, any>;
|
|
23
|
+
};
|
|
17
24
|
namespace?: string;
|
|
18
|
-
}
|
|
25
|
+
} | {
|
|
26
|
+
indexName: string;
|
|
27
|
+
id?: never;
|
|
28
|
+
filter: PineconeVectorFilter;
|
|
29
|
+
update: {
|
|
30
|
+
vector?: number[];
|
|
31
|
+
metadata?: Record<string, any>;
|
|
32
|
+
};
|
|
33
|
+
namespace?: string;
|
|
34
|
+
};
|
|
19
35
|
interface PineconeDeleteVectorParams extends DeleteVectorParams {
|
|
20
36
|
namespace?: string;
|
|
21
37
|
}
|
|
38
|
+
interface PineconeDeleteVectorsParams extends DeleteVectorsParams<PineconeVectorFilter> {
|
|
39
|
+
namespace?: string;
|
|
40
|
+
}
|
|
22
41
|
export declare class PineconeVector extends MastraVector<PineconeVectorFilter> {
|
|
23
42
|
private client;
|
|
24
43
|
private cloud;
|
|
@@ -54,16 +73,16 @@ export declare class PineconeVector extends MastraVector<PineconeVectorFilter> {
|
|
|
54
73
|
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
55
74
|
/**
|
|
56
75
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
57
|
-
*
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
60
|
-
* @param
|
|
61
|
-
* @param update
|
|
62
|
-
* @param namespace - The namespace of the index (optional).
|
|
76
|
+
* Note: Pinecone only supports update by ID, not by filter.
|
|
77
|
+
* @param params - Parameters containing the id for targeting the vector to update
|
|
78
|
+
* @param params.indexName - The name of the index containing the vector.
|
|
79
|
+
* @param params.id - The ID of the vector to update.
|
|
80
|
+
* @param params.update - An object containing the vector and/or metadata to update.
|
|
81
|
+
* @param namespace - The namespace of the index (optional, Pinecone-specific).
|
|
63
82
|
* @returns A promise that resolves when the update is complete.
|
|
64
83
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
65
84
|
*/
|
|
66
|
-
updateVector(
|
|
85
|
+
updateVector(params: PineconeUpdateVectorParams): Promise<void>;
|
|
67
86
|
/**
|
|
68
87
|
* Deletes a vector by its ID.
|
|
69
88
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -73,6 +92,16 @@ export declare class PineconeVector extends MastraVector<PineconeVectorFilter> {
|
|
|
73
92
|
* @throws Will throw an error if the deletion operation fails.
|
|
74
93
|
*/
|
|
75
94
|
deleteVector({ indexName, id, namespace }: PineconeDeleteVectorParams): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Deletes multiple vectors by IDs or filter.
|
|
97
|
+
* @param indexName - The name of the index containing the vectors.
|
|
98
|
+
* @param ids - Array of vector IDs to delete (mutually exclusive with filter).
|
|
99
|
+
* @param filter - Filter to match vectors to delete (mutually exclusive with ids).
|
|
100
|
+
* @param namespace - The namespace of the index (optional, Pinecone-specific).
|
|
101
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
102
|
+
* @throws Will throw an error if both ids and filter are provided, or if neither is provided.
|
|
103
|
+
*/
|
|
104
|
+
deleteVectors(params: PineconeDeleteVectorsParams): Promise<void>;
|
|
76
105
|
}
|
|
77
106
|
export {};
|
|
78
107
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"AACA,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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"AACA,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,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EACV,qBAAqB,EAErB,kBAAkB,EAClB,uBAAuB,EAExB,MAA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E,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB3F;;;;;;;;OAQG;IACG,aAAa,CAAC,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC;CAkGxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/pinecone",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
4
4
|
"description": "Pinecone vector store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,16 +25,17 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@microsoft/api-extractor": "^7.52.8",
|
|
27
27
|
"@types/node": "22.13.17",
|
|
28
|
-
"@vitest/coverage-v8": "4.0.
|
|
29
|
-
"@vitest/ui": "4.0.
|
|
28
|
+
"@vitest/coverage-v8": "4.0.12",
|
|
29
|
+
"@vitest/ui": "4.0.12",
|
|
30
30
|
"dotenv": "^17.0.0",
|
|
31
31
|
"eslint": "^9.37.0",
|
|
32
32
|
"tsup": "^8.5.0",
|
|
33
33
|
"typescript": "^5.8.3",
|
|
34
|
-
"vitest": "
|
|
35
|
-
"@
|
|
34
|
+
"vitest": "4.0.12",
|
|
35
|
+
"@internal/lint": "0.0.53",
|
|
36
36
|
"@internal/types-builder": "0.0.28",
|
|
37
|
-
"@internal/
|
|
37
|
+
"@internal/storage-test-utils": "0.0.49",
|
|
38
|
+
"@mastra/core": "1.0.0-beta.5"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|