@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
47 lines • 2 kB
TypeScript
import type { JsonValue } from '../types.ts';
/** A file operation a call waits on, for the host to run on its mount core. */
export interface NFSRequest {
readonly id: number;
readonly op: 'getattr' | 'readdir' | 'read' | 'readlink';
readonly path: string;
readonly offset?: number;
readonly size?: number;
readonly after?: string;
readonly limit?: number;
}
/**
* The mirage-rs NFSv3 server, which does no I/O of its own: the host feeds
* it each connection's bytes, runs the file operations `requests` names,
* and hands each result back through `complete`. It runs on a wasm
* instance of its own, so a long-lived server never holds the one streams
* share. Mirrors Python's NFSEngine.
*/
export declare class NFSEngine {
private readonly exports;
private readonly handle;
private constructor();
/**
* Open a server: `exportPath` is the path a client mounts, `generation` is
* stamped into every file handle (one from another generation is stale),
* and `port` is the port the host listens on.
*/
static open(exportPath: string, generation: number, port: number): Promise<NFSEngine>;
/** Take what connection `conn` sent; returns the replies it answers at once. */
feed(conn: number, data: Uint8Array): Uint8Array;
/** The file operations calls wait on, each with its `id`. */
requests(): NFSRequest[];
/**
* Hand back one request's result: `{error: 'ENOENT'}`, or what it asked for
* (`attrs`, `entries`, `target`), and the bytes a read returned. Returns the
* call's connection (null once it has closed) and its reply once it has one.
*/
complete(id: number, reply: Record<string, JsonValue>, data?: Uint8Array): [number | null, Uint8Array];
/** Forget connection `conn` and the calls it has out. */
close(conn: number): void;
/** Free the server. */
dispose(): void;
private put;
private output;
private refusal;
}
//# sourceMappingURL=nfs.d.ts.map