Managed processes
Keep servers, builds, and interactive programs running after a request finishes.
Managed processes keep running after the request returns. Use them for servers,
builds, watchers, and REPLs. Use exec for a command that should finish
as part of one request.
Start a process
Start the program, then keep its handle to check it, read its output, or stop it later.
const process = await sandbox.process.start({
cmd: ["npm", "run", "dev"],
cwd: "/workspace",
});
for await (const event of process.stream()) {
if (event.type === "stdout") process.stdout.write(event.text);
if (event.type === "exit") break;
}You can also start a process with the Python SDK or raw HTTP. See the TypeScript SDK, Python SDK, or the API reference for the complete request shape.
Work with it
With the returned handle you can:
- read or stream output;
- send input, including EOF for programs that wait for it;
- wait for completion and inspect the exit code;
- send a graceful signal or stop the process; and
- reconnect later from another client.
Set pty: true when the program needs an interactive terminal. A PTY process
can receive keystrokes and resize events; use the terminal for a
short-lived interactive shell instead.
What to expect
- The process outlives the starting request and can be reconnected to while the sandbox stays running.
- Output is buffered for reading and streaming. Consume important output while the process runs; it is not durable storage.
- Stopping or deleting a sandbox ends its managed processes. Treat a fresh boot as a fresh runtime.
- Processes started with
execare one-shot and do not remain available after the call; start a managed process for long-lived work.
For request and response fields, limits, status codes, and recovery behavior, use the API reference.
See also
- Processes & code execution — one-shot commands and code
- Terminal — an interactive shell
- Filesystem — read, write, and search files