Expand description
Filesystem methods + path guards + supporting types + the in-process VirtualFileSystem mount
contract.
Ported from packages/core/src/agent-os.ts (fs methods + _assertSafeAbsolutePath /
_assertWritableAbsolutePath), runtime-compat.ts (VirtualStat, VirtualFileSystem), and
filesystem-snapshot.ts (snapshot export types).
Parity notes: every method runs the path guards first; mkdir recursive uses the WRITABLE guard,
non-recursive uses the SAFE guard. writeFile does NOT create parents; writeFiles DOES. Batch
methods NEVER reject (per-entry error strings). Snapshot wire format keeps octal-string mode
and utf8/base64 content verbatim.
Structs§
- Batch
Read Result - Result of a single batch read (never an
Err).contentis None on failure. - Batch
Write Entry - A batch write entry.
- Batch
Write Result - Result of a single batch write (never an
Err). - Delete
Options - Options for
delete. - DirEntry
- An entry returned by
readdir_recursive. - Filesystem
Entry - A single snapshot entry.
modeis an OCTAL STRING (e.g."0755").contentis utf8 or base64. - Filesystem
Snapshot Entries { entries: FilesystemEntry[] }.- Filesystem
Snapshot Export { format: "agentos-filesystem-snapshot-v1"; filesystem: { entries } }.- Mkdir
Options - Options for
mkdir. - Mount
FsOptions - Options for
mount_fs. - Mounted
Fs - A registered in-process mount: the live
VirtualFileSystemdriver plus theread_onlyflag forwarded fromMountFsOptions. TSmountFspasses{ readOnly }through tokernel.mountFs, which enforces read-only mount semantics; the flag is retained here so the option is not structurally dropped before the mount-dispatch path consumes it. - Readdir
Recursive Options - Options for
readdir_recursive.max_depthNone = unlimited, Some(0) = immediate children only;excludematches basenames at any depth. - Root
Snapshot Export { kind: "snapshot-export"; source }.- Virtual
DirEntry - A directory entry with a known type, returned by
read_dir_with_typeson the mount contract. - Virtual
Stat - Stat result. 16 fields;
*_mstime fields aref64(JS ms, possibly fractional).
Enums§
- DirEntry
Type - The type of a directory entry.
- File
Content string | Uint8Arrayfile content.- Filesystem
Entry Encoding - Snapshot content encoding.
- Snapshot
Export Kind - The literal
"snapshot-export"tag.
Traits§
- Virtual
File System - The 25-method mount backend contract. A
mount_fsdriver implements this trait; it is a live in-process object and cannot cross an RPC boundary.