@mastra/pinecone 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ name: mastra-pinecone
3
3
  description: Documentation for @mastra/pinecone. Use when working with @mastra/pinecone APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/pinecone"
6
- version: "1.1.1"
6
+ version: "1.1.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.1",
2
+ "version": "1.1.2",
3
3
  "package": "@mastra/pinecone",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -14,6 +14,12 @@ Memory processors are [processors](https://mastra.ai/docs/agents/processors) tha
14
14
 
15
15
  Mastra automatically adds these processors when memory is enabled:
16
16
 
17
+ ### `MemoryInputFilter`
18
+
19
+ Trims client-echoed history before memory loaders run. For an existing thread, it keeps only the current user turn or new tool results. For an empty thread, it keeps the full initial input and removes provider item metadata from assistant parts that could refer to items that don't exist in storage.
20
+
21
+ This processor runs first so `MessageHistory`, `SemanticRecall`, and Observational Memory receive only the new input they need.
22
+
17
23
  ### `MessageHistory`
18
24
 
19
25
  Retrieves message history and persists new messages.
@@ -22,13 +28,15 @@ Retrieves message history and persists new messages.
22
28
 
23
29
  ```typescript
24
30
  memory: new Memory({
25
- lastMessages: 10,
31
+ options: {
32
+ lastMessages: 10,
33
+ },
26
34
  })
27
35
  ```
28
36
 
29
37
  **Mastra internally:**
30
38
 
31
- 1. Creates a `MessageHistory` processor with `limit: 10`
39
+ 1. Creates a `MessageHistory` processor with `lastMessages: 10`
32
40
  2. Adds it to the agent's input processors (runs before the LLM)
33
41
  3. Adds it to the agent's output processors (runs after the LLM)
34
42
 
@@ -55,7 +63,9 @@ const agent = new Agent({
55
63
  id: 'memory-store',
56
64
  url: 'file:memory.db',
57
65
  }),
58
- lastMessages: 10, // MessageHistory processor automatically added
66
+ options: {
67
+ lastMessages: 10, // MessageHistory processor automatically added
68
+ },
59
69
  }),
60
70
  })
61
71
  ```
@@ -79,7 +89,7 @@ memory: new Memory({
79
89
  1. Creates a `SemanticRecall` processor
80
90
  2. Adds it to the agent's input processors (runs before the LLM)
81
91
  3. Adds it to the agent's output processors (runs after the LLM)
82
- 4. Requires both a vector store and embedder to be configured
92
+ 4. Requires a vector store, plus an embedder unless the vector store generates embeddings itself
83
93
 
84
94
  **What it does:**
85
95
 
@@ -93,7 +103,7 @@ import { Agent } from '@mastra/core/agent'
93
103
  import { Memory } from '@mastra/memory'
94
104
  import { LibSQLStore } from '@mastra/libsql'
95
105
  import { PineconeVector } from '@mastra/pinecone'
96
- import { OpenAIEmbedder } from '@mastra/openai'
106
+ import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
97
107
  import { openai } from '@ai-sdk/openai'
98
108
 
99
109
  const agent = new Agent({
@@ -109,10 +119,7 @@ const agent = new Agent({
109
119
  id: 'memory-vector',
110
120
  apiKey: process.env.PINECONE_API_KEY!,
111
121
  }),
112
- embedder: new OpenAIEmbedder({
113
- model: 'text-embedding-3-small',
114
- apiKey: process.env.OPENAI_API_KEY!,
115
- }),
122
+ embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
116
123
  semanticRecall: { enabled: true }, // SemanticRecall processor automatically added
117
124
  }),
118
125
  })
@@ -187,7 +194,9 @@ const agent = new Agent({
187
194
  model: 'openai/gpt-5.6-sol',
188
195
  memory: new Memory({
189
196
  storage: new LibSQLStore({ id: 'memory-store', url: 'file:memory.db' }),
190
- lastMessages: 10, // This would normally add MessageHistory(10)
197
+ options: {
198
+ lastMessages: 10, // This would normally add MessageHistory(10)
199
+ },
191
200
  }),
192
201
  inputProcessors: [
193
202
  customMessageHistory, // Your custom one is used instead
@@ -206,7 +215,7 @@ Understanding the execution order is important when combining guardrails with me
206
215
  [Memory Processors] → [Your inputProcessors]
207
216
  ```
