export interface BlobPutResult {
hash: string;
path: string;
get ref(): string;
}
/**
* Content-addressed blob store for externalizing large binary data (images) from session JSONL files.
*
* Files are stored at `
/` with no extension. The SHA-256 hash is computed
* over the raw binary data (not base64). Content-addressing makes writes idempotent and
* provides automatic deduplication across sessions.
*/
export declare class BlobStore {
readonly dir: string;
constructor(dir: string);
/**
* Write binary data to the blob store.
* @returns SHA-256 hex hash of the data
*/
put(data: Buffer): Promise;
/**
* Synchronous variant of {@link put}. Use on persistence hot paths where the caller
* cannot afford the microtask hops of the async version (e.g. OOM-safe session writes).
* Returns once the bytes are in the kernel page cache.
*/
putSync(data: Buffer): BlobPutResult;
/** Read blob by hash, returns Buffer or null if not found. */
get(hash: string): Promise;
/** Check if a blob exists. */
has(hash: string): Promise;
}
/** Check if a data string is a blob reference. */
export declare function isBlobRef(data: string): boolean;
/** Extract the SHA-256 hash from a blob reference string. */
export declare function parseBlobRef(data: string): string | null;
/** Identify provider transport image data URLs so persistence can externalize and restore them losslessly. */
export declare function isImageDataUrl(data: string): boolean;
/**
* Externalize a provider image data URL to the blob store, returning a blob reference.
* The full data URL string is preserved so transport-native history can be reconstructed on resume.
*/
export declare function externalizeImageDataUrl(blobStore: BlobStore, dataUrl: string): Promise;
/** Synchronous variant of {@link externalizeImageDataUrl}. */
export declare function externalizeImageDataUrlSync(blobStore: BlobStore, dataUrl: string): string;
/**
* Externalize an image's base64 data to the blob store, returning a blob reference.
* If the data is already a blob reference, returns it unchanged.
*/
export declare function externalizeImageData(blobStore: BlobStore, base64Data: string): Promise;
/** Synchronous variant of {@link externalizeImageData}. */
export declare function externalizeImageDataSync(blobStore: BlobStore, base64Data: string): string;
/**
* Resolve an externalized provider image data URL back to its original string.
* If the data is not a blob reference, returns it unchanged.
* If the blob is missing, logs a warning and returns the reference as-is.
*/
export declare function resolveImageDataUrl(blobStore: BlobStore, data: string): Promise;
/**
* Resolve a blob reference back to base64 data.
* If the data is not a blob reference, returns it unchanged.
* If the blob is missing, logs a warning and returns a placeholder.
*/
export declare function resolveImageData(blobStore: BlobStore, data: string): Promise;