/** * Guardrails Module * * Provides input/output validation including: * - Injection detection (prompt injection, jailbreaks) * - PII detection and redaction * - Content filtering * - Custom validation rules */ import type { ContentCategory, ContentFilterResult, GuardrailResult, InjectionDetection, PIIDetection, PIIType, PatternCategory, PatternConfig, ViolationSeverity } from './types'; /** * Options for custom pattern matching */ export interface CustomPatternOptions { /** Case-insensitive matching (default: true) */ caseInsensitive?: boolean; /** Pattern category for categorization */ category?: PatternCategory; /** Severity level for matches */ severity?: ViolationSeverity; } /** * Match a pattern against content with options */ export declare function matchPattern(content: string, pattern: string | RegExp, options?: CustomPatternOptions): { matched: boolean; match?: RegExpMatchArray; }; /** * Create a custom pattern guardrail */ export declare function createCustomPatternGuardrail(patterns: Array, options?: CustomPatternOptions): (content: string, context?: Record) => Promise; /** * Detect injection attempts in text */ export declare function detectInjection(text: string): InjectionDetection; /** * Create an injection detection guardrail */ export declare function createInjectionGuardrail(): (content: string, context?: Record) => Promise; /** * Detect PII in text */ export declare function detectPII(text: string): PIIDetection; /** * Create a PII detection guardrail */ export declare function createPIIGuardrail(options?: { redact?: boolean; block?: boolean; allowedTypes?: PIIType[]; }): (content: string, context?: Record) => Promise; /** * Filter content for harmful categories */ export declare function filterContent(text: string): ContentFilterResult; /** * Create a content filter guardrail */ export declare function createContentFilterGuardrail(options?: { blockedCategories?: ContentCategory[]; warnCategories?: ContentCategory[]; }): (content: string, context?: Record) => Promise; /** * Guardrail configuration options */ export interface GuardrailsConfig { /** Enable injection detection */ injectionDetection?: boolean; /** Enable PII detection */ piiDetection?: boolean; /** PII detection options */ piiOptions?: { redact?: boolean; block?: boolean; allowedTypes?: PIIType[]; }; /** Enable content filtering */ contentFilter?: boolean; /** Content filter options */ contentFilterOptions?: { blockedCategories?: ContentCategory[]; warnCategories?: ContentCategory[]; }; /** * Pattern matching configuration * Controls how custom patterns are matched */ patternConfig?: PatternConfig; /** * Custom patterns to add to injection detection * These are checked in addition to built-in patterns */ customPatterns?: Array; /** * Pattern categories to enable (default: all) * Use this to selectively enable pattern categories */ enabledPatternCategories?: PatternCategory[]; /** Custom guardrails */ custom?: Array<(content: string, context?: Record) => Promise>; } /** * Create a composite guardrail from configuration */ export declare function createGuardrails(config?: GuardrailsConfig): Array<(content: string, context?: Record) => Promise>; //# sourceMappingURL=guardrails.d.ts.map