browser

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 30 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

The browser the agent drives: the cloud browser services plugins bring, the browsers that hold pages of their own, such as Camofox, and the Chromium of this machine that the browser tools and the agent desktop start

Index

Constants

View Source
const (
	Here     = "On this computer"
	InCloud  = "Cloud services"
	OwnTools = "Browsers with tools of their own"
)

Groups of places, in the words of their headings

View Source
const (
	Ready     = "Ready"
	NeedsKey  = "Needs an API key"
	NeedsMore = "Needs setup"
	Silent    = "Not answering"
)

States of a place pages open, in the words every page and command says them in

View Source
const Baked = "/etc/icebath/chromium-executable-path"

File the image of icebath writes the program of the Chromium it laid out at build into, which the image pins

View Source
const Chromium = "chromium"

Name of the package of the Chromium icebath ships

Variables

View Source
var BypassArgs = []string{"--no-sandbox", "--disable-dev-shm-usage"}

Flags that start Chromium where its sandbox cannot work, shared with the Bot Desktop dock

View Source
var ErrClosed = errors.New("CDP connection closed before reply")

A command whose connection dropped before its reply

View Source
var LocalDevTools = &http.Transport{Proxy: nil, IdleConnTimeout: 30 * time.Second, MaxIdleConnsPerHost: 2, DialContext: httpx.Dial}

Transport of the DevTools endpoints of this machine, never through a proxy

Functions

func AppArmor

func AppArmor() bool

Whether Ubuntu's default denies unprivileged user namespaces, so a Chromium sandbox that is not setuid dies

func Bypass

func Bypass() bool

Whether Chromium needs its sandbox off to start here: as root, in Docker, or under the AppArmor user namespace rule

func Chosen

func Chosen(cfg *config.Config) (string, bool)

Service the profile chose, lower case, and whether it chose one at all

func DevToolsTransport

func DevToolsTransport(env httpx.Env) *http.Transport

Transport of DevTools requests made in the environment, such as a profile's: its proxy for every host but loopback, which a local browser always is, and the authorities it trusts, shared by every environment that sets the same

func Docker

func Docker() bool

Whether icebath runs inside a Docker container

func Headless

func Headless(exe string) bool

Whether a build cannot open a window, as Playwright's headless shell

func Holder

func Holder(profile string) (int, bool)

Browser process, never one of its --type helpers, whose command line names the profile folder; false when none runs on it

func Locate

func Locate(name string) string

Program a name is: an explicit path, ~ expanded, when it is absolute and runs; else the one found on PATH; empty for none

func MergeFeatures

func MergeFeatures(argv []string) []string

Argv with every --disable-features and every --enable-features joined into one switch each, at the place of its first

func NamesProfile

func NamesProfile(pid int, profile string) bool

Whether the process's command line names the profile folder with --user-data-dir, however either is spelled

func Pinned

func Pinned(cfg *config.Config) string

Program browser.executable_path pins, ~ and the variables of the profile's environment expanded, empty for none

func ProfileDir

func ProfileDir(cfg *config.Config) string

Profile folder browser.user_data_dir keeps for every session, ~ expanded; empty for none

func QuietArgs

func QuietArgs() []string

Switches every agent Chromium starts with, the features as one --disable-features

func Release

func Release(ctx context.Context, env httpx.Env, title, method, url, shown, id string, headers map[string]string, body any) bool

Releases a session of a service through the environment's proxy, saying how it went in the log, whether it closed. Shown is the address as the log tells it, its start as the settings write it, the address itself where no setting writes it with a reference

func Released

func Released(status int) bool

Whether a release answer closed the session

func RunningOn

func RunningOn(profile string) bool

Whether a browser runs on the profile folder

func SameProfile

func SameProfile(a, b string) bool

Whether two spellings name one profile folder

func Seed

func Seed(userDataDir string, owned bool) error

Writes the quiet preferences into the profile files of a user data dir on this machine, through a temp file and a rename; owned for a profile of the agent's own, which also has browser sign in off

func SeedRemote

func SeedRemote(userDataDir string, owned bool, run Runner) error

Writes the quiet preferences into the profile files of a user data dir inside a sandbox or on a remote machine, through run

func SessionName

func SessionName(task string) string

Label of a cloud session in the logs, unique to it

Types

type Browser

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

Cloud services, page holders and the Chromium of this machine

func New

func New(cfg *config.Config, pm *packages.Packages) *Browser

func (*Browser) Cloud

func (b *Browser) Cloud(cfg *config.Config) (*Provider, error)

Cloud service pages open in for the profile, nil for this machine: the one it chose, local or a browser holding pages of its own keeping them here; left unchosen, the first service its keys alone pick

func (*Browser) Executable

func (b *Browser) Executable(cfg *config.Config, override bool) string

Chromium to run: the program of the settings when it may override; in the image the Chromium the image pins and no other, never one fetched or put in its place while the container runs; else the package manager's, then a distribution's where the package manager builds none; empty when there is none

