@mastra/pinecone 1.0.0-beta.0 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/index.cjs +15 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/dist/vector/index.d.ts +8 -2
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mastra/pinecone
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Adjust pinecone settings ([#10182](https://github.com/mastra-ai/mastra/pull/10182))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`2319326`](https://github.com/mastra-ai/mastra/commit/2319326f8c64e503a09bbcf14be2dd65405445e0), [`d629361`](https://github.com/mastra-ai/mastra/commit/d629361a60f6565b5bfb11976fdaf7308af858e2), [`08c31c1`](https://github.com/mastra-ai/mastra/commit/08c31c188ebccd598acaf55e888b6397d01f7eae), [`fd3d338`](https://github.com/mastra-ai/mastra/commit/fd3d338a2c362174ed5b383f1f011ad9fb0302aa), [`c30400a`](https://github.com/mastra-ai/mastra/commit/c30400a49b994b1b97256fe785eb6c906fc2b232), [`69e0a87`](https://github.com/mastra-ai/mastra/commit/69e0a878896a2da9494945d86e056a5f8f05b851), [`01f8878`](https://github.com/mastra-ai/mastra/commit/01f88783de25e4de048c1c8aace43e26373c6ea5), [`4c77209`](https://github.com/mastra-ai/mastra/commit/4c77209e6c11678808b365d545845918c40045c8), [`d827d08`](https://github.com/mastra-ai/mastra/commit/d827d0808ffe1f3553a84e975806cc989b9735dd), [`23c10a1`](https://github.com/mastra-ai/mastra/commit/23c10a1efdd9a693c405511ab2dc8a1236603162), [`676ccc7`](https://github.com/mastra-ai/mastra/commit/676ccc7fe92468d2d45d39c31a87825c89fd1ea0), [`c10398d`](https://github.com/mastra-ai/mastra/commit/c10398d5b88f1d4af556f4267ff06f1d11e89179), [`00c2387`](https://github.com/mastra-ai/mastra/commit/00c2387f5f04a365316f851e58666ac43f8c4edf), [`ad6250d`](https://github.com/mastra-ai/mastra/commit/ad6250dbdaad927e29f74a27b83f6c468b50a705), [`3a73998`](https://github.com/mastra-ai/mastra/commit/3a73998fa4ebeb7f3dc9301afe78095fc63e7999), [`e16d553`](https://github.com/mastra-ai/mastra/commit/e16d55338403c7553531cc568125c63d53653dff), [`4d59f58`](https://github.com/mastra-ai/mastra/commit/4d59f58de2d90d6e2810a19d4518e38ddddb9038), [`e1bb9c9`](https://github.com/mastra-ai/mastra/commit/e1bb9c94b4eb68b019ae275981be3feb769b5365), [`351a11f`](https://github.com/mastra-ai/mastra/commit/351a11fcaf2ed1008977fa9b9a489fc422e51cd4)]:
|
|
10
|
+
- @mastra/core@1.0.0-beta.3
|
|
11
|
+
|
|
3
12
|
## 1.0.0-beta.0
|
|
4
13
|
|
|
5
14
|
### Major Changes
|
package/dist/index.cjs
CHANGED
|
@@ -86,19 +86,31 @@ var PineconeFilterTranslator = class extends filter.BaseFilterTranslator {
|
|
|
86
86
|
// src/vector/index.ts
|
|
87
87
|
var PineconeVector = class extends vector.MastraVector {
|
|
88
88
|
client;
|
|
89
|
+
cloud;
|
|
90
|
+
region;
|
|
89
91
|
/**
|
|
90
92
|
* Creates a new PineconeVector client.
|
|
91
93
|
* @param id - The unique identifier for this vector store instance.
|
|
92
94
|
* @param apiKey - The API key for Pinecone.
|
|
93
95
|
* @param environment - The environment for Pinecone.
|
|
96
|
+
* @param cloud - The cloud provider for Pinecone.
|
|
97
|
+
* @param region - The region for Pinecone.
|
|
94
98
|
*/
|
|
95
|
-
constructor({
|
|
99
|
+
constructor({
|
|
100
|
+
id,
|
|
101
|
+
apiKey,
|
|
102
|
+
environment,
|
|
103
|
+
cloud,
|
|
104
|
+
region
|
|
105
|
+
}) {
|
|
96
106
|
super({ id });
|
|
97
107
|
const opts = { apiKey };
|
|
98
108
|
if (environment) {
|
|
99
109
|
opts["controllerHostUrl"] = environment;
|
|
100
110
|
}
|
|
101
111
|
this.client = new pinecone.Pinecone(opts);
|
|
112
|
+
this.cloud = cloud || "aws";
|
|
113
|
+
this.region = region || "us-east-1";
|
|
102
114
|
}
|
|
103
115
|
get indexSeparator() {
|
|
104
116
|
return "-";
|
|
@@ -129,8 +141,8 @@ var PineconeVector = class extends vector.MastraVector {
|
|
|
129
141
|
metric,
|
|
130
142
|
spec: {
|
|
131
143
|
serverless: {
|
|
132
|
-
cloud:
|
|
133
|
-
region:
|
|
144
|
+
cloud: this.cloud,
|
|
145
|
+
region: this.region
|
|
134
146
|
}
|
|
135
147
|
}
|
|
136
148
|
});
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":["BaseFilterTranslator","MastraVector","Pinecone","MastraError","ErrorDomain","ErrorCategory","error"],"mappings":";;;;;;;;AAkCO,IAAM,wBAAA,GAAN,cAAuCA,2BAAA,CAA2C;AAAA,EACpE,qBAAA,GAAyC;AAC1D,IAAA,OAAO;AAAA,MACL,GAAGA,2BAAA,CAAqB,iBAAA;AAAA,MACxB,OAAA,EAAS,CAAC,MAAA,EAAQ,KAAK,CAAA;AAAA,MACvB,KAAA,EAAO,CAAC,KAAA,EAAO,MAAA,EAAQ,MAAM,CAAA;AAAA,MAC7B,OAAA,EAAS,CAAC,SAAS,CAAA;AAAA,MACnB,OAAO,EAAC;AAAA,MACR,QAAQ;AAAC,KACX;AAAA,EACF;AAAA,EAEA,UAAU,MAAA,EAAqD;AAC7D,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,MAAM,CAAA,EAAG,OAAO,MAAA;AACjC,IAAA,IAAA,CAAK,eAAe,MAAM,CAAA;AAC1B,IAAA,OAAO,IAA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;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,YAAA,CAAa,EAAE,SAAA,EAAW,EAAA,EAAI,WAAU,EAA8C;AAC1F,IAAA,IAAI;AACF,MAAA,MAAM,KAAA,GAAQ,KAAK,MAAA,CAAO,KAAA,CAAM,SAAS,CAAA,CAAE,SAAA,CAAU,aAAa,EAAE,CAAA;AACpE,MAAA,MAAM,KAAA,CAAM,UAAU,EAAE,CAAA;AAAA,IAC1B,SAASA,OAAA,EAAO;AACd,MAAA,MAAM,IAAIH,iBAAA;AAAA,QACR;AAAA,UACE,EAAA,EAAI,8CAAA;AAAA,UACJ,QAAQC,iBAAA,CAAY,OAAA;AAAA,UACpB,UAAUC,mBAAA,CAAc,WAAA;AAAA,UACxB,OAAA,EAAS,EAAE,SAAA,EAAW,EAAA;AAAG,SAC3B;AAAA,QACAC;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACF;;;AChWO,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 UpdateVectorParams,\n} from '@mastra/core/vector';\nimport { Pinecone } from '@pinecone-database/pinecone';\nimport type {\n IndexStatsDescription,\n QueryOptions,\n RecordSparseValues,\n UpdateOptions,\n} from '@pinecone-database/pinecone';\n\nimport { PineconeFilterTranslator } from './filter';\nimport type { PineconeVectorFilter } from './filter';\n\ninterface PineconeIndexStats extends IndexStats {\n namespaces?: IndexStatsDescription['namespaces'];\n}\n\ninterface PineconeQueryVectorParams extends QueryVectorParams<PineconeVectorFilter> {\n namespace?: string;\n sparseVector?: RecordSparseValues;\n}\n\ninterface PineconeUpsertVectorParams extends UpsertVectorParams {\n namespace?: string;\n sparseVectors?: RecordSparseValues[];\n}\n\ninterface PineconeUpdateVectorParams extends UpdateVectorParams {\n namespace?: string;\n}\n\ninterface PineconeDeleteVectorParams extends DeleteVectorParams {\n namespace?: string;\n}\n\nexport class PineconeVector extends MastraVector<PineconeVectorFilter> {\n private client: Pinecone;\n\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 */\n constructor({ id, apiKey, environment }: { id: string; apiKey: string; environment?: string }) {\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 }\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: 'aws',\n region: 'us-east-1',\n },\n },\n });\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.errors?.[0]?.message || error?.message;\n if (\n error.status === 409 ||\n (typeof message === 'string' &&\n (message.toLowerCase().includes('already exists') || message.toLowerCase().includes('duplicate')))\n ) {\n // Fetch index info and check dimensions\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n // For any other errors, wrap in MastraError\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n async upsert({\n indexName,\n vectors,\n metadata,\n ids,\n namespace,\n sparseVectors,\n }: PineconeUpsertVectorParams): Promise<string[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n // Generate IDs if not provided\n const vectorIds = ids || vectors.map(() => crypto.randomUUID());\n\n const records = vectors.map((vector, i) => ({\n id: vectorIds[i]!,\n values: vector,\n ...(sparseVectors?.[i] && { sparseValues: sparseVectors?.[i] }),\n metadata: metadata?.[i] || {},\n }));\n\n // Pinecone has a limit of 100 vectors per upsert request\n const batchSize = 100;\n try {\n for (let i = 0; i < records.length; i += batchSize) {\n const batch = records.slice(i, i + batchSize);\n await index.upsert(batch);\n }\n\n return vectorIds;\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors.length },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: PineconeVectorFilter) {\n const translator = new PineconeFilterTranslator();\n return translator.translate(filter);\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n namespace,\n sparseVector,\n }: PineconeQueryVectorParams): Promise<QueryResult[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n const translatedFilter = this.transformFilter(filter) ?? undefined;\n\n const queryParams: QueryOptions = {\n vector: queryVector,\n topK,\n includeMetadata: true,\n includeValues: includeVector,\n filter: translatedFilter,\n };\n\n // If sparse vector is provided, use hybrid search\n if (sparseVector) {\n queryParams.sparseVector = sparseVector;\n }\n\n try {\n const results = await index.query(queryParams);\n\n return results.matches.map(match => ({\n id: match.id,\n score: match.score || 0,\n metadata: match.metadata as Record<string, any>,\n ...(includeVector && { vector: match.values || [] }),\n }));\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const indexesResult = await this.client.listIndexes();\n return indexesResult?.indexes?.map(index => index.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<PineconeIndexStats> {\n try {\n const index = this.client.Index(indexName);\n const stats = await index.describeIndexStats();\n const description = await this.client.describeIndex(indexName);\n\n return {\n dimension: description.dimension,\n count: stats.totalRecordCount || 0,\n metric: description.metric as 'cosine' | 'euclidean' | 'dotproduct',\n namespaces: stats.namespaces,\n };\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteIndex(indexName);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to update.\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @param namespace - The namespace of the index (optional).\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, update, namespace }: PineconeUpdateVectorParams): Promise<void> {\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'No updates provided',\n details: { indexName, id },\n });\n }\n\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n const updateObj: UpdateOptions = { id };\n\n if (update.vector) {\n updateObj.values = update.vector;\n }\n\n if (update.metadata) {\n updateObj.metadata = update.metadata;\n }\n\n await index.update(updateObj);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @param namespace - The namespace of the index (optional).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ indexName, id, namespace }: PineconeDeleteVectorParams): Promise<void> {\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n await index.deleteOne(id);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Pinecone Vector.\n */\nexport const PINECONE_PROMPT = `When querying Pinecone, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- A non-empty array is required for $all operator\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}`;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":["BaseFilterTranslator","MastraVector","Pinecone","MastraError","ErrorDomain","ErrorCategory","error"],"mappings":";;;;;;;;AAkCO,IAAM,wBAAA,GAAN,cAAuCA,2BAAA,CAA2C;AAAA,EACpE,qBAAA,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,CAA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AAA;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 UpdateVectorParams,\n} from '@mastra/core/vector';\nimport { Pinecone } from '@pinecone-database/pinecone';\nimport type {\n IndexStatsDescription,\n QueryOptions,\n RecordSparseValues,\n ServerlessSpecCloudEnum,\n UpdateOptions,\n} from '@pinecone-database/pinecone';\n\nimport { PineconeFilterTranslator } from './filter';\nimport type { PineconeVectorFilter } from './filter';\n\ninterface PineconeIndexStats extends IndexStats {\n namespaces?: IndexStatsDescription['namespaces'];\n}\n\ninterface PineconeQueryVectorParams extends QueryVectorParams<PineconeVectorFilter> {\n namespace?: string;\n sparseVector?: RecordSparseValues;\n}\n\ninterface PineconeUpsertVectorParams extends UpsertVectorParams {\n namespace?: string;\n sparseVectors?: RecordSparseValues[];\n}\n\ninterface PineconeUpdateVectorParams extends UpdateVectorParams {\n namespace?: string;\n}\n\ninterface PineconeDeleteVectorParams extends DeleteVectorParams {\n namespace?: string;\n}\n\nexport class PineconeVector extends MastraVector<PineconeVectorFilter> {\n private client: Pinecone;\n private cloud: ServerlessSpecCloudEnum;\n private region: string;\n\n /**\n * Creates a new PineconeVector client.\n * @param id - The unique identifier for this vector store instance.\n * @param apiKey - The API key for Pinecone.\n * @param environment - The environment for Pinecone.\n * @param cloud - The cloud provider for Pinecone.\n * @param region - The region for Pinecone.\n */\n constructor({\n id,\n apiKey,\n environment,\n cloud,\n region,\n }: {\n id: string;\n apiKey: string;\n environment?: string;\n region?: string;\n cloud?: ServerlessSpecCloudEnum;\n }) {\n super({ id });\n const opts: { apiKey: string; controllerHostUrl?: string } = { apiKey };\n if (environment) {\n opts['controllerHostUrl'] = environment;\n }\n this.client = new Pinecone(opts);\n this.cloud = cloud || 'aws';\n this.region = region || 'us-east-1';\n }\n\n get indexSeparator(): string {\n return '-';\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n try {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new Error('Dimension must be a positive integer');\n }\n if (metric && !['cosine', 'euclidean', 'dotproduct'].includes(metric)) {\n throw new Error('Metric must be one of: cosine, euclidean, dotproduct');\n }\n } catch (validationError) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_CREATE_INDEX_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, dimension, metric },\n },\n validationError,\n );\n }\n\n try {\n await this.client.createIndex({\n name: indexName,\n dimension: dimension,\n metric: metric,\n spec: {\n serverless: {\n cloud: this.cloud,\n region: this.region,\n },\n },\n });\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.errors?.[0]?.message || error?.message;\n if (\n error.status === 409 ||\n (typeof message === 'string' &&\n (message.toLowerCase().includes('already exists') || message.toLowerCase().includes('duplicate')))\n ) {\n // Fetch index info and check dimensions\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n // For any other errors, wrap in MastraError\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n async upsert({\n indexName,\n vectors,\n metadata,\n ids,\n namespace,\n sparseVectors,\n }: PineconeUpsertVectorParams): Promise<string[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n // Generate IDs if not provided\n const vectorIds = ids || vectors.map(() => crypto.randomUUID());\n\n const records = vectors.map((vector, i) => ({\n id: vectorIds[i]!,\n values: vector,\n ...(sparseVectors?.[i] && { sparseValues: sparseVectors?.[i] }),\n metadata: metadata?.[i] || {},\n }));\n\n // Pinecone has a limit of 100 vectors per upsert request\n const batchSize = 100;\n try {\n for (let i = 0; i < records.length; i += batchSize) {\n const batch = records.slice(i, i + batchSize);\n await index.upsert(batch);\n }\n\n return vectorIds;\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors.length },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: PineconeVectorFilter) {\n const translator = new PineconeFilterTranslator();\n return translator.translate(filter);\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n namespace,\n sparseVector,\n }: PineconeQueryVectorParams): Promise<QueryResult[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n const translatedFilter = this.transformFilter(filter) ?? undefined;\n\n const queryParams: QueryOptions = {\n vector: queryVector,\n topK,\n includeMetadata: true,\n includeValues: includeVector,\n filter: translatedFilter,\n };\n\n // If sparse vector is provided, use hybrid search\n if (sparseVector) {\n queryParams.sparseVector = sparseVector;\n }\n\n try {\n const results = await index.query(queryParams);\n\n return results.matches.map(match => ({\n id: match.id,\n score: match.score || 0,\n metadata: match.metadata as Record<string, any>,\n ...(includeVector && { vector: match.values || [] }),\n }));\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const indexesResult = await this.client.listIndexes();\n return indexesResult?.indexes?.map(index => index.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<PineconeIndexStats> {\n try {\n const index = this.client.Index(indexName);\n const stats = await index.describeIndexStats();\n const description = await this.client.describeIndex(indexName);\n\n return {\n dimension: description.dimension,\n count: stats.totalRecordCount || 0,\n metric: description.metric as 'cosine' | 'euclidean' | 'dotproduct',\n namespaces: stats.namespaces,\n };\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteIndex(indexName);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to update.\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @param namespace - The namespace of the index (optional).\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, update, namespace }: PineconeUpdateVectorParams): Promise<void> {\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'No updates provided',\n details: { indexName, id },\n });\n }\n\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n const updateObj: UpdateOptions = { id };\n\n if (update.vector) {\n updateObj.values = update.vector;\n }\n\n if (update.metadata) {\n updateObj.metadata = update.metadata;\n }\n\n await index.update(updateObj);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @param namespace - The namespace of the index (optional).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ indexName, id, namespace }: PineconeDeleteVectorParams): Promise<void> {\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n await index.deleteOne(id);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Pinecone Vector.\n */\nexport const PINECONE_PROMPT = `When querying Pinecone, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- A non-empty array is required for $all operator\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}`;\n"]}
|
package/dist/index.js
CHANGED
|
@@ -84,19 +84,31 @@ var PineconeFilterTranslator = class extends BaseFilterTranslator {
|
|
|
84
84
|
// src/vector/index.ts
|
|
85
85
|
var PineconeVector = class extends MastraVector {
|
|
86
86
|
client;
|
|
87
|
+
cloud;
|
|
88
|
+
region;
|
|
87
89
|
/**
|
|
88
90
|
* Creates a new PineconeVector client.
|
|
89
91
|
* @param id - The unique identifier for this vector store instance.
|
|
90
92
|
* @param apiKey - The API key for Pinecone.
|
|
91
93
|
* @param environment - The environment for Pinecone.
|
|
94
|
+
* @param cloud - The cloud provider for Pinecone.
|
|
95
|
+
* @param region - The region for Pinecone.
|
|
92
96
|
*/
|
|
93
|
-
constructor({
|
|
97
|
+
constructor({
|
|
98
|
+
id,
|
|
99
|
+
apiKey,
|
|
100
|
+
environment,
|
|
101
|
+
cloud,
|
|
102
|
+
region
|
|
103
|
+
}) {
|
|
94
104
|
super({ id });
|
|
95
105
|
const opts = { apiKey };
|
|
96
106
|
if (environment) {
|
|
97
107
|
opts["controllerHostUrl"] = environment;
|
|
98
108
|
}
|
|
99
109
|
this.client = new Pinecone(opts);
|
|
110
|
+
this.cloud = cloud || "aws";
|
|
111
|
+
this.region = region || "us-east-1";
|
|
100
112
|
}
|
|
101
113
|
get indexSeparator() {
|
|
102
114
|
return "-";
|
|
@@ -127,8 +139,8 @@ var PineconeVector = class extends MastraVector {
|
|
|
127
139
|
metric,
|
|
128
140
|
spec: {
|
|
129
141
|
serverless: {
|
|
130
|
-
cloud:
|
|
131
|
-
region:
|
|
142
|
+
cloud: this.cloud,
|
|
143
|
+
region: this.region
|
|
132
144
|
}
|
|
133
145
|
}
|
|
134
146
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":[],"mappings":";;;;;;AAkCO,IAAM,wBAAA,GAAN,cAAuC,oBAAA,CAA2C;AAAA,EACpE,qBAAA,GAAyC;AAC1D,IAAA,OAAO;AAAA,MACL,GAAG,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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;AAAA;AAAA,CAAA","file":"index.js","sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n QueryOperator,\n FilterValue,\n OperatorCondition,\n} from '@mastra/core/vector/filter';\n\ntype InitialOperatorValueMap = Omit<OperatorValueMap, '$regex' | '$options' | '$elemMatch' | '$all'> & {\n $contains: string;\n $gt: number | Date;\n $gte: number | Date;\n $lt: number | Date;\n $lte: number | Date;\n};\n\ntype PineconeOperatorValueMap = InitialOperatorValueMap & {\n $all: OperatorCondition<keyof InitialOperatorValueMap, InitialOperatorValueMap>[] | FilterValue[];\n};\ntype PineconeLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$not' | '$nor'>;\n\ntype PineconeBlacklisted = BlacklistedRootOperators | '$not' | '$nor';\n\nexport type PineconeVectorFilter = VectorFilter<\n keyof PineconeOperatorValueMap,\n PineconeOperatorValueMap,\n PineconeLogicalOperatorValueMap,\n PineconeBlacklisted\n>;\n\nexport class PineconeFilterTranslator extends BaseFilterTranslator<PineconeVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or'],\n array: ['$in', '$all', '$nin'],\n element: ['$exists'],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: PineconeVectorFilter): PineconeVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n return this.translateNode(filter);\n }\n\n private translateNode(node: PineconeVectorFilter, currentPath: string = ''): any {\n if (this.isRegex(node)) {\n throw new Error('Regex is not supported in Pinecone');\n }\n if (this.isPrimitive(node)) return this.normalizeComparisonValue(node);\n if (Array.isArray(node)) return { $in: this.normalizeArrayValues(node) };\n\n const entries = Object.entries(node as Record<string, any>);\n const firstEntry = entries[0];\n\n // Handle single operator case\n if (entries.length === 1 && firstEntry && this.isOperator(firstEntry[0])) {\n const [operator, value] = firstEntry;\n const translated = this.translateOperator(operator, value, currentPath);\n return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;\n }\n\n // Process each entry\n const result: Record<string, any> = {};\n\n for (const [key, value] of entries) {\n const newPath = currentPath ? `${currentPath}.${key}` : key;\n\n if (this.isOperator(key)) {\n result[key] = this.translateOperator(key, value, currentPath);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Handle nested $all\n if (Object.keys(value).length === 1 && '$all' in value) {\n const translated = this.translateNode(value, key);\n if (translated.$and) {\n return translated;\n }\n }\n\n // Check if the nested object contains operators\n if (Object.keys(value).length === 0) {\n result[newPath] = this.translateNode(value);\n } else {\n const hasOperators = Object.keys(value).some(k => this.isOperator(k));\n if (hasOperators) {\n // For objects with operators, normalize each operator value\n const normalizedValue: Record<string, any> = {};\n for (const [op, opValue] of Object.entries(value)) {\n normalizedValue[op] = this.isOperator(op) ? this.translateOperator(op, opValue) : opValue;\n }\n result[newPath] = normalizedValue;\n } else {\n // For objects without operators, flatten them\n Object.assign(result, this.translateNode(value, newPath));\n }\n }\n } else {\n result[newPath] = this.translateNode(value);\n }\n }\n\n return result;\n }\n\n private translateOperator(operator: QueryOperator, value: any, currentPath: string = ''): any {\n // Handle $all specially\n if (operator === '$all') {\n if (!Array.isArray(value) || value.length === 0) {\n throw new Error('A non-empty array is required for the $all operator');\n }\n\n return this.simulateAllOperator(currentPath, value);\n }\n\n // Handle logical operators\n if (this.isLogicalOperator(operator)) {\n return Array.isArray(value) ? value.map(item => this.translateNode(item)) : this.translateNode(value);\n }\n\n // Handle comparison and element operators\n return this.normalizeComparisonValue(value);\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n} from '@mastra/core/vector';\nimport { Pinecone } from '@pinecone-database/pinecone';\nimport type {\n IndexStatsDescription,\n QueryOptions,\n RecordSparseValues,\n UpdateOptions,\n} from '@pinecone-database/pinecone';\n\nimport { PineconeFilterTranslator } from './filter';\nimport type { PineconeVectorFilter } from './filter';\n\ninterface PineconeIndexStats extends IndexStats {\n namespaces?: IndexStatsDescription['namespaces'];\n}\n\ninterface PineconeQueryVectorParams extends QueryVectorParams<PineconeVectorFilter> {\n namespace?: string;\n sparseVector?: RecordSparseValues;\n}\n\ninterface PineconeUpsertVectorParams extends UpsertVectorParams {\n namespace?: string;\n sparseVectors?: RecordSparseValues[];\n}\n\ninterface PineconeUpdateVectorParams extends UpdateVectorParams {\n namespace?: string;\n}\n\ninterface PineconeDeleteVectorParams extends DeleteVectorParams {\n namespace?: string;\n}\n\nexport class PineconeVector extends MastraVector<PineconeVectorFilter> {\n private client: Pinecone;\n\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 */\n constructor({ id, apiKey, environment }: { id: string; apiKey: string; environment?: string }) {\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 }\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: 'aws',\n region: 'us-east-1',\n },\n },\n });\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.errors?.[0]?.message || error?.message;\n if (\n error.status === 409 ||\n (typeof message === 'string' &&\n (message.toLowerCase().includes('already exists') || message.toLowerCase().includes('duplicate')))\n ) {\n // Fetch index info and check dimensions\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n // For any other errors, wrap in MastraError\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n async upsert({\n indexName,\n vectors,\n metadata,\n ids,\n namespace,\n sparseVectors,\n }: PineconeUpsertVectorParams): Promise<string[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n // Generate IDs if not provided\n const vectorIds = ids || vectors.map(() => crypto.randomUUID());\n\n const records = vectors.map((vector, i) => ({\n id: vectorIds[i]!,\n values: vector,\n ...(sparseVectors?.[i] && { sparseValues: sparseVectors?.[i] }),\n metadata: metadata?.[i] || {},\n }));\n\n // Pinecone has a limit of 100 vectors per upsert request\n const batchSize = 100;\n try {\n for (let i = 0; i < records.length; i += batchSize) {\n const batch = records.slice(i, i + batchSize);\n await index.upsert(batch);\n }\n\n return vectorIds;\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors.length },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: PineconeVectorFilter) {\n const translator = new PineconeFilterTranslator();\n return translator.translate(filter);\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n namespace,\n sparseVector,\n }: PineconeQueryVectorParams): Promise<QueryResult[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n const translatedFilter = this.transformFilter(filter) ?? undefined;\n\n const queryParams: QueryOptions = {\n vector: queryVector,\n topK,\n includeMetadata: true,\n includeValues: includeVector,\n filter: translatedFilter,\n };\n\n // If sparse vector is provided, use hybrid search\n if (sparseVector) {\n queryParams.sparseVector = sparseVector;\n }\n\n try {\n const results = await index.query(queryParams);\n\n return results.matches.map(match => ({\n id: match.id,\n score: match.score || 0,\n metadata: match.metadata as Record<string, any>,\n ...(includeVector && { vector: match.values || [] }),\n }));\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const indexesResult = await this.client.listIndexes();\n return indexesResult?.indexes?.map(index => index.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<PineconeIndexStats> {\n try {\n const index = this.client.Index(indexName);\n const stats = await index.describeIndexStats();\n const description = await this.client.describeIndex(indexName);\n\n return {\n dimension: description.dimension,\n count: stats.totalRecordCount || 0,\n metric: description.metric as 'cosine' | 'euclidean' | 'dotproduct',\n namespaces: stats.namespaces,\n };\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteIndex(indexName);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to update.\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @param namespace - The namespace of the index (optional).\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, update, namespace }: PineconeUpdateVectorParams): Promise<void> {\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'No updates provided',\n details: { indexName, id },\n });\n }\n\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n const updateObj: UpdateOptions = { id };\n\n if (update.vector) {\n updateObj.values = update.vector;\n }\n\n if (update.metadata) {\n updateObj.metadata = update.metadata;\n }\n\n await index.update(updateObj);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @param namespace - The namespace of the index (optional).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ indexName, id, namespace }: PineconeDeleteVectorParams): Promise<void> {\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n await index.deleteOne(id);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Pinecone Vector.\n */\nexport const PINECONE_PROMPT = `When querying Pinecone, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- A non-empty array is required for $all operator\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}`;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":[],"mappings":";;;;;;AAkCO,IAAM,wBAAA,GAAN,cAAuC,oBAAA,CAA2C;AAAA,EACpE,qBAAA,GAAyC;AAC1D,IAAA,OAAO;AAAA,MACL,GAAG,oBAAA,CAAqB,iBAAA;AAAA,MAC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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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA","file":"index.js","sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n QueryOperator,\n FilterValue,\n OperatorCondition,\n} from '@mastra/core/vector/filter';\n\ntype InitialOperatorValueMap = Omit<OperatorValueMap, '$regex' | '$options' | '$elemMatch' | '$all'> & {\n $contains: string;\n $gt: number | Date;\n $gte: number | Date;\n $lt: number | Date;\n $lte: number | Date;\n};\n\ntype PineconeOperatorValueMap = InitialOperatorValueMap & {\n $all: OperatorCondition<keyof InitialOperatorValueMap, InitialOperatorValueMap>[] | FilterValue[];\n};\ntype PineconeLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$not' | '$nor'>;\n\ntype PineconeBlacklisted = BlacklistedRootOperators | '$not' | '$nor';\n\nexport type PineconeVectorFilter = VectorFilter<\n keyof PineconeOperatorValueMap,\n PineconeOperatorValueMap,\n PineconeLogicalOperatorValueMap,\n PineconeBlacklisted\n>;\n\nexport class PineconeFilterTranslator extends BaseFilterTranslator<PineconeVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or'],\n array: ['$in', '$all', '$nin'],\n element: ['$exists'],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: PineconeVectorFilter): PineconeVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n return this.translateNode(filter);\n }\n\n private translateNode(node: PineconeVectorFilter, currentPath: string = ''): any {\n if (this.isRegex(node)) {\n throw new Error('Regex is not supported in Pinecone');\n }\n if (this.isPrimitive(node)) return this.normalizeComparisonValue(node);\n if (Array.isArray(node)) return { $in: this.normalizeArrayValues(node) };\n\n const entries = Object.entries(node as Record<string, any>);\n const firstEntry = entries[0];\n\n // Handle single operator case\n if (entries.length === 1 && firstEntry && this.isOperator(firstEntry[0])) {\n const [operator, value] = firstEntry;\n const translated = this.translateOperator(operator, value, currentPath);\n return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;\n }\n\n // Process each entry\n const result: Record<string, any> = {};\n\n for (const [key, value] of entries) {\n const newPath = currentPath ? `${currentPath}.${key}` : key;\n\n if (this.isOperator(key)) {\n result[key] = this.translateOperator(key, value, currentPath);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Handle nested $all\n if (Object.keys(value).length === 1 && '$all' in value) {\n const translated = this.translateNode(value, key);\n if (translated.$and) {\n return translated;\n }\n }\n\n // Check if the nested object contains operators\n if (Object.keys(value).length === 0) {\n result[newPath] = this.translateNode(value);\n } else {\n const hasOperators = Object.keys(value).some(k => this.isOperator(k));\n if (hasOperators) {\n // For objects with operators, normalize each operator value\n const normalizedValue: Record<string, any> = {};\n for (const [op, opValue] of Object.entries(value)) {\n normalizedValue[op] = this.isOperator(op) ? this.translateOperator(op, opValue) : opValue;\n }\n result[newPath] = normalizedValue;\n } else {\n // For objects without operators, flatten them\n Object.assign(result, this.translateNode(value, newPath));\n }\n }\n } else {\n result[newPath] = this.translateNode(value);\n }\n }\n\n return result;\n }\n\n private translateOperator(operator: QueryOperator, value: any, currentPath: string = ''): any {\n // Handle $all specially\n if (operator === '$all') {\n if (!Array.isArray(value) || value.length === 0) {\n throw new Error('A non-empty array is required for the $all operator');\n }\n\n return this.simulateAllOperator(currentPath, value);\n }\n\n // Handle logical operators\n if (this.isLogicalOperator(operator)) {\n return Array.isArray(value) ? value.map(item => this.translateNode(item)) : this.translateNode(value);\n }\n\n // Handle comparison and element operators\n return this.normalizeComparisonValue(value);\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n} from '@mastra/core/vector';\nimport { Pinecone } from '@pinecone-database/pinecone';\nimport type {\n IndexStatsDescription,\n QueryOptions,\n RecordSparseValues,\n ServerlessSpecCloudEnum,\n UpdateOptions,\n} from '@pinecone-database/pinecone';\n\nimport { PineconeFilterTranslator } from './filter';\nimport type { PineconeVectorFilter } from './filter';\n\ninterface PineconeIndexStats extends IndexStats {\n namespaces?: IndexStatsDescription['namespaces'];\n}\n\ninterface PineconeQueryVectorParams extends QueryVectorParams<PineconeVectorFilter> {\n namespace?: string;\n sparseVector?: RecordSparseValues;\n}\n\ninterface PineconeUpsertVectorParams extends UpsertVectorParams {\n namespace?: string;\n sparseVectors?: RecordSparseValues[];\n}\n\ninterface PineconeUpdateVectorParams extends UpdateVectorParams {\n namespace?: string;\n}\n\ninterface PineconeDeleteVectorParams extends DeleteVectorParams {\n namespace?: string;\n}\n\nexport class PineconeVector extends MastraVector<PineconeVectorFilter> {\n private client: Pinecone;\n private cloud: ServerlessSpecCloudEnum;\n private region: string;\n\n /**\n * Creates a new PineconeVector client.\n * @param id - The unique identifier for this vector store instance.\n * @param apiKey - The API key for Pinecone.\n * @param environment - The environment for Pinecone.\n * @param cloud - The cloud provider for Pinecone.\n * @param region - The region for Pinecone.\n */\n constructor({\n id,\n apiKey,\n environment,\n cloud,\n region,\n }: {\n id: string;\n apiKey: string;\n environment?: string;\n region?: string;\n cloud?: ServerlessSpecCloudEnum;\n }) {\n super({ id });\n const opts: { apiKey: string; controllerHostUrl?: string } = { apiKey };\n if (environment) {\n opts['controllerHostUrl'] = environment;\n }\n this.client = new Pinecone(opts);\n this.cloud = cloud || 'aws';\n this.region = region || 'us-east-1';\n }\n\n get indexSeparator(): string {\n return '-';\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n try {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new Error('Dimension must be a positive integer');\n }\n if (metric && !['cosine', 'euclidean', 'dotproduct'].includes(metric)) {\n throw new Error('Metric must be one of: cosine, euclidean, dotproduct');\n }\n } catch (validationError) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_CREATE_INDEX_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, dimension, metric },\n },\n validationError,\n );\n }\n\n try {\n await this.client.createIndex({\n name: indexName,\n dimension: dimension,\n metric: metric,\n spec: {\n serverless: {\n cloud: this.cloud,\n region: this.region,\n },\n },\n });\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.errors?.[0]?.message || error?.message;\n if (\n error.status === 409 ||\n (typeof message === 'string' &&\n (message.toLowerCase().includes('already exists') || message.toLowerCase().includes('duplicate')))\n ) {\n // Fetch index info and check dimensions\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n // For any other errors, wrap in MastraError\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n async upsert({\n indexName,\n vectors,\n metadata,\n ids,\n namespace,\n sparseVectors,\n }: PineconeUpsertVectorParams): Promise<string[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n // Generate IDs if not provided\n const vectorIds = ids || vectors.map(() => crypto.randomUUID());\n\n const records = vectors.map((vector, i) => ({\n id: vectorIds[i]!,\n values: vector,\n ...(sparseVectors?.[i] && { sparseValues: sparseVectors?.[i] }),\n metadata: metadata?.[i] || {},\n }));\n\n // Pinecone has a limit of 100 vectors per upsert request\n const batchSize = 100;\n try {\n for (let i = 0; i < records.length; i += batchSize) {\n const batch = records.slice(i, i + batchSize);\n await index.upsert(batch);\n }\n\n return vectorIds;\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors.length },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: PineconeVectorFilter) {\n const translator = new PineconeFilterTranslator();\n return translator.translate(filter);\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n namespace,\n sparseVector,\n }: PineconeQueryVectorParams): Promise<QueryResult[]> {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n const translatedFilter = this.transformFilter(filter) ?? undefined;\n\n const queryParams: QueryOptions = {\n vector: queryVector,\n topK,\n includeMetadata: true,\n includeValues: includeVector,\n filter: translatedFilter,\n };\n\n // If sparse vector is provided, use hybrid search\n if (sparseVector) {\n queryParams.sparseVector = sparseVector;\n }\n\n try {\n const results = await index.query(queryParams);\n\n return results.matches.map(match => ({\n id: match.id,\n score: match.score || 0,\n metadata: match.metadata as Record<string, any>,\n ...(includeVector && { vector: match.values || [] }),\n }));\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const indexesResult = await this.client.listIndexes();\n return indexesResult?.indexes?.map(index => index.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<PineconeIndexStats> {\n try {\n const index = this.client.Index(indexName);\n const stats = await index.describeIndexStats();\n const description = await this.client.describeIndex(indexName);\n\n return {\n dimension: description.dimension,\n count: stats.totalRecordCount || 0,\n metric: description.metric as 'cosine' | 'euclidean' | 'dotproduct',\n namespaces: stats.namespaces,\n };\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteIndex(indexName);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to update.\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @param namespace - The namespace of the index (optional).\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, update, namespace }: PineconeUpdateVectorParams): Promise<void> {\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: 'No updates provided',\n details: { indexName, id },\n });\n }\n\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n\n const updateObj: UpdateOptions = { id };\n\n if (update.vector) {\n updateObj.values = update.vector;\n }\n\n if (update.metadata) {\n updateObj.metadata = update.metadata;\n }\n\n await index.update(updateObj);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_UPDATE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @param namespace - The namespace of the index (optional).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ indexName, id, namespace }: PineconeDeleteVectorParams): Promise<void> {\n try {\n const index = this.client.Index(indexName).namespace(namespace || '');\n await index.deleteOne(id);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_PINECONE_VECTOR_DELETE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Pinecone Vector.\n */\nexport const PINECONE_PROMPT = `When querying Pinecone, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- A non-empty array is required for $all operator\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}`;\n"]}
|
package/dist/vector/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MastraVector } from '@mastra/core/vector';
|
|
2
2
|
import type { QueryResult, IndexStats, CreateIndexParams, UpsertVectorParams, QueryVectorParams, DescribeIndexParams, DeleteIndexParams, DeleteVectorParams, UpdateVectorParams } from '@mastra/core/vector';
|
|
3
|
-
import type { IndexStatsDescription, RecordSparseValues } from '@pinecone-database/pinecone';
|
|
3
|
+
import type { IndexStatsDescription, RecordSparseValues, ServerlessSpecCloudEnum } from '@pinecone-database/pinecone';
|
|
4
4
|
import type { PineconeVectorFilter } from './filter.js';
|
|
5
5
|
interface PineconeIndexStats extends IndexStats {
|
|
6
6
|
namespaces?: IndexStatsDescription['namespaces'];
|
|
@@ -21,16 +21,22 @@ interface PineconeDeleteVectorParams extends DeleteVectorParams {
|
|
|
21
21
|
}
|
|
22
22
|
export declare class PineconeVector extends MastraVector<PineconeVectorFilter> {
|
|
23
23
|
private client;
|
|
24
|
+
private cloud;
|
|
25
|
+
private region;
|
|
24
26
|
/**
|
|
25
27
|
* Creates a new PineconeVector client.
|
|
26
28
|
* @param id - The unique identifier for this vector store instance.
|
|
27
29
|
* @param apiKey - The API key for Pinecone.
|
|
28
30
|
* @param environment - The environment for Pinecone.
|
|
31
|
+
* @param cloud - The cloud provider for Pinecone.
|
|
32
|
+
* @param region - The region for Pinecone.
|
|
29
33
|
*/
|
|
30
|
-
constructor({ id, apiKey, environment }: {
|
|
34
|
+
constructor({ id, apiKey, environment, cloud, region, }: {
|
|
31
35
|
id: string;
|
|
32
36
|
apiKey: string;
|
|
33
37
|
environment?: string;
|
|
38
|
+
region?: string;
|
|
39
|
+
cloud?: ServerlessSpecCloudEnum;
|
|
34
40
|
});
|
|
35
41
|
get indexSeparator(): string;
|
|
36
42
|
createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EACV,qBAAqB,EAErB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EACV,qBAAqB,EAErB,kBAAkB,EAClB,uBAAuB,EAExB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD,UAAU,kBAAmB,SAAQ,UAAU;IAC7C,UAAU,CAAC,EAAE,qBAAqB,CAAC,YAAY,CAAC,CAAC;CAClD;AAED,UAAU,yBAA0B,SAAQ,iBAAiB,CAAC,oBAAoB,CAAC;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC;AAED,UAAU,0BAA2B,SAAQ,kBAAkB;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,kBAAkB,EAAE,CAAC;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,SAAS,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBlE;;;;;;;;;;OAUG;IACG,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;IAsCnG;;;;;;;OAOG;IACG,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;CAgB5F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/pinecone",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"description": "Pinecone vector store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,13 +24,15 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@microsoft/api-extractor": "^7.52.8",
|
|
27
|
-
"@types/node": "
|
|
27
|
+
"@types/node": "22.13.17",
|
|
28
|
+
"@vitest/coverage-v8": "4.0.8",
|
|
29
|
+
"@vitest/ui": "4.0.8",
|
|
28
30
|
"dotenv": "^17.0.0",
|
|
29
31
|
"eslint": "^9.37.0",
|
|
30
32
|
"tsup": "^8.5.0",
|
|
31
33
|
"typescript": "^5.8.3",
|
|
32
|
-
"vitest": "^
|
|
33
|
-
"@mastra/core": "1.0.0-beta.
|
|
34
|
+
"vitest": "^4.0.8",
|
|
35
|
+
"@mastra/core": "1.0.0-beta.3",
|
|
34
36
|
"@internal/types-builder": "0.0.28",
|
|
35
37
|
"@internal/lint": "0.0.53"
|
|
36
38
|
},
|