Typical flow
Static methods
Volume.builder()
Example
Example
.disk().size(...) for a disk-backed volume. See VolumeBuilder for all options.
Parameters
namestringReturns
Volume.get()
Example
Example
.fs() and .remove(), unlike the read-only handles returned by list().
Parameters
namestringReturns
Volume.list()
Example
Example
.fs() or .remove() on them throws. Call Volume.get(name) to upgrade to a live handle.
Returns
Volume.remove()
Example
Example
Parameters
namestringInstance methods
volume.name
Returns
volume.path
~/.microsandbox/volumes/<name>/.
Returns
volume.fs()
Example
Example
VolumeFs for the full API.
Returns
VolumeBuilder
Fluent builder for a named volume. Obtained viaVolume.builder(name). Directory-backed volumes are the default; call disk() plus size() for a disk-backed volume. Every setter returns the builder, so calls chain.
.directory()
.disk()
Example
Example
size() to set the capacity.
.size()
disk().
Parameters
mibnumber.quota()
Parameters
mibnumber.label()
Parameters
keystringvaluestring.build()
create() instead. The returned config object is the internal NapiVolumeConfig shape (not a public export).
Returns
.create()
Example
Example
Volume.
Returns
VolumeFs methods
Host-side filesystem operations on a volume’s directory. Obtained viavolume.fs() or VolumeHandle.fs(). All operations run directly on the host without booting a sandbox. Paths are relative to the volume’s root directory. Every method is async.
vfs.read()
Example
Example
Parameters
pathstringReturns
vfs.readToString()
Example
Example
Parameters
pathstringReturns
vfs.readStream()
Example
Example
Parameters
pathstringReturns
vfs.write()
Example
Example
Parameters
pathstringdataUint8Array | stringvfs.writeStream()
Example
Example
Parameters
pathstringReturns
close() when done.vfs.list()
Example
Example
"" for the volume root.
Parameters
pathstringReturns
vfs.mkdir()
Example
Example
Parameters
pathstringvfs.removeDir()
Example
Example
Parameters
pathstringvfs.remove()
Example
Example
Parameters
pathstringvfs.copy()
Example
Example
Parameters
fromstringtostringvfs.rename()
Example
Example
Parameters
fromstringtostringvfs.stat()
Example
Example
Parameters
pathstringReturns
vfs.exists()
Example
Example
Parameters
pathstringReturns
true if the path exists.Types
VolumeHandle
Returned by Volume.get() · Volume.list()
A handle to an existing named volume, carrying its metadata. Handles fromVolume.get() are live: .fs() and .remove() work. Handles in the array from Volume.list() are read-only: those two methods throw, so call Volume.get(name) to upgrade.
| Property / Method | Type | Description |
|---|---|---|
| name | string | Volume name |
| kind | string | Volume kind ("dir" or "disk") |
| quotaMib | number | null | Recorded storage quota in MiB |
| usedBytes | number | Current disk usage in bytes |
| capacityBytes | number | null | Disk capacity in bytes (disk volumes) |
| diskFormat | string | null | Disk image format (disk volumes) |
| diskFstype | string | null | Inner disk filesystem (disk volumes) |
| labels | ReadonlyArray<readonly [string, string]> | Metadata labels |
| createdAt | Date | null | Creation timestamp |
| fs() | VolumeFs | Host-side filesystem (live handles only; throws on read-only handles) |
| remove() | Promise<void> | Delete this volume (live handles only; throws on read-only handles) |
VolumeFs
Returned by volume.fs() · VolumeHandle.fs()
Host-side filesystem operations on a volume’s directory. The methods mirrorSandboxFsOps but run directly on the host with no sandbox booted. See the VolumeFs methods section above for full per-method details.
| Method | Type | Description |
|---|---|---|
| read(path) | Promise<Uint8Array> | Read a file as bytes |
| readToString(path) | Promise<string> | Read a file as a UTF-8 string |
| readStream(path) | Promise<VolumeFsReadStream> | Open a streaming reader |
| write(path, data) | Promise<void> | Write a file (bytes or string) |
| writeStream(path) | Promise<VolumeFsWriteSink> | Open a streaming writer |
| list(path) | Promise<FsEntry[]> | List directory entries |
| mkdir(path) | Promise<void> | Create a directory, with parents |
| removeDir(path) | Promise<void> | Recursively remove a directory |
| remove(path) | Promise<void> | Remove a file |
| copy(from, to) | Promise<void> | Copy a file or directory |
| rename(from, to) | Promise<void> | Move or rename a file or directory |
| stat(path) | Promise<FsMetadata> | Get file metadata |
| exists(path) | Promise<boolean> | Check whether a path exists |
VolumeFsReadStream
Returned by VolumeFs.readStream()
A streaming reader over a volume file. ImplementsAsyncIterable<Uint8Array> and AsyncDisposable, so it works with for await and using.
| Method | Type | Description |
|---|---|---|
| recv() | Promise<Uint8Array | null> | Read the next chunk; null when the stream is exhausted |
| collect() | Promise<Uint8Array> | Drain the stream into a single byte array |
| Symbol.asyncIterator | AsyncIterator<Uint8Array> | Iterate chunks with for await |
| Symbol.asyncDispose | Promise<void> | Mark the stream done (for using) |
VolumeFsWriteSink
Returned by VolumeFs.writeStream()
A streaming writer for a volume file. ImplementsAsyncDisposable, so await using closes it automatically.
| Method | Type | Description |
|---|---|---|
| write(data) | Promise<void> | Write a chunk (Uint8Array or UTF-8 string) |
| close() | Promise<void> | Flush and close the sink; idempotent |
| Symbol.asyncDispose | Promise<void> | Close the sink (for await using) |