agents

package
v1.9.2 Latest Latest
Warning

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

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

Documentation

Overview

Package agents is the domain of agent-manager: an agent on the platform is a Flux HelmRelease of the Generic agent chart (1.x) — one release renders one kagent.dev/v1alpha3 AgentTemplate plus the agent's own muster RemoteMCPServer, the toolset carrier — sharing a per-namespace OCIRepository that tracks the chart. The package composes those two Flux objects exactly like the portal's create flow, pins every skill to an immutable source, validates the values against the chart's schema before anything is applied, and reads the agent back from the AgentTemplate, its RemoteMCPServer and its owning HelmRelease. Readiness is what the platform Harness reports on the template (status.harnesses[]); there is no per-agent Deployment or pod.

Index

Constants

View Source
const (
	DefaultChartOCIURL = "oci://gsoci.azurecr.io/charts/giantswarm/agent"
	// DefaultChartSemver is the range the per-namespace OCIRepository tracks:
	// every 1.x release of the Generic chart, never a pre-release build and
	// never a next major.
	DefaultChartSemver             = "1.x"
	DefaultHelmReleaseInterval     = "10m"
	DefaultOCIRepositoryInterval   = "30m"
	DefaultHelmReleaseAPIVersion   = "helm.toolkit.fluxcd.io/v2"
	DefaultOCIRepositoryAPIVersion = "source.toolkit.fluxcd.io/v1"
	// DefaultHarnessName is the platform Harness every agent runs on.
	DefaultHarnessName = "kagent"
)
View Source
const (
	// KubeconfigSecretSuffix: the Secret <cluster>-kubeconfig in the
	// organization namespace.
	KubeconfigSecretSuffix = "-kubeconfig" // #nosec G101 -- a Secret name suffix, not a credential
	// KubeconfigSecretKey is the key holding the kubeconfig.
	KubeconfigSecretKey = "value"
	// OrganizationNamespacePrefix: an organization's namespace on the
	// installation is org-<organization>.
	OrganizationNamespacePrefix = "org-"
	// ClusterLabel marks the HelmRelease of an agent placed on a workload
	// cluster with the cluster's name.
	ClusterLabel = "agent-platform.giantswarm.io/cluster"
)

The Cluster API contract of a workload cluster's kubeconfig.

View Source
const (
	// ToolsetValuesKey is the agent chart's top-level value carrying the
	// toolset (never `muster.tools`, which narrows the MCP binding).
	ToolsetValuesKey = "toolset"
	// ToolsetHeader is the header the chart renders on the agent's
	// RemoteMCPServer (spec.headersFrom[]).
	ToolsetHeader = "X-Muster-Toolset"
	// MaxToolsetSelectors is the inline cap; a longer list belongs in a preset.
	MaxToolsetSelectors = 32
)
View Source
const (
	// ModeApply writes the objects live, as the caller.
	ModeApply = "apply"
	// ModeCommit writes them as files into the git repository that owns the
	// target and opens a pull request as the caller.
	ModeCommit = "commit"
)

Write modes.

View Source
const (
	// DisplayNameAnnotation is the agent chart's contract for the friendly
	// name; IconURLAnnotation for the avatar (the AgentTemplate has no icon
	// field). Both are rendered by Generic chart 1.x and read by the Dev
	// Portal, Swarmgeist and agent-manager.
	DisplayNameAnnotation = "ui.giantswarm.io/display-name"
	IconURLAnnotation     = "ui.giantswarm.io/icon-url"
	// HarnessLabel names the Harness that runs an agent: the Generic chart
	// renders agent.harness into it and a Harness's allowedAgentTemplates
	// selector matches it.
	HarnessLabel = "agent-platform.giantswarm.io/harness"
	// HelmReleaseNameLabel / HelmReleaseNamespaceLabel are the Flux provenance
	// labels helm-controller stamps on every object a release renders.
	HelmReleaseNameLabel      = "helm.toolkit.fluxcd.io/name"
	HelmReleaseNamespaceLabel = "helm.toolkit.fluxcd.io/namespace"
	// KustomizationNameLabel marks a HelmRelease whose desired state lives in
	// git (applied by a Flux Kustomization): a live write would be undone on
	// the next reconciliation.
	KustomizationNameLabel = "kustomize.toolkit.fluxcd.io/name"
	// ManagedByLabel / ManagedByValue mark the HelmReleases and
	// OCIRepositories agent-manager created.
	ManagedByLabel = "app.kubernetes.io/managed-by"
	ManagedByValue = "agent-manager"
)

Labels and annotations the platform agrees on.

View Source
const (
	// ManagedHelmRelease: a HelmRelease owns the agent and can be written live.
	ManagedHelmRelease = "helmrelease"
	// ManagedGitOps: the owning HelmRelease is applied by a Flux Kustomization;
	// changes belong in git (the meta agent opens a PR instead).
	ManagedGitOps = "gitops"
	// ManagedNone: a bare AgentTemplate with no HelmRelease behind it.
	ManagedNone = "none"
)

How an agent is managed.

View Source
const (
	VerdictReady       = "ready"
	VerdictProgressing = "progressing"
	VerdictFailed      = "failed"
	VerdictUnknown     = "unknown"
)

Verdicts of a status check.

View Source
const CommitDirectory = "agent-manager"

CommitDirectory is the directory agent-manager writes an agent's files to, under the directory the owning Kustomization builds from (gitops-commit's layout, the one cluster-manager and model-manager write theirs to).

View Source
const DefaultKagentAPIVersion = "v1alpha3"

DefaultKagentAPIVersion is composed when discovery cannot answer.