208
217
 
209
- 1. **Memory processors run FIRST**: `WorkingMemory`, `MessageHistory`, `SemanticRecall`
218
+ 1. **Memory processors run FIRST**: `MemoryInputFilter`, then `WorkingMemory`, `MessageHistory`, and `SemanticRecall`
210
219
  2. **Your input processors run AFTER**: guardrails, filters, validators
211
220
 
212
221
  As a result, memory loads message history before your processors can validate or filter the input.
@@ -256,7 +265,7 @@ const agent = new Agent({
256
265
  name: 'safe-agent',
257
266
  instructions: 'You are a helpful assistant',
258
267
  model: 'openai/gpt-5.6-sol',
259
- memory: new Memory({ lastMessages: 10 }),
268
+ memory: new Memory({ options: { lastMessages: 10 } }),
260
269
  // Your guardrail runs BEFORE memory saves
261
270
  outputProcessors: [contentBlocker],
262
271
  })
@@ -296,7 +305,7 @@ const agent = new Agent({
296
305
  name: 'validated-agent',
297
306
  instructions: 'You are a helpful assistant',
298
307
  model: 'openai/gpt-5.6-sol',
299
- memory: new Memory({ lastMessages: 10 }),
308
+ memory: new Memory({ options: { lastMessages: 10 } }),
300
309
  // Your guardrail runs AFTER memory loads history
301
310
  inputProcessors: [inputValidator],
302
311
  })
@@ -373,7 +382,7 @@ export const supportAgent = new Agent({
373
382
  name: 'Support agent',
374
383
  instructions: 'Answer customer support questions.',
375
384
  model: 'openai/gpt-5.6-sol',
376
- memory: new Memory({ lastMessages: 10 }),
385
+ memory: new Memory({ options: { lastMessages: 10 } }),
377
386
  inputProcessors: [new AttachmentUploader()],
378
387
  })
379
388
  ```
@@ -50,23 +50,25 @@ console.log(results)
50
50
 
51
51
  The `topK` parameter specifies the maximum number of most similar results to return from the vector search.
52
52
 
53
- Results include both the text content and a similarity score:
53
+ Each result includes an `id`, a similarity `score`, and the stored `metadata`. When you store chunk text in metadata, it's available as `metadata.text`:
54
54
 
55
55
  ```ts
56
56
  [
57
57
  {
58
- text: 'Climate change poses significant challenges...',
58
+ id: 'chunk-1',
59
59
  score: 0.89,
60
- metadata: { source: 'article1.txt' },
60
+ metadata: { text: 'Climate change poses significant challenges...', source: 'article1.txt' },
61
61
  },
62
62
  {
63
- text: 'Rising temperatures affect crop yields...',
63
+ id: 'chunk-2',
64
64
  score: 0.82,
65
- metadata: { source: 'article1.txt' },
65
+ metadata: { text: 'Rising temperatures affect crop yields...', source: 'article1.txt' },
66
66
  },
67
67
  ]
68
68
  ```
69
69
 
70
+ Results can also include `vector` when you set `includeVector: true`, and `document` when the store returns the original document (Chroma only).
71
+
70
72
  ## Advanced retrieval options
71
73
 
72
74
  ### Metadata Filtering
@@ -54,6 +54,29 @@ const results = await store.hybridQuery({
54
54
 
55
55
  See the [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb) for details on `createSearchIndex()`, `textQuery()`, and `hybridQuery()`.
56
56
 
57
+ ### Automated Embedding
58
+
59
+ MongoDB can generate the embeddings itself, so you don't need an embedding provider in your application. Create the index with `autoEmbed` and a Voyage AI model, write plain text, and search with a query string:
60
+
61
+ ```ts
62
+ await store.createIndex({
63
+ indexName: 'myCollection',
64
+ autoEmbed: { model: 'voyage-4' },
65
+ })
66
+ await store.upsert({
67
+ indexName: 'myCollection',
68
+ documents: chunks.map(chunk => chunk.text),
69
+ metadata: chunks.map(chunk => ({ text: chunk.text })),
70
+ })
71
+ const results = await store.query({
72
+ indexName: 'myCollection',
73
+ queryText: 'search terms',
74
+ topK: 10,
75
+ })
76
+ ```
77
+
78
+ Automated Embedding is a MongoDB Preview feature and needs a deployment where it's available. See the [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb) for the supported options and requirements.
79
+
57
80
  **PgVector**:
58
81
 
59
82
  ```ts
