@mastra/weaviate 0.1.3-alpha.0 → 0.1.4-alpha.0
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/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +6 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -8
- package/dist/index.js.map +1 -1
- package/package.json +14 -15
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-weaviate
|
|
|
3
3
|
description: Documentation for @mastra/weaviate. Use when working with @mastra/weaviate APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/weaviate"
|
|
6
|
-
version: "0.1.
|
|
6
|
+
version: "0.1.4-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -16,18 +16,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
|
-
//#endregion
|
|
24
23
|
let _mastra_core_error = require("@mastra/core/error");
|
|
25
24
|
let _mastra_core_storage = require("@mastra/core/storage");
|
|
26
25
|
let _mastra_core_vector = require("@mastra/core/vector");
|
|
27
26
|
let weaviate_client = require("weaviate-client");
|
|
28
27
|
weaviate_client = __toESM(weaviate_client, 1);
|
|
29
28
|
let _mastra_core_vector_filter = require("@mastra/core/vector/filter");
|
|
30
|
-
|
|
29
|
+
// src/vector/encoding.ts
|
|
31
30
|
/**
|
|
32
31
|
* Weaviate reserves certain property names (e.g. `id`, `vector`). Metadata keys
|
|
33
32
|
* that collide are stored under a stable prefix and restored on read. This
|
|
@@ -55,8 +54,7 @@ function encodeMetaProperties(metadata) {
|
|
|
55
54
|
for (const [key, value] of Object.entries(metadata)) out[encodeMetaKey(key)] = value;
|
|
56
55
|
return out;
|
|
57
56
|
}
|
|
58
|
-
|
|
59
|
-
//#region src/vector/filter.ts
|
|
57
|
+
// src/vector/filter.ts
|
|
60
58
|
/**
|
|
61
59
|
* Translates MongoDB-style filters into Weaviate `FilterValue` objects.
|
|
62
60
|
*
|
|
@@ -213,8 +211,7 @@ function unsupportedOperatorError(op, field) {
|
|
|
213
211
|
}
|
|
214
212
|
});
|
|
215
213
|
}
|
|
216
|
-
|
|
217
|
-
//#region src/vector/index.ts
|
|
214
|
+
// src/vector/index.ts
|
|
218
215
|
/**
|
|
219
216
|
* Weaviate distance metrics mapped from Mastra metric names.
|
|
220
217
|
* @see https://weaviate.io/developers/weaviate/config-refs/distances
|
|
@@ -753,8 +750,7 @@ var WeaviateVector = class extends _mastra_core_vector.MastraVector {
|
|
|
753
750
|
}
|
|
754
751
|
}
|
|
755
752
|
};
|
|
756
|
-
|
|
757
|
-
//#region src/vector/prompt.ts
|
|
753
|
+
// src/vector/prompt.ts
|
|
758
754
|
/**
|
|
759
755
|
* Vector store specific prompt that details supported operators and examples.
|
|
760
756
|
* This prompt helps users construct valid filters for Weaviate Vector.
|
|
@@ -834,7 +830,6 @@ Example Complex Query:
|
|
|
834
830
|
{ "$not": { "status": "discontinued" } }
|
|
835
831
|
]
|
|
836
832
|
}`;
|
|
837
|
-
//#endregion
|
|
838
833
|
exports.WEAVIATE_PROMPT = WEAVIATE_PROMPT;
|
|
839
834
|
exports.WeaviateVector = WeaviateVector;
|
|
840
835
|
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["BaseFilterTranslator","Filters","MastraError","ErrorDomain","ErrorCategory","MastraVector","weaviate","MastraError","ErrorDomain","ErrorCategory"],"sources":["../src/vector/encoding.ts","../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"sourcesContent":["/**\n * Weaviate reserves certain property names (e.g. `id`, `vector`). Metadata keys\n * that collide are stored under a stable prefix and restored on read. This\n * module is the single source of truth shared by the adapter and the filter\n * translator — they must encode keys identically or filters will silently miss.\n */\n/** Internal property used to round-trip the caller's original id. */\nexport const MASTRA_ID_PROPERTY = 'mastraId';\nexport const META_KEY_PREFIX = 'mastraMeta_';\n// `mastraId` is reserved too: the adapter writes the caller's original id under\n// this property, so a user metadata key of the same name must be encoded to\n// avoid clobbering (or being clobbered by) the internal value.\nexport const RESERVED_META_KEYS = new Set(['id', 'vector', '_additional', MASTRA_ID_PROPERTY]);\n\nexport function encodeMetaKey(key: string): string {\n // Encode reserved names, and also escape any genuine user key that already\n // starts with the prefix. Escaping makes the transform fully reversible:\n // without it, a user key like `mastraMeta_id` would be indistinguishable from\n // an encoded `id` on read and would be returned under the wrong name.\n return RESERVED_META_KEYS.has(key) || key.startsWith(META_KEY_PREFIX) ? `${META_KEY_PREFIX}${key}` : key;\n}\n\nexport function decodeMetaKey(key: string): string {\n return key.startsWith(META_KEY_PREFIX) ? key.slice(META_KEY_PREFIX.length) : key;\n}\n\nexport function encodeMetaProperties(metadata?: Record<string, any>): Record<string, any> {\n if (!metadata) return {};\n const out: Record<string, any> = {};\n for (const [key, value] of Object.entries(metadata)) {\n out[encodeMetaKey(key)] = value;\n }\n return out;\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\nimport { Filters } from 'weaviate-client';\nimport type { FilterValue } from 'weaviate-client';\n\nimport { encodeMetaKey } from './encoding';\n\n/**\n * The subset of Weaviate's collection filter API used by the translator.\n * Provided at translate time via `collection.filter`.\n */\nexport interface WeaviateFilterApi {\n byProperty: (name: string, length?: boolean) => WeaviateFilterProperty;\n}\n\ninterface WeaviateFilterProperty {\n isNull: (value: boolean) => FilterValue;\n equal: (value: any) => FilterValue;\n notEqual: (value: any) => FilterValue;\n greaterThan: (value: any) => FilterValue;\n greaterOrEqual: (value: any) => FilterValue;\n lessThan: (value: any) => FilterValue;\n lessOrEqual: (value: any) => FilterValue;\n containsAny: (value: any[]) => FilterValue;\n containsAll: (value: any[]) => FilterValue;\n containsNone: (value: any[]) => FilterValue;\n}\n\ntype WeaviateOperatorValueMap = Omit<\n OperatorValueMap,\n '$options' | '$elemMatch' | '$regex' | '$nor' | '$size' | '$contains'\n>;\n\ntype WeaviateLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor'>;\n\ntype WeaviateBlacklistedRootOperators = BlacklistedRootOperators;\n\nexport type WeaviateVectorFilter = VectorFilter<\n keyof WeaviateOperatorValueMap,\n WeaviateOperatorValueMap,\n WeaviateLogicalOperatorValueMap,\n WeaviateBlacklistedRootOperators\n>;\n\n/**\n * Translates MongoDB-style filters into Weaviate `FilterValue` objects.\n *\n * Weaviate filters are built from the collection's `filter` API (which produces\n * protobuf-backed targets), so `translate` requires the collection filter API to\n * be supplied alongside the filter.\n */\nexport class WeaviateFilterTranslator extends BaseFilterTranslator<WeaviateVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n logical: ['$and', '$or', '$not'],\n basic: ['$eq', '$ne'],\n numeric: ['$gt', '$gte', '$lt', '$lte'],\n array: ['$in', '$nin', '$all'],\n element: ['$exists'],\n regex: [],\n custom: [],\n };\n }\n\n protected override isOperator(key: string): key is any {\n // $not can be used both logically and at field level.\n return super.isOperator(key) || key === '$not';\n }\n\n translate(filter?: WeaviateVectorFilter, api?: WeaviateFilterApi): FilterValue | undefined {\n if (this.isEmpty(filter)) return undefined;\n if (!api) {\n throw new Error('WeaviateFilterTranslator.translate requires a collection filter API');\n }\n this.validateFilter(filter);\n return this.translateNode(filter as Record<string, any>, api);\n }\n\n /**\n * An empty set matches nothing. Weaviate can't send `containsAny([])` against a text[]\n * property (the empty array is serialized as numbers), so express it as a contradiction\n * on the property's null state, which the collection indexes (`indexNullState: true`).\n */\n private containsAny(prop: WeaviateFilterProperty, values: any[]): FilterValue {\n const normalized = this.normalizeArrayValues(values);\n if (normalized.length === 0) return Filters.and(prop.isNull(true), prop.isNull(false));\n return prop.containsAny(normalized);\n }\n\n private combine(parts: Array<FilterValue | undefined>): FilterValue | undefined {\n const filtered = parts.filter((p): p is FilterValue => p !== undefined);\n if (filtered.length === 0) return undefined;\n if (filtered.length === 1) return filtered[0];\n return Filters.and(...filtered);\n }\n\n private translateNode(node: Record<string, any>, api: WeaviateFilterApi): FilterValue | undefined {\n const parts = Object.entries(node).map(([key, value]) => {\n if (key === '$and') {\n return this.combineLogical('and', value as any[], api);\n }\n if (key === '$or') {\n return this.combineLogical('or', value as any[], api);\n }\n if (key === '$not') {\n // Push the negation into the operators (De Morgan) rather than relying on\n // Weaviate's Not operator, which is not supported by all server versions.\n return this.negateNode(value as Record<string, any>, api);\n }\n return this.translateField(key, value, api);\n });\n return this.combine(parts);\n }\n\n /** Combines parts with OR, dropping undefined entries. */\n private combineOr(parts: Array<FilterValue | undefined>): FilterValue | undefined {\n const filtered = parts.filter((p): p is FilterValue => p !== undefined);\n if (filtered.length === 0) return undefined;\n if (filtered.length === 1) return filtered[0];\n return Filters.or(...filtered);\n }\n\n /**\n * Returns the negation of a node. A node's entries are AND-combined, so the\n * negation is the OR of each entry's negation (De Morgan).\n */\n private negateNode(node: Record<string, any>, api: WeaviateFilterApi): FilterValue | undefined {\n const parts = Object.entries(node).map(([key, value]) => {\n if (key === '$and') {\n // NOT(a AND b) = (NOT a) OR (NOT b)\n return this.combineOr((value as any[]).map(v => this.negateNode(v as Record<string, any>, api)));\n }\n if (key === '$or') {\n // NOT(a OR b) = (NOT a) AND (NOT b)\n return this.combine((value as any[]).map(v => this.negateNode(v as Record<string, any>, api)));\n }\n if (key === '$not') {\n // Double negation.\n return this.translateNode(value as Record<string, any>, api);\n }\n return this.negateField(key, value, api);\n });\n return this.combineOr(parts);\n }\n\n /** Returns the negation of a single field condition. */\n private negateField(field: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n\n if (value === null) {\n return prop.isNull(false);\n }\n if (this.isPrimitive(value)) {\n return prop.notEqual(this.normalizeComparisonValue(value));\n }\n if (Array.isArray(value)) {\n // NOT(field in [..]) = field not equal to every value.\n return this.combine(this.normalizeArrayValues(value).map(v => prop.notEqual(v)));\n }\n\n // Operator object: entries are AND-combined, so negation is OR of negations.\n const parts = Object.entries(value as Record<string, any>).map(([op, opValue]) =>\n this.negateSingleOp(field, op, opValue, api),\n );\n return this.combineOr(parts);\n }\n\n private negateSingleOp(field: string, op: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n switch (op) {\n case '$eq':\n return value === null ? prop.isNull(false) : prop.notEqual(this.normalizeComparisonValue(value));\n case '$ne':\n return value === null ? prop.isNull(true) : prop.equal(this.normalizeComparisonValue(value));\n case '$gt':\n return prop.lessOrEqual(this.normalizeComparisonValue(value));\n case '$gte':\n return prop.lessThan(this.normalizeComparisonValue(value));\n case '$lt':\n return prop.greaterOrEqual(this.normalizeComparisonValue(value));\n case '$lte':\n return prop.greaterThan(this.normalizeComparisonValue(value));\n case '$in':\n // NOT(in [..]) = not equal to every value.\n return this.combine(this.normalizeArrayValues(value as any[]).map(v => prop.notEqual(v)));\n case '$nin':\n // NOT(nin [..]) = in [..].\n return this.containsAny(prop, value as any[]);\n case '$exists':\n return prop.isNull(!!value);\n case '$not':\n return this.translateField(field, value, api);\n default:\n throw unsupportedOperatorError(op, field);\n }\n }\n\n private combineLogical(op: 'and' | 'or', values: any[], api: WeaviateFilterApi): FilterValue | undefined {\n const translated = values\n .map(v => this.translateNode(v as Record<string, any>, api))\n .filter((p): p is FilterValue => p !== undefined);\n if (translated.length === 0) return undefined;\n if (translated.length === 1) return translated[0];\n return op === 'and' ? Filters.and(...translated) : Filters.or(...translated);\n }\n\n private translateField(field: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n\n if (value === null) {\n return prop.isNull(true);\n }\n\n if (this.isPrimitive(value)) {\n return prop.equal(this.normalizeComparisonValue(value));\n }\n\n if (Array.isArray(value)) {\n return this.containsAny(prop, value);\n }\n\n // Operator object: combine each operator condition with AND.\n const parts = Object.entries(value as Record<string, any>).map(([op, opValue]) =>\n this.translateOperator(field, op, opValue, api),\n );\n return this.combine(parts);\n }\n\n private translateOperator(field: string, op: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n switch (op) {\n case '$eq':\n return value === null ? prop.isNull(true) : prop.equal(this.normalizeComparisonValue(value));\n case '$ne':\n return value === null ? prop.isNull(false) : prop.notEqual(this.normalizeComparisonValue(value));\n case '$gt':\n return prop.greaterThan(this.normalizeComparisonValue(value));\n case '$gte':\n return prop.greaterOrEqual(this.normalizeComparisonValue(value));\n case '$lt':\n return prop.lessThan(this.normalizeComparisonValue(value));\n case '$lte':\n return prop.lessOrEqual(this.normalizeComparisonValue(value));\n case '$in':\n return this.containsAny(prop, value as any[]);\n case '$nin':\n // Weaviate's ContainsNone is not available on all server versions; express\n // \"not in\" as an AND of not-equals instead.\n return this.combine(this.normalizeArrayValues(value as any[]).map(v => prop.notEqual(v)));\n case '$all':\n return prop.containsAll(this.normalizeArrayValues(value as any[]));\n case '$exists':\n return prop.isNull(!value);\n case '$not':\n return this.negateField(field, value, api);\n default:\n throw unsupportedOperatorError(op, field);\n }\n }\n}\n\n/** Builds a user-facing error for an operator Weaviate cannot translate. */\nfunction unsupportedOperatorError(op: string, field: string): MastraError {\n return new MastraError({\n id: 'STORAGE_WEAVIATE_FILTER_UNSUPPORTED_OPERATOR',\n text: `Unsupported filter operator \"${op}\" on field \"${field}\"`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { operator: op, field },\n });\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector, validateUpsertInput, validateVectorValues, validateTopK } 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 DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport weaviate, { generateUuid5 } from 'weaviate-client';\nimport type { WeaviateClient, Collection } from 'weaviate-client';\n\nimport { encodeMetaKey, decodeMetaKey, encodeMetaProperties, MASTRA_ID_PROPERTY } from './encoding';\nimport { WeaviateFilterTranslator } from './filter';\nimport type { WeaviateVectorFilter } from './filter';\n\n/**\n * Weaviate distance metrics mapped from Mastra metric names.\n * @see https://weaviate.io/developers/weaviate/config-refs/distances\n */\nconst DISTANCE_MAPPING: Record<string, 'cosine' | 'l2-squared' | 'dot'> = {\n cosine: 'cosine',\n euclidean: 'l2-squared',\n dotproduct: 'dot',\n};\n\nconst REVERSE_DISTANCE_MAPPING: Record<string, 'cosine' | 'euclidean' | 'dotproduct'> = {\n cosine: 'cosine',\n 'l2-squared': 'euclidean',\n dot: 'dotproduct',\n};\n\n/** Reserved property used to round-trip the caller-supplied vector id. */\n\n/** Metadata stored on a collection's description to preserve Mastra semantics. */\ninterface CollectionMeta {\n name: string;\n dimension: number;\n metric: 'cosine' | 'euclidean' | 'dotproduct';\n}\n\n/**\n * Connection options for the Weaviate vector store.\n * These map directly to `weaviate.connectToCustom`.\n */\nexport interface WeaviateVectorParams {\n /** Unique identifier for this vector store instance. */\n id: string;\n /** The hostname of the HTTP server. Defaults to `localhost`. */\n httpHost?: string;\n /** The port of the HTTP server. Defaults to `8080`. */\n httpPort?: number;\n /** Whether to use a secure connection to the HTTP server. Defaults to `false`. */\n httpSecure?: boolean;\n /** The hostname of the gRPC server. Defaults to the HTTP host. */\n grpcHost?: string;\n /** The port of the gRPC server. Defaults to `50051`. */\n grpcPort?: number;\n /** Whether to use a secure connection to the gRPC server. Defaults to `false`. */\n grpcSecure?: boolean;\n /** API key for authenticating with Weaviate (e.g. Weaviate Cloud). */\n apiKey?: string;\n /** Additional headers to include in requests (e.g. vectorizer API keys). */\n headers?: Record<string, string>;\n}\n\n/**\n * A Mastra vector store backed by Weaviate.\n *\n * Vectors are stored in `vectorizer: none` collections (Mastra supplies the\n * embeddings). Because Weaviate requires UUID object ids and capitalised\n * collection names, this adapter maps arbitrary Mastra ids to deterministic\n * UUIDv5 values (preserving the original id in a reserved property) and\n * preserves the original index name in the collection description.\n */\nexport class WeaviateVector extends MastraVector<WeaviateVectorFilter> {\n private clientPromise: Promise<WeaviateClient> | null = null;\n private readonly connectOptions: WeaviateVectorParams;\n /** Cache of property names known to exist in a collection's schema. */\n private readonly knownProperties = new Map<string, Set<string>>();\n /** Serializes schema mutations per collection to avoid concurrent addProperty races. */\n private readonly schemaLocks = new Map<string, Promise<void>>();\n\n constructor(params: WeaviateVectorParams) {\n super({ id: params.id });\n this.connectOptions = params;\n }\n\n private getClient(): Promise<WeaviateClient> {\n if (!this.clientPromise) {\n const { httpHost, httpPort, httpSecure, grpcHost, grpcPort, grpcSecure, apiKey, headers } = this.connectOptions;\n this.clientPromise = weaviate.connectToCustom({\n httpHost: httpHost ?? 'localhost',\n httpPort: httpPort ?? 8080,\n httpSecure: httpSecure ?? false,\n grpcHost: grpcHost ?? httpHost ?? 'localhost',\n grpcPort: grpcPort ?? 50051,\n grpcSecure: grpcSecure ?? false,\n ...(apiKey ? { authCredentials: new weaviate.ApiKey(apiKey) } : {}),\n ...(headers ? { headers } : {}),\n });\n }\n return this.clientPromise;\n }\n\n /** Closes the underlying Weaviate connection. */\n async disconnect(): Promise<void> {\n if (this.clientPromise) {\n const client = await this.clientPromise;\n await client.close();\n this.clientPromise = null;\n }\n }\n\n /** Weaviate collection names must start with an uppercase letter. */\n private toCollectionName(indexName: string): string {\n return indexName.charAt(0).toUpperCase() + indexName.slice(1);\n }\n\n private async getCollection(indexName: string): Promise<Collection> {\n const client = await this.getClient();\n return client.collections.get(this.toCollectionName(indexName));\n }\n\n private parseMeta(description?: string): CollectionMeta | null {\n if (!description) return null;\n try {\n const parsed = JSON.parse(description);\n if (parsed && typeof parsed === 'object' && typeof parsed.name === 'string') {\n return parsed as CollectionMeta;\n }\n } catch {\n // Not a Mastra-managed description.\n }\n return null;\n }\n\n private inferDataType(value: unknown): 'text' | 'number' | 'boolean' | 'text[]' | 'number[]' | 'boolean[]' | null {\n if (typeof value === 'string') return 'text';\n if (typeof value === 'number') return 'number';\n if (typeof value === 'boolean') return 'boolean';\n if (Array.isArray(value)) {\n const first = value.find(v => v !== null && v !== undefined);\n if (typeof first === 'string') return 'text[]';\n if (typeof first === 'number') return 'number[]';\n if (typeof first === 'boolean') return 'boolean[]';\n // Arrays of objects (or empty arrays) are left to Weaviate's auto-schema.\n return null;\n }\n return null;\n }\n\n /**\n * Ensures every metadata key across the batch exists as a collection property.\n * Weaviate's auto-schema would create text properties with `word` tokenization\n * (breaking exact-match filtering), so properties are created explicitly with\n * `field` tokenization for text values.\n */\n private async ensureProperties(\n collection: Collection,\n collectionName: string,\n metadata: Record<string, any>[] | undefined,\n ): Promise<void> {\n if (!metadata?.length) return;\n // Chain schema mutations for the same collection so concurrent upserts do not\n // race on addProperty (which would surface as partial-success failures).\n const prev = this.schemaLocks.get(collectionName) ?? Promise.resolve();\n const next = prev\n .catch(() => undefined)\n .then(() => this.ensurePropertiesLocked(collection, collectionName, metadata));\n this.schemaLocks.set(collectionName, next);\n await next;\n }\n\n private async ensurePropertiesLocked(\n collection: Collection,\n collectionName: string,\n metadata: Record<string, any>[],\n ): Promise<void> {\n let known = this.knownProperties.get(collectionName);\n if (!known) {\n const config = await collection.config.get();\n known = new Set(config.properties.map(p => p.name));\n this.knownProperties.set(collectionName, known);\n }\n\n const seen = new Map<string, 'text' | 'number' | 'boolean' | 'text[]' | 'number[]' | 'boolean[]'>();\n for (const row of metadata) {\n if (!row) continue;\n for (const [rawKey, value] of Object.entries(row)) {\n const key = encodeMetaKey(rawKey);\n if (known.has(key) || seen.has(key) || value === null || value === undefined) continue;\n const dataType = this.inferDataType(value);\n if (dataType) seen.set(key, dataType);\n }\n }\n\n for (const [name, dataType] of seen) {\n try {\n await collection.config.addProperty({\n name,\n dataType,\n ...(dataType === 'text' || dataType === 'text[]' ? { tokenization: 'field' } : {}),\n } as any);\n } catch (error) {\n // Tolerate a property that already exists (e.g. added by a racing caller).\n if (!/already/i.test((error as Error)?.message ?? '')) throw error;\n }\n known.add(name);\n }\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n try {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'INVALID_ARGS'),\n text: 'Dimension must be a positive integer',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, dimension },\n });\n }\n\n const distance = DISTANCE_MAPPING[metric];\n if (!distance) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'INVALID_ARGS'),\n text: `Invalid metric: ${metric}. Must be one of: cosine, euclidean, dotproduct`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, metric },\n });\n }\n\n const client = await this.getClient();\n const collectionName = this.toCollectionName(indexName);\n\n if (await client.collections.exists(collectionName)) {\n // Weaviate capitalises the first letter of collection names, so distinct\n // Mastra index names (e.g. `documents` and `Documents`) map to one\n // collection. Reject the collision instead of silently sharing storage.\n const existingConfig = await client.collections.get(collectionName).config.get();\n const existingMeta = this.parseMeta(existingConfig.description);\n if (existingMeta && existingMeta.name !== indexName) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'NAME_COLLISION'),\n text: `Index name \"${indexName}\" collides with existing index \"${existingMeta.name}\" (Weaviate collection \"${collectionName}\"). Weaviate capitalises the first letter of collection names, so these names cannot coexist.`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, existingName: existingMeta.name, collectionName },\n });\n }\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n\n const meta: CollectionMeta = { name: indexName, dimension, metric };\n await client.collections.create({\n name: collectionName,\n description: JSON.stringify(meta),\n // Store the original Mastra id as an exact-match (\"field\") text property so\n // arbitrary (e.g. numeric) ids are not misinterpreted by Weaviate's auto-schema.\n properties: [{ name: MASTRA_ID_PROPERTY, dataType: 'text', tokenization: 'field' }],\n // Index null state so `$exists` / null-equality filters are supported.\n invertedIndex: weaviate.configure.invertedIndex({ indexNullState: true }),\n vectorizers: weaviate.configure.vectors.selfProvided({\n vectorIndexConfig: weaviate.configure.vectorIndex.hnsw({ distanceMetric: distance }),\n }),\n });\n this.knownProperties.set(collectionName, new Set([MASTRA_ID_PROPERTY]));\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /** Fetches a collection's stored metadata, throwing if the index does not exist. */\n private async requireMeta(indexName: string, operation: string): Promise<CollectionMeta | null> {\n const client = await this.getClient();\n const collectionName = this.toCollectionName(indexName);\n if (!(await client.collections.exists(collectionName))) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', operation, 'INDEX_NOT_FOUND'),\n text: `Index ${indexName} does not exist`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n const config = await client.collections.get(collectionName).config.get();\n return this.parseMeta(config.description);\n }\n\n async upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]> {\n try {\n validateUpsertInput('WEAVIATE', vectors, metadata, ids);\n validateVectorValues('WEAVIATE', vectors);\n\n const meta = await this.requireMeta(indexName, 'UPSERT');\n if (meta?.dimension) {\n const mismatch = vectors.find(v => v.length !== meta.dimension);\n if (mismatch) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPSERT', 'DIMENSION_MISMATCH'),\n text: `Vector dimension ${mismatch.length} does not match index dimension ${meta.dimension}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, expected: meta.dimension, actual: mismatch.length },\n });\n }\n }\n\n const collection = await this.getCollection(indexName);\n await this.ensureProperties(collection, this.toCollectionName(indexName), metadata);\n const originalIds = ids ?? vectors.map(() => crypto.randomUUID());\n\n const objects = vectors.map((vector, i) => {\n const originalId = originalIds[i]!;\n return {\n id: generateUuid5(originalId),\n vectors: vector,\n properties: {\n ...encodeMetaProperties(metadata?.[i]),\n [MASTRA_ID_PROPERTY]: originalId,\n },\n };\n });\n\n const result = await collection.data.insertMany(objects);\n if (result.hasErrors) {\n const firstError = Object.values(result.errors)[0];\n throw new Error(firstError?.message ?? 'Weaviate insertMany reported errors');\n }\n\n return originalIds;\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'UPSERT', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n private transformFilter(collection: Collection, filter?: WeaviateVectorFilter) {\n const translator = new WeaviateFilterTranslator();\n return translator.translate(filter, collection.filter as any);\n }\n\n private toQueryResult(obj: any, includeVector?: boolean): QueryResult {\n const raw = obj.properties ?? {};\n const originalId = raw[MASTRA_ID_PROPERTY];\n const properties: Record<string, any> = {};\n for (const [key, value] of Object.entries(raw)) {\n if (key === MASTRA_ID_PROPERTY || value === undefined) continue;\n properties[decodeMetaKey(key)] = value;\n }\n\n const distance = obj.metadata?.distance;\n const score = typeof distance === 'number' ? 1 - distance : (obj.metadata?.certainty ?? 0);\n\n const result: QueryResult = {\n id: typeof originalId === 'string' ? originalId : obj.uuid,\n score,\n metadata: properties,\n };\n\n if (includeVector) {\n const vectors = obj.vectors ?? {};\n result.vector = vectors.default ?? Object.values(vectors)[0];\n }\n\n return result;\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n }: QueryVectorParams<WeaviateVectorFilter>): Promise<QueryResult[]> {\n try {\n validateTopK('WEAVIATE', topK);\n\n const meta = await this.requireMeta(indexName, 'QUERY');\n if (queryVector && meta?.dimension && queryVector.length !== meta.dimension) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'QUERY', 'DIMENSION_MISMATCH'),\n text: `Query vector dimension ${queryVector.length} does not match index dimension ${meta.dimension}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, expected: meta.dimension, actual: queryVector.length },\n });\n }\n\n const collection = await this.getCollection(indexName);\n const filters = this.transformFilter(collection, filter);\n const returnMetadata = ['distance'] as const;\n\n if (queryVector) {\n const response = await collection.query.nearVector(queryVector, {\n limit: topK,\n includeVector,\n returnMetadata: returnMetadata as any,\n ...(filters ? { filters } : {}),\n });\n return response.objects.map(obj => this.toQueryResult(obj, includeVector));\n }\n\n const response = await collection.query.fetchObjects({\n limit: topK,\n includeVector,\n ...(filters ? { filters } : {}),\n });\n return response.objects.map(obj => this.toQueryResult(obj, includeVector));\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'QUERY', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const client = await this.getClient();\n const collections = await client.collections.listAll();\n return collections.map(config => {\n const meta = this.parseMeta(config.description);\n return meta?.name ?? config.name;\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'LIST_INDEXES', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const client = await this.getClient();\n const collectionName = this.toCollectionName(indexName);\n if (!(await client.collections.exists(collectionName))) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'DESCRIBE_INDEX', 'INDEX_NOT_FOUND'),\n text: `Index ${indexName} does not exist`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n const collection = client.collections.get(collectionName);\n const config = await collection.config.get();\n const meta = this.parseMeta(config.description);\n\n const count = await collection.length();\n\n let dimension = meta?.dimension ?? 0;\n if (!dimension) {\n // Fall back to sampling a stored vector when dimension is unknown.\n const sample = await collection.query.fetchObjects({ limit: 1, includeVector: true });\n const vectors = sample.objects[0]?.vectors ?? {};\n const vec = (vectors as any).default ?? Object.values(vectors)[0];\n if (Array.isArray(vec)) dimension = vec.length;\n }\n\n let metric = meta?.metric;\n if (!metric) {\n const vectorConfig = (config.vectorizers as any)?.default ?? Object.values(config.vectorizers ?? {})[0];\n const distance = vectorConfig?.indexConfig?.distance;\n metric = distance ? REVERSE_DISTANCE_MAPPING[distance] : undefined;\n }\n\n return { dimension, count, metric };\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', '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 const client = await this.getClient();\n await client.collections.delete(this.toCollectionName(indexName));\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'DELETE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async updateVector({ indexName, id, filter, update }: UpdateVectorParams<WeaviateVectorFilter>): Promise<void> {\n try {\n if (id !== undefined && filter !== undefined) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n text: 'id and filter are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!update || (!update.vector && !update.metadata)) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n text: 'Update data is required: no updates provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate the id/filter target BEFORE touching the collection, otherwise a\n // rejected update (missing target or empty filter) would still mutate the\n // collection schema via ensureProperties below.\n if (id === undefined && filter === undefined) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\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 (id === undefined && (typeof filter !== 'object' || filter === null || Object.keys(filter).length === 0)) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n text: 'A non-empty filter is required: empty filter not allowed',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n const collection = await this.getCollection(indexName);\n\n // Mirror upsert's schema handling: create any missing properties with\n // `field` tokenization and encode reserved keys, otherwise updated metadata\n // would be auto-schemad with `word` tokenization (breaking exact-match\n // filters) or clash with Weaviate's reserved property names.\n if (update.metadata) {\n await this.ensureProperties(collection, this.toCollectionName(indexName), [update.metadata]);\n }\n const encodedProperties = update.metadata ? encodeMetaProperties(update.metadata) : undefined;\n\n const applyUpdate = async (uuid: string) => {\n await collection.data.update({\n id: uuid,\n ...(encodedProperties ? { properties: encodedProperties } : {}),\n ...(update.vector ? { vectors: update.vector } : {}),\n });\n };\n\n if (id !== undefined) {\n await applyUpdate(generateUuid5(id));\n return;\n }\n\n const filters = this.transformFilter(collection, filter!);\n // Page through the full match set so large filters don't silently update\n // only the first page and report success. Collect all uuids first, then\n // apply, so mutations can't shift the pagination window mid-iteration.\n const PAGE_SIZE = 1000;\n // Weaviate rejects fetchObjects once offset+limit exceeds its\n // QUERY_MAXIMUM_RESULTS cap (default 10000). Fail loudly with a clear\n // USER error before that happens rather than surfacing a raw driver error.\n const MAX_FILTERED_UPDATE = 10000;\n const uuids: string[] = [];\n for (let offset = 0; ; offset += PAGE_SIZE) {\n if (offset >= MAX_FILTERED_UPDATE) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: `Filtered updateVector matched more than ${MAX_FILTERED_UPDATE} vectors, which exceeds Weaviate's query result cap. Narrow the filter or update by id.`,\n details: { indexName, limit: MAX_FILTERED_UPDATE },\n });\n }\n const page = await collection.query.fetchObjects({\n limit: PAGE_SIZE,\n offset,\n ...(filters ? { filters } : {}),\n });\n for (const obj of page.objects) uuids.push(obj.uuid);\n if (page.objects.length < PAGE_SIZE) break;\n }\n for (const uuid of uuids) {\n await applyUpdate(uuid);\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, ...(id ? { id } : {}) },\n },\n error,\n );\n }\n }\n\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n const collection = await this.getCollection(indexName);\n await collection.data.deleteById(generateUuid5(id));\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'DELETE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<WeaviateVectorFilter>): Promise<void> {\n if (ids && filter) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', '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('WEAVIATE', '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 if (ids && ids.length === 0) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', '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 if (filter && typeof filter === 'object' && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', '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 collection = await this.getCollection(indexName);\n if (ids) {\n for (const id of ids) {\n await collection.data.deleteById(generateUuid5(id));\n }\n } else if (filter) {\n const filters = this.transformFilter(collection, filter);\n if (filters) {\n await collection.data.deleteMany(filters);\n }\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', '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 Weaviate Vector.\n */\nexport const WEAVIATE_PROMPT = `When querying Weaviate, 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 arrays containing all values\n Example: { \"tags\": { \"$all\": [\"sale\", \"new\"] } }\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- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists (is not null)\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and, $or, and $not logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\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, $not):\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\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": { \"$eq\": true } }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,qBAAqB;AAClC,MAAa,kBAAkB;AAI/B,MAAa,qCAAqB,IAAI,IAAI;CAAC;CAAM;CAAU;CAAe;AAAkB,CAAC;AAE7F,SAAgB,cA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,EAAE,UAAU,IAAI,OAAO;IACpC;GACF,GACA,KACF;EACF;CACF;AACF;;;;;;;AC/tBA,MAAa,kBAAkB"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["BaseFilterTranslator","Filters","MastraError","ErrorDomain","ErrorCategory","MastraVector","weaviate","MastraError","createVectorErrorId","ErrorDomain","ErrorCategory","generateUuid5"],"sources":["../src/vector/encoding.ts","../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"sourcesContent":["/**\n * Weaviate reserves certain property names (e.g. `id`, `vector`). Metadata keys\n * that collide are stored under a stable prefix and restored on read. This\n * module is the single source of truth shared by the adapter and the filter\n * translator — they must encode keys identically or filters will silently miss.\n */\n/** Internal property used to round-trip the caller's original id. */\nexport const MASTRA_ID_PROPERTY = 'mastraId';\nexport const META_KEY_PREFIX = 'mastraMeta_';\n// `mastraId` is reserved too: the adapter writes the caller's original id under\n// this property, so a user metadata key of the same name must be encoded to\n// avoid clobbering (or being clobbered by) the internal value.\nexport const RESERVED_META_KEYS = new Set(['id', 'vector', '_additional', MASTRA_ID_PROPERTY]);\n\nexport function encodeMetaKey(key: string): string {\n // Encode reserved names, and also escape any genuine user key that already\n // starts with the prefix. Escaping makes the transform fully reversible:\n // without it, a user key like `mastraMeta_id` would be indistinguishable from\n // an encoded `id` on read and would be returned under the wrong name.\n return RESERVED_META_KEYS.has(key) || key.startsWith(META_KEY_PREFIX) ? `${META_KEY_PREFIX}${key}` : key;\n}\n\nexport function decodeMetaKey(key: string): string {\n return key.startsWith(META_KEY_PREFIX) ? key.slice(META_KEY_PREFIX.length) : key;\n}\n\nexport function encodeMetaProperties(metadata?: Record<string, any>): Record<string, any> {\n if (!metadata) return {};\n const out: Record<string, any> = {};\n for (const [key, value] of Object.entries(metadata)) {\n out[encodeMetaKey(key)] = value;\n }\n return out;\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\nimport { Filters } from 'weaviate-client';\nimport type { FilterValue } from 'weaviate-client';\n\nimport { encodeMetaKey } from './encoding';\n\n/**\n * The subset of Weaviate's collection filter API used by the translator.\n * Provided at translate time via `collection.filter`.\n */\nexport interface WeaviateFilterApi {\n byProperty: (name: string, length?: boolean) => WeaviateFilterProperty;\n}\n\ninterface WeaviateFilterProperty {\n isNull: (value: boolean) => FilterValue;\n equal: (value: any) => FilterValue;\n notEqual: (value: any) => FilterValue;\n greaterThan: (value: any) => FilterValue;\n greaterOrEqual: (value: any) => FilterValue;\n lessThan: (value: any) => FilterValue;\n lessOrEqual: (value: any) => FilterValue;\n containsAny: (value: any[]) => FilterValue;\n containsAll: (value: any[]) => FilterValue;\n containsNone: (value: any[]) => FilterValue;\n}\n\ntype WeaviateOperatorValueMap = Omit<\n OperatorValueMap,\n '$options' | '$elemMatch' | '$regex' | '$nor' | '$size' | '$contains'\n>;\n\ntype WeaviateLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor'>;\n\ntype WeaviateBlacklistedRootOperators = BlacklistedRootOperators;\n\nexport type WeaviateVectorFilter = VectorFilter<\n keyof WeaviateOperatorValueMap,\n WeaviateOperatorValueMap,\n WeaviateLogicalOperatorValueMap,\n WeaviateBlacklistedRootOperators\n>;\n\n/**\n * Translates MongoDB-style filters into Weaviate `FilterValue` objects.\n *\n * Weaviate filters are built from the collection's `filter` API (which produces\n * protobuf-backed targets), so `translate` requires the collection filter API to\n * be supplied alongside the filter.\n */\nexport class WeaviateFilterTranslator extends BaseFilterTranslator<WeaviateVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n logical: ['$and', '$or', '$not'],\n basic: ['$eq', '$ne'],\n numeric: ['$gt', '$gte', '$lt', '$lte'],\n array: ['$in', '$nin', '$all'],\n element: ['$exists'],\n regex: [],\n custom: [],\n };\n }\n\n protected override isOperator(key: string): key is any {\n // $not can be used both logically and at field level.\n return super.isOperator(key) || key === '$not';\n }\n\n translate(filter?: WeaviateVectorFilter, api?: WeaviateFilterApi): FilterValue | undefined {\n if (this.isEmpty(filter)) return undefined;\n if (!api) {\n throw new Error('WeaviateFilterTranslator.translate requires a collection filter API');\n }\n this.validateFilter(filter);\n return this.translateNode(filter as Record<string, any>, api);\n }\n\n /**\n * An empty set matches nothing. Weaviate can't send `containsAny([])` against a text[]\n * property (the empty array is serialized as numbers), so express it as a contradiction\n * on the property's null state, which the collection indexes (`indexNullState: true`).\n */\n private containsAny(prop: WeaviateFilterProperty, values: any[]): FilterValue {\n const normalized = this.normalizeArrayValues(values);\n if (normalized.length === 0) return Filters.and(prop.isNull(true), prop.isNull(false));\n return prop.containsAny(normalized);\n }\n\n private combine(parts: Array<FilterValue | undefined>): FilterValue | undefined {\n const filtered = parts.filter((p): p is FilterValue => p !== undefined);\n if (filtered.length === 0) return undefined;\n if (filtered.length === 1) return filtered[0];\n return Filters.and(...filtered);\n }\n\n private translateNode(node: Record<string, any>, api: WeaviateFilterApi): FilterValue | undefined {\n const parts = Object.entries(node).map(([key, value]) => {\n if (key === '$and') {\n return this.combineLogical('and', value as any[], api);\n }\n if (key === '$or') {\n return this.combineLogical('or', value as any[], api);\n }\n if (key === '$not') {\n // Push the negation into the operators (De Morgan) rather than relying on\n // Weaviate's Not operator, which is not supported by all server versions.\n return this.negateNode(value as Record<string, any>, api);\n }\n return this.translateField(key, value, api);\n });\n return this.combine(parts);\n }\n\n /** Combines parts with OR, dropping undefined entries. */\n private combineOr(parts: Array<FilterValue | undefined>): FilterValue | undefined {\n const filtered = parts.filter((p): p is FilterValue => p !== undefined);\n if (filtered.length === 0) return undefined;\n if (filtered.length === 1) return filtered[0];\n return Filters.or(...filtered);\n }\n\n /**\n * Returns the negation of a node. A node's entries are AND-combined, so the\n * negation is the OR of each entry's negation (De Morgan).\n */\n private negateNode(node: Record<string, any>, api: WeaviateFilterApi): FilterValue | undefined {\n const parts = Object.entries(node).map(([key, value]) => {\n if (key === '$and') {\n // NOT(a AND b) = (NOT a) OR (NOT b)\n return this.combineOr((value as any[]).map(v => this.negateNode(v as Record<string, any>, api)));\n }\n if (key === '$or') {\n // NOT(a OR b) = (NOT a) AND (NOT b)\n return this.combine((value as any[]).map(v => this.negateNode(v as Record<string, any>, api)));\n }\n if (key === '$not') {\n // Double negation.\n return this.translateNode(value as Record<string, any>, api);\n }\n return this.negateField(key, value, api);\n });\n return this.combineOr(parts);\n }\n\n /** Returns the negation of a single field condition. */\n private negateField(field: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n\n if (value === null) {\n return prop.isNull(false);\n }\n if (this.isPrimitive(value)) {\n return prop.notEqual(this.normalizeComparisonValue(value));\n }\n if (Array.isArray(value)) {\n // NOT(field in [..]) = field not equal to every value.\n return this.combine(this.normalizeArrayValues(value).map(v => prop.notEqual(v)));\n }\n\n // Operator object: entries are AND-combined, so negation is OR of negations.\n const parts = Object.entries(value as Record<string, any>).map(([op, opValue]) =>\n this.negateSingleOp(field, op, opValue, api),\n );\n return this.combineOr(parts);\n }\n\n private negateSingleOp(field: string, op: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n switch (op) {\n case '$eq':\n return value === null ? prop.isNull(false) : prop.notEqual(this.normalizeComparisonValue(value));\n case '$ne':\n return value === null ? prop.isNull(true) : prop.equal(this.normalizeComparisonValue(value));\n case '$gt':\n return prop.lessOrEqual(this.normalizeComparisonValue(value));\n case '$gte':\n return prop.lessThan(this.normalizeComparisonValue(value));\n case '$lt':\n return prop.greaterOrEqual(this.normalizeComparisonValue(value));\n case '$lte':\n return prop.greaterThan(this.normalizeComparisonValue(value));\n case '$in':\n // NOT(in [..]) = not equal to every value.\n return this.combine(this.normalizeArrayValues(value as any[]).map(v => prop.notEqual(v)));\n case '$nin':\n // NOT(nin [..]) = in [..].\n return this.containsAny(prop, value as any[]);\n case '$exists':\n return prop.isNull(!!value);\n case '$not':\n return this.translateField(field, value, api);\n default:\n throw unsupportedOperatorError(op, field);\n }\n }\n\n private combineLogical(op: 'and' | 'or', values: any[], api: WeaviateFilterApi): FilterValue | undefined {\n const translated = values\n .map(v => this.translateNode(v as Record<string, any>, api))\n .filter((p): p is FilterValue => p !== undefined);\n if (translated.length === 0) return undefined;\n if (translated.length === 1) return translated[0];\n return op === 'and' ? Filters.and(...translated) : Filters.or(...translated);\n }\n\n private translateField(field: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n\n if (value === null) {\n return prop.isNull(true);\n }\n\n if (this.isPrimitive(value)) {\n return prop.equal(this.normalizeComparisonValue(value));\n }\n\n if (Array.isArray(value)) {\n return this.containsAny(prop, value);\n }\n\n // Operator object: combine each operator condition with AND.\n const parts = Object.entries(value as Record<string, any>).map(([op, opValue]) =>\n this.translateOperator(field, op, opValue, api),\n );\n return this.combine(parts);\n }\n\n private translateOperator(field: string, op: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n switch (op) {\n case '$eq':\n return value === null ? prop.isNull(true) : prop.equal(this.normalizeComparisonValue(value));\n case '$ne':\n return value === null ? prop.isNull(false) : prop.notEqual(this.normalizeComparisonValue(value));\n case '$gt':\n return prop.greaterThan(this.normalizeComparisonValue(value));\n case '$gte':\n return prop.greaterOrEqual(this.normalizeComparisonValue(value));\n case '$lt':\n return prop.lessThan(this.normalizeComparisonValue(value));\n case '$lte':\n return prop.lessOrEqual(this.normalizeComparisonValue(value));\n case '$in':\n return this.containsAny(prop, value as any[]);\n case '$nin':\n // Weaviate's ContainsNone is not available on all server versions; express\n // \"not in\" as an AND of not-equals instead.\n return this.combine(this.normalizeArrayValues(value as any[]).map(v => prop.notEqual(v)));\n case '$all':\n return prop.containsAll(this.normalizeArrayValues(value as any[]));\n case '$exists':\n return prop.isNull(!value);\n case '$not':\n return this.negateField(field, value, api);\n default:\n throw unsupportedOperatorError(op, field);\n }\n }\n}\n\n/** Builds a user-facing error for an operator Weaviate cannot translate. */\nfunction unsupportedOperatorError(op: string, field: string): MastraError {\n return new MastraError({\n id: 'STORAGE_WEAVIATE_FILTER_UNSUPPORTED_OPERATOR',\n text: `Unsupported filter operator \"${op}\" on field \"${field}\"`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { operator: op, field },\n });\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector, validateUpsertInput, validateVectorValues, validateTopK } 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 DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport weaviate, { generateUuid5 } from 'weaviate-client';\nimport type { WeaviateClient, Collection } from 'weaviate-client';\n\nimport { encodeMetaKey, decodeMetaKey, encodeMetaProperties, MASTRA_ID_PROPERTY } from './encoding';\nimport { WeaviateFilterTranslator } from './filter';\nimport type { WeaviateVectorFilter } from './filter';\n\n/**\n * Weaviate distance metrics mapped from Mastra metric names.\n * @see https://weaviate.io/developers/weaviate/config-refs/distances\n */\nconst DISTANCE_MAPPING: Record<string, 'cosine' | 'l2-squared' | 'dot'> = {\n cosine: 'cosine',\n euclidean: 'l2-squared',\n dotproduct: 'dot',\n};\n\nconst REVERSE_DISTANCE_MAPPING: Record<string, 'cosine' | 'euclidean' | 'dotproduct'> = {\n cosine: 'cosine',\n 'l2-squared': 'euclidean',\n dot: 'dotproduct',\n};\n\n/** Reserved property used to round-trip the caller-supplied vector id. */\n\n/** Metadata stored on a collection's description to preserve Mastra semantics. */\ninterface CollectionMeta {\n name: string;\n dimension: number;\n metric: 'cosine' | 'euclidean' | 'dotproduct';\n}\n\n/**\n * Connection options for the Weaviate vector store.\n * These map directly to `weaviate.connectToCustom`.\n */\nexport interface WeaviateVectorParams {\n /** Unique identifier for this vector store instance. */\n id: string;\n /** The hostname of the HTTP server. Defaults to `localhost`. */\n httpHost?: string;\n /** The port of the HTTP server. Defaults to `8080`. */\n httpPort?: number;\n /** Whether to use a secure connection to the HTTP server. Defaults to `false`. */\n httpSecure?: boolean;\n /** The hostname of the gRPC server. Defaults to the HTTP host. */\n grpcHost?: string;\n /** The port of the gRPC server. Defaults to `50051`. */\n grpcPort?: number;\n /** Whether to use a secure connection to the gRPC server. Defaults to `false`. */\n grpcSecure?: boolean;\n /** API key for authenticating with Weaviate (e.g. Weaviate Cloud). */\n apiKey?: string;\n /** Additional headers to include in requests (e.g. vectorizer API keys). */\n headers?: Record<string, string>;\n}\n\n/**\n * A Mastra vector store backed by Weaviate.\n *\n * Vectors are stored in `vectorizer: none` collections (Mastra supplies the\n * embeddings). Because Weaviate requires UUID object ids and capitalised\n * collection names, this adapter maps arbitrary Mastra ids to deterministic\n * UUIDv5 values (preserving the original id in a reserved property) and\n * preserves the original index name in the collection description.\n */\nexport class WeaviateVector extends MastraVector<WeaviateVectorFilter> {\n private clientPromise: Promise<WeaviateClient> | null = null;\n private readonly connectOptions: WeaviateVectorParams;\n /** Cache of property names known to exist in a collection's schema. */\n private readonly knownProperties = new Map<string, Set<string>>();\n /** Serializes schema mutations per collection to avoid concurrent addProperty races. */\n private readonly schemaLocks = new Map<string, Promise<void>>();\n\n constructor(params: WeaviateVectorParams) {\n super({ id: params.id });\n this.connectOptions = params;\n }\n\n private getClient(): Promise<WeaviateClient> {\n if (!this.clientPromise) {\n const { httpHost, httpPort, httpSecure, grpcHost, grpcPort, grpcSecure, apiKey, headers } = this.connectOptions;\n this.clientPromise = weaviate.connectToCustom({\n httpHost: httpHost ?? 'localhost',\n httpPort: httpPort ?? 8080,\n httpSecure: httpSecure ?? false,\n grpcHost: grpcHost ?? httpHost ?? 'localhost',\n grpcPort: grpcPort ?? 50051,\n grpcSecure: grpcSecure ?? false,\n ...(apiKey ? { authCredentials: new weaviate.ApiKey(apiKey) } : {}),\n ...(headers ? { headers } : {}),\n });\n }\n return this.clientPromise;\n }\n\n /** Closes the underlying Weaviate connection. */\n async disconnect(): Promise<void> {\n if (this.clientPromise) {\n const client = await this.clientPromise;\n await client.close();\n this.clientPromise = null;\n }\n }\n\n /** Weaviate collection names must start with an uppercase letter. */\n private toCollectionName(indexName: string): string {\n return indexName.charAt(0).toUpperCase() + indexName.slice(1);\n }\n\n private async getCollection(indexName: string): Promise<Collection> {\n const client = await this.getClient();\n return client.collections.get(this.toCollectionName(indexName));\n }\n\n private parseMeta(description?: string): CollectionMeta | null {\n if (!description) return null;\n try {\n const parsed = JSON.parse(description);\n if (parsed && typeof parsed === 'object' && typeof parsed.name === 'string') {\n return parsed as CollectionMeta;\n }\n } catch {\n // Not a Mastra-managed description.\n }\n return null;\n }\n\n private inferDataType(value: unknown): 'text' | 'number' | 'boolean' | 'text[]' | 'number[]' | 'boolean[]' | null {\n if (typeof value === 'string') return 'text';\n if (typeof value === 'number') return 'number';\n if (typeof value === 'boolean') return 'boolean';\n if (Array.isArray(value)) {\n const first = value.find(v => v !== null && v !== undefined);\n if (typeof first === 'string') return 'text[]';\n if (typeof first === 'number') return 'number[]';\n if (typeof first === 'boolean') return 'boolean[]';\n // Arrays of objects (or empty arrays) are left to Weaviate's auto-schema.\n return null;\n }\n return null;\n }\n\n /**\n * Ensures every metadata key across the batch exists as a collection property.\n * Weaviate's auto-schema would create text properties with `word` tokenization\n * (breaking exact-match filtering), so properties are created explicitly with\n * `field` tokenization for text values.\n */\n private async ensureProperties(\n collection: Collection,\n collectionName: string,\n metadata: Record<string, any>[] | undefined,\n ): Promise<void> {\n if (!metadata?.length) return;\n // Chain schema mutations for the same collection so concurrent upserts do not\n // race on addProperty (which would surface as partial-success failures).\n const prev = this.schemaLocks.get(collectionName) ?? Promise.resolve();\n const next = prev\n .catch(() => undefined)\n .then(() => this.ensurePropertiesLocked(collection, collectionName, metadata));\n this.schemaLocks.set(collectionName, next);\n await next;\n }\n\n private async ensurePropertiesLocked(\n collection: Collection,\n collectionName: string,\n metadata: Record<string, any>[],\n ): Promise<void> {\n let known = this.knownProperties.get(collectionName);\n if (!known) {\n const config = await collection.config.get();\n known = new Set(config.properties.map(p => p.name));\n this.knownProperties.set(collectionName, known);\n }\n\n const seen = new Map<string, 'text' | 'number' | 'boolean' | 'text[]' | 'number[]' | 'boolean[]'>();\n for (const row of metadata) {\n if (!row) continue;\n for (const [rawKey, value] of Object.entries(row)) {\n const key = encodeMetaKey(rawKey);\n if (known.has(key) || seen.has(key) || value === null || value === undefined) continue;\n const dataType = this.inferDataType(value);\n if (dataType) seen.set(key, dataType);\n }\n }\n\n for (const [name, dataType] of seen) {\n try {\n await collection.config.addProperty({\n name,\n dataType,\n ...(dataType === 'text' || dataType === 'text[]' ? { tokenization: 'field' } : {}),\n } as any);\n } catch (error) {\n // Tolerate a property that already exists (e.g. added by a racing caller).\n if (!/already/i.test((error as Error)?.message ?? '')) throw error;\n }\n known.add(name);\n }\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n try {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'INVALID_ARGS'),\n text: 'Dimension must be a positive integer',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, dimension },\n });\n }\n\n const distance = DISTANCE_MAPPING[metric];\n if (!distance) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'INVALID_ARGS'),\n text: `Invalid metric: ${metric}. Must be one of: cosine, euclidean, dotproduct`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, metric },\n });\n }\n\n const client = await this.getClient();\n const collectionName = this.toCollectionName(indexName);\n\n if (await client.collections.exists(collectionName)) {\n // Weaviate capitalises the first letter of collection names, so distinct\n // Mastra index names (e.g. `documents` and `Documents`) map to one\n // collection. Reject the collision instead of silently sharing storage.\n const existingConfig = await client.collections.get(collectionName).config.get();\n const existingMeta = this.parseMeta(existingConfig.description);\n if (existingMeta && existingMeta.name !== indexName) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'NAME_COLLISION'),\n text: `Index name \"${indexName}\" collides with existing index \"${existingMeta.name}\" (Weaviate collection \"${collectionName}\"). Weaviate capitalises the first letter of collection names, so these names cannot coexist.`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, existingName: existingMeta.name, collectionName },\n });\n }\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n\n const meta: CollectionMeta = { name: indexName, dimension, metric };\n await client.collections.create({\n name: collectionName,\n description: JSON.stringify(meta),\n // Store the original Mastra id as an exact-match (\"field\") text property so\n // arbitrary (e.g. numeric) ids are not misinterpreted by Weaviate's auto-schema.\n properties: [{ name: MASTRA_ID_PROPERTY, dataType: 'text', tokenization: 'field' }],\n // Index null state so `$exists` / null-equality filters are supported.\n invertedIndex: weaviate.configure.invertedIndex({ indexNullState: true }),\n vectorizers: weaviate.configure.vectors.selfProvided({\n vectorIndexConfig: weaviate.configure.vectorIndex.hnsw({ distanceMetric: distance }),\n }),\n });\n this.knownProperties.set(collectionName, new Set([MASTRA_ID_PROPERTY]));\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /** Fetches a collection's stored metadata, throwing if the index does not exist. */\n private async requireMeta(indexName: string, operation: string): Promise<CollectionMeta | null> {\n const client = await this.getClient();\n const collectionName = this.toCollectionName(indexName);\n if (!(await client.collections.exists(collectionName))) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', operation, 'INDEX_NOT_FOUND'),\n text: `Index ${indexName} does not exist`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n const config = await client.collections.get(collectionName).config.get();\n return this.parseMeta(config.description);\n }\n\n async upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]> {\n try {\n validateUpsertInput('WEAVIATE', vectors, metadata, ids);\n validateVectorValues('WEAVIATE', vectors);\n\n const meta = await this.requireMeta(indexName, 'UPSERT');\n if (meta?.dimension) {\n const mismatch = vectors.find(v => v.length !== meta.dimension);\n if (mismatch) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPSERT', 'DIMENSION_MISMATCH'),\n text: `Vector dimension ${mismatch.length} does not match index dimension ${meta.dimension}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, expected: meta.dimension, actual: mismatch.length },\n });\n }\n }\n\n const collection = await this.getCollection(indexName);\n await this.ensureProperties(collection, this.toCollectionName(indexName), metadata);\n const originalIds = ids ?? vectors.map(() => crypto.randomUUID());\n\n const objects = vectors.map((vector, i) => {\n const originalId = originalIds[i]!;\n return {\n id: generateUuid5(originalId),\n vectors: vector,\n properties: {\n ...encodeMetaProperties(metadata?.[i]),\n [MASTRA_ID_PROPERTY]: originalId,\n },\n };\n });\n\n const result = await collection.data.insertMany(objects);\n if (result.hasErrors) {\n const firstError = Object.values(result.errors)[0];\n throw new Error(firstError?.message ?? 'Weaviate insertMany reported errors');\n }\n\n return originalIds;\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'UPSERT', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n private transformFilter(collection: Collection, filter?: WeaviateVectorFilter) {\n const translator = new WeaviateFilterTranslator();\n return translator.translate(filter, collection.filter as any);\n }\n\n private toQueryResult(obj: any, includeVector?: boolean): QueryResult {\n const raw = obj.properties ?? {};\n const originalId = raw[MASTRA_ID_PROPERTY];\n const properties: Record<string, any> = {};\n for (const [key, value] of Object.entries(raw)) {\n if (key === MASTRA_ID_PROPERTY || value === undefined) continue;\n properties[decodeMetaKey(key)] = value;\n }\n\n const distance = obj.metadata?.distance;\n const score = typeof distance === 'number' ? 1 - distance : (obj.metadata?.certainty ?? 0);\n\n const result: QueryResult = {\n id: typeof originalId === 'string' ? originalId : obj.uuid,\n score,\n metadata: properties,\n };\n\n if (includeVector) {\n const vectors = obj.vectors ?? {};\n result.vector = vectors.default ?? Object.values(vectors)[0];\n }\n\n return result;\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n }: QueryVectorParams<WeaviateVectorFilter>): Promise<QueryResult[]> {\n try {\n validateTopK('WEAVIATE', topK);\n\n const meta = await this.requireMeta(indexName, 'QUERY');\n if (queryVector && meta?.dimension && queryVector.length !== meta.dimension) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'QUERY', 'DIMENSION_MISMATCH'),\n text: `Query vector dimension ${queryVector.length} does not match index dimension ${meta.dimension}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, expected: meta.dimension, actual: queryVector.length },\n });\n }\n\n const collection = await this.getCollection(indexName);\n const filters = this.transformFilter(collection, filter);\n const returnMetadata = ['distance'] as const;\n\n if (queryVector) {\n const response = await collection.query.nearVector(queryVector, {\n limit: topK,\n includeVector,\n returnMetadata: returnMetadata as any,\n ...(filters ? { filters } : {}),\n });\n return response.objects.map(obj => this.toQueryResult(obj, includeVector));\n }\n\n const response = await collection.query.fetchObjects({\n limit: topK,\n includeVector,\n ...(filters ? { filters } : {}),\n });\n return response.objects.map(obj => this.toQueryResult(obj, includeVector));\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'QUERY', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const client = await this.getClient();\n const collections = await client.collections.listAll();\n return collections.map(config => {\n const meta = this.parseMeta(config.description);\n return meta?.name ?? config.name;\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'LIST_INDEXES', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const client = await this.getClient();\n const collectionName = this.toCollectionName(indexName);\n if (!(await client.collections.exists(collectionName))) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'DESCRIBE_INDEX', 'INDEX_NOT_FOUND'),\n text: `Index ${indexName} does not exist`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n const collection = client.collections.get(collectionName);\n const config = await collection.config.get();\n const meta = this.parseMeta(config.description);\n\n const count = await collection.length();\n\n let dimension = meta?.dimension ?? 0;\n if (!dimension) {\n // Fall back to sampling a stored vector when dimension is unknown.\n const sample = await collection.query.fetchObjects({ limit: 1, includeVector: true });\n const vectors = sample.objects[0]?.vectors ?? {};\n const vec = (vectors as any).default ?? Object.values(vectors)[0];\n if (Array.isArray(vec)) dimension = vec.length;\n }\n\n let metric = meta?.metric;\n if (!metric) {\n const vectorConfig = (config.vectorizers as any)?.default ?? Object.values(config.vectorizers ?? {})[0];\n const distance = vectorConfig?.indexConfig?.distance;\n metric = distance ? REVERSE_DISTANCE_MAPPING[distance] : undefined;\n }\n\n return { dimension, count, metric };\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', '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 const client = await this.getClient();\n await client.collections.delete(this.toCollectionName(indexName));\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'DELETE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async updateVector({ indexName, id, filter, update }: UpdateVectorParams<WeaviateVectorFilter>): Promise<void> {\n try {\n if (id !== undefined && filter !== undefined) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n text: 'id and filter are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!update || (!update.vector && !update.metadata)) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n text: 'Update data is required: no updates provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate the id/filter target BEFORE touching the collection, otherwise a\n // rejected update (missing target or empty filter) would still mutate the\n // collection schema via ensureProperties below.\n if (id === undefined && filter === undefined) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\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 (id === undefined && (typeof filter !== 'object' || filter === null || Object.keys(filter).length === 0)) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n text: 'A non-empty filter is required: empty filter not allowed',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n const collection = await this.getCollection(indexName);\n\n // Mirror upsert's schema handling: create any missing properties with\n // `field` tokenization and encode reserved keys, otherwise updated metadata\n // would be auto-schemad with `word` tokenization (breaking exact-match\n // filters) or clash with Weaviate's reserved property names.\n if (update.metadata) {\n await this.ensureProperties(collection, this.toCollectionName(indexName), [update.metadata]);\n }\n const encodedProperties = update.metadata ? encodeMetaProperties(update.metadata) : undefined;\n\n const applyUpdate = async (uuid: string) => {\n await collection.data.update({\n id: uuid,\n ...(encodedProperties ? { properties: encodedProperties } : {}),\n ...(update.vector ? { vectors: update.vector } : {}),\n });\n };\n\n if (id !== undefined) {\n await applyUpdate(generateUuid5(id));\n return;\n }\n\n const filters = this.transformFilter(collection, filter!);\n // Page through the full match set so large filters don't silently update\n // only the first page and report success. Collect all uuids first, then\n // apply, so mutations can't shift the pagination window mid-iteration.\n const PAGE_SIZE = 1000;\n // Weaviate rejects fetchObjects once offset+limit exceeds its\n // QUERY_MAXIMUM_RESULTS cap (default 10000). Fail loudly with a clear\n // USER error before that happens rather than surfacing a raw driver error.\n const MAX_FILTERED_UPDATE = 10000;\n const uuids: string[] = [];\n for (let offset = 0; ; offset += PAGE_SIZE) {\n if (offset >= MAX_FILTERED_UPDATE) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: `Filtered updateVector matched more than ${MAX_FILTERED_UPDATE} vectors, which exceeds Weaviate's query result cap. Narrow the filter or update by id.`,\n details: { indexName, limit: MAX_FILTERED_UPDATE },\n });\n }\n const page = await collection.query.fetchObjects({\n limit: PAGE_SIZE,\n offset,\n ...(filters ? { filters } : {}),\n });\n for (const obj of page.objects) uuids.push(obj.uuid);\n if (page.objects.length < PAGE_SIZE) break;\n }\n for (const uuid of uuids) {\n await applyUpdate(uuid);\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, ...(id ? { id } : {}) },\n },\n error,\n );\n }\n }\n\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n const collection = await this.getCollection(indexName);\n await collection.data.deleteById(generateUuid5(id));\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'DELETE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<WeaviateVectorFilter>): Promise<void> {\n if (ids && filter) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', '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('WEAVIATE', '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 if (ids && ids.length === 0) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', '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 if (filter && typeof filter === 'object' && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', '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 collection = await this.getCollection(indexName);\n if (ids) {\n for (const id of ids) {\n await collection.data.deleteById(generateUuid5(id));\n }\n } else if (filter) {\n const filters = this.transformFilter(collection, filter);\n if (filters) {\n await collection.data.deleteMany(filters);\n }\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', '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 Weaviate Vector.\n */\nexport const WEAVIATE_PROMPT = `When querying Weaviate, 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 arrays containing all values\n Example: { \"tags\": { \"$all\": [\"sale\", \"new\"] } }\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- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists (is not null)\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and, $or, and $not logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\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, $not):\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\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": { \"$eq\": true } }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,qBAAqB;AAClC,MAAa,kBAAkB;AAI/B,MAAa,qCAAqB,IAAI,IAAI;CAAC;CAAM;CAAU;CAAe;AAAkB,CAAC;AAE7F,SAAgB,cAAc,KAAqB;CAKjD,OAAO,mBAAmB,IAAI,GAAG,KAAK,IAAI,WAAA,aAA0B,IAAI,GAAG,kBAAkB,QAAQ;AACvG;AAEA,SAAgB,cAAc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,OAAO;IACpC;GACF,GACA,KACF;EACF;CACF;AACF;;;;;;AC/tBA,MAAa,kBAAkB"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createVectorErrorId } from "@mastra/core/storage";
|
|
|
3
3
|
import { MastraVector, validateTopK, validateUpsertInput, validateVectorValues } from "@mastra/core/vector";
|
|
4
4
|
import weaviate, { Filters, generateUuid5 } from "weaviate-client";
|
|
5
5
|
import { BaseFilterTranslator } from "@mastra/core/vector/filter";
|
|
6
|
-
|
|
6
|
+
// src/vector/encoding.ts
|
|
7
7
|
/**
|
|
8
8
|
* Weaviate reserves certain property names (e.g. `id`, `vector`). Metadata keys
|
|
9
9
|
* that collide are stored under a stable prefix and restored on read. This
|
|
@@ -31,8 +31,7 @@ function encodeMetaProperties(metadata) {
|
|
|
31
31
|
for (const [key, value] of Object.entries(metadata)) out[encodeMetaKey(key)] = value;
|
|
32
32
|
return out;
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
//#region src/vector/filter.ts
|
|
34
|
+
// src/vector/filter.ts
|
|
36
35
|
/**
|
|
37
36
|
* Translates MongoDB-style filters into Weaviate `FilterValue` objects.
|
|
38
37
|
*
|
|
@@ -189,8 +188,7 @@ function unsupportedOperatorError(op, field) {
|
|
|
189
188
|
}
|
|
190
189
|
});
|
|
191
190
|
}
|
|
192
|
-
|
|
193
|
-
//#region src/vector/index.ts
|
|
191
|
+
// src/vector/index.ts
|
|
194
192
|
/**
|
|
195
193
|
* Weaviate distance metrics mapped from Mastra metric names.
|
|
196
194
|
* @see https://weaviate.io/developers/weaviate/config-refs/distances
|
|
@@ -729,8 +727,7 @@ var WeaviateVector = class extends MastraVector {
|
|
|
729
727
|
}
|
|
730
728
|
}
|
|
731
729
|
};
|
|
732
|
-
|
|
733
|
-
//#region src/vector/prompt.ts
|
|
730
|
+
// src/vector/prompt.ts
|
|
734
731
|
/**
|
|
735
732
|
* Vector store specific prompt that details supported operators and examples.
|
|
736
733
|
* This prompt helps users construct valid filters for Weaviate Vector.
|
|
@@ -810,7 +807,6 @@ Example Complex Query:
|
|
|
810
807
|
{ "$not": { "status": "discontinued" } }
|
|
811
808
|
]
|
|
812
809
|
}`;
|
|
813
|
-
//#endregion
|
|
814
810
|
export { WEAVIATE_PROMPT, WeaviateVector };
|
|
815
811
|
|
|
816
812
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/vector/encoding.ts","../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"sourcesContent":["/**\n * Weaviate reserves certain property names (e.g. `id`, `vector`). Metadata keys\n * that collide are stored under a stable prefix and restored on read. This\n * module is the single source of truth shared by the adapter and the filter\n * translator — they must encode keys identically or filters will silently miss.\n */\n/** Internal property used to round-trip the caller's original id. */\nexport const MASTRA_ID_PROPERTY = 'mastraId';\nexport const META_KEY_PREFIX = 'mastraMeta_';\n// `mastraId` is reserved too: the adapter writes the caller's original id under\n// this property, so a user metadata key of the same name must be encoded to\n// avoid clobbering (or being clobbered by) the internal value.\nexport const RESERVED_META_KEYS = new Set(['id', 'vector', '_additional', MASTRA_ID_PROPERTY]);\n\nexport function encodeMetaKey(key: string): string {\n // Encode reserved names, and also escape any genuine user key that already\n // starts with the prefix. Escaping makes the transform fully reversible:\n // without it, a user key like `mastraMeta_id` would be indistinguishable from\n // an encoded `id` on read and would be returned under the wrong name.\n return RESERVED_META_KEYS.has(key) || key.startsWith(META_KEY_PREFIX) ? `${META_KEY_PREFIX}${key}` : key;\n}\n\nexport function decodeMetaKey(key: string): string {\n return key.startsWith(META_KEY_PREFIX) ? key.slice(META_KEY_PREFIX.length) : key;\n}\n\nexport function encodeMetaProperties(metadata?: Record<string, any>): Record<string, any> {\n if (!metadata) return {};\n const out: Record<string, any> = {};\n for (const [key, value] of Object.entries(metadata)) {\n out[encodeMetaKey(key)] = value;\n }\n return out;\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\nimport { Filters } from 'weaviate-client';\nimport type { FilterValue } from 'weaviate-client';\n\nimport { encodeMetaKey } from './encoding';\n\n/**\n * The subset of Weaviate's collection filter API used by the translator.\n * Provided at translate time via `collection.filter`.\n */\nexport interface WeaviateFilterApi {\n byProperty: (name: string, length?: boolean) => WeaviateFilterProperty;\n}\n\ninterface WeaviateFilterProperty {\n isNull: (value: boolean) => FilterValue;\n equal: (value: any) => FilterValue;\n notEqual: (value: any) => FilterValue;\n greaterThan: (value: any) => FilterValue;\n greaterOrEqual: (value: any) => FilterValue;\n lessThan: (value: any) => FilterValue;\n lessOrEqual: (value: any) => FilterValue;\n containsAny: (value: any[]) => FilterValue;\n containsAll: (value: any[]) => FilterValue;\n containsNone: (value: any[]) => FilterValue;\n}\n\ntype WeaviateOperatorValueMap = Omit<\n OperatorValueMap,\n '$options' | '$elemMatch' | '$regex' | '$nor' | '$size' | '$contains'\n>;\n\ntype WeaviateLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor'>;\n\ntype WeaviateBlacklistedRootOperators = BlacklistedRootOperators;\n\nexport type WeaviateVectorFilter = VectorFilter<\n keyof WeaviateOperatorValueMap,\n WeaviateOperatorValueMap,\n WeaviateLogicalOperatorValueMap,\n WeaviateBlacklistedRootOperators\n>;\n\n/**\n * Translates MongoDB-style filters into Weaviate `FilterValue` objects.\n *\n * Weaviate filters are built from the collection's `filter` API (which produces\n * protobuf-backed targets), so `translate` requires the collection filter API to\n * be supplied alongside the filter.\n */\nexport class WeaviateFilterTranslator extends BaseFilterTranslator<WeaviateVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n logical: ['$and', '$or', '$not'],\n basic: ['$eq', '$ne'],\n numeric: ['$gt', '$gte', '$lt', '$lte'],\n array: ['$in', '$nin', '$all'],\n element: ['$exists'],\n regex: [],\n custom: [],\n };\n }\n\n protected override isOperator(key: string): key is any {\n // $not can be used both logically and at field level.\n return super.isOperator(key) || key === '$not';\n }\n\n translate(filter?: WeaviateVectorFilter, api?: WeaviateFilterApi): FilterValue | undefined {\n if (this.isEmpty(filter)) return undefined;\n if (!api) {\n throw new Error('WeaviateFilterTranslator.translate requires a collection filter API');\n }\n this.validateFilter(filter);\n return this.translateNode(filter as Record<string, any>, api);\n }\n\n /**\n * An empty set matches nothing. Weaviate can't send `containsAny([])` against a text[]\n * property (the empty array is serialized as numbers), so express it as a contradiction\n * on the property's null state, which the collection indexes (`indexNullState: true`).\n */\n private containsAny(prop: WeaviateFilterProperty, values: any[]): FilterValue {\n const normalized = this.normalizeArrayValues(values);\n if (normalized.length === 0) return Filters.and(prop.isNull(true), prop.isNull(false));\n return prop.containsAny(normalized);\n }\n\n private combine(parts: Array<FilterValue | undefined>): FilterValue | undefined {\n const filtered = parts.filter((p): p is FilterValue => p !== undefined);\n if (filtered.length === 0) return undefined;\n if (filtered.length === 1) return filtered[0];\n return Filters.and(...filtered);\n }\n\n private translateNode(node: Record<string, any>, api: WeaviateFilterApi): FilterValue | undefined {\n const parts = Object.entries(node).map(([key, value]) => {\n if (key === '$and') {\n return this.combineLogical('and', value as any[], api);\n }\n if (key === '$or') {\n return this.combineLogical('or', value as any[], api);\n }\n if (key === '$not') {\n // Push the negation into the operators (De Morgan) rather than relying on\n // Weaviate's Not operator, which is not supported by all server versions.\n return this.negateNode(value as Record<string, any>, api);\n }\n return this.translateField(key, value, api);\n });\n return this.combine(parts);\n }\n\n /** Combines parts with OR, dropping undefined entries. */\n private combineOr(parts: Array<FilterValue | undefined>): FilterValue | undefined {\n const filtered = parts.filter((p): p is FilterValue => p !== undefined);\n if (filtered.length === 0) return undefined;\n if (filtered.length === 1) return filtered[0];\n return Filters.or(...filtered);\n }\n\n /**\n * Returns the negation of a node. A node's entries are AND-combined, so the\n * negation is the OR of each entry's negation (De Morgan).\n */\n private negateNode(node: Record<string, any>, api: WeaviateFilterApi): FilterValue | undefined {\n const parts = Object.entries(node).map(([key, value]) => {\n if (key === '$and') {\n // NOT(a AND b) = (NOT a) OR (NOT b)\n return this.combineOr((value as any[]).map(v => this.negateNode(v as Record<string, any>, api)));\n }\n if (key === '$or') {\n // NOT(a OR b) = (NOT a) AND (NOT b)\n return this.combine((value as any[]).map(v => this.negateNode(v as Record<string, any>, api)));\n }\n if (key === '$not') {\n // Double negation.\n return this.translateNode(value as Record<string, any>, api);\n }\n return this.negateField(key, value, api);\n });\n return this.combineOr(parts);\n }\n\n /** Returns the negation of a single field condition. */\n private negateField(field: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n\n if (value === null) {\n return prop.isNull(false);\n }\n if (this.isPrimitive(value)) {\n return prop.notEqual(this.normalizeComparisonValue(value));\n }\n if (Array.isArray(value)) {\n // NOT(field in [..]) = field not equal to every value.\n return this.combine(this.normalizeArrayValues(value).map(v => prop.notEqual(v)));\n }\n\n // Operator object: entries are AND-combined, so negation is OR of negations.\n const parts = Object.entries(value as Record<string, any>).map(([op, opValue]) =>\n this.negateSingleOp(field, op, opValue, api),\n );\n return this.combineOr(parts);\n }\n\n private negateSingleOp(field: string, op: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n switch (op) {\n case '$eq':\n return value === null ? prop.isNull(false) : prop.notEqual(this.normalizeComparisonValue(value));\n case '$ne':\n return value === null ? prop.isNull(true) : prop.equal(this.normalizeComparisonValue(value));\n case '$gt':\n return prop.lessOrEqual(this.normalizeComparisonValue(value));\n case '$gte':\n return prop.lessThan(this.normalizeComparisonValue(value));\n case '$lt':\n return prop.greaterOrEqual(this.normalizeComparisonValue(value));\n case '$lte':\n return prop.greaterThan(this.normalizeComparisonValue(value));\n case '$in':\n // NOT(in [..]) = not equal to every value.\n return this.combine(this.normalizeArrayValues(value as any[]).map(v => prop.notEqual(v)));\n case '$nin':\n // NOT(nin [..]) = in [..].\n return this.containsAny(prop, value as any[]);\n case '$exists':\n return prop.isNull(!!value);\n case '$not':\n return this.translateField(field, value, api);\n default:\n throw unsupportedOperatorError(op, field);\n }\n }\n\n private combineLogical(op: 'and' | 'or', values: any[], api: WeaviateFilterApi): FilterValue | undefined {\n const translated = values\n .map(v => this.translateNode(v as Record<string, any>, api))\n .filter((p): p is FilterValue => p !== undefined);\n if (translated.length === 0) return undefined;\n if (translated.length === 1) return translated[0];\n return op === 'and' ? Filters.and(...translated) : Filters.or(...translated);\n }\n\n private translateField(field: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n\n if (value === null) {\n return prop.isNull(true);\n }\n\n if (this.isPrimitive(value)) {\n return prop.equal(this.normalizeComparisonValue(value));\n }\n\n if (Array.isArray(value)) {\n return this.containsAny(prop, value);\n }\n\n // Operator object: combine each operator condition with AND.\n const parts = Object.entries(value as Record<string, any>).map(([op, opValue]) =>\n this.translateOperator(field, op, opValue, api),\n );\n return this.combine(parts);\n }\n\n private translateOperator(field: string, op: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n switch (op) {\n case '$eq':\n return value === null ? prop.isNull(true) : prop.equal(this.normalizeComparisonValue(value));\n case '$ne':\n return value === null ? prop.isNull(false) : prop.notEqual(this.normalizeComparisonValue(value));\n case '$gt':\n return prop.greaterThan(this.normalizeComparisonValue(value));\n case '$gte':\n return prop.greaterOrEqual(this.normalizeComparisonValue(value));\n case '$lt':\n return prop.lessThan(this.normalizeComparisonValue(value));\n case '$lte':\n return prop.lessOrEqual(this.normalizeComparisonValue(value));\n case '$in':\n return this.containsAny(prop, value as any[]);\n case '$nin':\n // Weaviate's ContainsNone is not available on all server versions; express\n // \"not in\" as an AND of not-equals instead.\n return this.combine(this.normalizeArrayValues(value as any[]).map(v => prop.notEqual(v)));\n case '$all':\n return prop.containsAll(this.normalizeArrayValues(value as any[]));\n case '$exists':\n return prop.isNull(!value);\n case '$not':\n return this.negateField(field, value, api);\n default:\n throw unsupportedOperatorError(op, field);\n }\n }\n}\n\n/** Builds a user-facing error for an operator Weaviate cannot translate. */\nfunction unsupportedOperatorError(op: string, field: string): MastraError {\n return new MastraError({\n id: 'STORAGE_WEAVIATE_FILTER_UNSUPPORTED_OPERATOR',\n text: `Unsupported filter operator \"${op}\" on field \"${field}\"`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { operator: op, field },\n });\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector, validateUpsertInput, validateVectorValues, validateTopK } 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 DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport weaviate, { generateUuid5 } from 'weaviate-client';\nimport type { WeaviateClient, Collection } from 'weaviate-client';\n\nimport { encodeMetaKey, decodeMetaKey, encodeMetaProperties, MASTRA_ID_PROPERTY } from './encoding';\nimport { WeaviateFilterTranslator } from './filter';\nimport type { WeaviateVectorFilter } from './filter';\n\n/**\n * Weaviate distance metrics mapped from Mastra metric names.\n * @see https://weaviate.io/developers/weaviate/config-refs/distances\n */\nconst DISTANCE_MAPPING: Record<string, 'cosine' | 'l2-squared' | 'dot'> = {\n cosine: 'cosine',\n euclidean: 'l2-squared',\n dotproduct: 'dot',\n};\n\nconst REVERSE_DISTANCE_MAPPING: Record<string, 'cosine' | 'euclidean' | 'dotproduct'> = {\n cosine: 'cosine',\n 'l2-squared': 'euclidean',\n dot: 'dotproduct',\n};\n\n/** Reserved property used to round-trip the caller-supplied vector id. */\n\n/** Metadata stored on a collection's description to preserve Mastra semantics. */\ninterface CollectionMeta {\n name: string;\n dimension: number;\n metric: 'cosine' | 'euclidean' | 'dotproduct';\n}\n\n/**\n * Connection options for the Weaviate vector store.\n * These map directly to `weaviate.connectToCustom`.\n */\nexport interface WeaviateVectorParams {\n /** Unique identifier for this vector store instance. */\n id: string;\n /** The hostname of the HTTP server. Defaults to `localhost`. */\n httpHost?: string;\n /** The port of the HTTP server. Defaults to `8080`. */\n httpPort?: number;\n /** Whether to use a secure connection to the HTTP server. Defaults to `false`. */\n httpSecure?: boolean;\n /** The hostname of the gRPC server. Defaults to the HTTP host. */\n grpcHost?: string;\n /** The port of the gRPC server. Defaults to `50051`. */\n grpcPort?: number;\n /** Whether to use a secure connection to the gRPC server. Defaults to `false`. */\n grpcSecure?: boolean;\n /** API key for authenticating with Weaviate (e.g. Weaviate Cloud). */\n apiKey?: string;\n /** Additional headers to include in requests (e.g. vectorizer API keys). */\n headers?: Record<string, string>;\n}\n\n/**\n * A Mastra vector store backed by Weaviate.\n *\n * Vectors are stored in `vectorizer: none` collections (Mastra supplies the\n * embeddings). Because Weaviate requires UUID object ids and capitalised\n * collection names, this adapter maps arbitrary Mastra ids to deterministic\n * UUIDv5 values (preserving the original id in a reserved property) and\n * preserves the original index name in the collection description.\n */\nexport class WeaviateVector extends MastraVector<WeaviateVectorFilter> {\n private clientPromise: Promise<WeaviateClient> | null = null;\n private readonly connectOptions: WeaviateVectorParams;\n /** Cache of property names known to exist in a collection's schema. */\n private readonly knownProperties = new Map<string, Set<string>>();\n /** Serializes schema mutations per collection to avoid concurrent addProperty races. */\n private readonly schemaLocks = new Map<string, Promise<void>>();\n\n constructor(params: WeaviateVectorParams) {\n super({ id: params.id });\n this.connectOptions = params;\n }\n\n private getClient(): Promise<WeaviateClient> {\n if (!this.clientPromise) {\n const { httpHost, httpPort, httpSecure, grpcHost, grpcPort, grpcSecure, apiKey, headers } = this.connectOptions;\n this.clientPromise = weaviate.connectToCustom({\n httpHost: httpHost ?? 'localhost',\n httpPort: httpPort ?? 8080,\n httpSecure: httpSecure ?? false,\n grpcHost: grpcHost ?? httpHost ?? 'localhost',\n grpcPort: grpcPort ?? 50051,\n grpcSecure: grpcSecure ?? false,\n ...(apiKey ? { authCredentials: new weaviate.ApiKey(apiKey) } : {}),\n ...(headers ? { headers } : {}),\n });\n }\n return this.clientPromise;\n }\n\n /** Closes the underlying Weaviate connection. */\n async disconnect(): Promise<void> {\n if (this.clientPromise) {\n const client = await this.clientPromise;\n await client.close();\n this.clientPromise = null;\n }\n }\n\n /** Weaviate collection names must start with an uppercase letter. */\n private toCollectionName(indexName: string): string {\n return indexName.charAt(0).toUpperCase() + indexName.slice(1);\n }\n\n private async getCollection(indexName: string): Promise<Collection> {\n const client = await this.getClient();\n return client.collections.get(this.toCollectionName(indexName));\n }\n\n private parseMeta(description?: string): CollectionMeta | null {\n if (!description) return null;\n try {\n const parsed = JSON.parse(description);\n if (parsed && typeof parsed === 'object' && typeof parsed.name === 'string') {\n return parsed as CollectionMeta;\n }\n } catch {\n // Not a Mastra-managed description.\n }\n return null;\n }\n\n private inferDataType(value: unknown): 'text' | 'number' | 'boolean' | 'text[]' | 'number[]' | 'boolean[]' | null {\n if (typeof value === 'string') return 'text';\n if (typeof value === 'number') return 'number';\n if (typeof value === 'boolean') return 'boolean';\n if (Array.isArray(value)) {\n const first = value.find(v => v !== null && v !== undefined);\n if (typeof first === 'string') return 'text[]';\n if (typeof first === 'number') return 'number[]';\n if (typeof first === 'boolean') return 'boolean[]';\n // Arrays of objects (or empty arrays) are left to Weaviate's auto-schema.\n return null;\n }\n return null;\n }\n\n /**\n * Ensures every metadata key across the batch exists as a collection property.\n * Weaviate's auto-schema would create text properties with `word` tokenization\n * (breaking exact-match filtering), so properties are created explicitly with\n * `field` tokenization for text values.\n */\n private async ensureProperties(\n collection: Collection,\n collectionName: string,\n metadata: Record<string, any>[] | undefined,\n ): Promise<void> {\n if (!metadata?.length) return;\n // Chain schema mutations for the same collection so concurrent upserts do not\n // race on addProperty (which would surface as partial-success failures).\n const prev = this.schemaLocks.get(collectionName) ?? Promise.resolve();\n const next = prev\n .catch(() => undefined)\n .then(() => this.ensurePropertiesLocked(collection, collectionName, metadata));\n this.schemaLocks.set(collectionName, next);\n await next;\n }\n\n private async ensurePropertiesLocked(\n collection: Collection,\n collectionName: string,\n metadata: Record<string, any>[],\n ): Promise<void> {\n let known = this.knownProperties.get(collectionName);\n if (!known) {\n const config = await collection.config.get();\n known = new Set(config.properties.map(p => p.name));\n this.knownProperties.set(collectionName, known);\n }\n\n const seen = new Map<string, 'text' | 'number' | 'boolean' | 'text[]' | 'number[]' | 'boolean[]'>();\n for (const row of metadata) {\n if (!row) continue;\n for (const [rawKey, value] of Object.entries(row)) {\n const key = encodeMetaKey(rawKey);\n if (known.has(key) || seen.has(key) || value === null || value === undefined) continue;\n const dataType = this.inferDataType(value);\n if (dataType) seen.set(key, dataType);\n }\n }\n\n for (const [name, dataType] of seen) {\n try {\n await collection.config.addProperty({\n name,\n dataType,\n ...(dataType === 'text' || dataType === 'text[]' ? { tokenization: 'field' } : {}),\n } as any);\n } catch (error) {\n // Tolerate a property that already exists (e.g. added by a racing caller).\n if (!/already/i.test((error as Error)?.message ?? '')) throw error;\n }\n known.add(name);\n }\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n try {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'INVALID_ARGS'),\n text: 'Dimension must be a positive integer',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, dimension },\n });\n }\n\n const distance = DISTANCE_MAPPING[metric];\n if (!distance) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'INVALID_ARGS'),\n text: `Invalid metric: ${metric}. Must be one of: cosine, euclidean, dotproduct`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, metric },\n });\n }\n\n const client = await this.getClient();\n const collectionName = this.toCollectionName(indexName);\n\n if (await client.collections.exists(collectionName)) {\n // Weaviate capitalises the first letter of collection names, so distinct\n // Mastra index names (e.g. `documents` and `Documents`) map to one\n // collection. Reject the collision instead of silently sharing storage.\n const existingConfig = await client.collections.get(collectionName).config.get();\n const existingMeta = this.parseMeta(existingConfig.description);\n if (existingMeta && existingMeta.name !== indexName) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'NAME_COLLISION'),\n text: `Index name \"${indexName}\" collides with existing index \"${existingMeta.name}\" (Weaviate collection \"${collectionName}\"). Weaviate capitalises the first letter of collection names, so these names cannot coexist.`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, existingName: existingMeta.name, collectionName },\n });\n }\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n\n const meta: CollectionMeta = { name: indexName, dimension, metric };\n await client.collections.create({\n name: collectionName,\n description: JSON.stringify(meta),\n // Store the original Mastra id as an exact-match (\"field\") text property so\n // arbitrary (e.g. numeric) ids are not misinterpreted by Weaviate's auto-schema.\n properties: [{ name: MASTRA_ID_PROPERTY, dataType: 'text', tokenization: 'field' }],\n // Index null state so `$exists` / null-equality filters are supported.\n invertedIndex: weaviate.configure.invertedIndex({ indexNullState: true }),\n vectorizers: weaviate.configure.vectors.selfProvided({\n vectorIndexConfig: weaviate.configure.vectorIndex.hnsw({ distanceMetric: distance }),\n }),\n });\n this.knownProperties.set(collectionName, new Set([MASTRA_ID_PROPERTY]));\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /** Fetches a collection's stored metadata, throwing if the index does not exist. */\n private async requireMeta(indexName: string, operation: string): Promise<CollectionMeta | null> {\n const client = await this.getClient();\n const collectionName = this.toCollectionName(indexName);\n if (!(await client.collections.exists(collectionName))) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', operation, 'INDEX_NOT_FOUND'),\n text: `Index ${indexName} does not exist`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n const config = await client.collections.get(collectionName).config.get();\n return this.parseMeta(config.description);\n }\n\n async upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]> {\n try {\n validateUpsertInput('WEAVIATE', vectors, metadata, ids);\n validateVectorValues('WEAVIATE', vectors);\n\n const meta = await this.requireMeta(indexName, 'UPSERT');\n if (meta?.dimension) {\n const mismatch = vectors.find(v => v.length !== meta.dimension);\n if (mismatch) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPSERT', 'DIMENSION_MISMATCH'),\n text: `Vector dimension ${mismatch.length} does not match index dimension ${meta.dimension}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, expected: meta.dimension, actual: mismatch.length },\n });\n }\n }\n\n const collection = await this.getCollection(indexName);\n await this.ensureProperties(collection, this.toCollectionName(indexName), metadata);\n const originalIds = ids ?? vectors.map(() => crypto.randomUUID());\n\n const objects = vectors.map((vector, i) => {\n const originalId = originalIds[i]!;\n return {\n id: generateUuid5(originalId),\n vectors: vector,\n properties: {\n ...encodeMetaProperties(metadata?.[i]),\n [MASTRA_ID_PROPERTY]: originalId,\n },\n };\n });\n\n const result = await collection.data.insertMany(objects);\n if (result.hasErrors) {\n const firstError = Object.values(result.errors)[0];\n throw new Error(firstError?.message ?? 'Weaviate insertMany reported errors');\n }\n\n return originalIds;\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'UPSERT', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n private transformFilter(collection: Collection, filter?: WeaviateVectorFilter) {\n const translator = new WeaviateFilterTranslator();\n return translator.translate(filter, collection.filter as any);\n }\n\n private toQueryResult(obj: any, includeVector?: boolean): QueryResult {\n const raw = obj.properties ?? {};\n const originalId = raw[MASTRA_ID_PROPERTY];\n const properties: Record<string, any> = {};\n for (const [key, value] of Object.entries(raw)) {\n if (key === MASTRA_ID_PROPERTY || value === undefined) continue;\n properties[decodeMetaKey(key)] = value;\n }\n\n const distance = obj.metadata?.distance;\n const score = typeof distance === 'number' ? 1 - distance : (obj.metadata?.certainty ?? 0);\n\n const result: QueryResult = {\n id: typeof originalId === 'string' ? originalId : obj.uuid,\n score,\n metadata: properties,\n };\n\n if (includeVector) {\n const vectors = obj.vectors ?? {};\n result.vector = vectors.default ?? Object.values(vectors)[0];\n }\n\n return result;\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n }: QueryVectorParams<WeaviateVectorFilter>): Promise<QueryResult[]> {\n try {\n validateTopK('WEAVIATE', topK);\n\n const meta = await this.requireMeta(indexName, 'QUERY');\n if (queryVector && meta?.dimension && queryVector.length !== meta.dimension) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'QUERY', 'DIMENSION_MISMATCH'),\n text: `Query vector dimension ${queryVector.length} does not match index dimension ${meta.dimension}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, expected: meta.dimension, actual: queryVector.length },\n });\n }\n\n const collection = await this.getCollection(indexName);\n const filters = this.transformFilter(collection, filter);\n const returnMetadata = ['distance'] as const;\n\n if (queryVector) {\n const response = await collection.query.nearVector(queryVector, {\n limit: topK,\n includeVector,\n returnMetadata: returnMetadata as any,\n ...(filters ? { filters } : {}),\n });\n return response.objects.map(obj => this.toQueryResult(obj, includeVector));\n }\n\n const response = await collection.query.fetchObjects({\n limit: topK,\n includeVector,\n ...(filters ? { filters } : {}),\n });\n return response.objects.map(obj => this.toQueryResult(obj, includeVector));\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'QUERY', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const client = await this.getClient();\n const collections = await client.collections.listAll();\n return collections.map(config => {\n const meta = this.parseMeta(config.description);\n return meta?.name ?? config.name;\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'LIST_INDEXES', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const client = await this.getClient();\n const collectionName = this.toCollectionName(indexName);\n if (!(await client.collections.exists(collectionName))) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'DESCRIBE_INDEX', 'INDEX_NOT_FOUND'),\n text: `Index ${indexName} does not exist`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n const collection = client.collections.get(collectionName);\n const config = await collection.config.get();\n const meta = this.parseMeta(config.description);\n\n const count = await collection.length();\n\n let dimension = meta?.dimension ?? 0;\n if (!dimension) {\n // Fall back to sampling a stored vector when dimension is unknown.\n const sample = await collection.query.fetchObjects({ limit: 1, includeVector: true });\n const vectors = sample.objects[0]?.vectors ?? {};\n const vec = (vectors as any).default ?? Object.values(vectors)[0];\n if (Array.isArray(vec)) dimension = vec.length;\n }\n\n let metric = meta?.metric;\n if (!metric) {\n const vectorConfig = (config.vectorizers as any)?.default ?? Object.values(config.vectorizers ?? {})[0];\n const distance = vectorConfig?.indexConfig?.distance;\n metric = distance ? REVERSE_DISTANCE_MAPPING[distance] : undefined;\n }\n\n return { dimension, count, metric };\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', '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 const client = await this.getClient();\n await client.collections.delete(this.toCollectionName(indexName));\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'DELETE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async updateVector({ indexName, id, filter, update }: UpdateVectorParams<WeaviateVectorFilter>): Promise<void> {\n try {\n if (id !== undefined && filter !== undefined) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n text: 'id and filter are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!update || (!update.vector && !update.metadata)) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n text: 'Update data is required: no updates provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate the id/filter target BEFORE touching the collection, otherwise a\n // rejected update (missing target or empty filter) would still mutate the\n // collection schema via ensureProperties below.\n if (id === undefined && filter === undefined) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\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 (id === undefined && (typeof filter !== 'object' || filter === null || Object.keys(filter).length === 0)) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n text: 'A non-empty filter is required: empty filter not allowed',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n const collection = await this.getCollection(indexName);\n\n // Mirror upsert's schema handling: create any missing properties with\n // `field` tokenization and encode reserved keys, otherwise updated metadata\n // would be auto-schemad with `word` tokenization (breaking exact-match\n // filters) or clash with Weaviate's reserved property names.\n if (update.metadata) {\n await this.ensureProperties(collection, this.toCollectionName(indexName), [update.metadata]);\n }\n const encodedProperties = update.metadata ? encodeMetaProperties(update.metadata) : undefined;\n\n const applyUpdate = async (uuid: string) => {\n await collection.data.update({\n id: uuid,\n ...(encodedProperties ? { properties: encodedProperties } : {}),\n ...(update.vector ? { vectors: update.vector } : {}),\n });\n };\n\n if (id !== undefined) {\n await applyUpdate(generateUuid5(id));\n return;\n }\n\n const filters = this.transformFilter(collection, filter!);\n // Page through the full match set so large filters don't silently update\n // only the first page and report success. Collect all uuids first, then\n // apply, so mutations can't shift the pagination window mid-iteration.\n const PAGE_SIZE = 1000;\n // Weaviate rejects fetchObjects once offset+limit exceeds its\n // QUERY_MAXIMUM_RESULTS cap (default 10000). Fail loudly with a clear\n // USER error before that happens rather than surfacing a raw driver error.\n const MAX_FILTERED_UPDATE = 10000;\n const uuids: string[] = [];\n for (let offset = 0; ; offset += PAGE_SIZE) {\n if (offset >= MAX_FILTERED_UPDATE) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: `Filtered updateVector matched more than ${MAX_FILTERED_UPDATE} vectors, which exceeds Weaviate's query result cap. Narrow the filter or update by id.`,\n details: { indexName, limit: MAX_FILTERED_UPDATE },\n });\n }\n const page = await collection.query.fetchObjects({\n limit: PAGE_SIZE,\n offset,\n ...(filters ? { filters } : {}),\n });\n for (const obj of page.objects) uuids.push(obj.uuid);\n if (page.objects.length < PAGE_SIZE) break;\n }\n for (const uuid of uuids) {\n await applyUpdate(uuid);\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, ...(id ? { id } : {}) },\n },\n error,\n );\n }\n }\n\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n const collection = await this.getCollection(indexName);\n await collection.data.deleteById(generateUuid5(id));\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'DELETE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<WeaviateVectorFilter>): Promise<void> {\n if (ids && filter) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', '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('WEAVIATE', '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 if (ids && ids.length === 0) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', '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 if (filter && typeof filter === 'object' && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', '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 collection = await this.getCollection(indexName);\n if (ids) {\n for (const id of ids) {\n await collection.data.deleteById(generateUuid5(id));\n }\n } else if (filter) {\n const filters = this.transformFilter(collection, filter);\n if (filters) {\n await collection.data.deleteMany(filters);\n }\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', '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 Weaviate Vector.\n */\nexport const WEAVIATE_PROMPT = `When querying Weaviate, 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 arrays containing all values\n Example: { \"tags\": { \"$all\": [\"sale\", \"new\"] } }\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- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists (is not null)\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and, $or, and $not logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\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, $not):\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\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": { \"$eq\": true } }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}`;\n"],"mappings":";;;;;;;;;;;;;AAOA,MAAa,qBAAqB;AAClC,MAAa,kBAAkB;AAI/B,MAAa,qCAAqB,IAAI,IAAI;CAAC;CAAM;CAAU;CAAe;AAAkB,CAAC;AAE7F,SAAgB,cAAc,KAAqB;CAKjD,OAAO,mBAAmB,IAAI,GAAG,KAAK,IAAI,WAAA,aAA0B,IAAI,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MAAM,IAAI,YAAY;GACpB,IAAI,oBAAoB,YAAY,kBAAkB,WAAW;GACjE,MAAM;GACN,QAAQ,YAAY;GACpB,UAAU,cAAc;GACxB,SAAS,EAAE,UAAU;EACvB,CAAC;EAGH,IAAI,UAAU,OAAO,WAAW,YAAY,OAAO,KAAK,MAAM,CAAC,CAAC,WAAW,GACzE,MAAM,IAAI,YAAY;GACpB,IAAI,oBAAoB,YAAY,kBAAkB,cAAc;GACpE,MAAM;GACN,QAAQ,YAAY;GACpB,UAAU,cAAc;GACxB,SAAS,EAAE,UAAU;EACvB,CAAC;EAGH,IAAI;GACF,MAAM,aAAa,MAAM,KAAK,cAAc,SAAS;GACrD,IAAI,KACF,KAAK,MAAM,MAAM,KACf,MAAM,WAAW,KAAK,WAAW,cAAc,EAAE,CAAC;QAE/C,IAAI,QAAQ;IACjB,MAAM,UAAU,KAAK,gBAAgB,YAAY,MAAM;IACvD,IAAI,SACF,MAAM,WAAW,KAAK,WAAW,OAAO;GAE5C;EACF,SAAS,OAAO;GACd,IAAI,iBAAiB,aAAa,MAAM;GACxC,MAAM,IAAI,YACR;IACE,IAAI,oBAAoB,YAAY,kBAAkB,QAAQ;IAC9D,QAAQ,YAAY;IACpB,UAAU,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;;;;;;;AC/tBA,MAAa,kBAAkB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/vector/encoding.ts","../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"sourcesContent":["/**\n * Weaviate reserves certain property names (e.g. `id`, `vector`). Metadata keys\n * that collide are stored under a stable prefix and restored on read. This\n * module is the single source of truth shared by the adapter and the filter\n * translator — they must encode keys identically or filters will silently miss.\n */\n/** Internal property used to round-trip the caller's original id. */\nexport const MASTRA_ID_PROPERTY = 'mastraId';\nexport const META_KEY_PREFIX = 'mastraMeta_';\n// `mastraId` is reserved too: the adapter writes the caller's original id under\n// this property, so a user metadata key of the same name must be encoded to\n// avoid clobbering (or being clobbered by) the internal value.\nexport const RESERVED_META_KEYS = new Set(['id', 'vector', '_additional', MASTRA_ID_PROPERTY]);\n\nexport function encodeMetaKey(key: string): string {\n // Encode reserved names, and also escape any genuine user key that already\n // starts with the prefix. Escaping makes the transform fully reversible:\n // without it, a user key like `mastraMeta_id` would be indistinguishable from\n // an encoded `id` on read and would be returned under the wrong name.\n return RESERVED_META_KEYS.has(key) || key.startsWith(META_KEY_PREFIX) ? `${META_KEY_PREFIX}${key}` : key;\n}\n\nexport function decodeMetaKey(key: string): string {\n return key.startsWith(META_KEY_PREFIX) ? key.slice(META_KEY_PREFIX.length) : key;\n}\n\nexport function encodeMetaProperties(metadata?: Record<string, any>): Record<string, any> {\n if (!metadata) return {};\n const out: Record<string, any> = {};\n for (const [key, value] of Object.entries(metadata)) {\n out[encodeMetaKey(key)] = value;\n }\n return out;\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\nimport { Filters } from 'weaviate-client';\nimport type { FilterValue } from 'weaviate-client';\n\nimport { encodeMetaKey } from './encoding';\n\n/**\n * The subset of Weaviate's collection filter API used by the translator.\n * Provided at translate time via `collection.filter`.\n */\nexport interface WeaviateFilterApi {\n byProperty: (name: string, length?: boolean) => WeaviateFilterProperty;\n}\n\ninterface WeaviateFilterProperty {\n isNull: (value: boolean) => FilterValue;\n equal: (value: any) => FilterValue;\n notEqual: (value: any) => FilterValue;\n greaterThan: (value: any) => FilterValue;\n greaterOrEqual: (value: any) => FilterValue;\n lessThan: (value: any) => FilterValue;\n lessOrEqual: (value: any) => FilterValue;\n containsAny: (value: any[]) => FilterValue;\n containsAll: (value: any[]) => FilterValue;\n containsNone: (value: any[]) => FilterValue;\n}\n\ntype WeaviateOperatorValueMap = Omit<\n OperatorValueMap,\n '$options' | '$elemMatch' | '$regex' | '$nor' | '$size' | '$contains'\n>;\n\ntype WeaviateLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor'>;\n\ntype WeaviateBlacklistedRootOperators = BlacklistedRootOperators;\n\nexport type WeaviateVectorFilter = VectorFilter<\n keyof WeaviateOperatorValueMap,\n WeaviateOperatorValueMap,\n WeaviateLogicalOperatorValueMap,\n WeaviateBlacklistedRootOperators\n>;\n\n/**\n * Translates MongoDB-style filters into Weaviate `FilterValue` objects.\n *\n * Weaviate filters are built from the collection's `filter` API (which produces\n * protobuf-backed targets), so `translate` requires the collection filter API to\n * be supplied alongside the filter.\n */\nexport class WeaviateFilterTranslator extends BaseFilterTranslator<WeaviateVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n logical: ['$and', '$or', '$not'],\n basic: ['$eq', '$ne'],\n numeric: ['$gt', '$gte', '$lt', '$lte'],\n array: ['$in', '$nin', '$all'],\n element: ['$exists'],\n regex: [],\n custom: [],\n };\n }\n\n protected override isOperator(key: string): key is any {\n // $not can be used both logically and at field level.\n return super.isOperator(key) || key === '$not';\n }\n\n translate(filter?: WeaviateVectorFilter, api?: WeaviateFilterApi): FilterValue | undefined {\n if (this.isEmpty(filter)) return undefined;\n if (!api) {\n throw new Error('WeaviateFilterTranslator.translate requires a collection filter API');\n }\n this.validateFilter(filter);\n return this.translateNode(filter as Record<string, any>, api);\n }\n\n /**\n * An empty set matches nothing. Weaviate can't send `containsAny([])` against a text[]\n * property (the empty array is serialized as numbers), so express it as a contradiction\n * on the property's null state, which the collection indexes (`indexNullState: true`).\n */\n private containsAny(prop: WeaviateFilterProperty, values: any[]): FilterValue {\n const normalized = this.normalizeArrayValues(values);\n if (normalized.length === 0) return Filters.and(prop.isNull(true), prop.isNull(false));\n return prop.containsAny(normalized);\n }\n\n private combine(parts: Array<FilterValue | undefined>): FilterValue | undefined {\n const filtered = parts.filter((p): p is FilterValue => p !== undefined);\n if (filtered.length === 0) return undefined;\n if (filtered.length === 1) return filtered[0];\n return Filters.and(...filtered);\n }\n\n private translateNode(node: Record<string, any>, api: WeaviateFilterApi): FilterValue | undefined {\n const parts = Object.entries(node).map(([key, value]) => {\n if (key === '$and') {\n return this.combineLogical('and', value as any[], api);\n }\n if (key === '$or') {\n return this.combineLogical('or', value as any[], api);\n }\n if (key === '$not') {\n // Push the negation into the operators (De Morgan) rather than relying on\n // Weaviate's Not operator, which is not supported by all server versions.\n return this.negateNode(value as Record<string, any>, api);\n }\n return this.translateField(key, value, api);\n });\n return this.combine(parts);\n }\n\n /** Combines parts with OR, dropping undefined entries. */\n private combineOr(parts: Array<FilterValue | undefined>): FilterValue | undefined {\n const filtered = parts.filter((p): p is FilterValue => p !== undefined);\n if (filtered.length === 0) return undefined;\n if (filtered.length === 1) return filtered[0];\n return Filters.or(...filtered);\n }\n\n /**\n * Returns the negation of a node. A node's entries are AND-combined, so the\n * negation is the OR of each entry's negation (De Morgan).\n */\n private negateNode(node: Record<string, any>, api: WeaviateFilterApi): FilterValue | undefined {\n const parts = Object.entries(node).map(([key, value]) => {\n if (key === '$and') {\n // NOT(a AND b) = (NOT a) OR (NOT b)\n return this.combineOr((value as any[]).map(v => this.negateNode(v as Record<string, any>, api)));\n }\n if (key === '$or') {\n // NOT(a OR b) = (NOT a) AND (NOT b)\n return this.combine((value as any[]).map(v => this.negateNode(v as Record<string, any>, api)));\n }\n if (key === '$not') {\n // Double negation.\n return this.translateNode(value as Record<string, any>, api);\n }\n return this.negateField(key, value, api);\n });\n return this.combineOr(parts);\n }\n\n /** Returns the negation of a single field condition. */\n private negateField(field: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n\n if (value === null) {\n return prop.isNull(false);\n }\n if (this.isPrimitive(value)) {\n return prop.notEqual(this.normalizeComparisonValue(value));\n }\n if (Array.isArray(value)) {\n // NOT(field in [..]) = field not equal to every value.\n return this.combine(this.normalizeArrayValues(value).map(v => prop.notEqual(v)));\n }\n\n // Operator object: entries are AND-combined, so negation is OR of negations.\n const parts = Object.entries(value as Record<string, any>).map(([op, opValue]) =>\n this.negateSingleOp(field, op, opValue, api),\n );\n return this.combineOr(parts);\n }\n\n private negateSingleOp(field: string, op: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n switch (op) {\n case '$eq':\n return value === null ? prop.isNull(false) : prop.notEqual(this.normalizeComparisonValue(value));\n case '$ne':\n return value === null ? prop.isNull(true) : prop.equal(this.normalizeComparisonValue(value));\n case '$gt':\n return prop.lessOrEqual(this.normalizeComparisonValue(value));\n case '$gte':\n return prop.lessThan(this.normalizeComparisonValue(value));\n case '$lt':\n return prop.greaterOrEqual(this.normalizeComparisonValue(value));\n case '$lte':\n return prop.greaterThan(this.normalizeComparisonValue(value));\n case '$in':\n // NOT(in [..]) = not equal to every value.\n return this.combine(this.normalizeArrayValues(value as any[]).map(v => prop.notEqual(v)));\n case '$nin':\n // NOT(nin [..]) = in [..].\n return this.containsAny(prop, value as any[]);\n case '$exists':\n return prop.isNull(!!value);\n case '$not':\n return this.translateField(field, value, api);\n default:\n throw unsupportedOperatorError(op, field);\n }\n }\n\n private combineLogical(op: 'and' | 'or', values: any[], api: WeaviateFilterApi): FilterValue | undefined {\n const translated = values\n .map(v => this.translateNode(v as Record<string, any>, api))\n .filter((p): p is FilterValue => p !== undefined);\n if (translated.length === 0) return undefined;\n if (translated.length === 1) return translated[0];\n return op === 'and' ? Filters.and(...translated) : Filters.or(...translated);\n }\n\n private translateField(field: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n\n if (value === null) {\n return prop.isNull(true);\n }\n\n if (this.isPrimitive(value)) {\n return prop.equal(this.normalizeComparisonValue(value));\n }\n\n if (Array.isArray(value)) {\n return this.containsAny(prop, value);\n }\n\n // Operator object: combine each operator condition with AND.\n const parts = Object.entries(value as Record<string, any>).map(([op, opValue]) =>\n this.translateOperator(field, op, opValue, api),\n );\n return this.combine(parts);\n }\n\n private translateOperator(field: string, op: string, value: any, api: WeaviateFilterApi): FilterValue | undefined {\n const prop = api.byProperty(encodeMetaKey(field));\n switch (op) {\n case '$eq':\n return value === null ? prop.isNull(true) : prop.equal(this.normalizeComparisonValue(value));\n case '$ne':\n return value === null ? prop.isNull(false) : prop.notEqual(this.normalizeComparisonValue(value));\n case '$gt':\n return prop.greaterThan(this.normalizeComparisonValue(value));\n case '$gte':\n return prop.greaterOrEqual(this.normalizeComparisonValue(value));\n case '$lt':\n return prop.lessThan(this.normalizeComparisonValue(value));\n case '$lte':\n return prop.lessOrEqual(this.normalizeComparisonValue(value));\n case '$in':\n return this.containsAny(prop, value as any[]);\n case '$nin':\n // Weaviate's ContainsNone is not available on all server versions; express\n // \"not in\" as an AND of not-equals instead.\n return this.combine(this.normalizeArrayValues(value as any[]).map(v => prop.notEqual(v)));\n case '$all':\n return prop.containsAll(this.normalizeArrayValues(value as any[]));\n case '$exists':\n return prop.isNull(!value);\n case '$not':\n return this.negateField(field, value, api);\n default:\n throw unsupportedOperatorError(op, field);\n }\n }\n}\n\n/** Builds a user-facing error for an operator Weaviate cannot translate. */\nfunction unsupportedOperatorError(op: string, field: string): MastraError {\n return new MastraError({\n id: 'STORAGE_WEAVIATE_FILTER_UNSUPPORTED_OPERATOR',\n text: `Unsupported filter operator \"${op}\" on field \"${field}\"`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { operator: op, field },\n });\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector, validateUpsertInput, validateVectorValues, validateTopK } 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 DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport weaviate, { generateUuid5 } from 'weaviate-client';\nimport type { WeaviateClient, Collection } from 'weaviate-client';\n\nimport { encodeMetaKey, decodeMetaKey, encodeMetaProperties, MASTRA_ID_PROPERTY } from './encoding';\nimport { WeaviateFilterTranslator } from './filter';\nimport type { WeaviateVectorFilter } from './filter';\n\n/**\n * Weaviate distance metrics mapped from Mastra metric names.\n * @see https://weaviate.io/developers/weaviate/config-refs/distances\n */\nconst DISTANCE_MAPPING: Record<string, 'cosine' | 'l2-squared' | 'dot'> = {\n cosine: 'cosine',\n euclidean: 'l2-squared',\n dotproduct: 'dot',\n};\n\nconst REVERSE_DISTANCE_MAPPING: Record<string, 'cosine' | 'euclidean' | 'dotproduct'> = {\n cosine: 'cosine',\n 'l2-squared': 'euclidean',\n dot: 'dotproduct',\n};\n\n/** Reserved property used to round-trip the caller-supplied vector id. */\n\n/** Metadata stored on a collection's description to preserve Mastra semantics. */\ninterface CollectionMeta {\n name: string;\n dimension: number;\n metric: 'cosine' | 'euclidean' | 'dotproduct';\n}\n\n/**\n * Connection options for the Weaviate vector store.\n * These map directly to `weaviate.connectToCustom`.\n */\nexport interface WeaviateVectorParams {\n /** Unique identifier for this vector store instance. */\n id: string;\n /** The hostname of the HTTP server. Defaults to `localhost`. */\n httpHost?: string;\n /** The port of the HTTP server. Defaults to `8080`. */\n httpPort?: number;\n /** Whether to use a secure connection to the HTTP server. Defaults to `false`. */\n httpSecure?: boolean;\n /** The hostname of the gRPC server. Defaults to the HTTP host. */\n grpcHost?: string;\n /** The port of the gRPC server. Defaults to `50051`. */\n grpcPort?: number;\n /** Whether to use a secure connection to the gRPC server. Defaults to `false`. */\n grpcSecure?: boolean;\n /** API key for authenticating with Weaviate (e.g. Weaviate Cloud). */\n apiKey?: string;\n /** Additional headers to include in requests (e.g. vectorizer API keys). */\n headers?: Record<string, string>;\n}\n\n/**\n * A Mastra vector store backed by Weaviate.\n *\n * Vectors are stored in `vectorizer: none` collections (Mastra supplies the\n * embeddings). Because Weaviate requires UUID object ids and capitalised\n * collection names, this adapter maps arbitrary Mastra ids to deterministic\n * UUIDv5 values (preserving the original id in a reserved property) and\n * preserves the original index name in the collection description.\n */\nexport class WeaviateVector extends MastraVector<WeaviateVectorFilter> {\n private clientPromise: Promise<WeaviateClient> | null = null;\n private readonly connectOptions: WeaviateVectorParams;\n /** Cache of property names known to exist in a collection's schema. */\n private readonly knownProperties = new Map<string, Set<string>>();\n /** Serializes schema mutations per collection to avoid concurrent addProperty races. */\n private readonly schemaLocks = new Map<string, Promise<void>>();\n\n constructor(params: WeaviateVectorParams) {\n super({ id: params.id });\n this.connectOptions = params;\n }\n\n private getClient(): Promise<WeaviateClient> {\n if (!this.clientPromise) {\n const { httpHost, httpPort, httpSecure, grpcHost, grpcPort, grpcSecure, apiKey, headers } = this.connectOptions;\n this.clientPromise = weaviate.connectToCustom({\n httpHost: httpHost ?? 'localhost',\n httpPort: httpPort ?? 8080,\n httpSecure: httpSecure ?? false,\n grpcHost: grpcHost ?? httpHost ?? 'localhost',\n grpcPort: grpcPort ?? 50051,\n grpcSecure: grpcSecure ?? false,\n ...(apiKey ? { authCredentials: new weaviate.ApiKey(apiKey) } : {}),\n ...(headers ? { headers } : {}),\n });\n }\n return this.clientPromise;\n }\n\n /** Closes the underlying Weaviate connection. */\n async disconnect(): Promise<void> {\n if (this.clientPromise) {\n const client = await this.clientPromise;\n await client.close();\n this.clientPromise = null;\n }\n }\n\n /** Weaviate collection names must start with an uppercase letter. */\n private toCollectionName(indexName: string): string {\n return indexName.charAt(0).toUpperCase() + indexName.slice(1);\n }\n\n private async getCollection(indexName: string): Promise<Collection> {\n const client = await this.getClient();\n return client.collections.get(this.toCollectionName(indexName));\n }\n\n private parseMeta(description?: string): CollectionMeta | null {\n if (!description) return null;\n try {\n const parsed = JSON.parse(description);\n if (parsed && typeof parsed === 'object' && typeof parsed.name === 'string') {\n return parsed as CollectionMeta;\n }\n } catch {\n // Not a Mastra-managed description.\n }\n return null;\n }\n\n private inferDataType(value: unknown): 'text' | 'number' | 'boolean' | 'text[]' | 'number[]' | 'boolean[]' | null {\n if (typeof value === 'string') return 'text';\n if (typeof value === 'number') return 'number';\n if (typeof value === 'boolean') return 'boolean';\n if (Array.isArray(value)) {\n const first = value.find(v => v !== null && v !== undefined);\n if (typeof first === 'string') return 'text[]';\n if (typeof first === 'number') return 'number[]';\n if (typeof first === 'boolean') return 'boolean[]';\n // Arrays of objects (or empty arrays) are left to Weaviate's auto-schema.\n return null;\n }\n return null;\n }\n\n /**\n * Ensures every metadata key across the batch exists as a collection property.\n * Weaviate's auto-schema would create text properties with `word` tokenization\n * (breaking exact-match filtering), so properties are created explicitly with\n * `field` tokenization for text values.\n */\n private async ensureProperties(\n collection: Collection,\n collectionName: string,\n metadata: Record<string, any>[] | undefined,\n ): Promise<void> {\n if (!metadata?.length) return;\n // Chain schema mutations for the same collection so concurrent upserts do not\n // race on addProperty (which would surface as partial-success failures).\n const prev = this.schemaLocks.get(collectionName) ?? Promise.resolve();\n const next = prev\n .catch(() => undefined)\n .then(() => this.ensurePropertiesLocked(collection, collectionName, metadata));\n this.schemaLocks.set(collectionName, next);\n await next;\n }\n\n private async ensurePropertiesLocked(\n collection: Collection,\n collectionName: string,\n metadata: Record<string, any>[],\n ): Promise<void> {\n let known = this.knownProperties.get(collectionName);\n if (!known) {\n const config = await collection.config.get();\n known = new Set(config.properties.map(p => p.name));\n this.knownProperties.set(collectionName, known);\n }\n\n const seen = new Map<string, 'text' | 'number' | 'boolean' | 'text[]' | 'number[]' | 'boolean[]'>();\n for (const row of metadata) {\n if (!row) continue;\n for (const [rawKey, value] of Object.entries(row)) {\n const key = encodeMetaKey(rawKey);\n if (known.has(key) || seen.has(key) || value === null || value === undefined) continue;\n const dataType = this.inferDataType(value);\n if (dataType) seen.set(key, dataType);\n }\n }\n\n for (const [name, dataType] of seen) {\n try {\n await collection.config.addProperty({\n name,\n dataType,\n ...(dataType === 'text' || dataType === 'text[]' ? { tokenization: 'field' } : {}),\n } as any);\n } catch (error) {\n // Tolerate a property that already exists (e.g. added by a racing caller).\n if (!/already/i.test((error as Error)?.message ?? '')) throw error;\n }\n known.add(name);\n }\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n try {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'INVALID_ARGS'),\n text: 'Dimension must be a positive integer',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, dimension },\n });\n }\n\n const distance = DISTANCE_MAPPING[metric];\n if (!distance) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'INVALID_ARGS'),\n text: `Invalid metric: ${metric}. Must be one of: cosine, euclidean, dotproduct`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, metric },\n });\n }\n\n const client = await this.getClient();\n const collectionName = this.toCollectionName(indexName);\n\n if (await client.collections.exists(collectionName)) {\n // Weaviate capitalises the first letter of collection names, so distinct\n // Mastra index names (e.g. `documents` and `Documents`) map to one\n // collection. Reject the collision instead of silently sharing storage.\n const existingConfig = await client.collections.get(collectionName).config.get();\n const existingMeta = this.parseMeta(existingConfig.description);\n if (existingMeta && existingMeta.name !== indexName) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'NAME_COLLISION'),\n text: `Index name \"${indexName}\" collides with existing index \"${existingMeta.name}\" (Weaviate collection \"${collectionName}\"). Weaviate capitalises the first letter of collection names, so these names cannot coexist.`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, existingName: existingMeta.name, collectionName },\n });\n }\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n\n const meta: CollectionMeta = { name: indexName, dimension, metric };\n await client.collections.create({\n name: collectionName,\n description: JSON.stringify(meta),\n // Store the original Mastra id as an exact-match (\"field\") text property so\n // arbitrary (e.g. numeric) ids are not misinterpreted by Weaviate's auto-schema.\n properties: [{ name: MASTRA_ID_PROPERTY, dataType: 'text', tokenization: 'field' }],\n // Index null state so `$exists` / null-equality filters are supported.\n invertedIndex: weaviate.configure.invertedIndex({ indexNullState: true }),\n vectorizers: weaviate.configure.vectors.selfProvided({\n vectorIndexConfig: weaviate.configure.vectorIndex.hnsw({ distanceMetric: distance }),\n }),\n });\n this.knownProperties.set(collectionName, new Set([MASTRA_ID_PROPERTY]));\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'CREATE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /** Fetches a collection's stored metadata, throwing if the index does not exist. */\n private async requireMeta(indexName: string, operation: string): Promise<CollectionMeta | null> {\n const client = await this.getClient();\n const collectionName = this.toCollectionName(indexName);\n if (!(await client.collections.exists(collectionName))) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', operation, 'INDEX_NOT_FOUND'),\n text: `Index ${indexName} does not exist`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n const config = await client.collections.get(collectionName).config.get();\n return this.parseMeta(config.description);\n }\n\n async upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]> {\n try {\n validateUpsertInput('WEAVIATE', vectors, metadata, ids);\n validateVectorValues('WEAVIATE', vectors);\n\n const meta = await this.requireMeta(indexName, 'UPSERT');\n if (meta?.dimension) {\n const mismatch = vectors.find(v => v.length !== meta.dimension);\n if (mismatch) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPSERT', 'DIMENSION_MISMATCH'),\n text: `Vector dimension ${mismatch.length} does not match index dimension ${meta.dimension}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, expected: meta.dimension, actual: mismatch.length },\n });\n }\n }\n\n const collection = await this.getCollection(indexName);\n await this.ensureProperties(collection, this.toCollectionName(indexName), metadata);\n const originalIds = ids ?? vectors.map(() => crypto.randomUUID());\n\n const objects = vectors.map((vector, i) => {\n const originalId = originalIds[i]!;\n return {\n id: generateUuid5(originalId),\n vectors: vector,\n properties: {\n ...encodeMetaProperties(metadata?.[i]),\n [MASTRA_ID_PROPERTY]: originalId,\n },\n };\n });\n\n const result = await collection.data.insertMany(objects);\n if (result.hasErrors) {\n const firstError = Object.values(result.errors)[0];\n throw new Error(firstError?.message ?? 'Weaviate insertMany reported errors');\n }\n\n return originalIds;\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'UPSERT', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n private transformFilter(collection: Collection, filter?: WeaviateVectorFilter) {\n const translator = new WeaviateFilterTranslator();\n return translator.translate(filter, collection.filter as any);\n }\n\n private toQueryResult(obj: any, includeVector?: boolean): QueryResult {\n const raw = obj.properties ?? {};\n const originalId = raw[MASTRA_ID_PROPERTY];\n const properties: Record<string, any> = {};\n for (const [key, value] of Object.entries(raw)) {\n if (key === MASTRA_ID_PROPERTY || value === undefined) continue;\n properties[decodeMetaKey(key)] = value;\n }\n\n const distance = obj.metadata?.distance;\n const score = typeof distance === 'number' ? 1 - distance : (obj.metadata?.certainty ?? 0);\n\n const result: QueryResult = {\n id: typeof originalId === 'string' ? originalId : obj.uuid,\n score,\n metadata: properties,\n };\n\n if (includeVector) {\n const vectors = obj.vectors ?? {};\n result.vector = vectors.default ?? Object.values(vectors)[0];\n }\n\n return result;\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n }: QueryVectorParams<WeaviateVectorFilter>): Promise<QueryResult[]> {\n try {\n validateTopK('WEAVIATE', topK);\n\n const meta = await this.requireMeta(indexName, 'QUERY');\n if (queryVector && meta?.dimension && queryVector.length !== meta.dimension) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'QUERY', 'DIMENSION_MISMATCH'),\n text: `Query vector dimension ${queryVector.length} does not match index dimension ${meta.dimension}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, expected: meta.dimension, actual: queryVector.length },\n });\n }\n\n const collection = await this.getCollection(indexName);\n const filters = this.transformFilter(collection, filter);\n const returnMetadata = ['distance'] as const;\n\n if (queryVector) {\n const response = await collection.query.nearVector(queryVector, {\n limit: topK,\n includeVector,\n returnMetadata: returnMetadata as any,\n ...(filters ? { filters } : {}),\n });\n return response.objects.map(obj => this.toQueryResult(obj, includeVector));\n }\n\n const response = await collection.query.fetchObjects({\n limit: topK,\n includeVector,\n ...(filters ? { filters } : {}),\n });\n return response.objects.map(obj => this.toQueryResult(obj, includeVector));\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'QUERY', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const client = await this.getClient();\n const collections = await client.collections.listAll();\n return collections.map(config => {\n const meta = this.parseMeta(config.description);\n return meta?.name ?? config.name;\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'LIST_INDEXES', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const client = await this.getClient();\n const collectionName = this.toCollectionName(indexName);\n if (!(await client.collections.exists(collectionName))) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'DESCRIBE_INDEX', 'INDEX_NOT_FOUND'),\n text: `Index ${indexName} does not exist`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n const collection = client.collections.get(collectionName);\n const config = await collection.config.get();\n const meta = this.parseMeta(config.description);\n\n const count = await collection.length();\n\n let dimension = meta?.dimension ?? 0;\n if (!dimension) {\n // Fall back to sampling a stored vector when dimension is unknown.\n const sample = await collection.query.fetchObjects({ limit: 1, includeVector: true });\n const vectors = sample.objects[0]?.vectors ?? {};\n const vec = (vectors as any).default ?? Object.values(vectors)[0];\n if (Array.isArray(vec)) dimension = vec.length;\n }\n\n let metric = meta?.metric;\n if (!metric) {\n const vectorConfig = (config.vectorizers as any)?.default ?? Object.values(config.vectorizers ?? {})[0];\n const distance = vectorConfig?.indexConfig?.distance;\n metric = distance ? REVERSE_DISTANCE_MAPPING[distance] : undefined;\n }\n\n return { dimension, count, metric };\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', '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 const client = await this.getClient();\n await client.collections.delete(this.toCollectionName(indexName));\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'DELETE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async updateVector({ indexName, id, filter, update }: UpdateVectorParams<WeaviateVectorFilter>): Promise<void> {\n try {\n if (id !== undefined && filter !== undefined) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n text: 'id and filter are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!update || (!update.vector && !update.metadata)) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n text: 'Update data is required: no updates provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate the id/filter target BEFORE touching the collection, otherwise a\n // rejected update (missing target or empty filter) would still mutate the\n // collection schema via ensureProperties below.\n if (id === undefined && filter === undefined) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\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 (id === undefined && (typeof filter !== 'object' || filter === null || Object.keys(filter).length === 0)) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n text: 'A non-empty filter is required: empty filter not allowed',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n const collection = await this.getCollection(indexName);\n\n // Mirror upsert's schema handling: create any missing properties with\n // `field` tokenization and encode reserved keys, otherwise updated metadata\n // would be auto-schemad with `word` tokenization (breaking exact-match\n // filters) or clash with Weaviate's reserved property names.\n if (update.metadata) {\n await this.ensureProperties(collection, this.toCollectionName(indexName), [update.metadata]);\n }\n const encodedProperties = update.metadata ? encodeMetaProperties(update.metadata) : undefined;\n\n const applyUpdate = async (uuid: string) => {\n await collection.data.update({\n id: uuid,\n ...(encodedProperties ? { properties: encodedProperties } : {}),\n ...(update.vector ? { vectors: update.vector } : {}),\n });\n };\n\n if (id !== undefined) {\n await applyUpdate(generateUuid5(id));\n return;\n }\n\n const filters = this.transformFilter(collection, filter!);\n // Page through the full match set so large filters don't silently update\n // only the first page and report success. Collect all uuids first, then\n // apply, so mutations can't shift the pagination window mid-iteration.\n const PAGE_SIZE = 1000;\n // Weaviate rejects fetchObjects once offset+limit exceeds its\n // QUERY_MAXIMUM_RESULTS cap (default 10000). Fail loudly with a clear\n // USER error before that happens rather than surfacing a raw driver error.\n const MAX_FILTERED_UPDATE = 10000;\n const uuids: string[] = [];\n for (let offset = 0; ; offset += PAGE_SIZE) {\n if (offset >= MAX_FILTERED_UPDATE) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'INVALID_ARGS'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n text: `Filtered updateVector matched more than ${MAX_FILTERED_UPDATE} vectors, which exceeds Weaviate's query result cap. Narrow the filter or update by id.`,\n details: { indexName, limit: MAX_FILTERED_UPDATE },\n });\n }\n const page = await collection.query.fetchObjects({\n limit: PAGE_SIZE,\n offset,\n ...(filters ? { filters } : {}),\n });\n for (const obj of page.objects) uuids.push(obj.uuid);\n if (page.objects.length < PAGE_SIZE) break;\n }\n for (const uuid of uuids) {\n await applyUpdate(uuid);\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'UPDATE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, ...(id ? { id } : {}) },\n },\n error,\n );\n }\n }\n\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n const collection = await this.getCollection(indexName);\n await collection.data.deleteById(generateUuid5(id));\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', 'DELETE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<WeaviateVectorFilter>): Promise<void> {\n if (ids && filter) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', '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('WEAVIATE', '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 if (ids && ids.length === 0) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', '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 if (filter && typeof filter === 'object' && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('WEAVIATE', '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 collection = await this.getCollection(indexName);\n if (ids) {\n for (const id of ids) {\n await collection.data.deleteById(generateUuid5(id));\n }\n } else if (filter) {\n const filters = this.transformFilter(collection, filter);\n if (filters) {\n await collection.data.deleteMany(filters);\n }\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('WEAVIATE', '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 Weaviate Vector.\n */\nexport const WEAVIATE_PROMPT = `When querying Weaviate, 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 arrays containing all values\n Example: { \"tags\": { \"$all\": [\"sale\", \"new\"] } }\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- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists (is not null)\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and, $or, and $not logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\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, $not):\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\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": { \"$eq\": true } }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}`;\n"],"mappings":";;;;;;;;;;;;;AAOA,MAAa,qBAAqB;AAClC,MAAa,kBAAkB;AAI/B,MAAa,qCAAqB,IAAI,IAAI;CAAC;CAAM;CAAU;CAAe;AAAkB,CAAC;AAE7F,SAAgB,cAAc,KAAqB;CAKjD,OAAO,mBAAmB,IAAI,GAAG,KAAK,IAAI,WAAA,aAA0B,IAAI,GAAG,kBAAkB,QAAQ;AACvG;AAEA,SAAgB,cAAc,KAAqB;CACjD,OAAO,IAAI,WAAA,aAA0B,IAAI,IAAI,MAAM,EAAsB,IAAI;AAC/E;AAEA,SAAgB,qBAAqB,UAAqD;CACxF,IAAI,CAAC,UAAU,OAAO,CAAC;CACvB,MAAM,MAA2B,CAAC;CAClC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,QAAQ,GAChD,IAAI,cAAc,GAAG,KAAK;CAE5B,OAAO;AACT;;;;;;;;;ACyBA,IAAa,2BAAb,cAA8C,qBAA2C;CACvF,wBAA4D;EAC1D,OAAO;GACL,SAAS;IAAC;IAAQ;IAAO;GAAM;GAC/B,OAAO,CAAC,OAAO,KAAK;GACpB,SAAS;IAAC;IAAO;IAAQ;IAAO;GAAM;GACtC,OAAO;IAAC;IAAO;IAAQ;GAAM;GAC7B,SAA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AAY,MAAM;IACvD,IAAI,SACF,MAAM,WAAW,KAAK,WAAW,OAAO;GAE5C;EACF,SAAS,OAAO;GACd,IAAI,iBAAiB,aAAa,MAAM;GACxC,MAAM,IAAI,YACR;IACE,IAAI,oBAAoB,YAAY,kBAAkB,QAAQ;IAC9D,QAAQ,YAAY;IACpB,UAAU,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;;;;;;AC/tBA,MAAa,kBAAkB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/weaviate",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4-alpha.0",
|
|
4
4
|
"description": "Weaviate vector store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,21 +20,20 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"weaviate-client": "^3.
|
|
23
|
+
"weaviate-client": "^3.15.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/node": "22.
|
|
27
|
-
"@vitest/coverage-v8": "4.1.
|
|
28
|
-
"@vitest/ui": "4.1.
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"tsx": "^4.23.1",
|
|
26
|
+
"@types/node": "22.19.15",
|
|
27
|
+
"@vitest/coverage-v8": "4.1.12",
|
|
28
|
+
"@vitest/ui": "4.1.12",
|
|
29
|
+
"tsdown": "0.23.1",
|
|
30
|
+
"tsx": "^4.23.15",
|
|
32
31
|
"typescript": "^7.0.2",
|
|
33
|
-
"vitest": "4.1.
|
|
34
|
-
"@internal/
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"@internal/
|
|
32
|
+
"vitest": "4.1.12",
|
|
33
|
+
"@internal/lint": "0.0.145",
|
|
34
|
+
"@internal/storage-test-utils": "0.0.141",
|
|
35
|
+
"@mastra/core": "1.80.0-alpha.4",
|
|
36
|
+
"@internal/types-builder": "0.0.120"
|
|
38
37
|
},
|
|
39
38
|
"peerDependencies": {
|
|
40
39
|
"@mastra/core": ">=1.68.0-0 <2.0.0-0"
|
|
@@ -60,7 +59,7 @@
|
|
|
60
59
|
"pretest": "docker compose up -d",
|
|
61
60
|
"posttest": "docker compose down -v",
|
|
62
61
|
"test": "vitest run",
|
|
63
|
-
"lint": "oxlint
|
|
64
|
-
"lint:fix": "oxlint --
|
|
62
|
+
"lint": "oxlint --type-aware .",
|
|
63
|
+
"lint:fix": "oxlint --type-aware --fix ."
|
|
65
64
|
}
|
|
66
65
|
}
|