Skip to main content

Python SDK for cage-bro sandbox

Project description

cage-bro Python SDK

PyPI License

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


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.1.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cage_bro-0.1.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file cage_bro-0.1.1.tar.gz.

File metadata

  • Download URL: cage_bro-0.1.1.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

Hashes for cage_bro-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1c6fc258415e1110a6e88004e5cdcf1e4bd1622dc825edbd30b66b9c97f6417c
MD5 020335dfc3473b7c5a887ff419500a55
BLAKE2b-256 49eb1bde4de200a94dd0f55625dcb2d265ba3b189c4f846ad42463a949483e3c

See more details on using hashes here.

File details

Details for the file cage_bro-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cage_bro-0.1.1-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

Hashes for cage_bro-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c9c4520a1bd4579ae1b8fd06fd5790c91aa84878734122e28a71babf9f19c2a7
MD5 8d54802ee99340669359284d1576b872
BLAKE2b-256 e504ad0b27066dc0ada086a688df80f9e7572889324fa470ef6f339ee2f0b960

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page