UNPKG

@dooor-ai/toolkit

Version:

Guards, Evals & Observability for AI applications - works seamlessly with LangChain/LangGraph

48 lines 1.6 kB
import { Guard } from "./base"; import { GuardResult, GuardConfig } from "../core/types"; export interface PromptInjectionGuardConfig extends GuardConfig { /** * AI Provider name to use (configured in CortexDB Studio, e.g., "gemini") * If not provided, uses providerName from toolkitConfig */ providerName?: string; } /** * Guard that detects prompt injection attempts using AI (LLM-as-a-Judge) * * Detects various jailbreak techniques including: * - Instruction overrides ("ignore previous instructions") * - Role manipulation ("act as if you are") * - System prompt extraction ("reveal your instructions") * - Jailbreak modes (DAN, sudo mode, developer mode) * - Indirect injections and unicode tricks * * @example * ```typescript * // Provider from toolkitConfig (recommended) * const guard = new PromptInjectionGuard({ * threshold: 0.7, * }); * * // Or specify provider explicitly * const guard = new PromptInjectionGuard({ * threshold: 0.7, * providerName: "gemini", // Override toolkitConfig.providerName * }); * ``` */ export declare class PromptInjectionGuard extends Guard { private providerName?; constructor(config?: PromptInjectionGuardConfig); get name(): string; validate(input: string, metadata?: Record<string, any>): Promise<GuardResult>; /** * Build prompt for prompt injection detection */ private buildPromptInjectionPrompt; /** * Parse AI response for prompt injection score and techniques */ private parsePromptInjectionResponse; } //# sourceMappingURL=prompt-injection.d.ts.map