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

# Wasabi

> Virtualize a Wasabi bucket from Node or the browser.

`WasabiVFS` mounts one bucket: every object becomes a file and every `/` in a key
a folder. It is the [S3 VFS](https://docs.mirage.strukto.ai/typescript/vfs/s3.md) pointed at Wasabi's
endpoint, so commands behave as they do on S3. Set up credentials as in [Wasabi setup](https://docs.mirage.strukto.ai/home/setup/wasabi.md).

## Install

```bash theme={null}
npm install @struktoai/mirage-node
```

## Configure

```ts theme={null}
import { MountMode, WasabiVFS, Workspace } from '@struktoai/mirage-node'

const wasabi = new WasabiVFS({
  bucket: process.env.WASABI_BUCKET!,
  region: process.env.WASABI_REGION!,
  accessKeyId: process.env.WASABI_ACCESS_KEY_ID!,
  secretAccessKey: process.env.WASABI_SECRET_ACCESS_KEY!,
})
const ws = new Workspace({ '/wasabi': wasabi }, { mode: MountMode.WRITE })

const result = await ws.shell("ls /wasabi && find /wasabi -name '*.csv'")
console.log(result.stdoutText)
await ws.close()
```

`region` also picks the endpoint, `https://s3.<region>.wasabisys.com`,
or `https://s3.wasabisys.com` for `us-east-1`, the default; `endpoint`
replaces it.
A mount takes `MountMode.READ`, `WRITE` or `EXEC`.

### Fields

**bucket** `string` *required*

Name of the bucket to mount.

**accessKeyId** `string`

Access key ID; set it with `secretAccessKey`. Unset uses the AWS SDK credential chain.

**secretAccessKey** `string`

Secret access key paired with `accessKeyId`.

**sessionToken** `string`

Session token for temporary credentials, sent with the access key pair.

**profile** `string`

Named profile in the shared AWS config and credentials files that supplies credentials when no access key pair is given.

**forcePathStyle** `boolean`

Address the bucket in the URL path (`<endpoint>/<bucket>/<key>`) instead of as a subdomain of the endpoint.

**keyPrefix** `string`

Key prefix inside the bucket that the mount treats as its root; keys outside it are not visible. Leading slashes are dropped and a trailing `/` is added.

**timeout** `number` (default: DEFAULT\_TIMEOUT)

Seconds a request may wait to connect, or between two reads of its answer, before it fails; a download that keeps flowing is never cut off.

**proxy** `string`

Proxy URL for every HTTP and HTTPS request to the endpoint.

**region** `string` (default: 'us-east-1')

Wasabi region. It builds the endpoint `https://s3.<region>.wasabisys.com` (`https://s3.wasabisys.com` for `us-east-1`) unless `endpoint` is set, and signs every request.

**endpoint** `string`

Endpoint URL that replaces the one the provider derives.

Fields marked secret are redacted in snapshots.

## Authentication

Credentials come from the first of:

1. `accessKeyId` and `secretAccessKey`, with `sessionToken` for temporary
   credentials.
2. `profile`, a profile in `~/.aws/credentials`.
3. The AWS SDK credential chain: environment variables, then the instance or
   container role.

The key needs read access to the bucket, and write and delete access for a
write mount. A sub-user whose policy covers only the bucket is the safer
choice.
An object the key may not read or change answers `Permission denied`.

## Layout

```text theme={null}
/wasabi/
  README.md
  logs/
    app-2026-11-15.log
    app-2026-11-16.log
  reports/
    2026-q3.csv
    2026-q4.csv
```

`/wasabi/reports/2026-q3.csv` is the key `reports/2026-q3.csv`. Folders come
from the `/` in keys.

## Behavior

* **Key prefix:** `keyPrefix: 'users/42/'` mounts only that part of the bucket,
  so `/wasabi/notes.md` is the key `users/42/notes.md`.

## Browser

The browser `WasabiVFS` from `@struktoai/mirage-browser` keeps the keys off the
page: a server signs a URL for each S3 call with the Wasabi keys, and the
browser fetches it.

```bash theme={null}
npm install @struktoai/mirage-browser
```

```ts theme={null}
import { MountMode, WasabiVFS, Workspace } from '@struktoai/mirage-browser'

const wasabi = new WasabiVFS({
  bucket: 'my-bucket',
  region: 'us-east-2',
  presignedUrlProvider: async (path, op, opts) => {
    const r = await fetch('/presign', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ path, op, opts }),
    })
    return ((await r.json()) as { url: string }).url
  },
})
const ws = new Workspace({ '/wasabi': wasabi }, { mode: MountMode.READ })
```

* Requests go to the host each signed URL names; `region` and `endpoint` only
  name the mount's storage location.
* The bucket's CORS rules must allow the page's origin, exactly as served.
* A browser mount cannot declare `write: conditional`, and any HTTP 403 from a
  signed URL, an expired one included, answers `Permission denied`.
* `keyPrefix` set in the browser is no security boundary: enforce the prefix in
  the signing server and the key's permissions.

> [accordion] Signing server
>
> An Express route that signs URLs:
>
> ```ts theme={null}
> import {
>   CopyObjectCommand,
>   DeleteObjectCommand,
>   GetObjectCommand,
>   HeadObjectCommand,
>   ListObjectsV2Command,
>   PutObjectCommand,
>   S3Client,
> } from '@aws-sdk/client-s3'
> import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
>
> const REGION = process.env.WASABI_REGION!
> const BUCKET = process.env.WASABI_BUCKET!
> const client = new S3Client({
>   region: REGION,
>   endpoint: `https://s3.${REGION}.wasabisys.com`,
>   credentials: {
>     accessKeyId: process.env.WASABI_ACCESS_KEY_ID!,
>     secretAccessKey: process.env.WASABI_SECRET_ACCESS_KEY!,
>   },
> })
>
> app.post('/presign', async (req, res) => {
>   const { path, op, opts } = req.body as {
>     path: string
>     op: 'GET' | 'PUT' | 'HEAD' | 'DELETE' | 'LIST' | 'COPY'
>     opts?: Record<string, unknown>
>   }
>   const key = path.replace(/^\/+/, '')
>   const ttl = typeof opts?.ttlSec === 'number' ? opts.ttlSec : 300
>   let cmd
>   switch (op) {
>     case 'GET':    cmd = new GetObjectCommand({ Bucket: BUCKET, Key: key }); break
>     case 'PUT':    cmd = new PutObjectCommand({ Bucket: BUCKET, Key: key, ContentType: opts?.contentType as string | undefined }); break
>     case 'HEAD':   cmd = new HeadObjectCommand({ Bucket: BUCKET, Key: key }); break
>     case 'DELETE': cmd = new DeleteObjectCommand({ Bucket: BUCKET, Key: key }); break
>     case 'LIST':   cmd = new ListObjectsV2Command({
>       Bucket: BUCKET,
>       Prefix: opts?.listPrefix as string | undefined,
>       Delimiter: opts?.listDelimiter as string | undefined,
>       ContinuationToken: opts?.listContinuationToken as string | undefined,
>     }); break
>     case 'COPY':   cmd = new CopyObjectCommand({
>       Bucket: BUCKET,
>       Key: key,
>       CopySource: `${BUCKET}/${opts?.copySource as string}`,
>     }); break
>   }
>   const url = await getSignedUrl(client, cmd, { expiresIn: ttl })
>   res.json({ url })
> })
> ```
>
> Sign only the operations the app needs: a viewer needs `GET`, `HEAD` and `LIST`.
>
> For `us-east-1` the endpoint is `https://s3.wasabisys.com`, with no
> region in it.

