Booking.com adapter for browserkit. Requires login. Provides upcoming/past bookings, property search, availability, and reviews.
- Language: TypeScript 5.x → compiled to
dist/ - Runtime: Node.js 20+
- Browser: Patchright (Playwright fork, anti-detection) via
@browserkit-dev/core - Key deps:
@browserkit-dev/core(peer),patchright(peer),zod
src/
index.ts # adapter definition — tools, isLoggedIn, selectors, rateLimit
scraper.ts # DOM extraction helpers
selectors.ts# CSS/ARIA selectors (edit here when site DOM changes)
tests/
booking.test.ts # L1 unit — metadata, schemas, helpers (no browser)
booking.integration.test.ts# L2 live scraping — real browser, real network
mcp-protocol.test.ts # L3 MCP protocol — server lifecycle, tool dispatch
harness.test.ts # Harness guards — isLoggedIn contract, pkg.json checks
dist/ # compiled output (gitignored; included in npm publish via "files")
npm install # install deps
npm run build # tsc → dist/
npm test # unit + harness tests (no browser)
npm run test:integration # live browser tests (requires internet + login)
make agent-check # full verification gate — run before declaring doneisLoggedInmust returnfalseby default when not authenticated — never use body-content length, cookie presence, or other heuristics; only returntruewhen a specific auth element is confirmed present (a hard lesson:bodyText.length > 100matched the public homepage).- Auth selectors must be exclusive to logged-in state — never
[aria-label*="account"](matches "Create an account" and other public nav). Usedata-testidordata-component. package.jsonmust have"files": ["dist", "README.md"]— without it, npm follows.gitignoreand ships source-only packages that the daemon can't load.repository.urlrequired — npm provenance rejects publishes without it.prepublishOnly: "tsc"— ensuresdist/is always rebuilt beforenpm publish.- Selectors belong in
selectors.ts— never hardcode CSS strings inindex.tsorscraper.ts. - No
anytypes — useunknownwith type narrowing or Zod schemas. accountMenuselector must usedata-testid/data-componentonly —[aria-label*="account"]matched the public "Create an account" button, causingisLoggedInto returntruefor unauthenticated sessions.isLoggedInmust returnfalseby default — the oldbodyText.length > 100fallback was wrong; Booking.com homepage body is always > 100 chars.- Use
www.booking.comfor session cookies —secure.booking.comrequires a?sid=query param embedded in the homepage.
A task is complete when ALL of the following pass:
-
npm run buildexits 0 (no TypeScript errors) -
npm testpasses (L1 unit + harness tests, no browser needed) -
make agent-checkpasses (build + test in one command) -
npm pack --dry-runshowsdist/files in the tarball -
isLoggedInharness test passes with mock page (no regression)
- Architecture:
../../ARCH.md(monorepo) orREADME.mdin this repo - Selector maintenance: update
src/selectors.tswhen the site changes DOM - Publishing: push to
main→ CI builds and publishes via OIDC (no token needed)