Documentation
¶
Overview ¶
Package browser manages named Chromium user-data directories used by browser-driving MCPs (chrome-devtools-mcp, primarily). Each profile is a long-lived directory the user signs into once; agents reference it by name via the {{.BrowserProfile "name"}} template helper in agent.yaml.
Profiles live under $XDG_DATA_HOME/squad/browser-profiles/<name> (default: ~/.local/share/squad/browser-profiles/<name>). Names are validated to be filesystem-safe identifiers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrChromeNotFound = errors.New("could not locate Google Chrome or Chromium; install one or set SQUAD_BROWSER_BIN")
ErrChromeNotFound is returned by Launch when no Chrome/Chromium binary can be located on the system.
var ErrInvalidName = errors.New("browser profile name must be lowercase alphanumerics with optional `-`/`_`, no leading/trailing punctuation")
ErrInvalidName is returned by validators when a name does not satisfy validName.
var ErrProfileNotFound = errors.New("browser profile not found")
ErrProfileNotFound is returned by Delete when a name has no on-disk dir.
Functions ¶
func Delete ¶
Delete removes the profile dir for name. Returns ErrProfileNotFound when the profile does not exist; other I/O failures are wrapped.
func Exists ¶
Exists reports whether the profile named name has an on-disk dir. It does NOT validate name (use ValidateName separately if needed); a malformed name simply returns false.
func Launch ¶
func Launch(name string, opts LaunchOptions) error
Launch opens Chrome against the profile dir for name. The profile is created lazily by ProfileDir. Caller is responsible for printing human-facing instructions (e.g. "log in then close the window"); Launch is purely the subprocess wrapper.
func ProfileDir ¶
ProfileDir returns the absolute path to the profile named name, creating the directory if it does not yet exist. Returns ErrInvalidName for invalid names; otherwise the path is guaranteed to exist on success.
func Root ¶
func Root() string
Root returns the absolute directory containing all squad-managed browser profiles. It is created lazily by ProfileDir; Root itself does not touch the filesystem.
func ValidateName ¶
ValidateName reports whether name is a legal profile identifier.
Types ¶
type LaunchOptions ¶
type LaunchOptions struct {
// URL is the initial URL to load. Empty defaults to about:blank.
URL string
// Wait, when true, blocks Launch until Chrome exits. When false,
// Chrome is started and Launch returns immediately — useful for
// scripted setup where the caller doesn't want to wedge a terminal.
Wait bool
// Stderr receives diagnostic output (Chrome's own logs). nil discards.
Stderr *os.File
}
LaunchOptions controls Launch. The zero value is usable: it opens the profile to a blank page in a foreground window and waits for the user to quit Chrome.