Mirage shipsDocumentation 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.
BoxResource in two runtimes:
@struktoai/mirage-node, usesclient_id+client_secret+ refresh token (rotated on each use)@struktoai/mirage-browser, supports the same refresh token via PKCE (no client secret in the bundle)
/folders/{id}/items, /files/{id}/content, /search). Credentials are obtained the same way
in both runtimes, see Box Credentials.
Quick start: developer token
For exploration, skip the OAuth flow and use a developer token (one-button-click in the Box app console, 60-minute lifetime). TheBoxResource accepts an accessToken field that
short-circuits the refresh logic:
invalid_token), regenerate it in the console and
re-run. See Box Credentials -> Quick Start.
Node (server-side, long-running)
BoxTokenManager caches the access token in memory (5-minute safety buffer before expiry)
and rotates the refresh token on every refresh. Without onRefreshTokenRotated, the rotation
is in-memory only and a process restart needs a fresh refresh token.
Browser (PKCE, no client secret)
examples/typescript/browser/src/box_pkce.ts
runs the full PKCE dance and persists the rotated refresh token to localStorage.
VFS mode (patchNodeFs)
fs.promises.* is patched, sync forms aren’t supported.
FUSE mode
Path → ID resolution
Box uses numeric folder/file IDs internally (root folder is id0). Mirage caches the path → ID
mapping in the RAMIndexCacheStore attached to the resource. The first time you ls /box/foo/bar/,
it walks the tree top-down (one API call per level) and caches each entry’s ID. Subsequent reads
of /box/foo/bar/anyfile.json hit the cache instead of re-walking.
The cache TTL defaults to 24h. To force re-resolution, recreate the BoxResource.
Special file types
Five Box-specific file types get a.json suffix appended in the vfs and return clean,
agent-friendly JSON when you cat them. The Box file ID is unchanged, the suffix is
purely a vfs hint that cat returns JSON, mirroring Google Drive’s .gdoc.json style.
In ls /box/:
.boxnote.json, Box Notes
.boxcanvas.json, Box Canvas (whiteboards)
.gdoc.json / .gsheet.json / .gslides.json, Box’s V2 Google files
Box’s V2 G Suite integration stores Google-format files as Office Open XML zips (.docx /
.xlsx / .pptx). On cat, Mirage uses Box’s
representations API
with X-Rep-Hints: [extracted_text] to fetch Box’s auto-extracted plain-text version, then
returns a JSON envelope:
.gdoc.json, Box uses its own API + extracted-text
representation; Google Drive uses Google’s full Documents API and returns the rich Document
structure (paragraphs, named styles, lists, etc.). For real edits to the underlying Google
Doc, mount Google Drive separately with Google credentials and use the
GDocs / GSheets / GSlides resources, gws-docs-* commands won’t work
on Box because the file IDs are in different namespaces.
Available commands
BoxResource ships the same shell command set as GDriveResource and DropboxResource:
- Filesystem:
ls,cat,head,tail,nl,wc,stat,find,tree,du,file,realpath,basename,dirname - Search/text:
grep,rg,awk,sed,sort,uniq,cut,diff,cmp,jq - Encoding:
base64 - Format-aware:
cat_parquet,cat_feather,cat_hdf5, plushead_*/grep_*/ls_*/stat_*/tail_*/wc_*/file_*/cut_*variants for.parquet,.feather,.hdf5/.h5,.orcfiles
Examples
End-to-end runnable scripts are inexamples/typescript/box/:
box.ts,Workspace.execute('ls/stat/cat/tree …')shell demobox_parquet.ts, parquet preview throughcatbox_boxnote.ts,.boxnote.jsondecoded into clean JSONbox_office.ts,.gdoc.json/.gsheet.json/.gslides.jsonvia Box’s extracted_text representationbox_vfs.ts,patchNodeFs+ nativefs.promises.*callsbox_fuse.ts, FUSE mount with shell access in another terminal