Help us shape the future of Go! Take the 2026 Go Developer Survey

controller

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 66 Imported by: 0

Documentation

Overview

Package controller implements the Kubernetes controllers for agent-orca CRDs.

Index

Constants

View Source
const (
	// ConditionBudgetWarning is True from the warning until the cap is raised.
	ConditionBudgetWarning = "BudgetWarning"
	// ConditionBudgetExceeded is True while a run waits for a decision on a raise.
	ConditionBudgetExceeded = "BudgetExceeded"
)

Conditions for a run's budget.

View Source
const (
	// ConditionWorkflowValid reports whether a template (or a workflow's
	// structure) is usable; False carries every problem found.
	ConditionWorkflowValid = "Valid"
	// ConditionTemplateResolved reports whether a workflow created from a
	// template got its steps.
	ConditionTemplateResolved = "TemplateResolved"
)

Conditions on an AgentWorkflow that report on its definition.

View Source
const (
	// LabelManagedByMCPServer marks Tools generated by the MCPServer controller.
	LabelManagedByMCPServer = "mcpserver"
	// LabelManagedBy identifies who manages a resource.
	LabelManagedBy = "agentorca.io/managed-by"
	// LabelMCPServer identifies which MCPServer owns a Tool.
	LabelMCPServer = "agentorca.io/mcpserver"
)
View Source
const ConditionWaitingForApproval = "WaitingForApproval"

ConditionWaitingForApproval is True while a run has undecided approvals.

View Source
const (
	// ControllerPrincipal is the reserved name in MCPServer.allowedAgents that
	// grants the KnowledgeBase controller access to the MCP server.
	ControllerPrincipal = "_controller"
)
View Source
const RetrySandbox = "sandbox"

RetrySandbox is the name that asks for the workflow's shared sandbox to be provisioned again, for a workflow that failed before or without a failed step because its sandbox never came up or was lost.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentDeploymentReconciler

type AgentDeploymentReconciler struct {
	client.Client
	Scheme           *runtime.Scheme
	Recorder         record.EventRecorder
	K8s              kubernetes.Interface
	ModelRouterImage string
	// StateConfig is injected into router configs. The operator strips the Redis
	// password from it; RedisPassword carries it to a mounted Secret instead.
	StateConfig   state.Config
	RedisPassword string
	CloudProvider security.CloudProvider
	// TokenReviewerClusterRole is the ClusterRole that grants "create tokenreviews".
	TokenReviewerClusterRole string
	// OperatorAPIURL is the base URL of the operator's internal API server.
	// Injected into the router config so the model-router can call RAG, handoff, etc.
	OperatorAPIURL string
	// LLMRequestTimeout is the per-LLM-request timeout written into every router
	// config (default 1h). Injected from the LLM_REQUEST_TIMEOUT env var.
	LLMRequestTimeout time.Duration
	// ContextCompactionThreshold is the fraction of a provider's window at
	// which the router compacts the conversation (default 0.8, #47). Injected
	// from the CONTEXT_COMPACTION_THRESHOLD env var.
	ContextCompactionThreshold float64
	// ContextCompactionMode is "summary" (default) or "truncate", the rollback
	// switch (#47). Injected from the CONTEXT_COMPACTION_MODE env var.
	ContextCompactionMode string
	// ContextCompactionRatio is the fraction of the window drop-oldest
	// truncation cuts down to ("truncate" mode and the summary fallback).
	// Injected from the deprecated CONTEXT_COMPACTION_RATIO env var.
	ContextCompactionRatio float64

	// HindsightURL is the configured hindsight API endpoint (e.g. http://hindsight.local).
	// Injected from the HINDSIGHT_URL env var. Used to generate ipBlock egress rules
	// in the per-run NetworkPolicies when the cluster has a default-deny egress policy.
	HindsightURL string
	// HindsightAPIKey authenticates the model-router to a hindsight API that
	// requires a tenant API key. Injected from the HINDSIGHT_API_KEY env var; the
	// operator mirrors it into each run namespace (see ensureHindsightKeySecret).
	HindsightAPIKey string
}

AgentDeploymentReconciler reconciles an AgentDeployment object.

func (*AgentDeploymentReconciler) Reconcile

Reconcile implements the reconciliation loop for AgentDeployment.

func (*AgentDeploymentReconciler) SetupWithManager

