Declare machines
new Workspace(mounts, { machines: {...} }) takes machine entries, runtime
objects and machine handles by name. The first machine whose captures
names a program runs it:
sandboxId, mountType); YAML spells
the same keys in snake_case.
Change them on a live workspace
On a live workspace,addMachine adds
a runtime’s machine, removeMachine takes one
out, and engines() lists them. A machine provider’s machine, such as
docker, is declared when the workspace is built:
python3 moves to the new machine at once. A running line finishes before
its removed runtime closes, a removed instance cannot be added again, and
workspace cannot be removed. registerRuntime(name, cls) makes your own
runtime class available by name in YAML. The @external capture is also
exported as EXTERNAL_COMMANDS.
A machine subclass that overrides loadSdk() imports the SDK type from the
provider’s sdk module. The E2B one needs pnpm add @struktoai/mirage-core:
Child processes
A host application starts a program through the same admitted entry point as the shell.TypeScript SDK notes
- Local: in
@struktoai/mirage-nodeonly. With neitherhomenorMIRAGE_LOCAL_HOME,python3is the one onPATH. - Machines: in
@struktoai/mirage-node;e2balso runs in browsers.mountTypesshandbothneed thessh2package; a browser serves no files into a machine. Thesshmachine authenticates throughSSH_AUTH_SOCKwhen there is noidentityFile, andusernamedefaults to the local user.