View Source
const FieldManager = "agent-manager"

Defaults of the composition, the values composeManifests.ts uses. FieldManager names this service as the manager of the fields it writes on HelmRelease and OCIRepository objects (metadata.managedFields[].manager): a field manager names the tool that applied a field, never the person — the caller is recorded in the requestedBy annotation and in the apiserver audit log (every write runs with the caller's token).

View Source
const KustomizationNamespaceLabel = "kustomize.toolkit.fluxcd.io/namespace"

KustomizationNamespaceLabel is the namespace of the Kustomization named by KustomizationNameLabel.

View Source
const MaxSystemMessageLength = 20000

MaxSystemMessageLength is the agent chart's cap on agent.systemMessage: the compiled agent config must fit Substrate's 32768-character env value limit.

View Source
const SkillsGitAuthValuesKey = "skillsGitAuthSecretRef"

SkillsGitAuthValuesKey is the chart 1.x value that fans one read credential out to every git skill: {name: <Secret>}.

Variables

View Source
var (
	RemovedValuePaths = []string{
		"agent.runtime", "replicas", "resources", "nodeSelector", "tolerations",
		"muster.serverRef", "muster.allowedHeaders", "muster.stsWellKnownUri", "skills.gitAuthSecretRef",
	}
	RenamedValuePaths = map[string]string{"muster.toolNames": "muster.tools"}
)

The Generic chart 1.x values contract, for anyone rewriting 0.x values: RemovedValuePaths are the 0.x keys 1.x refuses (additionalProperties: false), RenamedValuePaths the ones that moved.

View Source
var (
	// ErrNotFound: the agent, HelmRelease or ModelConfig does not exist.
	ErrNotFound = errors.New("not found")
	// ErrInvalid: the request is malformed, fails the chart's values schema,
	// or names a skill reference that cannot be pinned.
	ErrInvalid = errors.New("invalid request")
	// ErrConflict: the object exists, is owned by GitOps, is suspended, or is
	// a bare AgentTemplate — a write would be refused or undone; force
	// overrides where documented.
	ErrConflict = errors.New("conflict")
	// ErrForbidden: the Kubernetes API refused the write for the identity
	// agent-manager runs with.
	ErrForbidden = errors.New("forbidden")
	// ErrUnsupported: the operation is not available on this installation.
	ErrUnsupported = errors.New("unsupported")
	// ErrUnauthenticated: the request reached the service without the caller
	// token it needs to act (the server runs as the caller only). 401.
	ErrUnauthenticated = errors.New("unauthenticated")
	// ErrGitOpsOwned: an apply-mode write targets a HelmRelease a Flux
	// Kustomization applies from git; the refusal names mode commit and the
	// repository and directory it would write. 409.
	ErrGitOpsOwned = errors.New("gitops_owned")
	// ErrAuthRequired: commit mode needs the person's GitHub authorization
	// and the call carries none (or GitHub refused it); the refusal names the
	// consent. 401.
	ErrAuthRequired = errors.New("auth_required")
)

Sentinel errors the API layers map to HTTP statuses and MCP error codes.

View Source
var ShippedPresets = []string{"read-only", "none", "infrastructure", "agent-platform", "full"}

ShippedPresets are the presets every installation has: muster's built-ins (read-only, none, full) and the two the platform charts ship (infrastructure, agent-platform).

Functions

func BuildHelmRelease

func BuildHelmRelease(name, namespace string, values map[string]any, cfg ComposeConfig) *unstructured.Unstructured

BuildHelmRelease composes the HelmRelease of an agent.

func BuildOCIRepository

func BuildOCIRepository(namespace string, cfg ComposeConfig) *unstructured.Unstructured

BuildOCIRepository composes the shared chart source of a namespace.

func BuildValues

func BuildValues(spec Spec, cfg ComposeConfig) map[string]any

BuildValues composes the chart values from a spec whose skills are pinned (see pinSkills). Only what the caller set is emitted so the chart's defaults apply to everything else — the same rule as the portal (an empty prompt means "the chart's default prompt").

func ManagedNamespaces added in v1.8.0

func ManagedNamespaces(def string, additional []string) []string

ManagedNamespaces are the default namespace followed by the additional ones, without empty entries or the default repeated.

func ParseToolsetHeader added in v0.4.0

func ParseToolsetHeader(value string) []string

ParseToolsetHeader splits a rendered X-Muster-Toolset header value back into selectors (comma-separated, whitespace around selectors trimmed).

func PlaceOnCluster added in v1.9.0

func PlaceOnCluster(hr *unstructured.Unstructured, t Target, agent, ns string)

PlaceOnCluster turns an agent's HelmRelease into one that installs on the target cluster: named after cluster and agent in the organization namespace, installing the release named after the agent into ns there through the kubeconfig Secret. The chart source stays beside it. Flux impersonates spec.serviceAccountName on the remote cluster, where no such account exists, so it is dropped: the kubeconfig is the identity.

func SkillsValues added in v1.1.0

func SkillsValues(list Skills) []any

SkillsValues renders a pinned skills list as the chart 1.x `skills` value; nil when the list is empty.

func ToYAML

func ToYAML(obj *unstructured.Unstructured) string

ToYAML renders an object as YAML (what the applied manifest looks like).

func ValidateName

func ValidateName(name string) error

ValidateName checks the technical name: a DNS-1123 label of at most 63 characters, as the AgentTemplate, Helm and the chart's schema require.

func ValidateSkills added in v1.0.0

func ValidateSkills(list Skills) error

ValidateSkills checks what can be checked before any lookup: exactly one source per entry, an http(s) repository URL, ref or commit but not both, a well-formed commit, a parseable OCI reference, a relative path without "..", unique names.

func ValidateSystemMessage added in v1.1.21

func ValidateSystemMessage(message string) error

ValidateSystemMessage checks the system prompt against the chart's cap, counted in characters (code points), as the chart schema counts it.

func ValidateToolset added in v0.4.0

func ValidateToolset(selectors []string, required bool) error

ValidateToolset checks a declared toolset against the inline grammar: non-empty, at most MaxToolsetSelectors selectors, each preset:<name> | server:<name> | workflow:<name> | tool:<name>; `toolset:` is reserved and `label:` exists inside presets only. A nil list is "absent": refused when required (create), fine otherwise (update: unchanged).

func ValidateValues

func ValidateValues(ctx context.Context, src SchemaSource, values map[string]any) (chart.Schema, []string)

ValidateValues checks values against the chart's schema and returns every violation as a readable line (path: message). A schema that does not compile is reported as one error rather than letting invalid values through.

Types

type Agent

type Agent struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	// Target is the workload cluster the agent runs on; absent on the
	// installation's own cluster.
	Target
	// Exists is false while the HelmRelease has not rendered the
	// AgentTemplate yet (or failed to).
	Exists        bool   `json:"exists"`
	DisplayName   string `json:"displayName,omitempty"`
	Description   string `json:"description,omitempty"`
	ModelConfig   string `json:"modelConfig,omitempty"`
	IconURL       string `json:"iconUrl,omitempty"`
	SystemMessage string `json:"systemMessage,omitempty"`
	// Skills as pinned: git skills by commit, OCI skills by digest.
	Skills Skills `json:"skills,omitempty"`
	// Toolset is the toolset the agent declares: the owning HelmRelease's
	// `toolset` value, or — for a bare AgentTemplate — the X-Muster-Toolset
	// header of the agent's RemoteMCPServer. Absent when none is declared.
	Toolset []string `json:"toolset,omitempty"`
	// ImplicitFullAccess is true when the agent declares no toolset but binds
	// muster: its meta-tools see every tool the gateway exposes to the
	// caller. Such agents predate toolsets and still need one assigned.
	ImplicitFullAccess bool `json:"implicitFullAccess,omitempty"`
	// Tools are the template's MCP bindings.
	Tools []ToolBinding `json:"tools,omitempty"`
	// Ready is the platform Harness's verdict on the template (Ready and the
	// desired revision is the latest successful one); nil while the template
	// is absent or the Harness has not reported.
	Ready *bool `json:"ready"`
	// Harnesses is the template's per-Harness status.
	Harnesses []HarnessStatus `json:"harnesses,omitempty"`
	// Managed is helmrelease, gitops or none.
	Managed     string          `json:"managed"`
	HelmRelease *HelmReleaseRef `json:"helmRelease,omitempty"`
	// Values are the HelmRelease's inline values (the chart contract), when a
	// HelmRelease owns the agent.
	Values map[string]any `json:"values,omitempty"`
}

