Interactive Exec
A live, bidirectional PTY session that can be checkpointed and resumed mid-session.
interactive-exec
Demonstrates sb.exec(cmd, { interactive: true }): a live, bidirectional PTY session that can be driven like a human — and resumed like one too.
Setup
bunx alineo-cli init # starts OpenSandbox in Docker (one-time setup)Run
bun install
bun startWhat it does
- Creates an
ubuntu:22.04sandbox and opens an interactivebashsession - Drives it with several
write()calls — exports a var,cds into a directory, writes a file — none of which is a single self-contained command - Checkpoints the sandbox while the shell is still open (not after it exits)
- Resumes from that checkpoint into a new sandbox
- Opens the same interactive exec again at the same call site — the resume path detects the session was still open, replays its recorded stdin for real against the freshly restored filesystem, then hands control back live
- Asserts the
cd, the file contents, and the exported variable all survived — reconstructed by re-running the recorded input, not by faking a transcript - Exits the shell and asserts the interactive exec resolves with the process's real exit code
OpenSandbox snapshots are rootfs-only (no CRIU) — the original bash process is provably gone after resume. Reconstructing shell state is only possible by replaying the stdin that produced it.