stdio API surface through six
self-contained demos. Each one starts a process with an open stdin pipe,
sends data, and reads the response.
What you’ll learn
- Sending stdin and receiving stdout via
sandbox.stdio.start(cmd) - Separate
on_stdoutandon_stderrcallbacks - Multi-round interactive conversations (read-echo loop)
- Iterator / stream protocol for consuming output
- Closing stdin to signal EOF (
proc.close_stdin()) - Custom environment variables and working directory
- Killing a long-running process (
proc.kill())
Prerequisites
- Python
- TypeScript
- Go
1. Basic echo (cat)
Startcat, send a line, close stdin, and read the echoed output.
- Python
- TypeScript
- Go
2. Stdout and stderr callbacks
Receive stdout and stderr on separate callbacks.- Python
- TypeScript
- Go
3. Multi-round interactive conversation
Send multiple lines to a process that reads in a loop.- Python
- TypeScript
- Go
4. Line counting with EOF
Send lines towc -l and close stdin so it sees EOF and reports.
- Python
- TypeScript
- Go
5. Environment variables and working directory
Pass env vars and set the working directory.- Python
- TypeScript
- Go
6. Kill a long-running process
Start a process, wait briefly, kill it, and read the exit code.- Python
- TypeScript
- Go
Full runnable examples
Complete self-contained scripts with all six demos and cleanup are available in the SDK repositories. Install the SDK (pip install declaw
or npm install @declaw/sdk) and run the example directly.