shellTool and applyPatchTool primitives that take pluggable Shell and Editor backends. Mirage provides MirageShell and MirageEditor implementations that route every command and patch through your Workspace instead of the host shell. mirageReadFileTool adds agent-initiated file reads with structured model input for text, images, and PDFs.
Install
@struktoai/mirage-agents/openai is runtime-agnostic. Pair it with @struktoai/mirage-node for Node or @struktoai/mirage-browser for the browser.
Usage
mirageTools(ws), Mirage’s seven function tools, instead of the hosted shell and editor tools.
Sandbox Agent
SandboxAgent runs the SDK’s own exec_command, apply_patch and view_image tools against a sandbox session. MirageSandboxClient makes that session a Mirage workspace, and MirageCapability adds the workspace’s mounts (backend, mode, commands) to the agent’s instructions. The client also needs @openai/agents-core, at the same version as @openai/agents.
- Every command starts at the manifest root,
/unless you configure aManifest, or at the model’sworkdir, and acdorexportends with its command, as in the SDK’s other sandboxes. Commands see the manifest’s environment. Each sandbox session has its own Mirage session, and its commands, file reads, writes and patches run in it one at a time. - A command still running after
exec_command’s yield time keeps running. The model polls it withwrite_stdinand stops it with Ctrl-C (\u0003). - Relative paths resolve against the manifest root. Manifest
fileanddirentries are written into the workspace; other entry types raiseSandboxUnsupportedFeatureError. - A run paused for tool approval resumes on the same workspace and keeps the files the agent wrote.
Exports
Unsupported binary formats return a metadata description instead of being decoded as corrupt text. The tool reads raw workspace bytes, so files mounted from RAM, S3, and other Mirage mounts use the same model-input path.
Examples
examples/typescript/agents/openai/ram_agent.ts, RAM-only sandbox.examples/typescript/agents/openai/multi_vfs_agent.ts, RAM + S3 mounts.examples/typescript/agents/openai/sandbox_agent.ts,SandboxAgentover a RAM workspace with a read-only data mount.examples/typescript/agents/openai/snapshot.ts, branch & roll back agent state.