@@ -207,7 +230,7 @@ await store.upsert({
207
230
  **libSQL**:
208
231
 
209
232
  ```ts
210
- import { LibSQLVector } from '@mastra/core/vector/libsql'
233
+ import { LibSQLVector } from '@mastra/libsql'
211
234
 
212
235
  const store = new LibSQLVector({
213
236
  id: 'libsql-vector',
@@ -248,6 +271,34 @@ await store.upsert({
248
271
  })
249
272
  ```
250
273
 
274
+ **Weaviate**:
275
+
276
+ ```ts
277
+ import { WeaviateVector } from '@mastra/weaviate'
278
+
279
+ const store = new WeaviateVector({
280
+ id: 'weaviate-vector',
281
+ httpHost: process.env.WEAVIATE_HOST,
282
+ httpPort: 443,
283
+ httpSecure: true,
284
+ grpcHost: process.env.WEAVIATE_GRPC_HOST,
285
+ grpcPort: 443,
286
+ grpcSecure: true,
287
+ apiKey: process.env.WEAVIATE_API_KEY,
288
+ })
289
+
290
+ await store.createIndex({
291
+ indexName: 'myCollection',
292
+ dimension: 1536,
293
+ })
294
+
295
+ await store.upsert({
296
+ indexName: 'myCollection',
297
+ vectors: embeddings,
298
+ metadata: chunks.map(chunk => ({ text: chunk.text })),
299
+ })
300
+ ```
301
+
251
302
  **Cloudflare**:
252
303
 
253
304
  ```ts
@@ -317,6 +368,29 @@ await store.upsert({
317
368
 
318
369
  For detailed setup instructions and best practices, see the [official Elasticsearch documentation](https://www.elastic.co/docs/solutions/search/get-started).
319
370
 
371
+ **Azure AI Search**:
372
+
373
+ ```ts
374
+ import { AzureAISearchVector } from '@mastra/azure-ai-search'
375
+
376
+ const store = new AzureAISearchVector({
377
+ id: 'azure-search-vectors',
378
+ endpoint: process.env.AZURE_AI_SEARCH_ENDPOINT!,
379
+ credential: process.env.AZURE_AI_SEARCH_CREDENTIAL!,
380
+ })
381
+
382
+ await store.createIndex({
383
+ indexName: 'my-collection',
384
+ dimension: 1536,
385
+ })
386
+
387
+ await store.upsert({
388
+ indexName: 'my-collection',
389
+ vectors: embeddings,
390
+ metadata: chunks.map(chunk => ({ text: chunk.text })),
391
+ })
392
+ ```
393
+
320
394
  **Couchbase**:
321
395
 
322
396
  ```ts
@@ -534,6 +608,17 @@ Namespace names must:
534
608
 
535
609
  - Example: `_namespace` isn't valid (starts with underscore)
536
610
 
611
+ **Weaviate**:
612
+
613
+ Index names map to Weaviate collections, which:
614
+
615
+ - Are capitalized by Weaviate (the first letter is upper-cased)
616
+ - Should contain only letters, numbers, and the `_` character
617
+ - Must start with a letter, since only the first character is upper-cased (a leading digit or symbol stays invalid)
618
+ - Preserve the original Mastra index name in the collection description, so `listIndexes()` and `describeIndex()` return the name you supplied
619
+ - Example: `my_collection` is stored as `My_collection` and returned as `my_collection`
620
+ - Example: `123_collection` isn't valid (starts with a digit)
621
+
537
622
  **Cloudflare**:
538
623
 
539
624
  Index names must:
@@ -587,6 +672,17 @@ Index names must:
587
672
  - Example: `myindex-` isn't valid (ends with hyphen)
588
673
  - Example: `MyIndex` isn't valid (contains uppercase letters)
589
674
 
675
+ **Azure AI Search**:
676
+
677
+ Index names must:
678
+
679
+ - Use only lowercase letters, numbers, dashes (`-`), and underscore (`_`) characters
680
+ - Not start or end with a dash
681
+ - Be between 2 and 128 characters long
682
+ - Example: `my-index-123` and `my_index` are valid
683
+ - Example: `MyIndex` isn't valid (contains uppercase letters)
684
+ - Example: `my-index-` isn't valid (ends with a dash)
685
+
590
686
  ### Upserting Embeddings
591
687
 
592
688
  After creating an index, you can store embeddings along with their basic metadata:
@@ -650,7 +746,7 @@ Key metadata considerations:
650
746
 
651
747
  ## Deleting vectors
652
748
 
653
- When building RAG applications, you often need to clean up stale vectors when documents are deleted or updated. Mastra provides the `deleteVectors` method that supports deleting vectors by metadata filters, making it straightforward to remove all embeddings associated with a specific document.
749
+ Use `deleteVectors` with a metadata filter to remove embeddings associated with a document. This is useful for cleaning up stale vectors after a document is deleted or updated.
654
750
 
655
751
  ### Delete by Metadata Filter
656
752
 
@@ -130,24 +130,28 @@ Query results are returned in this format:
130
130
  interface QueryResult {
131
131
  id: string
132
132
  score: number
133
- metadata: Record<string, any>
133
+ metadata?: Record<string, any>
134
134
  vector?: number[] // Only included if includeVector is true
135
135
  }
136
136
  ```
137
137
 
138
138
  ## Error handling
139
139
 
140
- The store throws typed errors that can be caught:
140
+ The store throws `MastraError` instances from `@mastra/core/error`:
141
141
 
142
142
  ```typescript
143
+ import { MastraError } from '@mastra/core/error'
144
+
143
145
  try {
144
146
  await store.query({
145
147
  indexName: 'index_name',
146
148
  queryVector: queryVector,
147
149
  })
148
150
  } catch (error) {
149
- if (error instanceof VectorStoreError) {
150
- console.log(error.code) // 'connection_failed' | 'invalid_dimension' | etc
151
+ if (error instanceof MastraError) {
152
+ console.log(error.id) // 'MASTRA_VECTOR_PINECONE_QUERY_FAILED'
153
+ console.log(error.domain) // 'STORAGE'
154
+ console.log(error.category) // 'USER' | 'THIRD_PARTY'
151
155
  console.log(error.details) // Additional error context
152
156
  }
153
157
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["BaseFilterTranslator","MastraVector","Pinecone","MastraError","ErrorDomain","ErrorCategory"],"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"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 PineconeConfiguration,\n QueryOptions,\n RecordSparseValues,\n ServerlessSpecCloudEnum,\n UpdateOptions,\n} from '@pinecone-database/pinecone';\n\nimport { PineconeFilterTranslator } from './filter';\nimport type { PineconeVectorFilter } from './filter';\n\n/**\n * Configuration for PineconeVector.\n *\n * Extends the Pinecone client configuration with Mastra-specific fields.\n * All Pinecone configuration options are supported (apiKey, controllerHostUrl,\n * fetchApi, additionalHeaders, sourceTag).\n *\n * @example\n * ```typescript\n * // Simple API key config\n * const vector = new PineconeVector({\n * id: 'my-pinecone',\n * apiKey: 'your-api-key',\n * });\n *\n * // With custom controller host\n * const vector = new PineconeVector({\n * id: 'my-pinecone',\n * apiKey: 'your-api-key',\n * controllerHostUrl: 'https://api.pinecone.io',\n * });\n *\n * // With index creation defaults\n * const vector = new PineconeVector({\n * id: 'my-pinecone',\n * apiKey: 'your-api-key',\n * cloud: 'gcp',\n * region: 'us-central1',\n * });\n * ```\n */\nexport type PineconeVectorConfig = PineconeConfiguration & {\n /** The unique identifier for this vector store instance. */\n id: string;\n /** The cloud provider for new index creation. Defaults to 'aws'. */\n cloud?: ServerlessSpecCloudEnum;\n /** The region for new index creation. Defaults to 'us-east-1'. */\n region?: string;\n};\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 *\n * @param config - Configuration options for the Pinecone client.\n * @see {@link PineconeVectorConfig} for all available options.\n */\n constructor({ id, cloud, region, ...pineconeConfig }: PineconeVectorConfig) {\n super({ id });\n this.client = new Pinecone(pineconeConfig);\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 if (!queryVector) {\n throw new MastraError({\n id: createVectorErrorId('PINECONE', 'QUERY', 'MISSING_VECTOR'),\n text: 'queryVector is required for Pinecone queries. Metadata-only queries are not supported by this vector store.',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\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"],"mappings":";;;;;;;AAkCA,IAAa,2BAAb,cAA8CA,2BAAAA,qBAA2C;CACvF,wBAA4D;EAC1D,OAAO;GACL,GAAGA,2BAAAA,qBAAqB;GACxB,SAAS,CAAC,QAAQ,KAAK;GACvB,OAAO;IAAC;IAAO;IAAQ;GAAM;GAC7B,SAAS,CAAC,SAAS;GACnB,OAAO,CAAC;GACR,QAAQ,CAAC;EACX;CACF;CAEA,UAAU,QAAqD;EAC7D,IAAI,KAAK,QAAQ,MAAM,GAAG,OAAO;EACjC,KAAK,eAAe,MAAM;EAC1B,OAAO,KAAK,cAAc,MAAM;CAClC;CAEA,cAAsB,MAA4B,cAAsB,IAAS;EAC/E,IAAI,KAAK,QAAQ,IAAI,GACnB,MAAM,IAAI,MAAM,oCAAoC;EAEtD,IAAI,KAAK,YAAY,IAAI,GAAG,OAAO,KAAK,yBAAyB,IAAI;EACrE,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO,EAAE,KAAK,KAAK,qBAAqB,IAAI,EAAE;EAEvE,MAAM,UAAU,OAAO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EpB,MAAM,QAAQ,MAAM,KAAK,cAAc,EAAE,UAAU,CAAC;KAGpD,MAAM,cAAc,IAAI,MAAM,MAAM,SAAS,CAAC,CAAC,KAAK,IAAI,KAAK,KAAK,MAAM,SAAS,CAAC;KAalF,MAAM,eAAc,MATE,MAAM,MAAM;MAChC,QAAQ;MACR,MAAM;MACN,QAAQ;MACR,iBAAiB;MACjB,eAAe;KACjB,CAAC,EAAA,CAG2B,QAAQ,KAAI,MAAK,EAAE,EAAY;KAC3D,IAAI,YAAY,SAAS,GACvB,MAAM,MAAM,WAAW,WAAW;IAEtC;GACF;EACF,SAAS,OAAO;GACd,IAAI,iBAAiBF,mBAAAA,aAAa,MAAM;GACxC,MAAM,IAAIA,mBAAAA,YACR;IACE,KAAA,GAAA,qBAAA,oBAAA,CAAwB,YAAY,kBAAkB,QAAQ;IAC9D,QAAQC,mBAAAA,YAAY;IACpB,UAAUC,mBAAAA,cAAc;IACxB,SAAS;KACP;KACA,GAAI,UAAU,EAAE,QAAQ,KAAK,UAAU,MAAM,EAAE;KAC/C,GAAI,OAAO,EAAE,UAAU,IAAI,OAAO;IACpC;GACF,GACA,KACF;EACF;CACF;AACF;;;;;;;ACvmBA,MAAa,kBAAkB"}
1
+ {"version":3,"file":"index.cjs","names":["BaseFilterTranslator","MastraVector","Pinecone","MastraError","createVectorErrorId","ErrorDomain","ErrorCategory"],"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"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 PineconeConfiguration,\n QueryOptions,\n RecordSparseValues,\n ServerlessSpecCloudEnum,\n UpdateOptions,\n} from '@pinecone-database/pinecone';\n\nimport { PineconeFilterTranslator } from './filter';\nimport type { PineconeVectorFilter } from './filter';\n\n/**\n * Configuration for PineconeVector.\n *\n * Extends the Pinecone client configuration with Mastra-specific fields.\n * All Pinecone configuration options are supported (apiKey, controllerHostUrl,\n * fetchApi, additionalHeaders, sourceTag).\n *\n * @example\n * ```typescript\n * // Simple API key config\n * const vector = new PineconeVector({\n * id: 'my-pinecone',\n * apiKey: 'your-api-key',\n * });\n *\n * // With custom controller host\n * const vector = new PineconeVector({\n * id: 'my-pinecone',\n * apiKey: 'your-api-key',\n * controllerHostUrl: 'https://api.pinecone.io',\n * });\n *\n * // With index creation defaults\n * const vector = new PineconeVector({\n * id: 'my-pinecone',\n * apiKey: 'your-api-key',\n * cloud: 'gcp',\n * region: 'us-central1',\n * });\n * ```\n */\nexport type PineconeVectorConfig = PineconeConfiguration & {\n /** The unique identifier for this vector store instance. */\n id: string;\n /** The cloud provider for new index creation. Defaults to 'aws'. */\n cloud?: ServerlessSpecCloudEnum;\n /** The region for new index creation. Defaults to 'us-east-1'. */\n region?: string;\n};\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 *\n * @param config - Configuration options for the Pinecone client.\n * @see {@link PineconeVectorConfig} for all available options.\n */\n constructor({ id, cloud, region, ...pineconeConfig }: PineconeVectorConfig) {\n super({ id });\n this.client = new Pinecone(pineconeConfig);\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 if (!queryVector) {\n throw new MastraError({\n id: createVectorErrorId('PINECONE', 'QUERY', 'MISSING_VECTOR'),\n text: 'queryVector is required for Pinecone queries. Metadata-only queries are not supported by this vector store.',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\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"],"mappings":";;;;;;;AAkCA,IAAa,2BAAb,cAA8CA,2BAAAA,qBAA2C;CACvF,wBAA4D;EAC1D,OAAO;GACL,GAAGA,2BAAAA,qBAA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AAK,UAAU,MAAM,EAAE;KAC/C,GAAI,OAAO,EAAE,UAAU,IAAI,OAAO;IACpC;GACF,GACA,KACF;EACF;CACF;AACF;;;;;;;ACvmBA,MAAa,kBAAkB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/pinecone",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Pinecone vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,18 +24,17 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "22.20.1",
27
- "@vitest/coverage-v8": "4.1.10",
28
- "@vitest/ui": "4.1.10",
27
+ "@vitest/coverage-v8": "4.1.11",
28
+ "@vitest/ui": "4.1.11",
29
29
  "dotenv": "^17.4.2",
30
- "eslint": "^10.7.0",
31
30
  "tsdown": "0.22.9",
32
31
  "tsx": "^4.23.1",
33
32
  "typescript": "^7.0.2",
34
- "vitest": "4.1.10",
35
- "@internal/storage-test-utils": "0.0.126",
36
- "@internal/lint": "0.0.130",
37
- "@internal/types-builder": "0.0.105",
38
- "@mastra/core": "1.64.0"
33
+ "vitest": "4.1.11",
34
+ "@internal/lint": "0.0.145",
35
+ "@internal/types-builder": "0.0.120",
36
+ "@mastra/core": "1.79.0",
37
+ "@internal/storage-test-utils": "0.0.141"
39
38
  },
40
39
  "peerDependencies": {
41
40
  "@mastra/core": ">=1.0.0-0 <2.0.0-0"
@@ -59,7 +58,7 @@
59
58
  "build:lib": "tsdown --silent --config tsdown.config.ts",
60
59
  "build:watch": "tsdown --watch --silent --config tsdown.config.ts",
61
60
  "test": "vitest run",
62
- "lint": "oxlint . && eslint .",
63
- "lint:fix": "oxlint --fix . && eslint --fix ."
61
+ "lint": "oxlint --type-aware .",
62
+ "lint:fix": "oxlint --type-aware --fix ."
64
63
  }
65
64
  }