Agent is the read model of one agent.

type ChartRef

type ChartRef struct {
	Kind      string `json:"kind"`
	Name      string `json:"name"`
	Namespace string `json:"namespace,omitempty"`
}

ChartRef is a HelmRelease's spec.chartRef.

type ChartSource

type ChartSource interface {
	SchemaSource
	Info(ctx context.Context) chart.Info
	Name() string
	OCIURL() string
	SemverRange() string
}

ChartSource is what the service needs to know about the agent chart.

type CommitFile added in v1.5.0

type CommitFile struct {
	Path    string `json:"path"`
	Action  string `json:"action"`
	Content string `json:"content,omitempty"`
}

CommitFile is one file of the commit; Content is shown on a dry run.

type CommitResult added in v1.5.0

type CommitResult struct {
	// Repository is owner/name, Base the branch the change goes to.
	Repository string `json:"repository"`
	Base       string `json:"base"`
	// Directory is where the files go: CommitDirectory under the
	// Kustomization's path (or the path the caller named).
	Directory string `json:"directory"`
	// Kustomization is the Flux Kustomization (namespace/name) that lands
	// the files after the merge, and Prune its spec.prune. Empty for a target
	// the caller named.
	Kustomization string `json:"kustomization,omitempty"`
	Prune         bool   `json:"prune"`
	// Branch is the pull request's head branch.
	Branch string       `json:"branch"`
	Files  []CommitFile `json:"files"`
	// PullRequest is the URL of the pull request opened as the caller, empty
	// on a dry run and when nothing changes.
	PullRequest string `json:"pullRequest,omitempty"`
	Number      int    `json:"number,omitempty"`
	// Author is the GitHub login the pull request is opened as.
	Author string `json:"author,omitempty"`
	// LiveSteps are what the merge alone does not do on the installation.
	LiveSteps []string `json:"liveSteps,omitempty"`
}

CommitResult is the pull request a write in commit mode opened — or, dry run, would open — in the repository that owns the agent. The shape is cluster-manager's and model-manager's.

type ComposeConfig

