Help us shape the future of Go! Take the 2026 Go Developer Survey

selfhosted

package
v0.1.0-alpha.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

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

View Source
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

func ReadWorkSecret(reader io.Reader) (string, error)

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

func SandboxHealthcheck(ctx context.Context, workdir string) (retErr error)

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.

func WriteWorkSecret

func WriteWorkSecret(writer io.Writer, secret string) error

WriteWorkSecret writes one bounded, length-prefixed Work secret to a launcher-owned transport. The frame is internal to first-party launchers; it is not part of Mango's HTTP or SDK contract.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL