Documentation
¶
Overview ¶
Package agent provides a Go harness for building model-backed agents, registering tools, managing memory, and composing teams and workflows.
Start with New and Harness.NewAgent for the common path. The model, memory, tool, engine, orchestrator, security, and types subpackages expose extension points for applications that need custom implementations.
Index ¶
- Constants
- func ResolveModelDefaults(cfg *ModelConfig)
- type Agent
- type AgentConfig
- type ConditionNode
- type Config
- type Harness
- func (h *Harness) AllowPermissions(permissions ...security.Permission)
- func (h *Harness) CheckPermission(perm security.Permission) error
- func (h *Harness) Close() error
- func (h *Harness) DenyPermissions(permissions ...security.Permission)
- func (h *Harness) InitMCPClients(ctx context.Context) error
- func (h *Harness) NewAgent(name, systemPrompt string) *engine.Agent
- func (h *Harness) NewTeam(cfg orchestrator.TeamConfig) *orchestrator.Team
- func (h *Harness) NewWorkflow(cfg orchestrator.WorkflowConfig) *orchestrator.Workflow
- func (h *Harness) RegisterTeam(team *orchestrator.Team) error
- func (h *Harness) RegisterTool(t tool.Tool) error
- func (h *Harness) RegisterWorkflow(workflow *orchestrator.Workflow) error
- func (h *Harness) RunAgent(ctx context.Context, name, input string, opts ...engine.RunOption) *engine.RunOutput
- func (h *Harness) RunTeam(ctx context.Context, name, input string) *orchestrator.TeamOutput
- func (h *Harness) RunWorkflow(ctx context.Context, name, input string) *orchestrator.WorkflowResult
- func (h *Harness) Sanitize(input string) string
- func (h *Harness) ValidateInput(input string) error
- func (h *Harness) ValidateOutput(output string) error
- type LoopNode
- type MCPClientConfig
- type MemoryConfig
- type ModelConfig
- type Node
- type NodeType
- type ParallelNode
- type Permission
- type RunOption
- type RunOutput
- type SecurityConfig
- type StepLog
- type StepNode
- type Team
- type TeamConfig
- type TeamMode
- type TeamOutput
- type Workflow
- type WorkflowConfig
- type WorkflowResult
Constants ¶
const ( ModeSequential = orchestrator.ModeSequential ModeParallel = orchestrator.ModeParallel ModeLeaderFollower = orchestrator.ModeLeaderFollower )
const ( PermReadFile = security.PermReadFile PermWriteFile = security.PermWriteFile PermExec = security.PermExec PermNetAccess = security.PermNetAccess PermReadDB = security.PermReadDB PermWriteDB = security.PermWriteDB PermSendEmail = security.PermSendEmail )
const ( NodeTypeStep = orchestrator.NodeTypeStep NodeTypeCondition = orchestrator.NodeTypeCondition NodeTypeLoop = orchestrator.NodeTypeLoop NodeTypeParallel = orchestrator.NodeTypeParallel )
Variables ¶
This section is empty.
Functions ¶
func ResolveModelDefaults ¶
func ResolveModelDefaults(cfg *ModelConfig)
ResolveModelDefaults normalizes vendor/api_format and timeout. BaseURL is never inferred from vendor ? configure it explicitly (vendor and api_format are independent).
Types ¶
type Agent ¶
Agent is the runtime agent implementation exposed by the root package.
func NewAgent ¶
func NewAgent(cfg AgentConfig) *Agent
NewAgent creates a standalone Agent. Most applications can instead use Harness.NewAgent, which shares the Harness model and tool registry.
type Config ¶
type Config struct {
Version string `json:"version"`
Name string `json:"name"`
LogLevel string `json:"log_level"`
DefaultModel ModelConfig `json:"default_model"`
AllowedTools []string `json:"allowed_tools"`
MemoryConfig MemoryConfig `json:"memory"`
PermissionMode string `json:"permission_mode"` // strict, permissive
MCPClients []MCPClientConfig `json:"mcp_clients,omitempty"`
Security SecurityConfig `json:"security"`
}
func DefaultConfig ¶
func DefaultConfig() Config
func LoadConfig ¶
type Harness ¶
type Harness struct {
Config Config
Model model.Model
ToolRegistry *tool.Registry
Memory memory.Memory
PermissionMgr *security.PermissionManager
InputValidator *security.InputValidator
OutputValidator *security.OutputValidator
Sanitizer *security.Sanitizer
Agents map[string]*engine.Agent
Teams map[string]*orchestrator.Team
Workflows map[string]*orchestrator.Workflow
// contains filtered or unexported fields
}
func (*Harness) AllowPermissions ¶
func (h *Harness) AllowPermissions(permissions ...security.Permission)
func (*Harness) CheckPermission ¶
func (h *Harness) CheckPermission(perm security.Permission) error
func (*Harness) DenyPermissions ¶
func (h *Harness) DenyPermissions(permissions ...security.Permission)
func (*Harness) NewTeam ¶
func (h *Harness) NewTeam(cfg orchestrator.TeamConfig) *orchestrator.Team
func (*Harness) NewWorkflow ¶
func (h *Harness) NewWorkflow(cfg orchestrator.WorkflowConfig) *orchestrator.Workflow
func (*Harness) RegisterTeam ¶
func (h *Harness) RegisterTeam(team *orchestrator.Team) error
func (*Harness) RegisterWorkflow ¶
func (h *Harness) RegisterWorkflow(workflow *orchestrator.Workflow) error
func (*Harness) RunTeam ¶
func (h *Harness) RunTeam(ctx context.Context, name, input string) *orchestrator.TeamOutput
func (*Harness) RunWorkflow ¶
func (h *Harness) RunWorkflow(ctx context.Context, name, input string) *orchestrator.WorkflowResult
func (*Harness) ValidateInput ¶
func (*Harness) ValidateOutput ¶
type LoopNode ¶
type LoopNode = orchestrator.LoopNode
type MCPClientConfig ¶
type MemoryConfig ¶
type ModelConfig ¶
type ModelConfig struct {
Vendor string `json:"vendor"` // deepseek / openai / anthropic / custom (logging / identity)
APIFormat string `json:"api_format"` // openai_response / openai_chat_completions / anthropic_message / mock
BaseURL string `json:"base_url,omitempty"`
APIKey string `json:"api_key,omitempty"`
ModelID string `json:"model_id"`
Timeout int `json:"timeout_seconds"`
}
ModelConfig describes which vendor and API protocol to use. Vendor and APIFormat are independent: BuildModel selects the client by APIFormat only; BaseURL/APIKey/ModelID come from config as-is.
func (ModelConfig) BuildModel ¶
func (c ModelConfig) BuildModel() (model.Model, error)
type Node ¶
type Node = orchestrator.Node
type NodeType ¶
type NodeType = orchestrator.NodeType
type ParallelNode ¶
type ParallelNode = orchestrator.ParallelNode
func NewParallelNode ¶
func NewParallelNode(id string, nodes ...Node) *ParallelNode
type Permission ¶
type Permission = security.Permission
type RunOption ¶
RunOption customizes an individual Agent run.
func WithMaxLoops ¶
func WithMaxTokens ¶
func WithStream ¶
func WithTemperature ¶
type SecurityConfig ¶
type StepLog ¶
type StepLog = orchestrator.StepLog
type StepNode ¶
type StepNode = orchestrator.StepNode
type TeamConfig ¶
type TeamConfig = orchestrator.TeamConfig
type TeamMode ¶
type TeamMode = orchestrator.TeamMode
type TeamOutput ¶
type TeamOutput = orchestrator.TeamOutput
type Workflow ¶
type Workflow = orchestrator.Workflow
func NewWorkflow ¶
func NewWorkflow(cfg WorkflowConfig) *Workflow
type WorkflowConfig ¶
type WorkflowConfig = orchestrator.WorkflowConfig
type WorkflowResult ¶
type WorkflowResult = orchestrator.WorkflowResult