type ComposeConfig struct {
	// ChartOCIURL is the agent chart, e.g. oci://gsoci.azurecr.io/charts/giantswarm/agent.
	ChartOCIURL string
	// ChartName is the OCIRepository's name (the chart name).
	ChartName string
	// ChartSemver is the OCIRepository ref.semver range (1.x).
	ChartSemver string
	// ChartSemverFilter is the OCIRepository ref.semverFilter: the regular
	// expression the tags must match before the range is evaluated. Empty
	// composes none.
	ChartSemverFilter string
	// HelmReleaseInterval / OCIRepositoryInterval are the Flux intervals.
	HelmReleaseInterval   string
	OCIRepositoryInterval string
	// ServiceAccountName is HelmRelease.spec.serviceAccountName, required by a
	// Flux multi-tenancy admission policy in tenant namespaces; empty omits it.
	ServiceAccountName string
	// HelmReleaseAPIVersion / OCIRepositoryAPIVersion are the served Flux API
	// versions (helm.toolkit.fluxcd.io/v2, source.toolkit.fluxcd.io/v1).
	HelmReleaseAPIVersion   string
	OCIRepositoryAPIVersion string
	// MusterURL is the platform's muster MCP URL, composed as the chart value
	// muster.url; empty composes nothing and the chart default applies.
	MusterURL string
	// TargetMusterURL is the muster MCP URL composed into an agent on a
	// workload cluster: one those clusters reach (the installation's public
	// endpoint). Empty: agents are refused a target cluster.
	TargetMusterURL string
	// HarnessName is the platform Harness every agent runs on: composed as
	// the chart value agent.harness (the admission label's value), and the
	// status.harnesses[] entry that decides an agent's readiness.
	HarnessName string
	// SkillsGitAuthSecretName is the installation's skills credential: the
	// Secret (key `token`) in the agent's namespace that every agent with a
	// git skill reads its skills with, unless the agent names its own.
	// Empty: such agents fetch anonymously.
	SkillsGitAuthSecretName string
}

ComposeConfig is the platform side of the composition.

func (ComposeConfig) ForTarget added in v1.9.0

func (c ComposeConfig) ForTarget() ComposeConfig

ForTarget is the composition of an agent on a workload cluster: muster at the URL the cluster reaches, and no installation skills credential (that Secret exists on the installation only; an agent on a cluster names its own).

type Condition

type Condition struct {
	Type               string `json:"type"`
	Status             string `json:"status"`
	Reason             string `json:"reason,omitempty"`
	Message            string `json:"message,omitempty"`
	LastTransitionTime string `json:"lastTransitionTime,omitempty"`
	ObservedGeneration int64  `json:"observedGeneration,omitempty"`
}

Condition is a Kubernetes-style status condition, flattened.

type Config

type Config struct {
	// DefaultNamespace receives agents when a request names none.
	DefaultNamespace string
	// ManagedNamespaces are the namespaces the service may read and write
	// (RBAC exists there); DefaultNamespace is always included.
	ManagedNamespaces []string
	// Compose is the platform side of the manifests.
	Compose ComposeConfig
	// KagentAPIVersion is the served kagent.dev version (v1alpha3).
	KagentAPIVersion string
	// Version is the service version reported by GET /info.
	Version string
	// GitHub offers commit mode: the pull request is opened as the person
	// with the GitHub token the App-pinned registration carries. Nil: commit
	// mode is refused as unsupported.
	GitHub RemoteFor
	// SkillsBootSecret keeps the installation's skills credential Secret
	// filled with the skills GitHub App's token; nil: the Secret is
	// provisioned by someone else.
	SkillsBootSecret *skills.BootSecret
}

Config configures the service.

type CreateResult

type CreateResult struct {
	Agent     Agent     `json:"agent"`
	Manifests Manifests `json:"manifests"`
	// Created says which objects were new; the OCIRepository is shared per
	// namespace and reused when it exists.
	Created struct {
		OCIRepository bool `json:"ociRepository"`
		HelmRelease   bool `json:"helmRelease"`
	} `json:"created"`
	Status *Status `json:"status,omitempty"`
	// RequestedBy is the authenticated caller the write ran as (email, else
	// subject); empty when the server runs without OAuth.
	RequestedBy string `json:"requestedBy,omitempty"`
	WriteOutcome
}

CreateResult reports what a create applied.

type DeleteResult

type DeleteResult struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Target
	HelmReleaseDeleted bool `json:"helmReleaseDeleted"`
	// AgentTemplateDeleted: the template was deleted directly (a bare one, or
	// the rendered objects of a suspended release, both with force).
	AgentTemplateDeleted   bool `json:"agentTemplateDeleted"`
	RemoteMCPServerDeleted bool `json:"remoteMcpServerDeleted"`
	OCIRepositoryDeleted   bool `json:"ociRepositoryDeleted"`
	// OCIRepositoryKept explains why the chart source stays (other agents
	// reference it, or it could not be checked).
	OCIRepositoryKept string `json:"ociRepositoryKept,omitempty"`
	// RequestedBy is the authenticated caller the delete ran as.
	RequestedBy string `json:"requestedBy,omitempty"`
	WriteOutcome
}

DeleteResult reports what a delete removed.

type Event

type Event struct {
	Type    string `json:"type"`
	Reason  string `json:"reason"`
	Message string `json:"message"`
	Object  string `json:"object"`
	Count   int32  `json:"count,omitempty"`
	Last    string `json:"lastTimestamp,omitempty"`
}

Event is a recent Warning event on the agent's objects.

type GitHubRemote added in v1.5.0

type GitHubRemote interface {
	commit.Remote
	commit.Reader
}

GitHubRemote is what commit mode needs of GitHub: the pull request seams and the reads of the base, acting as the person.

type GitSkill added in v1.0.0

type GitSkill struct {
	// URL of the git repository (http or https).
	URL string `json:"url"`
	// Ref is a branch, tag or commit a write resolves to its head commit at
	// write time; empty (and no Commit) means the repository's default
	// branch. Never written: the pin is Commit.
	Ref string `json:"ref,omitempty"`
	// Commit is the full commit id (40 or 64 hex characters) the skill is
	// pinned to. Given by a caller who has one (list_skills reports it),
	// resolved from Ref otherwise.
	Commit string `json:"commit,omitempty"`
}