> [accordion] Bucket CORS rules
>
> Wasabi takes the S3 `PutBucketCors` call, so the AWS CLI works against
> its endpoint:
>
> ```bash theme={null}
> aws s3api put-bucket-cors --bucket "$WASABI_BUCKET" \
>   --endpoint-url "https://s3.$WASABI_REGION.wasabisys.com" \
>   --cors-configuration '{"CORSRules":[{"AllowedOrigins":["http://localhost:5173","https://app.example.com"],"AllowedMethods":["GET","PUT","HEAD","DELETE","POST"],"AllowedHeaders":["*"],"ExposeHeaders":["ETag","Content-Length","Content-Type","Last-Modified"]}]}'
> ```

> [accordion] Browser fields
>
> **bucket** `string` *required*
>
> Name of the bucket to mount.
>
> **presignedUrlProvider** `function` *required*
>
> Function `(path, operation, options)` that returns a signed URL for each S3 operation; your server signs it, so the browser holds no keys.
>
> **region** `string` (default: 'us-east-1')
>
> Region of the bucket. It builds the endpoint `https://s3.<region>.wasabisys.com` (`https://s3.wasabisys.com` for `us-east-1`) unless `endpoint` is set.
>
> **endpoint** `string`
>
> Endpoint URL that replaces the one the provider derives. Requests go to the host each presigned URL names; the mount uses it to name its storage location.
>
> **defaultContentType** `string` (default: 'application/octet-stream')
>
> `Content-Type` stored with every object the mount writes.
>
> **keyPrefix** `string`
>
> Key prefix the mount treats as its root. The browser can change it before a URL is signed, so enforce the prefix on the signing server.
>
> **timeout** `number` (default: DEFAULT\_TIMEOUT)
>
> Seconds a request may wait to connect, or between two reads of its answer, before it fails; a download that keeps flowing is never cut off.
>
> Fields marked secret are redacted in snapshots.

