agent

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 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 Agent

type Agent struct {
	ID                           uuid.UUID  `json:"id" db:"id"`
	ProjectID                    uuid.UUID  `json:"project_id" db:"project_id"`
	Name                         string     `json:"name" db:"name"`
	ModelID                      uuid.UUID  `json:"model_id" db:"model_id"`
	PromptID                     uuid.UUID  `json:"prompt_id" db:"prompt_id"`
	PromptLabel                  *string    `json:"prompt_label,omitempty" db:"prompt_label"`
	SchemaID                     *uuid.UUID `json:"schema_id,omitempty" db:"schema_id"`
	EnableHistory                bool       `json:"enable_history" db:"enable_history"`
	SummarizerType               *string    `json:"summarizer_type,omitempty" db:"summarizer_type"` // "llm" or "sliding_window"
	LLMSummarizerTokenThreshold  *int       `json:"llm_summarizer_token_threshold,omitempty" db:"llm_summarizer_token_threshold"`
	LLMSummarizerKeepRecentCount *int       `json:"llm_summarizer_keep_recent_count,omitempty" db:"llm_summarizer_keep_recent_count"`
	LLMSummarizerPromptID        *uuid.UUID `json:"llm_summarizer_prompt_id,omitempty" db:"llm_summarizer_prompt_id"`
	LLMSummarizerPromptLabel     *string    `json:"llm_summarizer_prompt_label,omitempty" db:"llm_summarizer_prompt_label"`
	LLMSummarizerModelID         *uuid.UUID `json:"llm_summarizer_model_id,omitempty" db:"llm_summarizer_model_id"`
	SlidingWindowKeepCount       *int       `json:"sliding_window_keep_count,omitempty" db:"sliding_window_keep_count"`
	CreatedAt                    time.Time  `json:"created_at" db:"created_at"`
	UpdatedAt                    time.Time  `json:"updated_at" db:"updated_at"`
}

Agent represents an agent configuration

type AgentMCPServer

type AgentMCPServer struct {
	AgentID     uuid.UUID   `json:"agent_id" db:"agent_id"`
	MCPServerID uuid.UUID   `json:"mcp_server_id" db:"mcp_server_id"`
	ToolFilters ToolFilters `json:"tool_filters" db:"tool_filters"`
}

AgentMCPServer represents the relationship between an agent and an MCP server with tool filters

type AgentMCPServerDetail

type AgentMCPServerDetail struct {
	AgentMCPServer
	MCPServerName string `json:"mcp_server_name" db:"mcp_server_name"`
}

AgentMCPServerDetail includes MCP server information

type AgentMCPServerReq

type AgentMCPServerReq struct {
	MCPServerID uuid.UUID   `json:"mcp_server_id" validate:"required"`
	ToolFilters ToolFilters `json:"tool_filters,omitempty"`
}

AgentMCPServerReq represents MCP server configuration in a request

type AgentRepo

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

AgentRepo handles database operations for agents

func NewAgentRepo

func NewAgentRepo(db *sqlx.DB) *AgentRepo

NewAgentRepo creates a new agent repository

func (*AgentRepo) Create

func (r *AgentRepo) Create(ctx context.Context, projectID uuid.UUID, req *CreateAgentRequest) (*Agent, error)

Create creates a new agent

func (*AgentRepo) Delete

func (r *AgentRepo) Delete(ctx context.Context, projectID, id uuid.UUID) error

Delete deletes an agent

func (*AgentRepo) GetByID

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

GetByID retrieves an agent by ID with all related information

func (*AgentRepo) GetByName

func (r *AgentRepo) GetByName(ctx context.Context, projectID uuid.UUID, name string) (*AgentWithDetails, error)

GetByName retrieves an agent by name

func (*AgentRepo) List

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

List retrieves all agents with optional filtering

func (*AgentRepo) Update

func (r *AgentRepo) Update(ctx context.Context, projectID, id uuid.UUID, req *UpdateAgentRequest) (*Agent, error)

Update updates an agent

type AgentService

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

AgentService handles business logic for agents

func NewAgentService

func NewAgentService(repo *AgentRepo) *AgentService

NewAgentService creates a new agent service

func (*AgentService) Create

func (s *AgentService) Create(ctx context.Context, projectID uuid.UUID, req *CreateAgentRequest) (*Agent, error)

Create creates a new agent

func (*AgentService) Delete

func (s *AgentService) Delete(ctx context.Context, projectID, id uuid.UUID) error

Delete deletes an agent

func (*AgentService) GetByID

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

GetByID retrieves an agent by ID

func (*AgentService) GetByName

func (s *AgentService) GetByName(ctx context.Context, projectID uuid.UUID, name string) (*AgentWithDetails, error)

GetByName retrieves an agent by name

func (*AgentService) List

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

List retrieves all agents

func (*AgentService) Update

func (s *AgentService) Update(ctx context.Context, projectID, id uuid.UUID, req *UpdateAgentRequest) (*Agent, error)

Update updates an agent

type AgentWithDetails

type AgentWithDetails struct {
	Agent
	ModelName         string                  `json:"model_name" db:"model_name"`
	ModelProviderType *string                 `json:"model_provider_type,omitempty" db:"model_provider_type"`
	ModelModelID      *string                 `json:"model_model_id,omitempty" db:"model_model_id"`
	ModelParameters   *utils.RawMessage       `json:"model_parameters,omitempty" db:"model_parameters"`
	PromptName        string                  `json:"prompt_name" db:"prompt_name"`
	SchemaName        *string                 `json:"schema_name,omitempty" db:"schema_name"`
	SchemaData        *utils.RawMessage       `json:"schema_data,omitempty" db:"schema_data"`
	MCPServers        []*AgentMCPServerDetail `json:"mcp_servers"`
	// Summarizer model and provider fields (nullable, only populated when summarizer_type is 'llm')
	SummarizerPromptName            *string           `json:"summarizer_prompt_name,omitempty" db:"summarizer_prompt_name"`
	SummarizerModelModelID          *string           `json:"summarizer_model_model_id,omitempty" db:"summarizer_model_model_id"`
	SummarizerModelParameters       *utils.RawMessage `json:"summarizer_model_parameters,omitempty" db:"summarizer_model_parameters"`
	SummarizerProviderID            *uuid.UUID        `json:"summarizer_provider_id,omitempty" db:"summarizer_provider_id"`
	SummarizerProviderType          *string           `json:"summarizer_provider_type,omitempty" db:"summarizer_provider_type"`
	SummarizerProviderAPIKey        *string           `json:"summarizer_provider_api_key,omitempty" db:"summarizer_provider_api_key"`
	SummarizerProviderBaseURL       *string           `json:"summarizer_provider_base_url,omitempty" db:"summarizer_provider_base_url"`
	SummarizerProviderCustomHeaders *utils.RawMessage `json:"summarizer_provider_custom_headers,omitempty" db:"summarizer_provider_custom_headers"`
}

AgentWithDetails includes related information

type CreateAgentRequest

type CreateAgentRequest struct {
	Name                         string              `json:"name" validate:"required,min=1,max=255"`
	ModelID                      uuid.UUID           `json:"model_id" validate:"required"`
	PromptID                     uuid.UUID           `json:"prompt_id" validate:"required"`
	PromptLabel                  *string             `json:"prompt_label,omitempty" validate:"omitempty,oneof=production latest"`
	SchemaID                     *uuid.UUID          `json:"schema_id,omitempty"`
	EnableHistory                bool                `json:"enable_history"`
	SummarizerType               *string             `json:"summarizer_type,omitempty" validate:"omitempty,oneof=llm sliding_window none"`
	LLMSummarizerTokenThreshold  *int                `json:"llm_summarizer_token_threshold,omitempty"`
	LLMSummarizerKeepRecentCount *int                `json:"llm_summarizer_keep_recent_count,omitempty"`
	LLMSummarizerPromptID        *uuid.UUID          `json:"llm_summarizer_prompt_id,omitempty"`
	LLMSummarizerPromptLabel     *string             `json:"llm_summarizer_prompt_label,omitempty" validate:"omitempty,oneof=production latest"`
	LLMSummarizerModelID         *uuid.UUID          `json:"llm_summarizer_model_id,omitempty"`
	SlidingWindowKeepCount       *int                `json:"sliding_window_keep_count,omitempty"`
	MCPServers                   []AgentMCPServerReq `json:"mcp_servers" validate:"omitempty"`
}

CreateAgentRequest represents the request to create a new agent

type ToolFilters

type ToolFilters []string

ToolFilters represents a list of tool names to filter from an MCP server

func (ToolFilters) MarshalJSON

func (t ToolFilters) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*ToolFilters) Scan

func (t *ToolFilters) Scan(value interface{}) error

Scan implements the sql.Scanner interface for database/sql

func (*ToolFilters) UnmarshalJSON

func (t *ToolFilters) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

func (ToolFilters) Value

func (t ToolFilters) Value() (driver.Value, error)

Value implements the driver.Valuer interface for database/sql

type UpdateAgentRequest

type UpdateAgentRequest struct {
	Name                         *string              `json:"name,omitempty" validate:"omitempty,min=1,max=255"`
	ModelID                      *uuid.UUID           `json:"model_id,omitempty"`
	PromptID                     *uuid.UUID           `json:"prompt_id,omitempty"`
	PromptLabel                  *string              `json:"prompt_label,omitempty" validate:"omitempty,oneof=production latest"`
	SchemaID                     *uuid.UUID           `json:"schema_id,omitempty"`
	ClearSchemaID                bool                 `json:"clear_schema_id,omitempty"`
	EnableHistory                *bool                `json:"enable_history,omitempty"`
	SummarizerType               *string              `json:"summarizer_type,omitempty" validate:"omitempty,oneof=llm sliding_window"`
	LLMSummarizerTokenThreshold  *int                 `json:"llm_summarizer_token_threshold,omitempty"`
	LLMSummarizerKeepRecentCount *int                 `json:"llm_summarizer_keep_recent_count,omitempty"`
	LLMSummarizerPromptID        *uuid.UUID           `json:"llm_summarizer_prompt_id,omitempty"`
	LLMSummarizerPromptLabel     *string              `json:"llm_summarizer_prompt_label,omitempty" validate:"omitempty,oneof=production latest"`
	LLMSummarizerModelID         *uuid.UUID           `json:"llm_summarizer_model_id,omitempty"`
	SlidingWindowKeepCount       *int                 `json:"sliding_window_keep_count,omitempty"`
	MCPServers                   *[]AgentMCPServerReq `json:"mcp_servers,omitempty"`
}

UpdateAgentRequest represents the request to update an agent

Jump to

Keyboard shortcuts

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