Documentation
¶
Overview ¶
Package agent owns the rules for a space's agent definitions.
The handlers that used to hold these rules re-derived them per route: four of them separately asked the store for an agent and compared its space, and the one that deletes carried the workflow check inline. Both belong here, where a second caller -- a CLI command, another service -- gets them for free.
Index ¶
- Variables
- type CreateCmd
- type ModelCatalog
- type PluginSelection
- type RestoreRevisionCmd
- type SecretLookup
- type Service
- func (s *Service) CreateAgent(ctx context.Context, cmd CreateCmd) (*agentdef.Agent, error)
- func (s *Service) DeleteAgent(ctx context.Context, spaceID, agentID, userID string) error
- func (s *Service) GetAgent(ctx context.Context, spaceID, agentID string) (*agentdef.Agent, error)
- func (s *Service) ListAgents(ctx context.Context, spaceID string) ([]agentdef.Agent, error)
- func (s *Service) ListRevisions(ctx context.Context, spaceID, agentID string, limit, offset int) ([]agentdef.Revision, int, error)
- func (s *Service) RestoreRevision(ctx context.Context, cmd RestoreRevisionCmd) (*agentdef.Agent, error)
- func (s *Service) UpdateAgent(ctx context.Context, cmd UpdateCmd) (*agentdef.Agent, error)
- type UpdateCmd
- type WorkflowUsage
Constants ¶
This section is empty.
Variables ¶
var ( ErrAgentsNotConfigured = apierr.New(apierr.KindNotConfigured, "agents not configured") ErrAgentNotFound = apierr.New(apierr.KindNotFound, "agent not found") ErrRevisionNotFound = apierr.New(apierr.KindNotFound, "agent revision not found") ErrNameRequired = apierr.New(apierr.KindInvalid, "name required") ErrUnknownModel = apierr.New(apierr.KindInvalid, "unknown model") ErrInvalidSandboxTier = apierr.New(apierr.KindInvalid, "unknown sandbox network or filesystem tier") ErrUsedByPublishedFlows = apierr.New(apierr.KindConflict, "agent is used by published workflows") ErrPluginsNotConfigured = apierr.New(apierr.KindNotConfigured, "this deployment cannot resolve plugins, so an agent cannot name one") ErrSecretsNotConfigured = apierr.New(apierr.KindNotConfigured, "this deployment has no secret store, so an agent cannot consume one") ErrInstructionsTooLong = apierr.New(apierr.KindInvalid, "Space and Agent instructions exceed 8192 characters") )
Functions ¶
This section is empty.
Types ¶
type CreateCmd ¶
type CreateCmd struct {
SpaceID string
UserID string
Name string
Description string
Instructions string
// Model is the catalog model name this agent's runs call. Empty means the
// deployment default. See agentdef.Agent.Model.
Model string
// Plugins names catalog plugins this agent loads. Nothing is inherited
// from the space's activations, so an empty list means no plugins.
Plugins []string
// SandboxNetworkTier and SandboxFilesystemTier declare this agent's
// worker sandbox needs. Empty means the strictest tier on that axis. See
// docs/design/agent-sandbox-policy.md §4.2.
SandboxNetworkTier string
SandboxFilesystemTier string
// SecretConsumption declares which Space Secrets this agent consumes.
SecretConsumption agentdef.SecretConsumption
}
type ModelCatalog ¶
ModelCatalog lists the model names this deployment offers, so an agent naming a model its deployment does not serve is refused while somebody is watching a create/update rather than failing at its first run. The gateway checks again at call time -- a model can be disabled after the agent was saved -- but that later refusal is a failed run, and this one is a correction.
An interface rather than the gateway service itself, for the reason WorkflowUsage and PluginSelection are: this package needs one question answered, and depending on the whole service would tie an agent edit to inference routing.
type PluginSelection ¶
type PluginSelection interface {
ResolveSelection(ctx context.Context, spaceID string, names []string, actorID string) ([]coreplugin.Activation, error)
}
PluginSelection turns the plugin names an agent carries into the space activations that back them, applying the space's curation mode.
An interface rather than the plugin service itself, for the reason WorkflowUsage is one: this package needs one question answered, and depending on the whole service would tie an agent edit to publication and package storage.
type RestoreRevisionCmd ¶
type SecretLookup ¶
type SecretLookup interface {
GetSecret(ctx context.Context, id string) (*coresecret.Secret, error)
}
SecretLookup answers what Secret consumption validation needs: a space's Secret and its item names. It is an interface, and not the secret store itself, for the reason PluginSelection is one: an agent edit needs one question answered and must not depend on secret cryptography or lifecycle.
type Service ¶
type Service struct {
Agents agentdef.Store
Spaces interface {
GetSpace(context.Context, string) (*corespace.Space, error)
}
// Plugins is optional, and nil means the deployment has no Marketplace.
// An agent that names a plugin is then refused rather than saved: storing
// a selection nothing can resolve would be a definition that silently does
// less than it says.
Plugins PluginSelection
// Workflows is optional. Nil means the deployment cannot answer which
// workflows use an agent, so a delete is not blocked on that check -- the
// same behaviour as before, when the handler skipped it on a nil store.
Workflows WorkflowUsage
// Secrets is optional, and nil means the deployment has no secret store.
// An agent that consumes a Secret is then refused rather than saved, the
// same way a plugin selection is refused with no Marketplace.
Secrets SecretLookup
// Models is optional, and nil means this deployment cannot enumerate its
// models -- a direct-transport deployment reads its one model from
// server.yaml and has no catalog to check against. A model name is then
// stored unchecked and takes effect only if the run's transport can reach
// it; unlike a plugin, an unresolvable model has a defined fallback (the
// deployment default) at run time, so it is accepted rather than refused.
Models ModelCatalog
// Audit is optional; nil discards the events. An agent definition is
// instructions plus a tool and model selection that later runs execute, so a
// change to one is a governed act worth the trail.
Audit *audit.Recorder
}
func (*Service) CreateAgent ¶
func (*Service) DeleteAgent ¶
DeleteAgent marks an agent deleted, refusing while a published workflow still names it.
Deleting it anyway would leave that workflow unable to run and the operator would only find out at its next step. The refusal names the workflows so they can be fixed or archived first.
func (*Service) GetAgent ¶
GetAgent resolves an agent the space owns.
An agent belonging to another space reads as not found rather than forbidden, so the answer does not confirm that an id exists somewhere else.
func (*Service) ListAgents ¶
func (*Service) ListRevisions ¶
func (*Service) RestoreRevision ¶
func (s *Service) RestoreRevision(ctx context.Context, cmd RestoreRevisionCmd) (*agentdef.Agent, error)
RestoreRevision writes an older definition back as a new revision. Restoring is an edit, not a rewind: the history keeps growing.
type WorkflowUsage ¶
type WorkflowUsage interface {
PublishedWorkflowsUsingAgent(ctx context.Context, spaceID, agentID string) ([]coreworkflow.Workflow, error)
}
WorkflowUsage reports which published workflows still name an agent.
An interface rather than the workflow service itself: this package needs one question answered, and depending on the whole service would tie an agent edit to workflow orchestration.