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
- Variables
- func BuildHelmRelease(name, namespace string, values map[string]any, cfg ComposeConfig) *unstructured.Unstructured
- func BuildOCIRepository(namespace string, cfg ComposeConfig) *unstructured.Unstructured
- func BuildValues(spec Spec, cfg ComposeConfig) map[string]any
- func ParseToolsetHeader(value string) []string
- func SkillsValues(list Skills) []any
- func ToYAML(obj *unstructured.Unstructured) string
- func ValidateName(name string) error
- func ValidateSkills(list Skills) error
- func ValidateSystemMessage(message string) error
- func ValidateToolset(selectors []string, required bool) error
- func ValidateValues(ctx context.Context, src SchemaSource, values map[string]any) (chart.Schema, []string)
- type Agent
- type ChartRef
- type ChartSource
- type CommitFile
- type CommitResult
- type ComposeConfig
- type Condition
- type Config
- type CreateResult
- type DeleteResult
- type Event
- type GitHubRemote
- type GitSkill
- type HarnessStatus
- type HelmReleaseHistory
- type HelmReleaseRef
- type HelmReleaseStatus
- type InfoResponse
- type Manifests
- type ModelConfig
- type RemoteFor
- type SchemaSource
- type Service
- func (s *Service) CommitAvailable() bool
- func (s *Service) Create(ctx context.Context, spec Spec) (*CreateResult, error)
- func (s *Service) Delete(ctx context.Context, ns, name string, force bool, w WriteOptions) (*DeleteResult, error)
- func (s *Service) Get(ctx context.Context, ns, name string) (*Agent, error)
- func (s *Service) Info(ctx context.Context) InfoResponse
- func (s *Service) List(ctx context.Context, ns string) ([]Agent, error)
- func (s *Service) ListModelConfigs(ctx context.Context, ns string) ([]ModelConfig, error)
- func (s *Service) ListSkills(ctx context.Context, repository, ref string, refresh bool) (*skills.Result, error)
- func (s *Service) Namespace(ns string) (string, error)
- func (s *Service) Status(ctx context.Context, ns, name string) (*Status, error)
- func (s *Service) Update(ctx context.Context, upd Update) (*UpdateResult, error)
- func (s *Service) ValidateCreate(ctx context.Context, spec Spec) (*ValidateResult, error)
- func (s *Service) ValidateUpdate(ctx context.Context, upd Update) (*ValidateResult, error)
- type Skill
- type SkillPinner
- type Skills
- type Spec
- type Status
- type TemplateStatus
- type ToolBinding
- type Update
- type UpdateResult
- type ValidateResult
- type WriteOptions
- type WriteOutcome
Constants ¶
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" )
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 )
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.
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.
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.
const ( VerdictReady = "ready" VerdictProgressing = "progressing" VerdictFailed = "failed" VerdictUnknown = "unknown" )
Verdicts of a status check.
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).
const DefaultKagentAPIVersion = "v1alpha3"
DefaultKagentAPIVersion is composed when discovery cannot answer.
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).
const KustomizationNamespaceLabel = "kustomize.toolkit.fluxcd.io/namespace"
KustomizationNamespaceLabel is the namespace of the Kustomization named by KustomizationNameLabel.
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.
const SkillsGitAuthValuesKey = "skillsGitAuthSecretRef"
SkillsGitAuthValuesKey is the chart 1.x value that fans one read credential out to every git skill: {name: <Secret>}.
Variables ¶
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.
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.
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 ParseToolsetHeader ¶ added in v0.4.0
ParseToolsetHeader splits a rendered X-Muster-Toolset header value back into selectors (comma-separated, whitespace around selectors trimmed).
func SkillsValues ¶ added in v1.1.0
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 ¶
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
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
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
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"`
// 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
// 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
// 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.
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
}
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"`
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
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"`
} `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"`
}
InfoResponse is GET /info: what this installation can do, so the portal and agents feature-detect instead of guessing.
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 ¶
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 ¶
func New(k kube.Provider, c ChartSource, s *skills.Discoverer, p SkillPinner, cfg Config, log *slog.Logger) *Service
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
CommitAvailable reports whether this server offers commit mode.
func (*Service) Create ¶
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, ns, 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) Info ¶
func (s *Service) Info(ctx context.Context) InfoResponse
Info reports the installation's capabilities.
func (*Service) List ¶
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 ¶
ListModelConfigs lists the kagent ModelConfigs of a namespace.
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 ¶
Namespace resolves an optional namespace argument against the managed set.
func (*Service) Status ¶
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.
func (*Service) Update ¶
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 ¶
ValidateCreate is create_agent without the write.
func (*Service) ValidateUpdate ¶
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
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
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 {
// Namespace the agent lives in; empty selects the default managed namespace.
Namespace string `json:"namespace,omitempty"`
// 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"`
// 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"`
}
Status is the compact verdict of get_agent_status.
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 {
Namespace string `json:"namespace,omitempty"`
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"`
// 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.