GitSkill is a skill in a git repository. A write takes the repository and, optionally, a Ref to resolve or a Commit to pin; what is written and read back is always the Commit.

type HarnessStatus added in v1.0.0

type HarnessStatus struct {
	Harness string `json:"harness"`
	// Ready / Accepted / ResolvedRefs / Compatible mirror the conditions; nil
	// while unreported.
	Ready        *bool `json:"ready"`
	Accepted     *bool `json:"accepted"`
	ResolvedRefs *bool `json:"resolvedRefs"`
	Compatible   *bool `json:"compatible"`
	// DesiredRevision is the revision compiled from the current generation;
	// LatestSuccessfulRevision the last one that became ready.
	DesiredRevision          string      `json:"desiredRevision,omitempty"`
	LatestSuccessfulRevision string      `json:"latestSuccessfulRevision,omitempty"`
	Conditions               []Condition `json:"conditions,omitempty"`
	// Warnings are the Harness's non-blocking compatibility decisions.
	Warnings []string `json:"warnings,omitempty"`
}

HarnessStatus is what kagent reports for the template on one admitting Harness (AgentTemplate.status.harnesses[]).

type HelmReleaseHistory

type HelmReleaseHistory struct {
	Version      int64  `json:"version"`
	ChartVersion string `json:"chartVersion,omitempty"`
	Status       string `json:"status,omitempty"`
	LastDeployed string `json:"lastDeployed,omitempty"`
}

HelmReleaseHistory is one Helm release revision from status.history.

type HelmReleaseRef

type HelmReleaseRef struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	// Ready mirrors the Ready condition; nil while unreported.
	Ready   *bool  `json:"ready"`
	Reason  string `json:"reason,omitempty"`
	Message string `json:"message,omitempty"`
	// ChartVersion is the deployed chart version (last history entry), else
	// the last attempted revision.
	ChartVersion          string `json:"chartVersion,omitempty"`
	LastAttemptedRevision string `json:"lastAttemptedRevision,omitempty"`
	Suspended             bool   `json:"suspended"`
	GitOpsOwned           bool   `json:"gitOpsOwned"`
	// Deleting is true while helm-controller uninstalls the release (the
	// HelmRelease carries a deletionTimestamp); the template disappears with
	// it.
	Deleting bool      `json:"deleting"`
	ChartRef *ChartRef `json:"chartRef,omitempty"`
}

HelmReleaseRef is what an agent view says about its owning release.

type HelmReleaseStatus

type HelmReleaseStatus struct {
	Exists                bool                 `json:"exists"`
	Ready                 *bool                `json:"ready"`
	Suspended             bool                 `json:"suspended"`
	GitOpsOwned           bool                 `json:"gitOpsOwned"`
	Deleting              bool                 `json:"deleting"`
	Conditions            []Condition          `json:"conditions,omitempty"`
	History               []HelmReleaseHistory `json:"history,omitempty"`
	LastAttemptedRevision string               `json:"lastAttemptedRevision,omitempty"`
}

HelmReleaseStatus is the release's conditions and recent history.

type InfoResponse

type InfoResponse struct {
	Version string     `json:"version"`
	Chart   chart.Info `json:"chart"`
	// Namespaces the service manages agents in.
	Namespaces struct {
		Default string   `json:"default"`
		Managed []string `json:"managed"`
	} `json:"namespaces"`
	// Capabilities are explicit flags; a false flag means the matching
	// operation answers 501 unsupported (or, for commit, that the mode does
	// not exist on this installation).
	Capabilities map[string]bool `json:"capabilities"`
	// Identity says how calls reach the API server: `caller` (every call
	// presents the signed-in user's IdP token; the user's RBAC governs) or
	// `serviceAccount` (the service's own identity behind a trusted proxy).
	Identity string `json:"identity"`
	// APIVersions are the served CRD versions the service composes and reads.
	APIVersions struct {
		AgentTemplate   string `json:"agentTemplate"`
		Harness         string `json:"harness"`
		RemoteMCPServer string `json:"remoteMcpServer"`
		ModelConfig     string `json:"modelConfig"`
		HelmRelease     string `json:"helmRelease"`
		OCIRepository   string `json:"ociRepository"`
	} `json:"apiVersions"`
	// Flux settings the composed HelmReleases carry.
	Flux struct {
		HelmReleaseInterval   string `json:"helmReleaseInterval"`
		OCIRepositoryInterval string `json:"ociRepositoryInterval"`
		ServiceAccountName    string `json:"serviceAccountName,omitempty"`
	} `json:"flux"`
	// Harness is the platform Harness every agent runs on.
	Harness struct {
		Name string `json:"name"`
	} `json:"harness"`
	// Muster is the platform's muster MCP gateway as composed into every
	// agent: URL empty means the chart default applies.
	Muster struct {
		URL string `json:"url"`
		// TargetURL is the muster URL composed into agents on workload
		// clusters; empty: target clusters are refused.
		TargetURL string `json:"targetUrl,omitempty"`
	} `json:"muster"`
	// SkillsRepositories are the configured skill repositories.
	SkillsRepositories []string `json:"skillsRepositories"`
	// SkillsGitAuthSecretName is the installation's skills credential Secret
	// (key token) an agent with a git skill fetches with unless it names its
	// own; empty: anonymous fetches.
	SkillsGitAuthSecretName string `json:"skillsGitAuthSecretName,omitempty"`
	// SkillsGitAuthMint is the state of that Secret when agent-manager keeps
	// it filled with the skills GitHub App's token: the last refresh, the
	// token's expiry and a failed refresh's error.
	SkillsGitAuthMint *skills.BootSecretStatus `json:"skillsGitAuthMint,omitempty"`
}

