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
- Variables
- func AppArmor() bool
- func Bypass() bool
- func Chosen(cfg *config.Config) (string, bool)
- func DevToolsTransport(env httpx.Env) *http.Transport
- func Docker() bool
- func Headless(exe string) bool
- func Holder(profile string) (int, bool)
- func Locate(name string) string
- func MergeFeatures(argv []string) []string
- func NamesProfile(pid int, profile string) bool
- func Pinned(cfg *config.Config) string
- func ProfileDir(cfg *config.Config) string
- func QuietArgs() []string
- func Release(ctx context.Context, env httpx.Env, title, method, url, shown, id string, ...) bool
- func Released(status int) bool
- func RunningOn(profile string) bool
- func SameProfile(a, b string) bool
- func Seed(userDataDir string, owned bool) error
- func SeedRemote(userDataDir string, owned bool, run Runner) error
- func SessionName(task string) string
- type Browser
- func (b *Browser) Cloud(cfg *config.Config) (*Provider, error)
- func (b *Browser) Executable(cfg *config.Config, override bool) string
- func (b *Browser) Halt(cfg *config.Config, key string)
- func (b *Browser) Holder(cfg *config.Config, task string) *Page
- func (b *Browser) Launch(ctx context.Context, cfg *config.Config, launch Launch) (*Launched, error)
- func (b *Browser) Launches() bool
- func (b *Browser) Managed() string
- func (b *Browser) MissingHint(cfg *config.Config) string
- func (b *Browser) Places(ctx context.Context, cfg *config.Config) []Place
- func (b *Browser) Provider(name string) (Provider, bool)
- func (b *Browser) Register(registrant Registrant)
- func (b *Browser) Resolved(cfg *config.Config) string
- func (b *Browser) Shipped() (string, bool)
- func (b *Browser) Unbuilt() bool
- type Declared
- type DevTools
- func (d *DevTools) Alive() bool
- func (d *DevTools) Call(ctx context.Context, method string, params any, session string) (json.RawMessage, error)
- func (d *DevTools) Close()
- func (d *DevTools) Done() <-chan struct{}
- func (d *DevTools) On(fn func(Event)) func()
- func (d *DevTools) Within(method string, params any, session string, timeout time.Duration) (json.RawMessage, error)
- type Event
- type Key
- type Launch
- type Launched
- type Launcher
- type Live
- type Page
- type Place
- type ProtocolError
- type Provider
- type Registrant
- type Registry
- type Reply
- type Runner
- type Session
- type SocketError
- type UnknownError
Constants ¶
const ( Here = "On this computer" InCloud = "Cloud services" OwnTools = "Browsers with tools of their own" )
Groups of places, in the words of their headings
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
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
const Chromium = "chromium"
Name of the package of the Chromium icebath ships
Variables ¶
var BypassArgs = []string{"--no-sandbox", "--disable-dev-shm-usage"}
Flags that start Chromium where its sandbox cannot work, shared with the Bot Desktop dock
var ErrClosed = errors.New("CDP connection closed before reply")
A command whose connection dropped before its reply
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 DevToolsTransport ¶
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 Holder ¶
Browser process, never one of its --type helpers, whose command line names the profile folder; false when none runs on it
func Locate ¶
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 ¶
Argv with every --disable-features and every --enable-features joined into one switch each, at the place of its first
func NamesProfile ¶
Whether the process's command line names the profile folder with --user-data-dir, however either is spelled
func Pinned ¶
Program browser.executable_path pins, ~ and the variables of the profile's environment expanded, empty for none
func ProfileDir ¶
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 Seed ¶
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 ¶
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 ¶
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 (*Browser) Cloud ¶
Cloud returns the cloud service that opens pages, or nil for this computer. Under Automatic it returns the first service with a held key.
func (*Browser) Executable ¶
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) Launch ¶
Starts a Chromium of this machine for a feature, through the launcher of the browser tools
func (*Browser) MissingHint ¶
One line saying what to do on a machine without Chromium, never suggesting npm
func (*Browser) Places ¶
Every place pages can open for the profile, this computer first, each with how it stands
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 ¶
Chromium that runs on disk, the pin found on PATH when it is a bare name; empty when there is none
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 (*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
type Event ¶
type Event struct {
Method string
Params json.RawMessage
SessionID string
}
One protocol event and the flattened session it fired on
type Key ¶
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 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 Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func (*Registry) Live ¶
Services and page holders the live registrants bring the profile now, those of the registries nested in this one among them
func (*Registry) Of ¶
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) Register ¶
func (r *Registry) Register(registrant Registrant)
type Reply ¶
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
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