Documentation
¶
Overview ¶
Package browser drives a Chromium, Lightpanda, cloud, or attached browser over the Chrome DevTools Protocol
Index ¶
- Constants
- Variables
- func AtexitCleanup(ctx context.Context)
- func BeginVaultUnlock(ctx context.Context, backend string) int
- func BrowserCDPSchema() *pyjson.Object
- func BrowserCommand(ctx context.Context, env *tools.Env, ns map[string]any, w io.Writer) (int, error)
- func BrowserDialogSchema() *pyjson.Object
- func BrowserExecSchema() *pyjson.Object
- func BrowserExecSchemaOverrides(env *tools.Env) *pyjson.Object
- func BrowserPageBackendScopedRegistry() plugins.ScopedRegistry
- func BrowserProviderScopedRegistry() plugins.ScopedRegistry
- func BrowserVaultSchema() *pyjson.Object
- func BuildFillJS(fills []*pyjson.Object, expectedOrigin, nonce string) string
- func BuildInspectionJS(nonce string) string
- func BuildOTPFills(otpControls []ClassifiedLoginControl, code string) []*pyjson.Object
- func CDPOverrideRaw(env *tools.Env) string
- func CanPromptVaultHere(ctx context.Context, env *tools.Env) bool
- func ChromeDebugDataDir(ctx context.Context) string
- func ChromiumExecutable(env *tools.Env, allowOverride bool) string
- func ChromiumMissingHint(env *tools.Env) string
- func ClaimPrivateDir(path string) bool
- func CleanupAllBrowsers(ctx context.Context, env *tools.Env)
- func CleanupProfileBrowsers(ctx context.Context, env *tools.Env, homeKey string) error
- func DaemonIdentity(env map[string]string) [5]string
- func DiscoverLocalCDPURL(ctx context.Context, port int, timeout time.Duration) string
- func EmergencyCleanupAllSessions(ctx context.Context)
- func FindFreeDebugPort(preferred, attempts int) int
- func FindLightpandaBinary(env *tools.Env) string
- func FitDefaultSocketDir(env map[string]string) error
- func FitsSocketBudget(resolvedDir string, budget *int) bool
- func GetChromeDebugCandidates(system string) []string
- func IsBrowserDebugReady(ctx context.Context, rawURL string, timeout time.Duration) bool
- func IsLoginBackendEnabled(ctx context.Context, name string) (bool, error)
- func IsLoginBackendInstalled(ctx context.Context, name string) (bool, error)
- func IsVaultUnlocked(ctx context.Context, backend string) bool
- func LightpandaEngineStatus(env *tools.Env) (bool, string)
- func LiveCDPGeneration(homeKey string) int
- func LiveCDPOverride(homeKey string) string
- func LocalPortInUse(port int, timeout time.Duration) bool
- func LockAllVaultProfiles()
- func LockVault(ctx context.Context, backend *string)
- func LoginBackendScopedRegistry() plugins.ScopedRegistry
- func ManualChromeDebugCommand(ctx context.Context, port int, system string) string
- func NamespaceHarnessDirs(env map[string]string, tag string) error
- func PrivateUserRuntimeDir() string
- func RegisterLoginBackendProvider(ctx context.Context, provider LoginBackend, scope string) error
- func ReleaseVaultSession(sessionID string)
- func ResetLoginBackendRegistryForTests()
- func ResolveCDPOverride(ctx context.Context, cdpURL string) string
- func RunWithSecretEnv(argv []string, env map[string]string, secretEnv, secret string, ...) (provider.CLIResult, error)
- func RunWithStdinSecret(argv []string, env map[string]string, secret string, timeout time.Duration, ...) (provider.CLIResult, error)
- func RunningInstance(userDataDir string) (int, string, int, bool)
- func SelectCheckoutFills(classified []ClassifiedLoginControl, secret map[string]string, ...) []*pyjson.Object
- func SelectPasswordFill(classified []ClassifiedLoginControl, password string) []*pyjson.Object
- func SetLiveCDPOverride(homeKey, cdpURL string)
- func SocketDirBudget(platform string) *int
- func SocketFitRuntimeDir(runtimeDir, base, tag string) (string, error)
- func StaticLoginBackendName(provider any) (string, error)
- func StopBrowser(ctx context.Context, key string)
- func StoreVaultSessionToken(ctx context.Context, backend, token string, generation *int) bool
- func UsingLightpandaEngine(env *tools.Env) bool
- func VaultCommand(ctx context.Context, h string, ns map[string]any, w io.Writer) (code int, err error)
- func VaultSessionToken(ctx context.Context, backend string) (string, bool)
- type BitwardenLoginBackend
- func (*BitwardenLoginBackend) DisplayName() string
- func (b *BitwardenLoginBackend) GetMeta(handle string) (*vault.VaultItemMeta, error)
- func (b *BitwardenLoginBackend) IsUnlocked() bool
- func (b *BitwardenLoginBackend) ListItems() ([]vault.VaultItemMeta, error)
- func (*BitwardenLoginBackend) Name() string
- func (*BitwardenLoginBackend) NeedsUnlock() bool
- func (*BitwardenLoginBackend) Prefix() string
- func (b *BitwardenLoginBackend) ResolveOTP(handle string) (string, bool, error)
- func (b *BitwardenLoginBackend) ResolvePassword(handle string) (string, error)
- func (b *BitwardenLoginBackend) Unlock(masterPassword string) error
- type BrowserPageBackend
- type BrowserProvider
- type BrowserUseBrowserProvider
- type BrowserbaseBrowserProvider
- type CDPConn
- func (c *CDPConn) Alive() bool
- func (c *CDPConn) Attach(ctx context.Context, targetID string) (string, error)
- func (c *CDPConn) Call(ctx context.Context, method string, params any, sessionID string) (json.RawMessage, error)
- func (c *CDPConn) CallInto(ctx context.Context, method string, params any, sessionID string, out any) error
- func (c *CDPConn) CallTimeout(method string, params any, sessionID string, timeout time.Duration) (json.RawMessage, error)
- func (c *CDPConn) Close() error
- func (c *CDPConn) CreateTarget(ctx context.Context, url string, background bool) (string, error)
- func (c *CDPConn) Detach(ctx context.Context, sessionID string) error
- func (c *CDPConn) Done() <-chan struct{}
- func (c *CDPConn) Err() error
- func (c *CDPConn) OnEvent(fn func(CDPEvent)) func()
- func (c *CDPConn) Targets(ctx context.Context) ([]TargetInfo, error)
- func (c *CDPConn) URL() string
- type CDPError
- type CDPEvent
- type ChromeDebugLaunch
- type ClassifiedLoginControl
- type CloudBrowserProvider
- func (p *CloudBrowserProvider) CloseSession(env *tools.Env, sessionID string) bool
- func (p *CloudBrowserProvider) DisplayName() string
- func (p *CloudBrowserProvider) EmergencyCleanup(env *tools.Env, sessionID string)
- func (p *CloudBrowserProvider) GetSetupSchema() map[string]any
- func (p *CloudBrowserProvider) IsAvailable(env *tools.Env) bool
- func (p *CloudBrowserProvider) Name() string
- type DialogRecord
- type ErrWSClosed
- type FirecrawlBrowserProvider
- type FrameInfo
- type LaunchAttempt
- type LaunchOptions
- type LaunchedBrowser
- type LightpandaServer
- type LocalLoginBackend
- func (*LocalLoginBackend) DisplayName() string
- func (b *LocalLoginBackend) GetMeta(handle string) (*vault.VaultItemMeta, error)
- func (b *LocalLoginBackend) ListItems() ([]vault.VaultItemMeta, error)
- func (*LocalLoginBackend) Name() string
- func (*LocalLoginBackend) Prefix() string
- func (b *LocalLoginBackend) ResolveOTP(handle string) (string, bool, error)
- func (b *LocalLoginBackend) ResolvePassword(handle string) (string, error)
- func (b *LocalLoginBackend) ResolveSecret(handle string) (map[string]string, error)
- type LoginBackend
- func EnabledLoginBackends(ctx context.Context) ([]LoginBackend, error)
- func EnabledPluginLoginBackends(ctx context.Context, cfg map[string]any) []LoginBackend
- func LoginBackendForHandle(ctx context.Context, handle string) (LoginBackend, error)
- func LoginBackendProvider(ctx context.Context, name, scope string) LoginBackend
- func NewBitwardenLoginBackend(ctx context.Context, cfg map[string]any) LoginBackend
- func NewOnePasswordLoginBackend(ctx context.Context, cfg map[string]any) LoginBackend
- type LoginBackendDefaults
- func (LoginBackendDefaults) FillContext() (func() error, error)
- func (LoginBackendDefaults) IsUnlocked() bool
- func (LoginBackendDefaults) NeedsUnlock() bool
- func (d LoginBackendDefaults) Owns(handle string) bool
- func (LoginBackendDefaults) ResolveOTP(string) (string, bool, error)
- func (d LoginBackendDefaults) ResolveSecret(handle string) (map[string]string, error)
- type LoginControl
- type OnePasswordLoginBackend
- func (*OnePasswordLoginBackend) DisplayName() string
- func (b *OnePasswordLoginBackend) GetMeta(handle string) (*vault.VaultItemMeta, error)
- func (b *OnePasswordLoginBackend) IsUnlocked() bool
- func (b *OnePasswordLoginBackend) ListItems() ([]vault.VaultItemMeta, error)
- func (*OnePasswordLoginBackend) Name() string
- func (*OnePasswordLoginBackend) NeedsUnlock() bool
- func (*OnePasswordLoginBackend) Prefix() string
- func (b *OnePasswordLoginBackend) ResolveOTP(handle string) (string, bool, error)
- func (b *OnePasswordLoginBackend) ResolvePassword(handle string) (string, error)
- func (b *OnePasswordLoginBackend) Unlock(masterPassword string) error
- type PendingDialog
- type PluginBackendError
- type PluginLoginBackend
- func (b *PluginLoginBackend) DisplayName() string
- func (b *PluginLoginBackend) FillContext() (func() error, error)
- func (b *PluginLoginBackend) GetMeta(handle string) (*vault.VaultItemMeta, error)
- func (b *PluginLoginBackend) IsUnlocked() bool
- func (b *PluginLoginBackend) ListItems() ([]vault.VaultItemMeta, error)
- func (b *PluginLoginBackend) Name() string
- func (b *PluginLoginBackend) NeedsUnlock() bool
- func (b *PluginLoginBackend) Owns(handle string) bool
- func (b *PluginLoginBackend) Prefix() string
- func (b *PluginLoginBackend) ResolveOTP(handle string) (string, bool, error)
- func (b *PluginLoginBackend) ResolvePassword(handle string) (string, error)
- func (b *PluginLoginBackend) ResolveSecret(handle string) (map[string]string, error)
- type SupervisorSnapshot
- type TargetInfo
- type UnlockRequired
- type WSConn
- func (c *WSConn) Close(code int, reason string) error
- func (c *WSConn) ForceClose()
- func (c *WSConn) Ping(ctx context.Context, payload []byte) error
- func (c *WSConn) ReadMessage(ctx context.Context) (byte, []byte, error)
- func (c *WSConn) SendClose(code int, reason string) error
- func (c *WSConn) URL() string
- func (c *WSConn) WriteBinary(ctx context.Context, payload []byte) error
- func (c *WSConn) WriteText(ctx context.Context, payload []byte) error
- type WSOptions
Constants ¶
const ( // DefaultBrowserCDPPort is the remote debugging port /browser connect probes and launches on DefaultBrowserCDPPort = 9222 // DefaultBrowserCDPURL is the local CDP endpoint /browser connect uses without an argument DefaultBrowserCDPURL = "http://127.0.0.1:9222" )
const ( DialogPolicyMustRespond = "must_respond" DialogPolicyAutoDismiss = "auto_dismiss" DialogPolicyAutoAccept = "auto_accept" DefaultDialogPolicy = DialogPolicyMustRespond DefaultDialogTimeoutS = 300.0 )
Dialog policies the supervisor accepts
const ( CloseNormal = 1000 CloseGoingAway = 1001 CloseProtocolError = 1002 CloseUnsupportedData = 1003 CloseMessageTooBig = 1009 )
Close status codes used by the client
const InspectionStampAttr = "data-icebath-vault-slot"
Attribute each inspection stamps on every input as nonce and index
const LightpandaInstallHint = lightpandaInstallHint
Install line the doctor prints when the Lightpanda engine is selected without a binary
const NativeVisionValueKey = "vision.native"
Env.Values key the agent runtime sets to a bool saying screenshots may ride inside tool results
const Toolset = "browser"
Toolset every browser tool registers under
const UnsupportedChannel = "__unsupported_channel__"
Sentinel for a recognized Chromium pre release channel default, distinct from no Chromium default
Variables ¶
var BrowserPageBackendRegistry = provider.NewProviderRegistry[BrowserPageBackend](provider.ProviderRegistryOptions{
Label: "Browser page backend", Logger: pkgLog()})
Browser page backends plugins register, consumed by browser_vault before the CDP session
var BrowserProviderRegistry = provider.NewProviderRegistry[BrowserProvider](provider.ProviderRegistryOptions{Label: "Browser", Logger: pkgLog()})
Cloud browser providers plugins register, consumed by the cloud provider selection
var ErrCDPClosed = errors.New("CDP connection closed before reply")
ErrCDPClosed reports a command whose connection dropped before its reply
var HarnessDirKeys = [4]string{"BH_RUNTIME_DIR", "BH_RUNTIME_DIR_SHARED", "BH_TMP_DIR", "BH_TMP_DIR_SHARED"}
Env keys that with BU_NAME identify one harness daemon
Functions ¶
func AtexitCleanup ¶
Process exit sweep, every session closed and the janitor stopped, which the binary's shutdown path calls
func BeginVaultUnlock ¶
Lock generation snapshot taken before spawning the manager CLI, passed to StoreVaultSessionToken
func BrowserCommand ¶
func BrowserCommand(ctx context.Context, env *tools.Env, ns map[string]any, w io.Writer) (int, error)
BrowserCommand runs icebath browser, close-profile ending the browser that holds the real profile
func BrowserExecSchema ¶
Static browser_exec schema, its description tailored per session by the overrides
func BrowserExecSchemaOverrides ¶
Session tailored description, plus the local parameter only when real profile browsing is consented
func BrowserPageBackendScopedRegistry ¶
func BrowserPageBackendScopedRegistry() plugins.ScopedRegistry
Plugin facing registry that register_browser_page_backend writes into, a plugin host object stored as the backend adapted from it
func BrowserProviderScopedRegistry ¶
func BrowserProviderScopedRegistry() plugins.ScopedRegistry
Plugin facing registry that register_browser_provider writes into, a plugin host object stored as the provider adapted from it
func BrowserVaultSchema ¶
func BuildFillJS ¶
Page script that asserts the origin then fills the stamped controls and reports only a count
func BuildInspectionJS ¶
Page script that stamps every input with the nonce and reports the visible controls
func BuildOTPFills ¶
func BuildOTPFills(otpControls []ClassifiedLoginControl, code string) []*pyjson.Object
One fill per adjacent single character box of one form, else the best field takes the whole code
func CDPOverrideRaw ¶
Configured CDP override with no network I/O, the live connect then BROWSER_CDP_URL then browser.cdp_url
func CanPromptVaultHere ¶
False where no human can answer, cron, webhook, api_server and single query sessions
func ChromeDebugDataDir ¶
Profile directory of the debug browser under the icebath home
func ChromiumExecutable ¶
Chromium binary the launcher would run, the configured override honoured when allowed
func ChromiumMissingHint ¶
One actionable line for a machine without Chromium that never suggests npm
func ClaimPrivateDir ¶
Creates the dir 0700, or accepts an existing real directory of this uid closed to group and other
func CleanupAllBrowsers ¶
Closes every live browser session so the next tool call picks up the current backend
func CleanupProfileBrowsers ¶
Closes one profile home's sessions, supervisors and harness daemons and drops its cached config
func DaemonIdentity ¶
Harness dir values then BU_NAME of the daemon a call with env drives
func DiscoverLocalCDPURL ¶
DiscoverLocalCDPURL returns the first loopback URL on the port speaking CDP, empty when none does
func EmergencyCleanupAllSessions ¶
Closes this process's browser sessions then reaps orphans of crashed processes, once per process
func FindFreeDebugPort ¶
First port after preferred bindable on both loopbacks, preferred plus one when none binds
func FindLightpandaBinary ¶
Lightpanda binary found on PATH or in a known install directory, empty when absent
func FitDefaultSocketDir ¶
Moves a default runtime dir whose socket for the call's BU_NAME overflows sun_path to a private short dir
func FitsSocketBudget ¶
True when a 64 character session socket under the resolved dir fits the budget, always without one
func GetChromeDebugCandidates ¶
Existing debug browser binaries deduplicated by normalized path, first seen kept
func IsBrowserDebugReady ¶
IsBrowserDebugReady reports whether a URL exposes a reachable DevTools endpoint
func IsLoginBackendEnabled ¶
An installed manager is a login source unless the profile set vault.<name>.enabled to false
func IsLoginBackendInstalled ¶
Whether the manager CLI is reachable, a configured binary_path honoured over PATH
func IsVaultUnlocked ¶
Status probe that leaves the idle timer alone
func LightpandaEngineStatus ¶
Whether the Lightpanda engine is in effect and the setting shadowing it otherwise
func LiveCDPGeneration ¶
LiveCDPGeneration counts the home's live endpoint publishes
func LiveCDPOverride ¶
LiveCDPOverride is the home's /browser connect endpoint, empty when none is published
func LocalPortInUse ¶
LocalPortInUse reports whether either loopback accepts TCP on the port
func LockAllVaultProfiles ¶
func LockAllVaultProfiles()
Drops every token of every profile at process shutdown
func LockVault ¶
Forgets the current profile's session for one backend, or all of them when backend is nil
func LoginBackendScopedRegistry ¶
func LoginBackendScopedRegistry() plugins.ScopedRegistry
Plugin facing registry that register_login_backend writes into
func ManualChromeDebugCommand ¶
Copy paste command that starts a debug browser, empty when no binary is known
func NamespaceHarnessDirs ¶
Gives a served profile tag its own harness runtime and tmp dirs in the child env, an empty tag changing nothing
func PrivateUserRuntimeDir ¶
func PrivateUserRuntimeDir() string
The user runtime dir when it is an absolute real directory of this uid closed to group and other
func RegisterLoginBackendProvider ¶
func RegisterLoginBackendProvider(ctx context.Context, provider LoginBackend, scope string) error
Registers a plugin backend in a scope, refusing a name another plugin already holds there
func ReleaseVaultSession ¶
func ReleaseVaultSession(sessionID string)
Drops only the tokens the ended gateway session unlocked
func ResetLoginBackendRegistryForTests ¶
func ResetLoginBackendRegistryForTests()
Clears every plugin login backend registration, for tests only
func ResolveCDPOverride ¶
ResolveCDPOverride normalizes a CDP endpoint into a concrete websocket URL through /json/version discovery
func RunWithSecretEnv ¶
func RunWithSecretEnv(argv []string, env map[string]string, secretEnv, secret string, timeout time.Duration, label string) (provider.CLIResult, error)
Runs a manager CLI that reads the secret from a named variable set on the child environment only
func RunWithStdinSecret ¶
func RunWithStdinSecret(argv []string, env map[string]string, secret string, timeout time.Duration, label string) (provider.CLIResult, error)
Runs a manager CLI feeding the secret on stdin, never argv and never env
func RunningInstance ¶
Port, browser path and pid of the live Chromium already serving DevTools on the dir, for other packages
func SelectCheckoutFills ¶
func SelectCheckoutFills(classified []ClassifiedLoginControl, secret map[string]string, fieldTokens *pyjson.Object) []*pyjson.Object
Maps a payment or address payload onto the best control per token, a combined expiry replacing month and year
func SelectPasswordFill ¶
func SelectPasswordFill(classified []ClassifiedLoginControl, password string) []*pyjson.Object
One fill for the best current-password control, empty without a password field or password
func SetLiveCDPOverride ¶
func SetLiveCDPOverride(homeKey, cdpURL string)
SetLiveCDPOverride publishes or with an empty url clears the home's live endpoint and bumps its generation
func SocketDirBudget ¶
Runtime dir byte budget of a sys.platform value where the harness binds AF_UNIX sockets, nil elsewhere
func SocketFitRuntimeDir ¶
The runtime dir as given when its resolved socket path fits, else a private short dir keyed by base and tag
func StaticLoginBackendName ¶
The backend's name judged before anything else reads it, a ValueError with a fixed message when refused
func StopBrowser ¶
Stops the Chromium this process launched or leased under key
func StoreVaultSessionToken ¶
Commits an unlock, false and nothing stored when a lock happened since the generation snapshot
func UsingLightpandaEngine ¶
Whether browser.engine selects Lightpanda in the config of env
Types ¶
type BitwardenLoginBackend ¶
type BitwardenLoginBackend struct {
LoginBackendDefaults
// contains filtered or unexported fields
}
Bitwarden Password Manager logins read through the bw CLI
func (*BitwardenLoginBackend) DisplayName ¶
func (*BitwardenLoginBackend) DisplayName() string
func (*BitwardenLoginBackend) GetMeta ¶
func (b *BitwardenLoginBackend) GetMeta(handle string) (*vault.VaultItemMeta, error)
func (*BitwardenLoginBackend) IsUnlocked ¶
func (b *BitwardenLoginBackend) IsUnlocked() bool
func (*BitwardenLoginBackend) ListItems ¶
func (b *BitwardenLoginBackend) ListItems() ([]vault.VaultItemMeta, error)
Login metadata of every type 1 item with a fill target, URIs matched Never left out
func (*BitwardenLoginBackend) Name ¶
func (*BitwardenLoginBackend) Name() string
func (*BitwardenLoginBackend) NeedsUnlock ¶
func (*BitwardenLoginBackend) NeedsUnlock() bool
func (*BitwardenLoginBackend) Prefix ¶
func (*BitwardenLoginBackend) Prefix() string
func (*BitwardenLoginBackend) ResolveOTP ¶
func (b *BitwardenLoginBackend) ResolveOTP(handle string) (string, bool, error)
Current code of the item's TOTP seed, absent when bw reports none
func (*BitwardenLoginBackend) ResolvePassword ¶
func (b *BitwardenLoginBackend) ResolvePassword(handle string) (string, error)
func (*BitwardenLoginBackend) Unlock ¶
func (b *BitwardenLoginBackend) Unlock(masterPassword string) error
Mints a session key through the passwordenv contract, the variable set on the child environment only
type BrowserPageBackend ¶
type BrowserPageBackend interface {
provider.ProviderBase
HasPage(taskID string) bool
Evaluate(taskID, expression string, secret bool) (any, error)
}
A plugin browser owning its pages outside the CDP session whose live page browser_vault evaluates scripts on
type BrowserProvider ¶
type BrowserProvider interface {
provider.ProviderBase
IsAvailable(env *tools.Env) bool
CreateSession(env *tools.Env, taskID string) (map[string]any, error)
CloseSession(env *tools.Env, sessionID string) bool
EmergencyCleanup(env *tools.Env, sessionID string)
}
Cloud browser backend selected by browser.cloud_provider, each call reading the profile's secrets through env
type BrowserUseBrowserProvider ¶
type BrowserUseBrowserProvider struct{ CloudBrowserProvider }
Browser Use cloud browser on the user's BROWSER_USE_API_KEY
func (*BrowserUseBrowserProvider) CreateSession ¶
func (p *BrowserUseBrowserProvider) CreateSession(env *tools.Env, taskID string) (map[string]any, error)
Creates a browser, wrapping network errors in the provider's create failure
func (*BrowserUseBrowserProvider) IsAvailable ¶
func (p *BrowserUseBrowserProvider) IsAvailable(env *tools.Env) bool
Availability from the configured BROWSER_USE_API_KEY
type BrowserbaseBrowserProvider ¶
type BrowserbaseBrowserProvider struct{ CloudBrowserProvider }
Browserbase cloud browser with direct BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID only
func (*BrowserbaseBrowserProvider) CreateSession ¶
func (p *BrowserbaseBrowserProvider) CreateSession(env *tools.Env, taskID string) (map[string]any, error)
Creates a session with the configured features, retrying without each paid feature a 402 refuses
type CDPConn ¶
type CDPConn struct {
// contains filtered or unexported fields
}
CDPConn multiplexes commands and events over one DevTools websocket
func NewCDPConn ¶
NewCDPConn wraps an open websocket and starts dispatching its frames
func (*CDPConn) Call ¶
func (c *CDPConn) Call(ctx context.Context, method string, params any, sessionID string) (json.RawMessage, error)
Call sends one command, on the flattened session when given, and waits for its reply
func (*CDPConn) CallInto ¶
func (c *CDPConn) CallInto(ctx context.Context, method string, params any, sessionID string, out any) error
CallInto decodes a command's result into out
func (*CDPConn) CallTimeout ¶
func (c *CDPConn) CallTimeout(method string, params any, sessionID string, timeout time.Duration) (json.RawMessage, error)
CallTimeout runs Call under a fresh deadline
func (*CDPConn) Close ¶
Close ends the connection with a normal close handshake, forcing the socket shut after two seconds
func (*CDPConn) CreateTarget ¶
CreateTarget opens a new page target and returns its id
func (*CDPConn) Done ¶
func (c *CDPConn) Done() <-chan struct{}
Done closes once the connection is gone
type CDPError ¶
type CDPError struct {
Code int `json:"code"`
Message string `json:"message"`
Data string `json:"data,omitempty"`
}
CDPError is a protocol error reply to one command
type CDPEvent ¶
type CDPEvent struct {
Method string
Params json.RawMessage
SessionID string
}
CDPEvent is one protocol event with the flattened session it fired on
type ChromeDebugLaunch ¶
type ChromeDebugLaunch struct {
Launched bool
Attempts []*LaunchAttempt
}
ChromeDebugLaunch is whether a debug browser was spawned and the attempts explaining why not
func LaunchChromeDebug ¶
func LaunchChromeDebug(ctx context.Context, port int, system string) ChromeDebugLaunch
Launches a Chromium family browser with remote debugging, trying each candidate until one stays up
func (ChromeDebugLaunch) Hint ¶
func (l ChromeDebugLaunch) Hint() string
Best user facing explanation of a failed or soft launch, empty when none applies
type ClassifiedLoginControl ¶
type ClassifiedLoginControl struct {
Control LoginControl
Score int
Token string
}
func ClassifyCheckoutControl ¶
func ClassifyCheckoutControl(control LoginControl) *ClassifiedLoginControl
Classifies one control as a payment or address fill target, password and email inputs never matching by text
func ClassifyLoginControl ¶
func ClassifyLoginControl(control LoginControl) *ClassifiedLoginControl
Classifies one control as a login fill target, nil when it is none
func ClassifyOTPControls ¶
func ClassifyOTPControls(controls []LoginControl) []ClassifiedLoginControl
The controls taking a second factor code in DOM order, autocomplete one-time-code being authoritative
type CloudBrowserProvider ¶
type CloudBrowserProvider struct {
// contains filtered or unexported fields
}
Shared REST lifecycle of the bundled cloud browser vendors, one create request and one release request
func (*CloudBrowserProvider) CloseSession ¶
func (p *CloudBrowserProvider) CloseSession(env *tools.Env, sessionID string) bool
Releases a session, false on missing credentials or a failed release, logging each outcome
func (*CloudBrowserProvider) DisplayName ¶
func (p *CloudBrowserProvider) DisplayName() string
func (*CloudBrowserProvider) EmergencyCleanup ¶
func (p *CloudBrowserProvider) EmergencyCleanup(env *tools.Env, sessionID string)
Teardown from exit paths that tolerates missing credentials and network errors
func (*CloudBrowserProvider) GetSetupSchema ¶
func (p *CloudBrowserProvider) GetSetupSchema() map[string]any
Setup picker row, nil hiding the provider from the picker
func (*CloudBrowserProvider) IsAvailable ¶
func (p *CloudBrowserProvider) IsAvailable(env *tools.Env) bool
Available when the vendor config resolves, a raised resolution error propagating as a panic
func (*CloudBrowserProvider) Name ¶
func (p *CloudBrowserProvider) Name() string
type DialogRecord ¶
type DialogRecord struct {
ID, Type, Message string
OpenedAt, ClosedAt float64
ClosedBy string
FrameID any
}
One dialog that opened and was then handled
type ErrWSClosed ¶
ErrWSClosed reports the peer closed the websocket with its status code and reason
func (*ErrWSClosed) Error ¶
func (e *ErrWSClosed) Error() string
type FirecrawlBrowserProvider ¶
type FirecrawlBrowserProvider struct{ CloudBrowserProvider }
Firecrawl cloud browser on /v2/browser, explicit selection only
func (*FirecrawlBrowserProvider) CreateSession ¶
func (p *FirecrawlBrowserProvider) CreateSession(env *tools.Env, taskID string) (map[string]any, error)
Creates a browser with FIRECRAWL_BROWSER_TTL seconds of life, 300 when unset or unparseable
type FrameInfo ¶
type FrameInfo struct {
FrameID, URL, Origin string
ParentFrameID string
IsOOPIF bool
CDPSessionID string
Name string
}
One frame of the page's frame tree, out of process frames carrying their own session
type LaunchAttempt ¶
LaunchAttempt is the outcome of one candidate binary launch
type LaunchOptions ¶
type LaunchOptions struct {
Executable string
UserDataDir string
Ephemeral bool
Headed *bool
ExtraArgs []string
ProcEnv map[string]string
Timeout *time.Duration
SandboxBypass bool
Prepare func() string
// The copy of the user's own browser profile, which keeps its browser sign in
UserProfile bool
}
What a launch starts or attaches, a zero Executable resolving the packaged Chromium
type LaunchedBrowser ¶
type LaunchedBrowser struct {
Key string
PID *int64
StartTime *int64
CDPURL string
HTTPURL string
UserDataDir string
Owned bool
Ephemeral bool
HomeKey string
// Launch record file name its leases are keyed by when this process did not name it
RecordName string
// Held from another PID namespace so the pid is never signalled and liveness is its DevTools endpoint
Foreign bool
}
A Chromium this process launched or attached to on a shared profile
func LaunchChromium ¶
func LaunchChromium(ctx context.Context, env *tools.Env, key string, opts LaunchOptions) (*LaunchedBrowser, string)
Launches or attaches the Chromium for key, returning it or the launch error text
type LightpandaServer ¶
type LightpandaServer struct {
SessionName string
Port int
LogPath string
StartTime *int64
// contains filtered or unexported fields
}
One lightpanda serve per browser session, its CDP discovery URL on a loopback port
func (*LightpandaServer) CDPURL ¶
func (s *LightpandaServer) CDPURL() string
HTTP discovery URL, the harness resolves json/version itself
func (*LightpandaServer) IsAlive ¶
func (s *LightpandaServer) IsAlive() bool
type LocalLoginBackend ¶
type LocalLoginBackend struct {
LoginBackendDefaults
// contains filtered or unexported fields
}
The always on local Fernet vault as a login backend
func NewLocalLoginBackend ¶
func NewLocalLoginBackend(ctx context.Context) *LocalLoginBackend
Local backend reading the vault store of the ctx home
func (*LocalLoginBackend) DisplayName ¶
func (*LocalLoginBackend) DisplayName() string
func (*LocalLoginBackend) GetMeta ¶
func (b *LocalLoginBackend) GetMeta(handle string) (*vault.VaultItemMeta, error)
func (*LocalLoginBackend) ListItems ¶
func (b *LocalLoginBackend) ListItems() ([]vault.VaultItemMeta, error)
func (*LocalLoginBackend) Name ¶
func (*LocalLoginBackend) Name() string
func (*LocalLoginBackend) Prefix ¶
func (*LocalLoginBackend) Prefix() string
func (*LocalLoginBackend) ResolveOTP ¶
func (b *LocalLoginBackend) ResolveOTP(handle string) (string, bool, error)
Current code of a login storing a TOTP seed, absent without a seed
func (*LocalLoginBackend) ResolvePassword ¶
func (b *LocalLoginBackend) ResolvePassword(handle string) (string, error)
func (*LocalLoginBackend) ResolveSecret ¶
func (b *LocalLoginBackend) ResolveSecret(handle string) (map[string]string, error)
Every field of the item payload as text
type LoginBackend ¶
type LoginBackend interface {
Name() string
DisplayName() string
Prefix() string
NeedsUnlock() bool
Owns(handle string) bool
IsUnlocked() bool
// Profile exclusive section entered after the origin pre check, the returned function leaving it
FillContext() (func() error, error)
ListItems() ([]vault.VaultItemMeta, error)
GetMeta(handle string) (*vault.VaultItemMeta, error)
ResolvePassword(handle string) (string, error)
ResolveOTP(handle string) (string, bool, error)
ResolveSecret(handle string) (map[string]string, error)
}
Login source of the browser credential vault, listing metadata and resolving one secret at fill time
func EnabledLoginBackends ¶
func EnabledLoginBackends(ctx context.Context) ([]LoginBackend, error)
Local first, then every detected external manager the user has not turned off, then the enabled plugin backends
func EnabledPluginLoginBackends ¶
func EnabledPluginLoginBackends(ctx context.Context, cfg map[string]any) []LoginBackend
Registered backends the profile turned on with vault.<name>.enabled true, wrapped for the vault tool
func LoginBackendForHandle ¶
func LoginBackendForHandle(ctx context.Context, handle string) (LoginBackend, error)
The enabled backend whose namespace a handle carries, nil when none owns it
func LoginBackendProvider ¶
func LoginBackendProvider(ctx context.Context, name, scope string) LoginBackend
Backend registered under the name in the scope, nil when none is
func NewBitwardenLoginBackend ¶
func NewBitwardenLoginBackend(ctx context.Context, cfg map[string]any) LoginBackend
Bitwarden backend of a config section
func NewOnePasswordLoginBackend ¶
func NewOnePasswordLoginBackend(ctx context.Context, cfg map[string]any) LoginBackend
1Password backend of a config section, a configured service account token skipping the prompt
type LoginBackendDefaults ¶
type LoginBackendDefaults struct{ Self LoginBackend }
Contract defaults a concrete backend embeds with Self bound to itself
func (LoginBackendDefaults) FillContext ¶
func (LoginBackendDefaults) FillContext() (func() error, error)
No profile exclusive section around a fill, reported as a nil release
func (LoginBackendDefaults) IsUnlocked ¶
func (LoginBackendDefaults) IsUnlocked() bool
Always unlocked unless overridden
func (LoginBackendDefaults) NeedsUnlock ¶
func (LoginBackendDefaults) NeedsUnlock() bool
No master password prompt unless overridden
func (LoginBackendDefaults) Owns ¶
func (d LoginBackendDefaults) Owns(handle string) bool
A handle belongs to the backend whose prefix it carries
func (LoginBackendDefaults) ResolveOTP ¶
func (LoginBackendDefaults) ResolveOTP(string) (string, bool, error)
No one time code, the user is asked
func (LoginBackendDefaults) ResolveSecret ¶
func (d LoginBackendDefaults) ResolveSecret(handle string) (map[string]string, error)
Password only payload, the shape external managers resolve
type LoginControl ¶
type LoginControl struct {
Autocomplete string
FormIndex *int
Index int
Label string
Name string
Type string
MaxLength *int
}
Descriptor of a visible input control as inspected in the page
func LoginControlFromDict ¶
func LoginControlFromDict(raw *pyjson.Object) (LoginControl, error)
Control built from the inspection script's record, either key spelling accepted
type OnePasswordLoginBackend ¶
type OnePasswordLoginBackend struct {
LoginBackendDefaults
// contains filtered or unexported fields
}
1Password Login items read through the op CLI
func (*OnePasswordLoginBackend) DisplayName ¶
func (*OnePasswordLoginBackend) DisplayName() string
func (*OnePasswordLoginBackend) GetMeta ¶
func (b *OnePasswordLoginBackend) GetMeta(handle string) (*vault.VaultItemMeta, error)
func (*OnePasswordLoginBackend) IsUnlocked ¶
func (b *OnePasswordLoginBackend) IsUnlocked() bool
func (*OnePasswordLoginBackend) ListItems ¶
func (b *OnePasswordLoginBackend) ListItems() ([]vault.VaultItemMeta, error)
Login metadata of every item with a usable origin, remembering each item's vault for later reads
func (*OnePasswordLoginBackend) Name ¶
func (*OnePasswordLoginBackend) Name() string
func (*OnePasswordLoginBackend) NeedsUnlock ¶
func (*OnePasswordLoginBackend) NeedsUnlock() bool
func (*OnePasswordLoginBackend) Prefix ¶
func (*OnePasswordLoginBackend) Prefix() string
func (*OnePasswordLoginBackend) ResolveOTP ¶
func (b *OnePasswordLoginBackend) ResolveOTP(handle string) (string, bool, error)
Current code of the item's one time password field, absent when op reports none
func (*OnePasswordLoginBackend) ResolvePassword ¶
func (b *OnePasswordLoginBackend) ResolvePassword(handle string) (string, error)
func (*OnePasswordLoginBackend) Unlock ¶
func (b *OnePasswordLoginBackend) Unlock(masterPassword string) error
Mints a session token from the master password consumed on stdin
type PendingDialog ¶
type PendingDialog struct {
ID, Type, Message, DefaultPrompt string
OpenedAt float64
CDPSessionID string
FrameID any
BridgeRequestID string
}
One JS dialog currently open on some frame's session
type PluginBackendError ¶
type PluginBackendError struct{ Msg string }
A plugin login backend failed or broke its contract, the fixed text never carrying the plugin's own message
func (*PluginBackendError) Error ¶
func (e *PluginBackendError) Error() string
type PluginLoginBackend ¶
type PluginLoginBackend struct {
// contains filtered or unexported fields
}
Core owned wrapper around a plugin registered login backend, the only form the vault tool ever sees
func NewPluginLoginBackend ¶
func NewPluginLoginBackend(name string, plugin LoginBackend) *PluginLoginBackend
Wrapper whose namespace is the registry key, never an attribute the plugin can change later
func (*PluginLoginBackend) DisplayName ¶
func (b *PluginLoginBackend) DisplayName() string
func (*PluginLoginBackend) FillContext ¶
func (b *PluginLoginBackend) FillContext() (func() error, error)
The plugin's own section around one of its fills, its exit guarded like every other plugin call
func (*PluginLoginBackend) GetMeta ¶
func (b *PluginLoginBackend) GetMeta(handle string) (*vault.VaultItemMeta, error)
Validated copy of one item, nil outside the namespace or when the plugin reports another id
func (*PluginLoginBackend) IsUnlocked ¶
func (b *PluginLoginBackend) IsUnlocked() bool
func (*PluginLoginBackend) ListItems ¶
func (b *PluginLoginBackend) ListItems() ([]vault.VaultItemMeta, error)
Validated copies of the plugin's items restricted to its own namespace
func (*PluginLoginBackend) Name ¶
func (b *PluginLoginBackend) Name() string
func (*PluginLoginBackend) NeedsUnlock ¶
func (b *PluginLoginBackend) NeedsUnlock() bool
func (*PluginLoginBackend) Owns ¶
func (b *PluginLoginBackend) Owns(handle string) bool
Ownership decided here, so the plugin's own Owns is never consulted
func (*PluginLoginBackend) Prefix ¶
func (b *PluginLoginBackend) Prefix() string
func (*PluginLoginBackend) ResolveOTP ¶
func (b *PluginLoginBackend) ResolveOTP(handle string) (string, bool, error)
func (*PluginLoginBackend) ResolvePassword ¶
func (b *PluginLoginBackend) ResolvePassword(handle string) (string, error)
func (*PluginLoginBackend) ResolveSecret ¶
func (b *PluginLoginBackend) ResolveSecret(handle string) (map[string]string, error)
Copied payload of the plugin, a nil mapping reading as an invalid value
type SupervisorSnapshot ¶
type SupervisorSnapshot struct {
PendingDialogs []PendingDialog
RecentDialogs []DialogRecord
FrameTree *pyjson.Object
Active bool
CDPURL, TaskID string
// contains filtered or unexported fields
}
Read only view of supervisor state for tool handlers
func (SupervisorSnapshot) ToDict ¶
func (s SupervisorSnapshot) ToDict() *pyjson.Object
Serialized snapshot for tool output, recent dialogs only when any exist
type TargetInfo ¶
type TargetInfo struct {
TargetID string `json:"targetId"`
Type string `json:"type"`
Title string `json:"title"`
URL string `json:"url"`
Attached bool `json:"attached"`
OpenerID string `json:"openerId,omitempty"`
}
TargetInfo is one entry of Target.getTargets
type UnlockRequired ¶
type UnlockRequired struct{ Backend LoginBackend }
The backend is locked for this session, so the surface must prompt for the master password
func (*UnlockRequired) Error ¶
func (e *UnlockRequired) Error() string
type WSConn ¶
type WSConn struct {
// contains filtered or unexported fields
}
WSConn is one RFC 6455 client connection with reassembly, ping replies, and close handshake
func DialWS ¶
DialWS performs the opening handshake against a ws or wss URL, tunnelling through an environment proxy for non loopback hosts
func (*WSConn) Close ¶
Close sends a close frame, waits briefly for the peer's close, and shuts the socket
func (*WSConn) ForceClose ¶
func (c *WSConn) ForceClose()
ForceClose drops the socket without a close handshake
func (*WSConn) ReadMessage ¶
ReadMessage returns the next complete text or binary message, answering pings and completing a close handshake meanwhile
func (*WSConn) SendClose ¶
SendClose writes a close frame and leaves the peer's reply to whoever reads the connection
func (*WSConn) WriteBinary ¶
WriteBinary sends one unfragmented masked binary frame
Source Files
¶
- bot_desktop.go
- browser_cdp_tool.go
- browser_command.go
- browser_connect.go
- browser_connect_launch.go
- browser_connect_launch_unix.go
- browser_connect_other.go
- browser_connect_snapshot.go
- browser_dialog_tool.go
- browser_page_backend.go
- browser_page_backend_hosted.go
- browser_provider.go
- browser_provider_hosted.go
- browser_session.go
- browser_session_cdp.go
- browser_session_cloud.go
- browser_session_lifecycle.go
- browser_session_real_profile.go
- browser_session_sandbox.go
- browser_use_cli.go
- browser_use_exec.go
- browser_vault_tool.go
- cdp.go
- cdp_override_export.go
- cli_browser_exports.go
- cloud_provider.go
- cloud_vendors.go
- config.go
- doctor_exports.go
- endpoint.go
- exec_helpers.go
- exec_steps.go
- exports.go
- harnessdirs.go
- harnessdirs_unix.go
- holders.go
- holders_unix.go
- launcher.go
- launcher_run.go
- launcher_spawn_unix.go
- lightpanda.go
- log.go
- registry.go
- runtime.go
- supervisor.go
- tools.go
- tools_config_bridge.go
- urlpolicy.go
- vault_backend.go
- vault_backend_hosted.go
- vault_backend_local.go
- vault_backend_managers.go
- vault_backend_plugin.go
- vault_backend_registry.go
- vault_command.go
- vault_login_classifier.go
- vault_unlock.go
- ws.go