Skip to content
This repository was archived by the owner on Jun 2, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
16743e1
feat(chromium): port humanized Bezier mouse paths from fork (#1044 M2)
2015kmadanap May 23, 2026
6e29553
feat(mcp): port PM Autofill Preflight from fork (#1044 M2)
2015kmadanap May 23, 2026
9dc2aa1
feat(snapshot): emit [haspopup]/[expanded=false] in ARIA snapshot (#1…
2015kmadanap May 23, 2026
d1dc677
feat(mcp): port browser_take_ocr_friendly_screenshot + browser_trigge…
2015kmadanap May 23, 2026
9d09610
feat(mcp): port 5 fork CLI flags onto sync/upstream-1.61 (#1044 M3)
2015kmadanap May 23, 2026
623afae
feat(chromium): port CDP stealth mode + unit tests (#1044 M3)
2015kmadanap May 23, 2026
5616743
feat(mcp): port Path D srcdoc-iframe print bridge + window.open focus…
2015kmadanap May 23, 2026
adfe755
chore(types): replace `as any` casts + resolve TS 6.0 fallout (#1044 M5)
2015kmadanap May 23, 2026
d1e03e9
chore(lint): fix 3 pre-existing M2 ESLint errors (#1044)
2015kmadanap May 23, 2026
f410f4b
chore(test): unblock stealth-stubs.spec.ts by extracting buildChromeB…
2015kmadanap May 23, 2026
c929f3b
fix(mcp): address codex P1/P2 review feedback on PR #28 (#1044)
2015kmadanap May 23, 2026
d4fe0f1
fix(mcp): restore suppressFocus core plumbing to Target.createTarget …
2015kmadanap May 23, 2026
2d31a44
fix(stealth): re-add AutomationControlled disable after upstream assi…
2015kmadanap May 23, 2026
94c261b
fix(stealth): gate _updateUserAgentBrands on skipDefaultOverrides
2015kmadanap May 23, 2026
f3b63df
fix(mcp): wire browser_trigger_print through Path D bridge
2015kmadanap May 23, 2026
b892dc2
test(mcp): add FocusShim C5 regression spec (18 scenarios)
2015kmadanap May 23, 2026
b6ce24c
fix(mcp): re-add --keep-browser-alive flag (no-op) to keep Sapoto run…
2015kmadanap May 23, 2026
4d43286
fix(mcp): decouple FocusShim/Path D install from stealth gate (#1044 P0)
2015kmadanap May 23, 2026
5a0053c
fix(mcp): restore C3 deferred-print gate to stealth (#1044, addresses…
2015kmadanap May 23, 2026
f5c7eb4
A1: BrowserOptions cdpStealth shape + channel propagation (PRD #1045)…
2015kmadanap May 23, 2026
f77a378
feat(mcp): replace FocusShim fetch() with [FocusShim] background-open…
2015kmadanap May 23, 2026
504eca1
A4: Utility-world rename to opaque 16-char hex token (PRD #1045) (#31)
2015kmadanap May 23, 2026
237820a
A5: stealthInitScript section-gating (printCapture, chromeRuntimeStub…
2015kmadanap May 23, 2026
641bd2a
A3: CDP gating decompose β€” per-feature gates + new worker-runtime cyc…
2015kmadanap May 23, 2026
256ec14
A6: RawMouse.click sequential await (move β†’ down β†’ up) (PRD #1045) (#34)
2015kmadanap May 23, 2026
58aec1e
A2: Fork MCP CLI flag surface β€” --cdp-stealth + 3 booleans + aliases …
2015kmadanap May 23, 2026
f75885f
fix(mcp): filter Sapoto-bridge hidden CDP targets from browser_tabs l…
2015kmadanap May 24, 2026
67a8491
fix(mcp): version Sapoto background-target marker (V1 token) + correc…
2015kmadanap May 24, 2026
2c2e7fa
fix(mcp): address codex P1/P2 findings β€” UA locale, trigger_print mes…
2015kmadanap May 24, 2026
fd73dfd
docs: add stealth principles reference and update CLAUDE.md for fork
2015kmadanap May 27, 2026
53e59fb
fix(stealth): remove Red-tier JS stealth patches from init script (Tr…
2015kmadanap May 27, 2026
00acdec
fix(lint): remove unused resolveFetch, fix comment spacing in focus-s…
2015kmadanap May 28, 2026
de02122
fix(lint): reorder @isomorphic/cdpStealthCLIParser imports per import…
2015kmadanap May 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 101 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,50 @@
### Monorepo Packages
# sapoto-playwright

Fork of [microsoft/playwright](https://github.com/microsoft/playwright) maintained by Sapoto. The fork adds stealth and anti-detection capabilities for automating headed Chrome against financial portals protected by anti-bot systems (Cloudflare, DataDome, Akamai, etc.).

**Governing document: [`docs/stealth-principles.md`](docs/stealth-principles.md)** β€” read before any stealth-related work.

## Fork Architecture

```
upstream/main (microsoft/playwright)
β”‚
└──► origin/main (Sapoto fork β€” 29 commits ahead)
β”‚
β”œβ”€β”€ Launch-level stealth (Green)
β”‚ chromiumSwitches.ts β€” flag removal
β”‚ crUtilityWorldName.ts β€” randomized world names
β”‚
β”œβ”€β”€ CDP-level stealth (Yellow)
β”‚ cdpStealthGates.ts β€” per-feature kill switches
β”‚ crPage.ts β€” Runtime cycling, Log skip, UA-CH
β”‚ crServiceWorker.ts β€” worker stealth
β”‚ chromeUaBrands.ts β€” UA-CH brand builder
β”‚
β”œβ”€β”€ JS-level patches (Red β€” last resort)
β”‚ stealthInitScript.ts β€” 740 LOC, gated sections
β”‚
β”œβ”€β”€ MCP extensions
β”‚ context.ts β€” stealth injection + focus shim
β”‚ config.ts / program.ts β€” CLI flags
β”‚ pdf.ts, screenshot.ts, pmAutofillPreflight.ts
β”‚
└── Input humanization
bezierInput.ts β€” BΓ©zier mouse paths
crInput.ts β€” sequential click events
```

### Stealth Risk Tiers (from stealth-principles.md Β§5)

| Tier | What | Rule |
|------|------|------|
| **Green** β€” Launch-level | Chrome flags, switches, profile config | Preferred. Must match stock Chrome behavior. |
| **Yellow** β€” CDP-level | Runtime cycling, Log skip, UA-CH override, gate changes | Caution. Version-test against target Chromium. |
| **Red** β€” JS patches | `stealthInitScript.ts`, any main-world mutation | Last resort. Must be gated, portal-scoped, and justified. |

**When adding or modifying stealth features, classify the change by tier and follow the corresponding guidance in `docs/stealth-principles.md`.**

## Monorepo Packages

| Package | npm name | Purpose |
|---------|----------|---------|
Expand Down Expand Up @@ -34,9 +80,28 @@
| `tests/` | All test suites (page, library, playwright-test, mcp, components, etc.) |
| `docs/src/` | API documentation β€” **source of truth** for public TypeScript types |
| `docs/src/api/` | Per-class API reference (`class-page.md`, `class-locator.md`, etc.) |
| `docs/stealth-principles.md` | Anti-detection design principles (Sapoto fork) |
| `utils/` | Build scripts, code generation, linting, doc tools |
| `browser_patches/` | Browser engine patches |

## Sapoto-Specific Key Files

| File | Role |
|------|------|
| `packages/playwright-core/src/server/chromium/cdpStealthGates.ts` | Per-feature kill switches (runtime-cycle, log-skip, ua-brands, webdriver-delete, etc.) |
| `packages/playwright-core/src/server/chromium/crPage.ts` | CDP orchestration: Runtime enable/disable, Log skip, UA-CH, utility world |
| `packages/playwright-core/src/server/chromium/crServiceWorker.ts` | Worker stealth gates |
| `packages/playwright-core/src/server/chromium/chromiumSwitches.ts` | Launch flag removal |
| `packages/playwright-core/src/server/chromium/chromeUaBrands.ts` | UA-CH brand list builder |
| `packages/playwright-core/src/server/chromium/crUtilityWorldName.ts` | Opaque 16-char hex world names |
| `packages/playwright-core/src/tools/backend/stealthInitScript.ts` | Main-world JS patches (gated sections) |
| `packages/playwright-core/src/tools/backend/context.ts` | MCP context: stealth injection, focus shim, background-open |
| `packages/playwright-core/src/server/cdpStealth.ts` | CDP stealth coordination module |
| `packages/isomorphic/cdpStealthCLIParser.ts` | CLI flag parsing for `--cdp-stealth` |
| `packages/isomorphic/cdpStealthAlias.ts` | Gate alias resolution |
| `packages/playwright-core/src/server/chromium/bezierInput.ts` | Humanized BΓ©zier mouse paths |
| `packages/playwright-core/src/tools/backend/pmAutofillPreflight.ts` | Password manager autofill preflight |

## Build

```bash
Expand All @@ -61,7 +126,7 @@ Runs all lint checks in parallel: eslint, tsc, doclint, check-deps, generate_cha
| Command | Scope |
|---------|-------|
| `npm run ctest <filter>` | Chromium only library tests β€” **use during development** |
| `npm run test <filter> -- --project=<chromium,firefix,webkit>` | All library / per project |
| `npm run test <filter> -- --project=<chromium,firefox,webkit>` | All library / per project |
| `npm run ttest <filter>` | Test runner (`tests/playwright-test/`) |
| `npm run ctest-mcp <filter>` | Chromium only MCP tools (`tests/mcp/`) |
| `npm run test-mcp <filter> -- --project=<chromium,firefox,webkit>` | MCP tools (`tests/mcp/`) |
Expand All @@ -87,6 +152,24 @@ npm run ctest-mcp snapshot # By file name part

**Decision rule**: Does the test need `browser`/`browserType`/`context` β†’ `tests/library/`. Just needs `page` + `server` β†’ `tests/page/`.

### Stealth Tests (Sapoto)

| Test file | What it validates |
|-----------|-------------------|
| `tests/library/cdp-stealth-gates.spec.ts` | Gate enable/disable behavior, per-feature isolation |
| `tests/library/cdp-stealth-options.spec.ts` | CLI option parsing and propagation |
| `tests/library/stealth-stubs.spec.ts` | No Playwright globals leaked, stub correctness |
| `tests/library/utility-world-name.spec.ts` | World name randomization, no framework name leak |
| `tests/library/utility-world-name-leak.spec.ts` | Cross-frame world name isolation |
| `tests/library/focus-shim-c5.spec.ts` | FocusShim regression (18 scenarios) |
| `tests/library/srcdoc-print-bridge.spec.ts` | Print bridge via srcdoc iframe |
| `tests/library/bezier-input.spec.ts` | Humanized mouse path generation |
| `tests/library/humanize-input-channel.spec.ts` | Input humanization channel propagation |
| `tests/library/mcp-cli-flag-surface.spec.ts` | CLI flag surface for `--cdp-stealth` |
| `tests/mcp/pm-autofill-preflight.spec.ts` | Password manager autofill detection |

**Stealth test philosophy (from `docs/stealth-principles.md` Β§7):** Tests must prove the fork is indistinguishable from stock Chrome, not merely that patches applied their values. Always test cross-surface consistency (main frame, iframe, popup, worker).

## DEPS System

Import boundaries are enforced via `DEPS.list` files (52+ across the repo), checked by `npm run flint`.
Expand Down Expand Up @@ -123,7 +206,7 @@ EOF
)"
# **Never `git push` without an explicit instruction to push.**
git push origin fix-39562
gh pr create --repo microsoft/playwright --head username:fix-39562 \
gh pr create --repo Sapoto-Health/sapoto-playwright --head fix-39562 \
--title "fix(proxy): handle SOCKS proxy authentication" \
--body "$(cat <<'EOF'
## Summary
Expand All @@ -143,6 +226,20 @@ Branch naming for issue fixes: `fix-<issue-number>`

**Never `git push` without an explicit instruction to push.** Applies even when a PR is already open for the branch β€” additional commits are immediately visible to reviewers. Commit locally, report what was committed, and wait. Only push when the user's message contains "push", "upload", "create PR", "ship it", or equivalent.

**PRs always target `Sapoto-Health/sapoto-playwright`** β€” always pass `--repo Sapoto-Health/sapoto-playwright` to `gh pr create`. The fork has both `origin` (Sapoto) and `upstream` (microsoft) remotes; omitting `--repo` may target the wrong repository.

## Stealth Development Rules

1. **Read `docs/stealth-principles.md` before any stealth work.** It is the governing document.
2. **Classify every change by risk tier** (Green/Yellow/Red). State the tier in the commit message scope, e.g., `feat(stealth-green): ...`, `fix(stealth-red): ...`.
3. **Every new stealth feature must have a gate** in `cdpStealthGates.ts`. No ungated stealth code.
4. **Burden of proof is on the patch.** A new JS-level (Red) patch must document: what portal breaks without it, why a Green or Yellow approach won't work, and what detection surface the patch creates.
5. **No `Function.prototype.toString` patches** unless all alternatives are exhausted and the patch is gated.
6. **No console bridges** for automation control except portal-scoped operational needs.
7. **Cross-surface consistency is mandatory.** A change to main-frame behavior must also cover iframes, popups, workers, and service workers where applicable.
8. **UA-CH is correlated metadata.** Never override a single field; ensure UA string, `sec-ch-ua-*`, `navigator.userAgentData`, platform, `Accept-Language`, and locale all agree.
9. **Tests compare against stock Chrome**, not hardcoded expected values. See Β§7 of the principles doc.

## Development Guides

Detailed guides for common development tasks:
Expand All @@ -151,3 +248,4 @@ Detailed guides for common development tasks:
- **[Adding and Modifying APIs](.claude/skills/playwright-dev/api.md)** β€” 6-step process: define docs β†’ implement client β†’ define protocol β†’ implement dispatcher β†’ implement server β†’ write tests
- **[MCP Tools and CLI Commands](.claude/skills/playwright-dev/tools.md)** β€” `defineTool()`/`defineTabTool()`, tool capabilities, CLI `declareCommand()`, config options, testing with MCP fixtures
- **[Vendoring Dependencies](.claude/skills/playwright-dev/vendor.md)** β€” bundle architecture, esbuild setup, typed wrappers, adding deps to existing bundles
- **[Stealth Principles](docs/stealth-principles.md)** β€” anti-detection design principles, threat model, CDP risks, risk classification, implementation checklist, testing philosophy
Loading
Loading