Expand description
Named-tab orchestration: SQLite + the engine-agnostic TabBackend
working together.
The registry layer (crate::registry::tabs) is pure SQL CRUD. This
module adds the logic the agent contract actually requires:
- Get-or-create:
tab_open(_, name, url)returns an existing live tab under that name, or creates a freshabout:blank(or the givenurl) and registers it. - Navigate-on-mismatch: if the existing tab’s
last_urldoesn’t match the requestedurl, run navigate first. - Sweep-on-read: stale rows whose
target_idno longer exists in the live browser are dropped before they’re returned to the caller. - Budget pressure: when daemon-created rows exceed
HARD_CAP, the LRU is closed and recycled. - Cute names: agents who pass no
--namegettab-<cute-word>from the same generator that names browsers.
The same code path serves CDP (Chromium) and BiDi (Firefox) browsers
via TabBackend — CDP targetId and BiDi context are both opaque
ids stored in the tabs.target_id column. The registry doesn’t care
which engine produced the id.
Constants§
- HARD_
CAP - Hard cap on
daemon_createdrows per browser. Hitting this triggers LRU close+recreate of the oldest daemon-created tab. Chromium itself starts to struggle around a few hundred tabs depending on RAM; 50 is comfortably under that ceiling and large enough that even busy scraping agents won’t routinely hit it.
Functions§
- resolve_
tab - Resolve
<browser>/<name>to a live tab row for cross-command routing (eval, fetch, etc.). ReturnsOk(None)if no row matches or the row’starget_idno longer exists in the browser (TabNotFoundat the call site). - tab_
list tab list <browser>backend with sweep-on-read.- tab_
open - Open a named tab (get-or-create), navigating if
urldiffers from the existing tab’slast_url. Returns the up-to-date row. - with_
named_ tab_ recovery - Run
opagainst the named tab<browser>/<name>with one round of recover-and-retry on tab failures. Mirrorscrate::session::with_scratch_recoverybut for the agent-owned named-tab path.