automation

package
v0.12.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package automation provides a CLI automation layer using claude-go for agent-based processing of tasks like audit result transformation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditProcessInput

type AuditProcessInput struct {
	// AuditType is the type of audit (accessibility, security, etc.)
	AuditType string `json:"audit_type"`

	// RawData is the raw audit output from browser
	RawData map[string]interface{} `json:"raw_data"`

	// PageURL is the URL being audited
	PageURL string `json:"page_url"`

	// PageTitle is the page title
	PageTitle string `json:"page_title"`
}

AuditProcessInput is input for audit processing tasks.

type AuditProcessOutput

type AuditProcessOutput struct {
	// Summary is a 1-2 sentence summary
	Summary string `json:"summary"`

	// Score is the 0-100 score
	Score int `json:"score"`

	// Grade is the A-F grade
	Grade string `json:"grade"`

	// CheckedAt is when the audit was performed
	CheckedAt string `json:"checked_at"`

	// ChecksRun lists the check IDs that were executed
	ChecksRun []string `json:"checks_run"`

	// Fixable contains issues with selectors that can be fixed
	Fixable []FixableIssue `json:"fixable"`

	// Informational contains non-actionable info
	Informational []InformationalIssue `json:"informational"`

	// Actions lists prioritized actions
	Actions []string `json:"actions"`

	// CorrelatedGroups groups related issues
	CorrelatedGroups []CorrelatedGroup `json:"correlated_groups,omitempty"`

	// Stats contains summary counts
	Stats AuditStats `json:"stats"`
}

AuditProcessOutput is output from audit processing.

type AuditStats

type AuditStats struct {
	// Errors is the count of error-severity issues
	Errors int `json:"errors"`

	// Warnings is the count of warning-severity issues
	Warnings int `json:"warnings"`

	// Info is the count of info-severity issues
	Info int `json:"info"`

	// Fixable is the count of fixable issues
	Fixable int `json:"fixable"`

	// Informational is the count of informational issues
	Informational int `json:"informational"`
}

AuditStats contains summary counts.

type CorrelatedGroup

type CorrelatedGroup struct {
	// Name is the group name
	Name string `json:"name"`

	// IssueIDs are the IDs of issues in this group
	IssueIDs []string `json:"issue_ids"`

	// Description describes why these issues are related
	Description string `json:"description"`

	// CommonFix is a fix that addresses all issues in the group
	CommonFix string `json:"common_fix,omitempty"`
}

CorrelatedGroup groups related issues.

type FixableIssue

type FixableIssue struct {
	// ID is the unique issue ID
	ID string `json:"id"`

	// Type is the issue type
	Type string `json:"type"`

	// Severity is error, warning, or info
	Severity string `json:"severity"`

	// Impact is the 1-10 impact score
	Impact int `json:"impact"`

	// Selector is the CSS selector to target the element
	Selector string `json:"selector"`

	// Element is the truncated HTML of the element
	Element string `json:"element,omitempty"`

	// Message is the human-readable issue description
	Message string `json:"message"`

	// Fix is the specific fix instruction
	Fix string `json:"fix"`

	// Standard is the standard reference (WCAG, etc.)
	Standard string `json:"standard,omitempty"`
}

FixableIssue represents an actionable issue.

type InformationalIssue

type InformationalIssue struct {
	// ID is the unique issue ID
	ID string `json:"id"`

	// Type is the issue type
	Type string `json:"type"`

	// Severity is usually "info"
	Severity string `json:"severity"`

	// Message is the human-readable description
	Message string `json:"message"`

	// Context contains additional context data
	Context map[string]interface{} `json:"context,omitempty"`
}

InformationalIssue represents a non-actionable issue.

type Processor

type Processor struct {
	// contains filtered or unexported fields
}

Processor handles agent-based automation tasks.

func New

func New(cfg ProcessorConfig) (*Processor, error)

New creates a new automation processor.

func (*Processor) Close

func (p *Processor) Close() error

Close shuts down the processor.

func (*Processor) Process

func (p *Processor) Process(ctx context.Context, task Task) (*Result, error)

