gateway

package
v0.7.48 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package gateway owns the "installed on first agent use" half: making sure the pinned docker-mcp-gateway and harness images are present and the local runner image is built, before any run needs them. Only the containerized gateway is supported: the CLI-plugin auto-install path is rejected for its supply-chain surface.

Index

Constants

View Source
const CoderRecordFile = "/etc/agentry/coder/record"

CoderRecordFile is where the Coding agent's toolchain image records each tool's version and the Debian snapshot it was built from, read back into the receipt.

View Source
const ExecFailedFile = "/etc/agentry/exec-failed"

ExecFailedFile is where an Unsafe Mode exec image build records what did not install ("what<TAB>why" a line). An image whose record is not empty is rebuilt on its next use rather than reused, so a passing mirror or PyPI fault does not leave a tool missing for good under the same tag.

View Source
const ExecPackagesFile = "/etc/agentry/exec-packages"

ExecPackagesFile is where the exec image build records the resolved versions of the catalogued packages it installed ("name-version" per line, `apk list --installed`), read back into the receipt.

View Source
const NewestCheckEvery = 24 * time.Hour

NewestCheckEvery is how often a vendor is asked for its newest release. Between asks, the image built from the newest release (or the tested one) is used as it is.

View Source
const PodmanRuntimeRecipe = "register it in containers.conf under [engine.runtimes], the name as a path to a script that runs the runtime binary (rootless podman needs `runsc --ignore-cgroups`), and docker.gatewayRuntime as a second script that adds " + dockerx.HostUDSOpen

PodmanRuntimeRecipe is how a runtime is registered with podman: by name, as a path, in the operator's containers.conf. The runtime's own flags go in a wrapper script, since podman passes none; the gateway's wrapper adds --host-uds=open, and a rootless podman needs --ignore-cgroups.

Variables

This section is empty.

Functions

func EnsureExecImage

func EnsureExecImage(ctx context.Context, d dockerx.Client, runnerImage string, img spec.ExecImageSpec, ctxDir string, logw io.Writer) ([]string, error)

EnsureExecImage builds the per-QuickAgent exec image for a plan when absent: `FROM <runnerImage>`, the operator's catalogued apk packages installed (from the policy's mirror when one is named) with their resolved versions recorded into the image, git's safe.directory when git is declared, then one exec-form RUN of the runner binary's `minimize` role, so the resulting image holds only the declared commands (and the runner binary that serves the tools). The context is a generated Dockerfile under ctxDir. Returns the resolved package versions, read from the image whether it was built now or found; nil when no exec is declared.

An Unsafe Mode exec image (img.Unsafe) is built from the unsafe base instead and rebuilt when its last build left tools uninstalled; its result lists what installed, then what did not, each of those marked spec.ExecNotInstalledPrefix.

func EnsureHarnessImage

func EnsureHarnessImage(ctx context.Context, d dockerx.Client, adapterName string, h policy.HarnessImage, logw io.Writer) error

EnsureHarnessImage makes adapterName's harness image h present: pulled by its pinned ref, which names a digest, or built here from the artifact it is pinned by. Setup prepares the default adapter's image with it, a run its plan's (EnsureInstalledFor).

func EnsureHarnessImageBuilding added in v0.7.4

func EnsureHarnessImageBuilding(ctx context.Context, d dockerx.Client, adapterName string, h policy.HarnessImage, logw io.Writer, building func(version string)) error

EnsureHarnessImageBuilding is EnsureHarnessImage that also tells building the vendor release's version when an image is built here, before its download starts, so a caller can say a build is under way; nil tells nothing.

func EnsureInstalled

func EnsureInstalled(ctx context.Context, d dockerx.Client, pol *policy.Policy,
	runnerTag, imageCtxDir string, logw io.Writer, harnessImage bool,
) error

EnsureInstalled verifies the docker engine answers, pulls the pinned gateway + harness images if absent, and builds the local runner image from the embedded context if absent. Called from the install step of `agentry run`: after this returns nil, a run needs no further network access for infrastructure. harnessImage says whether this run needs the pinned harness image at all: an adapter that drives the person's own installation runs no container, so pulling docker-agent for it would be a download nobody asked for.

func EnsureInstalledFor

func EnsureInstalledFor(ctx context.Context, d dockerx.Client, pol *policy.Policy,
	runnerTag, imageCtxDir string, logw io.Writer, plan *spec.Plan,
) error

EnsureInstalledFor is EnsureInstalled for one plan: the harness image prepared is the one the plan's adapter runs and no other, none for a host harness. A published image is pulled by its pinned ref; one pinned by the artifact it is built from is built on this machine (harnessbuild), refused when this build cannot build it.

func EnsureNewestHarnessImage added in v0.7.4

func EnsureNewestHarnessImage(ctx context.Context, d dockerx.Client, pol *policy.Policy, recordPath, adapterName string, logw io.Writer, building func(version string)) (policy.HarnessImage, error)

EnsureNewestHarnessImage makes the image adapterName runs in present the way setup does: from the vendor's newest release first, when it is newer than the release this build pins and passes every check, else from the tested pin. The image is recorded beside pol's file and set in pol, so a run compiled after it runs in it; it is returned. A policy that pins the image itself, an adapter whose newest release is never tried, or a policy read from no file takes its pin as EnsureHarnessImageBuilding does. The vendor is asked at most once every NewestCheckEvery; between asks the recorded image is used, and built again from the record if it is gone. building is told the version of any image built, before its download.

func EnsurePodmanRuntime

func EnsurePodmanRuntime(ctx context.Context, d dockerx.Client, e dockerx.Engine, pol *policy.Policy) error

EnsurePodmanRuntime is EnsureRuntime on podman: the policy's runtime, and the gateway's, are each tried by name (`podman --runtime <name> info`), since podman lists every runtime its configuration names, installed or not, and the gateway's registration is read for --host-uds=open and the runtime it runs. The sandbox is held through podman's own CLI alone: the docker CLI's route to podman cannot read a container's runtime back (podman's Docker-compatible API answers "oci" for every container), and a podman service on another machine (a podman machine) is refused by Engine.

func EnsureRunnerImage

func EnsureRunnerImage(ctx context.Context, d dockerx.Client, pol *policy.Policy, runnerTag, imageCtxDir string, logw io.Writer) error

EnsureRunnerImage builds the local runner image from the embedded context when it is missing, and does nothing else: no daemon check, no pull. A step that needs only the runner's own binary (a later delivery) calls it alone.

func EnsureRuntime

func EnsureRuntime(ctx context.Context, d dockerx.Client, pol *policy.Policy) error

EnsureRuntime refuses, before anything is pulled or started, a policy whose docker.runtime the daemon has not registered: a run that quietly landed on runc after asking for runsc would carry a receipt claiming an isolation it did not have. The error names the runtime the policy wants and the ones the daemon has. The gateway's own runtime (docker.gatewayRuntime) is held to the same rule, and by what it runs as well as its name: it must be docker.runtime's binary registered again with --host-uds=open and nothing else, since the receipt says the gateway ran under it. An unset runtime asks nothing. On podman each name is tried (EnsurePodmanRuntime).

Types

This section is empty.

Jump to

Keyboard shortcuts

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