Documentation
¶
Overview ¶
Package browser provides a CDP-backed browser session for agent tools.
Index ¶
- func AssertNavigateURL(raw string, allowPrivate bool, allowHosts []string) error
- func WithSession(ctx context.Context, s *Session) context.Context
- type Config
- type Driver
- type Quirks
- type Session
- func (s *Session) Click(ctx context.Context, ref string) error
- func (s *Session) Close() error
- func (s *Session) Config() Config
- func (s *Session) Navigate(ctx context.Context, rawURL string) (string, error)
- func (s *Session) Screenshot(ctx context.Context) ([]byte, error)
- func (s *Session) Scroll(ctx context.Context, dx, dy int) error
- func (s *Session) Snapshot(ctx context.Context) (string, error)
- func (s *Session) Type(ctx context.Context, ref, text string) error
- func (s *Session) Wait(ctx context.Context, ms int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertNavigateURL ¶
AssertNavigateURL validates a navigation target against SSRF policy. allow_hosts is an explicit exception list. When allowPrivate is true, RFC1918 private addresses are permitted, but loopback, link-local, and cloud-metadata hosts remain blocked unless listed in allow_hosts.
Types ¶
type Config ¶
type Config struct {
Driver Driver
Endpoint string
AllowPrivate bool
AllowHosts []string
Timeout time.Duration
}
Config configures a browser session.
type Driver ¶
type Driver string
Driver selects CDP backend quirks.
const ( // DriverLightpanda is the Lightpanda headless browser CDP server. DriverLightpanda Driver = "lightpanda" // DriverPlaywright is Chromium exposed via remote-debugging CDP // (compose profile playwright-cdp), not the Playwright Test runner. DriverPlaywright Driver = "playwright" // MaxScreenshotBytes caps PNG bytes returned by Screenshot. MaxScreenshotBytes = 2 << 20 )
type Quirks ¶
type Quirks struct {
PreferNetworkIdle bool
}
Quirks holds per-driver capability differences.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a per-run isolated browser context with serialized operations.
func FromContext ¶
FromContext returns the Session attached to ctx, if any.
func NewSession ¶
NewSession creates a lazy session. CDP connects on first operation.
func (*Session) Screenshot ¶
Screenshot captures a PNG of the current page.