browser

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package browser gives the agent a real browser via the Chrome DevTools Protocol (chromedp): it attaches to the user's running Chrome/Chromium/ Brave when a DevTools port is open, otherwise launches a managed instance — visible by default, so the user can watch the agent work. When the machine has no Chromium-family browser at all, `factor init` provisions one (see install.go). Build with -tags nobrowser to strip the whole suite from the binary.

Index

Constants

View Source
const (

	// InstallTimeout bounds one provisioning attempt. The tarball is ~125MB
	// and the machines that need it most are the ones on slow links.
	InstallTimeout = 20 * time.Minute
)

Variables

This section is empty.

Functions

func Available added in v0.4.0

func Available() bool

Available reports whether this build carries the browser suite at all.

func EngineBinary added in v0.4.0

func EngineBinary(home string) string

EngineBinary is the provisioned browser's executable.

func EngineDir added in v0.4.0

func EngineDir(home string) string

EngineDir is where a provisioned browser lives.

func EnsureEngine added in v0.4.0

func EnsureEngine(ctx context.Context, home string, progress Progress) (string, bool, error)

EnsureEngine returns a Chromium-family binary the browser suite can drive, downloading Helium when the machine has none. The bool reports whether this call installed it. Callers holding a configured browser.command should resolve that with FindBrowserBinary first — this function only knows about the machine, not the config.

func EnsureFastEngine added in v0.4.0

func EnsureFastEngine(ctx context.Context, home string, progress Progress) (string, bool, error)

EnsureFastEngine installs Lightpanda: a browser written from scratch for automation, with a CDP server and no renderer at all. It reads pages for a fraction of Chromium's memory, which is worth a second engine on a small box — but only reads them, so it supplements the real browser instead of replacing it. Its builds need glibc 2.34, which older distributions do not have; the version check below is what turns that into a clear answer.

func FastEngineBinary added in v0.4.0

func FastEngineBinary(home string) string

FastEngineBinary is the provisioned lightweight engine.

func FastEngineSupported added in v0.4.0

func FastEngineSupported() (bool, string)

FastEngineSupported reports whether this machine can run the lightweight engine, and why not when it cannot.

func FindBrowserBinary

func FindBrowserBinary(configured string) (string, error)

FindBrowserBinary locates a Chromium-family binary: first on PATH, then in the fixed locations PATH never covers — where macOS and Windows keep their browsers, and where Factor installs the one it provisions itself.

func NewTools

func NewTools(cfg config.BrowserConfig, workspace string) ([]tools.Tool, func())

NewTools returns the browser tool suite sharing one session.

func Verify added in v0.4.0

func Verify(ctx context.Context, cfg config.BrowserConfig) error

Verify launches the configured browser and drives one round-trip through it, so `factor init` can report a browser that actually works rather than one that merely exists on disk. Every other wizard step checks itself the same way.

Types

type Progress added in v0.4.0

type Progress func(format string, args ...any)

Progress reports provisioning steps to whoever is watching (the wizard prints them; the gateway logs them).

type Session

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

Session lazily owns one browser connection shared by all browser tools.

func NewSession

func NewSession(cfg config.BrowserConfig, workspace string) *Session

func (*Session) Close

func (s *Session) Close()

Close shuts the managed browser down.

Jump to

Keyboard shortcuts

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