@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
31 lines • 1.46 kB
TypeScript
import { BytePipe } from '../../io/pipe.ts';
import type { PipeStream } from '../../io/types.ts';
import type { PathSpec } from '../../types.ts';
/**
* One directional virtual descriptor, with bounded producer backpressure.
*
* The read end belongs to the scope that opened it, which closes it, and the
* reader streams still open (`readers`, held weakly), when its command ends;
* no reader closes it, so a function can read one substitution twice. Readers
* take turns a chunk at a time, so they split the stream, and a ranged read
* leaves the rest of its chunk to the next. A reader whose signal fires while
* it waits leaves that chunk to the next reader. Mirrors Python's DevicePipe.
*/
export declare class DevicePipe {
readonly readable: boolean;
readonly pipe: BytePipe;
readonly readers: Set<WeakRef<PipeStream>>;
private source;
private pull;
private pending;
private turn;
constructor(readable: boolean);
write(data: Uint8Array, path: PathSpec, signal?: AbortSignal): Promise<void>;
read(path: PathSpec, size?: number | null, signal?: AbortSignal): Promise<Uint8Array>;
/** `signal` is the reader's own: once it fires, the reader takes nothing more. */
stream(path: PathSpec, signal?: AbortSignal): AsyncGenerator<Uint8Array>;
/** One reader's turn: the next bytes of the stream, at most `size`, empty at its end. */
private take;
private next;
}
//# sourceMappingURL=pipe.d.ts.map