Documentation
¶
Overview ¶
Package agents owns saved Agents: reusable configuration a tenant keeps independently of Sessions, with the optional model provider bundle that its x_agents_core.model_provider describes. It validates and merges saved configuration; Session snapshots and execution belong elsewhere.
Index ¶
Constants ¶
const MaxConfigurationBytes = 512 * 1024
MaxConfigurationBytes bounds a saved configuration and an update's patch.
const MaxPageSize = 100
MaxPageSize bounds one page of ListAgents.
Variables ¶
var ( // ErrNotFound reports an Agent the tenant does not have, including an // identifier that cannot name one. ErrNotFound = errors.New("agent not found") // ErrInvalidInput reports configuration, metadata or a request limit that // the saved Agent rules reject. ErrInvalidInput = errors.New("invalid agent input") )
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
ID string
TenantID string
Metadata map[string]string
Configuration json.RawMessage
CreatedAt time.Time
UpdatedAt time.Time
}
Agent is saved configuration owned by a tenant. It has no Harness binding or live execution state; Session snapshots are separate objects.
type CreateCommand ¶
type CreateCommand struct {
TenantID string
Metadata map[string]string
Configuration json.RawMessage
ModelProvider *v1.ModelProviderInput
}
CreateCommand saves a new Agent. Configuration is the resolved saved configuration; ModelProvider is the bundle its x_agents_core.model_provider describes. Each call creates a new Agent.
type DeleteCommand ¶
DeleteCommand removes an Agent. Session snapshots taken from it stay.
type ListQuery ¶
ListQuery selects one page of a tenant's Agents in creation order. After is the last Agent of the previous page; an After that names no Agent of the tenant is ErrNotFound.
type ModelProviderChange ¶
type ModelProviderChange struct {
Provider *v1.ModelProviderInput
}
ModelProviderChange replaces an Agent's saved model provider bundle. A nil Provider removes it.
type NewAgent ¶
type NewAgent struct {
TenantID string
// Metadata is the encoded metadata object.
Metadata json.RawMessage
Configuration json.RawMessage
// ModelProvider is sealed beside the Agent; nil saves none.
ModelProvider *v1.ModelProviderInput
}
NewAgent is a validated Agent to create.
type Revision ¶
type Revision struct {
// Metadata is the encoded metadata object.
Metadata json.RawMessage
Configuration json.RawMessage
// ModelProvider nil keeps the saved bundle.
ModelProvider *ModelProviderChange
}
Revision is the complete next state of an Agent.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service runs the Agent write use cases. Reads go through Reader.
func NewService ¶
type Storage ¶
type Storage interface {
// CreateAgent assigns the Agent's ID and saves it with its sealed model
// provider bundle.
CreateAgent(context.Context, NewAgent) (Agent, error)
// WithAgentUpdate locks the tenant's Agent and runs update; the revision
// it applies commits only when update returns nil.
WithAgentUpdate(ctx context.Context, tenantID, agentID string, update func(UpdateTx) error) error
// DeleteAgent removes the Agent and its model provider bundle and returns
// the deleted ID.
DeleteAgent(ctx context.Context, tenantID, agentID string) (string, error)
}
Storage persists Agent writes. Each method runs in one transaction that also records the write audit. An agent ID that cannot name an Agent is a missing Agent.
type UpdateCommand ¶
type UpdateCommand struct {
TenantID string
AgentID string
Configuration json.RawMessage
Metadata *map[string]string
ModelProvider *ModelProviderChange
}
UpdateCommand changes the supplied fields of an Agent. Configuration holds the supplied top-level fields only (see mergeConfiguration). Metadata nil keeps the saved map; a supplied map replaces it. ModelProvider nil keeps the saved bundle.