Documentation
¶
Index ¶
- Constants
- func InterpolateEnv(s string, workflowEnv map[string]string) string
- func ParseTimeout(s string) time.Duration
- type Action
- type ActionResult
- type ClickStep
- type DownloadStep
- type ElementInfo
- type EvalAssert
- type EvalResult
- type Executor
- func (e *Executor) Close()
- func (e *Executor) IsHeaded() bool
- func (e *Executor) KeyPress(key input.Key) error
- func (e *Executor) NavigateTo(url string) error
- func (e *Executor) Page() *rod.Page
- func (e *Executor) RunAction(name string) *ActionResult
- func (e *Executor) SetEnv(key, value string)
- func (e *Executor) Start() error
- func (e *Executor) UserAgent() string
- func (e *Executor) WaitOnFailure()
- type FillStep
- type InspectResult
- type Option
- type SelectStep
- type SleepStep
- type Step
- type UploadStep
- type Viewport
- type WaitStep
- type WaitURLStep
- type Workflow
Constants ¶
const InspectJS = `` /* 2995-byte string literal not displayed */
inspectJS extracts interactive elements from the DOM. Returns a JSON array of element descriptors. Designed to be compact and useful for LLM agents writing workflow YAML. InspectJS is the JavaScript that extracts interactive elements from the DOM. Exported so the CLI can call it via page.Eval().
Variables ¶
This section is empty.
Functions ¶
func InterpolateEnv ¶
InterpolateEnv replaces ${VAR_NAME} patterns with environment variable values. Checks the workflow's env map first, then os.Getenv.
func ParseTimeout ¶
ParseTimeout converts a timeout string like "30s" or "2m" to a Duration. Defaults to 30s if empty or unparseable.
Types ¶
type Action ¶
type Action struct {
URL string `yaml:"url,omitempty"`
Headed bool `yaml:"headed,omitempty"` // show browser window (used by BRZ_HEADED=auto)
Viewport *Viewport `yaml:"viewport,omitempty"` // override workflow-level viewport
Steps []Step `yaml:"steps"`
Eval []EvalAssert `yaml:"eval,omitempty"` // post-action assertions
}
Action is a named sequence of steps with an optional starting URL.
type ActionResult ¶
type ActionResult struct {
OK bool `json:"ok"`
Action string `json:"action"`
Steps int `json:"steps"`
DurationMs int64 `json:"duration_ms"`
Download string `json:"download,omitempty"`
DownloadSize int64 `json:"download_size,omitempty"`
Error string `json:"error,omitempty"`
FailedStep int `json:"failed_step,omitempty"`
StepType string `json:"step_type,omitempty"`
Screenshot string `json:"screenshot,omitempty"` // page state after failure
ScreenshotBefore string `json:"screenshot_before,omitempty"` // page state before the failed step
PageHTML string `json:"page_html,omitempty"` // page HTML at time of failure (for debugging)
PageURL string `json:"page_url,omitempty"` // page URL at time of failure
Escalated bool `json:"escalated,omitempty"` // true if auto-escalated from headless to headed
StatusCode int `json:"status_code,omitempty"` // HTTP status code of the last navigation
// Eval results
EvalsPassed int `json:"evals_passed,omitempty"` // number of eval assertions that passed
EvalsFailed int `json:"evals_failed,omitempty"` // number of eval assertions that failed
EvalErrors []string `json:"eval_errors,omitempty"` // descriptions of failed assertions
}
ActionResult is the structured output of running a workflow action. Designed for machine consumption — LLM agents parse this as JSON.
type DownloadStep ¶
type ElementInfo ¶
type ElementInfo struct {
Selector string `json:"selector"`
Tag string `json:"tag"`
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Text string `json:"text,omitempty"`
Href string `json:"href,omitempty"`
Value string `json:"value,omitempty"`
Role string `json:"role,omitempty"`
Hidden bool `json:"hidden,omitempty"`
}
ElementInfo describes a single interactive DOM element.
type EvalAssert ¶ added in v0.3.0
type EvalAssert struct {
// Page state
JS string `yaml:"js,omitempty"` // JS expression that must return truthy
URLContains string `yaml:"url_contains,omitempty"` // current URL must contain this string
TextVisible string `yaml:"text_visible,omitempty"` // text must be visible on page
NoText string `yaml:"no_text,omitempty"` // text must NOT be visible on page
Selector string `yaml:"selector,omitempty"` // element must exist on page
Timeout string `yaml:"timeout,omitempty"` // timeout for page-state checks (default "5s")
// Response state
StatusCode int `yaml:"status_code,omitempty"` // HTTP status code must match (e.g. 200)
// Download state
DownloadMinSize int64 `yaml:"download_min_size,omitempty"` // downloaded file must be at least N bytes
DownloadMinRows int `yaml:"download_min_rows,omitempty"` // CSV must have at least N data rows (excluding header)
DownloadHasColumns []string `yaml:"download_has_columns,omitempty"` // CSV header must contain these columns
// Metadata
Label string `yaml:"label,omitempty"` // human-readable description for logging/errors
}
EvalAssert is a single post-action assertion. Exactly one field should be set.
type EvalResult ¶ added in v0.3.0
EvalResult holds the outcome of running eval assertions on an action.
type Executor ¶
type Executor struct {
// LastDownload holds the path to the most recently downloaded file.
LastDownload string
// LastResult holds the string result of the most recent action (e.g. downloaded CSV content).
LastResult string
// LastStatusCode holds the HTTP status code from the most recent navigation.
LastStatusCode int
// contains filtered or unexported fields
}
Executor runs workflow actions against a real browser.
func NewExecutor ¶
NewExecutor creates an executor with browser configuration. Use functional options: WithHeaded(true), WithDebug(true), WithProfileDir("...").
func (*Executor) NavigateTo ¶
NavigateTo creates a new page, injects stealth, and navigates to the given URL. Used by one-shot commands (inspect, screenshot, eval) that don't need a workflow.
func (*Executor) RunAction ¶
func (e *Executor) RunAction(name string) *ActionResult
RunAction executes a named action from the workflow. Returns a structured ActionResult suitable for JSON serialization.
func (*Executor) SetEnv ¶
SetEnv sets an environment variable in the workflow's env map. These are used by InterpolateEnv for ${VAR} substitution in step values.
func (*Executor) UserAgent ¶ added in v0.7.1
UserAgent returns the User-Agent string the executor uses for page requests.
func (*Executor) WaitOnFailure ¶ added in v0.2.0
func (e *Executor) WaitOnFailure()
WaitOnFailure keeps the browser open for inspection when headed and an action failed. Call this from the CLI layer after RunAction returns a failure. Waits for the user to press Enter in the terminal, then returns.
type InspectResult ¶
type InspectResult struct {
OK bool `json:"ok"`
URL string `json:"url"`
Title string `json:"title"`
Elements []ElementInfo `json:"elements"`
Total int `json:"total"`
Truncated bool `json:"truncated,omitempty"`
DurationMs int64 `json:"duration_ms"`
Error string `json:"error,omitempty"`
}
InspectResult is the structured output of inspecting a page's interactive elements.
type Option ¶
type Option func(*Executor)
Option configures an Executor.
func WithAutoHeaded ¶ added in v0.2.0
WithAutoHeaded enables auto-escalation: start headless, but if an action marked headed:true fails, relaunch in headed mode and retry.
func WithHeaded ¶
WithHeaded shows the browser window (useful for CAPTCHAs or debugging).
func WithProfileDir ¶
WithProfileDir sets the Chrome profile directory for session persistence.
type SelectStep ¶ added in v0.5.0
type Step ¶
type Step struct {
Navigate string `yaml:"navigate,omitempty"`
// Interactions
Click *ClickStep `yaml:"click,omitempty"`
Fill *FillStep `yaml:"fill,omitempty"`
Select *SelectStep `yaml:"select,omitempty"`
Upload *UploadStep `yaml:"upload,omitempty"`
Download *DownloadStep `yaml:"download,omitempty"`
// Waits
WaitVisible *WaitStep `yaml:"wait_visible,omitempty"`
WaitText *WaitStep `yaml:"wait_text,omitempty"`
WaitURL *WaitURLStep `yaml:"wait_url,omitempty"`
// Utilities
Screenshot string `yaml:"screenshot,omitempty"`
Sleep *SleepStep `yaml:"sleep,omitempty"`
Eval string `yaml:"eval,omitempty"`
// Control flow
Label string `yaml:"label,omitempty"` // human-readable step description for logging
Optional bool `yaml:"optional,omitempty"` // if true, step failure is non-fatal
}
Step is a single browser operation. Exactly one field should be set.
type UploadStep ¶
type Viewport ¶ added in v0.6.0
Viewport configures the browser window size.
func DefaultViewport ¶ added in v0.6.0
func DefaultViewport() Viewport
DefaultViewport returns the default browser viewport (1280x900).
func ResolveViewport ¶ added in v0.6.0
ResolveViewport returns the effective viewport: action > workflow > default.
type WaitURLStep ¶
type Workflow ¶
type Workflow struct {
Name string `yaml:"name"`
Env map[string]string `yaml:"env,omitempty"`
Viewport *Viewport `yaml:"viewport,omitempty"`
DebugScreenshots *bool `yaml:"debug_screenshots,omitempty"` // default: true
Actions map[string]Action `yaml:"actions"`
}
Workflow defines a complete browser automation workflow loaded from YAML.
func LoadFromBytes ¶ added in v0.3.0
LoadFromBytes parses workflow YAML from a byte slice.