import type { IndexCacheStore } from './cache/index/store.ts'; import type { CommandRule } from './policy/types.ts'; import type { FindOptions } from './resource/base.ts'; export type JsonValue = null | boolean | number | string | JsonValue[] | { [k: string]: JsonValue; }; export type ErrorOf = (response: Response, body: string) => Error; export type PageFetch = (cursor: string | null) => Promise>; export declare const MountMode: Readonly<{ readonly READ: "read"; readonly WRITE: "write"; readonly EXEC: "exec"; }>; export type MountMode = (typeof MountMode)[keyof typeof MountMode]; /** * How a mount is exposed to the outside world. * * `vfs` is the default: the mount lives only inside mirage's own filesystem * and is reached through the command surface, with nothing registered with * the kernel. `fuse` and `fskit` additionally expose it as a real mountpoint. * * `fskit` is macOS 15.4+ only and needs no kernel extension. It has no * `direct_io` equivalent, so it serves correct reads only for resources that * set `sizesAlwaysKnown`; the mount-time guard warns about resources whose * size-unknown files will read as empty. Writes are also limited: appends and * metadata ops persist, but the macFUSE FSKit shim flushes pages a file did * not already have (a new file, or truncate-then-write) as NUL bytes (pinned * in `integ/fuse/truth_fskit.json`). There is deliberately no `auto`: * auto-selecting fskit would silently degrade every API-backed mount. */ export declare const MountBackend: Readonly<{ readonly VFS: "vfs"; readonly FUSE: "fuse"; readonly FSKIT: "fskit"; }>; export type MountBackend = (typeof MountBackend)[keyof typeof MountBackend]; /** Backends that register a real mountpoint with the kernel. */ export declare const KERNEL_BACKENDS: readonly MountBackend[]; export declare const MOUNT_MODE_RANK: Readonly>; /** The weaker of two mount modes on the READ < WRITE < EXEC lattice. */ export declare function weakerMode(a: MountMode, b: MountMode): MountMode; /** * What the data door treats as nonexistent for one session. * * A sibling of `Session.mountModes`: per-session narrowing that the * doors enforce, null-on-the-session means unrestricted. Hiding is * "does not exist", never "forbidden" — matching paths answer ENOENT * and drop out of listings, which is what makes a hide the way a profile * keeps a session away from a mount: naming mounts only narrows their * modes, and a refusal would hand back the name. * * `paths` are exact virtual paths; hiding a path hides its whole * subtree (a name you cannot see cannot be a parent you traverse), so * a mount root entry hides the mount. `patterns` are globs: one with * no `/` matches any single name component anywhere; one containing * `/` is anchored to the full virtual path, with `*` crossing slashes * exactly as GNU `find -path` does. */ export interface HiddenPaths { readonly paths?: readonly string[]; readonly patterns?: readonly string[]; } /** * One `show` entry of a profile's path axis, compiled. * * `path` is the entry as written: an exact subtree or an anchored * pattern, always absolute (a slashless name pattern is refused at * validation, because a show anchors to a place and a name pattern * names none). `mode` is what the entry states for its subtree; null * for a list-form entry, which inherits the mount's. */ export interface ShowEntry { readonly path: string; readonly mode: MountMode | null; } /** * The `show` half of one session's path axis. * * A sibling of `HiddenPaths`: per-session state the doors read, * null-on-the-session means the document states no show. An entry does * two things, each on the one anchor-depth rule: it re-opens a subtree * inside a hidden region when its anchor is deeper than the hide's, * and it states the mode in force below its anchor when it carries * one. */ export interface ShownPaths { readonly entries: readonly ShowEntry[]; } /** * What the session door treats as unset for one session. * * Enforced where env leaves the session: `get` misses, `snapshot` * omits, expansion sees unset. Field names differ from `HiddenPaths` * on purpose — the planes' matching semantics differ, so the specs * are not interchangeable. */ export interface HiddenVars { readonly names?: readonly string[]; readonly patterns?: readonly string[]; } /** * What a command's own I/O asks before touching an entry it reached * below its operands. * * The admission gate judges the paths a line names; a walk (`grep -r`, * `find`, `du`, `cp -r`, `tar`) then reaches entries no rule has seen. * The dispatcher binds the admitted command's gate to the session * context for the command's run, and the commands tier reads it there, * so the tier that enforces the rules never imports the tier that * states them. `scoped` is whether a path rule in force reads this * command's paths at all; a native walk (a backend's own find or du) * yields to the guarded readdir walk while it is set, so each entry * passes the gate. `check` throws when a rule in force refuses the entry * for the running command and returns when the command may touch it. */ export interface EntryGate { readonly scoped: boolean; /** * The ask rules this line runs under a grant for. Read by the op * doors, which see the same entries from below and would otherwise * re-derive a verdict that knows nothing of the nod the gate already * took. */ readonly granted: readonly CommandRule[]; check(virtual: string): void; } /** * Coerce a mount mode, accepting cumulative filesystem aliases. * * The mode ladder is cumulative (exec implies write implies read), so * only the cumulative spellings `r`, `rw`, `rwx` alias the modes; * bit-style forms like `w` or `x` are rejected. */ export declare function parseMountMode(value: string): MountMode; export declare const ConsistencyPolicy: Readonly<{ readonly LAZY: "lazy"; readonly ALWAYS: "always"; }>; export type ConsistencyPolicy = (typeof ConsistencyPolicy)[keyof typeof ConsistencyPolicy]; /** * Behaviour when a remote resource's live fingerprint differs from the * value recorded at snapshot time. */ export declare const DriftPolicy: Readonly<{ /** Raise ContentDriftError on first mismatch. */ readonly STRICT: "strict"; /** Skip drift checks entirely. */ readonly OFF: "off"; }>; export type DriftPolicy = (typeof DriftPolicy)[keyof typeof DriftPolicy]; /** * Behaviour when a command's output exceeds its limit cap. * TRUNCATE returns the truncated bytes + a notice on stderr. * ERROR returns no stdout and exits 1 with the same notice. */ export declare const OnExceed: Readonly<{ readonly ERROR: "error"; readonly TRUNCATE: "truncate"; }>; export type OnExceed = (typeof OnExceed)[keyof typeof OnExceed]; export interface LimitInit { maxBytes?: number | null; maxLines?: number | null; timeoutSeconds?: number | null; onExceed?: OnExceed; } /** * A bound on a result: the policy layer's limit arm and the shape * every cap config parses into. Carries its fields inline (the Deny * precedent: an action is its payload). `kind` is the wire * discriminant; `aggr` is the composition law (AND to the tightest * per bound, ANY on error mode). */ export declare class Limit { readonly kind: "limit"; readonly maxBytes: number | null; readonly maxLines: number | null; readonly timeoutSeconds: number | null; readonly onExceed: OnExceed; constructor(init?: LimitInit); /** * Aggregate several limits using each field's declared rule. * * Reads the rules off LIMIT_AGGR rather than naming the fields here, so a * new bound composes as soon as it is declared — the same property Python * gets from walking `model_fields` for each field's `Aggr(rule)`. Returns * null when nothing is configured. Used wherever bounds stack (policy * composition, cross-mount fan-out, layered configs). */ static aggr(limits: Iterable): Limit | null; } /** * Provenance of a result: who produced it, and where. * * Rides the IO envelope from the dispatch site to the workspace * boundary; merge keeps the rightmost producer, so this names the * command whose stream the caller actually sees. Post-layer policies * (output caps today; budgets and attribution later) read it as * context. Facts only: no policy reads a decision off the envelope; * the one a chain hands down is written beside it as * `IOResult.refusal` after the last hook has spoken. `declared` is * the bound the command's own registration declared, * when the dispatch site knows it (e.g. a CLI leaf). */ export interface Producer { readonly command: string; readonly prefixes: readonly string[]; readonly declared: Limit | null; } export type RefusalKind = 'deny' | 'pending' | 'failed'; export type RefusalScope = 'command' | 'operand'; /** * Why a line did not run, for the caller that reads the result. * * stderr keeps bash's voice (`: Permission denied`), which says * nothing about who refused or why; this record carries that beside * the envelope, so a host or an agent adapter can show the reason * without the shell having to. null on every run that was not * refused, and absent on the 127 `command not found` row, which must * not reveal that the word names anything. `kind` is `deny` for a * policy's refusal, `pending` for an ask the host has not answered, * `failed` for a policy that raised and so refused by default; * `policy` is the class name of the policy that spoke, empty for an * ask, which belongs to the host; `askId` is the approval to quote, * for `pending`. Mirrors the Python `Refusal`. */ export interface Refusal { readonly kind: RefusalKind; readonly reason: string; readonly policy: string; readonly scope: RefusalScope; readonly askId: string | null; } export declare const ResourceName: Readonly<{ readonly DISK: "disk"; readonly S3: "s3"; readonly RAM: "ram"; readonly GITHUB: "github"; readonly LINEAR: "linear"; readonly GCAL: "gcal"; readonly GDOCS: "gdocs"; readonly GSHEETS: "gsheets"; readonly GSLIDES: "gslides"; readonly GDRIVE: "gdrive"; readonly ONEDRIVE: "onedrive"; readonly SHAREPOINT: "sharepoint"; readonly DROPBOX: "dropbox"; readonly BOX: "box"; readonly SLACK: "slack"; readonly DISCORD: "discord"; readonly GMAIL: "gmail"; readonly TRELLO: "trello"; readonly MONGODB: "mongodb"; readonly GRIDFS: "gridfs"; readonly NOTION: "notion"; readonly LANGFUSE: "langfuse"; readonly JAEGER: "jaeger"; readonly SSH: "ssh"; readonly REDIS: "redis"; readonly GCS: "gcs"; readonly OCI: "oci"; readonly R2: "r2"; readonly EMAIL: "email"; readonly OPFS: "opfs"; readonly SUPABASE: "supabase"; readonly POSTGRES: "postgres"; readonly LANCEDB: "lancedb"; readonly CHROMA: "chroma"; readonly DIFY: "dify"; readonly MEM0: "mem0"; readonly QDRANT: "qdrant"; readonly HF_BUCKETS: "hf_buckets"; readonly HF_DATASETS: "hf_datasets"; readonly HF_MODELS: "hf_models"; readonly HF_SPACES: "hf_spaces"; readonly NEXTCLOUD: "nextcloud"; readonly DATABRICKS_VOLUME: "databricks_volume"; readonly MINIO: "minio"; readonly CEPH: "ceph"; readonly SEAWEEDFS: "seaweedfs"; readonly WASABI: "wasabi"; readonly BACKBLAZE: "backblaze"; readonly DIGITALOCEAN: "digitalocean"; readonly TENCENT: "tencent"; readonly ALIYUN: "aliyun"; readonly SCALEWAY: "scaleway"; readonly QINGSTOR: "qingstor"; readonly HISTORY: "history"; }>; export type ResourceName = (typeof ResourceName)[keyof typeof ResourceName]; /** * POSIX file type (the `st_mode` kind), the switch behavior branches on. * * One per entry, always present. Directory and symlink are their own * kinds; every regular file is FILE and carries its content shape on * `FileStat.content`. Distinct from ContentType, which is only a * rendering hint for a FILE. Mirrors `FileType` in `mirage/types.py`. * * The full POSIX set is enumerated so the model is comprehensive. * DIRECTORY, FILE, SYMLINK and CHAR_DEVICE (the /dev mount) are produced * today; BLOCK_DEVICE, FIFO and SOCKET are declared but not yet emitted, * and the render/derivation tables (find letter, st_mode bits, ls char) * grow a row for one the moment a backend starts producing it. */ export declare const FileType: Readonly<{ readonly DIRECTORY: "directory"; readonly FILE: "file"; readonly SYMLINK: "symlink"; readonly CHAR_DEVICE: "char_device"; readonly BLOCK_DEVICE: "block_device"; readonly FIFO: "fifo"; readonly SOCKET: "socket"; }>; export type FileType = (typeof FileType)[keyof typeof FileType]; /** * A regular file's content shape: the rendering hint (file/ls color). * * Only meaningful for a FILE; a directory or symlink carries none. Not a * node kind: nothing branches control flow on it. Mirrors `ContentType` * in `mirage/types.py`. */ export declare const ContentType: Readonly<{ readonly TEXT: "text"; readonly BINARY: "binary"; readonly JSON: "json"; readonly CSV: "csv"; readonly IMAGE_PNG: "image/png"; readonly IMAGE_JPEG: "image/jpeg"; readonly IMAGE_GIF: "image/gif"; readonly ZIP: "application/zip"; readonly GZIP: "application/gzip"; readonly PDF: "application/pdf"; }>; export type ContentType = (typeof ContentType)[keyof typeof ContentType]; export declare const LINK_TARGET_KEY = "link_target"; export declare const DEVICE_NUMBERS_KEY = "device_numbers"; /** * The metadata fields a `setattr` writes, all optional. * * Spelled the way the op, the CommandOpts bag and the guest bridge * spell them, so one fact keeps one name from a shell line down to a * guest's utime. `nofollow` is not a field but the AT_SYMLINK_NOFOLLOW * bit: it writes the link entry's own attrs rather than its target's. * Lives here rather than beside either consumer because the ops facade * and the runtime bridge both take it and neither may import the * other. */ export interface SetAttrFields { mode?: number; uid?: number | string; gid?: number | string; atime?: string; mtime?: string; nofollow?: boolean; } export interface FileStatInit { name: string; size?: number | null; modified?: string | null; fingerprint?: string | null; revision?: string | null; type: FileType; content?: ContentType | null; mode?: number | null; uid?: number | string | null; gid?: number | string | null; atime?: string | null; extra?: Record; } export declare class FileStat { readonly name: string; readonly size: number | null; readonly modified: string | null; readonly fingerprint: string | null; readonly revision: string | null; readonly type: FileType; readonly content: ContentType | null; readonly mode: number | null; readonly uid: number | string | null; readonly gid: number | string | null; readonly atime: string | null; readonly extra: Record; constructor(init: FileStatInit); with(update: Partial): FileStat; } export declare const FileChangeKind: Readonly<{ readonly CREATE: "create"; readonly UPDATE: "update"; readonly DELETE: "delete"; readonly MOVE: "move"; readonly UNKNOWN: "unknown"; }>; export type FileChangeKind = (typeof FileChangeKind)[keyof typeof FileChangeKind]; export interface FileMetadataInit { fingerprint?: string | null; size?: number | null; modified?: string | null; } export declare class FileMetadata { readonly fingerprint: string | null; readonly size: number | null; readonly modified: string | null; constructor(init?: FileMetadataInit); } export interface FileEventInit { kind: FileChangeKind; path: PathSpec; timestamp: Date; previousPath?: PathSpec | null; metadata?: FileMetadata | null; } export declare class FileEvent { readonly kind: FileChangeKind; readonly path: PathSpec; readonly timestamp: Date; readonly previousPath: PathSpec | null; readonly metadata: FileMetadata | null; constructor(init: FileEventInit); } export interface DeltaInit { changes: readonly FileEvent[]; checkpoint: string | null; } export declare class Delta { readonly changes: readonly FileEvent[]; readonly checkpoint: string | null; constructor(init: DeltaInit); } export interface WalkEntry { virtual: string; isDir: boolean; fingerprint: string | null; size?: number | null; modified?: string | null; } export type WalkFn = (root: PathSpec) => AsyncIterable; export declare const OverflowPolicy: Readonly<{ readonly COLLAPSE: "collapse"; readonly DROP_OLDEST: "drop_oldest"; readonly ERROR: "error"; }>; export type OverflowPolicy = (typeof OverflowPolicy)[keyof typeof OverflowPolicy]; export declare const CapacityState: { readonly QUOTA: "quota"; readonly ELASTIC: "elastic"; readonly NA: "na"; readonly UNKNOWN: "unknown"; }; export type CapacityState = (typeof CapacityState)[keyof typeof CapacityState]; export interface CapacityResult { state: CapacityState; total?: number | null; used?: number | null; available?: number | null; inodes?: number | null; inodesUsed?: number | null; inodesFree?: number | null; } export type ReadBytesFn = (...args: Args) => Promise; export type ReadStreamFn = (...args: Args) => AsyncIterable; export type CopyFn = (...args: Args) => Promise; export type MoveFn = (...args: Args) => Promise; export type FindFn = (...args: Args) => Promise; export type ReaddirFn = (...args: Args) => Promise; export type StatFn = (...args: Args) => Promise; export interface NativeCopy { copy: CopyFn; find: FindFn; dirCopy?: CopyFn; /** * Lets the per-entry policy path (--update/--backup, which cannot use a * whole-tree dirCopy) still materialize directories that hold no files. */ mkdir?: CopyFn<[path: PathSpec]>; } export interface PrimitiveCopy { readBytes: ReadBytesFn; write: CopyFn<[target: PathSpec, data: Uint8Array]>; mkdir: CopyFn<[path: PathSpec]>; readdir: ReaddirFn; } export type CopyStrategy = NativeCopy | PrimitiveCopy; export interface NativeMove { rename: MoveFn; } export interface PrimitiveMove { readBytes: ReadBytesFn; write: MoveFn<[target: PathSpec, data: Uint8Array]>; mkdir: MoveFn<[path: PathSpec]>; readdir: ReaddirFn; unlink: MoveFn<[path: PathSpec]>; rmdir: MoveFn<[path: PathSpec]>; } export type MoveStrategy = NativeMove | PrimitiveMove; export interface PathSpecInit { virtual: string; directory: string; resourcePath: string; pattern?: string | null; resolved?: boolean; rawPath?: string; } export declare class PathSpec { readonly virtual: string; readonly directory: string; readonly resourcePath: string; readonly pattern: string | null; readonly resolved: boolean; readonly rawPath: string; constructor(init: PathSpecInit); get mountPath(): string; get dir(): PathSpec; child(name: string): string; static fromStrPath(path: string, resourcePath?: string): PathSpec; } export declare function wordText(word: string | PathSpec): string; //# sourceMappingURL=types.d.ts.map