activity

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package activity provides the activity system for RPA workflow execution.

Index

Constants

This section is empty.

Variables

View Source
var DefaultRegistry = NewRegistry()

DefaultRegistry is the global default registry.

Functions

func GetBool

func GetBool(params map[string]any, key string) bool

GetBool retrieves a boolean parameter from the params map.

func GetFloat

func GetFloat(params map[string]any, key string) float64

GetFloat retrieves a float parameter from the params map.

func GetInt

func GetInt(params map[string]any, key string) int

GetInt retrieves an integer parameter from the params map.

func GetIntDefault

func GetIntDefault(params map[string]any, key string, defaultValue int) int

GetIntDefault retrieves an integer parameter with a default value.

func GetMap

func GetMap(params map[string]any, key string) map[string]any

GetMap retrieves a map parameter from the params map.

func GetString

func GetString(params map[string]any, key string) string

GetString retrieves a string parameter from the params map.

func GetStringDefault

func GetStringDefault(params map[string]any, key, defaultValue string) string

GetStringDefault retrieves a string parameter with a default value.

func GetStringSlice

func GetStringSlice(params map[string]any, key string) []string

GetStringSlice retrieves a string slice parameter from the params map.

func List

func List() []string

List returns all activity names from the default registry.

func Register

func Register(a Activity)

Register adds an activity to the default registry.

Types

type Activity

type Activity interface {
	// Name returns the activity's unique identifier (e.g., "browser.navigate").
	Name() string

	// Execute runs the activity with the given parameters and environment.
	Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)
}

Activity represents an executable RPA action.

func Get

func Get(name string) (Activity, bool)

Get retrieves an activity from the default registry.

type AssertActivity

type AssertActivity struct{}

AssertActivity asserts a condition is true.

func (*AssertActivity) Execute

func (a *AssertActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*AssertActivity) Name

func (a *AssertActivity) Name() string

type CheckActivity

type CheckActivity struct{}

CheckActivity checks a checkbox.

func (*CheckActivity) Execute

func (a *CheckActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*CheckActivity) Name

func (a *CheckActivity) Name() string

type ClickActivity

type ClickActivity struct{}

ClickActivity clicks on an element.

func (*ClickActivity) Execute

func (a *ClickActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*ClickActivity) Name

func (a *ClickActivity) Name() string

type Environment

type Environment struct {
	// Pilot is the browser automation interface.
	Pilot *w3pilot.Pilot

	// Variables contains workflow and step variables.
	Variables map[string]any

	// WorkDir is the working directory for file operations.
	WorkDir string

	// Logger is the structured logger for activity output.
	Logger *slog.Logger

	// Headless indicates if the browser is running in headless mode.
	Headless bool
}

Environment provides execution context to activities.

func NewEnvironment

func NewEnvironment(pilot *w3pilot.Pilot, workDir string, logger *slog.Logger) *Environment

NewEnvironment creates a new Environment with initialized fields.

type FileDeleteActivity

type FileDeleteActivity struct{}

FileDeleteActivity deletes a file.

func (*FileDeleteActivity) Execute

func (a *FileDeleteActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*FileDeleteActivity) Name

func (a *FileDeleteActivity) Name() string

type FileExistsActivity

type FileExistsActivity struct{}

FileExistsActivity checks if a file exists.

func (*FileExistsActivity) Execute

func (a *FileExistsActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*FileExistsActivity) Name

func (a *FileExistsActivity) Name() string

type FileReadActivity

type FileReadActivity struct{}

FileReadActivity reads a file's contents.

func (*FileReadActivity) Execute

func (a *FileReadActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*FileReadActivity) Name

func (a *FileReadActivity) Name() string

type FileWriteActivity

type FileWriteActivity struct{}

FileWriteActivity writes content to a file.

func (*FileWriteActivity) Execute

