Documentation
¶
Overview ¶
Package sandbox provides optional Docker isolation for agent shell and code tools.
Index ¶
- type Config
- type DockerRunner
- type Env
- func (e *Env) Exec(ctx context.Context, opts env.ExecOptions) result.Result[env.Capture, result.ExecutionError]
- func (e *Env) MkdirAll(ctx context.Context, path string, perm os.FileMode) result.Result[struct{}, result.FileError]
- func (e *Env) ReadFile(ctx context.Context, path string) result.Result[[]byte, result.FileError]
- func (e *Env) Remove(ctx context.Context, path string) result.Result[struct{}, result.FileError]
- func (e *Env) WriteFile(ctx context.Context, path string, data []byte, perm os.FileMode) result.Result[struct{}, result.FileError]
- type RunOptions
- type Runner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Image is the container image used for Exec.
Image string
// Network is the Docker network mode.
Network string
// Memory limits container memory (e.g. "512m").
Memory string
// Workspace is the host workspace path bind-mounted at the same path inside the container.
Workspace string
}
Config configures Docker sandbox execution.
func ConfigFromChatAgent ¶
func ConfigFromChatAgent(cfg config.ChatAgentSandboxConfig, workspace string) Config
ConfigFromChatAgent builds sandbox Config from chat agent settings.
type DockerRunner ¶
type DockerRunner struct{}
DockerRunner runs commands via the Docker Engine API.
func (DockerRunner) Run ¶
func (DockerRunner) Run(ctx context.Context, opts RunOptions) (env.Capture, error)
Run starts an ephemeral container, waits for exit, and returns captured output.
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env implements env.ExecutionEnv with host filesystem ops and sandboxed Exec.
func New ¶
func New(cfg Config, host env.ExecutionEnv, runner Runner) *Env
New creates a sandbox ExecutionEnv. Host FS ops use env.Default when host is nil.
func (*Env) Exec ¶
func (e *Env) Exec(ctx context.Context, opts env.ExecOptions) result.Result[env.Capture, result.ExecutionError]
Exec runs the command inside a sandbox container with the workspace mounted.
func (*Env) MkdirAll ¶
func (e *Env) MkdirAll(ctx context.Context, path string, perm os.FileMode) result.Result[struct{}, result.FileError]
MkdirAll creates directories on the host filesystem.
Click to show internal directories.
Click to hide internal directories.