sandbox

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildNanoclawConfig added in v0.26.0

func BuildNanoclawConfig(proxyBaseURL, proxyToken, assistantName string, imBridgeURL, bridgeSecret string, byokBaseURL, byokAPIKey string) string

BuildNanoclawConfig returns the environment variable content for a nanoclaw container. When byokBaseURL and byokAPIKey are non-empty (BYOK mode), they override the default proxy credentials.

func BuildOpenclawConfig

func BuildOpenclawConfig(proxyBaseURL, proxyToken, gatewayToken string, customModels []process.LLMModel) string

BuildOpenclawConfig returns the openclaw.json content with gateway settings and optional Anthropic proxy credentials. The gatewayToken is written into gateway.auth.token so that the gateway and Control UI share the same secret; without this, OpenClaw v2026.3.12+ auto-generates a random token on startup that won't match the token our proxy injects.

func BuildOpencodeConfig added in v0.13.0

func BuildOpencodeConfig(baseConfig, apiKey, overrideBaseURL string) string

BuildOpencodeConfig merges the per-sandbox proxy token into the base opencode config JSON. When overrideBaseURL is non-empty (BYOK mode), it also replaces provider.anthropic.options.baseURL.

func ExtractProxyBaseURL added in v0.13.0

func ExtractProxyBaseURL(configJSON string) string

ExtractProxyBaseURL extracts provider.anthropic.options.baseURL from the opencode config JSON. Used by sandbox managers that need the proxy URL (e.g. for openclaw config).

Types

type Config

type Config struct {
	AgentserverNamespace     string
	Image                    string
	SessionStorageSize       string
	StorageClassName         string
	RuntimeClassName         string
	OpencodePort             int
	OpencodeConfigContent    string // JSON config injected via OPENCODE_CONFIG_CONTENT
	OpenclawImage            string
	OpenclawPort             int
	OpenclawRuntimeClassName string
	OpenclawWeixinEnabled    bool
	NanoclawImage            string
	NanoclawRuntimeClassName string
	NanoclawIMBridgeEnabled  bool
	NanoclawBridgeBaseURL    string // agentserver internal URL for NanoClaw pods to call back (e.g. "http://agentserver:8080")
	NanoclawModel            string // Claude Code model override (e.g. "claude-opus-4-6")
}

Config holds configuration for the K8s sandbox backend.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config populated from environment variables with sensible defaults.

type Manager

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

Manager manages Sandbox CRs and remotecommand exec sessions.

func NewManager

func NewManager(cfg Config, database *db.DB) (*Manager, error)

NewManager creates a sandbox Manager using in-cluster or KUBECONFIG config.

func (*Manager) CleanOrphans

func (m *Manager) CleanOrphans(knownSandboxNames []string, namespaces []string)

CleanOrphans deletes Sandbox CRs labelled managed-by=agentserver that are NOT in the known set. It iterates all provided workspace namespaces.

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) ExecSimple added in v0.22.0

func (m *Manager) ExecSimple(ctx context.Context, sandboxID string, command []string) (string, error)

ExecSimple runs a command in a sandbox pod and returns its stdout. It is a one-shot exec (no stdin/TTY) intended for short-lived commands like writing config files or restarting a gateway.

func (*Manager) Get

func (m *Manager) Get(id string) (process.Process, bool)

func (*Manager) Pause

func (m *Manager) Pause(id string) error

Pause scales the sandbox to 0 replicas. Pod goes away, PVC stays.

func (*Manager) Resume

func (m *Manager) Resume(id, sandboxName, command string, args []string) (process.Process, error)

Resume scales the sandbox back to 1, waits for ready, and starts a new exec.

func (*Manager) ResumeContainer

func (m *Manager) ResumeContainer(id string) error

ResumeContainer scales a paused sandbox back to 1 replica and waits for it to be ready, without starting an exec session (the sidecar handles exec). Returns the pod IP.

func (*Manager) ResumeContainerWithIP

func (m *Manager) ResumeContainerWithIP(id string) (string, error)

ResumeContainerWithIP scales a paused sandbox back to 1 replica and returns the pod IP.

func (*Manager) Start

func (m *Manager) Start(id, command string, args, env []string, opts process.StartOptions) (process.Process, error)

func (*Manager) StartContainer

func (m *Manager) StartContainer(id string, opts process.StartOptions) error

StartContainer for K8s sandbox creates the Sandbox CR and waits for it to be ready. Returns the pod IP for agent server communication.

func (*Manager) StartContainerWithIP

func (m *Manager) StartContainerWithIP(id string, opts process.StartOptions) (string, error)

StartContainerWithIP creates/starts the sandbox and returns the pod IP.

func (*Manager) Stop

func (m *Manager) Stop(id string) error

func (*Manager) StopBySandboxName

func (m *Manager) StopBySandboxName(namespace, sandboxName string) error

StopBySandboxName deletes a Sandbox CR by its name in the given namespace.

Jump to

Keyboard shortcuts

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