func (a *FileWriteActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (_ any, err error)

func (*FileWriteActivity) Name

func (a *FileWriteActivity) Name() string

type FillActivity

type FillActivity struct{}

FillActivity fills an input with a value (clears first).

func (*FillActivity) Execute

func (a *FillActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*FillActivity) Name

func (a *FillActivity) Name() string

type FindActivity

type FindActivity struct{}

FindActivity finds an element by selector.

func (*FindActivity) Execute

func (a *FindActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*FindActivity) Name

func (a *FindActivity) Name() string

type FindAllActivity

type FindAllActivity struct{}

FindAllActivity finds all elements matching a selector.

func (*FindAllActivity) Execute

func (a *FindAllActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*FindAllActivity) Name

func (a *FindAllActivity) Name() string

type GetAttributeActivity

type GetAttributeActivity struct{}

GetAttributeActivity gets an attribute value from an element.

func (*GetAttributeActivity) Execute

func (a *GetAttributeActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*GetAttributeActivity) Name

func (a *GetAttributeActivity) Name() string

type GetTextActivity

type GetTextActivity struct{}

GetTextActivity gets the text content of an element.

func (*GetTextActivity) Execute

func (a *GetTextActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*GetTextActivity) Name

func (a *GetTextActivity) Name() string

type GetValueActivity

type GetValueActivity struct{}

GetValueActivity gets the value of an input element.

func (*GetValueActivity) Execute

func (a *GetValueActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*GetValueActivity) Name

func (a *GetValueActivity) Name() string

type HTTPDownloadActivity

type HTTPDownloadActivity struct{}

HTTPDownloadActivity downloads a file.

func (*HTTPDownloadActivity) Execute

func (a *HTTPDownloadActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*HTTPDownloadActivity) Name

func (a *HTTPDownloadActivity) Name() string

type HTTPGetActivity

type HTTPGetActivity struct{}

HTTPGetActivity performs an HTTP GET request.

func (*HTTPGetActivity) Execute

func (a *HTTPGetActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*HTTPGetActivity) Name

func (a *HTTPGetActivity) Name() string

type HTTPPostActivity

type HTTPPostActivity struct{}

HTTPPostActivity performs an HTTP POST request.

func (*HTTPPostActivity) Execute

func (a *HTTPPostActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*HTTPPostActivity) Name

func (a *HTTPPostActivity) Name() string

type IsVisibleActivity

type IsVisibleActivity struct{}

IsVisibleActivity checks if an element is visible.

func (*IsVisibleActivity) Execute

func (a *IsVisibleActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*IsVisibleActivity) Name

func (a *IsVisibleActivity) Name() string

type LogActivity

type LogActivity struct{}

LogActivity logs a message.

func (*LogActivity) Execute

func (a *LogActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*LogActivity) Name

func (a *LogActivity) Name() string
type NavigateActivity struct{}

NavigateActivity navigates to a URL.

func (a *NavigateActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)
func (a *NavigateActivity) Name() string

type PDFActivity

type PDFActivity struct{}

PDFActivity generates a PDF of the page.

func (*PDFActivity) Execute

func (a *PDFActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*PDFActivity) Name

func (a *PDFActivity) Name() string

type Registry

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

Registry holds all available activities.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new activity registry.

func (*Registry) Categories

func (r *Registry) Categories() []string

Categories returns all activity categories.

func (*Registry) Count

func (r *Registry) Count() int

Count returns the number of registered activities.

func (*Registry) Get

func (r *Registry) Get(name string) (Activity, bool)

Get retrieves an activity by name.

func (*Registry) List

func (r *Registry) List() []string

List returns all registered activity names.

func (*Registry) ListByCategory

func (r *Registry) ListByCategory() map[string][]string

ListByCategory returns activities grouped by category (prefix before ".").

func (*Registry) ListCategory

func (r *Registry) ListCategory(category string) []string

ListCategory returns all activities in a specific category.

func (*Registry) MustGet

func (r *Registry) MustGet(name string) Activity

MustGet retrieves an activity by name, panicking if not found.

func (*Registry) Register

func (r *Registry) Register(a Activity)

Register adds an activity to the registry.

type ScrapeTableActivity

type ScrapeTableActivity struct{}

ScrapeTableActivity extracts data from an HTML table.

func (*ScrapeTableActivity) Execute

func (a *ScrapeTableActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*ScrapeTableActivity) Name

func (a *ScrapeTableActivity) Name() string

type ScreenshotActivity

type ScreenshotActivity struct{}

ScreenshotActivity captures a screenshot.

func (*ScreenshotActivity) Execute

func (a *ScreenshotActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*ScreenshotActivity) Name

func (a *ScreenshotActivity) Name() string

type ScrollActivity

type ScrollActivity struct{}

ScrollActivity scrolls the page or an element.

func (*ScrollActivity) Execute

func (a *ScrollActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*ScrollActivity) Name

func (a *ScrollActivity) Name() string

type SelectOptionActivity

type SelectOptionActivity struct{}

SelectOptionActivity selects an option in a dropdown.

func (*SelectOptionActivity) Execute

func (a *SelectOptionActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*SelectOptionActivity) Name

func (a *SelectOptionActivity) Name() string

type SetVariableActivity

type SetVariableActivity struct{}

SetVariableActivity sets a variable value.

func (*SetVariableActivity) Execute

func (a *SetVariableActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*SetVariableActivity) Name

func (a *SetVariableActivity) Name() string

type TypeActivity

type TypeActivity struct{}

TypeActivity types text into an element (without clearing).

func (*TypeActivity) Execute

func (a *TypeActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*TypeActivity) Name

func (a *TypeActivity) Name() string

type UncheckActivity

type UncheckActivity struct{}

UncheckActivity unchecks a checkbox.

func (*UncheckActivity) Execute

func (a *UncheckActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*UncheckActivity) Name

func (a *UncheckActivity) Name() string

type WaitActivity

type WaitActivity struct{}

WaitActivity waits for a specified duration.

func (*WaitActivity) Execute

func (a *WaitActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*WaitActivity) Name

func (a *WaitActivity) Name() string

type WaitForActivity

type WaitForActivity struct{}

WaitForActivity waits for an element to reach a state.

func (*WaitForActivity) Execute

func (a *WaitForActivity) Execute(ctx context.Context, params map[string]any, env *Environment) (any, error)

func (*WaitForActivity) Name

func (a *WaitForActivity) Name() string

Jump to

Keyboard shortcuts

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