How aeroxy/cage-bro works
1. Top-level shape
- This is a polyrepo-style workspace centered on one Rust server binary, cage-bro, plus supporting crates, language SDKs, CLIs, docs, examples, and two marketing/demo sites.
- The architectural core is the Rust server; everything else either calls it, embeds its UI, or packages it for distribution.
2. Core runtime boundary
- The main production artifact is crates/cage-bro, built from src/main.rs, src/server.rs, and subsystem modules under src/api, src/browser, and src/mcp.
- That binary exposes the control plane over HTTP, serves the dashboard, and coordinates the execution subsystems.
3. Execution and sandboxing layer
- crates/cage-bro-runtime is the low-level process/session/isolation layer.
- It owns the mechanics for shell execution, PTY/session handling, filesystem access, local filesystem adapters, and Linux-focused isolation primitives such as Landlock plus rlimit caps.
- The README makes the key boundary explicit: untrusted code runs as child processes before exec, with filesystem confinement and resource limits, but network/syscall filtering is left to the deployment environment.
4. Code execution subsystem
- crates/cage-bro-code packages code-runner support, including Jupyter integration.
- The server exposes code execution APIs, while this crate handles the language/runtime-specific execution model, especially the stateful Jupyter path versus stateless Python/Node execution.
5. Shell and terminal subsystem
- Shell execution is a first-class path in the API and is backed by PTY/session primitives in the runtime crate.
- There is also a WebSocket terminal test (tests/ws_terminal.rs), which indicates interactive shell sessions are exposed over a real-time channel rather than only request/response HTTP.
6. Filesystem subsystem
- File operations are separated into a dedicated API module and runtime filesystem abstractions.
- The system treats the workspace as the main writable boundary: read/write/edit/list/search operations are scoped to the sandbox workspace, and snapshots operate on that workspace tree only.
7. Browser subsystem
- src/browser contains a browser manager and CDP client code, which points to a separate browser process or sidecar controlled through Chrome DevTools Protocol.
- The README states the browser is “Obscura” stealth mode, so browser automation is not embedded directly in the Rust process; it is orchestrated through a browser-control boundary.
8. MCP and agent-tooling boundary
- src/mcp implements an MCP server, with both stdio and HTTP/SSE modes mentioned in the README.
- This makes cage-bro usable as a tool provider for Claude Desktop, Cursor, and other MCP-aware agents, while the REST API remains the native control plane.
9. E2B compatibility layer
- src/api/e2b.rs and the README show an E2B-compatible sandbox lifecycle API at the server root.
- This layer is about sandbox orchestration: create/list/get/kill sandboxes, plus a cage-bro-specific /exec extension for running commands inside a tracked sandbox.
10. HTTP API surface
- src/api is split by capability: browser, code, file, shell, sandbox, and E2B.
- That separation matters architecturally because consumers can use narrow tool-specific endpoints instead of a generic “run arbitrary command” interface, which matches the agent/tooling design.
11. Dashboard as embedded UI
- The dashboard is a separate React/Vite app under crates/cage-bro/dashboard, but the README says it is embedded into the Rust binary.
- It provides local operator UI for terminal, code, files, and browser views, with the server serving both the API and the UI from the same origin.
12. Client and distribution layer
- sdk/python and sdk/typescript are thin client libraries for the HTTP API.
- cli-python, cli-typescript, Cargo packaging, and the Homebrew formula under Formula/ are distribution wrappers around the same server functionality, not separate execution engines.
13. Demo and documentation surfaces
- landing-page is the public marketing site, while wiki/, GUIDE.md, and the examples under examples/ document integration patterns and common use cases.
- These are important for architecture diagrams only insofar as they show the intended integration modes: direct HTTP, MCP, SDKs, and external agents.
14. State model and lifecycle
- The server’s sandbox registry and snapshot index are in-memory and scoped to a running process.
- That means lifecycle state is ephemeral by design: restart the server and the registry/snapshot index is rebuilt fresh; snapshots are filesystem-state only, not process-memory state.
15. Key external dependencies and trust boundaries
- External boundaries that materially affect the architecture are the host kernel/filesystem, a separate browser process reachable via CDP, and optional Jupyter infrastructure for notebook-style execution.
- The repo is designed so the Rust binary is the orchestration hub, but security guarantees depend on the surrounding VM/container/host policy for network isolation and syscall filtering.
Main entry points: mod.rs API · server.rs Server · lib.rs Runtime · README.md Examples
Components 26
Rust Core
Primary server binary and execution crates
- cage-bro · Main orchestrator that exposes HTTP, dashboard, and agent-tooling entry points
crates/cage-bro/src/main.rs - Server · Coordinates requests, sandbox lifecycle, and subsystem routing
crates/cage-bro/src/server.rs - Runtime · Low-level execution, PTY, filesystem, and isolation boundary
crates/cage-bro-runtime/src/lib.rs - Processes · Shell process spawning and execution mechanics
crates/cage-bro-runtime/src/process.rs - Sessions · Interactive terminal and session lifecycle primitives
crates/cage-bro-runtime/src/session.rs - Filesystem · Workspace filesystem abstraction and adapters
crates/cage-bro-runtime/src/filesystem.rs - Isolation · Landlock and resource-limit confinement primitives
crates/cage-bro-runtime/src/isolation.rs - Code Runtime · Language execution support including Jupyter integration
crates/cage-bro-code/src/lib.rs
Interfaces
APIs, MCP, dashboard, and browser control
- API · Capability-specific REST surface for shell, files, code, browser, sandbox, and E2B
crates/cage-bro/src/api/mod.rs - Shell API · Shell and terminal-oriented command execution endpoints
crates/cage-bro/src/api/shell.rs - Files API · Workspace-scoped read/write/list/search/edit operations
crates/cage-bro/src/api/file.rs - Code API · Code-runner endpoints for language execution and notebook flows
crates/cage-bro/src/api/code.rs - Sandbox API · Creates, tracks, and tears down sandbox sessions
crates/cage-bro/src/api/sandbox.rs - E2B API · E2B-compatible sandbox lifecycle surface plus exec extension
crates/cage-bro/src/api/e2b.rs - Browser API · HTTP surface for browser sessions and automation
crates/cage-bro/src/api/browser.rs - MCP Server · MCP transport and tool exposure for agent clients
crates/cage-bro/src/mcp/server.rs - Browser Mgmt · Manages external browser processes and session state
crates/cage-bro/src/browser/manager.rs - CDP Client · Chrome DevTools Protocol client used to control the browser boundary
crates/cage-bro/src/browser/cdp.rs - Dashboard · Embedded operator UI for terminal, code, files, and browser views
crates/cage-bro/dashboard/src/App.tsx
Distribution
SDKs and CLI wrappers
- Python SDK · Python client library for the server API
sdk/python/cage_bro/client.py - TS SDK · TypeScript client library for the server API
sdk/typescript/src/index.ts - Py CLI · Python command-line wrapper around the server capabilities
cli-python/cage_bro_cli/__init__.py - TS CLI · TypeScript command-line wrapper around the server capabilities
cli-typescript/bin/cage-bro.js
Docs & Demos
Examples, wiki, and marketing site
- Examples · Representative agent and application integrations
examples/claude-desktop/README.md - Wiki · Architecture and usage guidance
wiki/overview.md - Landing Page · Public marketing and product positioning site
landing-page/src/App.tsx
Connections 26
- cage-bro → Server: boots · Binary initializes the server runtime
- Server → API: routes · Server dispatches requests into capability-specific HTTP modules
- API → Shell API: shell · Shell endpoints
- API → Files API: files · Filesystem endpoints
- API → Code API: code · Code execution endpoints
- API → Sandbox API: sandboxes · Sandbox lifecycle endpoints
- API → E2B API: e2b · Compatibility surface
- API → Browser API: browser · Browser control endpoints
- Server → Runtime: executes · Server relies on the runtime layer for process and session management
- Runtime → Processes: spawns · Child process execution
- Runtime → Sessions: pty · Interactive terminal sessions
- Runtime → Filesystem: scopes · Workspace filesystem access
- Runtime → Isolation: confines · Filesystem and resource isolation
- Code API → Code Runtime: runs on · Code API delegates language-specific execution to code runtime support
- Browser API → Browser Mgmt: controls · Browser API manages browser sessions through the browser manager
- Browser Mgmt → CDP Client: uses · Browser manager speaks CDP to the external browser process
- Server → MCP Server: serves · Server exposes MCP tooling entry points
- Server → Dashboard: embeds · Server serves the embedded dashboard UI
- Python SDK → API: calls · Python SDK consumes the HTTP API
- TS SDK → API: calls · TypeScript SDK consumes the HTTP API
- Py CLI → API: wraps · Python CLI wraps server capabilities
- TS CLI → API: wraps · TypeScript CLI wraps server capabilities
- Examples → MCP Server: demonstrate · Examples show agent-tooling integration paths
- Examples → API: demonstrate · Examples also show direct API integration
- Wiki → API: documents · Documentation explains API and integration patterns
- Landing Page → Server: presents · Marketing site represents the overall product