InfoResponse is GET /info: what this installation can do, so the portal and agents feature-detect instead of guessing.

type Location added in v1.9.0

type Location struct {
	Namespace string `json:"namespace,omitempty"`
	Target
}

Location is where an agent is: its namespace (on the workload cluster when a target is set) and the target.

func In added in v1.9.0

func In(ns string) Location

In is the Location of namespace ns on the installation's own cluster.

type Manifests

type Manifests struct {
	OCIRepository string         `json:"ociRepository"`
	HelmRelease   string         `json:"helmRelease"`
	Values        map[string]any `json:"values"`
}

Manifests are the objects a create/update applies, as YAML, plus the values.

func ComposeManifests

func ComposeManifests(name, namespace string, values map[string]any, cfg ComposeConfig) Manifests

ComposeManifests renders the pair for a namespace and values.

type ModelConfig

type ModelConfig struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Provider  string `json:"provider,omitempty"`
	Model     string `json:"model,omitempty"`
	// Accepted mirrors the kagent Accepted condition; nil while unreported.
	Accepted  *bool  `json:"accepted"`
	Message   string `json:"message,omitempty"`
	ManagedBy string `json:"managedBy,omitempty"`
}

ModelConfig is a kagent ModelConfig an agent can reference.

type RemoteFor added in v1.5.0

type RemoteFor func(token string) (GitHubRemote, error)

RemoteFor builds the GitHub remote from the person's App user token.

type SchemaSource

type SchemaSource interface {
	Schema(ctx context.Context) chart.Schema
}

SchemaSource provides the agent chart's values.schema.json.

type Service

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

Service is the agent lifecycle.

func New

New builds the service. skills may be nil (list_skills then reports unsupported); pinner may be nil (skills must then come pinned).

func (*Service) CommitAvailable added in v1.5.0

func (s *Service) CommitAvailable() bool

CommitAvailable reports whether this server offers commit mode.

func (*Service) Create

func (s *Service) Create(ctx context.Context, spec Spec) (*CreateResult, error)

Create composes and applies the OCIRepository (when missing) and the HelmRelease of a new agent after pinning its skills and validating the values against the chart schema. Nothing is written when a check fails, or on a dry run. In commit mode the two land as files of a pull request in the repository that owns the namespace instead.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, loc Location, name string, force bool, w WriteOptions) (*DeleteResult, error)

Delete removes the agent's HelmRelease (helm-controller uninstalls the rendered AgentTemplate and RemoteMCPServer) and the shared OCIRepository when no other release references it. A bare AgentTemplate is only deleted with force. A dry run reports what would go and deletes nothing; in commit mode the files are removed with a pull request instead.

func (*Service) Get

func (s *Service) Get(ctx context.Context, loc Location, name string) (*Agent, error)

Get returns one agent by name.

func (*Service) Info

func (s *Service) Info(ctx context.Context) InfoResponse

Info reports the installation's capabilities.

func (*Service) List

func (s *Service) List(ctx context.Context, loc Location) ([]Agent, error)

List returns the agents of a namespace: every AgentTemplate (with its RemoteMCPServer and its owning HelmRelease when Flux labels name one) plus every HelmRelease of the agent chart that has not rendered a template yet.

func (*Service) ListModelConfigs

func (s *Service) ListModelConfigs(ctx context.Context, loc Location) ([]ModelConfig, error)

ListModelConfigs lists the kagent ModelConfigs of a namespace, on the target cluster when one is named.

func (*Service) ListSkills

func (s *Service) ListSkills(ctx context.Context, repository, ref string, refresh bool) (*skills.Result, error)

ListSkills discovers skills in the configured (or the given) repository.

func (*Service) Namespace

func (s *Service) Namespace(ns string) (string, error)

Namespace resolves an optional namespace argument against the managed set.

func (*Service) Status

func (s *Service) Status(ctx context.Context, loc Location, name string) (*Status, error)

Status gathers the AgentTemplate's per-Harness status, the owning HelmRelease (conditions, history) and the namespace's recent Warning events for the agent, and folds them into one verdict. For an agent on a workload cluster the template and its events are read there, the HelmRelease and its events on the installation.

func (*Service) Update

func (s *Service) Update(ctx context.Context, upd Update) (*UpdateResult, error)

Update merges the change into the HelmRelease values, validates the result against the chart schema and writes it. The rendered objects are never touched: helm-controller renders the change.

The write is a read-modify-write, retried when the API server answers Conflict: helm-controller writes the release's status while it reconciles the previous change, so an update that follows another closely reads a resourceVersion that is stale by the time it writes — nothing the caller asked for is in conflict. Every attempt reads the release again and merges into its latest values; a Conflict that outlasts the attempts is reported. The refusals of writableHelmRelease are conflicts of the domain, not of the API server, and end the attempts at once.

func (*Service) ValidateCreate

func (s *Service) ValidateCreate(ctx context.Context, spec Spec) (*ValidateResult, error)

ValidateCreate is create_agent without the write.

func (*Service) ValidateUpdate

func (s *Service) ValidateUpdate(ctx context.Context, upd Update) (*ValidateResult, error)

ValidateUpdate is update_agent without the write.

type Skill added in v1.0.0

