Prerequisites
Examples
SimpleBox
Foundation patterns — command execution, stdout/stderr separation, environment variables, working directories, and error handling.
CodeBox
AI code execution — securely run AI-generated Python code with automatic package installation.
BrowserBox
Browser automation — web scraping, end-to-end testing, and screenshot generation.
ComputerBox
Desktop automation — screenshots, mouse clicks, text input, and 9+ additional functions.
Lifecycle Management
Box state management — start, stop, restart, and inspect box lifecycle.
List Boxes
Runtime introspection — enumerate and inspect all active boxes.
Cross Process
Multi-process operations — share boxes across processes.
InteractiveBox
Interactive shells — TTY sessions with stdin/stdout streaming.
Native Example
Low-level Rust API — direct access to the BoxLite Rust runtime.
1. SimpleBox — Foundation Patterns
File:examples/python/simplebox_example.py
Demonstrates core BoxLite features: basic command execution, stdout/stderr separation, environment variables, working directory configuration, error handling, and running multiple commands in the same box.
2. CodeBox — AI Code Execution
File:examples/python/codebox_example.py
Secure Python code execution for AI agents. CodeBox provides automatic package installation and a safe execution sandbox.
3. BrowserBox — Browser Automation
File:examples/python/browserbox_example.py
Browser automation in an isolated VM. Use cases include web scraping, end-to-end testing, browser automation, and screenshot generation.
4. ComputerBox — Desktop Automation
File:examples/python/computerbox_example.py
Full desktop automation with a rich set of interaction functions.
| Function | Description |
|---|---|
screenshot() | Capture the screen |
left_click() | Left mouse click |
right_click() | Right mouse click |
double_click() | Double mouse click |
type_text(text) | Type text input |
get_screen_size() | Get screen dimensions |
move_mouse(x, y) | Move cursor to position |
| + 9 more | Additional interaction functions |
5. Lifecycle Management
File:examples/python/lifecycle_example.py
Demonstrates box state management including starting, stopping, restarting, and inspecting box state.
6. List Boxes
File:examples/python/list_boxes_example.py
Runtime introspection — enumerate and inspect all active boxes.
7. Cross Process
File:examples/python/cross_process_example.py
Multi-process operations — share and access boxes across different processes.
8. InteractiveBox
File:examples/python/interactivebox_example.py
Interactive shell sessions with TTY support.
9. Native Example
File:examples/python/native_example.py
Low-level access to the BoxLite Rust API from Python.