UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

57 lines • 3.25 kB
import type { ByteSource, IOResult } from './types.ts'; /** * One lazy byte cursor shared by commands inheriting an input descriptor. * Serializing reads prevents concurrent consumers from replaying bytes or * pulling the source simultaneously. A consumer stopping early leaves the * cursor open; byte-sized pulls preserve the unread suffix for its successor. */ export declare class SharedStdin implements AsyncIterable<Uint8Array> { private chunks; private buffer; private pos; private readonly lock; constructor(source: ByteSource); [Symbol.asyncIterator](): AsyncIterator<Uint8Array, undefined>; } export declare function drain(stream: ByteSource | null): Promise<void>; export declare function closeQuietly<T>(stream: Uint8Array | AsyncIterable<T> | AsyncIterator<T> | null): Promise<void>; /** Own producer cleanup even when its byte iterator was never started. */ export declare class OutputStream implements AsyncIterableIterator<Uint8Array> { private readonly source; private readonly close; private closing; constructor(source: AsyncIterator<Uint8Array>, close: () => Promise<void>); [Symbol.asyncIterator](): AsyncIterableIterator<Uint8Array>; next(): Promise<IteratorResult<Uint8Array>>; return(): Promise<IteratorResult<Uint8Array>>; private finish; } /** Discard failed reads without changing normal early-consumer close semantics. */ export declare function discardStreams(...streams: (ByteSource | null)[]): Promise<void>; export declare function discardIo(io: IOResult): Promise<void>; export declare function asyncChain(streams: Iterable<ByteSource | null>): AsyncIterable<Uint8Array>; /** * Write a program's input as it is read, then end it: a finite command * waits for that end. Writing stops once `stopped` says the program has * gone, and a program that closed its input (`closed` says which errors * mean that) has taken what it wanted, so neither fails the run; an input * that fails as it is read does. Mirrors Python's `feed`. */ export declare function feed(stdin: ByteSource | null, write: (chunk: Uint8Array) => Promise<void>, end: () => Promise<void>, stopped: () => boolean, closed?: (error: unknown) => boolean): Promise<void>; export declare function yieldBytes(data: Uint8Array): AsyncIterable<Uint8Array>; /** * Present a byte source as a stream. An iterable is returned as itself, so * closing the consumer closes its source; bytes become a one-chunk stream. */ export declare function ensureStream(src: ByteSource): AsyncIterable<Uint8Array>; /** Open a reader before creating its destination; retain ownership before the first pull. */ export declare function primeStream(source: AsyncIterable<Uint8Array>, failed?: (error: unknown) => void): Promise<ByteSource>; /** Take a byte window without materializing its prefix or suffix. */ export declare function sliceStream(source: ByteSource, offset?: number, size?: number | null): OutputStream; /** * Re-cut a stream into parts of up to `size` bytes, joining short ones, so a * consumer pays once per block rather than once per record. Mirrors Python's * rechunk. */ export declare function rechunk(source: ByteSource, size: number): OutputStream; //# sourceMappingURL=stream.d.ts.map