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 ¶
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 ¶
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 ¶
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.