Skip to main content

Sandbox Plugin - Isolated Code Execution

ยท One min read
Mark Dierolf
Creator of TokenRing AI

The Sandbox plugin provides secure, isolated environments for running untrusted code and commands.

Key Featuresโ€‹

๐Ÿ”’ Abstract Provider Interfaceโ€‹

Extensible for multiple sandbox backends including Docker, Kubernetes, and other container runtimes.

๐Ÿณ Container Lifecycleโ€‹

Complete container management:

  • Create: Spin up new containers with custom images
  • Execute: Run commands in isolated environments
  • Stop: Gracefully stop containers
  • Remove: Clean up resources
  • Logs: Access container output

๐Ÿ› ๏ธ Agent Integrationโ€‹

Tools and chat commands for interactive control:

/sandbox create ubuntu:latest
/sandbox exec echo "Hello from sandbox"
/sandbox logs
/sandbox remove

Usageโ€‹

const provider = new DockerSandboxProvider();
const { containerId } = await provider.createContainer({
image: 'python:3.9',
environment: { SCRIPT: 'print("Hello")' },
workingDir: '/app'
});

const result = await provider.executeCommand(
containerId,
'python -c "print(2+2)"'
);
console.log(result.stdout); // "4"

await provider.stopContainer(containerId);
await provider.removeContainer(containerId);

Security Benefitsโ€‹

  • Isolation: Code runs in separate containers
  • Resource Limits: Control CPU, memory, and timeout
  • Clean State: Each execution starts fresh
  • No Host Access: Sandboxed from host filesystem

Perfect for running AI-generated code safely, testing in isolated environments, and executing untrusted scripts.


Mark Dierolf
Creator of TokenRing AI