@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
77 lines • 4.54 kB
TypeScript
import type { IndexCacheStore } from '../../cache/index/store.ts';
import { DirListing, FileStat, type PathSpec } from '../../types.ts';
/**
* The key a mount keeps `path` under in its index: the virtual path, the
* mount root spelled without its slash. A glob word is keyed as the
* directory it lists. Mirrors Python's `index_key`.
*/
export declare function indexKey(prefix: string, path: PathSpec): string;
/** The key of the directory holding `key`; the root holds itself. */
export declare function folderOf(key: string): string;
/**
* A directory's listing as the index holds it, null when the index holds no
* complete, live listing for it. The mount's read policy rides the index: a
* listing past its bound, or one a `fresh` mount's check refuses, answers
* null here. A window (the newest messages, the last days) answers no glob:
* the backend moves its window to the span the glob asks for. Mirrors
* Python's `stored_listing`.
*/
export declare function storedListing(index: IndexCacheStore, key: string, glob?: boolean): Promise<string[] | null>;
/**
* Whether `key`'s folder holds a window that does not name it. A window shows
* everything to show but proves nothing absent: a day it does not list may
* still be there, and only the backend says. Mirrors Python's
* `beyond_window`.
*/
export declare function beyondWindow(index: IndexCacheStore, key: string): Promise<boolean>;
/**
* Keep what a backend listed, and answer the children's paths. A plain list is
* the directory's whole listing. A `DirListing` may also prove descendant
* listings (`seeds`), be a view rather than the whole directory (`partial`),
* or prove nothing absent (`window`); each is kept for what it proves, and a
* seed at the version its listing was read at.
*/
export declare function keepListing(index: IndexCacheStore, key: string, listed: readonly FileStat[] | DirListing, refill?: string | null, fetched?: Map<string, FileStat | null>): Promise<string[]>;
/**
* Whether the stored listing of the path's folder leaves it out without
* proving it absent: a complete listing the running command did not fetch,
* which another client may have added the name to since. Mirrors Python's
* `unproven_miss`.
*/
export declare function unprovenMiss(index: IndexCacheStore, key: string): Promise<boolean>;
/**
* A stat the stored listings answer, null when none does. The row the
* parent's listing holds answers it, so a listing costs one request and the
* stat of each child after it none. A complete listing that does not name the
* path rejects with ENOENT the same way, where `proves` says its folder's
* listing proves a name absent; a window that does not answers nothing, and
* neither does a listing that proves nothing. A directory whose own listing is
* held answers with the row a subtree read kept for it. `key` is below the
* mount root.
*/
export declare function storedStat(index: IndexCacheStore, key: string, proves?: ((folder: string) => boolean) | null): Promise<FileStat | null>;
/**
* What is at `key`, as its parent's listing names it, listing the parent
* through `warm` when no listing proves it; null when nothing is there. `key`
* is below the mount root, which no listing names.
*/
export declare function entryAt(index: IndexCacheStore, key: string, warm: (() => Promise<string[]>) | null): Promise<FileStat | null>;
/**
* A subtree read the stored listings answer, null when one does not: every
* entry below the directory as its parent's listing holds it, keyed by its
* path below `key`, which is what a walk of `readdir` and `stat` over the same
* listings would see. Null while any directory under it has no complete, live
* listing; a window is not one. Mirrors Python's `stored_tree`.
*/
export declare function storedTree(index: IndexCacheStore, key: string): Promise<Map<string, FileStat> | null>;
/**
* Keep a subtree read as the listings it proves: it names everything below the
* directory, so it is a complete listing of the directory and of each
* directory below it. The directory's own stat, which a read may name under
* `''`, is kept where a stat of it finds it. A folder whose listing is live
* keeps it: one that landed while the read ran may be newer than the read, and
* replacing it would report its newer children gone. Mirrors Python's
* `keep_tree`.
*/
export declare function keepTree(index: IndexCacheStore, key: string, tree: ReadonlyMap<string, FileStat>, refill?: string | null): Promise<void>;
//# sourceMappingURL=listing.d.ts.map