browser

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 9 Imported by: 0

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

View Source
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.

View Source
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.

View Source
var ErrProfileNotFound = errors.New("browser profile not found")

ErrProfileNotFound is returned by Delete when a name has no on-disk dir.

Functions

func Delete

func Delete(name string) error

Delete removes the profile dir for name. Returns ErrProfileNotFound when the profile does not exist; other I/O failures are wrapped.

func Exists

func Exists(name string) bool

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

func ProfileDir(name string) (string, error)

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

func ValidateName(name string) error

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.

type Profile

type Profile struct {
	Name    string
	Dir     string
	ModTime time.Time
}

Profile is a discovered profile entry. ModTime is the directory's mtime (a rough "last used" signal; Chrome touches the dir on session writes).

func List

func List() ([]Profile, error)

List returns all profiles under Root(), sorted by name. A missing root directory is not an error and returns an empty slice.

Jump to

Keyboard shortcuts

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