func (*Browser) Halt

func (b *Browser) Halt(cfg *config.Config, key string)

Stops the Chromium a feature started under the key

func (*Browser) Holder

func (b *Browser) Holder(cfg *config.Config, task string) *Page

Holder of the task's live page, nil when the DevTools session holds it

func (*Browser) Launch

func (b *Browser) Launch(ctx context.Context, cfg *config.Config, launch Launch) (*Launched, error)

Starts a Chromium of this machine for a feature, through the launcher of the browser tools

func (*Browser) Launches

func (b *Browser) Launches() bool

Whether something in this icebath starts Chromium for features

func (*Browser) Managed

func (b *Browser) Managed() string

Chromium the package manager installed, empty when it has not

func (*Browser) MissingHint

func (b *Browser) MissingHint(cfg *config.Config) string

One line saying what to do on a machine without Chromium, never suggesting npm

func (*Browser) Places

func (b *Browser) Places(ctx context.Context, cfg *config.Config) []Place

Every place pages can open for the profile, this computer first, each with how it stands

func (*Browser) Provider

func (b *Browser) Provider(name string) (Provider, bool)

Cloud service of the name

func (*Browser) Register

func (b *Browser) Register(registrant Registrant)

Adds a registrant; a registry nested in the host reaches it through Host

func (*Browser) Resolved

func (b *Browser) Resolved(cfg *config.Config) string

Chromium that runs on disk, the pin found on PATH when it is a bare name; empty when there is none

func (*Browser) Shipped

func (b *Browser) Shipped() (string, bool)

Chromium the image of icebath pins, the one it was built with, and whether it pins one: empty while it is missing from the image

func (*Browser) Unbuilt

func (b *Browser) Unbuilt() bool

Whether the package manager builds no Chromium for this machine

type Declared

type Declared struct {
	Services []Provider
	Holders  []Page
}

Services and page holders fixed once they are registered

func (Declared) Pages

func (d Declared) Pages() []Page

func (Declared) Providers

func (d Declared) Providers() []Provider

type DevTools

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

Commands and events of the DevTools protocol over one websocket, which the browser tools and every feature that drives a Chromium of its own speak through

func Dial

func Dial(ctx context.Context, env httpx.Env, endpoint string, maxMessage int64) (*DevTools, error)

Connects to a DevTools websocket in the environment and starts reading it

func (*DevTools) Alive

func (d *DevTools) Alive() bool

Whether the connection still reads

func (*DevTools) Call

func (d *DevTools) Call(ctx context.Context, method string, params any, session string) (json.RawMessage, error)

Sends one command, on the flattened session when given, and waits for its reply

func (*DevTools) Close

func (d *DevTools) Close()

Closes the connection and waits for its reader to end

func (*DevTools) Done

func (d *DevTools) Done() <-chan struct{}

Closed once the connection stopped reading

func (*DevTools) On

func (d *DevTools) On(fn func(Event)) func()

Adds an event handler and answers its removal

func (*DevTools) Within

func (d *DevTools) Within(method string, params any, session string, timeout time.Duration) (json.RawMessage, error)

Command under a deadline of its own

type Event

type Event struct {
	Method    string
	Params    json.RawMessage
	SessionID string
}

One protocol event and the flattened session it fired on

type Key

type Key struct {
	Env, Prompt, URL string
	Setting          string
}

One key a cloud service reads, by the variable that holds it, and the setting that keeps it, which the variable sets over

type Launch

type Launch struct {
	// Names the browser among the launches of this process: a launch under a key whose browser runs answers that browser
	Key string
	// Profile folder kept between launches, such as one a person signed in to; a throwaway one made for the launch when empty
	Folder string
	// The window shows where the computer has a display
	Headed bool
	// Flags beside those every launch takes
	Args []string
	// Variables of the environment Chromium runs in over the profile's own
	Env map[string]string
	// Longest the start may take, the browser's own limit when zero
	Timeout time.Duration
}

What starts a Chromium of this machine for a feature's own work, such as a meeting bot's, beside the browsers of the browser tools

type Launched

type Launched struct {
	Endpoint string
	PID      int
}

A Chromium started for a feature: where its DevTools answer, and its process

type Launcher

type Launcher interface {
	Launch(ctx context.Context, cfg *config.Config, launch Launch) (*Launched, error)
	// Stops the Chromium of the key, a kept profile folder left as it is
	Halt(cfg *config.Config, key string)
}

Registrant that starts Chromium for other features, the browser tools, whose launcher keeps, reaps and stops every Chromium of this machine; one that only brings this ability implements Providers and Pages returning nil

type Live

type Live interface {
	Registrant
	Live(profile string) ([]Provider, []Page)
}

Registrant whose services and page holders come and go as it runs, such as those the extensions of a profile bring: its Providers and Pages have none, and those it brings a profile are listed again on every read, which reads no setting and starts nothing