func (r *AgentDeploymentReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type AgentReconciler

type AgentReconciler struct {
	client.Client
	Scheme        *runtime.Scheme
	CloudProvider security.CloudProvider
}

AgentReconciler reconciles a Agent object.

func (*AgentReconciler) Reconcile

func (r *AgentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*AgentReconciler) SetupWithManager

func (r *AgentReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type AgentRunReconciler

type AgentRunReconciler struct {
	client.Client
	Scheme           *runtime.Scheme
	Recorder         record.EventRecorder
	K8s              kubernetes.Interface
	Dynamic          dynamic.Interface
	ModelRouterImage string
	// StateConfig is injected into router configs. The operator strips the Redis
	// password from it; RedisPassword carries it to a mounted Secret instead.
	StateConfig   state.Config
	RedisPassword string
	StateStore    state.Store
	CloudProvider security.CloudProvider
	// PostgresStore is the optional PostgreSQL archival store. When non-nil,
	// terminal-phase AgentRuns are snapshotted here for long-term retention
	// and historical querying by the UI.
	PostgresStore *postgresql.Store
	// TokenReviewerClusterRole is the name of the ClusterRole that grants
	// "create tokenreviews" — injected at startup from the Helm release name.
	// The agentrun controller binds each agent SA to this role so the
	// model-router sidecar can call the TokenReview API.
	TokenReviewerClusterRole string
	// OperatorAPIURL is the base URL of the operator's internal API server,
	// injected from the OPERATOR_API_URL env var. Written into every router
	// ConfigMap so sidecars can call /agentrun endpoints for handoff and child runs.
	// Example: "http://agent-orca-internal-api.agent-orca-system.svc.cluster.local:8082"
	OperatorAPIURL string
	// LLMRequestTimeout is the per-LLM-request timeout written into every router
	// config (default 1h). Injected from the LLM_REQUEST_TIMEOUT env var.
	LLMRequestTimeout time.Duration
	// ContextCompactionThreshold is the fraction of a provider's window at
	// which the router compacts the conversation (default 0.8, #47). Injected
	// from the CONTEXT_COMPACTION_THRESHOLD env var.
	ContextCompactionThreshold float64
	// ContextCompactionMode is "summary" (default) or "truncate", the rollback
	// switch (#47). Injected from the CONTEXT_COMPACTION_MODE env var.
	ContextCompactionMode string
	// ContextCompactionRatio is the fraction of the window drop-oldest
	// truncation cuts down to ("truncate" mode and the summary fallback).
	// Injected from the deprecated CONTEXT_COMPACTION_RATIO env var.
	ContextCompactionRatio float64

	// HindsightURL is the configured hindsight API endpoint (e.g. http://hindsight.local).
	// Injected from the HINDSIGHT_URL env var. Used to generate ipBlock egress rules
	// in the per-run NetworkPolicies when the cluster has a default-deny egress policy.
	HindsightURL string
	// HindsightAPIKey authenticates the model-router to a hindsight API that
	// requires a tenant API key. Injected from the HINDSIGHT_API_KEY env var; the
	// operator mirrors it into each run namespace (see ensureHindsightKeySecret).
	HindsightAPIKey string
	// OperatorNamespace is the namespace the operator runs in (POD_NAMESPACE). Per-run
	// NetworkPolicies allow its pods to scrape the model-router's :9091 metrics.
	OperatorNamespace string
	// Sandboxes is the OpenShell gateway that runs agents with
	// spec.runtime.sandbox set. Nil when the operator has no gateway configured;
	// such runs then fail with a clear reason.
	Sandboxes openshell.Gateway
	// SandboxPlacement chooses the nodes sandbox pods run on.
	SandboxPlacement openshell.Placement
	// Approvals stores egress approvals (PostgreSQL). Nil disables them: the
	// sandbox's denied requests stay denied.
	Approvals ApprovalStore
	// ApprovalNotifier tells approvers about new pending approvals. Optional.
	ApprovalNotifier ApprovalNotifier
	// GitHubApp mints the installation tokens of sandboxes with
	// spec.runtime.sandbox.github. Nil when no GitHub App is configured.
	GitHubApp GitHubTokenMinter
	// ClusterDomain is the cluster DNS domain (default "cluster.local"), used to
	// address the router Service from the sandbox namespace.
	ClusterDomain string
}

AgentRunReconciler reconciles a AgentRun object.

func (*AgentRunReconciler) Reconcile

func (r *AgentRunReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*AgentRunReconciler) SetupWithManager

func (r *AgentRunReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type AgentWorkflowReconciler

type AgentWorkflowReconciler struct {
	client.Client
	Scheme *runtime.Scheme

	// K8s reads the logs of container steps' pods. nil leaves their output empty.
	K8s kubernetes.Interface
	// Approvals stores the decisions of approval steps (the PostgreSQL store);
	// nil makes approval steps fail with a clear reason.
	Approvals ApprovalStore
	// ApprovalNotifier tells approvers about a new approval step. Optional.
	ApprovalNotifier ApprovalNotifier
	// CompletionNotifier announces workflows that opted in with the
	// notify-on-completion annotation when they finish. Optional.
	CompletionNotifier TextNotifier
	// AllowedRegistries restricts container steps' images, like the webhook does
	// for agents and tools. Empty allows any.
	AllowedRegistries []string
	// Sandboxes runs workflow-owned OpenShell sandboxes. Nil makes spec.sandbox
	// fail with a clear reason; workflows without one keep their existing behavior.
	Sandboxes openshell.Gateway
	// SandboxPlacement chooses the nodes workflow sandbox pods run on.
	SandboxPlacement openshell.Placement
	// GitHubApp mints optional credential-bound tokens for repository checkouts.
	GitHubApp GitHubTokenMinter
	// ClusterDomain is the cluster DNS domain used by sandboxed agent routers.
	ClusterDomain string
}

AgentWorkflowReconciler reconciles AgentWorkflow objects.

func (*AgentWorkflowReconciler) Reconcile

func (r *AgentWorkflowReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*AgentWorkflowReconciler) SetupWithManager

func (r *AgentWorkflowReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager registers the controller with the Manager.

type ApprovalNotifier added in v0.9.0

type ApprovalNotifier interface {
	NotifyApproval(ctx context.Context, a postgresql.Approval) error
}

ApprovalNotifier tells approvers about a request waiting for them.

type ApprovalStore added in v0.9.0

type ApprovalStore interface {
	RequestApproval(ctx context.Context, a postgresql.Approval) (postgresql.Approval, error)
	ListApprovals(ctx context.Context, q postgresql.ApprovalQuery) ([]postgresql.Approval, error)
	DecideApproval(ctx context.Context, id, status, by, reason string) (postgresql.Approval, error)
	MarkApprovalApplied(ctx context.Context, id string) error
	WithdrawRunApprovals(ctx context.Context, namespace, runName string) error
	WithdrawBySourcePrefix(ctx context.Context, kind, prefix, reason string) error
}

ApprovalStore persists approvals (postgresql.Store).

type GitHubTokenMinter added in v0.9.0

type GitHubTokenMinter interface {
	InstallationToken(ctx context.Context, req githubapp.TokenRequest) (*githubapp.Token, error)
}

GitHubTokenMinter mints GitHub App installation tokens (githubapp.Client).

type KnowledgeBaseReconciler

type KnowledgeBaseReconciler struct {
	client.Client
	Scheme           *runtime.Scheme
	MCPIngesterImage string
	QdrantImage      string
}

KnowledgeBaseReconciler reconciles KnowledgeBase objects.

func (*KnowledgeBaseReconciler) Reconcile

func (r *KnowledgeBaseReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*KnowledgeBaseReconciler) SetupWithManager

func (r *KnowledgeBaseReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager registers the controller with the Manager.

type MCPServerReconciler

type MCPServerReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

MCPServerReconciler reconciles an MCPServer object. It generates one child Tool CR per declared tool in the MCPServer spec, and — for OAuth-only remote MCP servers — performs the OAuth token exchange itself (no sidecar) so the flow lives entirely in the MCPServer CR.

func (*MCPServerReconciler) Reconcile

func (r *MCPServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*MCPServerReconciler) SetupWithManager

func (r *MCPServerReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type ModelProviderReconciler

type ModelProviderReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

ModelProviderReconciler reconciles a ModelProvider object.

func (*ModelProviderReconciler) Reconcile

func (r *ModelProviderReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*ModelProviderReconciler) SetupWithManager

func (r *ModelProviderReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type ModelSelectorReconciler

type ModelSelectorReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

ModelSelectorReconciler reconciles a ModelSelector object

func (*ModelSelectorReconciler) Reconcile

func (r *ModelSelectorReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the ModelSelector object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.23.1/pkg/reconcile

func (*ModelSelectorReconciler) SetupWithManager

func (r *ModelSelectorReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type TenantConfigReconciler

type TenantConfigReconciler struct {
	client.Client
	Scheme    *runtime.Scheme
	Refresher TenantRefresher
}

TenantConfigReconciler reconciles TenantConfig objects and keeps the external auth middleware's tenant cache up to date.

func (*TenantConfigReconciler) Reconcile

func (r *TenantConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*TenantConfigReconciler) SetupWithManager

func (r *TenantConfigReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type TenantRefresher

type TenantRefresher interface {
	RefreshTenants(ctx context.Context) error
}

TenantRefresher is implemented by ExternalAuth to refresh the tenant cache.

type TextNotifier added in v0.9.0

type TextNotifier interface {
	NotifyText(ctx context.Context, text string) error
}

TextNotifier posts a plain message to the same channel as approvals.

type ToolReconciler

type ToolReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

ToolReconciler reconciles a Tool object.

func (*ToolReconciler) Reconcile

func (r *ToolReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*ToolReconciler) SetupWithManager

func (r *ToolReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type WebhookApprovalNotifier added in v0.9.0

type WebhookApprovalNotifier struct {
	URL string
	// UIURL is the UI's public base URL; messages link to its approvals inbox.
	UIURL string
	HTTP  *http.Client
}

WebhookApprovalNotifier posts each new pending approval to an incoming webhook. The body is Slack's incoming-webhook format ({"text": ...}) plus the approval itself under "approval", so other receivers can use the fields.

func (*WebhookApprovalNotifier) NotifyApproval added in v0.9.0

func (n *WebhookApprovalNotifier) NotifyApproval(ctx context.Context, a postgresql.Approval) error

NotifyApproval implements ApprovalNotifier.

func (*WebhookApprovalNotifier) NotifyText added in v0.9.0

func (n *WebhookApprovalNotifier) NotifyText(ctx context.Context, text string) error

NotifyText implements TextNotifier.

Jump to

Keyboard shortcuts

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