Documentation
¶
Overview ¶
Package selfhosted implements operator-side launchers for Mango's self_hosted Environment Work protocol. Provider code lives here, outside the control plane: the provider only supplies compute while the Mango SDK owns lease, event-recovery, tool-result, and Stop semantics.
Index ¶
- Constants
- func CloseSandboxTools(tools []mango.SessionTool) error
- func ReadWorkSecret(reader io.Reader) (string, error)
- func SandboxHealthcheck(ctx context.Context, workdir string) (retErr error)
- func SandboxTools(workdir string) ([]mango.SessionTool, error)
- func SandboxToolsForSession(session mango.EnvironmentWorkerToolContext) ([]mango.SessionTool, error)
- func WriteWorkSecret(writer io.Writer, secret string) error
- type DockerLauncher
- type DockerLauncherOptions
Constants ¶
const (
DefaultWorkerImage = "mango-self-hosted-worker:local"
)
Variables ¶
This section is empty.
Functions ¶
func CloseSandboxTools ¶
func CloseSandboxTools(tools []mango.SessionTool) error
CloseSandboxTools releases stateful tools created directly with SandboxTools. EnvironmentWorker owns and closes tools returned by SandboxToolsForSession.
func ReadWorkSecret ¶
ReadWorkSecret reads one frame written by WriteWorkSecret. Callers should close the transport immediately after this returns so later tool processes cannot recover the credential from an inherited descriptor.
func SandboxHealthcheck ¶
SandboxHealthcheck proves subprocess execution and workspace read/write. Its program is fixed, receives no caller input, emits no process output, and inherits no credentials. The Docker launcher supplies an ephemeral workspace.
func SandboxTools ¶
func SandboxTools(workdir string) ([]mango.SessionTool, error)
SandboxTools builds the SDK's provider-neutral agent toolset only after a launcher has marked this process as sandboxed. It prevents the first-party Docker command from accidentally becoming a host-process fallback.
func SandboxToolsForSession ¶
func SandboxToolsForSession(session mango.EnvironmentWorkerToolContext) ([]mango.SessionTool, error)
SandboxToolsForSession binds the core toolset after EnvironmentWorker has materialized this Session's Memory Stores and supplied their access policy.
Types ¶
type DockerLauncher ¶
type DockerLauncher struct {
// contains filtered or unexported fields
}
DockerLauncher polls one self-hosted Environment and runs each acknowledged item in a hardened, per-Work Docker container. A workspace is reused by all Work items for the same Session, using a named volume by default.
func NewDockerLauncher ¶
func NewDockerLauncher(engine dockerEngine, opts DockerLauncherOptions) (*DockerLauncher, error)
NewDockerLauncher creates a launcher over an already-connected Docker Engine client. Callers normally pass the result of client.New(client.FromEnv) after a negotiated Ping; accepting the narrow interface keeps lifecycle tests independent of a daemon.
func (*DockerLauncher) Run ¶
func (l *DockerLauncher) Run(ctx context.Context) error
Run owns Poll and Ack on the host and waits for each item container to exit. The item-side EnvironmentWorker inside the container owns heartbeat, Session execution, permanent-input Fail, and final Stop. Transient item failures are logged and left for the normal Environment Work reclaim path.
type DockerLauncherOptions ¶
type DockerLauncherOptions struct {
Client *mango.Client
EnvironmentID string
WorkerID string
Image string
SandboxBaseURL string
RunnerPath string
NetworkMode string
User string
// WorkspaceRoot optionally binds <root>/<session-id> at /workspace. The
// operator prepares and owns these directories on the Docker daemon host.
WorkspaceRoot string
Drain bool
BlockMs mango.Optional[int64]
ReclaimAfterMs mango.Optional[int64]
MaxIdle time.Duration
Logger *slog.Logger
MemoryBytes int64
NanoCPUs int64
PidsLimit int64
}
DockerLauncherOptions configure a trusted host-side queue consumer. Client carries the Environment credential and is used only by WorkPoller. The launcher passes the per-item Work secret, never that client credential, into Docker.