/** * Verifies audio redaction by retranscribing with an independently selected ASR provider, so * span-production misses do not automatically pass verification. */ import { ElizaError } from "./errors.js"; import type { TranscriptWord } from "./transcripts.js"; /** Input to one verifier transcription call. */ export interface RedactionTranscribeInput { /** The redacted audio bytes to re-transcribe. */ audio: Uint8Array; /** Container mime (e.g. `audio/wav`, `audio/ogg`). */ mimeType: string; /** Expected-language hint for multilingual backends (BCP-47 / ISO 639-1). */ languageHint?: string; } /** One verifier transcription result. Timestamps are optional by contract. */ export interface RedactionTranscript { text: string; /** Per-word spans when the backend has them — never required for verify. */ words?: readonly TranscriptWord[]; } /** * A pluggable ASR backend for the verify step. Implementations MUST throw on * failure (model unavailable, transport error) — returning an empty * transcript for "could not transcribe" would fabricate a PII-absent pass. */ export interface RedactionTranscriber { /** Stable id for logs/evidence (e.g. `"local-transcription"`). */ readonly id: string; transcribe(input: RedactionTranscribeInput): Promise; } /** Thrown when the verify step has no usable transcriber — never a pass. */ export declare class AudioRedactionVerifyUnavailableError extends ElizaError { constructor(message: string); } /** What the verifier asserts over the redacted transcript. */ export interface RedactionVerifyExpectation { /** PII surface texts that must be INAUDIBLE (absent from the transcript). */ piiTexts: readonly string[]; /** Non-PII words that must still be AUDIBLE (over-mute guard). */ sentinelTexts?: readonly string[]; } /** One verifier backend's judgment. */ export interface RedactionVerifierFinding { verifierId: string; /** The raw transcript the backend produced (evidence trail). */ transcript: string; /** PII texts still present — any entry fails the verify. */ piiFound: string[]; /** Sentinels no longer present — any entry fails the verify (over-mute). */ sentinelsMissing: string[]; ok: boolean; } /** Aggregated verify outcome across all configured verifier backends. */ export interface RedactionVerifyResult { /** True only when EVERY configured verifier found no PII + all sentinels. */ ok: boolean; findings: RedactionVerifierFinding[]; } /** * PII texts still detectable in a transcript, by separator-insensitive * normalized containment ("555 0123" is found in "…is 5550123."). Exact-token * and fuzzed-separator hits are the same check by construction. */ export declare function findResidualPii(transcript: string, piiTexts: readonly string[]): string[]; /** Sentinel texts NOT present in the transcript (normalized containment). */ export declare function findMissingSentinels(transcript: string, sentinelTexts: readonly string[]): string[]; /** Pure judgment of one transcript against the expectation. */ export declare function judgeRedactedTranscript(verifierId: string, transcript: string, expectation: RedactionVerifyExpectation): RedactionVerifierFinding; /** * Run the verifier matrix: every configured backend re-transcribes the * redacted audio and judges it independently; the aggregate passes only when * ALL pass. Zero backends throws {@link AudioRedactionVerifyUnavailableError} * and a backend failure (its `transcribe` throwing) propagates — the verify * step fails observably, it never silently passes. */ export declare function verifyAudioRedaction(transcribers: readonly RedactionTranscriber[], input: RedactionTranscribeInput, expectation: RedactionVerifyExpectation): Promise;