Documentation
¶
Overview ¶
Package sandbox provides optional Docker isolation for agent shell and code tools.
Index ¶
- func EnsureAgentReadable(path string) error
- func ResolvedCLIBinary() string
- 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) ReadDir(ctx context.Context, path string) result.Result[[]env.DirEntry, 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 KernRunner
- type RunOptions
- type Runner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureAgentReadable ¶ added in v0.99.12
EnsureAgentReadable makes path readable by the sandbox container user (uid 1000). Prefer chown to the agent user with owner-only mode; if chown fails (non-root / Windows), fall back to world-accessible mode for the ephemeral temp path. Directories use modes with the execute bit so the agent can traverse into them.
func ResolvedCLIBinary ¶ added in v0.99.1
func ResolvedCLIBinary() string
ResolvedCLIBinary returns an absolute path to flowbot-cli_linux_amd64 beside the server executable. Missing or invalid siblings warn once and return empty; runners inject a failing stub instead.
Types ¶
type Config ¶
type Config struct {
// Runtime selects the sandbox backend (docker or kern). Empty defaults to docker.
Runtime string
// SecurityProfile sets kern --security-profile when Runtime is kern.
SecurityProfile string
// 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. By default it is bind-mounted at the same path
// inside the container; when WorkspaceInject is set (Docker only), it is copied to /workspace.
Workspace string
// WorkspaceInject copies the host Workspace into /workspace via the Docker API instead of
// bind-mounting. Ignored when Runtime is kern (bind mount remains).
WorkspaceInject bool
// ServerURL is the Flowbot API URL injected for the flowbot CLI inside the container.
ServerURL string
// AccessToken is the Hub access token injected for the flowbot CLI inside the container.
AccessToken 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 (bind-mounted or inject-copied workspace).
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.
func (*Env) ReadDir ¶ added in v0.96.0
func (e *Env) ReadDir(ctx context.Context, path string) result.Result[[]env.DirEntry, result.FileError]
ReadDir lists directory entries on the host filesystem.
type KernRunner ¶ added in v0.99.12
KernRunner runs commands via the kern CLI.
func (KernRunner) Run ¶ added in v0.99.12
func (r KernRunner) Run(ctx context.Context, opts RunOptions) (env.Capture, error)
Run starts an ephemeral kern box, waits for exit, and returns captured output.
type RunOptions ¶
type RunOptions struct {
Image string
Network string
Memory string
Workspace string
WorkDir string
Command string
Argv []string
ServerURL string
AccessToken string
// Env is appended to the container environment (KEY=VALUE).
Env []string
// Stdin is process input; non-empty values are written to .flowbot-stdin under the host workdir.
Stdin []byte
// WorkspaceInject copies opts.Workspace into /workspace instead of bind-mounting (Docker only).
WorkspaceInject bool
// CLIConfigDir is a host directory bind-mounted read-only at containerCLIConfigPath (kern only).
// When empty and AccessToken is set, KernRunner materializes a temporary directory.
CLIConfigDir string
// CLIBinary is a host path to a linux/amd64 flowbot CLI file (sibling of the server binary).
// DockerRunner copies it into the container via the Engine API; KernRunner stages a bind dir.
CLIBinary string
// CLIBinaryDir is a host directory bind-mounted read-only at containerCLIDirPath (kern only).
// When empty, KernRunner materializes a real CLI or stub directory.
CLIBinaryDir string
}
RunOptions configures one sandbox command invocation.