@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
57 lines • 2.35 kB
TypeScript
import type { VFSStat } from '../../types.ts';
import type { MontyFsBits } from './loader.ts';
/** Whether the row is a regular file: python's `S_ISREG` of its mode. */
export declare function isRegularRow(st: VFSStat): boolean;
/** Whether the row is a directory: python's `S_ISDIR` of its mode. */
export declare function isDirRow(st: VFSStat): boolean;
/**
* One mount row as the guest's stat fields.
*
* The numbers are monty's own `StatResult.file_stat` / `dir_stat`
* rules, replicated rather than imported because the JS package
* exports no `StatResult`: the type bits come from the row, the
* permission bits from its mode, and a directory reports 4096 bytes
* and two links whatever the backend said. Keeping the two hosts on
* one rule is the whole point — `python/mirage/runtime/python/monty/
* stat.py` reaches the same numbers by calling the constructors.
*
* Args:
* st: the mount's row for the path.
*/
/**
* The fields of the guest's `os.stat_result`, spelled the way CPython
* spells them because the guest reads them by those names.
*/
export declare function statFields(st: VFSStat): {
st_mode: number;
st_ino: number;
st_dev: number;
st_nlink: number;
st_uid: number;
st_gid: number;
st_size: number;
st_atime: number;
st_mtime: number;
st_ctime: number;
};
/**
* The guest-side `os.stat_result` for one row.
*
* Wrapped in the engine's `ClassInstance` rather than returned bare:
* a plain object converts structurally and arrives as a dict, so
* `st.st_size` raised AttributeError. The wrapper (new in
* @pydantic/monty 0.0.22) sends the object as a class instance with
* its own name, so attribute access and `repr` both read as CPython's.
* The sequence half of a real `stat_result` does not cross: the guest
* cannot subscript, iterate or take `len` of the answer, because the
* JS input encoder cannot construct a NamedTuple node. The protocol
* supports it, and Python sends a real `StatResult`; the JS engine
* cannot send that value back. This also prevents `os.chdir()`, which
* requires a native NamedTuple stat result to validate the directory.
*
* Args:
* bits: the loaded engine's pieces.
* st: the mount's row for the path.
*/
export declare function statResult(bits: MontyFsBits, st: VFSStat): object;
//# sourceMappingURL=stat.d.ts.map