/** * Multi-turn mutation - splits attack into multiple conversational turns * Tests if the model can be gradually manipulated through conversation * * Supports two input formats (consistent with the run command): * 1. String prompt: Uses built-in strategies to generate conversation context * 2. Array prompt: Uses the conversation as custom context, with the last user message as the attack target */ import { type CvssScore } from '../severity'; import type { Mutation } from './index'; export type MultiTurnStrategy = 'gradual_escalation' | 'context_switching' | 'persona_building' | 'distraction' | 'custom'; export interface ConversationTurn { role: 'user' | 'assistant' | 'system'; content: string; } /** * Options for multi-turn mutation with custom conversation support */ export interface MultiTurnOptions { /** The strategy to use for generating conversation context */ strategy?: MultiTurnStrategy; } /** * Input for multi-turn mutation - supports both string and array formats */ export interface MultiTurnInput { /** The attack prompt (string) or full conversation (array) */ prompt: string | ConversationTurn[]; } export declare class MultiTurnMutation implements Mutation { readonly name = "multi_turn"; readonly description = "Splits attacks into multi-message sequences to gradually manipulate"; readonly severity: "critical"; readonly cvssScore: CvssScore; private strategy; private currentPrefix?; constructor(strategyOrOptions?: MultiTurnStrategy | MultiTurnOptions); /** * Set custom conversation prefix from an array prompt. * Called by the redteam command when a test case has an array prompt. */ setConversationPrefix(prefix: ConversationTurn[]): void; /** * Clear the current conversation prefix (reset to use strategy-based generation) */ clearConversationPrefix(): void; /** * Check if this mutation has a custom prefix set */ hasCustomPrefix(): boolean; /** * For single-prompt use, returns a prompt that simulates multi-turn context. * If a custom prefix is set, uses that; otherwise uses the configured strategy. */ mutate(prompt: string): string; /** * Generate a full multi-turn conversation sequence. * If a custom prefix is set, uses that; otherwise uses the configured strategy. */ generateConversation(targetPrompt: string): ConversationTurn[]; /** * Custom conversation using user-provided prefix (from array prompt) */ private customConversation; /** * Generate full conversation with custom prefix */ private generateCustomConversation; /** * Gradual escalation: Start with harmless requests, slowly increase severity */ private gradualEscalation; private generateGradualEscalation; /** * Context switching: Abruptly change topic to confuse safety measures */ private contextSwitching; private generateContextSwitching; /** * Persona building: Establish a trusted persona before the attack */ private personaBuilding; private generatePersonaBuilding; /** * Distraction: Bury the attack within benign content */ private distraction; private generateDistraction; } //# sourceMappingURL=multi-turn.d.ts.map