Skip to main content
DiskResource mounts a directory on the host filesystem. Reads and writes go through node:fs against the configured root.
Node only. The browser SDK has no kernel filesystem; use OPFS instead.

Install

pnpm add @struktoai/mirage-node

Config

import { DiskResource, MountMode, Workspace } from '@struktoai/mirage-node'

const disk = new DiskResource({ root: '/Users/me/data' })
const ws = new Workspace({ '/disk': disk }, { mode: MountMode.WRITE })

await ws.execute('echo hello | tee /disk/note.txt')
await ws.execute('cat /disk/note.txt')
FieldDefaultNotes
rootrequiredAbsolute path on the host. Reads and writes are scoped to this directory.

Mount mode

read, write, exec. Use MountMode.EXEC if you need commands to run binaries from the mount.

Snapshot behavior

DiskResource.toState() captures the file tree as bytes. Loading a snapshot back doesn’t re-create the directory; pass a config file with a fresh root if the original location changed. For behavior shared with Python (filesystem layout, supported shell commands), see the Python Disk docs.