agent_config

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentConfig

type AgentConfig struct {
	ID        uuid.UUID       `json:"id" db:"id"`             // Row ID (unique per row)
	AgentID   uuid.UUID       `json:"agent_id" db:"agent_id"` // Stable UUID per agent (shared across versions)
	ProjectID uuid.UUID       `json:"project_id" db:"project_id"`
	Name      string          `json:"name" db:"name"`
	Version   int             `json:"version" db:"version"`     // Version number (0 is mutable, 1+ are immutable)
	Immutable bool            `json:"immutable" db:"immutable"` // true for versions > 0, false for version 0
	Config    AgentConfigData `json:"config" db:"config"`
	CreatedAt time.Time       `json:"created_at" db:"created_at"`
	UpdatedAt time.Time       `json:"updated_at" db:"updated_at"`
}

AgentConfig represents a versioned agent configuration stored in the database

type AgentConfigAlias

type AgentConfigAlias struct {
	ID        uuid.UUID `json:"id" db:"id"`
	ProjectID uuid.UUID `json:"project_id" db:"project_id"`
	AgentID   uuid.UUID `json:"agent_id" db:"agent_id"`
	Name      string    `json:"name" db:"name"`
	Version1  int       `json:"version1" db:"version1"`           // Required: at least one version
	Version2  *int      `json:"version2,omitempty" db:"version2"` // Optional: second version
	Weight    *float64  `json:"weight,omitempty" db:"weight"`     // Weight for version2 (0-100), required if version2 is set
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}

AgentConfigAlias represents a named mapping to one or two agent versions

type AgentConfigData

type AgentConfigData struct {
	Runtime    *string           `json:"runtime,omitempty"` // "Local", "Restate", or "Temporal"
	Model      *ModelConfig      `json:"model,omitempty"`
	Prompt     *PromptConfig     `json:"prompt,omitempty"`
	Schema     *SchemaConfig     `json:"schema,omitempty"`
	MCPServers []MCPServerConfig `json:"mcp_servers,omitempty"`
	History    *HistoryConfig    `json:"history,omitempty"`
}

AgentConfigData represents the complete JSON configuration stored in the config column

func (*AgentConfigData) Scan

func (c *AgentConfigData) Scan(value interface{}) error

Scan implements the sql.Scanner interface for database/sql

func (AgentConfigData) Value

func (c AgentConfigData) Value() (driver.Value, error)

Value implements the driver.Valuer interface for database/sql

type AgentConfigRepo

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

AgentConfigRepo handles database operations for agent configs

func NewAgentConfigRepo

func NewAgentConfigRepo(db *sqlx.DB) *AgentConfigRepo

NewAgentConfigRepo creates a new agent config repository

func (*AgentConfigRepo) Create

func (r *AgentConfigRepo) Create(ctx context.Context, projectID uuid.UUID, req *CreateAgentConfigRequest) (*AgentConfig, error)

Create creates a new agent config with agent_id and version 0

func (*AgentConfigRepo) CreateAlias

func (r *AgentConfigRepo) CreateAlias(ctx context.Context, projectID, agentID uuid.UUID, req *CreateAliasRequest) (*AgentConfigAlias, error)

CreateAlias creates a new alias for an agent config

func (*AgentConfigRepo) CreateVersion

func (r *AgentConfigRepo) CreateVersion(ctx context.Context, agentID uuid.UUID) (*AgentConfig, error)

CreateVersion creates a new immutable version from version 0

func (*AgentConfigRepo) Delete

func (r *AgentConfigRepo) Delete(ctx context.Context, agentID uuid.UUID) error

Delete deletes all versions of an agent config by agent_id

func (*AgentConfigRepo) DeleteAlias

func (r *AgentConfigRepo) DeleteAlias(ctx context.Context, projectID, id uuid.UUID) error

DeleteAlias deletes an alias by ID

func (*AgentConfigRepo) DeleteByName

func (r *AgentConfigRepo) DeleteByName(ctx context.Context, projectID uuid.UUID, name string) error

DeleteByName deletes all versions of an agent config by name

func (*AgentConfigRepo) DeleteVersion

func (r *AgentConfigRepo) DeleteVersion(ctx context.Context, agentID uuid.UUID, version int) error

DeleteVersion deletes a specific version of an agent config

func (*AgentConfigRepo) Exists

func (r *AgentConfigRepo) Exists(ctx context.Context, projectID uuid.UUID, name string) (bool, error)

Exists checks if an agent config with the given name exists

func (*AgentConfigRepo) GetAgentIDByName

func (r *AgentConfigRepo) GetAgentIDByName(ctx context.Context, projectID uuid.UUID, name string) (uuid.UUID, error)

GetAgentIDByName retrieves the agent_id for a given name

func (*AgentConfigRepo) GetAlias

func (r *AgentConfigRepo) GetAlias(ctx context.Context, projectID, id uuid.UUID) (*AgentConfigAlias, error)

GetAlias retrieves an alias by ID

func (*AgentConfigRepo) GetAliasByName

func (r *AgentConfigRepo) GetAliasByName(ctx context.Context, projectID, agentID uuid.UUID, name string) (*AgentConfigAlias, error)

GetAliasByName retrieves an alias by agent_id and name

func (*AgentConfigRepo) GetByAgentIDAndVersion

func (r *AgentConfigRepo) GetByAgentIDAndVersion(ctx context.Context, projectID uuid.UUID, agentID uuid.UUID, version int) (*AgentConfig, error)

GetByAgentIDAndVersion retrieves an agent config by agent_id and version

func (*AgentConfigRepo) GetByID

func (r *AgentConfigRepo) GetByID(ctx context.Context, projectID, id uuid.UUID) (*AgentConfig, error)

GetByID retrieves an agent config by row ID

func (*AgentConfigRepo) GetByNameAndVersion

func (r *AgentConfigRepo) GetByNameAndVersion(ctx context.Context, projectID uuid.UUID, name string, version int) (*AgentConfig, error)

GetByNameAndVersion retrieves an agent config by name and version (for backward compatibility)

func (*AgentConfigRepo) GetLatestByName

func (r *AgentConfigRepo) GetLatestByName(ctx context.Context, projectID uuid.UUID, name string) (*AgentConfig, error)

GetLatestByName retrieves version 0 (the mutable version) of an agent config by name

func (*AgentConfigRepo) List

func (r *AgentConfigRepo) List(ctx context.Context, projectID uuid.UUID) ([]*AgentConfigSummary, error)

List retrieves all unique agent configs (version 0 summary) for a project

func (*AgentConfigRepo) ListAliases

func (r *AgentConfigRepo) ListAliases(ctx context.Context, projectID, agentID uuid.UUID) ([]*AgentConfigAlias, error)

ListAliases retrieves all aliases for an agent

func (*AgentConfigRepo) ListVersions

func (r *AgentConfigRepo) ListVersions(ctx context.Context, projectID uuid.UUID, agentID uuid.UUID) ([]*AgentConfig, error)

ListVersions retrieves all versions of an agent config by agent_id

func (*AgentConfigRepo) ListVersionsByName

func (r *AgentConfigRepo) ListVersionsByName(ctx context.Context, projectID uuid.UUID, name string) ([]*AgentConfig, error)

ListVersionsByName retrieves all versions of an agent config by name (for backward compatibility)

func (*AgentConfigRepo) UpdateAlias

func (r *AgentConfigRepo) UpdateAlias(ctx context.Context, projectID, id uuid.UUID, req *UpdateAliasRequest) (*AgentConfigAlias, error)

UpdateAlias updates an existing alias

func (*AgentConfigRepo) UpdateVersion0

func (r *AgentConfigRepo) UpdateVersion0(ctx context.Context, agentID uuid.UUID, req *UpdateAgentConfigRequest) (*AgentConfig, error)

UpdateVersion0 updates version 0 in place (mutable)

type AgentConfigService

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

AgentConfigService handles business logic for agent configs

func NewAgentConfigService

func NewAgentConfigService(repo *AgentConfigRepo) *AgentConfigService

NewAgentConfigService creates a new agent config service

func (*AgentConfigService) Create

Create creates a new agent config with version 0

func (*AgentConfigService) CreateAlias

func (s *AgentConfigService) CreateAlias(ctx context.Context, projectID uuid.UUID, agentName string, req *CreateAliasRequest) (*AgentConfigAlias, error)

CreateAlias creates a new alias for an agent config

func (*AgentConfigService) CreateAliasByAgentID

func (s *AgentConfigService) CreateAliasByAgentID(ctx context.Context, projectID, agentID uuid.UUID, req *CreateAliasRequest) (*AgentConfigAlias, error)

CreateAliasByAgentID creates a new alias for an agent config by agent_id

func (*AgentConfigService) CreateVersion

func (s *AgentConfigService) CreateVersion(ctx context.Context, agentID uuid.UUID) (*AgentConfig, error)

CreateVersion creates a new immutable version from version 0

func (*AgentConfigService) CreateVersionByName

func (s *AgentConfigService) CreateVersionByName(ctx context.Context, projectID uuid.UUID, name string) (*AgentConfig, error)

CreateVersionByName creates a new immutable version by name (for backward compatibility)

func (*AgentConfigService) Delete

func (s *AgentConfigService) Delete(ctx context.Context, agentID uuid.UUID) error

Delete deletes all versions of an agent config by agent_id

func (*AgentConfigService) DeleteAlias

func (s *AgentConfigService) DeleteAlias(ctx context.Context, projectID, id uuid.UUID) error

DeleteAlias deletes an alias by ID

func (*AgentConfigService) DeleteByName

func (s *AgentConfigService) DeleteByName(ctx context.Context, projectID uuid.UUID, name string) error

DeleteByName deletes all versions of an agent config by name

func (*AgentConfigService) DeleteVersion

func (s *AgentConfigService) DeleteVersion(ctx context.Context, agentID uuid.UUID, version int) error

DeleteVersion deletes a specific version of an agent config

func (*AgentConfigService) GetAlias

func (s *AgentConfigService) GetAlias(ctx context.Context, projectID, id uuid.UUID) (*AgentConfigAlias, error)

GetAlias retrieves an alias by ID

func (*AgentConfigService) GetAliasByName

func (s *AgentConfigService) GetAliasByName(ctx context.Context, projectID uuid.UUID, agentName, aliasName string) (*AgentConfigAlias, error)

GetAliasByName retrieves an alias by agent name and alias name

func (*AgentConfigService) GetByAgentIDAndVersion

func (s *AgentConfigService) GetByAgentIDAndVersion(ctx context.Context, projectID uuid.UUID, agentID uuid.UUID, version int) (*AgentConfig, error)

GetByAgentIDAndVersion retrieves an agent config by agent_id and version

func (*AgentConfigService) GetByID

func (s *AgentConfigService) GetByID(ctx context.Context, projectID, id uuid.UUID) (*AgentConfig, error)

GetByID retrieves an agent config by row ID

func (*AgentConfigService) GetByNameAndVersion

func (s *AgentConfigService) GetByNameAndVersion(ctx context.Context, projectID uuid.UUID, name string, version int) (*AgentConfig, error)

GetByNameAndVersion retrieves an agent config by name and version (for backward compatibility)

func (*AgentConfigService) GetLatestByName

func (s *AgentConfigService) GetLatestByName(ctx context.Context, projectID uuid.UUID, name string) (*AgentConfig, error)

GetLatestByName retrieves version 0 (the mutable version) of an agent config by name

func (*AgentConfigService) List

func (s *AgentConfigService) List(ctx context.Context, projectID uuid.UUID) ([]*AgentConfigSummary, error)

List retrieves all agent configs for a project

func (*AgentConfigService) ListAliases

func (s *AgentConfigService) ListAliases(ctx context.Context, projectID uuid.UUID, agentName string) ([]*AgentConfigAlias, error)

ListAliases lists all aliases for an agent by name

func (*AgentConfigService) ListAliasesByAgentID

func (s *AgentConfigService) ListAliasesByAgentID(ctx context.Context, projectID, agentID uuid.UUID) ([]*AgentConfigAlias, error)

ListAliasesByAgentID lists all aliases for an agent by agent_id

func (*AgentConfigService) ListVersions

func (s *AgentConfigService) ListVersions(ctx context.Context, projectID uuid.UUID, agentID uuid.UUID) ([]*AgentConfig, error)

ListVersions retrieves all versions of an agent config by agent_id

func (*AgentConfigService) ListVersionsByName

func (s *AgentConfigService) ListVersionsByName(ctx context.Context, projectID uuid.UUID, name string) ([]*AgentConfig, error)

ListVersionsByName retrieves all versions of an agent config by name (for backward compatibility)

func (*AgentConfigService) UpdateAlias

func (s *AgentConfigService) UpdateAlias(ctx context.Context, projectID, id uuid.UUID, req *UpdateAliasRequest) (*AgentConfigAlias, error)

UpdateAlias updates an existing alias

func (*AgentConfigService) UpdateVersion0

func (s *AgentConfigService) UpdateVersion0(ctx context.Context, agentID uuid.UUID, req *UpdateAgentConfigRequest) (*AgentConfig, error)

UpdateVersion0 updates version 0 in place (mutable)

func (*AgentConfigService) UpdateVersion0ByName

func (s *AgentConfigService) UpdateVersion0ByName(ctx context.Context, projectID uuid.UUID, name string, req *UpdateAgentConfigRequest) (*AgentConfig, error)

UpdateVersion0ByName updates version 0 by name (for backward compatibility)

type AgentConfigSummary

type AgentConfigSummary struct {
	ID            uuid.UUID `json:"id" db:"id"`             // Row ID of version 0
	AgentID       uuid.UUID `json:"agent_id" db:"agent_id"` // Stable UUID per agent
	ProjectID     uuid.UUID `json:"project_id" db:"project_id"`
	Name          string    `json:"name" db:"name"`
	LatestVersion int       `json:"latest_version" db:"latest_version"`
	CreatedAt     time.Time `json:"created_at" db:"created_at"`
	UpdatedAt     time.Time `json:"updated_at" db:"updated_at"`
}