type Skill struct {
	// Name is the skill's name under the template (spec.skills[].name), the
	// directory it mounts under; defaults to the last path segment, else the
	// repository name. Unique per agent.
	Name string `json:"name,omitempty"`
	// Path is the subdirectory holding SKILL.md (git skills); empty for the
	// repository root. Relative, without "..".
	Path string `json:"path,omitempty"`
	// Git is the git source.
	Git *GitSkill `json:"git,omitempty"`
	// OCI is the OCI source: <registry>/<repository>@sha256:<digest> once
	// written; a write also takes <registry>/<repository>:<tag> and resolves
	// the digest.
	OCI string `json:"oci,omitempty"`
}

Skill is one skills[] entry of the Generic chart 1.x values: a name, a subdirectory and exactly one source, git or OCI.

type SkillPinner added in v1.0.0

type SkillPinner interface {
	// GitHead resolves ref of repoURL (empty: the default branch) to a commit.
	GitHead(ctx context.Context, repoURL, ref string) (string, error)
	// OCIDigest pins an OCI reference to <repository>@sha256:<digest>.
	OCIDigest(ctx context.Context, ref string) (string, error)
	// RequireReadable refuses a repository login (the caller's GitHub login,
	// empty when unknown) cannot read: skills.ErrNotReadable.
	RequireReadable(ctx context.Context, repoURL, login string) error
}

SkillPinner resolves mutable skill references to pins (skills.Resolver).

type Skills

type Skills []Skill

Skills is an agent's skill list.

func PinSkills added in v1.1.0

func PinSkills(ctx context.Context, p SkillPinner, list Skills) (Skills, error)

PinSkills is the composer's pinning for other callers (the migrate command rewriting 0.x releases): every entry pinned to a commit or a digest and named the way create_agent names it, or an ErrInvalid naming the reference that could not be resolved.

func (*Skills) UnmarshalJSON added in v1.0.0

func (s *Skills) UnmarshalJSON(b []byte) error

UnmarshalJSON accepts the list and explains the 0.x object shape ({refs, gitRefs, gitAuthSecretName}) to a caller still sending it.

type Spec

type Spec struct {
	// Location is the agent's namespace (empty selects the default managed
	// namespace) and, to run it on a workload cluster, the target cluster.
	// Fixed at create.
	Location
	// Name is the DNS-1123 technical name: the HelmRelease name and the
	// AgentTemplate name. The caller confirms it; agent-manager never derives
	// it.
	Name string `json:"name"`
	// DisplayName is the friendly Unicode name (max 63 chars).
	DisplayName string `json:"displayName,omitempty"`
	// Description goes to AgentTemplate.spec.description.
	Description string `json:"description,omitempty"`
	// SystemMessage is the system prompt (spec.systemPrompt); empty keeps the
	// chart default. At most MaxSystemMessageLength characters.
	SystemMessage string `json:"systemMessage,omitempty"`
	// ModelConfig names an existing kagent ModelConfig in the namespace.
	ModelConfig string `json:"modelConfig"`
	// Harness names the Harness of the namespace that runs the agent (chart
	// agent.harness); empty selects the platform Harness. Fixed at create.
	Harness string `json:"harness,omitempty"`
	// IconURL is the avatar URL (chart agent.iconUrl, rendered as the
	// ui.giantswarm.io/icon-url annotation).
	IconURL string `json:"iconUrl,omitempty"`
	// Skills the agent mounts; every entry is pinned before it is written.
	Skills Skills `json:"skills,omitempty"`
	// GitAuthSecretName names the Secret in the agent's namespace whose key
	// `token` reads the agent's private git skills (chart value
	// skillsGitAuthSecretRef.name, fanned out to every git skill). Empty
	// selects the installation's (ComposeConfig.SkillsGitAuthSecretName).
	GitAuthSecretName string `json:"gitAuthSecretName,omitempty"`
	// Toolset is the list of selectors that bounds which of the gateway's
	// tools the agent can use (chart value `toolset`). Required on create;
	// see ValidateToolset for the grammar.
	Toolset []string `json:"toolset,omitempty"`
	// Labels / Annotations are merged onto the AgentTemplate by the chart.
	Labels      map[string]string `json:"labels,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`

	// Removed arguments: they only exist so that a caller still passing them
	// is told why they are gone (see rejectRemoved) instead of getting an
	// "unknown field" error.
	RemovedToolNames json.RawMessage `json:"toolNames,omitempty"`
	RemovedRuntime   json.RawMessage `json:"runtime,omitempty"`

	WriteOptions
}

Spec is what a caller provides to create an agent. Everything but Name, ModelConfig and Toolset is optional; omitted fields keep the chart's defaults.

type Status

type Status struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Target
	// Verdict is ready, progressing, failed or unknown.
	Verdict string `json:"verdict"`
	// Summary is one sentence a human or an agent can act on.
	Summary     string             `json:"summary"`
	Template    *TemplateStatus    `json:"template,omitempty"`
	HelmRelease *HelmReleaseStatus `json:"helmRelease,omitempty"`
	Events      []Event            `json:"events,omitempty"`
	// contains filtered or unexported fields
}

Status is the compact verdict of get_agent_status.

type Target added in v1.9.0

type Target struct {
	// Organization owns the cluster: its namespace org-<organization> on the
	// installation holds the Cluster and its kubeconfig Secret.
	Organization string `json:"organization,omitempty"`
	// Cluster is the workload cluster's name.
	Cluster string `json:"cluster,omitempty"`
}

Target names the workload cluster an agent runs on: both fields or none.

func (Target) FluxNamespace added in v1.9.0

func (t Target) FluxNamespace() string

FluxNamespace is the installation namespace the agent's HelmRelease lives in: the organization's.

func (Target) IsSet added in v1.9.0

func (t Target) IsSet() bool

