UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

148 lines • 6.75 kB
import type { DotWalkError, FsError, MissingOpError, NoMountError, StaleWriteError, WalkDeclinedError } from './types.ts'; export declare function virtualOf(path: string | { virtual: string; rawPath?: string; }): string; export declare function fsError(path: string | { virtual: string; }, code: string, message?: string): FsError; export declare function unnamedFsError(code: string, message: string): Error; export declare function enoent(path: string | { virtual: string; }): FsError; /** EBADF for a read from a descriptor that is closed or write-only, named * as the reader names it (`-` for standard input). Mirrors Python's ebadf. */ export declare function ebadf(path: string | { virtual: string; }): FsError; /** EFBIG: a read the backend refuses to render whole (a records file past its * mount's record cap); python's FileTooLargeError. Per-operand, like ENOENT, * so a read-family command reports it and moves on. */ export declare function efbig(path: string | { virtual: string; }): FsError; /** EDQUOT: a write past its mount's capacity; python's QuotaExceededError. * Per-operand, so a command reports it and moves on. */ export declare function edquot(path: string | { virtual: string; }): FsError; /** A conditional write the backend refused: the file changed since it was * read. Per-operand, so a command reports it and moves on; never a read * failure. Python's StaleWriteError. */ export declare function staleWrite(path: string | { virtual: string; }, landed?: boolean): StaleWriteError; /** * The part of a failure's path below `operand`, '' when it is the operand: a * recursive command that fails on a file inside its operand names that * file, as GNU does (`rm: cannot remove 'd/s/b'`). Mirrors Python's * `inner_suffix`. */ export declare function innerSuffix(operand: { virtual: string; }, err: unknown): string; /** An operand as typed, or naming the file inside it that failed. Mirrors Python's `with_inner`. */ export declare function withInner(raw: string, inner: string): string; export declare function isStaleWrite(err: unknown): err is StaleWriteError; export declare function isLandedMove(err: unknown): err is StaleWriteError; export declare function ebusy(path: string | { virtual: string; }): FsError; export declare function enotdir(path: string | { virtual: string; }): FsError; export declare function dotWalkError(path: string | { virtual: string; }, code: 'ENOENT' | 'ENOTDIR' | 'ELOOP'): DotWalkError; /** What an op raises for an operand the kernel walk did not resolve, named * as typed (the empty name included), since that is what the command * reports and `virtual` names the working directory for it. Mirrors * Python's walk_refusal. */ export declare function walkRefusal(path: { virtual: string; rawPath: string; walkError: 'ENOENT' | 'ELOOP' | null; }): DotWalkError; /** ELOOP: a link loop stands in the path's walk. A walk refusal, so final * for every layer that re-reads a miss, and a coded fs error, so a * per-operand catch words it where the namespace's own CycleError escaped * every one. The dispatcher throws it for a loop above any name it is handed. * Mirrors Python's eloop. */ export declare function eloop(path: string | { virtual: string; }): DotWalkError; export declare function isDotWalkError(err: unknown): err is DotWalkError; export declare function eisdir(path: string | { virtual: string; }): FsError; export declare function eexist(path: string | { virtual: string; }): FsError; export declare function eacces(path: string | { virtual: string; }, message?: string): FsError; export declare function erofs(path: string | { virtual: string; }, message?: string): FsError; export declare function noXattr(path: string | { virtual: string; }): FsError; export declare function enotempty(path: string | { virtual: string; }): FsError; export declare function einval(path: string | { virtual: string; }, message?: string): FsError; export declare function exdev(path: string | { virtual: string; }): FsError; export declare function readdirError(path: string | { virtual: string; rawPath?: string; }, key: string, isFile: (p: string) => boolean | Promise<boolean>, isDir: (p: string) => boolean | Promise<boolean>): Promise<FsError>; export declare function listingError(path: string | { virtual: string; rawPath?: string; }, key: string, isFile: (p: string) => boolean | Promise<boolean>, isDir: (p: string) => boolean | Promise<boolean>): Promise<FsError>; export declare function noMount(path: string): NoMountError; export declare function isNoMount(err: unknown): boolean; export declare function isMissError(exc: unknown): boolean; export declare function isMissingPath(err: unknown): boolean; export declare function enotsup(vfs: string, op: string, path: string | { virtual: string; rawPath?: string; }): MissingOpError; export declare function walkDeclined(vfs: string, op: string, path: string | { virtual: string; rawPath?: string; }): WalkDeclinedError; export declare function isMissingOp(err: unknown, op: string): boolean; /** * What a diagnostic says about a failure, whatever threw it: the strerror * text for a condition the vocabulary names (EIO reads 'Input/output * error', a path no mount owns 'No such file or directory'), and a store's * own error (an SDK's, an HTTP status on upload) by its message, the only * cause it carries. Never the message of a stamped error, which may name a * real host path. Mirrors Python's `strerror_of`. */ export declare function strerrorOf(err: unknown): string; /** * Whether a failure ends the invocation rather than one write. A catch that * reports a failed write and keeps the line going takes whatever the backend * threw (an SDK's own error carries no code) except this: an abort or a * timeout is the caller's outcome. Mirrors Python's `is_aborting`. */ export declare function isAborting(err: unknown): boolean; export declare function fsStrerror(err: unknown): string | null; export declare function errorVirtualPath(err: unknown): string; export declare function isFsError(err: unknown): boolean; export declare function isEnoent(err: unknown): boolean; export declare function isEnotdir(err: unknown): boolean; export declare function isEfbig(err: unknown): boolean; export declare function isEisdir(err: unknown): boolean; export declare function isEexist(err: unknown): boolean; export declare function isEacces(err: unknown): boolean; export declare function isErofs(err: unknown): boolean; export declare function isRefusal(err: unknown): boolean; export declare function isWalkError(err: unknown): boolean; //# sourceMappingURL=fs.d.ts.map