@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
73 lines • 2.84 kB
TypeScript
import type { FSNode, NodeHost, NodeOps, StreamOps } from './types.ts';
/**
* The node table for one mount prefix.
*
* Everything about *which* nodes exist and what they are called lives
* here: creating them, naming them, moving them, and translating between
* the guest's absolute paths and positions in this tree. It records no
* mutations and reports no errno, so the filesystem above it is left with
* only the semantics of each call.
*/
export declare class NodeTable {
private readonly host;
private readonly nodeOps;
private readonly streamOps;
private readonly prefix;
private root;
/**
* Args:
* host: the Emscripten FS namespace, for `createNode` and the mode
* predicates.
* prefix: the mount prefix this tree serves, trailing slash optional.
* nodeOps: op table every node created here must carry.
* streamOps: stream op table every node created here must carry.
*/
constructor(host: NodeHost, prefix: string, nodeOps: NodeOps, streamOps: StreamOps);
/** Build the root. Emscripten calls this through `FSType.mount`. */
mount(): FSNode;
/**
* Create a node and file it under its parent.
*
* Args:
* parent: directory to file it under, null only for the root.
* name: the child's name.
* mode: type and permission bits.
*/
makeNode(parent: FSNode | null, name: string, mode: number, rdev?: number): FSNode;
/**
* Give a placed node the kind a mount reported for it afterwards.
*
* Only a node placed from an unclassified listing row is ever built on
* a guess, and the guess is a regular file. When the mount says it is
* a directory, the node gets a child table, which is what `makeNode`
* would have built for one.
*
* Args:
* node: the node to retype.
* mode: the mode the mount reported, type bits included.
*/
retype(node: FSNode, mode: number): void;
childOf(parent: FSNode, name: string): FSNode | undefined;
/**
* Forget every node below the root, so the next lookup asks the mount.
*
* A child process may have changed anything the tree served. A stream
* open on a forgotten node reads on through its core handle, as a
* descriptor keeps its inode.
*/
invalidate(): void;
childNames(node: FSNode): string[];
detach(parent: FSNode, name: string): void;
/**
* Move a node to a new parent and name.
*
* Args:
* node: the node being moved.
* newDir: its new parent directory.
* newName: its new name.
*/
move(node: FSNode, newDir: FSNode, newName: string): void;
/** The guest-absolute path of a node, which is what the journal names. */
pathOf(node: FSNode): string;
}
//# sourceMappingURL=nodes.d.ts.map