Documentation
¶
Overview ¶
Package sandboxlifecycle decides whether the Docker sandbox needs starting and, when it does, brings it up — reporting whether the caller now owns it. The ownership signal lets callers tear down only the sandbox they started.
Index ¶
- Variables
- func ConfirmExternalAccess(allowExternal, interactive bool, in io.Reader, out io.Writer) error
- func DefaultExternalAccessConfirm(cfg *config.Config) func() error
- func Ensure(ctx context.Context, sb Sandbox, confirm func() error) (startedByUs bool, err error)
- func NewExecutor(ctx context.Context, cfg *config.Config) (*container.ContainerExecutor, string, func(), error)
- type Result
- type Sandbox
Constants ¶
This section is empty.
Variables ¶
var ErrExternalAccessDeclined = errors.New("external network access declined")
ErrExternalAccessDeclined is returned when the user answers no to the unrestricted-network-access prompt.
var ErrExternalAccessNeedsTTY = errors.New("allow_external = true requires interactive confirmation, but no TTY is available")
ErrExternalAccessNeedsTTY is returned when allow_external is true but no interactive terminal is available to confirm it. There is no bypass.
Functions ¶
func ConfirmExternalAccess ¶ added in v0.11.4
ConfirmExternalAccess gates unrestricted external network access behind a y/N prompt. When allowExternal is false it is a no-op. When true and interactive, it warns on out and reads the answer from in, returning nil only for "y"/"yes" and ErrExternalAccessDeclined otherwise. When true and not interactive, it returns ErrExternalAccessNeedsTTY.
func DefaultExternalAccessConfirm ¶ added in v0.11.4
DefaultExternalAccessConfirm returns a confirm callback for Ensure that reads from stdin and warns on stderr, treating a terminal-attached stdin as interactive.
func Ensure ¶
Ensure makes sb running. If it is already running, Ensure does nothing and reports startedByUs=false (the caller must not tear it down). If it was not running, Ensure invokes confirm (when non-nil) before calling Up; a non-nil error from confirm aborts startup. On success, Ensure brings sb up and reports startedByUs=true. Any failure is returned and startedByUs is false.
func NewExecutor ¶
func NewExecutor(ctx context.Context, cfg *config.Config) (*container.ContainerExecutor, string, func(), error)
NewExecutor connects to Docker and builds a container executor for cfg's sandbox project (named deterministically from the current directory). The returned cleanup closes the Docker client and must be called by the caller.
Types ¶
type Result ¶
type Result struct {
Executor *container.ContainerExecutor
ProjectName string
StartedByUs bool
// contains filtered or unexported fields
}
Result carries the outcome of EnsureUp: the executor to run/tear down the sandbox, its project name, and whether this call started it.
func EnsureUp ¶
EnsureUp builds the executor for cfg and ensures the sandbox is running. On any failure it closes the Docker client and returns the error; Claude must not be launched in that case.
func (*Result) Close ¶
func (r *Result) Close()
Close releases the Docker client. Safe to call multiple times.