/** * Bounded streaming redaction over raw child output. * * Two lanes run before any byte receives a cursor, so raw sensitive data never * reaches memory retention, artifacts, telemetry, or presentation: * * 1. A byte matcher removes the exact UTF-8 encodings of registered sensitive * values across arbitrary chunk splits, including next to invalid UTF-8. * 2. A decoder applies the existing textual secret patterns to the valid UTF-8 * runs of the emitted region. * * Retention is bounded: the only bytes held back are an incomplete trailing * UTF-8 code point and a tail that is still a viable prefix of a registered * secret. Prompts without a trailing newline therefore emit immediately. */ import { type SessionOperation } from "./types.js"; export declare const REDACTION_MARKER = "[redacted]"; /** Bytes of an incomplete trailing multi-byte UTF-8 sequence, else 0. */ export declare function trailingIncompleteUtf8Bytes(bytes: Uint8Array): number; export interface Utf8Run { readonly valid: boolean; readonly bytes: Uint8Array; } /** Split a byte range into maximal valid-UTF-8 runs and invalid byte runs. */ export declare function splitUtf8Runs(bytes: Uint8Array): Utf8Run[]; export declare class StreamingSecretRedactor { private readonly overlapBytes; private pending; private readonly secrets; private redactedAny; private closed; constructor(overlapBytes: number); get redacted(): boolean; /** * Register an exact sensitive value. Values longer than the configured overlap * bound are rejected before delivery because they could not be matched across * chunk splits without unbounded retention. */ registerExactSecret(value: string, operation?: SessionOperation): void; /** Longest tail of `bytes` that is a proper prefix of any registered secret. */ private viablePrefixTail; /** * Tail that is either a partial secret-pattern prefix or an in-progress token * that a pattern could still consume. */ private viablePatternTail; /** Feed raw bytes; returns the safe bytes now eligible for cursor assignment. */ push(raw: Uint8Array): Uint8Array; /** Flush retained overlap through both lanes. Idempotent. */ close(): Uint8Array; private transform; private applyByteLane; }