export interface RedactEntity { type: string; placeholder: string; start: number; end: number; } export interface AttestationSummary { enclaveId: string; region: string; pcr0?: string; modelVersion?: string; recognizerVersion?: string; attested?: boolean; } export interface RedactResult { redacted: string; entities: RedactEntity[]; requestId: string; attestation?: AttestationSummary; modelVersion?: string; recognizerVersion?: string; } export interface AuditEntry { ts: string; requestId: string; source: 'run' | 'proxy'; entityCountsByType: Record; attestationRef: string; modelVersion?: string; recognizerVersion?: string; } export interface AuditListResponse { entries: AuditEntry[]; nextCursor?: string; } export declare class RedactApiError extends Error { statusCode: number; details?: unknown | undefined; constructor(message: string, statusCode: number, details?: unknown | undefined); } export declare class MissingCredentialsError extends Error { constructor(); } interface Creds { apiKey: string; walletAddress: string; apiUrl: string; } export declare function resolveCreds(override?: { apiKey?: string; }): Creds; export declare function redactText(text: string, override?: { apiKey?: string; }): Promise; export declare function fetchAttestation(override?: { apiKey?: string; }): Promise; export declare function getAuditLog(params?: { limit?: number; since?: string; apiKey?: string; }): Promise; /** * Forward an OpenAI-shaped chat-completion request through the control plane * and buffer the full (non-streaming) response. */ export declare function chatCompletionProxy(body: Record, modelKey: string, options?: { rehydrate?: boolean; apiKey?: string; }): Promise<{ status: number; body: unknown; rehydrationMap?: Record; requestId?: string; }>; export interface ChatCompletionStream { status: number; /** Raw upstream SSE stream when the upstream actually streamed, else null. */ stream: ReadableStream | null; /** Set when the upstream returned a non-SSE body (e.g. a JSON error) instead. */ body?: unknown; contentType: string; /** * Placeholder → original map sent in the `x-treza-rehydration` header. Known * entirely from the request-side redaction, so it is available before the * first token. Only populated when `rehydrate` was requested. */ rehydrationMap?: Record; requestId?: string; } /** * Streaming variant of {@link chatCompletionProxy}. Asks the control plane for * an SSE stream (`stream: true`) and returns the raw upstream byte stream so the * caller can pipe it straight to its own client. The proxy never rewrites the * response body — placeholders are rehydrated client-side (see * `applyStreamRehydration`) using the `x-treza-rehydration` map. * * Fails closed: if the request-side redaction errors the control plane returns a * non-2xx JSON body and this throws a {@link RedactApiError} before any bytes * reach the caller — nothing was forwarded upstream. */ export declare function chatCompletionProxyStream(body: Record, modelKey: string, options?: { rehydrate?: boolean; apiKey?: string; }): Promise; /** * Stateful rehydrator for streamed text. A placeholder such as `[EMAIL_1]` can * be split across SSE chunks, so we rehydrate against accumulated text rather * than individual deltas: any trailing fragment that could still grow into a * placeholder (an unclosed `[…`) is held back and prepended to the next delta. * * Returns the rehydrated, safe-to-emit text for this delta (possibly empty). * Call {@link StreamRehydrator.flush} once the stream ends to drain the tail. */ export declare class StreamRehydrator { private readonly map; private carry; constructor(map: Record); push(delta: string): string; flush(): string; private rehydrate; } export {}; //# sourceMappingURL=redact-api.d.ts.map