type Page

type Page struct {
	Name, Title string
	// Key of the section of its own settings, empty for none
	Section string
	// Whether it holds a live page for the task, never opening one
	Has func(cfg *config.Config, task string) bool
	// Runs the script on the task's page and answers its value; a secret script goes only where nothing between can read it
	Evaluate func(ctx context.Context, cfg *config.Config, task, script string, secret bool) (any, error)
	// How it stands in the state words, whether pages can open there, and the address a person watches its browser at; Ready when nil
	State func(ctx context.Context, cfg *config.Config) (state, watch string, ready bool)
}

A browser that holds pages of its own outside the DevTools session, such as a Camofox server, on whose page of a task the vault fills what the user saved

type Place

type Place struct {
	Name, Title, About, Section string
	// Heading it is listed under, one of the groups of places
	Group string
	// Its state in the state words, and whether pages can open there now
	State string
	Ready bool
	// Pages open there now
	Chosen bool
	// Address a person watches its browser at, empty when it shows none
	Watch string
	// Settings that keep its keys, outside its own section
	Keys []string
	// What a person pays for its browsers, whole sentences, empty when it says nothing
	Cost string
}

A place pages can open as the profile sees it: this computer, a cloud service or a browser holding pages of its own

type ProtocolError

type ProtocolError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    string `json:"data,omitempty"`
}

A protocol error reply to one command

func (*ProtocolError) Error

func (e *ProtocolError) Error() string

type Provider

type Provider struct {
	// Value of browser.cloud_provider that picks it
	Name  string
	Title string
	// What it offers, for the picker
	About string
	// Key of the section of its own settings, empty for none
	Section string
	// Variables it reads its keys from, and where to get them
	Keys []Key
	// Picked by its keys alone when the profile chose no service, the lowest first; zero never
	Detect int
	// Whether the profile has what it needs, such as its keys
	Available func(cfg *config.Config) bool
	// Opens a browser for the task
	Create func(ctx context.Context, cfg *config.Config, task string) (*Session, error)
	// Closes the browser of the id, false when it could not
	Close func(ctx context.Context, cfg *config.Config, id string) bool
	// What a person pays for its browsers, whole sentences, such as "Browsers cost about $0.10 for each hour they run."; empty when it says
	// nothing
	Cost string
	// How it stands in the state words, whether browsers can open there now, and the address a person watches its browser at, such as the
	// live view of the session open now; Ready as its keys have it when nil
	State func(ctx context.Context, cfg *config.Config) (state, watch string, ready bool)
}

A cloud browser service: browsers on its machines the browser tools drive over the DevTools protocol, picked by browser.cloud_provider

type Registrant

type Registrant interface {
	Providers() []Provider
	Pages() []Page
}

type Registry

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

func (*Registry) Host

func (r *Registry) Host() *Browser

Host the registry is nested in

func (*Registry) Live

func (r *Registry) Live(profile string) ([]Provider, []Page)

Services and page holders the live registrants bring the profile now, those of the registries nested in this one among them

func (*Registry) Of

func (r *Registry) Of(cfg *config.Config) ([]Provider, []Page)

Services and page holders fixed once they are registered, then those the live registrants bring the profile of the settings now, one of a name a fixed one or this computer has left out

func (*Registry) Pages

func (r *Registry) Pages() []Page

func (*Registry) Providers

func (r *Registry) Providers() []Provider

func (*Registry) Register

func (r *Registry) Register(registrant Registrant)

type Reply

type Reply struct {
	Status int
	Body   []byte
}

What a cloud service answered: its status and body

func Call

func Call(ctx context.Context, env httpx.Env, method, url string, headers map[string]string, body any, timeout time.Duration) (*Reply, error)

Answers a cloud browser service's API with a JSON body, nil sending none, within the timeout and through the proxy and authorities of the environment, the profile's

func (*Reply) OK

func (r *Reply) OK() bool

Whether the service took the call

type Runner

type Runner func(argv []string, stdin []byte) ([]byte, int, error)

Runs argv with stdin where the profile lives, answering stdout and the exit code

type Session

type Session struct {
	// Id the service closes it by
	ID string
	// Label of it in the logs
	Name string
	// DevTools endpoint the tools drive it through
	CDP string
	// When the service ends it, zero for no set end
	Expires time.Time
	// What the service turned on for it, such as proxies or stealth
	Features map[string]bool
}

A browser a cloud service opened for a task

type SocketError

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

A websocket failure: the connection dropped, was refused or never finished its handshake

func (*SocketError) Error

func (e *SocketError) Error() string

func (*SocketError) Unwrap

func (e *SocketError) Unwrap() error

type UnknownError

type UnknownError struct{ Name string }

Error of a browser.cloud_provider naming a service no plugin brings

func (*UnknownError) Error

func (e *UnknownError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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