@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
48 lines • 2.05 kB
TypeScript
export declare const CAPACITY: number;
/**
* Buffers their producer never writes again, such as mirage-rs output copied
* out of linear memory. A pipe keeps a chunk of one up to twice its capacity
* as written, so a reader holding a few bytes never pins a much larger
* buffer; it copies a chunk of any other buffer, in case the writer reuses it.
*/
export declare const SEALED: WeakSet<ArrayBufferLike>;
/** One reader and bounded asynchronous writes. Closing either endpoint wakes writers. */
export declare class BytePipe {
private readonly capacity;
constructor(capacity?: number);
private chunks;
private bytes;
private ended;
private readerClosed;
private reading;
private delivered;
private accepted;
private failure;
private wake;
get bufferedBytes(): number;
get closedReader(): boolean;
private notify;
private changed;
/** Accept bytes in bounded chunks, waiting for available capacity. */
write(data: Uint8Array, signal?: AbortSignal): Promise<void>;
private merged;
/** Wait until the reader consumes accepted writes or closes. */
drain(): Promise<void>;
/** Close the writer, preserving buffered bytes and a late failure. */
end(error?: unknown): void;
closeReader(): void;
/** Match a kernel pipe: an unblocked writer may finish its current burst. */
release(): void;
/** Wait until the reader first asks for bytes or closes. */
asked(): Promise<void>;
/**
* Read once; abandoning the iterator closes its endpoint. Each read is one
* chunk as written, unless `joined`: then it takes everything buffered, as
* a kernel pipe's read does, for a reader that keeps no write boundaries,
* which behind a writer that filled the pipe wakes once for the lot rather
* than once per chunk. Chunks side by side in one buffer (a sealed write)
* pass as one view of it; others are copied together.
*/
stream(joined?: boolean): AsyncGenerator<Uint8Array>;
}
//# sourceMappingURL=pipe.d.ts.map