export interface BlobStore { /** Bytes at `key`, or null when absent. Never throws for a missing key. */ get(key: string): Promise; /** Store bytes at `key`, atomically (a reader never observes a torn blob). Creating * parent "directories" is the store's job; idempotent overwrite is allowed (content- * addressed callers never rewrite different bytes under one key). */ put(key: string, bytes: Uint8Array): Promise; exists(key: string): Promise; /** Remove the blob (or, for a prefix ending in '/', everything under it — namespace * reset uses this). A missing key is not an error. */ remove(key: string): Promise; /** Keys currently stored under `prefix` (full keys, sorted). Lifecycle/reset tooling * only — the serve path addresses blobs by exact key. */ list(prefix: string): Promise; /** Byte size at `key`, or null when absent. */ size(key: string): Promise; /** Bytes `start`..`endInclusive` at `key` (clamped to the blob), or null when absent — a native * ranged read, so serving a range of a large blob (a video a player seeks in) does not load it * whole. Optional: `readBlobRange` falls back to `get` (a whole read) for a backend without it — * the hosted World's R2 store today. */ getRange?(key: string, start: number, endInclusive: number): Promise; /** A body's chunks written to `key` as they arrive and hashed as they are written, kept (atomically, as `put`) * only when `accept` holds for their size and SHA-256; otherwise nothing is kept. True when kept. So an upload * of a large object (a model's weights) never holds more than a chunk. Optional: `writeBlobStream` collects * the chunks and `put`s them for a backend without it. */ putStream?(key: string, chunks: AsyncIterable, accept: (written: BlobWritten) => boolean): Promise; } /** What a streamed write wrote: its byte length and its SHA-256 (hex). */ export type BlobWritten = { size: number; sha256: string; }; /** A body's chunks to `key` through the active store, kept when `accept` holds for what was written (the store's * own streamed write where it has one, else the chunks collected and `put`). True when kept. */ export declare function writeBlobStream(key: string, chunks: AsyncIterable, accept: (written: BlobWritten) => boolean): Promise; /** A web stream's chunks, read by its reader (a browser's ReadableStream need not be async-iterable). */ export declare function streamChunks(body: ReadableStream): AsyncGenerator; /** A range of the blob at `key` through the active store: native when the store has it, else sliced. */ export declare function readBlobRange(key: string, start: number, endInclusive: number): Promise; /** Today's layout, verbatim: keys are filesystem paths. */ export declare class FsBlobStore implements BlobStore { private options; constructor(options?: { sharedIndexRoot?: string | false; }); get(key: string): Promise; put(key: string, bytes: Uint8Array): Promise; putStream(key: string, chunks: AsyncIterable, accept: (written: BlobWritten) => boolean): Promise; exists(key: string): Promise; remove(key: string): Promise; list(prefix: string): Promise; size(key: string): Promise; getRange(key: string, start: number, endInclusive: number): Promise; } /** In-memory backend — tests and hydration rehearsals; also the shape an R2/S3 adapter * implements (same interface, object keys instead of paths). */ export declare class MemoryBlobStore implements BlobStore { private blobs; get(key: string): Promise; put(key: string, bytes: Uint8Array): Promise; exists(key: string): Promise; remove(key: string): Promise; list(prefix: string): Promise; size(key: string): Promise; getRange(key: string, start: number, endInclusive: number): Promise; } /** Content-address helper shared by byte-carrying packs: sha256 hex of the bytes. */ export declare function blobDigest(bytes: Uint8Array): string; /** The active store; under a read-only request's refusing scope (request-scope.ts), one that refuses * to store or remove bytes before any reach it, as the log's appenders refuse (a git push's objects, * an upload's body), while reads pass. */ export declare function getActiveBlobStore(): BlobStore; export declare function setActiveBlobStore(store: BlobStore): BlobStore; export declare function withBlobStore(store: BlobStore, fn: () => Promise | T): Promise;