/** * Embedding Module -- Tier 2.5 semantic similarity detection. * * Compares incoming text against pre-computed attack embeddings using * cosine similarity. Catches paraphrases, multilingual attacks, and * semantic variants that regex cannot detect. * * Uses all-MiniLM-L6-v2 (384 dimensions, ~22MB, runs locally in JS/WASM). * No API calls. Optional dependency: @xenova/transformers. * * @module agent-threat-rules/modules/embedding */ import type { AgentEvent } from '../types.js'; import type { ATRModule, ModuleCondition, ModuleResult } from './index.js'; import { type VectorEntry, type SearchResult } from '../embedding/vector-store.js'; import type { EmbeddingModel } from '../embedding/model-loader.js'; export interface EmbeddingModuleConfig { /** Pre-loaded attack vector entries */ readonly attackVectors?: readonly VectorEntry[]; /** Path to pre-computed attack-embeddings.json file */ readonly attackVectorsPath?: string; /** Raw JSON data (alternative to file path) */ readonly attackVectorsData?: readonly { id: string; vector: number[]; label: string; category: string; severity: string; }[]; /** Cosine similarity threshold (default: 0.65) */ readonly similarityThreshold?: number; /** Top-K results to consider (default: 3) */ readonly topK?: number; /** Custom embedding model (default: TransformersJSModel) */ readonly model?: EmbeddingModel; } export declare class EmbeddingModule implements ATRModule { private readonly config; readonly name = "embedding"; readonly description = "Vector similarity detection against known attack embeddings"; readonly version = "0.1.0"; readonly functions: { name: string; description: string; args: ({ name: string; type: "string"; required: boolean; description: string; } | { name: string; type: "number"; required: boolean; description: string; })[]; }[]; private store; private model; private readonly threshold; private readonly topK; private initialized; constructor(config?: EmbeddingModuleConfig); initialize(): Promise; evaluate(event: AgentEvent, condition: ModuleCondition): Promise; /** Get search results with full details (for debugging/testing) */ searchDetailed(text: string, threshold?: number): Promise; destroy(): Promise; /** Check if module is operational */ isAvailable(): boolean; } //# sourceMappingURL=embedding.d.ts.map