Skip to content

Add playwright-chromium pkg; agent-browser depends on it#155

Open
agent-137 wants to merge 5 commits intomainfrom
chromium
Open

Add playwright-chromium pkg; agent-browser depends on it#155
agent-137 wants to merge 5 commits intomainfrom
chromium

Conversation

@agent-137
Copy link
Copy Markdown

@agent-137 agent-137 commented May 6, 2026

Summary

  • Adds playwright-chromium pkg with per-arch sources (amd64 via Playwright→CfT redirect, arm64 via Playwright's MS-hosted build), pinned to browser revision 1200 (Chrome 143.0.7499.4, matches playwright-core ^1.57.0).
  • Ships both the full chromium browser AND chromium-headless-shell, since @playwright/test treats them as separate browser installs (default chromium.launch() runs headless via the shell binary).
  • Lays out files at /usr/share/playwright-chromium/chromium-1200/ and /usr/share/playwright-chromium/chromium_headless_shell-1200/ in the layout @playwright/test expects (per-arch dir names: chrome-linux64/ on amd64, chrome-linux/ on arm64), plus a /usr/bin/playwright-chromium wrapper.
  • agent-browser drops npx playwright-core install chromium and instead depends on playwright-chromium; the wrapper passes --executable-path /usr/bin/playwright-chromium.
  • Removes the previously-inlined chromium system-lib runtime_dep list from agent-browser since they come transitively via playwright-chromium.

Drop-in replacement for npx playwright install chromium

For Playwright users, the new pkg replaces the runtime CDN install with a real Minimal dependency. Set PLAYWRIGHT_BROWSERS_PATH=/usr/share/playwright-chromium in your CI env or task and @playwright/test will find the pre-installed binary at the layout it expects (chromium-1200/<inner>/chrome for headed, chromium_headless_shell-1200/<inner>/{headless_shell,chrome-headless-shell} for headless) and skip the download. The INSTALLATION_COMPLETE marker is written to both browser dirs so Playwright treats it as a successful install rather than re-fetching.

This gets us a real supply-chain story versus running npx playwright install ad-hoc:

  • Hash pinning is visible and auditable — the chromium sha256s sit in packages/playwright-chromium/build.ncl, version-controlled and reviewable. npx playwright install does verify hashes internally, but the expected hashes are buried inside a transitively-pinned npm dep that consumers rarely inspect.
  • Reproducibility tracks the pkg graph, not your node_modules — two builds of the same playwright-chromium pkg version always produce byte-identical chromium binaries, regardless of what playwright-core resolves to in any given project's lockfile.
  • No build-time network call — Minimal fetches the zips into its content-addressed store once; subsequent users of the pkg get a cache hit. npx playwright install re-runs at every fresh node_modules install and requires sandbox internet access.
  • Per-arch dispatch is explicit in the spec — the match { arch = 'Amd64, .. } | { arch = 'Arm64, .. } blocks in build.ncl make the cross-platform contract reviewable in one place.

Why playwright-chromium and not chrome-for-testing

Upstream agent-browser is built around Chrome for Testing (Google's official automation channel), and that would be the natural pkg to depend on. But as of 2026-05-06 Google does not publish a linux-arm64 CfT build — the JSON manifest has only linux64, mac-arm64, mac-x64, win32, win64. ARM64 Linux Chrome was announced for Q2 2026 but the CfT publishing pipeline hasn't shipped arm64 zips yet (upstream tracker).

Playwright self-hosts a linux-arm64 chromium build (their CDN redirects amd64 → Google's CfT bucket but arm64 → playwright.download.prss.microsoft.com), so playwright-chromium is the only pinnable chromium source today that works on both arches.

Notion follow-up tracks creating a chrome-for-testing pkg and flipping agent-browser back once Google ships arm64 CfT.

Test plan

  • min check --packages playwright-chromium agent-browser clean
  • min patched-pkg playwright-chromium builds (linux-arm64)
  • min patched-pkg agent-browser builds against the new dep
  • End-to-end smoke: playwright-chromium --versionChromium 143.0.7499.4; agent-browser --versionagent-browser 0.15.1
  • @playwright/test integration on arm64: chromium.launch() resolves executablePath to the pkg's chrome binary, launches the headless-shell variant, returns version 143.0.7499.4 without re-downloading (verified via temp task removed in last commit)
  • amd64 build verification + integration check (only validated on arm64 host so far)
  • Webapp e2e migration to playwright-chromium (separate PR in webapp repo)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Added a standalone Playwright Chromium package to centralize browser distribution.
    • Updated the agent browser to rely on the new Chromium package instead of enumerating many low-level libraries.
    • Changed packaging so Chromium is provided at runtime (via the new package) rather than bundled during build, simplifying the build output and installer layout.

Adds a new playwright-chromium pkg that pins Playwright browser revision
1200 (Chrome 143.0.7499.4 / playwright-core ^1.57.0) with per-arch
sources — amd64 fetches via Playwright's CDN (which redirects to Google
Chrome for Testing), arm64 fetches Microsoft-hosted Playwright builds.
Lays out files at /usr/share/playwright-chromium/chromium-1200/ in the
layout @playwright/test expects (chrome-linux64/ on amd64, chrome-linux/
on arm64), plus a /usr/bin/playwright-chromium wrapper.

agent-browser drops `npx playwright-core install chromium` from its
build and instead depends on playwright-chromium; the wrapper passes
--executable-path /usr/bin/playwright-chromium to the daemon. Removes
the previously-inlined chromium system-lib runtime_dep list since they
now come transitively via playwright-chromium.

Picked playwright-chromium over chrome-for-testing because Google does
not yet publish a linux-arm64 CfT build (announced for Q2 2026 but the
publishing pipeline hasn't shipped arm64 zips). Playwright self-hosts
arm64 chromium, so it's the only pinnable source that works on both
arches today. Notion follow-up tracks creating chrome-for-testing and
flipping back once Google ships arm64 CfT.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6fa5649c-0f02-4857-87d0-c3efed1c2cbe

📥 Commits

Reviewing files that changed from the base of the PR and between c13b235 and 303be39.

📒 Files selected for processing (2)
  • packages/playwright-chromium/build.ncl
  • packages/playwright-chromium/build.sh
✅ Files skipped from review due to trivial changes (2)
  • packages/playwright-chromium/build.ncl
  • packages/playwright-chromium/build.sh

📝 Walkthrough

Walkthrough

This PR extracts Chromium into a new playwright-chromium package and updates agent-browser to depend on it at runtime, adjusting build scripts and wrapper behavior to pass an explicit executable path instead of bundling or installing Chromium during build.

Changes

Playwright Chromium Packaging and Agent-Browser Integration

Layer / File(s) Summary
New Package Foundation
packages/playwright-chromium/build.ncl
Adds a new build spec pinning revision = "1200" and browser_version = "143.0.7499.4", declares archived downloads for full Chromium and headless-shell (amd64/arm64) with SHA-256s, runtime deps, outputs usr/bin/playwright-chromium and usr/share/playwright-chromium/**, and a smoketest.
Package Build Script
packages/playwright-chromium/build.sh
Unzips supplied Chromium artifacts, enforces a single top-level extracted dir per archive, installs both full and headless-shell trees into revision-scoped paths under $OUTPUT_DIR/usr/share/playwright-chromium/, writes INSTALLATION_COMPLETE markers, and installs a wrapper at $OUTPUT_DIR/usr/bin/playwright-chromium that execs the installed chrome binary.
Dependency Wiring
packages/agent-browser/build.ncl
Replaces a long list of direct system-library runtime deps with an import and single runtime_deps entry for playwright-chromium, and updates metadata comments accordingly (lines ~12–62).
Build Script Refactoring
packages/agent-browser/build.sh
Removes npx playwright-core install chromium and bundling of Playwright browser files into usr/share/agent-browser; updates packaging to omit browser layout and generates a wrapper that no longer exports PLAYWRIGHT_BROWSERS_PATH but execs the daemon with --executable-path /usr/bin/playwright-chromium "$@".
Smoketests / Metadata
packages/playwright-chromium/build.ncl
Defines package attributes (upstream_version, source_provenance, build_cost_multiple) and a smoketest invoking /bin/playwright-chromium --version.
sequenceDiagram
    autonumber
    participant User
    participant Wrapper as /usr/bin/agent-browser (wrapper)
    participant Daemon as agent-browser daemon
    participant Chromium as /usr/bin/playwright-chromium
    User->>Wrapper: run agent-browser $ARGS
    Wrapper->>Daemon: exec daemon --executable-path /usr/bin/playwright-chromium $ARGS
    Daemon->>Chromium: launch executable at /usr/bin/playwright-chromium with Playwright args
    Chromium-->>Daemon: spawn browser process / respond
    Daemon-->>User: forward output / provide browser-driven responses
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰
I hopped through zips and build-time trails,
Split chromium out into tidy bales.
A wrapper whispers the path to run,
Daemon and browser now dance as one.
Cheers from the burrow — build is done!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely summarizes the two main changes: adding a new playwright-chromium package and making agent-browser depend on it.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chromium

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/playwright-chromium/build.ncl`:
- Around line 122-126: The attrs block currently sets upstream_version but omits
source_provenance; update the attrs map (the attrs symbol in build.ncl) to add a
source_provenance entry documenting the canonical upstream source and version
(use the same browser_version value already assigned to upstream_version), so
packaging metadata is complete—leave build_cost_multiple as-is and ensure the
provenance points to the canonical upstream URL/source for this browser.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ed0c4445-8707-413e-bd8b-ec6abe6cc7de

📥 Commits

Reviewing files that changed from the base of the PR and between fbad6c8 and e7b9c00.

📒 Files selected for processing (4)
  • packages/agent-browser/build.ncl
  • packages/agent-browser/build.sh
  • packages/playwright-chromium/build.ncl
  • packages/playwright-chromium/build.sh

Comment thread packages/playwright-chromium/build.ncl
Spins up a throwaway npm project, installs playwright-core@1.57.0
(matches our pinned browser revision 1200), sets
PLAYWRIGHT_BROWSERS_PATH to the playwright-chromium pkg, and tries
to launch chromium. If the on-disk layout is correct, launch()
returns the chromium version.

Lets the integration be tested before this PR merges (so consumers
don't have to wait for `minimal update` in their downstream repo).
Tagged temp-* so it's clear this should be removed before merge.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@minimal.toml`:
- Line 31: The temporary directory created by mktemp -d is never removed and the
unquoted cd $T can break on paths with spaces; modify the shell command that
creates T to set a trap to remove the directory on EXIT (e.g., trap 'rm -rf
"$T"' EXIT) and quote uses of the variable (change cd $T to cd "$T" and quote
any other occurrences of $T) so the temp-dir is cleaned up reliably and path
values are safe.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 73a48da6-66ed-48aa-9f34-78d914267a65

📥 Commits

Reviewing files that changed from the base of the PR and between e7b9c00 and 8cbc012.

📒 Files selected for processing (1)
  • minimal.toml

Comment thread minimal.toml Outdated
mitodrummer and others added 2 commits May 6, 2026 23:36
Playwright treats `chromium` and `chromium-headless-shell` as two
separate browser installs (see playwright-core/browsers.json). Default
chromium.launch() runs headless, which uses the headless-shell binary
at chromium_headless_shell-<rev>/<inner>/{headless_shell,chrome-headless-shell}
— without it, launch() fails with "Executable doesn't exist at ...".

Adds a second per-arch Source for the headless-shell zip and extracts
each zip into a scratch dir before installing (both arm64 zips happen
to use the same chrome-linux/ top-level name, so they'd clobber one
another otherwise). Bumps build_cost_multiple from 2 to 3 since the
shell zip nearly doubles the artifact size.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Integration verified on arm64: chromium.launch() resolves
executablePath to the pkg's chrome-linux/chrome, launches the
headless-shell binary, and returns version 143.0.7499.4 without
any download attempt.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
packages/playwright-chromium/build.ncl (1)

146-150: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add missing source_provenance metadata in attrs.

upstream_version is present, but source_provenance is still missing. This leaves required package provenance incomplete.

Suggested fix
   attrs =
     {
       upstream_version = browser_version,
+      source_provenance = {
+        category = 'GithubRepo,
+        owner = "microsoft",
+        repo = "playwright",
+      },
       build_cost_multiple = 3,
     } | Attrs,

As per coding guidelines, “Set source_provenance for GitHub projects using category = 'GithubRepo, owner = "<account>", repo = "<repo>" … and use canonical upstream sources.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/playwright-chromium/build.ncl` around lines 146 - 150, The attrs
block currently sets upstream_version but omits required source_provenance;
update the attrs object (the Attrs being merged) to include a source_provenance
field for the GitHub upstream—e.g., add source_provenance = { category =
"GithubRepo", owner = "<owner>", repo = "<repo>" } (replace <owner> and <repo>
with the canonical repository) and ensure any canonical upstream source fields
are set accordingly so provenance is complete alongside upstream_version in the
same attrs record.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/playwright-chromium/build.sh`:
- Around line 20-21: The assignment to FULL_INNER and SHELL_INNER using `ls
_full` and `ls _shell` can return multiple entries and corrupt subsequent `cp`
targets/wrapper paths; update the logic that sets FULL_INNER and SHELL_INNER to
explicitly enumerate entries in the `_full` and `_shell` extraction roots,
verify there is exactly one top-level entry in each directory (fail with a clear
error if count != 1), and then assign the variable to that single entry name so
downstream `cp`/wrapper path logic uses an unambiguous directory; look for the
symbols FULL_INNER and SHELL_INNER in the script and replace the `ls` usage with
this validation-and-assign pattern.

---

Duplicate comments:
In `@packages/playwright-chromium/build.ncl`:
- Around line 146-150: The attrs block currently sets upstream_version but omits
required source_provenance; update the attrs object (the Attrs being merged) to
include a source_provenance field for the GitHub upstream—e.g., add
source_provenance = { category = "GithubRepo", owner = "<owner>", repo =
"<repo>" } (replace <owner> and <repo> with the canonical repository) and ensure
any canonical upstream source fields are set accordingly so provenance is
complete alongside upstream_version in the same attrs record.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f6e0e4b2-f278-4cf6-98e8-f8de6342ce40

📥 Commits

Reviewing files that changed from the base of the PR and between 8cbc012 and c13b235.

📒 Files selected for processing (2)
  • packages/playwright-chromium/build.ncl
  • packages/playwright-chromium/build.sh

Comment thread packages/playwright-chromium/build.sh Outdated
Add source_provenance attrs and harden the inner-dir detection in
build.sh against zips that ever produce more than one top-level entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants