//#region src/lateral-leak/protocol-guard.d.ts /** * Protocol/header injection guard - escapes control characters in * tool result bodies before they cross internal-service delivery * boundaries (SSE, WebSocket, REST body, HTTP header, audit row). * * The default policy mirrors the deployment-posture matrix from the * lateral-leak design (DEC-171): * * - `'sse' | 'http-header'` → `'strict'` (escape control chars to * `\xNN` hex literals; the safest default for cleartext frame * protocols). * - `'ws' | 'rest-body'` → `'replace'` (replace with the Unicode * replacement character `\uFFFD`). * - `'audit'` → `'strict'` (regulated deployments). * - `'reject'` is operator opt-in - the guard throws * {@link ProtocolInjectionRejectError} when control characters are * detected. * * @packageDocumentation */ /** * Per-boundary identifier used by the runtime when calling the * guard. * * @stable */ type ProtocolBoundary = 'sse' | 'http-header' | 'ws' | 'rest-body' | 'audit'; /** * Per-boundary escape policy. * * @stable */ type ProtocolEscapePolicy = 'strict' | 'replace' | 'reject'; /** * Configurable per-boundary policy table. There is no `AgentConfig` knob * for this; operators override specific boundaries by passing a * `ProtocolGuardConfig` to `guardOutboundContent(...)` / `resolvePolicy(...)` * when wiring server boundaries (SSE / session export). * * @stable */ interface ProtocolGuardConfig { readonly sse?: ProtocolEscapePolicy; readonly httpHeader?: ProtocolEscapePolicy; readonly ws?: ProtocolEscapePolicy; readonly restBody?: ProtocolEscapePolicy; readonly audit?: ProtocolEscapePolicy; } /** * Resolved policy lookup. Pure function - no side effects. * * @stable */ declare function resolvePolicy(boundary: ProtocolBoundary, cfg?: ProtocolGuardConfig): ProtocolEscapePolicy; /** * Outcome of {@link guardOutboundContent}. * * @stable */ interface GuardOutcome { readonly content: string; readonly escapedCharCount: number; readonly matchedPattern?: string; readonly decision: 'pass-through' | 'escaped' | 'replaced' | 'rejected'; readonly boundary: ProtocolBoundary; readonly policy: ProtocolEscapePolicy; } /** * Apply the configured escape policy to a single string body. Pure * - never mutates inputs. * * @stable */ declare function guardOutboundContent(input: string, boundary: ProtocolBoundary, cfg?: ProtocolGuardConfig): GuardOutcome; //#endregion export { GuardOutcome, ProtocolBoundary, ProtocolEscapePolicy, ProtocolGuardConfig, guardOutboundContent, resolvePolicy }; //# sourceMappingURL=protocol-guard.d.ts.map