https://github.com/apify/actor-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. ๐ฆ
https://github.com/apify/actor-ai-code-sandbox
Last synced: 14 days ago
JSON representation
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. ๐ฆ
- Host: GitHub
- URL: https://github.com/apify/actor-ai-code-sandbox
- Owner: apify
- Created: 2025-12-07T18:08:16.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2026-06-15T14:28:21.000Z (about 2 months ago)
- Last Synced: 2026-06-15T16:08:37.939Z (about 2 months ago)
- Language: TypeScript
- Homepage: https://apify.com/apify/ai-code-sandbox
- Size: 730 KB
- Stars: 5
- Watchers: 0
- Forks: 3
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐งช Apify AI Code Sandbox
A suite of Apify Actors providing secure, containerized environments for AI coding agents.
[](https://apify.com)
[](https://nodejs.org)
[](https://python.org)
## Overview
This monorepo contains four Apify Actors designed for AI-powered coding workflows:
| Actor | Description | Use Case |
|-------|-------------|----------|
| **[AI Sandbox](./sandbox)** | Core containerized environment with REST API, MCP server, and interactive shell | General AI agent development, sandboxed code execution |
| **[Claude Code](./claude-code)** | One-click access to Anthropic's Claude Code | Instant Claude Code sessions on Apify |
| **[OpenCode](./opencode)** | One-click access to open-source OpenCode | Free/open-source AI coding with multiple AI models support |
| **[OpenClaw](./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](https://docs.apify.com/platform/actors/development/programming-interface/metamorph) into the AI Sandbox, automatically launching their respective CLI tools in the terminal.
## Quick Start
### Use on Apify Platform
1. **AI Sandbox**: [Run on Apify](https://apify.com/apify/ai-sandbox) - Full sandbox with API access
2. **Claude Code**: [Run on Apify](https://apify.com/apify/claude-code) - Auto-opens Claude Code CLI
3. **OpenCode**: [Run on Apify](https://apify.com/apify/opencode) - Auto-opens OpenCode CLI
### Connect to a Running Sandbox
Once running, connect via:
- **MCP Client**: `https://.runs.apify.net/mcp`
- **REST API**: `POST /exec`, `GET/PUT/DELETE /fs/*`
- **Interactive Shell**: `https://.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
```bash
# 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
```bash
# 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](./sandbox/README.md) - Full API reference and usage examples
- [Claude Code README](./claude-code/README.md) - Claude Code integration details
- [OpenCode README](./opencode/README.md) - OpenCode integration details
- [OpenClaw README](./openclaw/README.md) - OpenClaw integration details
## Links
- [Apify Platform](https://apify.com)
- [Model Context Protocol](https://modelcontextprotocol.io/)
- [Claude Code](https://code.claude.com)
- [OpenCode](https://opencode.ai)
- [OpenClaw](https://openclaw.ai/)