UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

39 lines • 2.2 kB
import type { Accessor } from '../../accessor/base.ts'; import { ContentType, FileStat, FileType, type PathSpec } from '../../types.ts'; import type { ExtraFn, Guard } from './readdir.ts'; import { type DetectFn, type ScopeMatch } from './scope.ts'; export type StatHook<A extends Accessor> = (accessor: A, match: ScopeMatch, path: PathSpec, entry: FileStat | null, parent: FileStat | null) => Promise<FileStat>; export type RowFn = (name: string, ident: string, options?: { size?: number | null; modified?: string | null; extra?: Readonly<Record<string, unknown>>; }) => FileStat; /** * The row most id-addressed nodes share, keyed by an id field: the listed * name, size and modified time, and the node's id under `idField` in * `extra`, with whatever else the lister keeps for a child listing to read * back. A kind whose shape differs builds its own row instead. * * `kind` is the node's kind: a FileType for a non-regular node (a * directory), a ContentType for a regular file, whose node kind is then * FILE, or undefined for a regular file typed by its name (a mail * attachment). Mirrors `entry_stat` in `mirage/core/hierarchy/stat.py`. */ export declare function entryStat(idField: string, kind?: FileType | ContentType): RowFn; /** * Build a hierarchy stat: the listed row, or a shape the kind holds. * * A path its parent's listing names answers with that row, which the mount * hands in (`entry`). A kind whose existence the API answers directly has a * guard instead, and one that exists by construction (the top-level * directories) needs no proof; both answer the shape their scope gives them. * An override replaces the whole answer for a kind with a bespoke stat, * handed what is at the path and at its parent. Mirrors `make_stat` in * `mirage/core/hierarchy/stat.py`. */ export declare function makeStat<A extends Accessor>(detect: DetectFn, options?: { guards?: Readonly<Record<string, Guard<A>>>; extras?: Readonly<Record<string, ExtraFn>>; overrides?: Readonly<Record<string, StatHook<A>>>; }): (accessor: A, path: PathSpec, entry?: FileStat | null, parent?: FileStat | null) => Promise<FileStat>; //# sourceMappingURL=stat.d.ts.map