Skip to content

feat: Add Docker and SSH sandbox backend support #23

Description

@Peefy

Summary

Expand the sandbox execution system to support Docker containers and SSH remote execution as additional isolation backends beyond the existing Native, Claude (srt), and Vercel providers.

Motivation

OpenLoomi currently has a well-architected sandbox system (packages/ai/src/agent/sandbox/) with:

  • NativeProvider — direct host execution (no isolation)
  • ClaudeProvider — process isolation via Anthropic srt
  • VercelProvider — VM isolation via Firecracker MicroVMs

However, it's missing two common enterprise-grade isolation options:

Backend Use Case Priority
Docker Container isolation, reproducible environments High
SSH Remote server execution, CI/CD integration Medium

Current Sandbox Architecture

packages/ai/src/agent/sandbox/
├── types.ts           # ISandboxProvider interface
├── plugin.ts          # BaseSandboxProvider, defineSandboxPlugin()
├── registry.ts        # SandboxRegistry
└── providers/
    ├── native.ts      # ✅ existing
    ├── claude.ts      # ✅ existing
    ├── vercel.ts      # ✅ existing
    ├── docker.ts      # ❌ missing
    └── ssh.ts         # ❌ missing

Implementation Details

Docker Backend

  • Use Docker Engine API or docker CLI
  • Support image specification (node, python, bun)
  • Resource limits (CPU, memory, network)
  • Volume mounts for workspace
  • Container lifecycle management
interface DockerConfig {
  image: string;           // e.g., \"node:22\", \"python:3.13\"
  network: 'bridge' | 'none';
  memory?: string;         // e.g., \"512m\"
  cpu?: number;            // e.g., 1
  volumes?: string[];      // mount points
}

SSH Backend

  • Use ssh2 library or CLI
  • Support key-based and password authentication
  • Command execution with timeout
  • Stream output back to client
  • Connection pooling
interface SSHConfig {
  host: string;
  port: number;
  username: string;
  auth: 'key' | 'password';
  privateKey?: string;
  password?: string;
  cwd?: string;            // working directory
  timeout?: number;
}

Requirements

  • Follow existing ISandboxProvider interface
  • Implement exec() and runScript() methods
  • Add provider to BuiltinSandboxProviderType
  • Schema validation via getDockerConfigSchema(), getSSHConfigSchema()
  • Register in SandboxRegistry
  • Unit tests
  • Documentation

References

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions