/** * Semantic Validator * * Provides LLM-based content validation using the "LLM-as-judge" pattern. * This complements pattern-based detection by using semantic understanding * to identify threats that regex patterns might miss. */ import type { ModelClient } from '@artemiskit/core'; import type { ContentValidationConfig, GuardrailResult, SemanticValidationResult } from './types'; /** * SemanticValidator - LLM-based content validation */ export declare class SemanticValidator { private llmClient; private config; constructor(llmClient: ModelClient, config: ContentValidationConfig); /** * Validate input content using LLM */ validateInput(content: string): Promise; /** * Validate output content using LLM * @param content - The output to validate * @param inputContext - Optional input that generated this output (for context) */ validateOutput(content: string, inputContext?: string): Promise; /** * Create a guardrail function from this validator * * For output validation, the context parameter should include `inputContext` * containing the original user input, which improves detection of manipulation * success patterns where an attacker's prompt injection affected the output. */ asGuardrail(direction?: 'input' | 'output'): (content: string, context?: Record) => Promise; /** * Internal validation logic */ private validate; /** * Parse LLM response into SemanticValidationResult * * SECURITY: This method detects multiple valid JSON candidates in the response. * Multiple candidates could indicate a prompt injection attack where the attacker * prepended their own benign JSON object. When detected, we treat this as suspicious. */ private parseResponse; /** * Extract a complete JSON object from a string starting at the given index * Uses brace counting to handle nested objects correctly */ private extractJsonObject; /** * Map validation category to severity */ private categoryToSeverity; } /** * Create a semantic validator instance */ export declare function createSemanticValidator(llmClient: ModelClient, config?: Partial): SemanticValidator; //# sourceMappingURL=semantic-validator.d.ts.map