#2225
Add origin-scoped clipboard-read permission control (clipboard read fails with NotAllowedError in headless)
Summary
In a headless session, clipboard read fails with NotAllowedError, because navigator.clipboard.readText() needs the clipboard-read permission. The CLI gives no way to grant that permission for one origin.
Environment
- agent-browser 0.39.2, headless Chromium
- Linux
Reproduction
agent-browser open http://localhost:3000/(any page served from a local origin)agent-browser clipboard write "hello"agent-browser clipboard read
Expected: a caller can first grant clipboard-read for http://localhost:3000, and the read then returns hello.
Actual: the read fails with NotAllowedError (from navigator.clipboard.readText()). There is no CLI command that grants clipboard-read scoped to an origin.
Details
- The daemon's
permissionsaction callsBrowser.grantPermissionswith only a permissions array. It sets neitheroriginnorbrowserContextId, so a grant applies to every origin in the browser instead of the page under test. - Callers can't safely send the CDP command themselves. Discovering the endpoint (
cdp_urland similar actions) can implicitly launch a browser when none is running.
Proposal
Add an action that works only on an existing browser, for example clipboard permission grant|reset <origin>, which:
- validates that
<origin>matches the active target's origin exactly; - calls
Browser.setPermissionwith{ name: "clipboard-read" },setting: "granted"(or"prompt"for reset), thatorigin, and the target'sbrowserContextId; - never launches a browser if none is running.
We patched this locally along those lines and confirmed it with headless Chromium:
- reads were refused before the grant and allowed after it;
- a different origin stayed refused;
- reset restored the refusal.
Activity
0No activity yet.