UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

54 lines • 3.49 kB
import { IOResult, type ByteSource } from '../../../io/types.ts'; import type { LinkView, MountView, StatPath } from '../../../view/types.ts'; import type { FileStat, PathSpec, StatFn } from '../../../types.ts'; export declare function operandName(virtual: string): string; /** * Stat one operand the way a reporting command needs it. * * Two things no single backend stat can get right, both about paths that * are namespace structure rather than backend state: * * A path that only exists because mounts or links sit under it (`/repos` * when `/repos/alpha` is mounted) has no backend to answer for it, so the * backend stat throws and the operand reads as absent. `statPath` routes * through the dispatcher, which answers such a path from the namespace, * so it is asked second and only on a miss. Its row is already named from * the path. * * A mount root has a backend, but that backend names its own root rather * than the path: ram answers `/`, and disk answers the host directory's * basename, which leaks the path behind the mount. So the row is renamed * here, the way `ls` renames a child-mount row for the same reason. * * Mirrors Python `mirage.commands.builtin.utils.operands.operand_stat`. */ export declare function operandStat(path: PathSpec, stat: StatFn, statPath?: StatPath | null, mounts?: MountView | null, links?: LinkView | null): Promise<FileStat>; /** * The mount roots a walk of `directory` reaches first, sorted: the edge of * the directory's own filesystem, so a mount nested in a mount is not one * of them. Mirrors Python's mount_points. */ export declare function mountPoints(mounts: MountView | null | undefined, directory: string): string[]; export declare function splitReadable(paths: readonly PathSpec[], stat: StatFn, cmdName: string): Promise<[PathSpec[], string]>; /** * splitReadable for the commands that head each operand. GNU head and tail * open an operand before they read it, and a directory opens: its `==> name * <==` header prints and only the read after it fails. So a directory keeps * its place among the opened operands, named in the unread set, while one * that does not open at all (a missing name) is dropped as splitReadable * drops it. Mirrors Python's split_opened. */ export declare function splitOpened(paths: readonly PathSpec[], stat: StatFn, cmdName: string): Promise<[PathSpec[], ReadonlySet<string>, string]>; export declare function operandsIo(err: string): IOResult; export declare function singleChunk(data: Uint8Array): AsyncIterable<Uint8Array>; /** Report a deferred filesystem error while allowing later operands. */ export declare function reportedStream(source: AsyncIterable<Uint8Array>, io: IOResult, path: PathSpec, cmdName: string): AsyncIterable<Uint8Array>; /** * Report one operand's filesystem failure on a result whose output goes on: * its fsErrorLine lands after the stderr already there, and the exit code * becomes 1. Mirrors Python's report_fs_error. */ export declare function reportFsError(io: IOResult, cmdName: string, path: PathSpec, err: unknown): Promise<void>; /** `each` over every operand in turn, or over stdin without one. Mirrors Python's per_operand. */ export declare function perOperand(paths: readonly PathSpec[], stream: (p: PathSpec) => AsyncIterable<Uint8Array>, stdin: ByteSource | null, io: IOResult, cmdName: string, each: (source: ByteSource) => AsyncIterable<Uint8Array>): AsyncIterable<Uint8Array>; //# sourceMappingURL=operands.d.ts.map