agentbrowser

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 11 Imported by: ? 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

Package agentbrowser bounds the lifetime of the agent-browser daemons an agent run starts.

agent-browser runs each browser behind a daemon that detaches from the CLI that spawned it (it is reparented to init and leads its own process group), and in the releases we support it never exits on its own: its idle shutdown is off by default. Every run that touched a browser - the typed browser_auth tool, or the model running `agent-browser` from bash - therefore left a daemon and its Chrome behind. They piled up across runs in long-lived containers, and the next run reused the leftover `default` daemon, inheriting another target's live cookies and racing any run that shared it.

Begin gives a run a private AGENT_BROWSER_SOCKET_DIR, where agent-browser keeps the pid file and socket of every daemon it starts, and hands it to the run's subprocesses through the context (procutil.WithEnv), so concurrent runs in one server process stay apart. The returned end function runs `agent-browser close --all` against that directory only - it can never close an operator's own sessions - and removes it. A default idle timeout is the backstop for a run that dies before end runs.

Index

Constants

View Source
const (
	// EnvSocketDir is where agent-browser keeps each daemon's pid file and
	// socket. An operator who sets it keeps full control: Begin then leaves
	// the run's environment alone and closes nothing.
	EnvSocketDir = "AGENT_BROWSER_SOCKET_DIR"
	// EnvIdleTimeout shuts a daemon down after that many ms without a command.
	// The daemon reads it when it starts, from the spawning CLI's environment.
	EnvIdleTimeout = "AGENT_BROWSER_IDLE_TIMEOUT_MS"

	// DefaultIdleTimeout applies when the operator has not set EnvIdleTimeout.
	// It only matters when end never runs (the process was killed): a run that
	// finishes closes its daemons itself. It is long because an agent may run
	// a multi-minute native scan between two browser steps and expects the
	// logged-in browser to still be there.
	DefaultIdleTimeout = 30 * time.Minute
)

Variables

This section is empty.

Functions

func Begin

func Begin(ctx context.Context, binary string) (context.Context, func())

Begin scopes the agent-browser daemons started under the returned context to this run. binary is agent.browser.binary_path ("" = agent-browser on PATH); it is only used to close the daemons. Call end when the run is over.

A ctx that already carries a socket dir belongs to an outer run (the autopilot pipeline's auth preflight and operator agent, swarm phases): the nested run shares its browsers and end is a no-op, so it cannot close them under the outer run.

Begin never fails the run: if it cannot create the directory, it logs and returns ctx unchanged, which is the pre-scope behaviour.

func ResolveBinary

func ResolveBinary(configured string) (string, error)

ResolveBinary honours a configured agent.browser.binary_path (absolute, relative or a bare name) and falls back to agent-browser on PATH.

Types

This section is empty.

Jump to

Keyboard shortcuts

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