IsSet reports whether the target names a cluster.

func (Target) KubeconfigSecret added in v1.9.0

func (t Target) KubeconfigSecret() string

KubeconfigSecret is the name of the cluster's kubeconfig Secret.

func (Target) ReleaseName added in v1.9.0

func (t Target) ReleaseName(agent string) string

ReleaseName is the HelmRelease name of an agent on the cluster: prefixed with the cluster, since one organization namespace holds the releases of all its clusters. Its length is checked by ValidateReleaseName.

func (Target) Validate added in v1.9.0

func (t Target) Validate() error

Validate checks that both fields are DNS-1123 labels, or both are empty.

func (Target) ValidateReleaseName added in v1.9.0

func (t Target) ValidateReleaseName(agent string) error

ValidateReleaseName refuses a cluster and agent name pair whose release name is not a label value (helm-controller stamps it on every object).

type TemplateStatus added in v1.0.0

type TemplateStatus struct {
	Exists             bool            `json:"exists"`
	Generation         int64           `json:"generation,omitempty"`
	ObservedGeneration int64           `json:"observedGeneration,omitempty"`
	Harnesses          []HarnessStatus `json:"harnesses"`
}

TemplateStatus is the AgentTemplate's status: one entry per admitting Harness, plus the generations that say whether kagent has caught up.

type ToolBinding added in v1.0.0

type ToolBinding struct {
	// Server is the RemoteMCPServer bound (same namespace).
	Server string `json:"server"`
	// Tools narrows the binding to these tools; empty is every tool.
	Tools []string `json:"tools,omitempty"`
}

ToolBinding is one MCP tool binding of the template (spec.tools[].mcp).

type Update

type Update struct {
	Location
	Name          string  `json:"name"`
	DisplayName   *string `json:"displayName,omitempty"`
	Description   *string `json:"description,omitempty"`
	SystemMessage *string `json:"systemMessage,omitempty"`
	ModelConfig   *string `json:"modelConfig,omitempty"`
	IconURL       *string `json:"iconUrl,omitempty"`
	Skills        *Skills `json:"skills,omitempty"`
	// GitAuthSecretName replaces the skills credential Secret; empty clears it
	// back to the installation's.
	GitAuthSecretName *string            `json:"gitAuthSecretName,omitempty"`
	Toolset           *[]string          `json:"toolset,omitempty"`
	Labels            *map[string]string `json:"labels,omitempty"`
	Annotations       *map[string]string `json:"annotations,omitempty"`
	// RefreshSkills re-resolves every git skill of the agent to the head of
	// its repository's default branch — a skill passed in Skills with a Ref
	// goes to that ref's head — and changes nothing else on the release.
	RefreshSkills bool `json:"refreshSkills,omitempty"`
	// Removed arguments: see Spec.
	RemovedToolNames json.RawMessage `json:"toolNames,omitempty"`
	RemovedRuntime   json.RawMessage `json:"runtime,omitempty"`
	// Force writes to a suspended HelmRelease anyway. A GitOps-owned one is
	// never written live: mode commit changes it in git.
	Force bool `json:"force,omitempty"`

	WriteOptions
}

Update is a partial change to an existing agent: nil pointers leave the current value; a pointer to an empty value clears it (falls back to the chart default). Skills replace the whole list; Toolset replaces the whole list (an empty list is refused: use preset:none).

type UpdateResult

type UpdateResult struct {
	Agent     Agent          `json:"agent"`
	Before    map[string]any `json:"before"`
	After     map[string]any `json:"after"`
	Changed   []string       `json:"changed"`
	Manifests Manifests      `json:"manifests"`
	// RequestedBy is the authenticated caller the write ran as.
	RequestedBy string `json:"requestedBy,omitempty"`
	WriteOutcome
}

UpdateResult reports before/after values of an update.

type ValidateResult

type ValidateResult struct {
	Valid bool `json:"valid"`
	// Mode is create or update.
	Mode string `json:"mode"`
	// Errors lists every schema violation and precondition failure.
	Errors []string `json:"errors,omitempty"`
	// Notes lists the checks the dry run could not make, such as the name
	// check for a caller who may not read the namespace's releases.
	Notes []string `json:"notes,omitempty"`
	// SchemaVersion / SchemaSource say which chart schema judged the values.
	SchemaVersion string    `json:"schemaVersion"`
	SchemaSource  string    `json:"schemaSource"`
	Manifests     Manifests `json:"manifests"`
}

ValidateResult is a dry run: nothing was written.

type WriteOptions added in v1.5.0

type WriteOptions struct {
	// Mode is apply (default) or commit.
	Mode string `json:"mode,omitempty"`
	// DryRun returns the manifests and, in commit mode, the files and the
	// pull request that would be opened, and writes nothing.
	DryRun bool `json:"dryRun,omitempty"`
	// Repository (owner/name), Branch and Path name the commit target where
	// no Flux Kustomization owns the namespace yet; given, they override the
	// target derived from Flux. Commit mode only.
	Repository string `json:"repository,omitempty"`
	Branch     string `json:"branch,omitempty"`
	Path       string `json:"path,omitempty"`
}

WriteOptions say how a write lands. Every write tool takes them.

type WriteOutcome added in v1.5.0

type WriteOutcome struct {
	Mode   string        `json:"mode"`
	DryRun bool          `json:"dryRun"`
	Commit *CommitResult `json:"commit,omitempty"`
}

WriteOutcome is how a write landed: its mode, whether it was a dry run (Created, the deleted flags and the agent then say what would happen) and, in commit mode, the pull request.

Jump to

Keyboard shortcuts

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