๐งช Apify AI Code Sandbox
Open-source Actor that provides a sandbox for secure execution of AI generated code. Supports Node.js, Python. Provides pre-configured Claude Code, Codex CLI, and OpenCode. ๐ฆ
README
๐งช Apify AI Code Sandbox
A suite of Apify Actors providing secure, containerized environments for AI coding agents.
Overview
This monorepo contains four Apify Actors designed for AI-powered coding workflows:
| Actor | Description | Use Case |
|---|---|---|
| AI Sandbox | Core containerized environment with REST API, MCP server, and interactive shell | General AI agent development, sandboxed code execution |
| Claude Code | One-click access to Anthropic's Claude Code | Instant Claude Code sessions on Apify |
| OpenCode | One-click access to open-source OpenCode | Free/open-source AI coding with multiple AI models support |
| OpenClaw | Clears your inbox, sends emails, manages your calendar, checks you in for flights | All from Apify platform |
Architecture
The AI Sandbox is the core Actor that provides the full execution environment:
- Debian Trixie container with Node.js 24 and Python 3
- RESTful filesystem API for file operations
- MCP (Model Context Protocol) server for AI agent integration
- Interactive browser-based terminal (ttyd)
- Dependency management for npm and pip packages
The Claude Code and OpenCode Actors are lightweight proxies that metamorph into the AI Sandbox, automatically launching their respective CLI tools in the terminal.
Quick Start
Use on Apify Platform
- AI Sandbox: Run on Apify - Full sandbox with API access
- Claude Code: Run on Apify - Auto-opens Claude Code CLI
- OpenCode: Run on Apify - Auto-opens OpenCode CLI
Connect to a Running Sandbox
Once running, connect via:
- MCP Client:
https://<RUN-ID>.runs.apify.net/mcp - REST API:
POST /exec,GET/PUT/DELETE /fs/* - Interactive Shell:
https://<RUN-ID>.runs.apify.net/shell/
Features
- ๐ Secure Isolation: Execute untrusted code safely in containerized environments
- ๐ค AI Agent Ready: MCP server with tools for file operations and code execution
- ๐ฆ Multi-Language: JavaScript, TypeScript, Python, and shell command support
- ๐ฅ๏ธ Interactive Shell: Browser-based terminal for real-time debugging
- ๐ Actor Orchestration: Agents can use the Apify token to run other Actors
- ๐ Filesystem API: RESTful endpoints for file upload, download, and management
- ๐ Dynamic Proxy: Expose local services running in the container to external paths
- โก Auto-Shutdown: Configurable idle timeout for cost efficiency
Repository Structure
โโโ sandbox/ # Core AI Sandbox Actor
โ โโโ src/ # Express server, MCP, file operations
โ โโโ artifacts/ # Configuration files (AGENTS.md, opencode.json)
โ โโโ README.md # Full API documentation
โ
โโโ claude-code/ # Claude Code proxy Actor
โ โโโ src/main.ts # Metamorph into sandbox
โ โโโ README.md # Claude Code specific docs
โ
โโโ opencode/ # OpenCode proxy Actor
โ โโโ src/main.ts # Metamorph into sandbox
โ โโโ README.md # OpenCode specific docs
โ
โโโ openclaw/ # OpenClaw proxy Actor
โโโ src/main.ts # Metamorph into sandbox with OpenClaw init
โโโ README.md # OpenClaw specific docs
Development
Prerequisites
- Node.js 24+
- Docker (for local builds)
Build
# Build all Actors
cd sandbox && npm install && npm run build
cd ../claude-code && npm install && npm run build
cd ../opencode && npm install && npm run build
cd ../openclaw && npm install && npm run build
Deploy
# Deploy using Apify CLI
cd sandbox && apify push
cd ../claude-code && apify push
cd ../opencode && apify push
cd ../openclaw && apify push
Documentation
- AI Sandbox README - Full API reference and usage examples
- Claude Code README - Claude Code integration details
- OpenCode README - OpenCode integration details
- OpenClaw README - OpenClaw integration details