Process runs a single task and returns the result.

func (*Processor) ProcessBatch

func (p *Processor) ProcessBatch(ctx context.Context, tasks []Task) ([]*Result, error)

ProcessBatch runs multiple tasks concurrently.

func (*Processor) Stats

func (p *Processor) Stats() ProcessorStats

Stats returns the processor statistics.

type ProcessorConfig

type ProcessorConfig struct {
	// Model is the default model to use (haiku recommended for most tasks)
	Model string

	// MaxBudgetUSD is the maximum cost per task in USD
	MaxBudgetUSD float64

	// MaxTurns is the maximum conversation turns
	MaxTurns int

	// WorkingDir is the working directory context
	WorkingDir string

	// AllowedTools specifies tools the agent can use
	AllowedTools []string

	// DisallowedTools specifies tools the agent cannot use
	DisallowedTools []string

	// TimeoutSecs is the timeout for each task
	TimeoutSecs int
}

ProcessorConfig configures the automation processor.

func DefaultConfig

func DefaultConfig() ProcessorConfig

DefaultConfig returns config optimized for automation tasks.

type ProcessorStats

type ProcessorStats struct {
	TasksProcessed  int64
	TasksSucceeded  int64
	TasksFailed     int64
	TotalTokens     int64
	TotalCostUSD    float64
	AverageDuration time.Duration
}

ProcessorStats tracks processor statistics.

type PromptRegistry

type PromptRegistry struct {
	// contains filtered or unexported fields
}

PromptRegistry holds system prompts for each task type.

func DefaultPromptRegistry

func DefaultPromptRegistry() *PromptRegistry

DefaultPromptRegistry returns prompts optimized for automation.

func (*PromptRegistry) Get

func (r *PromptRegistry) Get(taskType TaskType) string

Get returns the prompt for a task type.

func (*PromptRegistry) Set

func (r *PromptRegistry) Set(taskType TaskType, prompt string)

Set sets a custom prompt for a task type.

type Result

type Result struct {
	// Type is the task type that was processed
	Type TaskType

	// Output is the task-specific output
	Output interface{}

	// Tokens is the number of tokens used
	Tokens int

	// Cost is the cost in USD
	Cost float64

	// Duration is the processing time
	Duration time.Duration

	// Error contains any processing error
	Error error
}

Result represents the processed output.

type Task

type Task struct {
	// Type is the task type
	Type TaskType

	// Input is the task-specific input data
	Input interface{}

	// Context provides additional context (page URL, etc.)
	Context map[string]interface{}

	// Options configures task processing
	Options TaskOptions
}

Task represents an automation task to process.

func NewAuditProcessTask

func NewAuditProcessTask(auditType string, rawData map[string]interface{}, pageURL, pageTitle string) Task

NewAuditProcessTask creates a new audit processing task.

func NewPrioritizeTask

func NewPrioritizeTask(items []interface{}, context map[string]interface{}) Task

NewPrioritizeTask creates a new prioritization task.

func NewSummarizeTask

func NewSummarizeTask(content string, context map[string]interface{}) Task

NewSummarizeTask creates a new summarization task.

type TaskOptions

type TaskOptions struct {
	// Model overrides the default model for this task
	Model string

	// MaxTokens limits the response tokens
	MaxTokens int

	// Temperature controls randomness (0.0-1.0, lower = more deterministic)
	Temperature float64
}

TaskOptions configures task processing.

type TaskType

type TaskType string

TaskType identifies the type of automation task.

const (
	// TaskTypeAuditProcess processes raw audit data into actionable output
	TaskTypeAuditProcess TaskType = "audit_process"

	// TaskTypeSummarize summarizes content
	TaskTypeSummarize TaskType = "summarize"

	// TaskTypePrioritize prioritizes action items
	TaskTypePrioritize TaskType = "prioritize"

	// TaskTypeGenerateFixes generates fix suggestions
	TaskTypeGenerateFixes TaskType = "generate_fixes"

	// TaskTypeCorrelate correlates related issues
	TaskTypeCorrelate TaskType = "correlate"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL