agent

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AutoCompactionThreshold = 0.95
)
View Source
const (
	TaskToolName = "task"
)

Variables

View Source
var (
	ErrRequestCancelled = errors.New("request cancelled by user")
	ErrSessionBusy      = errors.New("session is currently processing another request")

	//go:embed prompts/*.md
	AgentPrompts embed.FS
)

Common errors

Functions

func NewAgentTool

func NewAgentTool(
	sessions session.Service,
	messages message.Service,
	lspClients map[string]*lsp.Client,
	permissions permission.Service,
	history history.Service,
	reg agentregistry.Registry,
	mcpReg MCPRegistry,
) tools.BaseTool

func NewToolSet

func NewToolSet(
	ctx context.Context,
	info *agentregistry.AgentInfo,
	reg agentregistry.Registry,
	permissions permission.Service,
	historyService history.Service,
	lspClients map[string]*lsp.Client,
	sessions session.Service,
	messages message.Service,
	mcpRegistry MCPRegistry,
) <-chan tools.BaseTool

NewToolSet dynamically builds the tool slice for an agent based on its registry info. Only tools that pass registry.IsToolEnabled are included.

Types

type AgentEvent

type AgentEvent struct {
	Type    AgentEventType
	Message message.Message
	Error   error

	// When summarizing
	SessionID string
	Progress  string
	Done      bool
}

type AgentEventType

type AgentEventType string
const (
	AgentEventTypeError     AgentEventType = "error"
	AgentEventTypeResponse  AgentEventType = "response"
	AgentEventTypeSummarize AgentEventType = "summarize"
)

type AgentParams deprecated

type AgentParams = TaskParams

Deprecated: use TaskParams instead

type MCPClient

type MCPClient interface {
	Initialize(
		ctx context.Context,
		request mcp.InitializeRequest,
	) (*mcp.InitializeResult, error)
	ListTools(ctx context.Context, request mcp.ListToolsRequest) (*mcp.ListToolsResult, error)
	CallTool(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)
	Close() error
}

type MCPRegistry

type MCPRegistry interface {
	// GetTools return tools matching filter, if registry is not loaded it will begin loading
	LoadTools(ctx context.Context, filter *MCPRegistryFiler) <-chan tools.BaseTool
	// StartClient starts a new MCPClient, caller have to properly close when done
	StartClient(ctx context.Context, name string) (c *client.Client, err error)
}

func NewMCPRegistry

func NewMCPRegistry(permissions permission.Service, agentRegistry agentregistry.Registry) MCPRegistry

type MCPRegistryFiler

type MCPRegistryFiler struct {
	ToolNames   []string
	ServerNames []string
}

type Service

type Service interface {
	pubsub.Suscriber[AgentEvent]
	AgentID() config.AgentName
	Model() models.Model
	Run(ctx context.Context, sessionID string, content string, attachments ...message.Attachment) (<-chan AgentEvent, error)
	Cancel(sessionID string)
	IsSessionBusy(sessionID string) bool
	IsBusy() bool
	Update(agentName config.AgentName, modelID models.ModelID) (models.Model, error)
	Summarize(ctx context.Context, sessionID string) error
}

func NewAgent

func NewAgent(
	ctx context.Context,
	agentInfo *agentregistry.AgentInfo,
	sessions session.Service,
	messages message.Service,
	permissions permission.Service,
	historyService history.Service,
	lspClients map[string]*lsp.Client,
	reg agentregistry.Registry,
	mcpReg MCPRegistry,
) (Service, error)

type TaskParams

type TaskParams struct {
	Prompt       string `json:"prompt"`
	SubagentType string `json:"subagent_type"`
	TaskID       string `json:"task_id,omitempty"`
	TaskTitle    string `json:"task_title,omitempty"`
}

Jump to

Keyboard shortcuts

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