AgentConfigSummary represents a summary of an agent config for listing

type CreateAgentConfigRequest

type CreateAgentConfigRequest struct {
	Name   string          `json:"name" validate:"required,min=1,max=255"`
	Config AgentConfigData `json:"config" validate:"required"`
}

CreateAgentConfigRequest represents the request to create a new agent config

type CreateAliasRequest

type CreateAliasRequest struct {
	Name     string   `json:"name" validate:"required,min=1,max=255"`
	Version1 int      `json:"version1" validate:"required"`
	Version2 *int     `json:"version2,omitempty"`
	Weight   *float64 `json:"weight,omitempty" validate:"omitempty,min=0,max=100"`
}

CreateAliasRequest represents the request to create a new alias

type CreateVersionRequest

type CreateVersionRequest struct {
}

CreateVersionRequest represents the request to create a new immutable version from version 0

type HistoryConfig

type HistoryConfig struct {
	Enabled    bool              `json:"enabled"`
	Summarizer *SummarizerConfig `json:"summarizer,omitempty"` // Required when enabled is true
}

HistoryConfig represents conversation history configuration

type MCPServerConfig

type MCPServerConfig struct {
	Name                        string            `json:"name"`
	Endpoint                    string            `json:"endpoint"`
	Headers                     map[string]string `json:"headers,omitempty"`
	ToolFilters                 []string          `json:"tool_filters,omitempty"`                   // Tools to include (empty means all)
	ToolsRequiringHumanApproval []string          `json:"tools_requiring_human_approval,omitempty"` // Tools that need human approval
}

MCPServerConfig represents an MCP server configuration with tool filters

type ModelConfig

type ModelConfig struct {
	ProviderType string                 `json:"provider_type"`        // e.g., "OpenAI", "Anthropic", "Gemini", "xAI"
	ModelID      string                 `json:"model_id"`             // e.g., "gpt-4.1", "gpt-4o"
	Parameters   map[string]interface{} `json:"parameters,omitempty"` // Model parameters like temperature, max_tokens
}

ModelConfig represents model configuration embedded in agent config

type PromptConfig

type PromptConfig struct {
	// Use either RawPrompt OR (PromptID + Label), not both
	RawPrompt *string    `json:"raw_prompt,omitempty"` // Raw prompt text
	PromptID  *uuid.UUID `json:"prompt_id,omitempty"`  // Reference to a prompt
	Version   *int       `json:"version,omitempty"`
}

PromptConfig represents prompt configuration - either raw text or a reference to a prompt version

type SchemaConfig

type SchemaConfig struct {
	Name          string            `json:"name"`
	Description   *string           `json:"description,omitempty"`
	Schema        *utils.RawMessage `json:"schema,omitempty"`      // JSON Schema definition
	SourceType    *string           `json:"source_type,omitempty"` // "manual", "go_struct", "typescript"
	SourceContent *string           `json:"source_content,omitempty"`
}

SchemaConfig represents output schema configuration

type SummarizerConfig

type SummarizerConfig struct {
	Type                   string        `json:"type"`                                // "llm", "sliding_window", or "none"
	LLMTokenThreshold      *int          `json:"llm_token_threshold,omitempty"`       // For "llm" type
	LLMKeepRecentCount     *int          `json:"llm_keep_recent_count,omitempty"`     // For "llm" type
	LLMSummarizerPrompt    *PromptConfig `json:"llm_summarizer_prompt,omitempty"`     // For "llm" type
	LLMSummarizerModel     *ModelConfig  `json:"llm_summarizer_model,omitempty"`      // For "llm" type
	SlidingWindowKeepCount *int          `json:"sliding_window_keep_count,omitempty"` // For "sliding_window" type
}

SummarizerConfig represents conversation summarization configuration

type UpdateAgentConfigRequest

type UpdateAgentConfigRequest struct {
	Config AgentConfigData `json:"config" validate:"required"`
}

UpdateAgentConfigRequest represents the request to update version 0 (mutable) or create a new version

type UpdateAliasRequest

type UpdateAliasRequest struct {
	Name     string   `json:"name,omitempty" validate:"omitempty,min=1,max=255"`
	Version1 *int     `json:"version1,omitempty"`
	Version2 *int     `json:"version2,omitempty"`
	Weight   *float64 `json:"weight,omitempty" validate:"omitempty,min=0,max=100"`
}

UpdateAliasRequest represents the request to update an existing alias

Jump to

Keyboard shortcuts

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