Documentation
¶
Index ¶
- Constants
- Variables
- func CoderAgentTools(permissions permission.Service, sessions session.Service, ...) []tools.BaseTool
- func CoderAgentToolsWithMesnada(mesnadaOrchestrator *orchestrator.Orchestrator, ...) []tools.BaseTool
- func GetActivePersona() string
- func GetMcpTools(ctx context.Context, permissions permission.Service) []tools.BaseTool
- func GetMcpToolsWithGateway(ctx context.Context, permissions permission.Service, gw *mcpgateway.Gateway) []tools.BaseTool
- func GetPersonaManager() *persona.Manager
- func ListAvailablePersonas() []string
- func NewAgentTool(Sessions session.Service, Messages message.Service, ...) tools.BaseTool
- func NewMcpTool(name string, tool mcp.Tool, permissions permission.Service, ...) tools.BaseTool
- func SetActivePersona(name string) error
- func SetContextEnricher(e ContextEnricher)
- func SetLuaManager(fm *luaengine.FilterManager)
- func SetPersonaManager(mgr *persona.Manager)
- func SetPersonaSelector(ps *PersonaSelector)
- func TaskAgentTools(lspClients map[string]*lsp.Client) []tools.BaseTool
- type AgentEvent
- type AgentEventType
- type AgentParams
- type ContextEnricher
- type MCPClient
- type PersonaSelector
- type Service
Constants ¶
const (
AgentToolName = "agent"
)
Variables ¶
var ( ErrRequestCancelled = errors.New("request cancelled by user") ErrSessionBusy = errors.New("session is currently processing another request") )
Common errors
var ErrNoModel = fmt.Errorf("no model configured, please select a model")
ErrNoModel is returned when the agent has no model configured.
Functions ¶
func CoderAgentTools ¶
func CoderAgentToolsWithMesnada ¶
func CoderAgentToolsWithMesnada( mesnadaOrchestrator *orchestrator.Orchestrator, remembrances *rag.RemembrancesService, gateway *mcpgateway.Gateway, permissions permission.Service, sessions session.Service, messages message.Service, history history.Service, lspClients map[string]*lsp.Client, skillManager *skills.SkillManager, ) []tools.BaseTool
func GetActivePersona ¶ added in v0.200.0
func GetActivePersona() string
GetActivePersona returns the currently active persona name. An empty string means no persona is active (auto-select or none).
func GetMcpTools ¶
func GetMcpToolsWithGateway ¶ added in v0.8.0
func GetMcpToolsWithGateway(ctx context.Context, permissions permission.Service, gw *mcpgateway.Gateway) []tools.BaseTool
GetMcpToolsWithGateway returns MCP-backed tools for the LLM agent. When gw is non-nil (gateway mode), it exposes two proxy tools plus any favorite tools as direct wrappers. When gw is nil it falls back to the standard per-server tool list.
func GetPersonaManager ¶ added in v0.200.0
GetPersonaManager returns the global persona manager, or nil if not initialised.
func ListAvailablePersonas ¶ added in v0.200.0
func ListAvailablePersonas() []string
ListAvailablePersonas returns the names of all loaded personas. Uses the global persona manager when available; falls back to the selector's manager.
func NewAgentTool ¶
func NewMcpTool ¶
func SetActivePersona ¶ added in v0.200.0
SetActivePersona sets the active persona by name. Pass an empty string to clear the active persona (revert to auto-select or none). Returns an error if the named persona does not exist (and name is non-empty).
func SetContextEnricher ¶ added in v0.236.1
func SetContextEnricher(e ContextEnricher)
SetContextEnricher sets the context enricher used to prepend KB/code context to user messages. Pass nil to disable context enrichment.
func SetLuaManager ¶ added in v0.8.0
func SetLuaManager(fm *luaengine.FilterManager)
SetLuaManager sets the global Lua filter manager used for MCP tool input/output filtering.
func SetPersonaManager ¶ added in v0.200.0
SetPersonaManager sets the global persona manager used for persona listing and manual persona selection. This should be called during app initialisation.
func SetPersonaSelector ¶ added in v0.41.0
func SetPersonaSelector(ps *PersonaSelector)
SetPersonaSelector sets the global persona selector used in the main conversation agent.
Types ¶
type AgentEvent ¶
type AgentEvent struct {
Type AgentEventType
Message message.Message
Error error
Delta string
ToolCall *message.ToolCall
ToolResult *message.ToolResult
// When summarizing
SessionID string
Progress string
Done bool
// Todos is populated when Type == AgentEventTypeTodosUpdated.
Todos []tools.TodoItem
}
type AgentEventType ¶
type AgentEventType string
const ( AgentEventTypeError AgentEventType = "error" AgentEventTypeResponse AgentEventType = "response" AgentEventTypeSummarize AgentEventType = "summarize" AgentEventTypeContentDelta AgentEventType = "content_delta" AgentEventTypeThinkingDelta AgentEventType = "thinking_delta" AgentEventTypeToolCall AgentEventType = "tool_call" AgentEventTypeToolResult AgentEventType = "tool_result" // AgentEventTypeTodosUpdated is emitted when the TodoWrite tool runs successfully. // It carries the current todo list for non-ACP consumers (TUI, WebUI). AgentEventTypeTodosUpdated AgentEventType = "todos_updated" )
type AgentParams ¶
type AgentParams struct {
Prompt string `json:"prompt"`
}
type ContextEnricher ¶ added in v0.236.1
ContextEnricher is the interface used by the agent to enrich the user's prompt with context retrieved from the KB and code index before sending it to the LLM. A local interface is used to avoid import cycles between agent and rag packages.
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 PersonaSelector ¶ added in v0.41.0
type PersonaSelector struct {
// contains filtered or unexported fields
}
PersonaSelector automatically selects and applies a persona for each user prompt. It uses a lite LLM provider (configured via agents["persona-selector"]) to pick the best matching persona from the personas directory, then prepends its content to the user message before it reaches the main conversation model.
func NewPersonaSelector ¶ added in v0.41.0
func NewPersonaSelector(personaPath string) (*PersonaSelector, error)
NewPersonaSelector creates a PersonaSelector that loads personas from personaPath and uses the model configured under agents["persona-selector"] to perform selection. Returns an error if the persona-selector agent is not configured or the model is unavailable.
func (*PersonaSelector) SelectAndApply ¶ added in v0.41.0
func (ps *PersonaSelector) SelectAndApply(ctx context.Context, userPrompt string) string
SelectAndApply selects the best persona for userPrompt and returns the prompt with the persona content prepended. Kept for backward compatibility; prefer SelectPersonaContent when the content will be injected into the system prompt.
func (*PersonaSelector) SelectPersonaContent ¶ added in v0.265.0
func (ps *PersonaSelector) SelectPersonaContent(ctx context.Context, userPrompt string) string
SelectPersonaContent selects the best persona for userPrompt and returns its raw content (the persona instructions). Returns an empty string if no persona matches, the selector is disabled, or an error occurs. The content is intended to be injected into the system prompt rather than prepended to the user message.
type Service ¶
type Service interface {
pubsub.Suscriber[AgentEvent]
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
SetLuaManager(fm *luaengine.FilterManager)
// GetTools returns the tools available to this agent instance.
GetTools() []tools.BaseTool
}