Documentation
¶
Overview ¶
Package sandbox provides Docker sandbox lifecycle management including creation, detection, argument building, and environment forwarding.
Index ¶
- func EnvForAgent(ctx context.Context, agentRef string, env environment.Provider) (flags, envVars []string)
- func ExtraWorkspace(wd, agentRef string) string
- func ResolveAlias(name string) string
- func StartTokenWriterIfNeeded(ctx context.Context, dir, modelsGateway string) func()
- type Backend
- func (b *Backend) BuildExecCmd(ctx context.Context, name, wd string, cagentArgs, envFlags, envVars []string) *exec.Cmd
- func (b *Backend) CheckAvailable(ctx context.Context) error
- func (b *Backend) Ensure(ctx context.Context, wd, extra, template, configDir string) (string, error)
- func (b *Backend) ForWorkspace(ctx context.Context, wd string) *Existing
- type Existing
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnvForAgent ¶
func EnvForAgent(ctx context.Context, agentRef string, env environment.Provider) (flags, envVars []string)
EnvForAgent loads the agent config and gathers the environment variables it requires. It returns:
- flags: `-e KEY` args for docker sandbox exec (name only, no value)
- envVars: `KEY=VALUE` entries to set on the exec process environment
Variables that Docker Desktop already proxies are skipped.
func ExtraWorkspace ¶
ExtraWorkspace returns the directory to mount as a read-only extra workspace when the agent file lives outside the main workspace. Returns "" if no extra mount is needed (file is under wd, is not a local path, etc.).
func ResolveAlias ¶
ResolveAlias returns the alias path if name is a user-defined alias, or an empty string otherwise.
func StartTokenWriterIfNeeded ¶
StartTokenWriterIfNeeded starts a background goroutine that refreshes DOCKER_TOKEN into a shared file when a models gateway is configured. Returns a stop function that is safe to call multiple times (and is a no-op when no writer was started).
Types ¶
type Backend ¶ added in v1.44.0
type Backend struct {
// contains filtered or unexported fields
}
Backend describes how to invoke sandbox CLI commands. The two supported backends are "docker sandbox" and "sbx".
func NewBackend ¶ added in v1.44.0
NewBackend returns the appropriate backend. When preferSbx is true and the "sbx" binary is on PATH, the sbx backend is used; otherwise it falls back to "docker sandbox".
func (*Backend) BuildExecCmd ¶ added in v1.44.0
func (b *Backend) BuildExecCmd(ctx context.Context, name, wd string, cagentArgs, envFlags, envVars []string) *exec.Cmd
BuildExecCmd assembles the sandbox exec command.
func (*Backend) CheckAvailable ¶ added in v1.44.0
CheckAvailable returns a user-friendly error when Docker is not installed or the sandbox feature is not supported.
func (*Backend) Ensure ¶ added in v1.44.0
func (b *Backend) Ensure(ctx context.Context, wd, extra, template, configDir string) (string, error)
Ensure makes sure a sandbox exists for the given workspace, creating or recreating it as needed. When template is non-empty it is passed to `docker sandbox create -t`. Returns the sandbox name.
type Existing ¶
Existing holds the name and workspaces of an existing Docker sandbox.
func (*Existing) HasWorkspace ¶
HasWorkspace reports whether the sandbox has dir mounted as a workspace.