Processes & Shell
Processes
Process management inside the VM: exec, spawn, stdin, lifecycle, shell sessions, process events, and visibility.
Run commands and long-lived processes inside a VM, stream their output, and drive interactive shells. Reach for this whenever an agent needs to invoke tools, start a dev server, pipe data over stdin, or attach a terminal.
How it works
A server.ts registers a VM with its software, and each script connects with createClient and grabs a VM via client.vm.getOrCreate("my-agent"). From there the VM handle exposes the full process surface:
exec— run a command to completion and collectstdout,stderr, andexitCodein one call.spawn+ lifecycle — start a process for apid, thenlistProcesses,getProcess,waitProcess,stopProcess(SIGTERM), andkillProcess(SIGKILL).- stdin —
writeProcessStdinandcloseProcessStdinto feed a running process, including an interactivesh(seeshell.ts). - events —
agent.connect()returns a connection that emitsprocessOutput/processExitandshellData, so output streams live as it is produced.
visibility.ts shows how to enumerate and inspect everything running in the VM.
Run it
npm install
npx tsx server.ts & # start the VM registry on :6420
npx tsx exec.ts # then run any of the scripts (spawn.ts, stdin.ts, shell.ts, ...)
Each script prints its process output and exit codes to the console.