@mastra/pinecone 1.0.0-beta.2 → 1.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @mastra/pinecone
2
2
 
3
+ ## 1.0.0-beta.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Standardize error IDs across all storage and vector stores using centralized helper functions (`createStorageErrorId` and `createVectorErrorId`). This ensures consistent error ID patterns (`MASTRA_STORAGE_{STORE}_{OPERATION}_{STATUS}` and `MASTRA_VECTOR_{STORE}_{OPERATION}_{STATUS}`) across the codebase for better error tracking and debugging. ([#10913](https://github.com/mastra-ai/mastra/pull/10913))
8
+
9
+ - Updated dependencies [[`3076c67`](https://github.com/mastra-ai/mastra/commit/3076c6778b18988ae7d5c4c5c466366974b2d63f), [`85d7ee1`](https://github.com/mastra-ai/mastra/commit/85d7ee18ff4e14d625a8a30ec6656bb49804989b), [`c6c1092`](https://github.com/mastra-ai/mastra/commit/c6c1092f8fbf76109303f69e000e96fd1960c4ce), [`81dc110`](https://github.com/mastra-ai/mastra/commit/81dc11008d147cf5bdc8996ead1aa61dbdebb6fc), [`7aedb74`](https://github.com/mastra-ai/mastra/commit/7aedb74883adf66af38e270e4068fd42e7a37036), [`8f02d80`](https://github.com/mastra-ai/mastra/commit/8f02d800777397e4b45d7f1ad041988a8b0c6630), [`d7aad50`](https://github.com/mastra-ai/mastra/commit/d7aad501ce61646b76b4b511e558ac4eea9884d0), [`ce0a73a`](https://github.com/mastra-ai/mastra/commit/ce0a73abeaa75b10ca38f9e40a255a645d50ebfb), [`a02e542`](https://github.com/mastra-ai/mastra/commit/a02e542d23179bad250b044b17ff023caa61739f), [`a372c64`](https://github.com/mastra-ai/mastra/commit/a372c640ad1fd12e8f0613cebdc682fc156b4d95), [`8846867`](https://github.com/mastra-ai/mastra/commit/8846867ffa9a3746767618e314bebac08eb77d87), [`42a42cf`](https://github.com/mastra-ai/mastra/commit/42a42cf3132b9786feecbb8c13c583dce5b0e198), [`ae08bf0`](https://github.com/mastra-ai/mastra/commit/ae08bf0ebc6a4e4da992b711c4a389c32ba84cf4), [`21735a7`](https://github.com/mastra-ai/mastra/commit/21735a7ef306963554a69a89b44f06c3bcd85141), [`1d877b8`](https://github.com/mastra-ai/mastra/commit/1d877b8d7b536a251c1a7a18db7ddcf4f68d6f8b)]:
10
+ - @mastra/core@1.0.0-beta.7
11
+
3
12
  ## 1.0.0-beta.2
4
13
 
5
14
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var error = require('@mastra/core/error');
4
+ var storage = require('@mastra/core/storage');
4
5
  var vector = require('@mastra/core/vector');
5
6
  var pinecone = require('@pinecone-database/pinecone');
6
7
  var filter = require('@mastra/core/vector/filter');
@@ -126,7 +127,7 @@ var PineconeVector = class extends vector.MastraVector {
126
127
  } catch (validationError) {
127
128
  throw new error.MastraError(
128
129
  {
129
- id: "STORAGE_PINECONE_VECTOR_CREATE_INDEX_INVALID_ARGS",
130
+ id: storage.createVectorErrorId("PINECONE", "CREATE_INDEX", "INVALID_ARGS"),
130
131
  domain: error.ErrorDomain.STORAGE,
131
132
  category: error.ErrorCategory.USER,
132
133
  details: { indexName, dimension, metric }
@@ -154,7 +155,7 @@ var PineconeVector = class extends vector.MastraVector {
154
155
  }
155
156
  throw new error.MastraError(
156
157
  {
157
- id: "STORAGE_PINECONE_VECTOR_CREATE_INDEX_FAILED",
158
+ id: storage.createVectorErrorId("PINECONE", "CREATE_INDEX", "FAILED"),
158
159
  domain: error.ErrorDomain.STORAGE,
159
160
  category: error.ErrorCategory.THIRD_PARTY,
160
161
  details: { indexName, dimension, metric }
@@ -189,7 +190,7 @@ var PineconeVector = class extends vector.MastraVector {
189
190
  } catch (error$1) {
190
191
  throw new error.MastraError(
191
192
  {
192
- id: "STORAGE_PINECONE_VECTOR_UPSERT_FAILED",
193
+ id: storage.createVectorErrorId("PINECONE", "UPSERT", "FAILED"),
193
194
  domain: error.ErrorDomain.STORAGE,
194
195
  category: error.ErrorCategory.THIRD_PARTY,
195
196
  details: { indexName, vectorCount: vectors.length }
@@ -234,7 +235,7 @@ var PineconeVector = class extends vector.MastraVector {
234
235
  } catch (error$1) {
235
236
  throw new error.MastraError(
236
237
  {
237
- id: "STORAGE_PINECONE_VECTOR_QUERY_FAILED",
238
+ id: storage.createVectorErrorId("PINECONE", "QUERY", "FAILED"),
238
239
  domain: error.ErrorDomain.STORAGE,
239
240
  category: error.ErrorCategory.THIRD_PARTY,
240
241
  details: { indexName, topK }
@@ -250,7 +251,7 @@ var PineconeVector = class extends vector.MastraVector {
250
251
  } catch (error$1) {
251
252
  throw new error.MastraError(
252
253
  {
253
- id: "STORAGE_PINECONE_VECTOR_LIST_INDEXES_FAILED",
254
+ id: storage.createVectorErrorId("PINECONE", "LIST_INDEXES", "FAILED"),
254
255
  domain: error.ErrorDomain.STORAGE,
255
256
  category: error.ErrorCategory.THIRD_PARTY
256
257
  },
@@ -278,7 +279,7 @@ var PineconeVector = class extends vector.MastraVector {
278
279
  } catch (error$1) {
279
280
  throw new error.MastraError(
280
281
  {
281
- id: "STORAGE_PINECONE_VECTOR_DESCRIBE_INDEX_FAILED",
282
+ id: storage.createVectorErrorId("PINECONE", "DESCRIBE_INDEX", "FAILED"),
282
283
  domain: error.ErrorDomain.STORAGE,
283
284
  category: error.ErrorCategory.THIRD_PARTY,
284
285
  details: { indexName }
@@ -293,7 +294,7 @@ var PineconeVector = class extends vector.MastraVector {
293
294
  } catch (error$1) {
294
295
  throw new error.MastraError(
295
296
  {
296
- id: "STORAGE_PINECONE_VECTOR_DELETE_INDEX_FAILED",
297
+ id: storage.createVectorErrorId("PINECONE", "DELETE_INDEX", "FAILED"),
297
298
  domain: error.ErrorDomain.STORAGE,
298
299
  category: error.ErrorCategory.THIRD_PARTY,
299
300
  details: { indexName }
@@ -317,7 +318,7 @@ var PineconeVector = class extends vector.MastraVector {
317
318
  const { indexName, update } = params;
318
319
  if ("id" in params && params.id && "filter" in params && params.filter) {
319
320
  throw new error.MastraError({
320
- id: "STORAGE_PINECONE_VECTOR_UPDATE_MUTUALLY_EXCLUSIVE",
321
+ id: storage.createVectorErrorId("PINECONE", "UPDATE_VECTOR", "MUTUALLY_EXCLUSIVE"),
321
322
  text: "Cannot specify both id and filter - they are mutually exclusive",
322
323
  domain: error.ErrorDomain.STORAGE,
323
324
  category: error.ErrorCategory.USER,
@@ -326,7 +327,7 @@ var PineconeVector = class extends vector.MastraVector {
326
327
  }
327
328
  if (!("id" in params && params.id) && !("filter" in params && params.filter)) {
328
329
  throw new error.MastraError({
329
- id: "STORAGE_PINECONE_VECTOR_UPDATE_NO_TARGET",
330
+ id: storage.createVectorErrorId("PINECONE", "UPDATE_VECTOR", "NO_TARGET"),
330
331
  text: "Either id or filter must be provided",
331
332
  domain: error.ErrorDomain.STORAGE,
332
333
  category: error.ErrorCategory.USER,
@@ -335,7 +336,7 @@ var PineconeVector = class extends vector.MastraVector {
335
336
  }
336
337
  if (!update.vector && !update.metadata) {
337
338
  throw new error.MastraError({
338
- id: "STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_INVALID_ARGS",
339
+ id: storage.createVectorErrorId("PINECONE", "UPDATE_VECTOR", "NO_PAYLOAD"),
339
340
  domain: error.ErrorDomain.STORAGE,
340
341
  category: error.ErrorCategory.USER,
341
342
  text: "No updates provided",
@@ -357,7 +358,7 @@ var PineconeVector = class extends vector.MastraVector {
357
358
  } else if ("filter" in params && params.filter) {
358
359
  if (Object.keys(params.filter).length === 0) {
359
360
  throw new error.MastraError({
360
- id: "STORAGE_PINECONE_VECTOR_UPDATE_EMPTY_FILTER",
361
+ id: storage.createVectorErrorId("PINECONE", "UPDATE_VECTOR", "EMPTY_FILTER"),
361
362
  text: "Filter cannot be an empty filter object",
362
363
  domain: error.ErrorDomain.STORAGE,
363
364
  category: error.ErrorCategory.USER,
@@ -392,7 +393,7 @@ var PineconeVector = class extends vector.MastraVector {
392
393
  if (error$1 instanceof error.MastraError) throw error$1;
393
394
  throw new error.MastraError(
394
395
  {
395
- id: "STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_FAILED",
396
+ id: storage.createVectorErrorId("PINECONE", "UPDATE_VECTOR", "FAILED"),
396
397
  domain: error.ErrorDomain.STORAGE,
397
398
  category: error.ErrorCategory.THIRD_PARTY,
398
399
  details: {
@@ -420,7 +421,7 @@ var PineconeVector = class extends vector.MastraVector {
420
421
  } catch (error$1) {
421
422
  throw new error.MastraError(
422
423
  {
423
- id: "STORAGE_PINECONE_VECTOR_DELETE_VECTOR_FAILED",
424
+ id: storage.createVectorErrorId("PINECONE", "DELETE_VECTOR", "FAILED"),
424
425
  domain: error.ErrorDomain.STORAGE,
425
426
  category: error.ErrorCategory.THIRD_PARTY,
426
427
  details: {
@@ -446,7 +447,7 @@ var PineconeVector = class extends vector.MastraVector {
446
447
  const namespace = params.namespace;
447
448
  if (ids && filter) {
448
449
  throw new error.MastraError({
449
- id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_MUTUALLY_EXCLUSIVE",
450
+ id: storage.createVectorErrorId("PINECONE", "DELETE_VECTORS", "MUTUALLY_EXCLUSIVE"),
450
451
  text: "Cannot specify both ids and filter - they are mutually exclusive",
451
452
  domain: error.ErrorDomain.STORAGE,
452
453
  category: error.ErrorCategory.USER,
@@ -455,7 +456,7 @@ var PineconeVector = class extends vector.MastraVector {
455
456
  }
456
457
  if (!ids && !filter) {
457
458
  throw new error.MastraError({
458
- id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_NO_TARGET",
459
+ id: storage.createVectorErrorId("PINECONE", "DELETE_VECTORS", "NO_TARGET"),
459
460
  text: "Either filter or ids must be provided",
460
461
  domain: error.ErrorDomain.STORAGE,
461
462
  category: error.ErrorCategory.USER,
@@ -464,7 +465,7 @@ var PineconeVector = class extends vector.MastraVector {
464
465
  }
465
466
  if (ids && ids.length === 0) {
466
467
  throw new error.MastraError({
467
- id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_EMPTY_IDS",
468
+ id: storage.createVectorErrorId("PINECONE", "DELETE_VECTORS", "EMPTY_IDS"),
468
469
  text: "Cannot delete with empty ids array",
469
470
  domain: error.ErrorDomain.STORAGE,
470
471
  category: error.ErrorCategory.USER,
@@ -473,7 +474,7 @@ var PineconeVector = class extends vector.MastraVector {
473
474
  }
474
475
  if (filter && Object.keys(filter).length === 0) {
475
476
  throw new error.MastraError({
476
- id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_EMPTY_FILTER",
477
+ id: storage.createVectorErrorId("PINECONE", "DELETE_VECTORS", "EMPTY_FILTER"),
477
478
  text: "Cannot delete with empty filter object",
478
479
  domain: error.ErrorDomain.STORAGE,
479
480
  category: error.ErrorCategory.USER,
@@ -506,7 +507,7 @@ var PineconeVector = class extends vector.MastraVector {
506
507
  if (error$1 instanceof error.MastraError) throw error$1;
507
508
  throw new error.MastraError(
508
509
  {
509
- id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_FAILED",
510
+ id: storage.createVectorErrorId("PINECONE", "DELETE_VECTORS", "FAILED"),
510
511
  domain: error.ErrorDomain.STORAGE,
511
512
  category: error.ErrorCategory.THIRD_PARTY,
512
513
  details: {
@@ -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,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;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"]}
1
+ {"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":["BaseFilterTranslator","MastraVector","Pinecone","MastraError","createVectorErrorId","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,CAAc,IAAA,EAA4B,WAAA,GAAsB,EAAA,EAAS;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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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 { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n 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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', 'UPDATE_VECTOR', '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: createVectorErrorId('PINECONE', 'UPDATE_VECTOR', '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: createVectorErrorId('PINECONE', 'UPDATE_VECTOR', 'NO_PAYLOAD'),\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: createVectorErrorId('PINECONE', 'UPDATE_VECTOR', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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
@@ -1,4 +1,5 @@
1
1
  import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
2
+ import { createVectorErrorId } from '@mastra/core/storage';
2
3
  import { MastraVector } from '@mastra/core/vector';
3
4
  import { Pinecone } from '@pinecone-database/pinecone';
4
5
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
@@ -124,7 +125,7 @@ var PineconeVector = class extends MastraVector {
124
125
  } catch (validationError) {
125
126
  throw new MastraError(
126
127
  {
127
- id: "STORAGE_PINECONE_VECTOR_CREATE_INDEX_INVALID_ARGS",
128
+ id: createVectorErrorId("PINECONE", "CREATE_INDEX", "INVALID_ARGS"),
128
129
  domain: ErrorDomain.STORAGE,
129
130
  category: ErrorCategory.USER,
130
131
  details: { indexName, dimension, metric }
@@ -152,7 +153,7 @@ var PineconeVector = class extends MastraVector {
152
153
  }
153
154
  throw new MastraError(
154
155
  {
155
- id: "STORAGE_PINECONE_VECTOR_CREATE_INDEX_FAILED",
156
+ id: createVectorErrorId("PINECONE", "CREATE_INDEX", "FAILED"),
156
157
  domain: ErrorDomain.STORAGE,
157
158
  category: ErrorCategory.THIRD_PARTY,
158
159
  details: { indexName, dimension, metric }
@@ -187,7 +188,7 @@ var PineconeVector = class extends MastraVector {
187
188
  } catch (error) {
188
189
  throw new MastraError(
189
190
  {
190
- id: "STORAGE_PINECONE_VECTOR_UPSERT_FAILED",
191
+ id: createVectorErrorId("PINECONE", "UPSERT", "FAILED"),
191
192
  domain: ErrorDomain.STORAGE,
192
193
  category: ErrorCategory.THIRD_PARTY,
193
194
  details: { indexName, vectorCount: vectors.length }
@@ -232,7 +233,7 @@ var PineconeVector = class extends MastraVector {
232
233
  } catch (error) {
233
234
  throw new MastraError(
234
235
  {
235
- id: "STORAGE_PINECONE_VECTOR_QUERY_FAILED",
236
+ id: createVectorErrorId("PINECONE", "QUERY", "FAILED"),
236
237
  domain: ErrorDomain.STORAGE,
237
238
  category: ErrorCategory.THIRD_PARTY,
238
239
  details: { indexName, topK }
@@ -248,7 +249,7 @@ var PineconeVector = class extends MastraVector {
248
249
  } catch (error) {
249
250
  throw new MastraError(
250
251
  {
251
- id: "STORAGE_PINECONE_VECTOR_LIST_INDEXES_FAILED",
252
+ id: createVectorErrorId("PINECONE", "LIST_INDEXES", "FAILED"),
252
253
  domain: ErrorDomain.STORAGE,
253
254
  category: ErrorCategory.THIRD_PARTY
254
255
  },
@@ -276,7 +277,7 @@ var PineconeVector = class extends MastraVector {
276
277
  } catch (error) {
277
278
  throw new MastraError(
278
279
  {
279
- id: "STORAGE_PINECONE_VECTOR_DESCRIBE_INDEX_FAILED",
280
+ id: createVectorErrorId("PINECONE", "DESCRIBE_INDEX", "FAILED"),
280
281
  domain: ErrorDomain.STORAGE,
281
282
  category: ErrorCategory.THIRD_PARTY,
282
283
  details: { indexName }
@@ -291,7 +292,7 @@ var PineconeVector = class extends MastraVector {
291
292
  } catch (error) {
292
293
  throw new MastraError(
293
294
  {
294
- id: "STORAGE_PINECONE_VECTOR_DELETE_INDEX_FAILED",
295
+ id: createVectorErrorId("PINECONE", "DELETE_INDEX", "FAILED"),
295
296
  domain: ErrorDomain.STORAGE,
296
297
  category: ErrorCategory.THIRD_PARTY,
297
298
  details: { indexName }
@@ -315,7 +316,7 @@ var PineconeVector = class extends MastraVector {
315
316
  const { indexName, update } = params;
316
317
  if ("id" in params && params.id && "filter" in params && params.filter) {
317
318
  throw new MastraError({
318
- id: "STORAGE_PINECONE_VECTOR_UPDATE_MUTUALLY_EXCLUSIVE",
319
+ id: createVectorErrorId("PINECONE", "UPDATE_VECTOR", "MUTUALLY_EXCLUSIVE"),
319
320
  text: "Cannot specify both id and filter - they are mutually exclusive",
320
321
  domain: ErrorDomain.STORAGE,
321
322
  category: ErrorCategory.USER,
@@ -324,7 +325,7 @@ var PineconeVector = class extends MastraVector {
324
325
  }
325
326
  if (!("id" in params && params.id) && !("filter" in params && params.filter)) {
326
327
  throw new MastraError({
327
- id: "STORAGE_PINECONE_VECTOR_UPDATE_NO_TARGET",
328
+ id: createVectorErrorId("PINECONE", "UPDATE_VECTOR", "NO_TARGET"),
328
329
  text: "Either id or filter must be provided",
329
330
  domain: ErrorDomain.STORAGE,
330
331
  category: ErrorCategory.USER,
@@ -333,7 +334,7 @@ var PineconeVector = class extends MastraVector {
333
334
  }
334
335
  if (!update.vector && !update.metadata) {
335
336
  throw new MastraError({
336
- id: "STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_INVALID_ARGS",
337
+ id: createVectorErrorId("PINECONE", "UPDATE_VECTOR", "NO_PAYLOAD"),
337
338
  domain: ErrorDomain.STORAGE,
338
339
  category: ErrorCategory.USER,
339
340
  text: "No updates provided",
@@ -355,7 +356,7 @@ var PineconeVector = class extends MastraVector {
355
356
  } else if ("filter" in params && params.filter) {
356
357
  if (Object.keys(params.filter).length === 0) {
357
358
  throw new MastraError({
358
- id: "STORAGE_PINECONE_VECTOR_UPDATE_EMPTY_FILTER",
359
+ id: createVectorErrorId("PINECONE", "UPDATE_VECTOR", "EMPTY_FILTER"),
359
360
  text: "Filter cannot be an empty filter object",
360
361
  domain: ErrorDomain.STORAGE,
361
362
  category: ErrorCategory.USER,
@@ -390,7 +391,7 @@ var PineconeVector = class extends MastraVector {
390
391
  if (error instanceof MastraError) throw error;
391
392
  throw new MastraError(
392
393
  {
393
- id: "STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_FAILED",
394
+ id: createVectorErrorId("PINECONE", "UPDATE_VECTOR", "FAILED"),
394
395
  domain: ErrorDomain.STORAGE,
395
396
  category: ErrorCategory.THIRD_PARTY,
396
397
  details: {
@@ -418,7 +419,7 @@ var PineconeVector = class extends MastraVector {
418
419
  } catch (error) {
419
420
  throw new MastraError(
420
421
  {
421
- id: "STORAGE_PINECONE_VECTOR_DELETE_VECTOR_FAILED",
422
+ id: createVectorErrorId("PINECONE", "DELETE_VECTOR", "FAILED"),
422
423
  domain: ErrorDomain.STORAGE,
423
424
  category: ErrorCategory.THIRD_PARTY,
424
425
  details: {
@@ -444,7 +445,7 @@ var PineconeVector = class extends MastraVector {
444
445
  const namespace = params.namespace;
445
446
  if (ids && filter) {
446
447
  throw new MastraError({
447
- id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_MUTUALLY_EXCLUSIVE",
448
+ id: createVectorErrorId("PINECONE", "DELETE_VECTORS", "MUTUALLY_EXCLUSIVE"),
448
449
  text: "Cannot specify both ids and filter - they are mutually exclusive",
449
450
  domain: ErrorDomain.STORAGE,
450
451
  category: ErrorCategory.USER,
@@ -453,7 +454,7 @@ var PineconeVector = class extends MastraVector {
453
454
  }
454
455
  if (!ids && !filter) {
455
456
  throw new MastraError({
456
- id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_NO_TARGET",
457
+ id: createVectorErrorId("PINECONE", "DELETE_VECTORS", "NO_TARGET"),
457
458
  text: "Either filter or ids must be provided",
458
459
  domain: ErrorDomain.STORAGE,
459
460
  category: ErrorCategory.USER,
@@ -462,7 +463,7 @@ var PineconeVector = class extends MastraVector {
462
463
  }
463
464
  if (ids && ids.length === 0) {
464
465
  throw new MastraError({
465
- id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_EMPTY_IDS",
466
+ id: createVectorErrorId("PINECONE", "DELETE_VECTORS", "EMPTY_IDS"),
466
467
  text: "Cannot delete with empty ids array",
467
468
  domain: ErrorDomain.STORAGE,
468
469
  category: ErrorCategory.USER,
@@ -471,7 +472,7 @@ var PineconeVector = class extends MastraVector {
471
472
  }
472
473
  if (filter && Object.keys(filter).length === 0) {
473
474
  throw new MastraError({
474
- id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_EMPTY_FILTER",
475
+ id: createVectorErrorId("PINECONE", "DELETE_VECTORS", "EMPTY_FILTER"),
475
476
  text: "Cannot delete with empty filter object",
476
477
  domain: ErrorDomain.STORAGE,
477
478
  category: ErrorCategory.USER,
@@ -504,7 +505,7 @@ var PineconeVector = class extends MastraVector {
504
505
  if (error instanceof MastraError) throw error;
505
506
  throw new MastraError(
506
507
  {
507
- id: "STORAGE_PINECONE_VECTOR_DELETE_VECTORS_FAILED",
508
+ id: createVectorErrorId("PINECONE", "DELETE_VECTORS", "FAILED"),
508
509
  domain: ErrorDomain.STORAGE,
509
510
  category: ErrorCategory.THIRD_PARTY,
510
511
  details: {
package/dist/index.js.map CHANGED
@@ -1 +1 @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,KAAK,EAAE,EAAY,CAAA;AAC3D,UAAA,IAAI,WAAA,CAAY,SAAS,CAAA,EAAG;AAC1B,YAAA,MAAM,KAAA,CAAM,WAAW,WAAW,CAAA;AAAA,UACpC;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,KAAA,EAAO;AACd,MAAA,IAAI,KAAA,YAAiB,aAAa,MAAM,KAAA;AACxC,MAAA,MAAM,IAAI,WAAA;AAAA,QACR;AAAA,UACE,EAAA,EAAI,+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"]}
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,IA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;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 { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n 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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', 'UPDATE_VECTOR', '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: createVectorErrorId('PINECONE', 'UPDATE_VECTOR', '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: createVectorErrorId('PINECONE', 'UPDATE_VECTOR', 'NO_PAYLOAD'),\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: createVectorErrorId('PINECONE', 'UPDATE_VECTOR', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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: createVectorErrorId('PINECONE', '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"]}
@@ -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,EAC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,QAAQ,EACR,GAAG,EACH,SAAS,EACT,aAAa,GACd,EAAE,0BAA0B,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAmCjD,eAAe,CAAC,MAAM,CAAC,EAAE,oBAAoB;IAKvC,KAAK,CAAC,EACV,SAAS,EACT,WAAW,EACX,IAAS,EACT,MAAM,EACN,aAAqB,EACrB,SAAS,EACT,YAAY,GACb,EAAE,yBAAyB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAwC/C,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAgBtC;;;;;OAKG;IACG,aAAa,CAAC,EAAE,SAAS,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAyB9E,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBlE;;;;;;;;;;OAUG;IACG,YAAY,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;IAwHrE;;;;;;;OAOG;IACG,YAAY,CAAC,EAAE,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.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "Pinecone vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -32,10 +32,10 @@
32
32
  "tsup": "^8.5.0",
33
33
  "typescript": "^5.8.3",
34
34
  "vitest": "4.0.12",
35
- "@internal/lint": "0.0.53",
36
- "@internal/types-builder": "0.0.28",
37
35
  "@internal/storage-test-utils": "0.0.49",
38
- "@mastra/core": "1.0.0-beta.5"
36
+ "@internal/types-builder": "0.0.28",
37
+ "@internal/lint": "0.0.53",
38
+ "@mastra/core": "1.0.0-beta.7"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@mastra/core": ">=1.0.0-0 <2.0.0-0"