sandbox

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package sandbox provides isolation for untrusted tool/skill execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerConfig

type ContainerConfig struct {
	Image       string
	SocketPath  string
	MemoryBytes int64
	CPUQuota    int64
	NetworkMode string
}

ContainerConfig holds container sandbox configuration.

type ContainerSandbox

type ContainerSandbox struct {
	Image string

	// Resource limits
	MemoryBytes int64
	CPUQuota    int64
	NetworkMode string
	// contains filtered or unexported fields
}

ContainerSandbox implements Sandbox using Docker Engine API for production-grade isolation.

func NewContainerSandbox

func NewContainerSandbox(cfg ContainerConfig) *ContainerSandbox

NewContainerSandbox creates a Docker-based sandbox.

func (*ContainerSandbox) Close

func (c *ContainerSandbox) Close() error

func (*ContainerSandbox) Execute

func (c *ContainerSandbox) Execute(ctx context.Context, command string, args []string, timeout time.Duration) (*Result, error)

type ProcessSandbox

type ProcessSandbox struct {
	WorkDir string
}

ProcessSandbox runs commands in a subprocess with timeouts. For production, replace with container-based isolation (gVisor, Firecracker, etc.).

func NewProcessSandbox

func NewProcessSandbox(workDir string) *ProcessSandbox

func (*ProcessSandbox) Close

func (s *ProcessSandbox) Close() error

func (*ProcessSandbox) Execute

func (s *ProcessSandbox) Execute(ctx context.Context, command string, args []string, timeout time.Duration) (*Result, error)

type Result

type Result struct {
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
	ExitCode int    `json:"exit_code"`
}

Result captures the output of a sandboxed execution.

type Sandbox

type Sandbox interface {
	Execute(ctx context.Context, command string, args []string, timeout time.Duration) (*Result, error)
	Close() error
}

Sandbox defines the interface for executing untrusted code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL