environment

package
v0.13.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiscoverySource

type DiscoverySource interface {
	Name() string
	Discover() ([]agent.Agent, error)
}

DiscoverySource abstracts a single source of agent discovery. Existing providers (Claude, Codex, Gemini) already satisfy this via their Name() and Discover() methods.

type Environment

type Environment interface {
	// Name returns the friendly name of this environment.
	Name() string

	// Type returns the type of environment ("local", "openshell", "k8s", etc).
	Type() string

	// Discover discovers running agents in this environment.
	Discover() ([]agent.Agent, error)

	// CreateSandbox creates a new sandbox for agent execution with the given options.
	// Returns the sandbox name or an error.
	CreateSandbox(ctx context.Context, opts SandboxOpts) (string, error)

	// DeleteSandbox deletes a sandbox by name.
	DeleteSandbox(ctx context.Context, name string) error

	// ListSandboxes lists all sandboxes in this environment.
	ListSandboxes(ctx context.Context) ([]SandboxStatus, error)

	// Kill terminates an agent process.
	Kill(a agent.Agent) error
}

Environment represents an execution environment where agents can run. This can be a local machine, an OpenShell sandbox, a Kubernetes cluster, or another backend.

type K8sEnvironment

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

K8sEnvironment discovers and manages agents running on a Kubernetes cluster. Discovery uses Redis heartbeats and the K8s API. The circuit breaker prevents the TUI from freezing when Redis is unreachable.

func NewK8sEnvironment

func NewK8sEnvironment(name string, cfg K8sEnvironmentConfig) *K8sEnvironment

NewK8sEnvironment creates a K8sEnvironment with the given configuration.

func (*K8sEnvironment) Backend

func (e *K8sEnvironment) Backend() *aimuxrt.K8sBackend

Backend returns the underlying K8sBackend for callers that need direct access (e.g., SetClientset in tests).

func (*K8sEnvironment) Close

func (e *K8sEnvironment) Close()

Close shuts down the shared Redis client.

func (*K8sEnvironment) CreateSandbox

func (e *K8sEnvironment) CreateSandbox(ctx context.Context, opts SandboxOpts) (string, error)

CreateSandbox creates a new K8s agent deployment.

func (*K8sEnvironment) DeleteSandbox

func (e *K8sEnvironment) DeleteSandbox(ctx context.Context, name string) error

DeleteSandbox scales down the named deployment.

func (*K8sEnvironment) Discover

func (e *K8sEnvironment) Discover() ([]agent.Agent, error)

Discover reads Redis heartbeats and K8s API to enumerate live agents.

func (*K8sEnvironment) GetTaskResult

func (e *K8sEnvironment) GetTaskResult(taskID string) (string, error)

GetTaskResult returns the full result reference for a task.

func (*K8sEnvironment) Kill

func (e *K8sEnvironment) Kill(a agent.Agent) error

Kill deletes the agent's K8s deployment.

func (*K8sEnvironment) ListSandboxes

func (e *K8sEnvironment) ListSandboxes(ctx context.Context) ([]SandboxStatus, error)

ListSandboxes lists K8s agent deployments.

func (*K8sEnvironment) ListTasks

func (e *K8sEnvironment) ListTasks() ([]task.Task, error)

ListTasks returns all tasks for the configured team.

func (*K8sEnvironment) Name

func (e *K8sEnvironment) Name() string

func (*K8sEnvironment) ScaleDown

func (e *K8sEnvironment) ScaleDown(provider, role string) error

ScaleDown scales the deployment to 0.

func (*K8sEnvironment) ScaleDownOne

func (e *K8sEnvironment) ScaleDownOne(providerName, role string) error

ScaleDownOne decrements the deployment by 1.

func (*K8sEnvironment) SendMessage

func (e *K8sEnvironment) SendMessage(agentID, text string) error

SendMessage writes a message to the agent's Redis inbox stream.

func (*K8sEnvironment) SpawnRemote

func (e *K8sEnvironment) SpawnRemote(provider, role string, count int) error

SpawnRemote scales up a K8s Deployment for the given provider and role.

func (*K8sEnvironment) SpawnSession

func (e *K8sEnvironment) SpawnSession(providerName string) (podName, namespace string, err error)

SpawnSession creates a session pod and waits for it to become ready.

func (*K8sEnvironment) Status

func (e *K8sEnvironment) Status() string

Status returns a human-readable connection status.

func (*K8sEnvironment) Type

func (e *K8sEnvironment) Type() string

type K8sEnvironmentConfig

type K8sEnvironmentConfig struct {
	RedisURL   string
	TeamID     string
	Namespace  string
	Kubeconfig string
}

K8sEnvironmentConfig holds connection settings for a Kubernetes environment.

type LocalEnvironment

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

LocalEnvironment discovers and manages agents running on the local machine. It delegates discovery to one or more DiscoverySource implementations.

func NewLocalEnvironment

func NewLocalEnvironment(sources ...DiscoverySource) *LocalEnvironment

NewLocalEnvironment creates a LocalEnvironment that queries the given discovery sources during Discover().

func (*LocalEnvironment) CreateSandbox

func (e *LocalEnvironment) CreateSandbox(ctx context.Context, opts SandboxOpts) (string, error)

func (*LocalEnvironment) DeleteSandbox

func (e *LocalEnvironment) DeleteSandbox(ctx context.Context, name string) error

func (*LocalEnvironment) Discover

func (e *LocalEnvironment) Discover() ([]agent.Agent, error)

func (*LocalEnvironment) Kill

func (e *LocalEnvironment) Kill(a agent.Agent) error

func (*LocalEnvironment) ListSandboxes

func (e *LocalEnvironment) ListSandboxes(ctx context.Context) ([]SandboxStatus, error)

func (*LocalEnvironment) Name

func (e *LocalEnvironment) Name() string

func (*LocalEnvironment) Type

func (e *LocalEnvironment) Type() string

type LocalExecutor

type LocalExecutor struct{}

LocalExecutor wraps exec.Command for launching local processes. It implements the executor pattern used by agent-compose but as a standalone aimux type.

func NewLocalExecutor

func NewLocalExecutor() *LocalExecutor

NewLocalExecutor creates a new LocalExecutor.

func (*LocalExecutor) Launch

func (e *LocalExecutor) Launch(ctx context.Context, binary string, args []string, dir string, env map[string]string) (*os.Process, error)

Launch starts a new process with the given binary, arguments, working directory, and environment. It returns the started process or an error if the process could not be started.

type OpenShellConfig

type OpenShellConfig struct {
	Gateway  string
	Insecure bool
	Image    string
}

OpenShellConfig holds configuration for an OpenShell environment.

type OpenShellEnvironment

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

OpenShellEnvironment discovers and manages agents running in OpenShell sandboxes.

func NewOpenShellEnvironment

func NewOpenShellEnvironment(name string, cfg OpenShellConfig) *OpenShellEnvironment

NewOpenShellEnvironment creates an OpenShellEnvironment with the given config.

func (*OpenShellEnvironment) CreateSandbox

func (e *OpenShellEnvironment) CreateSandbox(ctx context.Context, opts SandboxOpts) (string, error)

CreateSandbox creates a new OpenShell sandbox.

func (*OpenShellEnvironment) DeleteSandbox

func (e *OpenShellEnvironment) DeleteSandbox(ctx context.Context, name string) error

DeleteSandbox deletes an OpenShell sandbox by name.

func (*OpenShellEnvironment) Discover

func (e *OpenShellEnvironment) Discover() ([]agent.Agent, error)

Discover returns agents for running OpenShell sandboxes. Uses a 3-second timeout so a stuck gateway never blocks the discovery tick.

func (*OpenShellEnvironment) FetchSessionReplies

func (e *OpenShellEnvironment) FetchSessionReplies(sandboxName, sessionID string) map[string]string

FetchSessionReplies reads the Claude Code session JSONL from inside a remote sandbox and returns assistant reply text keyed by promptId.

func (*OpenShellEnvironment) FetchSessionTurns

func (e *OpenShellEnvironment) FetchSessionTurns(sandboxName, sessionID string) []trace.Turn

FetchSessionTurns reads the session JSONL from inside a sandbox and builds trace.Turn entries directly from it, without needing OTEL data.

func (*OpenShellEnvironment) Kill

Kill terminates an agent by deleting its sandbox.

func (*OpenShellEnvironment) ListSandboxes

func (e *OpenShellEnvironment) ListSandboxes(ctx context.Context) ([]SandboxStatus, error)

ListSandboxes lists all OpenShell sandboxes and returns their status.

func (*OpenShellEnvironment) Name

func (e *OpenShellEnvironment) Name() string

func (*OpenShellEnvironment) Type

func (e *OpenShellEnvironment) Type() string

type SandboxOpts

type SandboxOpts struct {
	// Image is the container image or environment template to use.
	Image string

	// Provider is the AI provider for the sandbox ("claude", "codex", "gemini", etc).
	Provider string

	// Mode is the sandbox execution mode ("worker" for background jobs, "session" for interactive).
	Mode string

	// Env is a map of environment variables to set in the sandbox.
	Env map[string]string

	// Labels are key-value pairs for sandbox metadata and management.
	Labels map[string]string
}

SandboxOpts contains options for creating a sandbox.

type SandboxStatus

type SandboxStatus struct {
	// Name is the unique identifier of the sandbox.
	Name string

	// Status is the current state of the sandbox ("running", "ready", "stopped", "dead", etc).
	Status string

	// Idle indicates whether the sandbox is currently idle (not running workloads).
	Idle bool
}

SandboxStatus represents the status of a sandbox.

Jump to

Keyboard shortcuts

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