Python SDK for cage-bro sandbox
Project description
cage-bro Python SDK
Python SDK for cage-bro — a sandboxed execution environment for AI agents with browser, shell, code execution, file ops, and MCP support.
Install
pip install cage-bro
Requires a running cage-bro server. See the main project for installation instructions.
Quick Start
from cage_bro import CageBro
cage = CageBro("http://localhost:8080")
# Shell commands
result = cage.shell_exec("ls -la")
print(result["stdout"])
# Code execution
result = cage.python("print(2 + 2)")
print(result["stdout"])
# File operations
cage.file_write("hello.txt", "world")
content = cage.file_read("hello.txt")
# Browser automation
cage.browser_launch()
cage.browser_navigate("https://example.com")
screenshot = cage.browser_screenshot()
Context Manager
with CageBro("http://localhost:8080") as cage:
cage.shell_exec("echo hello")
API Reference
Sandbox
| Method | Description |
|---|---|
info() |
Get sandbox info |
health() |
Health check |
Shell
| Method | Description |
|---|---|
shell_exec(command, timeout_ms=None) |
Execute a shell command |
shell_create_session(shell=None) |
Create a persistent shell session |
Files
| Method | Description |
|---|---|
file_read(path) |
Read a file and return its content |
file_write(path, content) |
Write content to a file |
file_edit(path, old_text, new_text) |
Edit a file (find and replace) |
file_list(path=".") |
List directory contents |
file_search(query, path=None) |
Search files for text |
file_delete(path) |
Delete a file or directory |
Code Execution
| Method | Description |
|---|---|
python(code, timeout_ms=None) |
Execute Python code in the sandbox |
node(code, timeout_ms=None) |
Execute Node.js code in the sandbox |
Browser
| Method | Description |
|---|---|
browser_launch(port=None, stealth=True) |
Launch the headless browser |
browser_navigate(url) |
Navigate to a URL |
browser_screenshot() |
Take a screenshot of the current page |
browser_click(selector) |
Click an element by CSS selector |
browser_type(selector, text) |
Type text into an input element |
browser_evaluate(expression) |
Evaluate JavaScript in the browser |
browser_content() |
Get the current page HTML content |
browser_close() |
Close the browser |
Links
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cage_bro-0.2.0.tar.gz
(3.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cage_bro-0.2.0.tar.gz.
File metadata
- Download URL: cage_bro-0.2.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
169850b48aea84fb49649624b645648cfa9c99684101a2656d2e17947b15acca
|
|
| MD5 |
ffc42b9eba6deebe141a4c7d6bc24bc1
|
|
| BLAKE2b-256 |
b858ca9c45dda04884f61d26593535c3b827be00a79d8e38a40a9070b909c6df
|
File details
Details for the file cage_bro-0.2.0-py3-none-any.whl.
File metadata
- Download URL: cage_bro-0.2.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a289aa2d51e3d83fa327ce76460fbc1aceb962ec2ff0b9570692ec3256f138ed
|
|
| MD5 |
32352133fb843000c21e9bcb55d1a830
|
|
| BLAKE2b-256 |
d063e9adc4a18cf446a97721d28a0bc12d4c97c4a8f9bfbbcf6862a08ac41085
|