@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
36 lines • 2 kB
TypeScript
import type { GitHubAccessor } from '../../accessor/github.ts';
import { type FileStat, type PathSpec } from '../../types.ts';
import type { Handed } from '../../vfs/types.ts';
/**
* Read a file's blob and record the sha it was fetched by.
*
* The sha comes from the file's row, as its folder's listing names it. The
* blob endpoint is content-addressed, so the recorded sha names exactly the
* bytes returned however old the listing is. That is also the documented
* limit of `read: fresh` here: a file read for the first time comes from the
* listing, and the next read's probe corrects it.
*
* Mirrors Python's `read`.
*/
export declare function read(accessor: GitHubAccessor, path: PathSpec, entry?: FileStat | null): Promise<Uint8Array>;
/**
* Several files' blobs in one GraphQL query.
*
* Each blob is asked by the sha its row names, as `read` asks it. GraphQL
* hands a blob over as text, so a file is kept only when that text, encoded
* as UTF-8, hashes to the sha the way git hashes a blob, which proves the
* bytes are the ones a read returns. A binary, truncated or non-UTF-8 blob, a
* file past `limit` bytes, and a path with no file row are left out for
* their own read. Each file kept is recorded as `read` records it. Mirrors
* Python's `read_many`.
*/
export declare function readMany(accessor: GitHubAccessor, paths: readonly PathSpec[], limit: number, handed?: readonly Handed[]): Promise<Map<string, Uint8Array>>;
/**
* Stream a file's blob as it downloads, recorded by its sha. The blob comes
* as GitHub's raw media type, the bytes themselves rather than base64 inside
* JSON. The sha is the row's, as `read` takes it, and recorded up front: the
* blob endpoint is content-addressed, so it names the bytes however far the
* stream is read. Mirrors Python's `read_stream`.
*/
export declare function readStream(accessor: GitHubAccessor, path: PathSpec, entry?: FileStat | null): AsyncGenerator<Uint8Array, void>;
//# sourceMappingURL=read.d.ts.map