Documentation
¶
Overview ¶
Package agent defines the core agent interface and types
Package agent contains mock implementations for testing
Index ¶
- type Agent
- type Event
- type EventType
- type Metrics
- type MockAgent
- func (m *MockAgent) CurrentTask() string
- func (m *MockAgent) Directory() string
- func (m *MockAgent) ID() string
- func (m *MockAgent) IsBackground() bool
- func (m *MockAgent) LastActivity() time.Time
- func (m *MockAgent) LastError() error
- func (m *MockAgent) Metrics() Metrics
- func (m *MockAgent) Name() string
- func (m *MockAgent) Output() io.Reader
- func (m *MockAgent) ParentID() string
- func (m *MockAgent) Pause() error
- func (m *MockAgent) ProjectID() string
- func (m *MockAgent) Refresh() error
- func (m *MockAgent) Resume() error
- func (m *MockAgent) SendInput(input string) error
- func (m *MockAgent) StartTime() time.Time
- func (m *MockAgent) Status() Status
- func (m *MockAgent) Terminate() error
- func (m *MockAgent) Type() string
- type MockProvider
- func (p *MockProvider) AddAgent(agent Agent)
- func (p *MockProvider) Close()
- func (p *MockProvider) Discover(ctx context.Context) ([]Agent, error)
- func (p *MockProvider) SendEvent(event Event)
- func (p *MockProvider) Spawn(ctx context.Context, config SpawnConfig) (Agent, error)
- func (p *MockProvider) Type() string
- func (p *MockProvider) Watch(ctx context.Context) (<-chan Event, error)
- type Provider
- type Registry
- type SpawnConfig
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent interface {
// Identity
ID() string
Name() string
Type() string // "opencode", "claude", etc.
// Location
Directory() string
ProjectID() string
// Hierarchy
ParentID() string
IsBackground() bool
// Status
Status() Status
StartTime() time.Time
LastActivity() time.Time
// Session data
Output() io.Reader // Stream of output
CurrentTask() string // What the agent is working on
Metrics() Metrics // Performance metrics
LastError() error // Last error if any
// Control
SendInput(input string) error
Terminate() error
Pause() error
Resume() error
}
Agent represents a single AI agent instance
type Event ¶
type Event struct {
Type EventType
AgentID string
Agent Agent
Timestamp time.Time
Data interface{}
Error error
}
Event represents an agent lifecycle event
type Metrics ¶
type Metrics struct {
TokensIn int64 `json:"tokens_in"`
TokensOut int64 `json:"tokens_out"`
EstimatedCost float64 `json:"estimated_cost"`
Duration time.Duration `json:"duration"`
ActiveTime time.Duration `json:"active_time"`
IdleTime time.Duration `json:"idle_time"`
ToolCalls int `json:"tool_calls"`
ErrorCount int `json:"error_count"`
TasksCompleted int `json:"tasks_completed"`
TasksFailed int `json:"tasks_failed"`
ContextUtilization float64 `json:"context_utilization"` // 0.0 - 1.0
}
Metrics holds agent performance metrics
type MockAgent ¶
type MockAgent struct {
MockID string
MockName string
MockType string
MockStatus Status
MockDirectory string
MockProjectID string
MockParentID string
MockCurrentTask string
MockStartTime time.Time
MockLastActivity time.Time
MockMetrics Metrics
MockLastError error
MockOutput []byte
TerminateCalled bool
SendInputCalled bool
LastInput string
}
MockAgent implements Agent interface for testing
func NewMockAgent ¶
NewMockAgent creates a new mock agent with default values
func (*MockAgent) CurrentTask ¶
func (*MockAgent) IsBackground ¶
func (*MockAgent) LastActivity ¶
type MockProvider ¶
MockProvider implements Provider interface for testing
func NewMockProvider ¶
func NewMockProvider() *MockProvider
NewMockProvider creates a new mock provider
func (*MockProvider) AddAgent ¶
func (p *MockProvider) AddAgent(agent Agent)
AddAgent adds an agent to the mock provider
func (*MockProvider) Discover ¶
func (p *MockProvider) Discover(ctx context.Context) ([]Agent, error)
func (*MockProvider) SendEvent ¶
func (p *MockProvider) SendEvent(event Event)
SendEvent sends a mock event
func (*MockProvider) Spawn ¶
func (p *MockProvider) Spawn(ctx context.Context, config SpawnConfig) (Agent, error)
func (*MockProvider) Type ¶
func (p *MockProvider) Type() string
type Provider ¶
type Provider interface {
// Identity
Name() string
Type() string
// Discovery
Discover(ctx context.Context) ([]Agent, error)
Watch(ctx context.Context) (<-chan Event, error)
// Control
Spawn(ctx context.Context, config SpawnConfig) (Agent, error)
Get(id string) (Agent, error)
List() []Agent
Terminate(id string) error
SendInput(id string, input string) error
}
Provider discovers and manages agents of a specific type
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages multiple agent providers
func (*Registry) DiscoverAll ¶
DiscoverAll discovers agents from all providers
type SpawnConfig ¶
type SpawnConfig struct {
Type string `json:"type"`
Name string `json:"name"`
Directory string `json:"directory"`
Prompt string `json:"prompt"`
Env map[string]string `json:"env"`
}
SpawnConfig holds configuration for spawning a new agent