import { ConversationMessage } from '../config/types.js'; /** * Phases in the guardrail pipeline where plugins can intercept */ export type GuardrailPhase = 'pre_request' | 'post_response' | 'pre_tool_input' | 'post_tool_output'; /** * Action to take after guardrail evaluation */ export type GuardrailAction = 'allow' | 'block' | 'modify'; /** * Severity levels for violations */ export type ViolationSeverity = 'info' | 'warning' | 'error' | 'critical'; /** * A violation detected by a guardrail plugin */ export interface GuardrailViolation { pluginName: string; phase: GuardrailPhase; rule: string; severity: ViolationSeverity; message: string; details?: Record; } /** * A modification made by a guardrail plugin */ export interface GuardrailModification { pluginName: string; phase: GuardrailPhase; field: string; originalValue?: unknown; newValue?: unknown; reason: string; } /** * Context passed through the guardrail pipeline */ export interface GuardrailContext { requestId: string; provider: string; model: string; timestamp: Date; messages: ConversationMessage[]; prompt?: string; response?: string; toolName?: string; toolArgs?: Record; toolResult?: unknown; metadata: Map; violations: GuardrailViolation[]; modifications: GuardrailModification[]; } /** * Result from a guardrail plugin execution */ export interface GuardrailResult { action: GuardrailAction; context: GuardrailContext; blockedBy?: string; blockReason?: string; } /** * Base interface for guardrail plugins */ export interface GuardrailPlugin { /** Unique plugin name */ name: string; /** Whether the plugin is currently enabled */ enabled: boolean; /** Execution priority (lower = runs first) */ priority: number; /** Which phases this plugin handles */ phases: GuardrailPhase[]; /** Initialize the plugin with its configuration */ initialize(config: Record): Promise; /** Execute the plugin for a specific phase */ execute(phase: GuardrailPhase, context: GuardrailContext): Promise; /** Cleanup plugin resources */ shutdown(): Promise; } /** * Options for creating a guardrail context */ export interface CreateContextOptions { requestId?: string; provider?: string; model?: string; messages?: ConversationMessage[]; prompt?: string; response?: string; toolName?: string; toolArgs?: Record; toolResult?: unknown; } //# sourceMappingURL=types.d.ts.map