What You’ll Learn
- Streaming command output with
sbx.commands.run_stream()(Python) /sbx.commands.runStream()(TypeScript) - Real-time
on_stdout/on_stderrcallbacks that fire as each line arrives - Inspecting the final accumulated
CommandResultafter the stream completes - Proper cleanup with
try/finallyandsbx.kill()
Prerequisites
Code Walkthrough
- Python
- TypeScript
Use Each line is delivered to
run_stream() with on_stdout and on_stderr keyword callbacks. The call blocks until the command exits and returns a CommandResult with the full accumulated output:on_stdout as it is emitted — no buffering until the command finishes. The returned result.stdout contains all lines joined together.