Workspace
Record<string, VFS>
required
The backend at each prefix, such as
{ '/': new RAMVFS(), '/s3': new S3VFS(config) }.MountMode
default:"MountMode.READ"
The mode a mount gets when it sets none:
READ, WRITE or EXEC.string
The profile a session gets when it names none.
AskHandler
Answers an ask while the line waits. Without one, asks wait in
ws.decisions.cache, index, store, runtimes, clis, env, secrets, commandLimits, …) are the top-level YAML keys, in camelCase.
ws.session
Session every call below runs as. It creates the session when the id is new and adopts it when it exists. profile and mounts apply only on create, and throw for an existing session. ws.createSession is the same call without the handle.
ws.listSessions, ws.closeSession
ws.cancel, ws.kill
cancel cancels the running and queued lines, whichever way they came in, and resolves once they have ended; each rejects with an AbortError. kill kills the background jobs (cmd &) and the processes runtimes started. Each answers how many it stopped.
ws.snapshot, Workspace.load
snapshot answers the tar’s bytes; with one, its size. target and source are a path, or an object key with s3; source can also be the bytes. While it captures, new lines and file writes wait, and running ones get 30 seconds to end, else it rejects with an EBUSY error; a path target streams disk mount files rather than holding them whole. See Snapshots for what a tar holds.
ws.copy
ws.decisions
pending() lists every session’s, pending('agent') one session’s, and an answer never reaches another session. outcome is Outcome.ALLOW or Outcome.DENY. Scope.ONCE, the default, answers the one line, so its retry runs or is refused; Scope.SESSION allows every line the rule covers for the rest of that session.
ws.close
Session
ws.session. Every call on it answers under the session’s profile, working directory and environment. ws.shell, ws.glob, ws.vfs and ws.tools are the same calls as the workspace’s default session.
string
SessionState
The session’s record, as
ws.listSessions answers it.Ops
The file API, below.
MirageToolOperations
The agent tools, below.
session.shell
Uint8Array | AsyncIterable<Uint8Array>
The line’s stdin. An async iterable streams it.
string
A working directory for this line only. A
cd in the line does not leak.Record<string, string>
Variables for this line only.
AbortSignal
Aborting it stops the line, which throws an
AbortError.boolean
default:"true"
false keeps the line out of history.session.glob
session.explain
session.shell or a session.vfs call would do, without running it: a line’s verdict and parse tree, a VFS call’s verdict and error, each with every policy’s answer. In a browser (no async task isolation) explain.vfs throws and explain.shell’s policies act for real. See Explain.
session.vfs
The file API, run as the session. Paths are absolute, bytes areUint8Array. A failure throws an Error whose code is the POSIX name, as Node’s fs does: ENOENT, EACCES, EROFS.
session.tools
isError, never a throw. call takes a tool’s name and its JSON input, the form an agent loop gets from the model. The session has one table, shared by every caller, so write and edit refuse a file the agent has not read in full, or one that changed since it read it. names() is the tools the session’s profile leaves it, which MCP, RPC and the agent adapters offer: shell needs a command the allow list installs, ls and grep those commands, write and edit a mount the session may write.
readMedia(path) answers an image or a PDF as media instead of numbered text, for adapters that hand media to the model. @struktoai/mirage-core/workspace/tools/tool_descriptions has each tool’s description and JSON schema to hand the model, and the agent adapters wire the tools into each framework. new MirageToolOperations(session, false), from @struktoai/mirage-core/workspace/tools/tool_operations, is a table without the read guard.