AGENT SKILL

flatpak-chromium-automation

Drive Flatpak Chromium CDP, install unpacked extensions, manage profiles.

License 许可
MIT
最近更新
2026-11-15
Stars
★ 0
Forks
0

01 前言 Front Matter

name
flatpak-chromium-automation
metadata
{ "tags": [ "browser", "chromium", "brave", "flatpak", "automation" ] }
description
Drive Flatpak Chromium CDP, install unpacked extensions, manage profiles.
when-to-use
Use when CDP debugging of a Flatpak browser fails to bind its port, when orphan Flatpak instances hijack a debug launch, when pkill/pgrep patterns threaten the agent shell, when adding a Web Store extension that cannot be clicked through, or when a tool must see or create browser profiles deterministically, when editing Local State or Preferences with a closed browser, when probing user-data dirs under native, Flatpak, Snap, or macOS installs, or when wiring NAME|user|pass|url envs into vault items plus browser profiles. Not for driving non-Flatpak browsers.
argument-hint
<appid | ext-id | cmd | create | inspect> [user-data-dir] [--dry-run] [--yes]

02 资源文件 3

03 SKILL.md 正文

Automating flatpak-packaged Chromium browsers

You drive Flatpak-packaged Brave/Chromium over CDP from the host, install Web Store extensions unpacked, and manage (create, inspect, fix) the underlying Brave/Chromium profile dirs and Local State — the things that break when the sandbox is in the way or when a tool must see profiles deterministically.

Profile provisioning detail — Local State info_cache registry, user-data dir locations across native/Flatpak/Snap/macOS, the closed-browser guard, and Bitwarden CLI companion setup: references/profile-provisioning.md.

Which paths the browser process can actually see

See references/sandbox-paths-and-launch.md for sandbox-visible paths, probe commands, orphan-instance cleanup, and first-in CDP launch verification.

The sandbox does NOT bind host /etc or ~/.config (outside ~/.var/app/...): /etc/brave/policies/managed/*.json and --policy-directory=/home/<user>/.config/... silently load nothing (verify via chrome://policy over CDP — statuses come back as errors/not-listed rather than an exception). Paths that ARE visible: anything under /tmp or ~/.var/app/<APPID>/. Probe without launching: flatpak run --command=ls <APPID> <path>.

Orphan instances hijack your debug launch

A live browser owns the user-data dir singleton, so a fresh flatpak run com.brave.Browser --remote-debugging-port=... --profile-directory=... just hands off to the running instance and exits: no port listens, no error, and it looks like "flatpak breaks CDP". CDP works fine from the host (127.0.0.1) once the launch is genuinely first-in. Before launching debug sessions, check flatpak ps and probe the target dir's SingletonSocket; killing the flatpak run wrapper does NOT kill the browser — clean up with flatpak kill <instance-id>, and re-verify with pgrep -f "[/]app/brave/brave" ([/] bracket so the pattern cannot match your own shell, see below).

pkill/pgrep self-match kills your own shell

pkill -f "remote-debugging-port=9233" issued from an agent shell matches the shell's own command line (it contains that string) and SIGTERMs the command mid-run. Always break the pattern with a bracket class: pkill -f "92[3]3".

Extension install without clicking anything

Brave/Chromium's "Add extension" prompt is a NATIVE window — it is not in any CDP target, page DOM, or accessibility tree reachable via connect_over_cdp/Playwright, so web-store install flows are not automatable. Do not burn time trying to click it.

Working method (verified end-to-end): fetch the official CRX by extension id from the update endpoint, unpack it, and launch with --load-extension=<dir> --disable-extensions-except=<dir>. The MV3 service worker appears in /json/list and the extension popup runs normally under CDP. Endpoint + CRX3/CRX2 binary layout, and the caveat that unpacked dirs get path-derived IDs instead of the store ID: references/crx-fetch.md.

--load-extension is per-launch only; there is no verified per-profile permanent install path in the flatpak sandbox yet (External Extensions with external_crx and policy force-install both failed to take here) — treat any "permanent" claim as needing a fresh-launch verification that the extension got installed under its official ID.

04 同仓库更多 Skills