/** * AI Guard enforcement interceptor. * * Translates ActionDecision output from the policy/action engine into actual * traffic manipulation. Prior to this module the SDK was strictly observe-only * — findings were logged but never blocked or modified. * * Modes (per-request, configurable via SDKConfig.enforcementMode): * observe — scan and log only, never block (default) * warn — scan, log, and add X-AI-Guard-Warning headers * block — scan and block requests with critical/block decisions * shadow-block — observe but mark wouldHaveBlocked (for testing before enabling) */ import type { DynamicFinding, EnforcementMode, CapturedRequest } from "./types"; export type EnforcementResult = { /** Whether the request was blocked (response should not be returned). */ blocked: boolean; /** HTTP status code to return (only meaningful when blocked is true). */ statusCode: number; /** Structured error body (only meaningful when blocked is true). */ body: EnforcementBlockBody | null; /** Warning headers to attach to the response (mode: warn). */ warningHeaders: string[]; /** Findings that triggered block/warn decisions. */ enforcingFindings: DynamicFinding[]; }; export type EnforcementBlockBody = { error: string; code: string; ruleIds: string[]; message: string; }; /** * Evaluates findings against the current enforcement mode and produces an * EnforcementResult that callers can use to decide whether to return the * original response, inject warnings, or block. */ export declare function evaluateEnforcement(findings: DynamicFinding[], mode: EnforcementMode, requestId: string): EnforcementResult; /** * Creates a blocking response object suitable for returning from provider * wrappers instead of the real model response. */ export declare function createBlockResponse(result: EnforcementResult, request: CapturedRequest): Record; /** * Shortcut: check whether a single finding would trigger a block in the * current enforcement mode. Used by streaming interceptors to decide * mid-stream whether to abort. */ export declare function wouldBlockInMode(finding: DynamicFinding, mode: EnforcementMode): boolean;