import type { ImageContent } from "@earendil-works/pi-ai"; /** * Media sanitization for every channel that serializes guest or provider data * into text: fabric_exec logs, results, and error text, and actor host-event * payloads. Worker event lines are not sanitized: one past the line cap fails the * run with a bounded raw prefix as evidence. * * Raw image bytes stay available out of band (see the images side channel), so a * multimodal model can still receive them while text channels receive a * descriptor. The rule used to be implemented only for actor host events, so a * guest that printed or returned a nested pi.read image could push hundreds of * KB of base64 into one serialized line and break the run. */ /** Descriptor that replaces an image payload in a text channel. */ export interface FabricSanitizedMediaDescriptor { type: "image"; mediaIndex: number; mimeType: string; redacted: true; } export interface SanitizedFabricMedia { value: unknown; /** Raw payloads, indexed by mediaIndex in the descriptors. */ images: ImageContent[]; media: FabricSanitizedMediaDescriptor[]; } /** True when an entire string is a base64 payload (or a base64 data URL). */ export declare const looksLikeBase64: (value: string) => boolean; /** True for the Pi multimodal block shape {type: "image", data, mimeType}. */ export declare const isImageContent: (value: unknown) => value is ImageContent; /** * Replace base64 runs inside free text with a bounded marker. Short strings are * returned untouched, so the hot event-line path pays only a length check. */ export declare const sanitizeFabricMediaText: (text: string) => string; /** * Recursively replace image payloads and long base64 strings in a value. * * Images are deduplicated by content hash and hoisted into the images side * channel, and their text representation becomes a descriptor. Non-plain objects * and repeated references are returned unchanged: rebuilding them would drop * class identity, which matters because fabric_exec inspects result values for * control fields such as terminate. */ export declare const sanitizeFabricMediaValue: (value: unknown) => SanitizedFabricMedia; //# sourceMappingURL=media-sanitize.d.ts.map