browser

package
v0.14.3 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckResult

type CheckResult struct {
	SiteID     string `json:"site_id"`
	Profile    string `json:"profile"`
	CheckCount int    `json:"check_count"`
	Passed     bool   `json:"passed"`
	Message    string `json:"message"`
}

CheckResult reports check action outcome.

type Config

type Config struct {
	WorkspaceDir           string
	DefaultProfile         string
	ManagedHeadless        bool
	ManagedExecutablePath  string
	ManagedUserDataDir     string
	SiteFlowsDir           string
	AutoLoginSiteAllowlist []string
	Vault                  SecretReader
	OTP                    OTPRequester
}

Config controls browser runtime behavior.

type LoginResult

type LoginResult struct {
	SiteID  string `json:"site_id"`
	Profile string `json:"profile"`
	Mode    string `json:"mode"`
	Success bool   `json:"success"`
	Message string `json:"message"`
}

LoginResult reports login outcome without exposing secrets.

type OTPRequester

type OTPRequester interface {
	RequestOTP(ctx context.Context, siteID string, timeout time.Duration) (string, error)
}

OTPRequester requests a one-time passcode from an approved channel.

type Profile

type Profile struct {
	Name               string `json:"name"`
	Driver             string `json:"driver"`
	Default            bool   `json:"default"`
	Running            bool   `json:"running"`
	ExtensionConnected bool   `json:"extension_connected,omitempty"`
}

Profile reports available browser profiles.

type RunResult

type RunResult struct {
	SiteID    string `json:"site_id"`
	Profile   string `json:"profile"`
	Action    string `json:"action"`
	StepCount int    `json:"step_count"`
	Success   bool   `json:"success"`
	Message   string `json:"message"`
}

RunResult reports flow run outcome.

type SecretReader

type SecretReader interface {
	ReadKV(ctx context.Context, secretPath string) (map[string]string, error)
}

SecretReader resolves secret values for login automation.

type Service

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

Service provides profile-aware browser operations.

func NewService

func NewService(cfg Config) *Service

func (*Service) Act

func (s *Service) Act(action string, target string, value string) (State, error)

func (*Service) Check

func (s *Service) Check(ctx context.Context, siteID string, profile string) (CheckResult, error)

func (*Service) Login

func (s *Service) Login(ctx context.Context, siteID string, profile string) (LoginResult, error)

func (*Service) Open

func (s *Service) Open(rawURL string) (State, error)

func (*Service) Profiles

func (s *Service) Profiles() []Profile

func (*Service) Run

func (s *Service) Run(ctx context.Context, siteID string, flowAction string, profile string) (RunResult, error)

func (*Service) Screenshot

func (s *Service) Screenshot(name string) (State, error)

func (*Service) Snapshot

func (s *Service) Snapshot() (State, error)

func (*Service) Start

func (s *Service) Start(profile string) State

func (*Service) Status

func (s *Service) Status() State

func (*Service) Stop

func (s *Service) Stop() State

type SiteAction

type SiteAction struct {
	Steps []SiteStep `yaml:"steps,omitempty" json:"steps,omitempty"`
}

type SiteCheck

type SiteCheck struct {
	Selector  string `yaml:"selector,omitempty" json:"selector,omitempty"`
	Contains  string `yaml:"contains,omitempty" json:"contains,omitempty"`
	TimeoutMS int    `yaml:"timeout_ms,omitempty" json:"timeout_ms,omitempty"`
}

type SiteFlow

type SiteFlow struct {
	ID           string                `yaml:"id" json:"id"`
	Enabled      bool                  `yaml:"enabled" json:"enabled"`
	URL          string                `yaml:"url,omitempty" json:"url,omitempty"`
	Profile      string                `yaml:"profile,omitempty" json:"profile,omitempty"`
	AllowedHosts []string              `yaml:"allowed_hosts,omitempty" json:"allowed_hosts,omitempty"`
	Login        SiteLogin             `yaml:"login,omitempty" json:"login,omitempty"`
	Checks       []SiteCheck           `yaml:"checks,omitempty" json:"checks,omitempty"`
	Actions      map[string]SiteAction `yaml:"actions,omitempty" json:"actions,omitempty"`
}

SiteFlow defines a site-specific browser automation flow.

func LoadSiteFlows

func LoadSiteFlows(dir string) ([]SiteFlow, error)

LoadSiteFlows parses all site flow YAML files from dir.

type SiteLogin

type SiteLogin struct {
	Mode             string `yaml:"mode,omitempty" json:"mode,omitempty"`
	URL              string `yaml:"url,omitempty" json:"url,omitempty"`
	VaultPath        string `yaml:"vault_path,omitempty" json:"vault_path,omitempty"`
	EnvPrefix        string `yaml:"env_prefix,omitempty" json:"env_prefix,omitempty"`
	UsernameField    string `yaml:"username_field,omitempty" json:"username_field,omitempty"`
	PasswordField    string `yaml:"password_field,omitempty" json:"password_field,omitempty"`
	UsernameSelector string `yaml:"username_selector,omitempty" json:"username_selector,omitempty"`
	PasswordSelector string `yaml:"password_selector,omitempty" json:"password_selector,omitempty"`
	SubmitSelector   string `yaml:"submit_selector,omitempty" json:"submit_selector,omitempty"`
	SuccessSelector  string `yaml:"success_selector,omitempty" json:"success_selector,omitempty"`
	OTPRequired      bool   `yaml:"otp_required,omitempty" json:"otp_required,omitempty"`
	OTPTimeoutSec    int    `yaml:"otp_timeout_sec,omitempty" json:"otp_timeout_sec,omitempty"`
}

type SiteStep

type SiteStep struct {
	Open    string `yaml:"open,omitempty" json:"open,omitempty"`
	Click   string `yaml:"click,omitempty" json:"click,omitempty"`
	Type    string `yaml:"type,omitempty" json:"type,omitempty"`
	Value   string `yaml:"value,omitempty" json:"value,omitempty"`
	Wait    int    `yaml:"wait,omitempty" json:"wait,omitempty"`
	Extract string `yaml:"extract,omitempty" json:"extract,omitempty"`
}

type State

type State struct {
	Running            bool   `json:"running"`
	Profile            string `json:"profile,omitempty"`
	Driver             string `json:"driver,omitempty"`
	CurrentURL         string `json:"current_url,omitempty"`
	LastSnapshot       string `json:"last_snapshot,omitempty"`
	LastAction         string `json:"last_action,omitempty"`
	LastScreenshot     string `json:"last_screenshot,omitempty"`
	ExtensionConnected bool   `json:"extension_connected,omitempty"`
	AttachedTabs       int    `json:"attached_tabs,omitempty"`
	LastError          string `json:"last_error,omitempty"`
}

State is the current browser runtime state.

Jump to

Keyboard shortcuts

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