hostedagent

package
v0.26.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 27 Imported by: 0

README

Hosted agent instance reconciliation

HostedAgentInstance resources are reconciled through pkg/agentbackend. The controller owns Obot-specific resolution and passes only normalized, runtime-ready configuration to the selected backend.

The controller:

  • validates an explicitly selected pool against the user's assignments;
  • selects the user's default assignment, or lazily creates a deterministic pool and default assignment from the deployment-wide default HostedAgentPoolDefaults;
  • uses the instance UID as the stable backend identity;
  • installs a finalizer before creating backend resources;
  • calculates an Obot-owned revision from desired runtime configuration;
  • reports an instance ready only when the backend has applied that revision;
  • retains the first healthy runtime URL across later state changes;
  • polls transitional instances every ten seconds and ready instances every five minutes, so backend events are an optimization rather than a correctness requirement; and
  • removes its finalizer only after the backend confirms deletion is complete.

The default builder currently renders the versioned /etc/obot/agent.json, non-sensitive environment, harness image, and source repository. Sensitive values are deliberately excluded. Resolution of MCP gateway endpoints, model proxy endpoints, skill file trees, and backend secret references belongs in the builder and can be added without changing the backend interface or lifecycle controller.

Documentation

Overview

Package hostedagent reconciles hosted agent instances through the implementation-neutral agent backend contract.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildInput

type BuildInput struct {
	Client     kclient.Client
	Namespace  string
	Instance   *v1.HostedAgentInstance
	Agent      *v1.HostedAgent
	Harness    *v1.Harness
	Credential string
}

BuildInput is everything needed to render a sandbox's runtime contract.

Client is here because the sandbox config resolves models and skills into complete endpoints and files, which means reading them; Credential is here because those endpoints carry it.

type CredentialIssuer

type CredentialIssuer interface {
	// EnsureInstanceCredential returns the sandbox credential and an opaque
	// version that changes whenever the value does. It must be idempotent:
	// reconciles are frequent, and reissuing on every pass would restart the
	// sandbox on every pass.
	EnsureInstanceCredential(ctx context.Context, instanceID, ownerUserID string) (value string, version string, err error)
	// RevokeInstanceCredential is called during deletion and must tolerate a
	// credential that is already gone.
	RevokeInstanceCredential(ctx context.Context, instanceID string) error
}

CredentialIssuer mints and revokes the credential a sandbox authenticates with. It is an interface so the controller can be tested without a database, and so the credential store stays replaceable.

type DesiredBuilder

type DesiredBuilder interface {
	Build(context.Context, BuildInput) (agentbackend.DesiredInstance, error)
}

DesiredBuilder converts Obot resources into the runtime-ready backend contract. Keeping this boundary injectable lets resource and credential resolution evolve without coupling a backend adapter to Obot storage types.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func New

func New(backend agentbackend.InstanceBackend, credentials CredentialIssuer, serverURL, internalURL string, maxRepoSizeMB int) *Handler

func NewWithBuilder

func NewWithBuilder(backend agentbackend.InstanceBackend, credentials CredentialIssuer, builder DesiredBuilder) *Handler

func (*Handler) EnsurePool

func (h *Handler) EnsurePool(req router.Request, _ router.Response) error

EnsurePool resolves the instance's pool before backend reconciliation. The deterministic names make concurrent first-instance reconciles for one user converge on the same pool and assignment.

func (*Handler) OrchestrateInstance

func (h *Handler) OrchestrateInstance(req router.Request, resp router.Response) error

OrchestrateInstance converges one HostedAgentInstance and periodically observes it so out-of-band backend changes are reflected in Obot.

func (*Handler) RemoveInstance

func (h *Handler) RemoveInstance(req router.Request, resp router.Response) error

RemoveInstance asks the backend to remove an instance. The router retains the finalizer while this handler requests a retry.

Directories

Path Synopsis
Package credentials issues the credential a hosted agent sandbox uses to authenticate to Obot.
Package credentials issues the credential a hosted agent sandbox uses to authenticate to Obot.

Jump to

Keyboard shortcuts

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