sandboxbackend

package
v0.0.0-...-a766d22 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureAgentSandboxAPIsRegistered

func EnsureAgentSandboxAPIsRegistered(ctx context.Context, c client.Client) error

EnsureAgentSandboxAPIsRegistered checks that the apiserver exposes the agent-sandbox resources kagent needs (SandboxTemplate, SandboxClaim, Sandbox). Call this before creating or reconciling SandboxAgent when a sandbox backend is configured.

When CRDs are missing, the apiserver returns a *meta.NoKindMatchError (or similar); that surfaces as a clear prerequisite error instead of a late reconcile failure.

func FilterTranslatorOwnedTypesForList

func FilterTranslatorOwnedTypesForList(cl client.Client, agent v1alpha2.AgentObject, translatorOwnedTypes []client.Object, backend Backend) ([]client.Object, error)

FilterTranslatorOwnedTypesForList returns the owned-resource types the reconciler should pass to FindOwnedObjects. It drops sandbox-backend-only types when the workload is not sandbox, so reconcile does not List agent-sandbox APIs on clusters where those CRDs are not installed. For sandbox workloads it keeps only the owned types for the agent's sandbox platform.

translatorOwnedTypes is typically AdkApiTranslator.GetOwnedResourceTypes() (full set used for watches).

func NormalizeAllowedDomainHost

func NormalizeAllowedDomainHost(raw string) (string, bool)

NormalizeAllowedDomainHost trims an AgentHarness allowedDomains entry into a hostname or glob suitable for sandbox.v1.NetworkEndpoint.host. URLs and host:port forms are accepted.

func ValidateSandboxPlatform

func ValidateSandboxPlatform(backend Backend, agent v1alpha2.AgentObject) error

ValidateSandboxPlatform reports whether backend supports the agent's sandbox platform.

Types

type AsyncBackend

type AsyncBackend interface {
	// Name identifies the backend for AgentHarness.Status.BackendRef.Backend
	// and logging.
	Name() v1alpha2.AgentHarnessBackendType

	// EnsureAgentHarness creates the sandbox on the backend if it does not
	// already exist. Implementations must be idempotent — if a sandbox
	// matching sbx.Name is already present, return its current handle.
	EnsureAgentHarness(ctx context.Context, ah *v1alpha2.AgentHarness) (EnsureResult, error)

	// GetStatus returns a Ready condition (status, reason, message) for
	// the sandbox identified by h. Used to refresh AgentHarness.Status after
	// each reconcile.
	GetStatus(ctx context.Context, h Handle) (metav1.ConditionStatus, string, string)

	// DeleteAgentHarness releases the sandbox. It performs at most one
	// reconcile-safe delete step and returns done=true once the sandbox is gone.
	// NotFound must be treated as success so the finalizer can be removed
	// idempotently.
	DeleteAgentHarness(ctx context.Context, h Handle) (done bool, err error)

	// OnAgentHarnessReady runs one-time work after the AgentHarness reports
	// Ready (for example ExecSandbox bootstrap inside the VM). Backends that
	// have no post-ready work should return nil.
	OnAgentHarnessReady(ctx context.Context, ah *v1alpha2.AgentHarness, h Handle) error
}

AsyncBackend is the minimal surface a gRPC/HTTP-driven sandbox control plane must implement to back the kagent.dev/v1alpha2 AgentHarness CRD. It is deliberately separate from Backend (which serves SandboxAgent's in-cluster agent-runtime flow).

type Backend

type Backend interface {
	BuildSandbox(ctx context.Context, in BuildInput) ([]client.Object, error)
	GetOwnedResourceTypes() []client.Object
	// OwnedResourceTypesFor returns owned types for the agent's sandbox platform (for reconcile lists).
	OwnedResourceTypesFor(agent v1alpha2.AgentObject) ([]client.Object, error)

	// ComputeReady reflects implementation-specific status into condition pieces for Agent.status.
	ComputeReady(ctx context.Context, cl client.Client, nn types.NamespacedName) (status metav1.ConditionStatus, reason, message string)
}

Backend builds sandbox CRD objects and evaluates their readiness.

type BuildInput

type BuildInput struct {
	Agent        v1alpha2.AgentObject
	PodTemplate  corev1.PodTemplateSpec
	WorkloadName string
	ExtraLabels  map[string]string
}

BuildInput carries the pod template for a Sandbox workload (agents.x-k8s.io Sandbox).

type EnsureResult

type EnsureResult struct {
	Handle   Handle
	Endpoint string
}

EnsureResult is returned by EnsureAgentHarness. Endpoint (if set) is surfaced to users via AgentHarness.Status.Connection (OpenShell: gateway URL#sandbox id; Substrate: kagent gateway proxy path).

type Handle

type Handle struct {
	ID string
}

Handle is the opaque identifier an AsyncBackend uses to address a sandbox it owns on an external control plane. Persisted in AgentHarness.Status.BackendRef.

type RoutingBackend

type RoutingBackend struct {
	AgentSandbox Backend
	Substrate    Backend
}

RoutingBackend delegates to agent-sandbox or Agent Substrate based on spec.platform.

func NewRoutingBackend

func NewRoutingBackend(agentSandbox, substrate Backend) *RoutingBackend

NewRoutingBackend returns a backend that routes SandboxAgent workloads by platform.

func (*RoutingBackend) BuildSandbox

func (r *RoutingBackend) BuildSandbox(ctx context.Context, in BuildInput) ([]client.Object, error)

func (*RoutingBackend) ComputeReady

func (*RoutingBackend) GetOwnedResourceTypes

func (r *RoutingBackend) GetOwnedResourceTypes() []client.Object

func (*RoutingBackend) OwnedResourceTypesFor

func (r *RoutingBackend) OwnedResourceTypesFor(agent v1alpha2.AgentObject) ([]client.Object, error)

OwnedResourceTypesFor returns owned-resource types for the agent's sandbox platform.

func (*RoutingBackend) ValidatePlatform

func (r *RoutingBackend) ValidatePlatform(agent v1alpha2.AgentObject) error

ValidatePlatform reports whether this routing backend can reconcile the agent's sandbox platform.

Directories

Path Synopsis
Package openshell implements sandboxbackend.AsyncBackend against an external OpenShell gateway over gRPC.
Package openshell implements sandboxbackend.AsyncBackend against an external OpenShell gateway over gRPC.

Jump to

Keyboard shortcuts

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