Cogbox 开源 AI 代码执行沙箱运行时,启动低于 90ms
cognifyi/cogbox
Cogbox 发布开源沙箱运行时,用于执行 AI 生成代码和支撑智能体工作流,每个沙箱是带独立内核、文件系统、网络栈和分配 vCPU、RAM、磁盘的隔离计算机,从代码到执行启动时间低于 90ms。
Run AI Code.
Secure and Elastic Infrastructure for
Running Your AI-Generated Code.
Documentation · Report Bug · Request Feature ·
Cogbox is a secure and elastic infrastructure runtime for AI-generated code execution and agent workflows. Our open-source platform provides sandboxes, full composable computers with complete isolation, a dedicated kernel, filesystem, network stack, and allocated vCPU, RAM, and disk.
Sandboxes are the core component of the Cogbox platform, spinning up in under 90ms from code to execution and running any code in Python, TypeScript, and JavaScript. Built on OCI/Docker compatibility, massive parallelization, and unlimited persistence, sandboxes deliver consistent, predictable environments for agent workflows.
Agents and developers interact with sandboxes programmatically using the Cogbox SDKs, API, and CLI. Operations span sandbox lifecycle management, filesystem operations, process and code execution, and runtime configuration through base images, packages, and tooling. Our stateful environment snapshots enable persistent agent operations across sessions, making Cogbox the ideal foundation for AI agent architectures.
Features
Cogbox provides an extensive set of features and tools for interacting with sandboxes.
- Platform: governance and operational controls for organizations standardizing on Cogbox
- Sandboxes: isolated full composable computers that execute workloads and retain state
- Agent tools: programmatic capabilities for application code, agents, and integrations
- Human tools: interfaces and remote sessions for interacting with sandboxes
- System tools: platform-level hooks and controls for lifecycle events and network access
Architecture
Cogbox platform is organized into multiple plane components, each serving a specific purpose. A detailed overview of each component is available in the architecture documentation.
- Interface plane: provides client interfaces for interacting with Cogbox
- Control plane: orchestrates all sandbox operations
- Compute plane: runs and manages sandbox instances
Applications
Runnable applications and services for the Cogbox platform. Each directory is a deployable or buildable component, available in the apps directory.
api: NestJS-based RESTful service; primary entry point for all platform operationscli: Go command-line interface access to core features for interacting with sandboxesdaemon: code execution agent that runs inside each sandboxdashboard: web user interface for visual sandbox managementdocs: documentation content; website published to cogbox.pazity.com/docsotel-collector: trace and metric collection for Cogbox SDK operationsproxy: reverse proxy for custom routing and preview URLsrunner: compute nodes that power Cogbox's compute plane and run sandboxessnapshot-manager: orchestrates the creation of sandbox snapshotsssh-gateway: standalone SSH gateway that accepts authenticatedsshconnections
Client libraries
Client libraries integrate the Cogbox platform from application code through developer-facing SDKs backed by OpenAPI-generated REST clients and toolbox API clients. Each directory is a publishable package for a specific language or runtime, available in the libs directory.
Python
pip install cogbox
Standalone packages and libraries for interacting with Cogbox using Python:
sdk-python•api-client-python•api-client-python-async•toolbox-api-client-python•toolbox-api-client-python-async
TypeScript
npm install @cogbox/sdk
Standalone packages and libraries for interacting with Cogbox using TypeScript:
Ruby
gem install cogbox
Standalone packages and libraries for interacting with Cogbox using Ruby:
Go
go get github.com/cognifyi/cogbox/libs/sdk-go
Standalone packages and libraries for interacting with Cogbox using Go:
Java
Gradle (build.gradle.kts):
dependencies {
implementation("io.cogbox:sdk:x.y.z")
}Maven (pom.xml):
<dependency> <groupId>io.cogbox</groupId> <artifactId>sdk</artifactId> <version>x.y.z</version> </dependency>
Standalone packages and libraries for interacting with Cogbox using Java:
Deployments
Cogbox is available as a managed service on cogbox.pazity.com. Cogbox can run as a fully hosted service, as an open-source stack you operate, or in a hybrid setup where Cogbox orchestrates sandboxes while execution happens on machines you manage.
- Open source deployment: full local stack from the
dockerdirectory using Docker Compose - Customer managed compute: custom regions and runner machines that operate Cogbox sandboxes on your own compute infrastructure
Quick Start
- Create an account at cogbox.pazity.com
- Generate an API key
- Create a sandbox
Python SDK
from cogbox import Cogbox, CogboxConfig config = CogboxConfig(api_key="YOUR_API_KEY") cogbox = Cogbox(config) sandbox = cogbox.create() response = sandbox.process.code_run('print("Hello World!")') print(response.result)
Typescript SDK
import { Cogbox } from "@cogbox/sdk"; const cogbox = new Cogbox({ apiKey: "YOUR_API_KEY" }); const sandbox = await cogbox.create(); const response = await sandbox.process.codeRun('print("Hello World!")'); console.log(response.result);
Ruby SDK
require 'cogbox' config = Cogbox::Config.new(api_key: 'YOUR_API_KEY') cogbox = Cogbox::Cogbox.new(config) sandbox = cogbox.create response = sandbox.process.code_run(code: 'print("Hello World!")') puts response.result
Go SDK
package main import ( "context" "fmt" "github.com/cognifyi/cogbox/libs/sdk-go/pkg/cogbox" "github.com/cognifyi/cogbox/libs/sdk-go/pkg/types" ) func main() { config := &types.CogboxConfig{APIKey: "YOUR_API_KEY"} client, _ := cogbox.NewClientWithConfig(config) ctx := context.Background() sandbox, _ := client.Create(ctx, nil) response, _ := sandbox.Process.ExecuteCommand(ctx, "echo 'Hello World!'") fmt.Println(response.Result) }
Java SDK
import io.cogbox.sdk.Cogbox; import io.cogbox.sdk.CogboxConfig; import io.cogbox.sdk.Sandbox; import io.cogbox.sdk.model.ExecuteResponse; public class Main { public static void main(String[] args) { CogboxConfig config = new CogboxConfig.Builder() .apiKey("YOUR_API_KEY") .build(); try (Cogbox cogbox = new Cogbox(config)) { Sandbox sandbox = cogbox.create(); ExecuteResponse response = sandbox.getProcess().executeCommand("echo 'Hello World!'"); System.out.println(response.getResult()); } } }
API
curl 'https://cogbox.pazity.com/api/sandbox' \ --request POST \ --header 'Authorization: Bearer <YOUR_API_KEY>' \ --header 'Content-Type: application/json' \ --data '{}'
CLI
cogbox create
Development
Devcontainer (full environment)
Open this repository in a devcontainer-compatible editor (VS Code, GitHub Codespaces) for a batteries-included setup with all languages, tools, and supporting services.
Nix (lightweight, agent-friendly)
If you prefer working outside the devcontainer — or are an AI agent executing build commands — use the Nix dev shells:
# Enter the full dev shell (Go + Node + Python + Ruby + JDK) nix develop # Or pick a language-specific shell nix develop .#go # Go services & libs nix develop .#node # TypeScript / Node.js apps & libs nix develop .#python # Python SDKs & libs nix develop .#ruby # Ruby SDKs & libs nix develop .#java # Java SDKs & libs
Prerequisites: Nix with flakes enabled (experimental-features = nix-command flakes in ~/.config/nix/nix.conf).
For non-interactive / CI usage:
nix develop .#go --command bash -c "go build ./..."Optional: Install direnv + nix-direnv for automatic shell activation when you cd into the project.
See AGENTS.md for the full shell reference, project-to-shell mapping, and common commands.
Note: Supporting services (PostgreSQL, Redis, etc.) are still managed via
docker compose -f .devcontainer/docker-compose.yaml up.
Contributing
来源:GitHub · github.com