Documentation
¶
Overview ¶
Package completion provides detection for when agents complete their assigned work.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompletionDetector ¶
type CompletionDetector struct {
Session string
Config DetectionConfig
Store *assignment.AssignmentStore
Patterns []*regexp.Regexp // Completion patterns
FailPattern []*regexp.Regexp // Failure patterns
// contains filtered or unexported fields
}
CompletionDetector monitors agents for work completion
func New ¶
func New(session string, store *assignment.AssignmentStore) *CompletionDetector
New creates a new CompletionDetector with default configuration
func NewWithConfig ¶
func NewWithConfig(session string, store *assignment.AssignmentStore, cfg DetectionConfig) *CompletionDetector
NewWithConfig creates a new CompletionDetector with custom configuration
func (*CompletionDetector) AddFailurePattern ¶
func (d *CompletionDetector) AddFailurePattern(pattern string) error
AddFailurePattern adds a custom failure pattern
func (*CompletionDetector) AddPattern ¶
func (d *CompletionDetector) AddPattern(pattern string) error
AddPattern adds a custom completion pattern
func (*CompletionDetector) CheckNow ¶
func (d *CompletionDetector) CheckNow(pane int) (*CompletionEvent, error)
CheckNow performs an immediate check for a specific pane
func (*CompletionDetector) Watch ¶
func (d *CompletionDetector) Watch(ctx context.Context) <-chan CompletionEvent
Watch starts continuous monitoring and returns a channel of completion events. The channel is closed when the context is cancelled.
type CompletionEvent ¶
type CompletionEvent struct {
Pane int `json:"pane"`
AgentType string `json:"agent_type"`
BeadID string `json:"bead_id"`
Method DetectionMethod `json:"method"`
Timestamp time.Time `json:"timestamp"`
Duration time.Duration `json:"duration"` // How long agent worked
Output string `json:"output"` // Last N lines (for debugging)
IsFailed bool `json:"is_failed"` // True if failure detected
FailReason string `json:"fail_reason"` // Reason for failure
}
CompletionEvent represents a detected completion
type DetectionConfig ¶
type DetectionConfig struct {
PollInterval time.Duration // Interval for bead status polling (default 5s)
IdleThreshold time.Duration // Duration of inactivity to consider complete (default 120s)
RetryOnError bool // Retry failed checks (default true)
RetryInterval time.Duration // Time between retries (default 10s)
MaxRetries int // Max retries before giving up (default 3)
DedupWindow time.Duration // Prevent duplicate events (default 5s)
GracefulDegrading bool // Fall back to lesser methods (default true)
CaptureLines int // Lines to capture for pattern matching (default 50)
}
DetectionConfig configures the detector behavior
func DefaultConfig ¶
func DefaultConfig() DetectionConfig
DefaultConfig returns sensible default configuration
type DetectionMethod ¶
type DetectionMethod string
DetectionMethod describes how completion was detected
const ( // MethodBeadClosed indicates the bead was detected as closed in br MethodBeadClosed DetectionMethod = "bead_closed" // MethodPatternMatch indicates completion phrase was found in output MethodPatternMatch DetectionMethod = "pattern_match" // MethodIdle indicates no activity for threshold duration MethodIdle DetectionMethod = "idle" // MethodAgentMail indicates agent sent completion message MethodAgentMail DetectionMethod = "agent_mail" // MethodPaneLost indicates the pane no longer exists MethodPaneLost DetectionMethod = "pane_lost" )