Documentation
¶
Index ¶
- type Agent
- type AgentBoot
- func (ab *AgentBoot) GetAgent(agentType AgentType) (Agent, error)
- func (ab *AgentBoot) GetConfig() Config
- func (ab *AgentBoot) GetDefaultAgent() (Agent, error)
- func (ab *AgentBoot) ListAgents() []AgentType
- func (ab *AgentBoot) MustGetAgent(agentType AgentType) Agent
- func (ab *AgentBoot) RegisterAgent(agentType AgentType, agent Agent)
- func (ab *AgentBoot) SetDefaultAgent(agentType AgentType) error
- type AgentType
- type CompletionResult
- type Config
- type Event
- type ExecutionOptions
- type MessageHandler
- type OutputFormat
- type PermissionConfig
- type PermissionMode
- type PermissionRequest
- type PermissionResponse
- type PermissionResult
- type Result
- func (r *Result) GetAssistantMessages() []Event
- func (r *Result) GetCostUSD() float64
- func (r *Result) GetMessageChain() []Event
- func (r *Result) GetMessagesByType(messageType string) []Event
- func (r *Result) GetSessionID() string
- func (r *Result) GetStatus() string
- func (r *Result) GetToolResultMessages() []Event
- func (r *Result) GetToolUseMessages() []Event
- func (r *Result) GetUserMessages() []Event
- func (r *Result) IsSuccess() bool
- func (r *Result) TextOutput() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent interface {
// Execute runs the agent with the given prompt
Execute(ctx context.Context, prompt string, opts ExecutionOptions) (*Result, error)
// IsAvailable checks if the agent is available
IsAvailable() bool
// Type returns the agent type
Type() AgentType
// SetDefaultFormat sets the default output format
SetDefaultFormat(format OutputFormat)
// GetDefaultFormat returns the current default format
GetDefaultFormat() OutputFormat
}
Agent is the interface for all agent types
type AgentBoot ¶
type AgentBoot struct {
// contains filtered or unexported fields
}
AgentBoot manages agent instances
func (*AgentBoot) GetDefaultAgent ¶
GetDefaultAgent returns the default agent
func (*AgentBoot) ListAgents ¶
ListAgents returns all registered agent types
func (*AgentBoot) MustGetAgent ¶
MustGetAgent returns an agent by type or panics
func (*AgentBoot) RegisterAgent ¶
RegisterAgent registers a new agent type
func (*AgentBoot) SetDefaultAgent ¶
SetDefaultAgent sets the default agent type
type AgentType ¶
type AgentType string
AgentType defines the supported agent types
const (
AgentTypeClaude AgentType = "claude"
)
type CompletionResult ¶
CompletionResult contains the final result information
type Config ¶
type Config struct {
DefaultAgent AgentType `json:"default_agent"`
DefaultFormat OutputFormat `json:"default_format"`
EnableStreamJSON bool `json:"enable_stream_json"`
StreamBufferSize int `json:"stream_buffer_size"`
}
Config holds the AgentBoot configuration
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default AgentBoot configuration
type Event ¶
type Event struct {
Type string `json:"type"`
Data map[string]interface{} `json:"data"`
Timestamp time.Time `json:"timestamp"`
Raw string `json:"raw,omitempty"`
}
Event represents a generic agent event
type ExecutionOptions ¶
type ExecutionOptions struct {
ProjectPath string
OutputFormat OutputFormat
Timeout time.Duration
Env []string
// Handler is an optional message handler for real-time processing
// If provided, messages will be streamed to the handler during execution
Handler MessageHandler
// SessionID is the session ID to use or resume
// If Resume is true, --resume <session_id> is used to continue an existing session
// If Resume is false, --session-id <session_id> is used to create a new session with specific ID
SessionID string
// Resume indicates whether to resume an existing session (true) or create a new one (false)
Resume bool
}
ExecutionOptions controls agent execution
type MessageHandler ¶
type MessageHandler interface {
OnMessage(msg interface{}) error
OnError(err error)
OnComplete(result *CompletionResult)
}
MessageHandler is the interface for real-time message processing This interface is defined here to avoid circular dependencies
type OutputFormat ¶
type OutputFormat string
OutputFormat defines agent output format
const ( OutputFormatText OutputFormat = "text" OutputFormatStreamJSON OutputFormat = "stream-json" )
func (OutputFormat) String ¶
func (f OutputFormat) String() string
String returns the string representation of OutputFormat
type PermissionConfig ¶
type PermissionConfig struct {
DefaultMode PermissionMode `json:"default_mode"`
Timeout time.Duration `json:"timeout"`
EnableWhitelist bool `json:"enable_whitelist"`
Whitelist []string `json:"whitelist"`
Blacklist []string `json:"blacklist"`
RememberDecisions bool `json:"remember_decisions"`
DecisionDuration time.Duration `json:"decision_duration"`
}
PermissionConfig holds permission handler configuration
func DefaultPermissionConfig ¶
func DefaultPermissionConfig() PermissionConfig
DefaultPermissionConfig returns the default permission handler configuration
type PermissionMode ¶
type PermissionMode string
PermissionMode defines how permission requests are handled
const ( PermissionModeAuto PermissionMode = "auto" // Auto-approve all requests PermissionModeManual PermissionMode = "manual" // Require user approval PermissionModeSkip PermissionMode = "skip" // Skip permission prompts )
func ParsePermissionMode ¶
func ParsePermissionMode(s string) (PermissionMode, bool)
ParsePermissionMode parses a permission mode from string
func (PermissionMode) String ¶
func (m PermissionMode) String() string
String returns the string representation of PermissionMode
type PermissionRequest ¶
type PermissionRequest struct {
RequestID string `json:"request_id"`
AgentType AgentType `json:"agent_type"`
ToolName string `json:"tool_name"`
Input map[string]interface{} `json:"input"`
Reason string `json:"reason,omitempty"`
Timestamp time.Time `json:"timestamp"`
SessionID string `json:"session_id,omitempty"`
}
PermissionRequest represents a permission request from an agent
type PermissionResponse ¶
type PermissionResponse struct {
RequestID string `json:"request_id"`
Approved bool `json:"approved"`
Reason string `json:"reason,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
PermissionResponse represents the response to a permission request
type PermissionResult ¶
type PermissionResult struct {
Approved bool `json:"approved"`
Reason string `json:"reason,omitempty"`
}
PermissionResult represents the result of a permission check
type Result ¶
type Result struct {
Output string // Agent output (text mode)
ExitCode int // Process exit code
Error string // Error message if failed
Duration time.Duration
Format OutputFormat // Output format used
Events []Event // Stream events (stream-json mode)
Metadata map[string]interface{} // Additional metadata
}
Result represents the result of an agent execution
func (*Result) GetAssistantMessages ¶
GetAssistantMessages returns all assistant message events
func (*Result) GetCostUSD ¶
GetCostUSD extracts the total cost from result events if available
func (*Result) GetMessageChain ¶
GetMessageChain returns all events in order, excluding result/system events
func (*Result) GetMessagesByType ¶
GetMessagesByType returns all events of a specific type
func (*Result) GetSessionID ¶
GetSessionID extracts the session ID from metadata or events
func (*Result) GetToolResultMessages ¶
GetToolResultMessages returns all tool_result message events
func (*Result) GetToolUseMessages ¶
GetToolUseMessages returns all tool_use message events
func (*Result) GetUserMessages ¶
GetUserMessages returns all user message events
func (*Result) TextOutput ¶
TextOutput returns the full text output from the result