## Integration

Wasabi answers these commands through its own API, so fewer objects are
read. See [Integration](https://docs.mirage.strukto.ai/home/integration/overview.md).

* `md5sum`: the object's ETag, when it is the MD5 (a single-part upload,
  unencrypted or under SSE-S3).
* `find`: one recursive listing.
* `du`: one recursive listing.
* `ls -R` and `tree`: one recursive listing.

## VFS.md

The [VFS.md](https://docs.mirage.strukto.ai/home/setup/vfs-md.md) an agent reads with Wasabi mounted at `/<path>`.
`<mode>` is the mount's mode: `read`, `write` or `exec`. The commands shown are
those of a `write` mount.

> [tab] Rendered
>
> **Virtual Filesystem**
>
> | Path | Description |
> | - | - |
> | `/<path>` | `<mode>` |
>
> **Supported Unix Commands for VFS**
>
> Unix commands work on each path as on a local filesystem, as far as the path supports them:
>
> | Path | Supported |
> | - | - |
> | `/<path>` | Almost all Unix commands. |
>
> **Limitations of Unix Commands for VFS**
>
> Where a path differs from a local filesystem:
>
> | Path | Limitations |
> | - | - |
> | `/<path>` | `grep -r`, `find` and `du` stop after 1000 files; a glob matching more, `tar -c`, `cp -r` and `rm -r` are refused. |
>
> Run `man <cmd>` or `<cmd> --help` for one command's usage.

> [tab] Raw
>
> ```markdown theme={null}
> ---
> name: workspace-filesystem
> description: The virtual filesystem layout of this workspace.
> ---
>
> # Virtual Filesystem
>
> | Path | Description |
> | --- | --- |
> | `/<path>` | `<mode>` |
>
> ## Supported Unix Commands for VFS
>
> Unix commands work on each path as on a local filesystem, as far as the path supports them:
>
> | Path | Supported |
> | --- | --- |
> | `/<path>` | Almost all Unix commands. |
>
> ## Limitations of Unix Commands for VFS
>
> Where a path differs from a local filesystem:
>
> | Path | Limitations |
> | --- | --- |
> | `/<path>` | `grep -r`, `find` and `du` stop after 1000 files; a glob matching more, `tar -c`, `cp -r` and `rm -r` are refused. |
>
> Run `man <cmd>` or `<cmd> --help` for one command's usage.
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.