> ## Documentation Index
> Fetch the complete documentation index at: https://docs.microsandbox.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Volumes

> TypeScript SDK - Volume API reference

Create and manage named volumes: persistent storage that lives independently of any sandbox. Build a volume, look one up, read and write its files from the host, then delete it. See [Volumes](/sandboxes/volumes) for usage examples and patterns.

<p className="msb-label" id="typical-flow">Typical flow</p>

```typescript theme={null}
import { Volume } from "microsandbox";

const data = await Volume.builder("my-data")    // 1. configure
  .label("env", "prod")
  .create();                                    // 2. create on disk

const vfs = data.fs();                          // 3. host-side I/O
await vfs.write("seed.txt", "hello");
console.log(await vfs.list(""));

await Volume.remove("my-data");                 // 4. delete
```

## Static methods

#### <span className="msb-recv">Volume.</span><span className="msb-hn">builder()</span>

```typescript theme={null}
static builder(name: string): VolumeBuilder
```

<Accordion title="Example">
  ```typescript theme={null}
  const data = await Volume.builder("my-data")
    .label("env", "prod")
    .create();
  ```
</Accordion>

Begin building a named volume. Directory-backed volumes are the default. Call `.disk().size(...)` for a disk-backed volume. See [`VolumeBuilder`](#volumebuilder) for all options.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>name</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Volume name.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="#volume-builder">VolumeBuilder</a></div>
    <div className="msb-param-desc">Fluent builder for configuring the volume.</div>
  </div>
</div>

#### <span className="msb-recv">Volume.</span><span className="msb-hn">get()</span>

```typescript theme={null}
static get(name: string): Promise<VolumeHandle>
```

<Accordion title="Example">
  ```typescript theme={null}
  const handle = await Volume.get("my-data");
  console.log(handle.usedBytes);
  ```
</Accordion>

Get a live handle to an existing named volume. A live handle supports `.fs()` and `.remove()`, unlike the read-only handles returned by [`list()`](#volume-list).

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>name</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Volume name.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="#volumehandle">Promise\<VolumeHandle></a></div>
    <div className="msb-param-desc">Live handle with metadata, filesystem access, and removal.</div>
  </div>
</div>

#### <span className="msb-recv">Volume.</span><span className="msb-hn">list()</span>

```typescript theme={null}
static list(): Promise<VolumeHandle[]>
```

<Accordion title="Example">
  ```typescript theme={null}
  for (const v of await Volume.list()) {
    console.log(`${v.name} — ${v.kind} — ${v.usedBytes} bytes`);
  }
  ```
</Accordion>

List all named volumes. Handles returned here are **read-only**: calling `.fs()` or `.remove()` on them throws. Call [`Volume.get(name)`](#volume-get) to upgrade to a live handle.

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="#volumehandle">Promise\<VolumeHandle\[]></a></div>
    <div className="msb-param-desc">All volumes, as read-only handles.</div>
  </div>
</div>

#### <span className="msb-recv">Volume.</span><span className="msb-hn">remove()</span>

```typescript theme={null}
static remove(name: string): Promise<void>
```

<Accordion title="Example">
  ```typescript theme={null}
  await Volume.remove("my-data");
  ```
</Accordion>

Delete a named volume and its contents. Fails if the volume is currently mounted by a sandbox.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>name</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Volume name.</div>
  </div>
</div>

## Instance methods

#### <span className="msb-recv">volume.</span><span className="msb-hn">name</span>

```typescript theme={null}
get name(): string
```

The volume's name.

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Volume name.</div>
  </div>
</div>

#### <span className="msb-recv">volume.</span><span className="msb-hn">path</span>

```typescript theme={null}
get path(): string
```

Absolute host path to the volume's directory. By default volumes live under `~/.microsandbox/volumes/<name>/`.

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Absolute host directory path.</div>
  </div>
</div>

#### <span className="msb-recv">volume.</span><span className="msb-hn">fs()</span>

```typescript theme={null}
fs(): VolumeFs
```

<Accordion title="Example">
  ```typescript theme={null}
  const vfs = data.fs();
  await vfs.write("seed.txt", "hello");
  console.log(await vfs.readToString("seed.txt"));
  ```
</Accordion>

Get a host-side filesystem handle for this volume's directory. Reads and writes happen directly on the host, with no sandbox running. See [`VolumeFs`](#volumefs-methods) for the full API.

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="#volumefs">VolumeFs</a></div>
    <div className="msb-param-desc">Host-side filesystem handle.</div>
  </div>
</div>

## VolumeBuilder

Fluent builder for a named volume. Obtained via [`Volume.builder(name)`](#volume-builder). Directory-backed volumes are the default; call [`disk()`](#disk) plus [`size()`](#size) for a disk-backed volume. Every setter returns the builder, so calls chain.

#### <span className="msb-recv">.</span><span className="msb-hn">directory()</span>

```typescript theme={null}
directory(): this
```

Create a directory-backed volume. This is the default, so calling it is only needed for clarity.

#### <span className="msb-recv">.</span><span className="msb-hn">disk()</span>

```typescript theme={null}
disk(): this
```

<Accordion title="Example">
  ```typescript theme={null}
  const dockerData = await Volume.builder("docker-data")
    .disk()
    .size(20 * 1024)
    .create();
  ```
</Accordion>

Create a raw ext4 disk-backed volume. Pair with [`size()`](#size) to set the capacity.

#### <span className="msb-recv">.</span><span className="msb-hn">size()</span>

```typescript theme={null}
size(mib: number): this
```

Set the disk capacity in MiB. Required after [`disk()`](#disk).

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>mib</code><span className="msb-type">number</span></div>
    <div className="msb-param-desc">Disk capacity in MiB.</div>
  </div>
</div>

#### <span className="msb-recv">.</span><span className="msb-hn">quota()</span>

```typescript theme={null}
quota(mib: number): this
```

Record a quota in MiB as metadata for directory-backed volumes.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>mib</code><span className="msb-type">number</span></div>
    <div className="msb-param-desc">Quota in MiB.</div>
  </div>
</div>

#### <span className="msb-recv">.</span><span className="msb-hn">label()</span>

```typescript theme={null}
label(key: string, value: string): this
```

Add a metadata label. Can be called multiple times.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>key</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Label key.</div>
  </div>

  <div className="msb-param">
    <div className="msb-param-key"><code>value</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Label value.</div>
  </div>
</div>

#### <span className="msb-recv">.</span><span className="msb-hn">build()</span>

```typescript theme={null}
build(): { name: string; kind: string; quotaMib?: number | null; capacityMib?: number | null; labels: Record<string, string> }
```

Materialize the volume configuration without creating the volume on disk. To create it, use [`create()`](#create) instead. The returned config object is the internal `NapiVolumeConfig` shape (not a public export).

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key">
      <span className="msb-type">
        {`{ name, kind, quotaMib?, capacityMib?, labels }`}
      </span>
    </div>

    <div className="msb-param-desc">Frozen volume configuration object.</div>
  </div>
</div>

#### <span className="msb-recv">.</span><span className="msb-hn">create()</span>

```typescript theme={null}
create(): Promise<Volume>
```

<Accordion title="Example">
  ```typescript theme={null}
  const data = await Volume.builder("my-data").create();
  ```
</Accordion>

Build and create the volume on disk, returning a [`Volume`](#instance-methods).

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="#instance-methods">Promise\<Volume></a></div>
    <div className="msb-param-desc">The created volume.</div>
  </div>
</div>

## VolumeFs methods

Host-side filesystem operations on a volume's directory. Obtained via [`volume.fs()`](#volume-fs) or [`VolumeHandle.fs()`](#volumehandle). All operations run directly on the host without booting a sandbox. Paths are relative to the volume's root directory. Every method is async.

#### <span className="msb-recv">vfs.</span><span className="msb-hn">read()</span>

```typescript theme={null}
read(path: string): Promise<Uint8Array>
```

<Accordion title="Example">
  ```typescript theme={null}
  const bytes = await vfs.read("data.bin");
  ```
</Accordion>

Read a file's full contents as bytes.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Path relative to the volume root.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><span className="msb-type">Promise\<Uint8Array></span></div>
    <div className="msb-param-desc">File contents.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">readToString()</span>

```typescript theme={null}
readToString(path: string): Promise<string>
```

<Accordion title="Example">
  ```typescript theme={null}
  const text = await vfs.readToString("config.json");
  ```
</Accordion>

Read a file's full contents as a UTF-8 string.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Path relative to the volume root.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><span className="msb-type">Promise\<string></span></div>
    <div className="msb-param-desc">Decoded file contents.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">readStream()</span>

```typescript theme={null}
readStream(path: string): Promise<VolumeFsReadStream>
```

<Accordion title="Example">
  ```typescript theme={null}
  const stream = await vfs.readStream("large.bin");
  for await (const chunk of stream) {
    console.log(chunk.byteLength);
  }
  ```
</Accordion>

Open a streaming reader for a file, for chunked reads of large files without loading them fully into memory.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Path relative to the volume root.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="#volumefsreadstream">Promise\<VolumeFsReadStream></a></div>
    <div className="msb-param-desc">Async-iterable read stream.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">write()</span>

```typescript theme={null}
write(path: string, data: Uint8Array | string): Promise<void>
```

<Accordion title="Example">
  ```typescript theme={null}
  await vfs.write("seed.txt", "hello");
  ```
</Accordion>

Write a file, replacing any existing contents. Strings are encoded as UTF-8.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Path relative to the volume root.</div>
  </div>

  <div className="msb-param">
    <div className="msb-param-key"><code>data</code><span className="msb-type">Uint8Array | string</span></div>
    <div className="msb-param-desc">Bytes, or a UTF-8 string.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">writeStream()</span>

```typescript theme={null}
writeStream(path: string): Promise<VolumeFsWriteSink>
```

<Accordion title="Example">
  ```typescript theme={null}
  const sink = await vfs.writeStream("out.bin");
  await sink.write(chunk);
  await sink.close();
  ```
</Accordion>

Open a streaming writer for a file, for chunked writes of large files.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Path relative to the volume root.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="#volumefswritesink">Promise\<VolumeFsWriteSink></a></div>
    <div className="msb-param-desc">Write sink; call <code>close()</code> when done.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">list()</span>

```typescript theme={null}
list(path: string): Promise<FsEntry[]>
```

<Accordion title="Example">
  ```typescript theme={null}
  for (const e of await vfs.list("")) {
    console.log(e.path, e.kind, e.size);
  }
  ```
</Accordion>

List the entries in a directory. Pass `""` for the volume root.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Directory path relative to the volume root.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="/sdk/typescript/filesystem#fsentry">Promise\<FsEntry\[]></a></div>
    <div className="msb-param-desc">Directory entries.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">mkdir()</span>

```typescript theme={null}
mkdir(path: string): Promise<void>
```

<Accordion title="Example">
  ```typescript theme={null}
  await vfs.mkdir("cache/images");
  ```
</Accordion>

Create a directory, including any missing parents.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Directory path relative to the volume root.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">removeDir()</span>

```typescript theme={null}
removeDir(path: string): Promise<void>
```

<Accordion title="Example">
  ```typescript theme={null}
  await vfs.removeDir("cache");
  ```
</Accordion>

Recursively remove a directory and its contents.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Directory path relative to the volume root.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">remove()</span>

```typescript theme={null}
remove(path: string): Promise<void>
```

<Accordion title="Example">
  ```typescript theme={null}
  await vfs.remove("seed.txt");
  ```
</Accordion>

Remove a single file.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">File path relative to the volume root.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">copy()</span>

```typescript theme={null}
copy(from: string, to: string): Promise<void>
```

<Accordion title="Example">
  ```typescript theme={null}
  await vfs.copy("seed.txt", "backup/seed.txt");
  ```
</Accordion>

Copy a file or directory from one path to another.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>from</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Source path relative to the volume root.</div>
  </div>

  <div className="msb-param">
    <div className="msb-param-key"><code>to</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Destination path relative to the volume root.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">rename()</span>

```typescript theme={null}
rename(from: string, to: string): Promise<void>
```

<Accordion title="Example">
  ```typescript theme={null}
  await vfs.rename("draft.txt", "final.txt");
  ```
</Accordion>

Move or rename a file or directory.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>from</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Source path relative to the volume root.</div>
  </div>

  <div className="msb-param">
    <div className="msb-param-key"><code>to</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Destination path relative to the volume root.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">stat()</span>

```typescript theme={null}
stat(path: string): Promise<FsMetadata>
```

<Accordion title="Example">
  ```typescript theme={null}
  const meta = await vfs.stat("seed.txt");
  console.log(meta.size, meta.kind);
  ```
</Accordion>

Get metadata for a file or directory.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Path relative to the volume root.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><a className="msb-type" href="/sdk/typescript/filesystem#fsmetadata">Promise\<FsMetadata></a></div>
    <div className="msb-param-desc">Kind, size, mode, and timestamps.</div>
  </div>
</div>

#### <span className="msb-recv">vfs.</span><span className="msb-hn">exists()</span>

```typescript theme={null}
exists(path: string): Promise<boolean>
```

<Accordion title="Example">
  ```typescript theme={null}
  if (await vfs.exists("seed.txt")) {
    await vfs.remove("seed.txt");
  }
  ```
</Accordion>

Check whether a path exists.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>path</code><span className="msb-type">string</span></div>
    <div className="msb-param-desc">Path relative to the volume root.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><span className="msb-type">Promise\<boolean></span></div>
    <div className="msb-param-desc"><code>true</code> if the path exists.</div>
  </div>
</div>

## Types

### VolumeHandle

<p className="msb-backref">Returned by <a href="#volume-get">Volume.get()</a> · <a href="#volume-list">Volume.list()</a></p>

A handle to an existing named volume, carrying its metadata. Handles from [`Volume.get()`](#volume-get) are **live**: `.fs()` and `.remove()` work. Handles in the array from [`Volume.list()`](#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`](#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

<p className="msb-backref">Returned by <a href="#volume-fs">volume.fs()</a> · <a href="#volumehandle">VolumeHandle.fs()</a></p>

Host-side filesystem operations on a volume's directory. The methods mirror [`SandboxFsOps`](/sdk/typescript/filesystem) but run directly on the host with no sandbox booted. See the [VolumeFs methods](#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`](#volumefsreadstream)`>`           | Open a streaming reader            |
| write(path, data)  | `Promise<void>`                                                    | Write a file (bytes or string)     |
| writeStream(path)  | `Promise<`[`VolumeFsWriteSink`](#volumefswritesink)`>`             | Open a streaming writer            |
| list(path)         | `Promise<`[`FsEntry`](/sdk/typescript/filesystem#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`](/sdk/typescript/filesystem#fsmetadata)`>` | Get file metadata                  |
| exists(path)       | `Promise<boolean>`                                                 | Check whether a path exists        |

### VolumeFsReadStream

<p className="msb-backref">Returned by <a href="#volumefs-methods">VolumeFs.readStream()</a></p>

A streaming reader over a volume file. Implements `AsyncIterable<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

<p className="msb-backref">Returned by <a href="#volumefs-methods">VolumeFs.writeStream()</a></p>

A streaming writer for a volume file. Implements `AsyncDisposable`, 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`)           |
